Compare commits

...

4 commits

Author SHA1 Message Date
Alex Gleason
24ab3a2be0 Merge branch 'deno-2.3.1' into 'main'
Deno v2.3.1

See merge request soapbox-pub/ditto!736
2025-06-05 11:09:15 +00:00
Alex Gleason
24d27c4cdd
Index I/i tags 2025-06-01 19:45:36 -05:00
Alex Gleason
96799d1918
Index kind 1111 tags 2025-06-01 14:45:29 -05:00
Alex Gleason
4594f2dbeb
Deno v2.3.1 2025-05-03 03:02:08 -05:00
5 changed files with 52 additions and 18 deletions

View file

@ -1,4 +1,4 @@
image: denoland/deno:2.2.2 image: denoland/deno:2.3.1
default: default:
interruptible: true interruptible: true

View file

@ -1 +1 @@
deno 2.2.2 deno 2.3.1

View file

@ -80,15 +80,20 @@ export class DittoPgStore extends NPostgres {
/** Conditions for when to index certain tags. */ /** Conditions for when to index certain tags. */
static tagConditions: Record<string, TagCondition> = { static tagConditions: Record<string, TagCondition> = {
'A': ({ count }) => count === 0,
'E': ({ count, value }) => count === 0 && isNostrId(value),
'I': ({ count }) => count === 0,
'K': ({ count, value }) => count === 0 && Number.isInteger(Number(value)),
'L': ({ event, count }) => event.kind === 1985 || count === 0,
'P': ({ count, value }) => count === 0 && isNostrId(value),
'a': ({ count }) => count < 15, 'a': ({ count }) => count < 15,
'client': ({ count, value }) => count === 0 && value.length < 50, 'client': ({ count, value }) => count === 0 && value.length < 50,
'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind), 'd': ({ event, count }) => count === 0 && NKinds.parameterizedReplaceable(event.kind),
'e': DittoPgStore.eTagCondition, 'e': DittoPgStore.eTagCondition,
'i': ({ count }) => count < 15,
'k': ({ count }) => count < 3, 'k': ({ count }) => count < 3,
'L': ({ event, count }) => event.kind === 1985 || count === 0,
'l': ({ event, count }) => event.kind === 1985 || count === 0, 'l': ({ event, count }) => event.kind === 1985 || count === 0,
'n': ({ count, value }) => count < 50 && value.length < 50, 'n': ({ count, value }) => count < 50 && value.length < 50,
'P': ({ count, value }) => count === 0 && isNostrId(value),
'p': DittoPgStore.pTagCondition, 'p': DittoPgStore.pTagCondition,
'proxy': ({ count, value }) => count === 0 && value.length < 256, 'proxy': ({ count, value }) => count === 0 && value.length < 256,
'q': ({ event, count, value }) => count === 0 && event.kind === 1 && isNostrId(value), 'q': ({ event, count, value }) => count === 0 && event.kind === 1 && isNostrId(value),

View file

@ -28,7 +28,9 @@ export function contentToHtml(content: string, mentions: MastodonMention[], opts
hashtag: ({ content }) => { hashtag: ({ content }) => {
const tag = content.replace(/^#/, ''); const tag = content.replace(/^#/, '');
const href = conf.local(`/tags/${tag}`); const href = conf.local(`/tags/${tag}`);
return html`<a class="mention hashtag" href="${href}" rel="tag"><span>#</span>${tag}</a>`; return html`
<a class="mention hashtag" href="${href}" rel="tag"><span>#</span>${tag}</a>
`;
}, },
url: ({ attributes, content }) => { url: ({ attributes, content }) => {
try { try {
@ -47,7 +49,10 @@ export function contentToHtml(content: string, mentions: MastodonMention[], opts
const acct = mention?.acct ?? npub; const acct = mention?.acct ?? npub;
const name = mention?.acct ?? npub.substring(0, 8); const name = mention?.acct ?? npub.substring(0, 8);
const href = mention?.url ?? conf.local(`/@${acct}`); const href = mention?.url ?? conf.local(`/@${acct}`);
return html`<span class="h-card"><a class="u-url mention" href="${href}" rel="ugc">@<span>${name}</span></a></span>${extra}`; return html`
<span class="h-card"><a class="u-url mention" href="${href}" rel="ugc">@<span
>${name}</span></a></span>${extra}
`;
} else { } else {
return ''; return '';
} }

View file

@ -21,34 +21,58 @@ export function renderMetadata(url: string, { account, status, instance }: Metad
const height = attachment?.meta?.original?.height; const height = attachment?.meta?.original?.height;
if (title) { if (title) {
tags.push(html`<title>${title}</title>`); tags.push(html`
tags.push(html`<meta property="og:title" content="${title}">`); <title>${title}</title>
tags.push(html`<meta name="twitter:title" content="${title}">`); `);
tags.push(html`
<meta property="og:title" content="${title}">
`);
tags.push(html`
<meta name="twitter:title" content="${title}">
`);
} }
if (description) { if (description) {
tags.push(html`<meta name="description" content="${description}">`); tags.push(html`
tags.push(html`<meta property="og:description" content="${description}">`); <meta name="description" content="${description}">
tags.push(html`<meta name="twitter:description" content="${description}">`); `);
tags.push(html`
<meta property="og:description" content="${description}">
`);
tags.push(html`
<meta name="twitter:description" content="${description}">
`);
} }
if (image) { if (image) {
tags.push(html`<meta property="og:image" content="${image}">`); tags.push(html`
tags.push(html`<meta name="twitter:image" content="${image}">`); <meta property="og:image" content="${image}">
`);
tags.push(html`
<meta name="twitter:image" content="${image}">
`);
} }
if (typeof width === 'number' && typeof height === 'number') { if (typeof width === 'number' && typeof height === 'number') {
tags.push(html`<meta property="og:image:width" content="${width}">`); tags.push(html`
tags.push(html`<meta property="og:image:height" content="${height}">`); <meta property="og:image:width" content="${width}">
`);
tags.push(html`
<meta property="og:image:height" content="${height}">
`);
} }
if (siteName) { if (siteName) {
tags.push(html`<meta property="og:site_name" content="${siteName}">`); tags.push(html`
<meta property="og:site_name" content="${siteName}">
`);
} }
// Extra tags (always present if other tags exist). // Extra tags (always present if other tags exist).
if (tags.length > 0) { if (tags.length > 0) {
tags.push(html`<meta property="og:url" content="${url}">`); tags.push(html`
<meta property="og:url" content="${url}">
`);
tags.push('<meta property="og:type" content="website">'); tags.push('<meta property="og:type" content="website">');
tags.push('<meta name="twitter:card" content="summary">'); tags.push('<meta name="twitter:card" content="summary">');
} }