Skip to content

Instantly share code, notes, and snippets.

View sebilasse's full-sized avatar

Sebastian Lasse sebilasse

View GitHub Profile
@sebilasse
sebilasse / local.ts
Created October 22, 2025 01:30
further local infos for IntlToActivityPub
// languages which Intl does not support have an own module not covered here, set customExtended = {}:
import { customExtended } from './optionalExtended.ts';
const op = (w) => w.replace(/^[(]/, '(?:');
const rd = (fn) => (r, w, i, a) => (i > 19 ? [...r, w, ...a.slice(1, 10).map((w1) => fn(w, w1))] : [...r, w]);
const r = (a, mapFn) => new RegExp(`\\b(?:${(mapFn ? a.map(mapFn) : a).join('\\b|')})`, 'gi');
const esPt = [
'(nullo?|zero)', '(uno|uma?)', '(doi?s|duas)', '(tr[eê]s)', '([qc]uatro)', '(cinco)', '(seis)', '(si?ete)',
'(ocho|oito)', '(nueve|nove)', '(di?ez)', '(once)', '(doce)', '(tre[cz]e)', '(cator[cz]e)',
@sebilasse
sebilasse / IntlToActivitypub.ts
Last active October 22, 2025 02:03
IntlToActivitypub - for reference - converts JS Intl to Regexes which are used in the ActivityPub Parser
// see below
import { intlLocales, cardinalSuffix, isS, isNr, ok, calcTime, toTimeInt } from './shared.ts';
import { custom, dateCasual, dateCasualKeys } from './local.ts';
const IS_SERVER = (typeof document === 'undefined');
let m49regionMissing; let m49regionMap;
if (IS_SERVER) {
m49regionMissing = (await import('./m49.ts')).m49regionMissing;
m49regionMap = (await import('./m49.ts')).m49regionMap;
import { custom, extend, localeFormats, regexPattern } from './constants.ts';
const timeZone = 'Europe/Berlin';
const base = [
{ l: [ 'ar-AE','ar-BH','ar-DZ','ar-EG','ar-IQ','ar-JO','ar-KW','ar-LB','ar-LY','ar-MA','ar-OM','ar-QA','ar-SA','ar-SY','ar-TN','ar-YE'],
o: { am: 'ص', pm: 'م' } },
{ l: [ 'cy-GB','en-NZ','es-AR','es-BO','es-CO','es-CR','es-DO','es-GT','es-HN','es-MX','es-NI',
'es-PA','es-PE','es-PR','es-PY','es-SV','es-UY','es-VE','gl-ES','mi-NZ','quz-BO','quz-PE' ],
o: { am: 'a.m.', pm: 'p.m.' } },
{ l: [ 'en-029','en-AU','en-BZ','en-CA','en-GB','en-JM','en-PH','en-TT','en-US','en-ZA',
'en-ZW','he-IL','mt-MT','ns-ZA','sw-KE','th-TH','tn-ZA','ur-PK','xh-ZA', 'zh-SG','zu-ZA' ],
@sebilasse
sebilasse / donotuse.ts
Last active May 20, 2025 16:23
Preview kv to as, currently bugs
declare global {
var Deno: any;
}
import { createFederation, Activity, exportJwk, generateCryptoKeyPair, importJwk, MemoryKvStore } from "@fedify/fedify";
import { Patch, AsFnDef, PromiseAs, VersionId, ScopeStatus, Status, HREF } from './kvInterfaces.ts';
import { AsObjectNormalized, normalize, shrinkToId, asId, hasAnyType, hasAllTypes, isActivity, findKeyAndType } from "@AS";
import { SimilarityKV } from '@/API/base/String/similarity.ts';
import { hrefToAs } from '@/API/Link/index.ts';
import { encode } from '@/API/Place/geohash.ts';
import { ulid: setUlid, monotonicUlid, decodeTime } from "jsr:@std/ulid";
@sebilasse
sebilasse / wikiUtil.ts
Created March 7, 2025 11:23
wd utils (v1.1) to `as`, as described to max in fedi
import { AsObjectNormalized } from "@AS";
import { HEADERS } from "@/lib/constants.ts";
import { createHash } from "https://deno.land/[email protected]/hash/mod.ts";
export interface WikiPropertyVar {
name: string;
property: string;
container: string | string[];
type: string | string[];
functional: boolean;
@sebilasse
sebilasse / wikidataToAS.ts
Last active March 7, 2025 11:24
abstracted wd (v1.1) to `as`, as described to max in fedi
import { Redaktor } from "@/API/context/index.ts"; // Context Factory
import { AsLinkObject } from "@AS"; // Type
import { WBK, simplifySnak, simplifyQualifiers } from "https://esm.sh/[email protected]";
import wellKnownIDS from "@/data/wellKnownIDS.json" with { type: "json" };
// useful for well known ids like ISO, ISBN etc ... {"Q142": "FR" ... ...}
import { wdPropertyToAS, wdToNameQualifier } from "@/data/PROPERTY/_PROPERTY.ts";
// what goes to as containers like image, icon, attachment etc. and which Qualifiers to use ...
// first parser result with qualified statements and Quantity / Unit // WIP ...
{
"type": [
"Place",
"redaktor:Factual",
"redaktor:Topic",
"wd:Q3624078",
"wd:Q6256",
"redaktor:ADM0",
@sebilasse
sebilasse / osmToASPlace.ts
Created January 9, 2025 19:58
OSM Place to ActivityPub (WIP)
import { AsLocation, AsLinkObject, AsObjectNormalized } from "@AS";
import { OsmRes, NominatimRes, NominatimLookup } from '../interfaces.d.ts';
import { ASUnits } from "../context/index.ts";
import { getSitelinkUrl } from "../wikidata.ts";
export interface LocationFeatureSpecification {
/* amenity */
propertyID?: string;
/* restaurant */
value?: any; /* string | boolean | number | https://schema.org/StructuredValue; */
/* osm:979019920 */
@sebilasse
sebilasse / ActivityPubNormalize.ts
Last active January 5, 2025 11:05
Normalize and inflate ActivityPub
import { IS_BROWSER } from "$fresh/runtime.ts";
import {
APall, RedaktorActor, AsActivity, AsObject,
AsObjectNormalized, AsLinkObject, AsCollection
} from './interfaces.d.ts';
import {
AsActors, AsActivities, AsObjects, AsLinks
} from './ActivityPubInfo.ts';
import { Object as asObject } from "jsr:@fedify/fedify";
import DOMPurify from '$dompurify';
import plugin from 'tailwindcss/plugin';
// const maxScreenWidth = 3800;
const maxContainerWidth = 640;
const media = {
square: { min: 305, dif: 21, start: 15, '--l': '15', '--apt': '100%', '--ar': '1 / 1' }
};
const ratios = [ // [w,h]
// landscape