@geekity/cms 0.3.0 → 0.4.0
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/README.md +2091 -214
- package/admin/components/fields.njk +165 -0
- package/admin/layouts/base.njk +1 -1
- package/admin/layouts/settings-page.njk +26 -0
- package/admin/layouts/shell.njk +17 -3
- package/admin/pages/account/forgot.njk +47 -0
- package/admin/pages/account/login.njk +26 -0
- package/admin/pages/account/reset.njk +38 -0
- package/admin/pages/account/setup.njk +28 -0
- package/admin/pages/appearance/themes.njk +69 -0
- package/admin/pages/comments/all.njk +133 -0
- package/admin/{layouts/dashboard.njk → pages/dashboard/home.njk} +8 -15
- package/admin/{layouts/document-conflict.njk → pages/documents/conflict.njk} +1 -0
- package/admin/pages/documents/editor.njk +196 -0
- package/admin/{layouts/document-list.njk → pages/documents/list.njk} +19 -2
- package/admin/pages/documents/taxonomy.njk +95 -0
- package/admin/pages/federation/followers.njk +238 -0
- package/admin/pages/media/library.njk +160 -0
- package/admin/pages/messages/all.njk +110 -0
- package/admin/{layouts → pages}/placeholder.njk +5 -1
- package/admin/pages/settings/discussion.njk +99 -0
- package/admin/pages/settings/email.njk +203 -0
- package/admin/pages/settings/federation.njk +75 -0
- package/admin/pages/settings/general.njk +29 -0
- package/admin/pages/settings/permalinks.njk +50 -0
- package/admin/pages/settings/reading.njk +72 -0
- package/admin/pages/users/edit.njk +239 -0
- package/admin/pages/users/list.njk +48 -0
- package/admin/pages/users/new.njk +41 -0
- package/admin/static/admin.css +498 -3
- package/admin/static/copy.js +52 -0
- package/admin/static/editor.js +16 -16
- package/admin/static/slug.js +61 -0
- package/dist/admin/accounts.d.ts +413 -0
- package/dist/admin/accounts.d.ts.map +1 -0
- package/dist/admin/accounts.js +680 -0
- package/dist/admin/accounts.js.map +1 -0
- package/dist/admin/appearance.d.ts +80 -0
- package/dist/admin/appearance.d.ts.map +1 -0
- package/dist/admin/appearance.js +136 -0
- package/dist/admin/appearance.js.map +1 -0
- package/dist/admin/comments.d.ts +90 -0
- package/dist/admin/comments.d.ts.map +1 -0
- package/dist/admin/comments.js +244 -0
- package/dist/admin/comments.js.map +1 -0
- package/dist/admin/credentials.d.ts +26 -2
- package/dist/admin/credentials.d.ts.map +1 -1
- package/dist/admin/credentials.js +35 -2
- package/dist/admin/credentials.js.map +1 -1
- package/dist/admin/documents.d.ts +127 -10
- package/dist/admin/documents.d.ts.map +1 -1
- package/dist/admin/documents.js +360 -41
- package/dist/admin/documents.js.map +1 -1
- package/dist/admin/federation.d.ts +151 -50
- package/dist/admin/federation.d.ts.map +1 -1
- package/dist/admin/federation.js +225 -93
- package/dist/admin/federation.js.map +1 -1
- package/dist/admin/formatting.d.ts +20 -0
- package/dist/admin/formatting.d.ts.map +1 -0
- package/dist/admin/formatting.js +72 -0
- package/dist/admin/formatting.js.map +1 -0
- package/dist/admin/headers.d.ts +65 -0
- package/dist/admin/headers.d.ts.map +1 -0
- package/dist/admin/headers.js +104 -0
- package/dist/admin/headers.js.map +1 -0
- package/dist/admin/index.d.ts +38 -12
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +25 -7
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/media.d.ts +168 -0
- package/dist/admin/media.d.ts.map +1 -0
- package/dist/admin/media.js +295 -0
- package/dist/admin/media.js.map +1 -0
- package/dist/admin/menu.d.ts +79 -0
- package/dist/admin/menu.d.ts.map +1 -0
- package/dist/admin/menu.js +126 -0
- package/dist/admin/menu.js.map +1 -0
- package/dist/admin/messages.d.ts +80 -0
- package/dist/admin/messages.d.ts.map +1 -0
- package/dist/admin/messages.js +152 -0
- package/dist/admin/messages.js.map +1 -0
- package/dist/admin/preview.d.ts.map +1 -1
- package/dist/admin/preview.js +31 -7
- package/dist/admin/preview.js.map +1 -1
- package/dist/admin/recovery.d.ts +92 -0
- package/dist/admin/recovery.d.ts.map +1 -0
- package/dist/admin/recovery.js +229 -0
- package/dist/admin/recovery.js.map +1 -0
- package/dist/admin/routes.d.ts +0 -20
- package/dist/admin/routes.d.ts.map +1 -1
- package/dist/admin/routes.js +155 -105
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/settings-discussion.d.ts +37 -0
- package/dist/admin/settings-discussion.d.ts.map +1 -0
- package/dist/admin/settings-discussion.js +117 -0
- package/dist/admin/settings-discussion.js.map +1 -0
- package/dist/admin/settings-email.d.ts +54 -0
- package/dist/admin/settings-email.d.ts.map +1 -0
- package/dist/admin/settings-email.js +189 -0
- package/dist/admin/settings-email.js.map +1 -0
- package/dist/admin/settings-federation.d.ts +39 -0
- package/dist/admin/settings-federation.d.ts.map +1 -0
- package/dist/admin/settings-federation.js +103 -0
- package/dist/admin/settings-federation.js.map +1 -0
- package/dist/admin/settings-general.d.ts +12 -0
- package/dist/admin/settings-general.d.ts.map +1 -0
- package/dist/admin/settings-general.js +48 -0
- package/dist/admin/settings-general.js.map +1 -0
- package/dist/admin/settings-page.d.ts +102 -0
- package/dist/admin/settings-page.d.ts.map +1 -0
- package/dist/admin/settings-page.js +126 -0
- package/dist/admin/settings-page.js.map +1 -0
- package/dist/admin/settings-pages.d.ts +19 -0
- package/dist/admin/settings-pages.d.ts.map +1 -0
- package/dist/admin/settings-pages.js +33 -0
- package/dist/admin/settings-pages.js.map +1 -0
- package/dist/admin/settings-permalinks.d.ts +16 -0
- package/dist/admin/settings-permalinks.d.ts.map +1 -0
- package/dist/admin/settings-permalinks.js +32 -0
- package/dist/admin/settings-permalinks.js.map +1 -0
- package/dist/admin/settings-reading.d.ts +33 -0
- package/dist/admin/settings-reading.d.ts.map +1 -0
- package/dist/admin/settings-reading.js +48 -0
- package/dist/admin/settings-reading.js.map +1 -0
- package/dist/admin/settings.d.ts +325 -96
- package/dist/admin/settings.d.ts.map +1 -1
- package/dist/admin/settings.js +650 -308
- package/dist/admin/settings.js.map +1 -1
- package/dist/admin/store.d.ts +606 -152
- package/dist/admin/store.d.ts.map +1 -1
- package/dist/admin/store.js +863 -268
- package/dist/admin/store.js.map +1 -1
- package/dist/admin/taxonomy.d.ts +114 -0
- package/dist/admin/taxonomy.d.ts.map +1 -0
- package/dist/admin/taxonomy.js +289 -0
- package/dist/admin/taxonomy.js.map +1 -0
- package/dist/admin/templates.d.ts +44 -14
- package/dist/admin/templates.d.ts.map +1 -1
- package/dist/admin/templates.js +44 -14
- package/dist/admin/templates.js.map +1 -1
- package/dist/admin/throttle.d.ts +84 -0
- package/dist/admin/throttle.d.ts.map +1 -0
- package/dist/admin/throttle.js +143 -0
- package/dist/admin/throttle.js.map +1 -0
- package/dist/admin/uploads.d.ts +28 -2
- package/dist/admin/uploads.d.ts.map +1 -1
- package/dist/admin/uploads.js +43 -4
- package/dist/admin/uploads.js.map +1 -1
- package/dist/admin/users.d.ts +100 -13
- package/dist/admin/users.d.ts.map +1 -1
- package/dist/admin/users.js +412 -39
- package/dist/admin/users.js.map +1 -1
- package/dist/cache.d.ts +141 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +207 -0
- package/dist/cache.js.map +1 -0
- package/dist/cli.d.ts +14 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +424 -21
- package/dist/cli.js.map +1 -1
- package/dist/comments/akismet.d.ts +130 -0
- package/dist/comments/akismet.d.ts.map +1 -0
- package/dist/comments/akismet.js +274 -0
- package/dist/comments/akismet.js.map +1 -0
- package/dist/comments/conversation.d.ts +29 -0
- package/dist/comments/conversation.d.ts.map +1 -0
- package/dist/comments/conversation.js +60 -0
- package/dist/comments/conversation.js.map +1 -0
- package/dist/comments/form.d.ts +75 -0
- package/dist/comments/form.d.ts.map +1 -0
- package/dist/comments/form.js +64 -0
- package/dist/comments/form.js.map +1 -0
- package/dist/comments/index.d.ts +15 -0
- package/dist/comments/index.d.ts.map +1 -0
- package/dist/comments/index.js +9 -0
- package/dist/comments/index.js.map +1 -0
- package/dist/comments/markdown.d.ts +8 -0
- package/dist/comments/markdown.d.ts.map +1 -0
- package/dist/comments/markdown.js +85 -0
- package/dist/comments/markdown.js.map +1 -0
- package/dist/comments/moderate.d.ts +71 -0
- package/dist/comments/moderate.d.ts.map +1 -0
- package/dist/comments/moderate.js +88 -0
- package/dist/comments/moderate.js.map +1 -0
- package/dist/comments/policy.d.ts +57 -0
- package/dist/comments/policy.d.ts.map +1 -0
- package/dist/comments/policy.js +80 -0
- package/dist/comments/policy.js.map +1 -0
- package/dist/comments/records.d.ts +266 -0
- package/dist/comments/records.d.ts.map +1 -0
- package/dist/comments/records.js +487 -0
- package/dist/comments/records.js.map +1 -0
- package/dist/comments/routes.d.ts +58 -0
- package/dist/comments/routes.d.ts.map +1 -0
- package/dist/comments/routes.js +177 -0
- package/dist/comments/routes.js.map +1 -0
- package/dist/comments/submission.d.ts +263 -0
- package/dist/comments/submission.d.ts.map +1 -0
- package/dist/comments/submission.js +241 -0
- package/dist/comments/submission.js.map +1 -0
- package/dist/config.d.ts +190 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +118 -6
- package/dist/config.js.map +1 -1
- package/dist/contact/delivery.d.ts +60 -0
- package/dist/contact/delivery.d.ts.map +1 -0
- package/dist/contact/delivery.js +87 -0
- package/dist/contact/delivery.js.map +1 -0
- package/dist/contact/form.d.ts +130 -0
- package/dist/contact/form.d.ts.map +1 -0
- package/dist/contact/form.js +163 -0
- package/dist/contact/form.js.map +1 -0
- package/dist/contact/index.d.ts +17 -0
- package/dist/contact/index.d.ts.map +1 -0
- package/dist/contact/index.js +13 -0
- package/dist/contact/index.js.map +1 -0
- package/dist/contact/records.d.ts +124 -0
- package/dist/contact/records.d.ts.map +1 -0
- package/dist/contact/records.js +218 -0
- package/dist/contact/records.js.map +1 -0
- package/dist/contact/routes.d.ts +17 -0
- package/dist/contact/routes.d.ts.map +1 -0
- package/dist/contact/routes.js +127 -0
- package/dist/contact/routes.js.map +1 -0
- package/dist/contact/submission.d.ts +103 -0
- package/dist/contact/submission.d.ts.map +1 -0
- package/dist/contact/submission.js +166 -0
- package/dist/contact/submission.js.map +1 -0
- package/dist/content/document.d.ts +7 -2
- package/dist/content/document.d.ts.map +1 -1
- package/dist/content/document.js +1 -0
- package/dist/content/document.js.map +1 -1
- package/dist/content/index.d.ts +7 -2
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +4 -1
- package/dist/content/index.js.map +1 -1
- package/dist/content/markdown.d.ts.map +1 -1
- package/dist/content/markdown.js +24 -2
- package/dist/content/markdown.js.map +1 -1
- package/dist/content/parser.d.ts.map +1 -1
- package/dist/content/parser.js +11 -4
- package/dist/content/parser.js.map +1 -1
- package/dist/content/save.d.ts +5 -0
- package/dist/content/save.d.ts.map +1 -1
- package/dist/content/save.js +44 -1
- package/dist/content/save.js.map +1 -1
- package/dist/content/schedule.d.ts +125 -0
- package/dist/content/schedule.d.ts.map +1 -0
- package/dist/content/schedule.js +207 -0
- package/dist/content/schedule.js.map +1 -0
- package/dist/content/search.d.ts +64 -0
- package/dist/content/search.d.ts.map +1 -0
- package/dist/content/search.js +136 -0
- package/dist/content/search.js.map +1 -0
- package/dist/content/store.d.ts +202 -7
- package/dist/content/store.d.ts.map +1 -1
- package/dist/content/store.js +374 -67
- package/dist/content/store.js.map +1 -1
- package/dist/content/sync.d.ts +7 -1
- package/dist/content/sync.d.ts.map +1 -1
- package/dist/content/sync.js +18 -10
- package/dist/content/sync.js.map +1 -1
- package/dist/content/time.d.ts +56 -0
- package/dist/content/time.d.ts.map +1 -0
- package/dist/content/time.js +141 -0
- package/dist/content/time.js.map +1 -0
- package/dist/content/writer.d.ts.map +1 -1
- package/dist/content/writer.js +3 -0
- package/dist/content/writer.js.map +1 -1
- package/dist/env.d.ts +58 -4
- package/dist/env.d.ts.map +1 -1
- package/dist/federation/actor.d.ts +95 -41
- package/dist/federation/actor.d.ts.map +1 -1
- package/dist/federation/actor.js +180 -53
- package/dist/federation/actor.js.map +1 -1
- package/dist/federation/article.d.ts +44 -17
- package/dist/federation/article.d.ts.map +1 -1
- package/dist/federation/article.js +98 -46
- package/dist/federation/article.js.map +1 -1
- package/dist/federation/delivery.d.ts +63 -15
- package/dist/federation/delivery.d.ts.map +1 -1
- package/dist/federation/delivery.js +154 -80
- package/dist/federation/delivery.js.map +1 -1
- package/dist/federation/federation.d.ts +22 -17
- package/dist/federation/federation.d.ts.map +1 -1
- package/dist/federation/federation.js +98 -77
- package/dist/federation/federation.js.map +1 -1
- package/dist/federation/followers.d.ts +3 -2
- package/dist/federation/followers.d.ts.map +1 -1
- package/dist/federation/followers.js +6 -5
- package/dist/federation/followers.js.map +1 -1
- package/dist/federation/import-wordpress.d.ts +128 -0
- package/dist/federation/import-wordpress.d.ts.map +1 -0
- package/dist/federation/import-wordpress.js +426 -0
- package/dist/federation/import-wordpress.js.map +1 -0
- package/dist/federation/inbox.d.ts +36 -13
- package/dist/federation/inbox.d.ts.map +1 -1
- package/dist/federation/inbox.js +120 -49
- package/dist/federation/inbox.js.map +1 -1
- package/dist/federation/index.d.ts +22 -10
- package/dist/federation/index.d.ts.map +1 -1
- package/dist/federation/index.js +13 -8
- package/dist/federation/index.js.map +1 -1
- package/dist/federation/keys.d.ts +98 -20
- package/dist/federation/keys.d.ts.map +1 -1
- package/dist/federation/keys.js +269 -39
- package/dist/federation/keys.js.map +1 -1
- package/dist/federation/mount.d.ts +42 -10
- package/dist/federation/mount.d.ts.map +1 -1
- package/dist/federation/mount.js +266 -26
- package/dist/federation/mount.js.map +1 -1
- package/dist/federation/paths.d.ts +23 -35
- package/dist/federation/paths.d.ts.map +1 -1
- package/dist/federation/paths.js +26 -39
- package/dist/federation/paths.js.map +1 -1
- package/dist/federation/records.d.ts +223 -0
- package/dist/federation/records.d.ts.map +1 -0
- package/dist/federation/records.js +506 -0
- package/dist/federation/records.js.map +1 -0
- package/dist/federation/relays.d.ts +114 -0
- package/dist/federation/relays.d.ts.map +1 -0
- package/dist/federation/relays.js +290 -0
- package/dist/federation/relays.js.map +1 -0
- package/dist/federation/replies.d.ts +80 -0
- package/dist/federation/replies.d.ts.map +1 -0
- package/dist/federation/replies.js +166 -0
- package/dist/federation/replies.js.map +1 -0
- package/dist/federation/wordpress.d.ts +131 -0
- package/dist/federation/wordpress.d.ts.map +1 -0
- package/dist/federation/wordpress.js +341 -0
- package/dist/federation/wordpress.js.map +1 -0
- package/dist/files/atomic.d.ts +103 -0
- package/dist/files/atomic.d.ts.map +1 -0
- package/dist/files/atomic.js +150 -0
- package/dist/files/atomic.js.map +1 -0
- package/dist/files/index.d.ts +3 -0
- package/dist/files/index.d.ts.map +1 -0
- package/dist/files/index.js +2 -0
- package/dist/files/index.js.map +1 -0
- package/dist/forms/protection.d.ts +85 -0
- package/dist/forms/protection.d.ts.map +1 -0
- package/dist/forms/protection.js +116 -0
- package/dist/forms/protection.js.map +1 -0
- package/dist/images/icons.d.ts +59 -0
- package/dist/images/icons.d.ts.map +1 -0
- package/dist/images/icons.js +131 -0
- package/dist/images/icons.js.map +1 -0
- package/dist/images/index.d.ts +7 -0
- package/dist/images/index.d.ts.map +1 -0
- package/dist/images/index.js +4 -0
- package/dist/images/index.js.map +1 -0
- package/dist/images/markup.d.ts +47 -0
- package/dist/images/markup.d.ts.map +1 -0
- package/dist/images/markup.js +175 -0
- package/dist/images/markup.js.map +1 -0
- package/dist/images/paths.d.ts +34 -0
- package/dist/images/paths.d.ts.map +1 -0
- package/dist/images/paths.js +41 -0
- package/dist/images/paths.js.map +1 -0
- package/dist/images/variants.d.ts +104 -0
- package/dist/images/variants.d.ts.map +1 -0
- package/dist/images/variants.js +320 -0
- package/dist/images/variants.js.map +1 -0
- package/dist/index.d.ts +123 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +327 -25
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +18 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +34 -3
- package/dist/init.js.map +1 -1
- package/dist/mail/brevo.d.ts +35 -0
- package/dist/mail/brevo.d.ts.map +1 -0
- package/dist/mail/brevo.js +85 -0
- package/dist/mail/brevo.js.map +1 -0
- package/dist/mail/credentials.d.ts +62 -0
- package/dist/mail/credentials.d.ts.map +1 -0
- package/dist/mail/credentials.js +86 -0
- package/dist/mail/credentials.js.map +1 -0
- package/dist/mail/index.d.ts +15 -0
- package/dist/mail/index.d.ts.map +1 -0
- package/dist/mail/index.js +8 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/mail/memory.d.ts +35 -0
- package/dist/mail/memory.d.ts.map +1 -0
- package/dist/mail/memory.js +29 -0
- package/dist/mail/memory.js.map +1 -0
- package/dist/mail/provider.d.ts +80 -0
- package/dist/mail/provider.d.ts.map +1 -0
- package/dist/mail/provider.js +23 -0
- package/dist/mail/provider.js.map +1 -0
- package/dist/mail/service.d.ts +156 -0
- package/dist/mail/service.d.ts.map +1 -0
- package/dist/mail/service.js +265 -0
- package/dist/mail/service.js.map +1 -0
- package/dist/mail/smtp.d.ts +39 -0
- package/dist/mail/smtp.d.ts.map +1 -0
- package/dist/mail/smtp.js +58 -0
- package/dist/mail/smtp.js.map +1 -0
- package/dist/mail/templates.d.ts +91 -0
- package/dist/mail/templates.d.ts.map +1 -0
- package/dist/mail/templates.js +69 -0
- package/dist/mail/templates.js.map +1 -0
- package/dist/notifications/comments.d.ts +66 -0
- package/dist/notifications/comments.d.ts.map +1 -0
- package/dist/notifications/comments.js +151 -0
- package/dist/notifications/comments.js.map +1 -0
- package/dist/notifications/digest.d.ts +135 -0
- package/dist/notifications/digest.d.ts.map +1 -0
- package/dist/notifications/digest.js +287 -0
- package/dist/notifications/digest.js.map +1 -0
- package/dist/notifications/index.d.ts +13 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +8 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/links.d.ts +60 -0
- package/dist/notifications/links.d.ts.map +1 -0
- package/dist/notifications/links.js +63 -0
- package/dist/notifications/links.js.map +1 -0
- package/dist/notifications/optouts.d.ts +48 -0
- package/dist/notifications/optouts.d.ts.map +1 -0
- package/dist/notifications/optouts.js +93 -0
- package/dist/notifications/optouts.js.map +1 -0
- package/dist/notifications/preferences.d.ts +158 -0
- package/dist/notifications/preferences.d.ts.map +1 -0
- package/dist/notifications/preferences.js +195 -0
- package/dist/notifications/preferences.js.map +1 -0
- package/dist/notifications/routes.d.ts +28 -0
- package/dist/notifications/routes.d.ts.map +1 -0
- package/dist/notifications/routes.js +184 -0
- package/dist/notifications/routes.js.map +1 -0
- package/dist/notifications/tokens.d.ts +60 -0
- package/dist/notifications/tokens.d.ts.map +1 -0
- package/dist/notifications/tokens.js +125 -0
- package/dist/notifications/tokens.js.map +1 -0
- package/dist/notify.d.ts +84 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +149 -0
- package/dist/notify.js.map +1 -0
- package/dist/web/archive.d.ts +49 -0
- package/dist/web/archive.d.ts.map +1 -0
- package/dist/web/archive.js +59 -0
- package/dist/web/archive.js.map +1 -0
- package/dist/web/assets.d.ts +6 -5
- package/dist/web/assets.d.ts.map +1 -1
- package/dist/web/assets.js +5 -7
- package/dist/web/assets.js.map +1 -1
- package/dist/web/authors.d.ts +143 -0
- package/dist/web/authors.d.ts.map +1 -0
- package/dist/web/authors.js +178 -0
- package/dist/web/authors.js.map +1 -0
- package/dist/web/comments.d.ts +60 -0
- package/dist/web/comments.d.ts.map +1 -0
- package/dist/web/comments.js +207 -0
- package/dist/web/comments.js.map +1 -0
- package/dist/web/context.d.ts +162 -28
- package/dist/web/context.d.ts.map +1 -1
- package/dist/web/context.js +123 -26
- package/dist/web/context.js.map +1 -1
- package/dist/web/conversation.d.ts +209 -0
- package/dist/web/conversation.d.ts.map +1 -0
- package/dist/web/conversation.js +557 -0
- package/dist/web/conversation.js.map +1 -0
- package/dist/web/documents.d.ts +36 -6
- package/dist/web/documents.d.ts.map +1 -1
- package/dist/web/documents.js +52 -10
- package/dist/web/documents.js.map +1 -1
- package/dist/web/feed-atom.d.ts +22 -0
- package/dist/web/feed-atom.d.ts.map +1 -0
- package/dist/web/feed-atom.js +83 -0
- package/dist/web/feed-atom.js.map +1 -0
- package/dist/web/feed-item.d.ts +145 -0
- package/dist/web/feed-item.d.ts.map +1 -0
- package/dist/web/feed-item.js +120 -0
- package/dist/web/feed-item.js.map +1 -0
- package/dist/web/feed-json.d.ts +79 -0
- package/dist/web/feed-json.d.ts.map +1 -0
- package/dist/web/feed-json.js +53 -0
- package/dist/web/feed-json.js.map +1 -0
- package/dist/web/feed-rss.d.ts +26 -0
- package/dist/web/feed-rss.d.ts.map +1 -0
- package/dist/web/feed-rss.js +203 -0
- package/dist/web/feed-rss.js.map +1 -0
- package/dist/web/feed-source.d.ts +244 -0
- package/dist/web/feed-source.d.ts.map +1 -0
- package/dist/web/feed-source.js +201 -0
- package/dist/web/feed-source.js.map +1 -0
- package/dist/web/feed-xml.d.ts +63 -0
- package/dist/web/feed-xml.d.ts.map +1 -0
- package/dist/web/feed-xml.js +116 -0
- package/dist/web/feed-xml.js.map +1 -0
- package/dist/web/feeds.d.ts +31 -96
- package/dist/web/feeds.d.ts.map +1 -1
- package/dist/web/feeds.js +94 -198
- package/dist/web/feeds.js.map +1 -1
- package/dist/web/health.d.ts +31 -0
- package/dist/web/health.d.ts.map +1 -0
- package/dist/web/health.js +44 -0
- package/dist/web/health.js.map +1 -0
- package/dist/web/index.d.ts +30 -10
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +18 -7
- package/dist/web/index.js.map +1 -1
- package/dist/web/navigation.d.ts +73 -0
- package/dist/web/navigation.d.ts.map +1 -0
- package/dist/web/navigation.js +110 -0
- package/dist/web/navigation.js.map +1 -0
- package/dist/web/negotiate.d.ts +9 -0
- package/dist/web/negotiate.d.ts.map +1 -1
- package/dist/web/negotiate.js +6 -1
- package/dist/web/negotiate.js.map +1 -1
- package/dist/web/recent.d.ts +43 -0
- package/dist/web/recent.d.ts.map +1 -0
- package/dist/web/recent.js +37 -0
- package/dist/web/recent.js.map +1 -0
- package/dist/web/render.d.ts +197 -9
- package/dist/web/render.d.ts.map +1 -1
- package/dist/web/render.js +334 -17
- package/dist/web/render.js.map +1 -1
- package/dist/web/routes.d.ts +25 -8
- package/dist/web/routes.d.ts.map +1 -1
- package/dist/web/routes.js +845 -93
- package/dist/web/routes.js.map +1 -1
- package/dist/web/sanitize.d.ts +19 -0
- package/dist/web/sanitize.d.ts.map +1 -0
- package/dist/web/sanitize.js +272 -0
- package/dist/web/sanitize.js.map +1 -0
- package/dist/web/search.d.ts +79 -0
- package/dist/web/search.d.ts.map +1 -0
- package/dist/web/search.js +94 -0
- package/dist/web/search.js.map +1 -0
- package/dist/web/sitemap.d.ts +120 -0
- package/dist/web/sitemap.d.ts.map +1 -0
- package/dist/web/sitemap.js +199 -0
- package/dist/web/sitemap.js.map +1 -0
- package/dist/web/taxonomy.d.ts +152 -0
- package/dist/web/taxonomy.d.ts.map +1 -0
- package/dist/web/taxonomy.js +237 -0
- package/dist/web/taxonomy.js.map +1 -0
- package/dist/web/templates.d.ts +54 -16
- package/dist/web/templates.d.ts.map +1 -1
- package/dist/web/templates.js +109 -28
- package/dist/web/templates.js.map +1 -1
- package/dist/web/themes.d.ts +205 -0
- package/dist/web/themes.d.ts.map +1 -0
- package/dist/web/themes.js +277 -0
- package/dist/web/themes.js.map +1 -0
- package/dist/webmention/discovery.d.ts +51 -0
- package/dist/webmention/discovery.d.ts.map +1 -0
- package/dist/webmention/discovery.js +176 -0
- package/dist/webmention/discovery.js.map +1 -0
- package/dist/webmention/html.d.ts +71 -0
- package/dist/webmention/html.d.ts.map +1 -0
- package/dist/webmention/html.js +285 -0
- package/dist/webmention/html.js.map +1 -0
- package/dist/webmention/index.d.ts +12 -0
- package/dist/webmention/index.d.ts.map +1 -0
- package/dist/webmention/index.js +8 -0
- package/dist/webmention/index.js.map +1 -0
- package/dist/webmention/links.d.ts +18 -0
- package/dist/webmention/links.d.ts.map +1 -0
- package/dist/webmention/links.js +64 -0
- package/dist/webmention/links.js.map +1 -0
- package/dist/webmention/microformats.d.ts +93 -0
- package/dist/webmention/microformats.d.ts.map +1 -0
- package/dist/webmention/microformats.js +376 -0
- package/dist/webmention/microformats.js.map +1 -0
- package/dist/webmention/receive.d.ts +141 -0
- package/dist/webmention/receive.d.ts.map +1 -0
- package/dist/webmention/receive.js +264 -0
- package/dist/webmention/receive.js.map +1 -0
- package/dist/webmention/routes.d.ts +37 -0
- package/dist/webmention/routes.d.ts.map +1 -0
- package/dist/webmention/routes.js +75 -0
- package/dist/webmention/routes.js.map +1 -0
- package/dist/webmention/service.d.ts +94 -0
- package/dist/webmention/service.d.ts.map +1 -0
- package/dist/webmention/service.js +207 -0
- package/dist/webmention/service.js.map +1 -0
- package/package.json +11 -6
- package/templates/site/content/_data/site.json +1 -0
- package/templates/site/content/posts/2026-01-01-hello-world.md +5 -3
- package/templates/site/geekity.config.ts +11 -1
- package/templates/site/tsconfig.json +1 -1
- package/themes/default/README.md +1096 -50
- package/themes/default/layouts/404.njk +2 -3
- package/themes/default/layouts/author.njk +37 -0
- package/themes/default/layouts/base.njk +172 -31
- package/themes/default/layouts/category.njk +27 -0
- package/themes/default/layouts/front-page.njk +57 -0
- package/themes/default/layouts/home.njk +17 -1
- package/themes/default/layouts/page.njk +57 -5
- package/themes/default/layouts/post.njk +78 -19
- package/themes/default/layouts/search.njk +57 -0
- package/themes/default/layouts/tag.njk +3 -6
- package/themes/default/mail/comment-digest.html.njk +37 -0
- package/themes/default/mail/comment-digest.subject.njk +3 -0
- package/themes/default/mail/comment-digest.txt.njk +40 -0
- package/themes/default/mail/comment-pending.html.njk +27 -0
- package/themes/default/mail/comment-pending.subject.njk +2 -0
- package/themes/default/mail/comment-pending.txt.njk +24 -0
- package/themes/default/mail/comment-reply.html.njk +21 -0
- package/themes/default/mail/comment-reply.subject.njk +2 -0
- package/themes/default/mail/comment-reply.txt.njk +22 -0
- package/themes/default/mail/contact-message.html.njk +24 -0
- package/themes/default/mail/contact-message.subject.njk +5 -0
- package/themes/default/mail/contact-message.txt.njk +20 -0
- package/themes/default/mail/password-changed.html.njk +18 -0
- package/themes/default/mail/password-changed.subject.njk +2 -0
- package/themes/default/mail/password-changed.txt.njk +17 -0
- package/themes/default/mail/password-reset.html.njk +22 -0
- package/themes/default/mail/password-reset.subject.njk +2 -0
- package/themes/default/mail/password-reset.txt.njk +18 -0
- package/themes/default/mail/test.html.njk +14 -0
- package/themes/default/mail/test.subject.njk +2 -0
- package/themes/default/mail/test.txt.njk +12 -0
- package/themes/default/partials/archive.njk +27 -0
- package/themes/default/partials/bio.njk +77 -0
- package/themes/default/partials/comment-form.njk +109 -0
- package/themes/default/partials/contact-form.njk +88 -0
- package/themes/default/partials/conversation.njk +139 -0
- package/themes/default/partials/feeds.njk +26 -0
- package/themes/default/partials/jsonld.njk +120 -0
- package/themes/default/partials/pagination.njk +12 -6
- package/themes/default/partials/post-list.njk +51 -18
- package/themes/default/partials/search-form.njk +17 -0
- package/themes/default/partials/tags.njk +26 -5
- package/themes/default/static/highlight.js +4 -0
- package/themes/default/static/style.css +1119 -194
- package/themes/default/theme.json +5 -0
- package/admin/layouts/document-editor.njk +0 -167
- package/admin/layouts/federation.njk +0 -145
- package/admin/layouts/login.njk +0 -23
- package/admin/layouts/settings.njk +0 -116
- package/admin/layouts/setup.njk +0 -27
- package/admin/layouts/users.njk +0 -91
- /package/admin/{layouts/_flash.njk → components/flash.njk} +0 -0
package/dist/web/routes.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
+
import { listUsers } from '../admin/accounts.js';
|
|
2
|
+
import { readSiteSettings } from '../admin/settings.js';
|
|
1
3
|
import { serializeDocument } from '../content/writer.js';
|
|
2
|
-
import {
|
|
4
|
+
import { findImageVariant, VARIANT_ASSET_PREFIX } from '../images/variants.js';
|
|
5
|
+
import { assetNotModified, assetResponse, findThemeAsset, findUpload, matchesEtag, themeAssetNotModified, themeAssetResponse, THEME_ASSET_PREFIX, UPLOAD_ASSET_MAX_AGE, UPLOAD_ASSET_PREFIX, } from './assets.js';
|
|
6
|
+
import { COMMENT_NOTICE_PARAM, COMMENT_REPLY_PARAM } from '../comments/form.js';
|
|
7
|
+
import { commentNoticeFor, commentReplyTarget, mountComments } from '../comments/routes.js';
|
|
8
|
+
import { CONTACT_NOTICE_PARAM, contactNoticeFor } from '../contact/form.js';
|
|
9
|
+
import { mountContact } from '../contact/routes.js';
|
|
10
|
+
import { mountWebmentions, WEBMENTION_PATH } from '../webmention/routes.js';
|
|
11
|
+
import { mountNotificationLinks } from '../notifications/routes.js';
|
|
12
|
+
import { authorFeedHref, authorHref, authorNames, parseAuthorPath, profileContext, } from './authors.js';
|
|
13
|
+
import { feedComments, spokenIn } from './conversation.js';
|
|
3
14
|
import { isPublicDocument, publicDocumentAt } from './documents.js';
|
|
4
|
-
import { feedResponse, feedSize,
|
|
5
|
-
import { DOCUMENT_REPRESENTATIONS, documentJson, LISTING_REPRESENTATIONS, lastModifiedOf, latestModified, notAcceptableResponse, representationEtag, representationResponse, selectRepresentation, splitRepresentationExtension, } from './negotiate.js';
|
|
15
|
+
import { commentsFeedPath, commentsFeedResponse, feedPathUnder, feedResponse, feedSize, splitFeedPath, COMMENTS_ROOT, COMMENTS_TITLE_PREFIX, FEED_FORMATS, FEED_SEGMENTS, } from './feeds.js';
|
|
16
|
+
import { DOCUMENT_REPRESENTATIONS, documentJson, LISTING_REPRESENTATIONS, lastModifiedOf, latestModified, MEDIA_TYPES, notAcceptableResponse, representationHref, representationEtag, representationResponse, selectRepresentation, splitRepresentationExtension, } from './negotiate.js';
|
|
6
17
|
import { offsetForPage, paginate } from './pagination.js';
|
|
7
18
|
import { TEMPLATES } from './render.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export const TAG_SEGMENT = 'tags';
|
|
19
|
+
import { robotsResponse, sitemapResponse, ROBOTS_PATH, SITEMAP_CHILD_ROUTE, SITEMAP_PATH, } from './sitemap.js';
|
|
20
|
+
import { searchHref, searchJson, searchPageIndex, searchQuery, SEARCH_PAGE_PARAM, SEARCH_PATH, SEARCH_QUERY_PARAM, } from './search.js';
|
|
21
|
+
import { PAGE_SEGMENT, redirectedTerm, taxonomyForSegment, termHref } from './taxonomy.js';
|
|
12
22
|
/**
|
|
13
23
|
* Register the public site on a Hono app.
|
|
14
24
|
*
|
|
@@ -19,84 +29,361 @@ export const TAG_SEGMENT = 'tags';
|
|
|
19
29
|
*/
|
|
20
30
|
export function mountPublicSite(app) {
|
|
21
31
|
app.get(`${THEME_ASSET_PREFIX}*`, themeAsset);
|
|
32
|
+
// Derived images go on first: their prefix is inside the uploads one, so the
|
|
33
|
+
// general route would otherwise swallow them and answer 404 for a file that
|
|
34
|
+
// is not under `content/uploads/` at all.
|
|
35
|
+
app.get(`${VARIANT_ASSET_PREFIX}*`, imageVariant);
|
|
22
36
|
app.get(`${UPLOAD_ASSET_PREFIX}*`, upload);
|
|
23
|
-
|
|
37
|
+
// Where the comment form under a post posts to (TASK-50). A POST at a fixed
|
|
38
|
+
// path of the CMS's own, so no permalink can ever shadow it and the route
|
|
39
|
+
// table does not grow with the site.
|
|
40
|
+
mountComments(app);
|
|
41
|
+
// And where a contact form's message is sent (TASK-56): the same prefix
|
|
42
|
+
// again, so the page a form is on can be permalinked anywhere.
|
|
43
|
+
mountContact(app);
|
|
44
|
+
// And where a webmention is sent (TASK-51), for the same reason and under
|
|
45
|
+
// the same prefix.
|
|
46
|
+
mountWebmentions(app);
|
|
47
|
+
// And where the one-click links in a notification land (TASK-55): the same
|
|
48
|
+
// prefix again, and no session behind either of them.
|
|
49
|
+
mountNotificationLinks(app);
|
|
50
|
+
app.get('/', (c) => {
|
|
51
|
+
// The site's latest posts, or the page the Reading setting names — the
|
|
52
|
+
// whole of WordPress's "Your homepage displays", decided per request off
|
|
53
|
+
// `site.json` so a save on the settings screen moves the front page on the
|
|
54
|
+
// very next one.
|
|
55
|
+
const home = frontPages(c).home;
|
|
56
|
+
if (home === undefined)
|
|
57
|
+
return listing(c, { term: undefined, pageNumber: 0 });
|
|
58
|
+
return negotiateDocument(c, home, selectFromAccept(c, DOCUMENT_REPRESENTATIONS), '/');
|
|
59
|
+
});
|
|
24
60
|
app.get(`/${PAGE_SEGMENT}/:page{[0-9]+}/`, (c) => {
|
|
25
61
|
const requested = Number(c.req.param('page'));
|
|
26
62
|
// Page one is the home page; it does not get a second URL.
|
|
27
63
|
if (requested <= 1)
|
|
28
64
|
return c.redirect('/', 301);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
app.get(`/${TAG_SEGMENT}/:tag/`, (c) => listing(c, { tag: c.req.param('tag'), pageNumber: 0 }));
|
|
40
|
-
app.get(`/${TAG_SEGMENT}/:tag/${PAGE_SEGMENT}/:page{[0-9]+}/`, (c) => {
|
|
41
|
-
const tag = c.req.param('tag');
|
|
42
|
-
const requested = Number(c.req.param('page'));
|
|
43
|
-
if (requested <= 1)
|
|
44
|
-
return c.redirect(tagHref(tag, 0), 301);
|
|
45
|
-
return listing(c, { tag, pageNumber: requested - 1 });
|
|
65
|
+
const pages = frontPages(c);
|
|
66
|
+
// With a posts page, the listing's pages live under it and these are the
|
|
67
|
+
// URLs they used to have; with a static homepage and no posts page, the
|
|
68
|
+
// listing has no page of its own and neither have its pages.
|
|
69
|
+
if (pages.posts !== undefined) {
|
|
70
|
+
return c.redirect(listingPageHref(pages.posts.permalink, requested - 1), 301);
|
|
71
|
+
}
|
|
72
|
+
if (pages.home !== undefined)
|
|
73
|
+
return notFound(c);
|
|
74
|
+
return listing(c, { term: undefined, pageNumber: requested - 1 });
|
|
46
75
|
});
|
|
47
|
-
|
|
76
|
+
// The site's own feeds are routes rather than representations, so a reader's
|
|
77
|
+
// careless `Accept` header cannot land it on the HTML (doc-3), and so a
|
|
78
|
+
// document permalinked at `/feed/` cannot take the subscribers' URL. Their
|
|
79
|
+
// paths are fixed — only the taxonomy feeds hang off a configurable base —
|
|
80
|
+
// so the route table can hold them.
|
|
81
|
+
for (const format of FEED_FORMATS) {
|
|
82
|
+
app.get(feedPathUnder('/', format), (c) => feed(c, format, {}));
|
|
83
|
+
}
|
|
84
|
+
// The site-wide comments feed, for the same reason and at WordPress's URL.
|
|
85
|
+
app.get(commentsFeedHref(undefined), (c) => comments(c, undefined));
|
|
86
|
+
// The sitemap, its children and the robots file: fixed paths at the root of
|
|
87
|
+
// the site, which is the only place a crawler looks, and routes for the same
|
|
88
|
+
// reason the feeds are — no document permalinked there can take the URL a
|
|
89
|
+
// search engine polls.
|
|
90
|
+
app.get(SITEMAP_PATH, (c) => sitemap(c, undefined));
|
|
91
|
+
app.get(SITEMAP_CHILD_ROUTE, (c) => sitemap(c, Number(c.req.param('page'))));
|
|
92
|
+
app.get(ROBOTS_PATH, (c) => robotsResponse(c.var.config.baseUrl, conditionalHeaders(c)));
|
|
93
|
+
// The site's search (TASK-22): a route at a fixed path for the reason the
|
|
94
|
+
// feeds are, so the form in every theme's footer submits somewhere no
|
|
95
|
+
// permalink can take. It negotiates HTML and JSON like a listing, and
|
|
96
|
+
// `/search/index.json` is the same escape hatch a listing has. The path
|
|
97
|
+
// without its slash is where a hand-typed URL lands, and keeps its query on
|
|
98
|
+
// the way to the real one.
|
|
99
|
+
app.get(SEARCH_PATH, (c) => search(c, selectFromAccept(c, LISTING_REPRESENTATIONS)));
|
|
100
|
+
app.get(representationHref(SEARCH_PATH, 'json'), (c) => search(c, 'json'));
|
|
101
|
+
app.get(SEARCH_PATH.slice(0, -1), (c) => c.redirect(`${SEARCH_PATH}${new URL(c.req.url).search}`, 301));
|
|
102
|
+
// The taxonomy archives are deliberately not routes. A route table is fixed
|
|
103
|
+
// when the app is built and the bases are a setting, so an archive is
|
|
104
|
+
// resolved per request in the not-found handler, from the base the site
|
|
105
|
+
// holds at that moment (TASK-36).
|
|
106
|
+
app.notFound(resolveRequest);
|
|
48
107
|
}
|
|
49
108
|
/**
|
|
50
|
-
* The last stop for a request:
|
|
51
|
-
*
|
|
52
|
-
* should have asked for, or the
|
|
109
|
+
* The last stop for a request: a taxonomy archive or one of its feeds, the
|
|
110
|
+
* document at this URL, the same document in the representation a `.md` or
|
|
111
|
+
* `.json` suffix asked for, the canonical URL it should have asked for, or the
|
|
112
|
+
* theme's 404.
|
|
53
113
|
*
|
|
54
|
-
* The
|
|
55
|
-
*
|
|
114
|
+
* The archives come first, so an archive URL means the archive however a
|
|
115
|
+
* document is permalinked; they are here rather than in the route table
|
|
116
|
+
* because their bases are a setting, and a route table is fixed when the app
|
|
117
|
+
* is built. The suffix is stripped and the *same* {@link publicDocumentAt}
|
|
118
|
+
* lookup runs again, so no representation can resolve to a document the others
|
|
119
|
+
* cannot see.
|
|
56
120
|
*/
|
|
57
|
-
function
|
|
58
|
-
const { store } = c.var;
|
|
121
|
+
function resolveRequest(c) {
|
|
122
|
+
const { store, renderer } = c.var;
|
|
59
123
|
const pathname = requestPath(c);
|
|
124
|
+
const bases = renderer.taxonomyBases();
|
|
125
|
+
const authors = authorsOf(c);
|
|
126
|
+
const pages = frontPages(c);
|
|
127
|
+
// The posts page carries the listing at its own URL, so it is answered
|
|
128
|
+
// before the document lookup that would otherwise render it as the page it
|
|
129
|
+
// also is. Its pagination hangs off it: `{permalink}page/2/`.
|
|
130
|
+
if (pages.posts !== undefined) {
|
|
131
|
+
const request = postsPageRequest(pages.posts, pathname);
|
|
132
|
+
if (request !== undefined) {
|
|
133
|
+
// `{permalink}page/1/` is the listing's own URL spelled twice, and
|
|
134
|
+
// collapses onto it exactly as `/page/1/` collapses onto `/`.
|
|
135
|
+
if (request.pageNumber === 0 && pathname !== pages.posts.permalink) {
|
|
136
|
+
return c.redirect(encodePath(pages.posts.permalink), 301);
|
|
137
|
+
}
|
|
138
|
+
return listing(c, request);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const feedRequest = parseFeedPath(store, pathname, bases, authors);
|
|
142
|
+
if (feedRequest !== undefined) {
|
|
143
|
+
const { target, format } = feedRequest;
|
|
144
|
+
if (!feedRequest.canonical)
|
|
145
|
+
return c.redirect(feedTargetHref(target, format, bases), 301);
|
|
146
|
+
return target.kind === 'listing'
|
|
147
|
+
? feed(c, format, target.subject)
|
|
148
|
+
: comments(c, target.document);
|
|
149
|
+
}
|
|
150
|
+
const archive = taxonomyArchive(c, pathname, bases, authors);
|
|
151
|
+
if (archive !== undefined)
|
|
152
|
+
return archive;
|
|
153
|
+
// And one person's, which is the same kind of thing at a path the site
|
|
154
|
+
// reserves: `author` is never a document's first segment, so this can be
|
|
155
|
+
// answered before the permalink lookup without anything being shadowed.
|
|
156
|
+
const byAuthor = authorArchive(c, pathname, bases, authors);
|
|
157
|
+
if (byAuthor !== undefined)
|
|
158
|
+
return byAuthor;
|
|
60
159
|
const document = publicDocumentAt(store, pathname);
|
|
61
160
|
if (document !== undefined) {
|
|
161
|
+
// The front page has one URL. The page it is made of keeps its own
|
|
162
|
+
// permalink in the file, so that a homepage put back to being an ordinary
|
|
163
|
+
// page goes back to answering there, and that URL points at `/` while it
|
|
164
|
+
// is the front page.
|
|
165
|
+
if (document.path === pages.home?.path)
|
|
166
|
+
return c.redirect('/', 301);
|
|
167
|
+
// WordPress answered `?feed=rss2` on a permalink with that post's comments
|
|
168
|
+
// feed, which is the only feed a post has here too. The other spellings
|
|
169
|
+
// name a format a comments feed does not come in, so they are not a feed
|
|
170
|
+
// request at all and the page is served.
|
|
171
|
+
if (document.type === 'post' && queryFeedFormat(c) === 'rss') {
|
|
172
|
+
return c.redirect(commentsFeedHref(document), 301);
|
|
173
|
+
}
|
|
62
174
|
return negotiateDocument(c, document, selectFromAccept(c, DOCUMENT_REPRESENTATIONS));
|
|
63
175
|
}
|
|
64
176
|
const extension = splitRepresentationExtension(pathname);
|
|
65
177
|
if (extension !== undefined) {
|
|
66
178
|
for (const candidate of extension.paths) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
179
|
+
// `/index.md` and `/index.json` are the front page's own
|
|
180
|
+
// representations on a site whose `/` is a page: the document is at `/`
|
|
181
|
+
// however it is asked for.
|
|
182
|
+
const found = candidate === '/' ? pages.home : publicDocumentAt(store, candidate);
|
|
183
|
+
if (found !== undefined) {
|
|
184
|
+
return negotiateDocument(c, found, extension.representation, candidate === '/' ? '/' : undefined);
|
|
185
|
+
}
|
|
70
186
|
}
|
|
71
|
-
// `/index.json`, `/page/2/index.json`, `/
|
|
72
|
-
// escape hatch over a listing, for the
|
|
187
|
+
// `/index.json`, `/page/2/index.json`, `/tag/x/index.json`,
|
|
188
|
+
// `/category/x/index.json`: the same escape hatch over a listing, for the
|
|
189
|
+
// representations a listing has.
|
|
73
190
|
if (LISTING_REPRESENTATIONS.includes(extension.representation)) {
|
|
74
191
|
for (const candidate of extension.paths) {
|
|
75
|
-
const request =
|
|
192
|
+
const request = listingRequestAt(pages, candidate, bases, authors);
|
|
76
193
|
if (request !== undefined)
|
|
77
194
|
return listing(c, request, extension.representation);
|
|
78
195
|
}
|
|
79
196
|
}
|
|
80
197
|
}
|
|
81
|
-
const canonical = canonicalPath(c, pathname);
|
|
198
|
+
const canonical = canonicalPath(c, pathname, bases, authors);
|
|
82
199
|
if (canonical !== undefined)
|
|
83
200
|
return c.redirect(canonical, 301);
|
|
84
201
|
return notFound(c);
|
|
85
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* One taxonomy archive, the redirect that puts it at its canonical URL, or
|
|
205
|
+
* `undefined` when the path is not one.
|
|
206
|
+
*
|
|
207
|
+
* `/{base}/x/page/1/` collapses onto the archive root the way `/page/1/`
|
|
208
|
+
* collapses onto the home page, and an archive nothing carries 404s rather
|
|
209
|
+
* than redirecting first: a URL that leads nowhere should cost one 404, not a
|
|
210
|
+
* redirect and then a 404.
|
|
211
|
+
*/
|
|
212
|
+
function taxonomyArchive(c, pathname, bases, authors) {
|
|
213
|
+
if (!pathname.endsWith('/'))
|
|
214
|
+
return undefined;
|
|
215
|
+
const request = parseListingPath(pathname, bases, authors);
|
|
216
|
+
if (request?.term === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
// An archive that answers is served; only once nothing carries the term is
|
|
219
|
+
// the record of renames consulted, so a term that comes back into use — or
|
|
220
|
+
// one that was merged into and then recreated — beats what it used to be
|
|
221
|
+
// called. One hop: the list is stored with its chains already collapsed.
|
|
222
|
+
if (countListing(c.var.store, request) === 0) {
|
|
223
|
+
const moved = movedTerm(c, request.term);
|
|
224
|
+
if (moved !== undefined)
|
|
225
|
+
return c.redirect(termHref(moved, request.pageNumber, bases), 301);
|
|
226
|
+
}
|
|
227
|
+
const canonical = termHref(request.term, request.pageNumber, bases);
|
|
228
|
+
if (canonical !== encodePath(pathname)) {
|
|
229
|
+
return countListing(c.var.store, request) === 0 ? notFound(c) : c.redirect(canonical, 301);
|
|
230
|
+
}
|
|
231
|
+
return listing(c, request);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* One person's archive, the redirect that puts it at its canonical URL, or
|
|
235
|
+
* `undefined` when the path is not one.
|
|
236
|
+
*
|
|
237
|
+
* Unlike a taxonomy archive it does not depend on there being anything on it.
|
|
238
|
+
* A tag exists only while something carries it; a person exists because they
|
|
239
|
+
* have an account, and after decision-14 this URL is the id their followers
|
|
240
|
+
* file them under — so an archive that 404'd until its owner published would
|
|
241
|
+
* be an account that came into being with a post. What decides the 404 is
|
|
242
|
+
* whether the username is somebody's, which {@link parseListingPath} has
|
|
243
|
+
* already asked.
|
|
244
|
+
*
|
|
245
|
+
* `/author/{username}/page/1/` collapses onto the archive root the way
|
|
246
|
+
* `/page/1/` collapses onto the home page.
|
|
247
|
+
*/
|
|
248
|
+
function authorArchive(c, pathname, bases, authors) {
|
|
249
|
+
if (!pathname.endsWith('/'))
|
|
250
|
+
return undefined;
|
|
251
|
+
const request = parseListingPath(pathname, bases, authors);
|
|
252
|
+
if (request?.author === undefined)
|
|
253
|
+
return undefined;
|
|
254
|
+
const canonical = authorHref(request.author.user.username, request.pageNumber);
|
|
255
|
+
if (canonical !== encodePath(pathname))
|
|
256
|
+
return c.redirect(canonical, 301);
|
|
257
|
+
return listing(c, request);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Where a term with nothing left under it went, or `undefined` when the site
|
|
261
|
+
* records no such rename.
|
|
262
|
+
*/
|
|
263
|
+
function movedTerm(c, term) {
|
|
264
|
+
const moved = redirectedTerm(c.var.renderer.termRedirects(), term);
|
|
265
|
+
return moved === undefined ? undefined : { taxonomy: term.taxonomy, term: moved };
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* A path as the feed it names: `/feed/`, `/feed/atom/`, `/{base}/x/feed/json/`,
|
|
269
|
+
* the comments feeds at `/comments/feed/` and `{permalink}feed/`, and the
|
|
270
|
+
* `/feed/rss/` spelling WordPress also answered at any of those roots.
|
|
271
|
+
*
|
|
272
|
+
* The site's own canonical feeds are real routes and never reach here; what
|
|
273
|
+
* does reach here is every taxonomy feed — their bases are a setting, so they
|
|
274
|
+
* cannot be in the route table — every post's comments feed, and every alias.
|
|
275
|
+
*/
|
|
276
|
+
function parseFeedPath(store, pathname, bases, authors) {
|
|
277
|
+
const split = splitFeedPath(pathname);
|
|
278
|
+
if (split === undefined)
|
|
279
|
+
return undefined;
|
|
280
|
+
const { format, canonical } = split;
|
|
281
|
+
if (split.root === COMMENTS_ROOT) {
|
|
282
|
+
return format === 'rss'
|
|
283
|
+
? { target: { kind: 'comments', document: undefined }, format, canonical }
|
|
284
|
+
: undefined;
|
|
285
|
+
}
|
|
286
|
+
const root = parseListingPath(split.root, bases, authors);
|
|
287
|
+
// Only a listing root has a feed, and only its first page: a feed is not
|
|
288
|
+
// paginated, so `/{base}/x/page/2/feed/` names nothing.
|
|
289
|
+
if (root !== undefined) {
|
|
290
|
+
return root.pageNumber === 0
|
|
291
|
+
? { target: { kind: 'listing', subject: root }, format, canonical }
|
|
292
|
+
: undefined;
|
|
293
|
+
}
|
|
294
|
+
// Otherwise it may be a post's comments feed. Only a published post has one:
|
|
295
|
+
// a page never federates, so nothing in the fediverse can ever have replied
|
|
296
|
+
// to it, and a comments feed for it would be empty for ever.
|
|
297
|
+
if (format !== 'rss')
|
|
298
|
+
return undefined;
|
|
299
|
+
const document = publicDocumentAt(store, split.root);
|
|
300
|
+
if (document?.type !== 'post')
|
|
301
|
+
return undefined;
|
|
302
|
+
return { target: { kind: 'comments', document }, format, canonical };
|
|
303
|
+
}
|
|
304
|
+
/** Where the canonical URL of one feed is. */
|
|
305
|
+
function feedTargetHref(target, format, bases) {
|
|
306
|
+
return target.kind === 'listing'
|
|
307
|
+
? listingFeedHref(target.subject, format, bases)
|
|
308
|
+
: commentsFeedHref(target.document);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* The format `?feed=` asked for, WordPress's pre-permalink spelling, or
|
|
312
|
+
* `undefined` when the request did not ask for a feed at all.
|
|
313
|
+
*
|
|
314
|
+
* `rss2` is what WordPress calls RSS 2.0 and `rss` its RSS 0.92, which this
|
|
315
|
+
* site does not serve and answers with the RSS 2.0 feed rather than a 404.
|
|
316
|
+
*/
|
|
317
|
+
function queryFeedFormat(c) {
|
|
318
|
+
const asked = c.req.query('feed');
|
|
319
|
+
if (asked === undefined)
|
|
320
|
+
return undefined;
|
|
321
|
+
if (asked === 'rss2' || asked === 'rss')
|
|
322
|
+
return 'rss';
|
|
323
|
+
return FEED_FORMATS.find((format) => FEED_SEGMENTS[format] === asked);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* What the query string puts on a rendered post, if anything.
|
|
327
|
+
*
|
|
328
|
+
* A reader has no session, so the message after a submission travels in the
|
|
329
|
+
* URL and is read back here. An unknown value says nothing at all rather than
|
|
330
|
+
* being printed, so the query cannot be used to put words on somebody's post.
|
|
331
|
+
*/
|
|
332
|
+
function commentNotice(c, document) {
|
|
333
|
+
const notice = commentNoticeFor(c.req.query(COMMENT_NOTICE_PARAM));
|
|
334
|
+
return {
|
|
335
|
+
...(notice === undefined ? {} : { commentNotice: notice }),
|
|
336
|
+
// And who a Reply link says the form is answering, which travels the same
|
|
337
|
+
// way and for the same reason: a reader has no session, and threading
|
|
338
|
+
// should not need a line of JavaScript.
|
|
339
|
+
...commentReplyTarget({
|
|
340
|
+
admin: c.var.admin,
|
|
341
|
+
document,
|
|
342
|
+
id: c.req.query(COMMENT_REPLY_PARAM),
|
|
343
|
+
}),
|
|
344
|
+
// And the thank-you after a contact form was sent, which travels the same
|
|
345
|
+
// way for the same reason (TASK-56).
|
|
346
|
+
...contactNotice(c),
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* The thank-you a contact form's redirect landed on, if the query names one.
|
|
351
|
+
*
|
|
352
|
+
* On the context rather than in the form's own state because the redirect is
|
|
353
|
+
* what makes a refresh harmless: the page is drawn fresh, and the query is the
|
|
354
|
+
* only thing that says a message went.
|
|
355
|
+
*/
|
|
356
|
+
function contactNotice(c) {
|
|
357
|
+
const notice = contactNoticeFor(c.req.query(CONTACT_NOTICE_PARAM));
|
|
358
|
+
return notice === undefined ? {} : { contactNotice: notice };
|
|
359
|
+
}
|
|
86
360
|
/** The representation an `Accept` header asked for, or `undefined` for a 406. */
|
|
87
361
|
function selectFromAccept(c, available) {
|
|
88
362
|
return selectRepresentation(c.req.header('accept'), available);
|
|
89
363
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
364
|
+
/**
|
|
365
|
+
* One document in one representation, or the 406 an impossible `Accept` earns.
|
|
366
|
+
*
|
|
367
|
+
* `href` is where it is being served, which is its own permalink everywhere
|
|
368
|
+
* but the front page: a page serving as the homepage is read at `/`, and the
|
|
369
|
+
* canonical URL, the alternates and the theme's own links have to say so.
|
|
370
|
+
*/
|
|
371
|
+
function negotiateDocument(c, document, representation, href = document.permalink) {
|
|
92
372
|
if (representation === undefined) {
|
|
93
|
-
return notAcceptableResponse(encodePath(
|
|
373
|
+
return notAcceptableResponse(encodePath(href), DOCUMENT_REPRESENTATIONS);
|
|
94
374
|
}
|
|
95
375
|
const body = representation === 'markdown'
|
|
96
376
|
? serializeDocument(document)
|
|
97
377
|
: representation === 'json'
|
|
98
378
|
? documentJson(document, { baseUrl: c.var.config.baseUrl })
|
|
99
|
-
:
|
|
379
|
+
: // The thank-you after a comment was posted, which the redirect
|
|
380
|
+
// carried back as a query. It is the only thing about a document's
|
|
381
|
+
// HTML that the URL rather than the file decides.
|
|
382
|
+
// A document served at `/` is the site's front page, and the front
|
|
383
|
+
// page is the one place a theme may lay a page out differently.
|
|
384
|
+
href === '/'
|
|
385
|
+
? c.var.renderer.renderFrontPage(document, commentNotice(c, document))
|
|
386
|
+
: c.var.renderer.renderDocument(document, commentNotice(c, document));
|
|
100
387
|
// The theme can change without the document changing, and only the document
|
|
101
388
|
// is hashed. While the watcher is on — a development server, where a template
|
|
102
389
|
// edit lands mid-process — the HTML gets no validator rather than a stale one.
|
|
@@ -104,8 +391,13 @@ function negotiateDocument(c, document, representation) {
|
|
|
104
391
|
return representationResponse({
|
|
105
392
|
body,
|
|
106
393
|
representation,
|
|
107
|
-
href: encodePath(
|
|
394
|
+
href: encodePath(href),
|
|
108
395
|
available: DOCUMENT_REPRESENTATIONS,
|
|
396
|
+
// Where a webmention about this page is sent. It is a header rather than
|
|
397
|
+
// only a `<link>` because a sender is allowed to find the endpoint without
|
|
398
|
+
// parsing the page, and because the JSON and Markdown representations of a
|
|
399
|
+
// post have no head to put one in (TASK-51).
|
|
400
|
+
links: webmentionLinks(c),
|
|
109
401
|
...(validated
|
|
110
402
|
? {
|
|
111
403
|
etag: representationEtag(representation, document.hash),
|
|
@@ -115,6 +407,19 @@ function negotiateDocument(c, document, representation) {
|
|
|
115
407
|
conditional: conditionalHeaders(c),
|
|
116
408
|
});
|
|
117
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* The `Link` header advertising this site's webmention endpoint, or none when
|
|
412
|
+
* the site does not take them.
|
|
413
|
+
*
|
|
414
|
+
* Read per request off the settings, so turning webmentions off on the
|
|
415
|
+
* settings screen takes the advertisement off the very next page rather than
|
|
416
|
+
* off the next restart.
|
|
417
|
+
*/
|
|
418
|
+
function webmentionLinks(c) {
|
|
419
|
+
if (!readSiteSettings(c.var.config.contentDir).webmentionsReceive)
|
|
420
|
+
return [];
|
|
421
|
+
return [`<${WEBMENTION_PATH}>; rel="webmention"`];
|
|
422
|
+
}
|
|
118
423
|
/** The conditional request headers, as the negotiator wants them. */
|
|
119
424
|
function conditionalHeaders(c) {
|
|
120
425
|
return {
|
|
@@ -131,55 +436,231 @@ function conditionalHeaders(c) {
|
|
|
131
436
|
* itself rather than the path with a slash bolted on, so `/page/1` lands on
|
|
132
437
|
* `/` in one hop instead of two.
|
|
133
438
|
*/
|
|
134
|
-
function canonicalPath(c, pathname) {
|
|
439
|
+
function canonicalPath(c, pathname, bases, authors) {
|
|
135
440
|
if (pathname === '' || pathname.endsWith('/'))
|
|
136
441
|
return undefined;
|
|
137
|
-
const target = canonicalTarget(c, `${pathname}
|
|
442
|
+
const target = canonicalTarget(c, `${pathname}/`, bases, authors);
|
|
138
443
|
if (target === undefined)
|
|
139
444
|
return undefined;
|
|
140
445
|
return `${target}${new URL(c.req.url).search}`;
|
|
141
446
|
}
|
|
142
447
|
/** Where a path with a trailing slash canonically lives, if anywhere. */
|
|
143
|
-
function canonicalTarget(c, pathname) {
|
|
448
|
+
function canonicalTarget(c, pathname, bases, authors) {
|
|
144
449
|
const { store, renderer } = c.var;
|
|
450
|
+
// A feed first: `/feed`, `/feed/atom`, `/{base}/x/feed`, `/comments/feed`
|
|
451
|
+
// and a post's `{permalink}feed` all lead somewhere real, and `/feed/rss`
|
|
452
|
+
// leads to `/feed/` in the same one hop rather than to a second redirect.
|
|
453
|
+
const feedRequest = parseFeedPath(store, pathname, bases, authors);
|
|
454
|
+
if (feedRequest !== undefined) {
|
|
455
|
+
const { target } = feedRequest;
|
|
456
|
+
if (target.kind === 'listing' &&
|
|
457
|
+
target.subject.term !== undefined &&
|
|
458
|
+
countListing(store, target.subject) === 0) {
|
|
459
|
+
return undefined;
|
|
460
|
+
}
|
|
461
|
+
return feedTargetHref(target, feedRequest.format, bases);
|
|
462
|
+
}
|
|
463
|
+
const pages = frontPages(c);
|
|
145
464
|
const document = store.getByPermalink(pathname);
|
|
146
465
|
if (document !== undefined) {
|
|
147
|
-
|
|
466
|
+
if (!isPublicDocument(document))
|
|
467
|
+
return undefined;
|
|
468
|
+
// The homepage's own URL leads to `/` rather than to the redirect that
|
|
469
|
+
// leads to `/`: one hop, the way `/page/1` reaches `/` in one.
|
|
470
|
+
return document.path === pages.home?.path ? '/' : encodePath(pathname);
|
|
148
471
|
}
|
|
149
|
-
const listing =
|
|
472
|
+
const listing = listingRequestAt(pages, pathname, bases, authors);
|
|
150
473
|
if (listing === undefined)
|
|
151
474
|
return undefined;
|
|
152
|
-
// The home listing
|
|
153
|
-
|
|
154
|
-
|
|
475
|
+
// The home listing and an author archive both exist with nothing on them; a
|
|
476
|
+
// taxonomy archive does not.
|
|
477
|
+
const total = countListing(store, listing);
|
|
478
|
+
if (listing.term !== undefined && total === 0)
|
|
155
479
|
return undefined;
|
|
156
480
|
const totalPages = Math.max(1, Math.ceil(total / renderer.pageSize()));
|
|
157
481
|
if (listing.pageNumber >= totalPages)
|
|
158
482
|
return undefined;
|
|
159
|
-
return listing.
|
|
160
|
-
|
|
161
|
-
|
|
483
|
+
return listingHref(listing, listing.pageNumber, bases, listing.document?.permalink ?? '/');
|
|
484
|
+
}
|
|
485
|
+
/** {@link AuthorLookup} over one request's site. */
|
|
486
|
+
function authorsOf(c) {
|
|
487
|
+
let users;
|
|
488
|
+
return (username) => {
|
|
489
|
+
users ??= listUsers(c.var.config.dataDir);
|
|
490
|
+
const user = users.find((candidate) => candidate.username === username);
|
|
491
|
+
return user === undefined ? undefined : { user, names: authorNames(users, user) };
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* WordPress's Reading choice, resolved for this request.
|
|
496
|
+
*
|
|
497
|
+
* The setting holds slugs, and a slug is only a front page while it names a
|
|
498
|
+
* page the public site would serve: one drafted, trashed or deleted since it
|
|
499
|
+
* was picked resolves to nothing, and a site whose homepage resolves to
|
|
500
|
+
* nothing is a site showing its latest posts again. That is the whole of the
|
|
501
|
+
* fallback — there is no state to repair and nothing to write — and it is why
|
|
502
|
+
* the pick is kept rather than cleared: publishing the page again puts the
|
|
503
|
+
* front page back.
|
|
504
|
+
*/
|
|
505
|
+
function frontPages(c) {
|
|
506
|
+
const { homepage, postsPage } = c.var.renderer.frontPageSlugs();
|
|
507
|
+
const home = publicPage(c, homepage);
|
|
508
|
+
return {
|
|
509
|
+
home,
|
|
510
|
+
// Without a homepage there is no posts page: the listing is already at
|
|
511
|
+
// `/`, and a second URL for it is exactly what this pair exists to avoid.
|
|
512
|
+
posts: home === undefined ? undefined : publicPage(c, postsPage),
|
|
513
|
+
};
|
|
162
514
|
}
|
|
163
|
-
/**
|
|
164
|
-
|
|
515
|
+
/**
|
|
516
|
+
* A path as the page of a listing it names, wherever the listing lives, or
|
|
517
|
+
* `undefined` when it names none.
|
|
518
|
+
*
|
|
519
|
+
* The posts page first, because its permalink is the listing's root on a site
|
|
520
|
+
* that has one; then the ordinary `/`, `/page/N/` and the taxonomy archives.
|
|
521
|
+
* A site whose homepage is a page and which named no posts page has no home
|
|
522
|
+
* listing at all, so nothing under the root is one either.
|
|
523
|
+
*/
|
|
524
|
+
function listingRequestAt(pages, pathname, bases, authors) {
|
|
525
|
+
const onPostsPage = pages.posts === undefined ? undefined : postsPageRequest(pages.posts, pathname);
|
|
526
|
+
if (onPostsPage !== undefined)
|
|
527
|
+
return onPostsPage;
|
|
528
|
+
const request = parseListingPath(pathname, bases, authors);
|
|
529
|
+
if (request === undefined)
|
|
530
|
+
return undefined;
|
|
531
|
+
// Only the home listing can be homeless. A tag archive and a person's
|
|
532
|
+
// archive have URLs of their own, whatever the Reading setting says `/` is.
|
|
533
|
+
if (request.term === undefined && request.author === undefined) {
|
|
534
|
+
if (listingRoot(pages) === undefined)
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
return request;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Where the post listing lives, or `undefined` when it has no page at all.
|
|
541
|
+
*
|
|
542
|
+
* A site showing its latest posts has it at `/`; a site with a posts page has
|
|
543
|
+
* it there; a site whose homepage is a page and which named no posts page has
|
|
544
|
+
* nowhere for it, which is WordPress's own answer and the reason its Reading
|
|
545
|
+
* screen offers the second pick. The feeds are unaffected either way.
|
|
546
|
+
*/
|
|
547
|
+
function listingRoot(pages) {
|
|
548
|
+
if (pages.posts !== undefined)
|
|
549
|
+
return pages.posts.permalink;
|
|
550
|
+
return pages.home === undefined ? '/' : undefined;
|
|
551
|
+
}
|
|
552
|
+
/** The published page one slug names, or `undefined`. */
|
|
553
|
+
function publicPage(c, slug) {
|
|
554
|
+
if (slug === '')
|
|
555
|
+
return undefined;
|
|
556
|
+
const found = c.var.store.getBySlug(slug);
|
|
557
|
+
if (found?.type !== 'page')
|
|
558
|
+
return undefined;
|
|
559
|
+
return isPublicDocument(found, c.var.store.now()) ? found : undefined;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* `{permalink}` or `{permalink}page/N/` as a page of the listing the posts
|
|
563
|
+
* page carries, or `undefined` when the path is neither.
|
|
564
|
+
*
|
|
565
|
+
* `page/1/` is not one: the first page of a listing lives at the listing's own
|
|
566
|
+
* URL, exactly as `/page/1/` collapses onto `/`, and the canonicalisation that
|
|
567
|
+
* says so is the ordinary one.
|
|
568
|
+
*/
|
|
569
|
+
function postsPageRequest(document, pathname) {
|
|
570
|
+
const { permalink } = document;
|
|
571
|
+
if (pathname === permalink)
|
|
572
|
+
return { term: undefined, pageNumber: 0, document };
|
|
573
|
+
if (!pathname.startsWith(permalink))
|
|
574
|
+
return undefined;
|
|
575
|
+
const segments = pathname
|
|
576
|
+
.slice(permalink.length)
|
|
577
|
+
.split('/')
|
|
578
|
+
.filter((segment) => segment !== '');
|
|
579
|
+
if (segments.length !== 2 || segments[0] !== PAGE_SEGMENT || !pathname.endsWith('/')) {
|
|
580
|
+
return undefined;
|
|
581
|
+
}
|
|
582
|
+
const page = pageIndex(segments[1]);
|
|
583
|
+
return page === undefined ? undefined : { term: undefined, pageNumber: page, document };
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* `/`, `/page/N/`, `/author/{username}/` and `/author/{username}/page/N/`, and
|
|
587
|
+
* either taxonomy's `/{base}/x/` and `/{base}/x/page/N/`, as a listing to
|
|
588
|
+
* check.
|
|
589
|
+
*/
|
|
590
|
+
function parseListingPath(pathname, bases, authors) {
|
|
165
591
|
const segments = pathname.split('/').filter((segment) => segment !== '');
|
|
166
592
|
if (segments.length === 0)
|
|
167
|
-
return {
|
|
593
|
+
return { term: undefined, pageNumber: 0 };
|
|
168
594
|
if (segments[0] === PAGE_SEGMENT && segments.length === 2) {
|
|
169
595
|
const page = pageIndex(segments[1]);
|
|
170
|
-
return page === undefined ? undefined : {
|
|
596
|
+
return page === undefined ? undefined : { term: undefined, pageNumber: page };
|
|
597
|
+
}
|
|
598
|
+
// One person's archive, at the path decision-14 reserves. A username nobody
|
|
599
|
+
// has is not a listing at all, which is what turns it into one 404 rather
|
|
600
|
+
// than an empty archive.
|
|
601
|
+
const byAuthor = parseAuthorPath(pathname);
|
|
602
|
+
if (byAuthor !== undefined) {
|
|
603
|
+
const found = authors(byAuthor.username);
|
|
604
|
+
return found === undefined ? undefined : { author: found, pageNumber: byAuthor.pageNumber };
|
|
171
605
|
}
|
|
172
|
-
|
|
606
|
+
const taxonomy = taxonomyForSegment(segments[0], bases);
|
|
607
|
+
if (taxonomy === undefined || segments[1] === undefined)
|
|
173
608
|
return undefined;
|
|
174
|
-
const
|
|
609
|
+
const term = { taxonomy, term: segments[1] };
|
|
175
610
|
if (segments.length === 2)
|
|
176
|
-
return {
|
|
611
|
+
return { term, pageNumber: 0 };
|
|
177
612
|
if (segments.length === 4 && segments[2] === PAGE_SEGMENT) {
|
|
178
613
|
const page = pageIndex(segments[3]);
|
|
179
|
-
return page === undefined ? undefined : {
|
|
614
|
+
return page === undefined ? undefined : { term, pageNumber: page };
|
|
180
615
|
}
|
|
181
616
|
return undefined;
|
|
182
617
|
}
|
|
618
|
+
/** How many published documents a listing holds. */
|
|
619
|
+
function countListing(store, subject) {
|
|
620
|
+
const { term, author } = subject;
|
|
621
|
+
if (author !== undefined)
|
|
622
|
+
return store.countByAuthor(author.names);
|
|
623
|
+
if (term === undefined)
|
|
624
|
+
return store.counts().posts;
|
|
625
|
+
return term.taxonomy === 'tag' ? store.countByTag(term.term) : store.countByCategory(term.term);
|
|
626
|
+
}
|
|
627
|
+
/** One page of a listing's documents, newest first. */
|
|
628
|
+
function listListing(store, subject, paging) {
|
|
629
|
+
const { term, author } = subject;
|
|
630
|
+
if (author !== undefined)
|
|
631
|
+
return store.listByAuthor(author.names, paging);
|
|
632
|
+
if (term === undefined)
|
|
633
|
+
return store.listPosts(paging);
|
|
634
|
+
return term.taxonomy === 'tag'
|
|
635
|
+
? store.listByTag(term.term, paging)
|
|
636
|
+
: store.listByCategory(term.term, paging);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* The URL of a page of a listing: the home archive's, or a taxonomy's.
|
|
640
|
+
*
|
|
641
|
+
* `root` is where the home listing lives — `/`, or the posts page's permalink
|
|
642
|
+
* on a site that has one — so every link the listing draws, every canonical
|
|
643
|
+
* redirect and the sitemap all spell its pages the same way.
|
|
644
|
+
*/
|
|
645
|
+
function listingHref(subject, index, bases, root = '/') {
|
|
646
|
+
const { term, author } = subject;
|
|
647
|
+
if (author !== undefined)
|
|
648
|
+
return authorHref(author.user.username, index);
|
|
649
|
+
return term === undefined ? listingPageHref(root, index) : termHref(term, index, bases);
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* The URL of one format of one listing's feed, whichever kind of listing it is.
|
|
653
|
+
*
|
|
654
|
+
* The site's and a taxonomy's hang off the listing root; a person's hangs off
|
|
655
|
+
* their archive, which decision-14 keeps at WordPress's `/author/{username}/`
|
|
656
|
+
* rather than under the listing machinery, because that root is also an actor
|
|
657
|
+
* id.
|
|
658
|
+
*/
|
|
659
|
+
function listingFeedHref(subject, format, bases) {
|
|
660
|
+
return subject.author === undefined
|
|
661
|
+
? feedHref(subject.term, format, bases)
|
|
662
|
+
: authorFeedHref(subject.author.user.username, format);
|
|
663
|
+
}
|
|
183
664
|
/**
|
|
184
665
|
* A `/page/N/` segment as a zero-based index. `page/1` parses to the first
|
|
185
666
|
* page, which lives at the listing root, so canonicalisation collapses it.
|
|
@@ -193,35 +674,56 @@ function pageIndex(segment) {
|
|
|
193
674
|
/** One page of a listing, in whichever representation the request settled on. */
|
|
194
675
|
function listing(c, request, representation = selectFromAccept(c, LISTING_REPRESENTATIONS)) {
|
|
195
676
|
const { store, renderer } = c.var;
|
|
196
|
-
const {
|
|
677
|
+
const { term, author } = request;
|
|
197
678
|
const size = renderer.pageSize();
|
|
198
|
-
|
|
199
|
-
// listing
|
|
200
|
-
|
|
201
|
-
|
|
679
|
+
const bases = renderer.taxonomyBases();
|
|
680
|
+
// Where this listing's pages live: the posts page's permalink when the site
|
|
681
|
+
// has one, and the site root otherwise.
|
|
682
|
+
const root = request.document?.permalink ?? '/';
|
|
683
|
+
// WordPress served every feed as a query on the listing before it served one
|
|
684
|
+
// at a path, and the links are still out there. `/?feed=rss2` and
|
|
685
|
+
// `/{base}/x/?feed=atom` land on the feed the listing now has.
|
|
686
|
+
const asked = queryFeedFormat(c);
|
|
687
|
+
if (asked !== undefined)
|
|
688
|
+
return c.redirect(listingFeedHref(request, asked, bases), 301);
|
|
689
|
+
// A taxonomy archive only exists while something carries the term; the home
|
|
690
|
+
// listing and a person's archive exist even with nothing on them.
|
|
691
|
+
const total = countListing(store, request);
|
|
692
|
+
if (term !== undefined && total === 0)
|
|
202
693
|
return notFound(c);
|
|
203
|
-
const href =
|
|
694
|
+
const href = listingHref(request, request.pageNumber, bases, root);
|
|
204
695
|
const pagination = paginate({
|
|
205
696
|
total,
|
|
206
697
|
size,
|
|
207
698
|
pageNumber: request.pageNumber,
|
|
208
|
-
hrefForPage: (index) => (
|
|
699
|
+
hrefForPage: (index) => listingHref(request, index, bases, root),
|
|
209
700
|
});
|
|
210
701
|
if (request.pageNumber >= pagination.totalPages)
|
|
211
702
|
return notFound(c);
|
|
212
703
|
if (representation === undefined)
|
|
213
704
|
return notAcceptableResponse(href, LISTING_REPRESENTATIONS);
|
|
214
705
|
const paging = { limit: size, offset: offsetForPage(request.pageNumber, size) };
|
|
215
|
-
const documents =
|
|
706
|
+
const documents = listListing(store, request, paging);
|
|
216
707
|
const full = wantsFullDocuments(c);
|
|
217
708
|
const body = representation === 'json'
|
|
218
709
|
? documents.map((document) => documentJson(document, { baseUrl: c.var.config.baseUrl, body: full }))
|
|
219
710
|
: renderer.renderListing({
|
|
220
|
-
|
|
711
|
+
// An author archive is headed by the person, a taxonomy archive by
|
|
712
|
+
// the term, the posts page by its own title the way any page is, and
|
|
713
|
+
// the home listing by the site's.
|
|
714
|
+
title: term?.term ??
|
|
715
|
+
author?.user.profile?.displayName ??
|
|
716
|
+
author?.user.username ??
|
|
717
|
+
request.document?.title ??
|
|
718
|
+
renderer.site().title,
|
|
221
719
|
url: href,
|
|
222
720
|
documents,
|
|
223
721
|
pagination,
|
|
224
|
-
|
|
722
|
+
// And its words go above the posts, which is what a posts page is
|
|
723
|
+
// for: a theme prints `{{ content | safe }}` over the list.
|
|
724
|
+
...(request.document === undefined ? {} : { document: request.document }),
|
|
725
|
+
...(term === undefined ? {} : taxonomyContext(term)),
|
|
726
|
+
...(author === undefined ? {} : authorArchiveContext(author)),
|
|
225
727
|
});
|
|
226
728
|
const validated = representation !== 'html' || !c.var.config.watch;
|
|
227
729
|
return representationResponse({
|
|
@@ -238,6 +740,59 @@ function listing(c, request, representation = selectFromAccept(c, LISTING_REPRES
|
|
|
238
740
|
conditional: conditionalHeaders(c),
|
|
239
741
|
});
|
|
240
742
|
}
|
|
743
|
+
/**
|
|
744
|
+
* One page of search results, in whichever representation the request settled
|
|
745
|
+
* on.
|
|
746
|
+
*
|
|
747
|
+
* What it finds is what the listings would show: the index holds the search to
|
|
748
|
+
* published, untrashed, already-due documents, so a draft cannot be found by
|
|
749
|
+
* its words any more than it can be found by its URL. A search with no query
|
|
750
|
+
* is the page with the form on it and nothing found, rather than an error,
|
|
751
|
+
* because that is where a link to the search from a theme lands. A page past
|
|
752
|
+
* the last one 404s, as it does on a listing.
|
|
753
|
+
*/
|
|
754
|
+
function search(c, representation) {
|
|
755
|
+
const { store, renderer, config } = c.var;
|
|
756
|
+
const query = searchQuery(c.req.query(SEARCH_QUERY_PARAM));
|
|
757
|
+
const pageNumber = searchPageIndex(c.req.query(SEARCH_PAGE_PARAM));
|
|
758
|
+
if (pageNumber === undefined)
|
|
759
|
+
return notFound(c);
|
|
760
|
+
const size = renderer.pageSize();
|
|
761
|
+
const pagination = paginate({
|
|
762
|
+
total: store.countSearch(query),
|
|
763
|
+
size,
|
|
764
|
+
pageNumber,
|
|
765
|
+
hrefForPage: (index) => searchHref(query, index),
|
|
766
|
+
});
|
|
767
|
+
if (pageNumber >= pagination.totalPages)
|
|
768
|
+
return notFound(c);
|
|
769
|
+
const href = searchHref(query, pageNumber);
|
|
770
|
+
if (representation === undefined)
|
|
771
|
+
return notAcceptableResponse(href, LISTING_REPRESENTATIONS);
|
|
772
|
+
const hits = store.search(query, { limit: size, offset: offsetForPage(pageNumber, size) });
|
|
773
|
+
const documents = hits.map((hit) => hit.document);
|
|
774
|
+
const full = wantsFullDocuments(c);
|
|
775
|
+
const body = representation === 'json'
|
|
776
|
+
? searchJson({ query, hits, pagination, baseUrl: config.baseUrl, body: full })
|
|
777
|
+
: renderer.renderSearch({ query, url: href, hits, pagination });
|
|
778
|
+
const validated = representation !== 'html' || !config.watch;
|
|
779
|
+
return representationResponse({
|
|
780
|
+
body,
|
|
781
|
+
representation,
|
|
782
|
+
href,
|
|
783
|
+
// The alternates are spelled here rather than by the negotiator, because
|
|
784
|
+
// they carry the query and a listing's never have one to carry.
|
|
785
|
+
available: [representation],
|
|
786
|
+
links: LISTING_REPRESENTATIONS.filter((other) => other !== representation).map((other) => `<${searchHref(query, pageNumber, other)}>; rel="alternate"; type="${MEDIA_TYPES[other]}"`),
|
|
787
|
+
...(validated
|
|
788
|
+
? {
|
|
789
|
+
etag: representationEtag(representation, listingFingerprint(href, pagination, documents, full)),
|
|
790
|
+
lastModified: latestModified(documents),
|
|
791
|
+
}
|
|
792
|
+
: {}),
|
|
793
|
+
conditional: conditionalHeaders(c),
|
|
794
|
+
});
|
|
795
|
+
}
|
|
241
796
|
/**
|
|
242
797
|
* Whether the request asked for whole documents rather than summaries.
|
|
243
798
|
*
|
|
@@ -264,31 +819,155 @@ function listingFingerprint(href, pagination, documents, full) {
|
|
|
264
819
|
].join('\n');
|
|
265
820
|
}
|
|
266
821
|
/**
|
|
267
|
-
* The site's feed, or one
|
|
822
|
+
* The site's feed, or one archive's, in one format.
|
|
268
823
|
*
|
|
269
|
-
* A
|
|
824
|
+
* A term with nothing published under it 404s exactly as its archive does: a
|
|
270
825
|
* feed reader should be told the URL is wrong rather than handed an empty feed
|
|
271
826
|
* it will poll forever.
|
|
272
827
|
*/
|
|
273
|
-
function feed(c, format,
|
|
828
|
+
function feed(c, format, subject) {
|
|
274
829
|
const { store, renderer, config } = c.var;
|
|
275
830
|
const site = renderer.site();
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
831
|
+
const bases = renderer.taxonomyBases();
|
|
832
|
+
const { term, author } = subject;
|
|
833
|
+
if (term !== undefined && countListing(store, subject) === 0) {
|
|
834
|
+
// A subscriber to a renamed archive's feed follows it to the new one
|
|
835
|
+
// rather than being dropped, exactly as a reader of the archive does.
|
|
836
|
+
const moved = movedTerm(c, term);
|
|
837
|
+
if (moved === undefined)
|
|
838
|
+
return notFound(c);
|
|
839
|
+
return c.redirect(feedHref(moved, format, bases), 301);
|
|
840
|
+
}
|
|
841
|
+
const documents = listListing(store, subject, { limit: feedSize(site) });
|
|
842
|
+
const href = listingHref(subject, 0, bases);
|
|
843
|
+
// What the feed calls itself: the site, and then the term or the person it
|
|
844
|
+
// is about, so a reader subscribed to several of a site's feeds can tell
|
|
845
|
+
// them apart in a list.
|
|
846
|
+
const about = term?.term ?? author?.user.profile?.displayName ?? author?.user.username;
|
|
282
847
|
const source = {
|
|
283
848
|
site,
|
|
284
849
|
documents,
|
|
285
|
-
title:
|
|
850
|
+
title: about === undefined ? site.title : `${site.title}: ${about}`,
|
|
286
851
|
href,
|
|
287
|
-
feedHref:
|
|
852
|
+
feedHref: listingFeedHref(subject, format, bases),
|
|
288
853
|
baseUrl: config.baseUrl,
|
|
854
|
+
// Only RSS carries the comment pointers; the other two formats have no
|
|
855
|
+
// vocabulary for them, and counting for a feed that cannot say the number
|
|
856
|
+
// would be a query per item for nothing.
|
|
857
|
+
...(format === 'rss' ? { commentCounts: c.var.conversation.counts(documents) } : {}),
|
|
289
858
|
};
|
|
290
859
|
return feedResponse({ format, source, conditional: conditionalHeaders(c) });
|
|
291
860
|
}
|
|
861
|
+
/**
|
|
862
|
+
* A post's comments, or the whole site's, as RSS 2.0.
|
|
863
|
+
*
|
|
864
|
+
* A post with no replies answers an empty feed rather than a 404: it exists,
|
|
865
|
+
* and a reader that subscribed before anybody answered should keep polling.
|
|
866
|
+
* Only a permalink that is no published post 404s, which is the ordinary
|
|
867
|
+
* document lookup rather than anything this feed decides.
|
|
868
|
+
*/
|
|
869
|
+
function comments(c, document) {
|
|
870
|
+
const { conversation, renderer, config } = c.var;
|
|
871
|
+
const site = renderer.site();
|
|
872
|
+
const limit = feedSize(site);
|
|
873
|
+
// The same reading the page is drawn from, which is the point: a subscriber
|
|
874
|
+
// to a post's comments and a reader who scrolls to the bottom of it are
|
|
875
|
+
// looking at one conversation. A post's own feed hands the builder entries
|
|
876
|
+
// with no post attached, and so its items name no post: there, every item
|
|
877
|
+
// answers the same one.
|
|
878
|
+
const found = feedComments(document === undefined ? conversation.latest(limit) : spokenIn(conversation.thread(document)), { baseUrl: config.baseUrl, limit });
|
|
879
|
+
const source = {
|
|
880
|
+
site,
|
|
881
|
+
comments: found,
|
|
882
|
+
title: document === undefined
|
|
883
|
+
? `${site.title}: comments`
|
|
884
|
+
: `${COMMENTS_TITLE_PREFIX}${document.title}`,
|
|
885
|
+
href: document?.permalink ?? '/',
|
|
886
|
+
feedHref: commentsFeedHref(document),
|
|
887
|
+
baseUrl: config.baseUrl,
|
|
888
|
+
};
|
|
889
|
+
return commentsFeedResponse(source, conditionalHeaders(c));
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* The sitemap, or one of its children once the site is too big for one file.
|
|
893
|
+
*
|
|
894
|
+
* A child that does not exist 404s through the theme like any other missing
|
|
895
|
+
* URL: `/sitemap-1.xml` names nothing at all on a site whose whole sitemap
|
|
896
|
+
* fits, and a crawler asking for one should be told so rather than handed an
|
|
897
|
+
* empty file it would come back to.
|
|
898
|
+
*/
|
|
899
|
+
function sitemap(c, page) {
|
|
900
|
+
const response = sitemapResponse({
|
|
901
|
+
urls: sitemapUrls(c),
|
|
902
|
+
baseUrl: c.var.config.baseUrl,
|
|
903
|
+
page,
|
|
904
|
+
conditional: conditionalHeaders(c),
|
|
905
|
+
});
|
|
906
|
+
return response ?? notFound(c);
|
|
907
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Every URL the public site publishes, in the order the sitemap lists them:
|
|
910
|
+
* the home archive's pages, then every post and page, then every tag archive
|
|
911
|
+
* and every category archive with their own pages.
|
|
912
|
+
*
|
|
913
|
+
* Everything here is spelled by the same functions the site's own links go
|
|
914
|
+
* through — {@link homeHref}, the permalinks, {@link termHref} — and drawn
|
|
915
|
+
* from the same queries the listings use, so a sitemap can never advertise a
|
|
916
|
+
* URL the site does not serve. Nothing hidden reaches it either: the index's
|
|
917
|
+
* public queries already exclude drafts, the trash and posts whose date has
|
|
918
|
+
* not arrived, and {@link isPublicDocument} is asked again with the store's
|
|
919
|
+
* own clock so the two answers cannot drift apart.
|
|
920
|
+
*/
|
|
921
|
+
function sitemapUrls(c) {
|
|
922
|
+
const { store, renderer } = c.var;
|
|
923
|
+
const now = store.now();
|
|
924
|
+
const size = renderer.pageSize();
|
|
925
|
+
const bases = renderer.taxonomyBases();
|
|
926
|
+
const pages = frontPages(c);
|
|
927
|
+
const urls = [];
|
|
928
|
+
/** The pages of one listing, each dated by the newest document on it. */
|
|
929
|
+
const listingPages = (documents, hrefForPage) => {
|
|
930
|
+
const totalPages = Math.max(1, Math.ceil(documents.length / size));
|
|
931
|
+
for (let index = 0; index < totalPages; index += 1) {
|
|
932
|
+
const onPage = documents.slice(index * size, (index + 1) * size);
|
|
933
|
+
urls.push({ loc: hrefForPage(index), lastmod: latestModified(onPage) });
|
|
934
|
+
}
|
|
935
|
+
};
|
|
936
|
+
const posts = store.listPosts().filter((document) => isPublicDocument(document, now));
|
|
937
|
+
// The listing's pages, wherever it lives: under `/`, under the posts page,
|
|
938
|
+
// or nowhere at all on a site whose homepage is a page and which named no
|
|
939
|
+
// posts page. Its first page is that root, which is why `/` and the posts
|
|
940
|
+
// page's own URL are listed here rather than with the documents.
|
|
941
|
+
const root = listingRoot(pages);
|
|
942
|
+
if (root !== undefined)
|
|
943
|
+
listingPages(posts, (index) => listingPageHref(root, index));
|
|
944
|
+
// And `/` itself when it is a page rather than the listing: the front page
|
|
945
|
+
// is published at one URL, and it is this one.
|
|
946
|
+
if (pages.home !== undefined)
|
|
947
|
+
urls.push({ loc: '/', lastmod: lastModifiedOf(pages.home) });
|
|
948
|
+
const documents = store
|
|
949
|
+
.listAll({ type: 'page', draft: false, trashed: false, scheduled: false })
|
|
950
|
+
.filter((document) => isPublicDocument(document, now));
|
|
951
|
+
for (const document of [...posts, ...documents]) {
|
|
952
|
+
// The homepage answers at `/` and redirects from its own permalink, and
|
|
953
|
+
// the posts page is the listing's first page, which is already listed:
|
|
954
|
+
// neither is advertised twice.
|
|
955
|
+
if (document.path === pages.home?.path || document.path === pages.posts?.path)
|
|
956
|
+
continue;
|
|
957
|
+
urls.push({ loc: document.permalink, lastmod: lastModifiedOf(document) });
|
|
958
|
+
}
|
|
959
|
+
// A taxonomy archive exists only while something public carries the term,
|
|
960
|
+
// which is exactly what these two queries report.
|
|
961
|
+
for (const { tag } of store.listTags()) {
|
|
962
|
+
const term = { taxonomy: 'tag', term: tag };
|
|
963
|
+
listingPages(store.listByTag(tag), (index) => termHref(term, index, bases));
|
|
964
|
+
}
|
|
965
|
+
for (const { category } of store.listCategories()) {
|
|
966
|
+
const term = { taxonomy: 'category', term: category };
|
|
967
|
+
listingPages(store.listByCategory(category), (index) => termHref(term, index, bases));
|
|
968
|
+
}
|
|
969
|
+
return urls;
|
|
970
|
+
}
|
|
292
971
|
/**
|
|
293
972
|
* A file from the theme's `static/` directory, the site's copy first.
|
|
294
973
|
*
|
|
@@ -297,7 +976,7 @@ function feed(c, format, tag) {
|
|
|
297
976
|
*/
|
|
298
977
|
function themeAsset(c) {
|
|
299
978
|
const relative = requestPath(c).slice(THEME_ASSET_PREFIX.length);
|
|
300
|
-
const asset = findThemeAsset(relative,
|
|
979
|
+
const asset = findThemeAsset(relative, c.var.renderer.themeDirs());
|
|
301
980
|
if (asset === undefined)
|
|
302
981
|
return notFound(c);
|
|
303
982
|
if (matchesEtag(c.req.header('if-none-match'), asset.etag)) {
|
|
@@ -305,6 +984,38 @@ function themeAsset(c) {
|
|
|
305
984
|
}
|
|
306
985
|
return themeAssetResponse(asset);
|
|
307
986
|
}
|
|
987
|
+
/**
|
|
988
|
+
* One derived copy of an upload, generated on the spot if it is not there.
|
|
989
|
+
*
|
|
990
|
+
* The directory these live in is disposable (decision-9): deleting it costs
|
|
991
|
+
* the next reader of each picture one encode and costs the site nothing else,
|
|
992
|
+
* which is what this handler is for. A width or a format the site does not
|
|
993
|
+
* offer is a 404 and encodes nothing, so the URL space cannot be used to make
|
|
994
|
+
* the server work.
|
|
995
|
+
*
|
|
996
|
+
* The cache lifetime is the uploads' own, and it is honest for the same
|
|
997
|
+
* reason: a derived URL names one width of one file, and the file it was
|
|
998
|
+
* derived from is never overwritten.
|
|
999
|
+
*/
|
|
1000
|
+
async function imageVariant(c) {
|
|
1001
|
+
const relative = requestPath(c).slice(VARIANT_ASSET_PREFIX.length);
|
|
1002
|
+
const asset = await findImageVariant(c.var.config, decodeVariantPath(relative));
|
|
1003
|
+
if (asset === undefined)
|
|
1004
|
+
return notFound(c);
|
|
1005
|
+
const options = { maxAge: UPLOAD_ASSET_MAX_AGE };
|
|
1006
|
+
return matchesEtag(c.req.header('if-none-match'), asset.etag)
|
|
1007
|
+
? assetNotModified(asset, options)
|
|
1008
|
+
: assetResponse(asset, options);
|
|
1009
|
+
}
|
|
1010
|
+
/** A request path as a path on disk: percent-encoding off, segment by segment. */
|
|
1011
|
+
function decodeVariantPath(relative) {
|
|
1012
|
+
try {
|
|
1013
|
+
return relative.split('/').map(decodeURIComponent).join('/');
|
|
1014
|
+
}
|
|
1015
|
+
catch {
|
|
1016
|
+
return relative;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
308
1019
|
/**
|
|
309
1020
|
* A file from `content/uploads/`, at the URL Eleventy's passthrough copy puts
|
|
310
1021
|
* it at.
|
|
@@ -327,16 +1038,57 @@ function upload(c) {
|
|
|
327
1038
|
}
|
|
328
1039
|
/** The URL of a page of the home listing, by zero-based index. */
|
|
329
1040
|
export function homeHref(index) {
|
|
330
|
-
return
|
|
1041
|
+
return listingPageHref('/', index);
|
|
331
1042
|
}
|
|
332
|
-
/**
|
|
333
|
-
|
|
334
|
-
|
|
1043
|
+
/**
|
|
1044
|
+
* The URL of a page of the listing that hangs off `root`, by zero-based index.
|
|
1045
|
+
*
|
|
1046
|
+
* The first page is the root itself: `/` or the posts page's own permalink,
|
|
1047
|
+
* which is what makes a posts page one URL rather than two.
|
|
1048
|
+
*/
|
|
1049
|
+
export function listingPageHref(root, index) {
|
|
335
1050
|
return index === 0 ? root : `${root}${PAGE_SEGMENT}/${String(index + 1)}/`;
|
|
336
1051
|
}
|
|
337
|
-
/**
|
|
338
|
-
|
|
339
|
-
|
|
1052
|
+
/**
|
|
1053
|
+
* What the theme is told about a taxonomy archive: the term under the name of
|
|
1054
|
+
* its taxonomy, and the layout that taxonomy uses.
|
|
1055
|
+
*/
|
|
1056
|
+
function taxonomyContext(term) {
|
|
1057
|
+
return term.taxonomy === 'tag'
|
|
1058
|
+
? { tag: term.term, template: TEMPLATES.tag }
|
|
1059
|
+
: { category: term.term, template: TEMPLATES.category };
|
|
1060
|
+
}
|
|
1061
|
+
/**
|
|
1062
|
+
* What the theme is told about an author archive: the person's profile under
|
|
1063
|
+
* `author`, the same shape a post's byline gets, and the layout an archive of
|
|
1064
|
+
* theirs uses.
|
|
1065
|
+
*
|
|
1066
|
+
* One shape for both places is the point. A theme that knows how to print a
|
|
1067
|
+
* byline already knows how to print the heading of the archive that byline
|
|
1068
|
+
* links to, and neither has to ask whether the site has users.
|
|
1069
|
+
*/
|
|
1070
|
+
function authorArchiveContext(author) {
|
|
1071
|
+
return { author: profileContext(author.user), template: TEMPLATES.author };
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* The URL of a feed: the whole site's, or one taxonomy archive's.
|
|
1075
|
+
*
|
|
1076
|
+
* WordPress's layout, so a subscriber of a migrated site keeps polling the URL
|
|
1077
|
+
* they already hold: `/feed/` is RSS 2.0, `/feed/atom/` and `/feed/json/` are
|
|
1078
|
+
* its siblings, and an archive's feeds hang off the archive.
|
|
1079
|
+
*/
|
|
1080
|
+
export function feedHref(term, format, bases) {
|
|
1081
|
+
return feedPathUnder(listingHref({ term }, 0, bases), format);
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Where the site's comments feed lives, and where one post's does.
|
|
1085
|
+
*
|
|
1086
|
+
* WordPress's URLs, so a site migrated from it keeps both: the whole site's
|
|
1087
|
+
* comments at `/comments/feed/`, and a post's under its own permalink. There
|
|
1088
|
+
* is one format, RSS 2.0, because that is what a comments feed is read in.
|
|
1089
|
+
*/
|
|
1090
|
+
export function commentsFeedHref(document) {
|
|
1091
|
+
return commentsFeedPath(document === undefined ? undefined : encodePath(document.permalink));
|
|
340
1092
|
}
|
|
341
1093
|
/** The theme's 404 page. */
|
|
342
1094
|
export function notFound(c) {
|