@geekity/cms 0.34.0 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/components/job-status.njk +15 -10
- package/admin/components/upload.njk +26 -0
- package/admin/pages/documents/chooser.njk +30 -0
- package/admin/pages/documents/editor.njk +410 -165
- package/admin/pages/federation/followers.njk +2 -1
- package/admin/pages/media/file.njk +143 -0
- package/admin/pages/media/library.njk +107 -198
- package/admin/pages/settings/general.njk +52 -2
- package/admin/pages/settings/privacy.njk +1 -1
- package/admin/pages/tools/export.njk +54 -51
- package/admin/pages/tools/maintenance.njk +49 -0
- package/admin/pages/users/edit.njk +3 -0
- package/admin/src/admin.css +2 -0
- package/admin/static/admin.css +843 -106
- package/admin/static/copy.js +30 -23
- package/admin/static/item-lookup.js +179 -0
- package/admin/static/job-status.js +158 -0
- package/admin/static/media.js +82 -0
- package/admin/static/upload-drop.js +225 -0
- package/dist/admin/documents.d.ts.map +1 -1
- package/dist/admin/documents.js +141 -24
- package/dist/admin/documents.js.map +1 -1
- package/dist/admin/editor-actions.d.ts.map +1 -1
- package/dist/admin/editor-actions.js +2 -3
- package/dist/admin/editor-actions.js.map +1 -1
- package/dist/admin/editor-fields.d.ts +20 -8
- package/dist/admin/editor-fields.d.ts.map +1 -1
- package/dist/admin/editor-fields.js +35 -12
- package/dist/admin/editor-fields.js.map +1 -1
- package/dist/admin/editor-kinds.d.ts +30 -0
- package/dist/admin/editor-kinds.d.ts.map +1 -0
- package/dist/admin/editor-kinds.js +136 -0
- package/dist/admin/editor-kinds.js.map +1 -0
- package/dist/admin/editor-layout.d.ts +10 -1
- package/dist/admin/editor-layout.d.ts.map +1 -1
- package/dist/admin/editor-layout.js +38 -31
- package/dist/admin/editor-layout.js.map +1 -1
- package/dist/admin/federation.d.ts +1 -1
- package/dist/admin/federation.d.ts.map +1 -1
- package/dist/admin/federation.js +2 -1
- package/dist/admin/federation.js.map +1 -1
- package/dist/admin/formatting.d.ts +2 -0
- package/dist/admin/formatting.d.ts.map +1 -1
- package/dist/admin/formatting.js +8 -0
- package/dist/admin/formatting.js.map +1 -1
- package/dist/admin/index.d.ts +1 -1
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/item-lookup.d.ts +16 -0
- package/dist/admin/item-lookup.d.ts.map +1 -0
- package/dist/admin/item-lookup.js +192 -0
- package/dist/admin/item-lookup.js.map +1 -0
- package/dist/admin/job-status.d.ts +1 -0
- package/dist/admin/job-status.d.ts.map +1 -1
- package/dist/admin/job-status.js +1 -0
- package/dist/admin/job-status.js.map +1 -1
- package/dist/admin/maintenance.d.ts +2 -0
- package/dist/admin/maintenance.d.ts.map +1 -1
- package/dist/admin/maintenance.js +14 -0
- package/dist/admin/maintenance.js.map +1 -1
- package/dist/admin/media.d.ts +47 -36
- package/dist/admin/media.d.ts.map +1 -1
- package/dist/admin/media.js +293 -68
- package/dist/admin/media.js.map +1 -1
- package/dist/admin/preview.d.ts.map +1 -1
- package/dist/admin/preview.js +9 -12
- package/dist/admin/preview.js.map +1 -1
- package/dist/admin/routes.d.ts.map +1 -1
- package/dist/admin/routes.js +4 -0
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/settings-general.d.ts +6 -0
- package/dist/admin/settings-general.d.ts.map +1 -1
- package/dist/admin/settings-general.js +46 -1
- package/dist/admin/settings-general.js.map +1 -1
- package/dist/admin/templates.d.ts +2 -0
- package/dist/admin/templates.d.ts.map +1 -1
- package/dist/admin/templates.js +4 -0
- package/dist/admin/templates.js.map +1 -1
- package/dist/admin/uploads.d.ts +2 -1
- package/dist/admin/uploads.d.ts.map +1 -1
- package/dist/admin/uploads.js +5 -2
- package/dist/admin/uploads.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/cms/app.d.ts.map +1 -1
- package/dist/cms/app.js +1 -0
- package/dist/cms/app.js.map +1 -1
- package/dist/cms/services.d.ts +2 -0
- package/dist/cms/services.d.ts.map +1 -1
- package/dist/cms/services.js +13 -0
- package/dist/cms/services.js.map +1 -1
- package/dist/content/document-form.d.ts +5 -13
- package/dist/content/document-form.d.ts.map +1 -1
- package/dist/content/document-form.js +2 -3
- package/dist/content/document-form.js.map +1 -1
- package/dist/content/excerpt.d.ts +1 -3
- package/dist/content/excerpt.d.ts.map +1 -1
- package/dist/content/excerpt.js +2 -7
- package/dist/content/excerpt.js.map +1 -1
- package/dist/content/post-fields.d.ts +1 -1
- package/dist/content/post-fields.d.ts.map +1 -1
- package/dist/content/post-fields.js +30 -35
- package/dist/content/post-fields.js.map +1 -1
- package/dist/content/post-type.d.ts +2 -3
- package/dist/content/post-type.d.ts.map +1 -1
- package/dist/content/post-type.js +8 -9
- package/dist/content/post-type.js.map +1 -1
- package/dist/content/review-form.d.ts +49 -0
- package/dist/content/review-form.d.ts.map +1 -0
- package/dist/content/review-form.js +282 -0
- package/dist/content/review-form.js.map +1 -0
- package/dist/content/review.d.ts +57 -0
- package/dist/content/review.d.ts.map +1 -0
- package/dist/content/review.js +264 -0
- package/dist/content/review.js.map +1 -0
- package/dist/content/write.d.ts.map +1 -1
- package/dist/content/write.js +6 -9
- package/dist/content/write.js.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/federation/article.d.ts.map +1 -1
- package/dist/federation/article.js +27 -29
- package/dist/federation/article.js.map +1 -1
- package/dist/federation/federation.d.ts +3 -0
- package/dist/federation/federation.d.ts.map +1 -1
- package/dist/federation/federation.js +5 -1
- package/dist/federation/federation.js.map +1 -1
- package/dist/federation/refusals.d.ts +18 -0
- package/dist/federation/refusals.d.ts.map +1 -0
- package/dist/federation/refusals.js +84 -0
- package/dist/federation/refusals.js.map +1 -0
- package/dist/images/variants.d.ts +1 -0
- package/dist/images/variants.d.ts.map +1 -1
- package/dist/images/variants.js +10 -0
- package/dist/images/variants.js.map +1 -1
- package/dist/item-lookup/item-id.d.ts +33 -0
- package/dist/item-lookup/item-id.d.ts.map +1 -0
- package/dist/item-lookup/item-id.js +71 -0
- package/dist/item-lookup/item-id.js.map +1 -0
- package/dist/item-lookup/lookup.d.ts +58 -0
- package/dist/item-lookup/lookup.d.ts.map +1 -0
- package/dist/item-lookup/lookup.js +532 -0
- package/dist/item-lookup/lookup.js.map +1 -0
- package/dist/media/library.d.ts +9 -0
- package/dist/media/library.d.ts.map +1 -1
- package/dist/media/library.js +25 -1
- package/dist/media/library.js.map +1 -1
- package/dist/micropub/create.d.ts +1 -1
- package/dist/micropub/create.d.ts.map +1 -1
- package/dist/micropub/create.js +4 -2
- package/dist/micropub/create.js.map +1 -1
- package/dist/micropub/endpoint.d.ts.map +1 -1
- package/dist/micropub/endpoint.js +3 -10
- package/dist/micropub/endpoint.js.map +1 -1
- package/dist/micropub/update.d.ts.map +1 -1
- package/dist/micropub/update.js +12 -6
- package/dist/micropub/update.js.map +1 -1
- package/dist/plugin.d.ts +26 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/settings/names.d.ts +1 -1
- package/dist/settings/names.d.ts.map +1 -1
- package/dist/settings/names.js +8 -1
- package/dist/settings/names.js.map +1 -1
- package/dist/settings/registry.d.ts.map +1 -1
- package/dist/settings/registry.js +2 -1
- package/dist/settings/registry.js.map +1 -1
- package/dist/settings/tmdb.d.ts +5 -0
- package/dist/settings/tmdb.d.ts.map +1 -0
- package/dist/settings/tmdb.js +22 -0
- package/dist/settings/tmdb.js.map +1 -0
- package/dist/store/profiles.d.ts +3 -2
- package/dist/store/profiles.d.ts.map +1 -1
- package/dist/store/profiles.js +2 -4
- package/dist/store/profiles.js.map +1 -1
- package/dist/web/context.d.ts +9 -21
- package/dist/web/context.d.ts.map +1 -1
- package/dist/web/context.js +20 -20
- package/dist/web/context.js.map +1 -1
- package/dist/web/feed-item.d.ts +6 -6
- package/dist/web/feed-item.d.ts.map +1 -1
- package/dist/web/feed-item.js +7 -3
- package/dist/web/feed-item.js.map +1 -1
- package/dist/web/plugin-federation.d.ts +2 -0
- package/dist/web/plugin-federation.d.ts.map +1 -1
- package/dist/web/plugin-federation.js +3 -0
- package/dist/web/plugin-federation.js.map +1 -1
- package/dist/webmention/cited-picture.d.ts +1 -0
- package/dist/webmention/cited-picture.d.ts.map +1 -1
- package/dist/webmention/cited-picture.js +7 -4
- package/dist/webmention/cited-picture.js.map +1 -1
- package/dist/webmention/fetch-public.d.ts +3 -0
- package/dist/webmention/fetch-public.d.ts.map +1 -1
- package/dist/webmention/fetch-public.js +1 -1
- package/dist/webmention/fetch-public.js.map +1 -1
- package/dist/webmention/reply-context/json-ld.d.ts +8 -0
- package/dist/webmention/reply-context/json-ld.d.ts.map +1 -1
- package/dist/webmention/reply-context/json-ld.js +21 -0
- package/dist/webmention/reply-context/json-ld.js.map +1 -1
- package/dist/webmention/service.d.ts.map +1 -1
- package/dist/webmention/service.js +3 -5
- package/dist/webmention/service.js.map +1 -1
- package/package.json +6 -1
- package/themes/default/layouts/post.njk +6 -5
- package/themes/default/partials/post-list.njk +15 -20
- package/themes/default/partials/review.njk +1 -0
- package/themes/default/src/style.css +24 -4
- package/themes/default/static/style.css +33 -5
- package/dist/comments/routes.d.ts +0 -65
- package/dist/comments/routes.d.ts.map +0 -1
- package/dist/comments/routes.js +0 -235
- package/dist/comments/routes.js.map +0 -1
- package/dist/content/media.d.ts +0 -85
- package/dist/content/media.d.ts.map +0 -1
- package/dist/content/media.js +0 -237
- package/dist/content/media.js.map +0 -1
- package/dist/content/read-form.d.ts +0 -31
- package/dist/content/read-form.d.ts.map +0 -1
- package/dist/content/read-form.js +0 -157
- package/dist/content/read-form.js.map +0 -1
- package/dist/content/read.d.ts +0 -29
- package/dist/content/read.d.ts.map +0 -1
- package/dist/content/read.js +0 -82
- package/dist/content/read.js.map +0 -1
- package/dist/export/export-archives.d.ts +0 -29
- package/dist/export/export-archives.d.ts.map +0 -1
- package/dist/export/export-archives.js +0 -88
- package/dist/export/export-archives.js.map +0 -1
- package/dist/federation/mount.d.ts +0 -53
- package/dist/federation/mount.d.ts.map +0 -1
- package/dist/federation/mount.js +0 -344
- package/dist/federation/mount.js.map +0 -1
- package/dist/mail/credentials.d.ts +0 -62
- package/dist/mail/credentials.d.ts.map +0 -1
- package/dist/mail/credentials.js +0 -86
- package/dist/mail/credentials.js.map +0 -1
- package/dist/site/setting-rows.d.ts +0 -45
- package/dist/site/setting-rows.d.ts.map +0 -1
- package/dist/site/setting-rows.js +0 -361
- package/dist/site/setting-rows.js.map +0 -1
- package/dist/site/settings-form.d.ts +0 -30
- package/dist/site/settings-form.d.ts.map +0 -1
- package/dist/site/settings-form.js +0 -54
- package/dist/site/settings-form.js.map +0 -1
- package/dist/site/site-json.d.ts +0 -38
- package/dist/site/site-json.d.ts.map +0 -1
- package/dist/site/site-json.js +0 -69
- package/dist/site/site-json.js.map +0 -1
- package/dist/webmention/routes.d.ts +0 -37
- package/dist/webmention/routes.d.ts.map +0 -1
- package/dist/webmention/routes.js +0 -75
- package/dist/webmention/routes.js.map +0 -1
- package/themes/default/partials/read.njk +0 -5
package/dist/comments/routes.js
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { CROSS_SITE_REFUSAL, crossSiteWrite, csrfTokenMatches } from '../web/session.js';
|
|
2
|
-
import { clientAddress, createLoginThrottle } from '../web/throttle.js';
|
|
3
|
-
import { documentSite } from '../admin/documents.js';
|
|
4
|
-
import { stringOrEmpty } from '../util/forms.js';
|
|
5
|
-
import { isServed } from '../content/served.js';
|
|
6
|
-
import { COMMENT_NOTICE_PARAM, COMMENT_NOTICES, COMMENT_POST_PATH, commentForm, refilledCommentForm, signedInCommentForm, valuesOf, } from './form.js';
|
|
7
|
-
import { commentPolicyOf, commentsOpen } from './policy.js';
|
|
8
|
-
import { commentAnchor, visibleReply } from './conversation.js';
|
|
9
|
-
import { COMMENT_FIELDS, COMMENT_RATE_LIMIT, COMMENT_RATE_WINDOW_SECONDS, submitComment, } from './submission.js';
|
|
10
|
-
import { submitReplyPost } from './reply-post.js';
|
|
11
|
-
import { commenterOf } from './viewer.js';
|
|
12
|
-
/**
|
|
13
|
-
* The one public endpoint comments add: where the form under a post posts to.
|
|
14
|
-
*
|
|
15
|
-
* It is a single path rather than one per post because the post is a field of
|
|
16
|
-
* the form. That keeps it out of the way of every permalink a site might ever
|
|
17
|
-
* mint — a path under `/_geekity/` is the CMS's own, like the health check —
|
|
18
|
-
* and means the route table does not grow with the site.
|
|
19
|
-
*
|
|
20
|
-
* Everything it answers is either a redirect or the post's own page rendered
|
|
21
|
-
* again with the form still filled in. There is no JSON, no fragment and no
|
|
22
|
-
* script: a comment form has worked without JavaScript since 2003 and there is
|
|
23
|
-
* no reason for this one to stop.
|
|
24
|
-
*/
|
|
25
|
-
export { COMMENT_POST_PATH, COMMENT_REPLY_PARAM } from './form.js';
|
|
26
|
-
/** Register the comment endpoint. Mounted by the public site. */
|
|
27
|
-
export function mountComments(app) {
|
|
28
|
-
// One limiter for the whole mount, built on the first submission because the
|
|
29
|
-
// clock is on the context. It holds nothing but recent submissions, so it
|
|
30
|
-
// belongs to the process rather than the database: a restart clears it,
|
|
31
|
-
// which is the right trade for state an anonymous caller can create.
|
|
32
|
-
let limiter;
|
|
33
|
-
function throttle(config) {
|
|
34
|
-
limiter ??= createLoginThrottle({
|
|
35
|
-
attempts: COMMENT_RATE_LIMIT,
|
|
36
|
-
lockoutSeconds: COMMENT_RATE_WINDOW_SECONDS,
|
|
37
|
-
now: config.now,
|
|
38
|
-
});
|
|
39
|
-
return limiter;
|
|
40
|
-
}
|
|
41
|
-
app.post(COMMENT_POST_PATH, async (c) => {
|
|
42
|
-
const { store, admin, renderer, config } = c.var;
|
|
43
|
-
const body = await c.req.parseBody();
|
|
44
|
-
const form = formOf(body);
|
|
45
|
-
// Who the session says this is, read before anything else is decided: it
|
|
46
|
-
// settles the token, the attribution and where the comment lands.
|
|
47
|
-
const account = c.var.signedIn;
|
|
48
|
-
const viewer = account === undefined ? undefined : commenterOf(account);
|
|
49
|
-
// A form that acts on nobody's behalf needs no token, and the public one
|
|
50
|
-
// still carries none. This one posts under somebody's name, so without a
|
|
51
|
-
// matching token a page on another site could make them say something they
|
|
52
|
-
// never typed. Refused in the words and with the status the admin guard
|
|
53
|
-
// uses, because it is the same check on the same token.
|
|
54
|
-
//
|
|
55
|
-
// Fetch Metadata first, as in the admin: a browser that says the form was
|
|
56
|
-
// on another site is refused whatever token it carries. A stranger's form
|
|
57
|
-
// is left alone, because it acts on nobody's behalf.
|
|
58
|
-
if (viewer !== undefined && crossSiteWrite(c))
|
|
59
|
-
return c.text(CROSS_SITE_REFUSAL, 403);
|
|
60
|
-
if (viewer !== undefined && !csrfTokenMatches(viewer.csrfToken, form.csrf)) {
|
|
61
|
-
return c.text('That form was stale or came from somewhere else. Reload and try again.', 403);
|
|
62
|
-
}
|
|
63
|
-
const document = store.getBySlug(form.post);
|
|
64
|
-
if (document === undefined || !isServed(document, store.now())) {
|
|
65
|
-
return c.text('There is no such post to comment on.', 404);
|
|
66
|
-
}
|
|
67
|
-
const now = config.now();
|
|
68
|
-
if (!commentsOpen(document, commentPolicyOf(renderer.site()), now)) {
|
|
69
|
-
// 403 rather than 404: the post is there, and the reader can see for
|
|
70
|
-
// themselves that it is. Saying so is more honest than pretending the
|
|
71
|
-
// URL is wrong, and a closed post is a state rather than a mistake.
|
|
72
|
-
return page(c, document, 403, viewer, {
|
|
73
|
-
...drawnFor(refilledCommentForm(document, valuesOf(form), {}, now), viewer),
|
|
74
|
-
error: 'This post is not taking comments any more.',
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
if (viewer !== undefined) {
|
|
78
|
-
const answered = await submitReplyPost({
|
|
79
|
-
site: documentSite(c, viewer.username),
|
|
80
|
-
document,
|
|
81
|
-
conversation: c.var.conversation.thread(document),
|
|
82
|
-
form,
|
|
83
|
-
throttle: throttle(config),
|
|
84
|
-
address: clientAddress(c, config),
|
|
85
|
-
});
|
|
86
|
-
if (answered.kind === 'saved') {
|
|
87
|
-
const reply = c.var.conversation.replyNamed(document, answered.saved.permalink);
|
|
88
|
-
const anchor = reply === undefined ? 'comments' : commentAnchor(reply.key);
|
|
89
|
-
return c.redirect(`${document.permalink}?${COMMENT_NOTICE_PARAM}=posted#${anchor}`, 303);
|
|
90
|
-
}
|
|
91
|
-
return refusedPage(c, document, viewer, form, answered.refusal, now);
|
|
92
|
-
}
|
|
93
|
-
const outcome = await submitComment({
|
|
94
|
-
records: { admin, contentDir: config.contentDir, dataDir: config.dataDir },
|
|
95
|
-
document,
|
|
96
|
-
cited: (url) => c.var.replyContexts.read(url),
|
|
97
|
-
form,
|
|
98
|
-
dataDir: config.dataDir,
|
|
99
|
-
baseUrl: config.baseUrl,
|
|
100
|
-
checker: config.commentChecker,
|
|
101
|
-
// Who hears about what lands is the intake's to decide, and neither
|
|
102
|
-
// message is awaited: the reader is redirected now and they go out
|
|
103
|
-
// behind them (TASK-55).
|
|
104
|
-
notices: c.var.notifications,
|
|
105
|
-
address: clientAddress(c, config),
|
|
106
|
-
userAgent: c.req.header('user-agent'),
|
|
107
|
-
referrer: c.req.header('referer'),
|
|
108
|
-
throttle: throttle(config),
|
|
109
|
-
// Whether the box on the form meant anything, read per submission so a
|
|
110
|
-
// credential saved a moment ago is honoured now (TASK-55).
|
|
111
|
-
notifiable: c.var.mail.configured(),
|
|
112
|
-
now,
|
|
113
|
-
});
|
|
114
|
-
if (outcome.kind === 'stored') {
|
|
115
|
-
const stored = outcome.comment;
|
|
116
|
-
// A redirect rather than a rendered page, so a refresh does not post the
|
|
117
|
-
// comment a second time. An approved comment is on the page already, so
|
|
118
|
-
// the reader is sent to it; one waiting for a moderator has nothing to
|
|
119
|
-
// point at, so the reader is sent to the form they just used.
|
|
120
|
-
const anchor = stored.status === 'approved' ? commentAnchor(stored.id) : 'respond';
|
|
121
|
-
const notice = stored.status === 'approved' ? 'posted' : 'pending';
|
|
122
|
-
return c.redirect(`${document.permalink}?${COMMENT_NOTICE_PARAM}=${notice}#${anchor}`, 303);
|
|
123
|
-
}
|
|
124
|
-
const refusal = outcome.refusal;
|
|
125
|
-
if (refusal.kind === 'discarded') {
|
|
126
|
-
// Nothing is said about why. A robot that filled the honeypot, or that a
|
|
127
|
-
// checker recognised, learns exactly as much from this as from a
|
|
128
|
-
// successful post — which is the point of both defences.
|
|
129
|
-
return c.redirect(`${document.permalink}?${COMMENT_NOTICE_PARAM}=pending#respond`, 303);
|
|
130
|
-
}
|
|
131
|
-
return refusedPage(c, document, viewer, form, refusal, now);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
/** The post's page again, with the form refilled and what went wrong on it. */
|
|
135
|
-
function refusedPage(c, document, viewer, form, refusal, now) {
|
|
136
|
-
if (refusal.kind === 'rate-limited') {
|
|
137
|
-
c.header('Retry-After', String(refusal.retryAfter));
|
|
138
|
-
return page(c, document, 429, viewer, {
|
|
139
|
-
...drawnFor(refilledCommentForm(document, valuesOf(form), {}, now), viewer),
|
|
140
|
-
error: 'That is a lot of comments in a short time. Try again in a few minutes.',
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const message = refusal.kind === 'too-quick'
|
|
144
|
-
? 'That was posted faster than anybody types. Try again.'
|
|
145
|
-
: refusal.kind === 'stale'
|
|
146
|
-
? 'That form had been open a long time. Here it is again — the words are still there.'
|
|
147
|
-
: undefined;
|
|
148
|
-
return page(c, document, 400, viewer, {
|
|
149
|
-
...drawnFor(refilledCommentForm(document, valuesOf(form), problemsOf(refusal), now), viewer),
|
|
150
|
-
...(message === undefined ? {} : { error: message }),
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* The same form drawn for whoever is filling it in: the short one when the
|
|
155
|
-
* site knows them, and the stranger's one when it does not.
|
|
156
|
-
*/
|
|
157
|
-
function drawnFor(form, viewer) {
|
|
158
|
-
return viewer === undefined ? form : signedInCommentForm(form, viewer);
|
|
159
|
-
}
|
|
160
|
-
function page(c, document, status, viewer, form) {
|
|
161
|
-
c.status(status);
|
|
162
|
-
return c.html(c.var.renderer.renderDocument(document, { commentForm: form }, viewer));
|
|
163
|
-
}
|
|
164
|
-
/** The per-field messages a refusal carries, if it carries any. */
|
|
165
|
-
function problemsOf(refusal) {
|
|
166
|
-
return refusal.kind === 'invalid' ? (refusal.problems ?? {}) : {};
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* The thank-you a reader is shown after posting, from the query the redirect
|
|
170
|
-
* carried, or `undefined` when the URL says nothing.
|
|
171
|
-
*
|
|
172
|
-
* A query rather than a flash message, because a reader has no session to hang
|
|
173
|
-
* one on, and because a comment form that only works for people with cookies
|
|
174
|
-
* is not a comment form.
|
|
175
|
-
*/
|
|
176
|
-
export function commentNoticeFor(query) {
|
|
177
|
-
return query === undefined ? undefined : COMMENT_NOTICES[query];
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* The comment a `?reply_to=` query points at, as the theme needs it, or an
|
|
181
|
-
* empty object when the query names nothing on this post.
|
|
182
|
-
*
|
|
183
|
-
* Checked against the index rather than trusted, so a made-up id — or one from
|
|
184
|
-
* another page — cannot put a stranger's name on somebody's reply form, and so
|
|
185
|
-
* a comment waiting for a moderator cannot be discovered by guessing. With the
|
|
186
|
-
* post's `thread`, which is handed over for somebody signed in (TASK-300), any
|
|
187
|
-
* entry a reader can see is answerable: a webmention, a fediverse reply or a
|
|
188
|
-
* reply post as well as a comment.
|
|
189
|
-
*/
|
|
190
|
-
export function commentReplyTarget(options) {
|
|
191
|
-
if (options.id === undefined || options.id === '')
|
|
192
|
-
return {};
|
|
193
|
-
if (options.thread !== undefined) {
|
|
194
|
-
const reply = visibleReply(options.thread.replies, options.id);
|
|
195
|
-
return reply === undefined
|
|
196
|
-
? {}
|
|
197
|
-
: { commentReplyTo: reply.key, commentReplyingTo: reply.author.name };
|
|
198
|
-
}
|
|
199
|
-
const parent = options.admin.getComment(options.id);
|
|
200
|
-
if (parent === undefined || parent.slug !== options.document.slug)
|
|
201
|
-
return {};
|
|
202
|
-
if (parent.status !== 'approved')
|
|
203
|
-
return {};
|
|
204
|
-
return { commentReplyTo: parent.id, commentReplyingTo: parent.author.name };
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* The form for a post, or `undefined` when it is not taking comments.
|
|
208
|
-
*
|
|
209
|
-
* What the renderer is handed at boot. It reads the settings and the clock on
|
|
210
|
-
* every render, so a post that closed an hour ago stops offering a form on the
|
|
211
|
-
* very next request.
|
|
212
|
-
*/
|
|
213
|
-
export function commentFormFor(options) {
|
|
214
|
-
if (!commentsOpen(options.document, commentPolicyOf(options.site), options.now))
|
|
215
|
-
return undefined;
|
|
216
|
-
const form = commentForm(options.document, options.now, options.notifiable ?? false);
|
|
217
|
-
return drawnFor(form, options.viewer);
|
|
218
|
-
}
|
|
219
|
-
/** A submitted body as the form it is, every field a string. */
|
|
220
|
-
function formOf(body) {
|
|
221
|
-
return {
|
|
222
|
-
post: stringOrEmpty(body[COMMENT_FIELDS.post]),
|
|
223
|
-
name: stringOrEmpty(body[COMMENT_FIELDS.name]),
|
|
224
|
-
email: stringOrEmpty(body[COMMENT_FIELDS.email]),
|
|
225
|
-
url: stringOrEmpty(body[COMMENT_FIELDS.url]),
|
|
226
|
-
body: stringOrEmpty(body[COMMENT_FIELDS.body]),
|
|
227
|
-
inReplyTo: stringOrEmpty(body[COMMENT_FIELDS.inReplyTo]),
|
|
228
|
-
trap: stringOrEmpty(body[COMMENT_FIELDS.trap]),
|
|
229
|
-
loaded: stringOrEmpty(body[COMMENT_FIELDS.loaded]),
|
|
230
|
-
notify: stringOrEmpty(body[COMMENT_FIELDS.notify]),
|
|
231
|
-
csrf: stringOrEmpty(body[COMMENT_FIELDS.csrf]),
|
|
232
|
-
listed: stringOrEmpty(body[COMMENT_FIELDS.listed]),
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
//# sourceMappingURL=routes.js.map
|
|
@@ -1 +0,0 @@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ELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What may be uploaded into `content/uploads/`, described once.
|
|
3
|
-
*
|
|
4
|
-
* The upload endpoint is the only door into the content directory that does
|
|
5
|
-
* not write Markdown, so what it accepts is a list rather than a judgement:
|
|
6
|
-
* an extension the CMS has never heard of is refused, and one it has is
|
|
7
|
-
* checked against the media type the browser declared and, where the format
|
|
8
|
-
* has one, against the bytes the file actually starts with.
|
|
9
|
-
*
|
|
10
|
-
* The table lives here rather than beside the endpoint because
|
|
11
|
-
* {@link ResolvedConfig} validates a site's allowlist against it, and config
|
|
12
|
-
* may not depend on the admin.
|
|
13
|
-
*/
|
|
14
|
-
/** Bytes a file of some format carries at a fixed offset. */
|
|
15
|
-
export interface UploadSignature {
|
|
16
|
-
/** Where in the file the bytes are. */
|
|
17
|
-
offset: number;
|
|
18
|
-
/** The bytes themselves. */
|
|
19
|
-
bytes: readonly number[];
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* What an upload is for, which decides what the CMS offers to do with it.
|
|
23
|
-
*
|
|
24
|
-
* An image is embedded and gets variants, audio and video can be a post's
|
|
25
|
-
* enclosure and are held to their own size limit, and a document is linked.
|
|
26
|
-
*/
|
|
27
|
-
export type UploadKind = 'image' | 'audio' | 'video' | 'document';
|
|
28
|
-
/** One kind of file the upload endpoint knows about. */
|
|
29
|
-
export interface UploadMediaType {
|
|
30
|
-
/**
|
|
31
|
-
* Media types a browser may declare for this extension. An empty string is
|
|
32
|
-
* always accepted alongside these: a browser that does not recognise a file
|
|
33
|
-
* sends no type at all, and there is then nothing to disagree with.
|
|
34
|
-
*/
|
|
35
|
-
declared: readonly string[];
|
|
36
|
-
/** What the file is for. */
|
|
37
|
-
kind: UploadKind;
|
|
38
|
-
/**
|
|
39
|
-
* Byte patterns that identify the format, as alternatives: a file matches
|
|
40
|
-
* when every part of any one of them matches. Absent for the text formats,
|
|
41
|
-
* which have no header to check.
|
|
42
|
-
*/
|
|
43
|
-
signatures?: readonly (readonly UploadSignature[])[] | undefined;
|
|
44
|
-
/** Whether the file is text, served with its character set named. */
|
|
45
|
-
text?: true;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Every extension the upload endpoint can accept, and what it takes to be one.
|
|
49
|
-
*
|
|
50
|
-
* SVG is deliberately absent. An SVG is a document that may carry script, and
|
|
51
|
-
* an upload is served from the site's own origin, so accepting one would hand
|
|
52
|
-
* anybody who can reach the editor a stored cross-site scripting hole. A site
|
|
53
|
-
* that wants them anyway can put `.svg` in `uploadTypes` — and then it has
|
|
54
|
-
* chosen that, which is the point.
|
|
55
|
-
*/
|
|
56
|
-
export declare const UPLOAD_MEDIA_TYPES: ReadonlyMap<string, UploadMediaType>;
|
|
57
|
-
/** The extensions a site may put in its allowlist, sorted. */
|
|
58
|
-
export declare const KNOWN_UPLOAD_TYPES: readonly string[];
|
|
59
|
-
/**
|
|
60
|
-
* An extension as the allowlist spells it: lower case, with the dot.
|
|
61
|
-
*
|
|
62
|
-
* `PNG`, `.Png` and `png` are all the same thing to somebody writing a config
|
|
63
|
-
* file, so they are the same thing here.
|
|
64
|
-
*/
|
|
65
|
-
export declare function normalizeUploadType(value: string): string;
|
|
66
|
-
/**
|
|
67
|
-
* The media type a feed or an attachment announces for this kind of file: the
|
|
68
|
-
* first one {@link UploadMediaType.declared} lists, which is the registered
|
|
69
|
-
* name where a browser may also send an older one.
|
|
70
|
-
*/
|
|
71
|
-
export declare function canonicalType(media: UploadMediaType): string | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* The `Content-Type` an upload of this kind is served with: its
|
|
74
|
-
* {@link canonicalType}, with the character set when it is text.
|
|
75
|
-
*/
|
|
76
|
-
export declare function servedType(media: UploadMediaType): string;
|
|
77
|
-
/**
|
|
78
|
-
* Whether the first bytes of a file are the ones its extension implies.
|
|
79
|
-
*
|
|
80
|
-
* A format with no signature — the text ones — matches anything, because there
|
|
81
|
-
* is nothing to compare. Returns `false` for a file too short to hold the
|
|
82
|
-
* header it claims.
|
|
83
|
-
*/
|
|
84
|
-
export declare function matchesSignature(media: UploadMediaType, bytes: Uint8Array): boolean;
|
|
85
|
-
//# sourceMappingURL=media.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/content/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,6DAA6D;AAC7D,MAAM,WAAW,eAAe;IAC9B,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,CAAC;AAElE,wDAAwD;AACxD,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,4BAA4B;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,eAAe,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC;IACjE,qEAAqE;IACrE,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AAgBD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAkKlE,CAAC;AAEH,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAA0C,CAAC;AAE3F;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAExE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAGzD;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CASnF"}
|
package/dist/content/media.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What may be uploaded into `content/uploads/`, described once.
|
|
3
|
-
*
|
|
4
|
-
* The upload endpoint is the only door into the content directory that does
|
|
5
|
-
* not write Markdown, so what it accepts is a list rather than a judgement:
|
|
6
|
-
* an extension the CMS has never heard of is refused, and one it has is
|
|
7
|
-
* checked against the media type the browser declared and, where the format
|
|
8
|
-
* has one, against the bytes the file actually starts with.
|
|
9
|
-
*
|
|
10
|
-
* The table lives here rather than beside the endpoint because
|
|
11
|
-
* {@link ResolvedConfig} validates a site's allowlist against it, and config
|
|
12
|
-
* may not depend on the admin.
|
|
13
|
-
*/
|
|
14
|
-
/** The bytes of an ASCII string, for spelling a signature readably. */
|
|
15
|
-
function ascii(value) {
|
|
16
|
-
return [...value].map((character) => character.charCodeAt(0));
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* An ISO base media file — MP4, M4A, M4V — whatever its brand: a box length,
|
|
20
|
-
* then `ftyp`.
|
|
21
|
-
*/
|
|
22
|
-
const ISO_BASE_MEDIA = [{ offset: 4, bytes: ascii('ftyp') }];
|
|
23
|
-
/** An Ogg page, whatever codec is inside it. */
|
|
24
|
-
const OGG = [{ offset: 0, bytes: ascii('OggS') }];
|
|
25
|
-
/**
|
|
26
|
-
* Every extension the upload endpoint can accept, and what it takes to be one.
|
|
27
|
-
*
|
|
28
|
-
* SVG is deliberately absent. An SVG is a document that may carry script, and
|
|
29
|
-
* an upload is served from the site's own origin, so accepting one would hand
|
|
30
|
-
* anybody who can reach the editor a stored cross-site scripting hole. A site
|
|
31
|
-
* that wants them anyway can put `.svg` in `uploadTypes` — and then it has
|
|
32
|
-
* chosen that, which is the point.
|
|
33
|
-
*/
|
|
34
|
-
export const UPLOAD_MEDIA_TYPES = new Map([
|
|
35
|
-
[
|
|
36
|
-
'.png',
|
|
37
|
-
{
|
|
38
|
-
declared: ['image/png'],
|
|
39
|
-
kind: 'image',
|
|
40
|
-
signatures: [[{ offset: 0, bytes: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a] }]],
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
[
|
|
44
|
-
'.jpg',
|
|
45
|
-
{
|
|
46
|
-
declared: ['image/jpeg', 'image/jpg'],
|
|
47
|
-
kind: 'image',
|
|
48
|
-
signatures: [[{ offset: 0, bytes: [0xff, 0xd8, 0xff] }]],
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
[
|
|
52
|
-
'.jpeg',
|
|
53
|
-
{
|
|
54
|
-
declared: ['image/jpeg', 'image/jpg'],
|
|
55
|
-
kind: 'image',
|
|
56
|
-
signatures: [[{ offset: 0, bytes: [0xff, 0xd8, 0xff] }]],
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
[
|
|
60
|
-
'.gif',
|
|
61
|
-
{
|
|
62
|
-
declared: ['image/gif'],
|
|
63
|
-
kind: 'image',
|
|
64
|
-
signatures: [
|
|
65
|
-
[{ offset: 0, bytes: ascii('GIF87a') }],
|
|
66
|
-
[{ offset: 0, bytes: ascii('GIF89a') }],
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
[
|
|
71
|
-
'.webp',
|
|
72
|
-
{
|
|
73
|
-
declared: ['image/webp'],
|
|
74
|
-
kind: 'image',
|
|
75
|
-
// A WebP is a RIFF container whose form type is WEBP, so both halves of
|
|
76
|
-
// the header have to be there.
|
|
77
|
-
signatures: [
|
|
78
|
-
[
|
|
79
|
-
{ offset: 0, bytes: ascii('RIFF') },
|
|
80
|
-
{ offset: 8, bytes: ascii('WEBP') },
|
|
81
|
-
],
|
|
82
|
-
],
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
'.avif',
|
|
87
|
-
{
|
|
88
|
-
declared: ['image/avif'],
|
|
89
|
-
kind: 'image',
|
|
90
|
-
// An ISO base media file: a length, then `ftyp`, then the brand.
|
|
91
|
-
signatures: [
|
|
92
|
-
[
|
|
93
|
-
{ offset: 4, bytes: ascii('ftyp') },
|
|
94
|
-
{ offset: 8, bytes: ascii('avif') },
|
|
95
|
-
],
|
|
96
|
-
[
|
|
97
|
-
{ offset: 4, bytes: ascii('ftyp') },
|
|
98
|
-
{ offset: 8, bytes: ascii('avis') },
|
|
99
|
-
],
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
[
|
|
104
|
-
'.pdf',
|
|
105
|
-
{
|
|
106
|
-
declared: ['application/pdf'],
|
|
107
|
-
kind: 'document',
|
|
108
|
-
signatures: [[{ offset: 0, bytes: ascii('%PDF-') }]],
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
// The two text formats have no header. Nothing is sniffed, and nothing needs
|
|
112
|
-
// to be: they are served as text, and `application/octet-stream` is allowed
|
|
113
|
-
// because that is what a browser sends for a file type it does not know.
|
|
114
|
-
['.txt', { declared: ['text/plain', 'application/octet-stream'], kind: 'document', text: true }],
|
|
115
|
-
[
|
|
116
|
-
'.md',
|
|
117
|
-
{
|
|
118
|
-
declared: ['text/markdown', 'text/x-markdown', 'text/plain', 'application/octet-stream'],
|
|
119
|
-
kind: 'document',
|
|
120
|
-
text: true,
|
|
121
|
-
},
|
|
122
|
-
],
|
|
123
|
-
// WebVTT opens with its name, after a byte order mark when the editor that
|
|
124
|
-
// wrote it added one. SubRip has no header, so it is taken as text like the
|
|
125
|
-
// two formats above.
|
|
126
|
-
[
|
|
127
|
-
'.vtt',
|
|
128
|
-
{
|
|
129
|
-
declared: ['text/vtt', 'text/plain', 'application/octet-stream'],
|
|
130
|
-
kind: 'document',
|
|
131
|
-
text: true,
|
|
132
|
-
signatures: [
|
|
133
|
-
[{ offset: 0, bytes: ascii('WEBVTT') }],
|
|
134
|
-
[{ offset: 0, bytes: [0xef, 0xbb, 0xbf, ...ascii('WEBVTT')] }],
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
],
|
|
138
|
-
[
|
|
139
|
-
'.srt',
|
|
140
|
-
{
|
|
141
|
-
declared: ['application/x-subrip', 'text/srt', 'text/plain', 'application/octet-stream'],
|
|
142
|
-
kind: 'document',
|
|
143
|
-
text: true,
|
|
144
|
-
},
|
|
145
|
-
],
|
|
146
|
-
[
|
|
147
|
-
'.mp3',
|
|
148
|
-
{
|
|
149
|
-
declared: ['audio/mpeg', 'audio/mp3'],
|
|
150
|
-
kind: 'audio',
|
|
151
|
-
// An ID3 tag, or straight into an MPEG audio frame: eleven sync bits,
|
|
152
|
-
// then MPEG-1 or MPEG-2 layer III, with or without a CRC.
|
|
153
|
-
signatures: [
|
|
154
|
-
[{ offset: 0, bytes: ascii('ID3') }],
|
|
155
|
-
[{ offset: 0, bytes: [0xff, 0xfb] }],
|
|
156
|
-
[{ offset: 0, bytes: [0xff, 0xfa] }],
|
|
157
|
-
[{ offset: 0, bytes: [0xff, 0xf3] }],
|
|
158
|
-
[{ offset: 0, bytes: [0xff, 0xf2] }],
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
[
|
|
163
|
-
'.m4a',
|
|
164
|
-
{
|
|
165
|
-
declared: ['audio/mp4', 'audio/x-m4a', 'audio/m4a'],
|
|
166
|
-
kind: 'audio',
|
|
167
|
-
signatures: [ISO_BASE_MEDIA],
|
|
168
|
-
},
|
|
169
|
-
],
|
|
170
|
-
[
|
|
171
|
-
'.aac',
|
|
172
|
-
{
|
|
173
|
-
declared: ['audio/aac', 'audio/x-aac', 'audio/aacp'],
|
|
174
|
-
kind: 'audio',
|
|
175
|
-
// A raw ADTS stream: twelve sync bits, MPEG-4 or MPEG-2, no CRC.
|
|
176
|
-
signatures: [[{ offset: 0, bytes: [0xff, 0xf1] }], [{ offset: 0, bytes: [0xff, 0xf9] }]],
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
['.ogg', { declared: ['audio/ogg', 'application/ogg'], kind: 'audio', signatures: [OGG] }],
|
|
180
|
-
['.oga', { declared: ['audio/ogg', 'application/ogg'], kind: 'audio', signatures: [OGG] }],
|
|
181
|
-
['.opus', { declared: ['audio/ogg', 'audio/opus'], kind: 'audio', signatures: [OGG] }],
|
|
182
|
-
['.mp4', { declared: ['video/mp4'], kind: 'video', signatures: [ISO_BASE_MEDIA] }],
|
|
183
|
-
['.m4v', { declared: ['video/mp4', 'video/x-m4v'], kind: 'video', signatures: [ISO_BASE_MEDIA] }],
|
|
184
|
-
[
|
|
185
|
-
'.webm',
|
|
186
|
-
{
|
|
187
|
-
declared: ['video/webm', 'audio/webm'],
|
|
188
|
-
kind: 'video',
|
|
189
|
-
// The EBML header every Matroska file, WebM included, opens with.
|
|
190
|
-
signatures: [[{ offset: 0, bytes: [0x1a, 0x45, 0xdf, 0xa3] }]],
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
]);
|
|
194
|
-
/** The extensions a site may put in its allowlist, sorted. */
|
|
195
|
-
export const KNOWN_UPLOAD_TYPES = [...UPLOAD_MEDIA_TYPES.keys()].sort();
|
|
196
|
-
/**
|
|
197
|
-
* An extension as the allowlist spells it: lower case, with the dot.
|
|
198
|
-
*
|
|
199
|
-
* `PNG`, `.Png` and `png` are all the same thing to somebody writing a config
|
|
200
|
-
* file, so they are the same thing here.
|
|
201
|
-
*/
|
|
202
|
-
export function normalizeUploadType(value) {
|
|
203
|
-
const trimmed = value.trim().toLowerCase();
|
|
204
|
-
if (trimmed === '')
|
|
205
|
-
return '';
|
|
206
|
-
return trimmed.startsWith('.') ? trimmed : `.${trimmed}`;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* The media type a feed or an attachment announces for this kind of file: the
|
|
210
|
-
* first one {@link UploadMediaType.declared} lists, which is the registered
|
|
211
|
-
* name where a browser may also send an older one.
|
|
212
|
-
*/
|
|
213
|
-
export function canonicalType(media) {
|
|
214
|
-
return media.declared[0];
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* The `Content-Type` an upload of this kind is served with: its
|
|
218
|
-
* {@link canonicalType}, with the character set when it is text.
|
|
219
|
-
*/
|
|
220
|
-
export function servedType(media) {
|
|
221
|
-
const type = media.declared[0] ?? 'application/octet-stream';
|
|
222
|
-
return media.text === true ? `${type}; charset=utf-8` : type;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Whether the first bytes of a file are the ones its extension implies.
|
|
226
|
-
*
|
|
227
|
-
* A format with no signature — the text ones — matches anything, because there
|
|
228
|
-
* is nothing to compare. Returns `false` for a file too short to hold the
|
|
229
|
-
* header it claims.
|
|
230
|
-
*/
|
|
231
|
-
export function matchesSignature(media, bytes) {
|
|
232
|
-
const alternatives = media.signatures;
|
|
233
|
-
if (alternatives === undefined)
|
|
234
|
-
return true;
|
|
235
|
-
return alternatives.some((signature) => signature.every((part) => part.bytes.every((byte, index) => bytes[part.offset + index] === byte)));
|
|
236
|
-
}
|
|
237
|
-
//# sourceMappingURL=media.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/content/media.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAsCH,uEAAuE;AACvE,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,cAAc,GAA+B,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEzF,gDAAgD;AAChD,MAAM,GAAG,GAA+B,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,CAA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Y,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAE5C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CACrC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CACvE,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { FieldError } from './form-error.ts';
|
|
2
|
-
import type { Read, ReadOf } from './read.ts';
|
|
3
|
-
export interface ReadOfForm {
|
|
4
|
-
name: string;
|
|
5
|
-
author: string;
|
|
6
|
-
uid: string;
|
|
7
|
-
url: string;
|
|
8
|
-
photo: string;
|
|
9
|
-
photoAlt: string;
|
|
10
|
-
}
|
|
11
|
-
export declare const READ_FIELDS: {
|
|
12
|
-
readonly status: 'read-status';
|
|
13
|
-
readonly name: 'read-of-name';
|
|
14
|
-
readonly author: 'read-of-author';
|
|
15
|
-
readonly uid: 'read-of-uid';
|
|
16
|
-
readonly url: 'read-of-url';
|
|
17
|
-
readonly photo: 'read-of-photo';
|
|
18
|
-
readonly photoAlt: 'read-of-photo-alt';
|
|
19
|
-
};
|
|
20
|
-
export declare function submittedReadOfForm(body: Readonly<Record<string, unknown>>): ReadOfForm;
|
|
21
|
-
export declare const BLANK_READ_OF_FORM: ReadOfForm;
|
|
22
|
-
export declare function readOfForm(of: ReadOf | undefined): ReadOfForm;
|
|
23
|
-
export declare function resolveRead(status: string, of: ReadOfForm, contentDir: string): {
|
|
24
|
-
read: Read | undefined;
|
|
25
|
-
} | FieldError;
|
|
26
|
-
export declare function readOfFromMicropub(values: readonly unknown[], refuse: (message: string) => void, baseUrl: string): ReadOfForm;
|
|
27
|
-
export declare function readCite({ photo, ...of }: ReadOf, baseUrl: string): {
|
|
28
|
-
type: string[];
|
|
29
|
-
properties: Record<string, unknown[]>;
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=read-form.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"read-form.d.ts","sourceRoot":"","sources":["../../src/content/read-form.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,WAAW;aACtB,MAAM,EAAE,aAAa;aACrB,IAAI,EAAE,cAAc;aACpB,MAAM,EAAE,gBAAgB;aACxB,GAAG,EAAE,aAAa;aAClB,GAAG,EAAE,aAAa;aAClB,KAAK,EAAE,eAAe;aACtB,QAAQ,EAAE,mBAAmB;CACrB,CAAC;AAEX,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,UAAU,CASvF;AAED,eAAO,MAAM,kBAAkB,EAAE,UAOhC,CAAC;AAEF,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAS7D;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,UAAU,EACd,UAAU,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,IAAI,GAAG,SAAS,CAAA;CAAE,GAAG,UAAU,CAmDzC;AAKD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,SAAS,OAAO,EAAE,EAC1B,MAAM,EAAE,CAAC,OA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