@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/admin/settings.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
1
|
+
import { statSync } from 'node:fs';
|
|
3
2
|
import path from 'node:path';
|
|
3
|
+
import { DEFAULT_COMMENTS_CLOSE_AFTER_DAYS } from '../comments/policy.js';
|
|
4
|
+
import { readFileIfPresentSync, updateFileAtomically, writeFileAtomicallySync, } from '../files/atomic.js';
|
|
5
|
+
import { MAIL_PROVIDERS } from '../mail/provider.js';
|
|
4
6
|
import { SITE_DATA_FILE } from '../web/context.js';
|
|
5
|
-
import {
|
|
7
|
+
import { DEFAULT_NOTIFY_SERVER } from '../web/feeds.js';
|
|
8
|
+
import { navigationItemsOf } from '../web/navigation.js';
|
|
9
|
+
import { DEFAULT_TAXONOMY_BASES, taxonomyBaseProblems, taxonomyRedirectsOf, } from '../web/taxonomy.js';
|
|
10
|
+
import { readTheme, themeNameProblem } from '../web/themes.js';
|
|
6
11
|
import { ADMIN_PREFIX } from './session.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Where the settings live: the General page, and the root every other settings
|
|
14
|
+
* page hangs off ({@link settingsPagePath}).
|
|
15
|
+
*/
|
|
10
16
|
export const SETTINGS_PATH = `${ADMIN_PREFIX}/settings`;
|
|
11
|
-
/** Where the avatar's upload form and its Remove button post. */
|
|
12
|
-
export const AVATAR_PATH = `${SETTINGS_PATH}/avatar`;
|
|
13
|
-
/** The fields those two forms submit. */
|
|
14
|
-
export const AVATAR_FIELDS = { file: 'avatar', action: 'action' };
|
|
15
|
-
/** The {@link AVATAR_FIELDS.action} that takes the avatar down again. */
|
|
16
|
-
export const AVATAR_REMOVE = 'remove';
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* What a language tag may look like: BCP 47's shape rather than its registry —
|
|
19
|
+
* a two or three letter primary subtag followed by dash-separated subtags of
|
|
20
|
+
* letters and digits.
|
|
19
21
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
+
* Checking the shape and not the registry is deliberate. The value ends up in
|
|
23
|
+
* `<html lang>`, an RSS `<language>` and an Atom `xml:lang`, where a
|
|
24
|
+
* well-formed tag a reader has never heard of is harmless and a malformed one
|
|
25
|
+
* is not; refusing a valid tag because this CMS shipped before it was
|
|
26
|
+
* registered would be worse than accepting one nobody uses.
|
|
22
27
|
*/
|
|
23
|
-
export const
|
|
24
|
-
'Person',
|
|
25
|
-
'Organization',
|
|
26
|
-
'Service',
|
|
27
|
-
'Group',
|
|
28
|
-
'Application',
|
|
29
|
-
];
|
|
28
|
+
export const LANGUAGE_TAG_PATTERN = /^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,4}$/;
|
|
30
29
|
/**
|
|
31
|
-
* What an
|
|
32
|
-
*
|
|
33
|
-
*
|
|
30
|
+
* What an email address has to look like before the settings screen will keep
|
|
31
|
+
* it: something, an `@`, and a dotted host.
|
|
32
|
+
*
|
|
33
|
+
* Deliberately loose. The grammar in RFC 5321 allows addresses nobody has ever
|
|
34
|
+
* typed, and the only test that settles whether an address works is sending to
|
|
35
|
+
* it — which is what the Send test email button is for. This catches the
|
|
36
|
+
* typo where a whole field was pasted into the wrong box.
|
|
34
37
|
*/
|
|
35
|
-
export const
|
|
38
|
+
export const EMAIL_PATTERN = /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/;
|
|
36
39
|
/**
|
|
37
40
|
* What a site is worth before anybody has said otherwise.
|
|
38
41
|
*
|
|
@@ -44,11 +47,28 @@ export const DEFAULT_SITE_SETTINGS = {
|
|
|
44
47
|
tagline: '',
|
|
45
48
|
baseUrl: '',
|
|
46
49
|
timezone: 'UTC',
|
|
50
|
+
language: 'en',
|
|
47
51
|
postsPerPage: 10,
|
|
52
|
+
homepage: '',
|
|
53
|
+
postsPage: '',
|
|
48
54
|
author: '',
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
theme: '',
|
|
56
|
+
tagBase: DEFAULT_TAXONOMY_BASES.tag,
|
|
57
|
+
categoryBase: DEFAULT_TAXONOMY_BASES.category,
|
|
58
|
+
comments: true,
|
|
59
|
+
commentsCloseAfterDays: DEFAULT_COMMENTS_CLOSE_AFTER_DAYS,
|
|
60
|
+
webmentionsSend: true,
|
|
61
|
+
webmentionsReceive: true,
|
|
62
|
+
notifyServer: DEFAULT_NOTIFY_SERVER,
|
|
63
|
+
mailProvider: 'none',
|
|
64
|
+
mailFromName: '',
|
|
65
|
+
mailFromAddress: '',
|
|
66
|
+
mailReplyTo: '',
|
|
67
|
+
contactEmail: '',
|
|
68
|
+
relays: [],
|
|
69
|
+
wordpressActivityPub: false,
|
|
70
|
+
navigation: [],
|
|
71
|
+
taxonomyRedirects: [],
|
|
52
72
|
};
|
|
53
73
|
/** The form field each setting is submitted under. */
|
|
54
74
|
export const SETTINGS_FIELDS = {
|
|
@@ -56,74 +76,151 @@ export const SETTINGS_FIELDS = {
|
|
|
56
76
|
tagline: 'tagline',
|
|
57
77
|
baseUrl: 'base_url',
|
|
58
78
|
timezone: 'timezone',
|
|
79
|
+
language: 'language',
|
|
59
80
|
postsPerPage: 'posts_per_page',
|
|
81
|
+
homepage: 'homepage',
|
|
82
|
+
postsPage: 'posts_page',
|
|
60
83
|
author: 'author',
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
theme: 'theme',
|
|
85
|
+
tagBase: 'tag_base',
|
|
86
|
+
categoryBase: 'category_base',
|
|
87
|
+
comments: 'comments',
|
|
88
|
+
commentsCloseAfterDays: 'comments_close_after_days',
|
|
89
|
+
webmentionsSend: 'webmentions_send',
|
|
90
|
+
webmentionsReceive: 'webmentions_receive',
|
|
91
|
+
notifyServer: 'notify_server',
|
|
92
|
+
mailProvider: 'mail_provider',
|
|
93
|
+
mailFromName: 'mail_from_name',
|
|
94
|
+
mailFromAddress: 'mail_from_address',
|
|
95
|
+
mailReplyTo: 'mail_reply_to',
|
|
96
|
+
contactEmail: 'contact_email',
|
|
97
|
+
relays: 'relays',
|
|
98
|
+
wordpressActivityPub: 'wordpress_activitypub',
|
|
99
|
+
navigation: 'navigation',
|
|
63
100
|
};
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
? stored['actorType']
|
|
80
|
-
: DEFAULT_SITE_SETTINGS.actorType,
|
|
81
|
-
avatar: stored['avatar'] ?? DEFAULT_SITE_SETTINGS.avatar,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
/** Write a whole settings object back to the store. */
|
|
85
|
-
export function writeSiteSettings(store, settings) {
|
|
86
|
-
store.setSettings({
|
|
87
|
-
title: settings.title,
|
|
88
|
-
tagline: settings.tagline,
|
|
89
|
-
baseUrl: settings.baseUrl,
|
|
90
|
-
timezone: settings.timezone,
|
|
91
|
-
postsPerPage: String(settings.postsPerPage),
|
|
92
|
-
author: settings.author,
|
|
93
|
-
actorHandle: settings.actorHandle,
|
|
94
|
-
actorType: settings.actorType,
|
|
95
|
-
avatar: settings.avatar,
|
|
96
|
-
});
|
|
101
|
+
/**
|
|
102
|
+
* A site's settings, as its `content/_data/site.json` says them right now.
|
|
103
|
+
*
|
|
104
|
+
* Read on every request that needs one rather than cached, which is what a
|
|
105
|
+
* source of truth being a file is worth: a hand edit shows on the public site,
|
|
106
|
+
* on the settings screen and in the actor document without a restart and
|
|
107
|
+
* without anything being told. The file is a few hundred bytes, so the read
|
|
108
|
+
* costs less than the parse of the template that is about to use it.
|
|
109
|
+
*
|
|
110
|
+
* A file that is missing, or one that will not parse, is the defaults rather
|
|
111
|
+
* than an error: a typo in `site.json` should leave a site up and answerable,
|
|
112
|
+
* with the settings screen there to put it right.
|
|
113
|
+
*/
|
|
114
|
+
export function readSiteSettings(contentDir) {
|
|
115
|
+
return settingsFromSiteJson(readSiteJsonSync(siteDataPath(contentDir)));
|
|
97
116
|
}
|
|
98
117
|
/**
|
|
99
|
-
*
|
|
118
|
+
* `content/_data/site.json` as the settings it names, defaults filled in.
|
|
100
119
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* rather than
|
|
120
|
+
* Read tolerantly, key by key, because the file is public, in git and editable
|
|
121
|
+
* by hand: a key of the wrong type, or one a site has never written, falls
|
|
122
|
+
* back to the default rather than taking the site down. The empty string is a
|
|
123
|
+
* value of its own for `tagline`, `author` and `notifyServer`, where empty is
|
|
124
|
+
* a decision — no tagline, no author, notifications off — and not for
|
|
125
|
+
* `title`, `timezone`, `language` or the two archive bases, where it is a hole
|
|
126
|
+
* only a default can fill.
|
|
104
127
|
*/
|
|
105
|
-
export function
|
|
128
|
+
export function settingsFromSiteJson(file) {
|
|
129
|
+
const postsPerPage = Number(file['postsPerPage']);
|
|
130
|
+
const closeAfterDays = Number(file['commentsCloseAfterDays']);
|
|
106
131
|
return {
|
|
107
|
-
...
|
|
108
|
-
...(
|
|
109
|
-
...(
|
|
110
|
-
...(
|
|
111
|
-
...(
|
|
112
|
-
|
|
113
|
-
|
|
132
|
+
...DEFAULT_SITE_SETTINGS,
|
|
133
|
+
...(typeof file['title'] === 'string' && file['title'] !== '' ? { title: file['title'] } : {}),
|
|
134
|
+
...(typeof file['tagline'] === 'string' ? { tagline: file['tagline'] } : {}),
|
|
135
|
+
...(typeof file['author'] === 'string' ? { author: file['author'] } : {}),
|
|
136
|
+
...(typeof file['timezone'] === 'string' && file['timezone'] !== ''
|
|
137
|
+
? { timezone: file['timezone'] }
|
|
138
|
+
: {}),
|
|
139
|
+
...(typeof file['language'] === 'string' && file['language'] !== ''
|
|
140
|
+
? { language: file['language'] }
|
|
141
|
+
: {}),
|
|
142
|
+
// Absent is the ordinary state of this one: a site on the packaged theme
|
|
143
|
+
// has never written the key, so anything but a string is that site.
|
|
144
|
+
...(typeof file['theme'] === 'string' ? { theme: file['theme'] } : {}),
|
|
145
|
+
// Absent is the ordinary state of these two: a site showing its latest
|
|
146
|
+
// posts writes neither key, so anything but a string is read as none.
|
|
147
|
+
...(typeof file['homepage'] === 'string' ? { homepage: file['homepage'] } : {}),
|
|
148
|
+
...(typeof file['postsPage'] === 'string' ? { postsPage: file['postsPage'] } : {}),
|
|
149
|
+
...(typeof file['tagBase'] === 'string' && file['tagBase'] !== ''
|
|
150
|
+
? { tagBase: file['tagBase'] }
|
|
151
|
+
: {}),
|
|
152
|
+
...(typeof file['categoryBase'] === 'string' && file['categoryBase'] !== ''
|
|
153
|
+
? { categoryBase: file['categoryBase'] }
|
|
154
|
+
: {}),
|
|
155
|
+
...(typeof file['comments'] === 'boolean' ? { comments: file['comments'] } : {}),
|
|
156
|
+
...(Number.isInteger(closeAfterDays) && closeAfterDays >= 0
|
|
157
|
+
? { commentsCloseAfterDays: closeAfterDays }
|
|
158
|
+
: {}),
|
|
159
|
+
...(typeof file['webmentionsSend'] === 'boolean'
|
|
160
|
+
? { webmentionsSend: file['webmentionsSend'] }
|
|
161
|
+
: {}),
|
|
162
|
+
...(typeof file['webmentionsReceive'] === 'boolean'
|
|
163
|
+
? { webmentionsReceive: file['webmentionsReceive'] }
|
|
164
|
+
: {}),
|
|
165
|
+
...(typeof file['notifyServer'] === 'string' ? { notifyServer: file['notifyServer'] } : {}),
|
|
166
|
+
// Only a provider this version ships, for the reason the actor type is
|
|
167
|
+
// read that way: a file naming one it has never heard of is a site that
|
|
168
|
+
// sends no mail rather than a boot that fails.
|
|
169
|
+
...(typeof file['mailProvider'] === 'string' &&
|
|
170
|
+
MAIL_PROVIDERS.includes(file['mailProvider'])
|
|
171
|
+
? { mailProvider: file['mailProvider'] }
|
|
172
|
+
: {}),
|
|
173
|
+
...(typeof file['mailFromName'] === 'string' ? { mailFromName: file['mailFromName'] } : {}),
|
|
174
|
+
...(typeof file['mailFromAddress'] === 'string'
|
|
175
|
+
? { mailFromAddress: file['mailFromAddress'] }
|
|
176
|
+
: {}),
|
|
177
|
+
...(typeof file['mailReplyTo'] === 'string' ? { mailReplyTo: file['mailReplyTo'] } : {}),
|
|
178
|
+
...(typeof file['contactEmail'] === 'string' ? { contactEmail: file['contactEmail'] } : {}),
|
|
179
|
+
// Through the same normaliser a submitted form goes through, so the file
|
|
180
|
+
// and the screen cannot mean different things by the same line.
|
|
181
|
+
...(Array.isArray(file['relays'])
|
|
182
|
+
? {
|
|
183
|
+
relays: relayList(file['relays'].filter((entry) => typeof entry === 'string').join('\n')),
|
|
184
|
+
}
|
|
185
|
+
: {}),
|
|
186
|
+
// Absent is the ordinary state of this one, like `homepage`: a site that
|
|
187
|
+
// has never carried WordPress's paths does not write the key at all.
|
|
188
|
+
...(typeof file['wordpressActivityPub'] === 'boolean'
|
|
189
|
+
? { wordpressActivityPub: file['wordpressActivityPub'] }
|
|
190
|
+
: {}),
|
|
191
|
+
...(Array.isArray(file['navigation'])
|
|
192
|
+
? { navigation: navigationItemsOf(file['navigation']) }
|
|
193
|
+
: {}),
|
|
194
|
+
// The renames a site has published redirects for: facts about its URLs
|
|
195
|
+
// rather than preferences, which is why a content directory restored on
|
|
196
|
+
// its own keeps answering the archive URLs it used to.
|
|
197
|
+
...(Array.isArray(file['taxonomyRedirects'])
|
|
198
|
+
? { taxonomyRedirects: taxonomyRedirectsOf(file['taxonomyRedirects']) }
|
|
199
|
+
: {}),
|
|
200
|
+
...(Number.isInteger(postsPerPage) && postsPerPage > 0 ? { postsPerPage } : {}),
|
|
201
|
+
...(typeof file['url'] === 'string' ? { baseUrl: file['url'] } : {}),
|
|
114
202
|
};
|
|
115
203
|
}
|
|
204
|
+
/** The two archive bases the settings hold, as the URL builders want them. */
|
|
205
|
+
export function taxonomyBasesFromSettings(settings) {
|
|
206
|
+
return { tag: settings.tagBase, category: settings.categoryBase };
|
|
207
|
+
}
|
|
116
208
|
/**
|
|
117
209
|
* `content/_data/site.json` as it should read for these settings.
|
|
118
210
|
*
|
|
119
|
-
* Every key the
|
|
120
|
-
* file's shape is stable and an Eleventy template may reference
|
|
121
|
-
* without guarding it. Every other key the file already had is
|
|
122
|
-
* may put anything in there and reach it from its templates, and
|
|
123
|
-
* form is not going to be the thing that throws it away.
|
|
211
|
+
* Every key the settings model is written whether or not it has a value, so
|
|
212
|
+
* the file's shape is stable and an Eleventy template may reference
|
|
213
|
+
* `site.author` without guarding it. Every other key the file already had is
|
|
214
|
+
* kept: a site may put anything in there and reach it from its templates, and
|
|
215
|
+
* the settings form is not going to be the thing that throws it away.
|
|
216
|
+
*
|
|
217
|
+
* `homepage` and `postsPage` are the one exception, and they earn it: a site
|
|
218
|
+
* showing its latest posts has no static front page at all rather than an
|
|
219
|
+
* empty one, so the keys are absent rather than empty — which is also how a
|
|
220
|
+
* `site.json` written before this version reads, and what it should mean.
|
|
124
221
|
*/
|
|
125
222
|
export function siteJsonFor(settings, existing = {}) {
|
|
126
|
-
|
|
223
|
+
const file = {
|
|
127
224
|
...existing,
|
|
128
225
|
title: settings.title,
|
|
129
226
|
tagline: settings.tagline,
|
|
@@ -131,69 +228,155 @@ export function siteJsonFor(settings, existing = {}) {
|
|
|
131
228
|
author: settings.author,
|
|
132
229
|
postsPerPage: settings.postsPerPage,
|
|
133
230
|
timezone: settings.timezone,
|
|
134
|
-
|
|
231
|
+
language: settings.language,
|
|
232
|
+
tagBase: settings.tagBase,
|
|
233
|
+
categoryBase: settings.categoryBase,
|
|
234
|
+
comments: settings.comments,
|
|
235
|
+
commentsCloseAfterDays: settings.commentsCloseAfterDays,
|
|
236
|
+
webmentionsSend: settings.webmentionsSend,
|
|
237
|
+
webmentionsReceive: settings.webmentionsReceive,
|
|
238
|
+
notifyServer: settings.notifyServer,
|
|
239
|
+
mailProvider: settings.mailProvider,
|
|
240
|
+
mailFromName: settings.mailFromName,
|
|
241
|
+
mailFromAddress: settings.mailFromAddress,
|
|
242
|
+
mailReplyTo: settings.mailReplyTo,
|
|
243
|
+
contactEmail: settings.contactEmail,
|
|
244
|
+
relays: [...settings.relays],
|
|
245
|
+
navigation: settings.navigation.map((item) => ({ ...item })),
|
|
246
|
+
taxonomyRedirects: settings.taxonomyRedirects.map((entry) => ({ ...entry })),
|
|
135
247
|
};
|
|
248
|
+
// `theme` is absent for a site on the packaged theme, on the same rule and
|
|
249
|
+
// for the same reason as the two above: running what the package ships is
|
|
250
|
+
// not a choice a site should have to write down, and a `theme` of `""` would
|
|
251
|
+
// be a name no directory has.
|
|
252
|
+
for (const key of ['homepage', 'postsPage', 'theme']) {
|
|
253
|
+
if (settings[key] === '')
|
|
254
|
+
delete file[key];
|
|
255
|
+
else
|
|
256
|
+
file[key] = settings[key];
|
|
257
|
+
}
|
|
258
|
+
// And the WordPress switch, on the same rule and for a sharper reason: it is
|
|
259
|
+
// a temporary accommodation for one migrated site (decision-14), so a site
|
|
260
|
+
// that has never turned it on should have nothing to say about it, and one
|
|
261
|
+
// that has turned it off again should go back to saying nothing.
|
|
262
|
+
if (settings.wordpressActivityPub)
|
|
263
|
+
file['wordpressActivityPub'] = true;
|
|
264
|
+
else
|
|
265
|
+
delete file['wordpressActivityPub'];
|
|
266
|
+
return file;
|
|
136
267
|
}
|
|
137
268
|
/** The absolute path of one site's `content/_data/site.json`. */
|
|
138
269
|
export function siteDataPath(contentDir) {
|
|
139
270
|
return path.join(contentDir, ...SITE_DATA_FILE.split('/'));
|
|
140
271
|
}
|
|
272
|
+
/** The bytes of one settings object, as the file holds them. */
|
|
273
|
+
function siteJsonText(settings, existing) {
|
|
274
|
+
return `${JSON.stringify(siteJsonFor(settings, existing), null, 2)}\n`;
|
|
275
|
+
}
|
|
141
276
|
/**
|
|
142
|
-
* Rewrite `content/_data/site.json`
|
|
277
|
+
* Rewrite `content/_data/site.json` as these settings, keeping the keys they
|
|
278
|
+
* do not model.
|
|
143
279
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* one.
|
|
280
|
+
* {@link updateSiteSettings} for a caller whose new settings depend on the old
|
|
281
|
+
* ones, which every screen's is: this is for the callers that have the whole
|
|
282
|
+
* object already, a test's set-up among them.
|
|
148
283
|
*/
|
|
149
284
|
export async function writeSiteJson(options) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
285
|
+
await updateSiteSettings({ contentDir: options.contentDir, change: () => options.settings });
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Change the settings: re-read the file, apply the change, write it back, with
|
|
289
|
+
* nothing able to write that file in between ({@link updateFileAtomically}).
|
|
290
|
+
*
|
|
291
|
+
* The re-read is what makes the file win the way it wins for a post
|
|
292
|
+
* (decision-9). Two people with the settings screen open both save what they
|
|
293
|
+
* see, and the second save is applied to what the first one actually wrote
|
|
294
|
+
* rather than to what the second one had on screen — so a change to a field
|
|
295
|
+
* the second person did not touch survives. The write is a temporary file and
|
|
296
|
+
* a rename, so a reader — an Eleventy build, the site data source, another
|
|
297
|
+
* process entirely — never sees a half-written file. Keys the settings do not
|
|
298
|
+
* model, `feedSize` and anything a site added, are kept.
|
|
299
|
+
*/
|
|
300
|
+
export async function updateSiteSettings(options) {
|
|
301
|
+
let written = DEFAULT_SITE_SETTINGS;
|
|
302
|
+
await updateFileAtomically(siteDataPath(options.contentDir), (current) => {
|
|
303
|
+
const existing = parseSiteJson(current ?? '');
|
|
304
|
+
written = options.change(settingsFromSiteJson(existing));
|
|
305
|
+
return siteJsonText(written, existing);
|
|
306
|
+
});
|
|
307
|
+
return written;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Turn an older site's settings rows into `content/_data/site.json`, once, and
|
|
311
|
+
* drop the table.
|
|
312
|
+
*
|
|
313
|
+
* TASK-14 made SQLite the source and the file its mirror; decision-9 reversed
|
|
314
|
+
* that, and a site upgrading across the two has rows nothing would ever read
|
|
315
|
+
* again. So the first boot of this version writes them out. Which side wins
|
|
316
|
+
* when both have something to say is decided the way it is decided everywhere
|
|
317
|
+
* else: the file wins when it was written after the last save, because that is
|
|
318
|
+
* a hand edit or a restored checkout, and the rows win otherwise. Either way
|
|
319
|
+
* the actor handle and type come from the rows, because `site.json` never
|
|
320
|
+
* carried them and losing them would rename the site's actor.
|
|
321
|
+
*
|
|
322
|
+
* Synchronous because `createCms` is: it runs before the server is listening
|
|
323
|
+
* and before anything else has touched the file.
|
|
324
|
+
*/
|
|
325
|
+
export function migrateSettingsToFile(options) {
|
|
326
|
+
const { admin, contentDir } = options;
|
|
327
|
+
const rows = admin.legacySettings();
|
|
328
|
+
if (rows !== undefined && rows.length > 0) {
|
|
329
|
+
const stored = settingsFromRows(rows);
|
|
330
|
+
const file = siteDataPath(contentDir);
|
|
331
|
+
const existing = parseSiteJson(readFileIfPresentSync(file) ?? '');
|
|
332
|
+
const settings = fileWasEditedLast(file, rows) ? settingsFromSiteJson(existing) : stored;
|
|
333
|
+
writeFileAtomicallySync(file, siteJsonText(settings, existing));
|
|
159
334
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
335
|
+
// Dropped whether or not it had rows: a fresh database gets the table from
|
|
336
|
+
// migration 3, which has shipped and so is never edited, and a site that has
|
|
337
|
+
// been migrated must not be asked again on the next boot.
|
|
338
|
+
admin.dropLegacyTable('settings');
|
|
339
|
+
}
|
|
340
|
+
/** The old key/value rows as settings, defaults filled in. */
|
|
341
|
+
function settingsFromRows(rows) {
|
|
342
|
+
const stored = {};
|
|
343
|
+
for (const row of rows)
|
|
344
|
+
stored[row.key] = row.value;
|
|
345
|
+
// Through the file's own reader, so one description of what a setting is
|
|
346
|
+
// worth serves both: the rows are spelled as the file spells them and read
|
|
347
|
+
// back the same way. `relays`, `navigation` and `taxonomyRedirects` were
|
|
348
|
+
// stored one entry per line, which is not how the file holds them.
|
|
349
|
+
return settingsFromSiteJson({
|
|
350
|
+
...stored,
|
|
351
|
+
...(stored['baseUrl'] === undefined ? {} : { url: stored['baseUrl'] }),
|
|
352
|
+
...(stored['postsPerPage'] === undefined
|
|
353
|
+
? {}
|
|
354
|
+
: { postsPerPage: Number(stored['postsPerPage']) }),
|
|
355
|
+
relays: relayList(stored['relays'] ?? ''),
|
|
356
|
+
navigation: navigationList(stored['navigation'] ?? ''),
|
|
357
|
+
taxonomyRedirects: redirectList(stored['taxonomyRedirects'] ?? ''),
|
|
358
|
+
});
|
|
163
359
|
}
|
|
164
360
|
/**
|
|
165
|
-
*
|
|
166
|
-
* existed before this screen did — or one `geekity init` just wrote — keeps
|
|
167
|
-
* the values it already had.
|
|
361
|
+
* Whether `site.json` has been written since the newest settings row was.
|
|
168
362
|
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
363
|
+
* A missing file has not, so the rows win. A file whose modification time
|
|
364
|
+
* cannot be read is treated the same way: the rows are the only thing that is
|
|
365
|
+
* certainly there.
|
|
172
366
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
: {}),
|
|
187
|
-
...(typeof file['avatar'] === 'string' ? { avatar: file['avatar'] } : {}),
|
|
188
|
-
...(Number.isInteger(postsPerPage) && postsPerPage > 0 ? { postsPerPage } : {}),
|
|
189
|
-
// The file's `url` only becomes the setting when the deployment has not
|
|
190
|
-
// named one; otherwise the setting records what is actually in effect.
|
|
191
|
-
baseUrl: config.baseUrlSource === 'default' && typeof file['url'] === 'string' && file['url'] !== ''
|
|
192
|
-
? file['url']
|
|
193
|
-
: config.baseUrl,
|
|
194
|
-
};
|
|
195
|
-
writeSiteSettings(store, seeded);
|
|
196
|
-
return seeded;
|
|
367
|
+
function fileWasEditedLast(file, rows) {
|
|
368
|
+
let modified;
|
|
369
|
+
try {
|
|
370
|
+
modified = statSync(file).mtimeMs;
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
const newest = rows.reduce((latest, row) => {
|
|
376
|
+
const at = Date.parse(row.updatedAt);
|
|
377
|
+
return Number.isNaN(at) ? latest : Math.max(latest, at);
|
|
378
|
+
}, 0);
|
|
379
|
+
return modified > newest;
|
|
197
380
|
}
|
|
198
381
|
/**
|
|
199
382
|
* The base URL actually in effect, and why.
|
|
@@ -209,28 +392,151 @@ export function effectiveBaseUrl(config, settings) {
|
|
|
209
392
|
return config.baseUrl;
|
|
210
393
|
return settings.baseUrl === '' ? config.baseUrl : settings.baseUrl;
|
|
211
394
|
}
|
|
212
|
-
/**
|
|
213
|
-
|
|
395
|
+
/**
|
|
396
|
+
* What is wrong with each field of a submitted form: one check per field, so a
|
|
397
|
+
* page can run the checks for the fields it carries and no others.
|
|
398
|
+
*
|
|
399
|
+
* A field nothing can be wrong with — a tagline, an author, a checkbox — has a
|
|
400
|
+
* check all the same, because a table with a hole in it is a field somebody
|
|
401
|
+
* added and forgot to think about.
|
|
402
|
+
*/
|
|
403
|
+
const FIELD_CHECKS = {
|
|
404
|
+
title: (form) => (form.title.trim() === '' ? 'The site needs a title.' : undefined),
|
|
405
|
+
tagline: () => undefined,
|
|
406
|
+
author: () => undefined,
|
|
407
|
+
baseUrl: (form) => normalizeBaseUrl(form.baseUrl) === undefined
|
|
408
|
+
? 'The base URL has to be an absolute http:// or https:// URL.'
|
|
409
|
+
: undefined,
|
|
410
|
+
postsPerPage: (form) => {
|
|
411
|
+
const perPage = Number(form.postsPerPage);
|
|
412
|
+
return !Number.isInteger(perPage) || perPage < 1
|
|
413
|
+
? 'Posts per page has to be a whole number of one or more.'
|
|
414
|
+
: undefined;
|
|
415
|
+
},
|
|
416
|
+
// The two picks are checked as a pair, the way the archive bases are, and
|
|
417
|
+
// for the same reason: two of the three rules are about the pair. Neither
|
|
418
|
+
// check asks whether the slug still names a published page — the select only
|
|
419
|
+
// offers ones that do, and a page drafted after it was picked is a site back
|
|
420
|
+
// on its latest posts rather than a settings screen that will not save.
|
|
421
|
+
homepage: (form) => slugProblem(form.homepage, 'A homepage'),
|
|
422
|
+
postsPage: (form) => {
|
|
423
|
+
if (form.postsPage.trim() === '')
|
|
424
|
+
return undefined;
|
|
425
|
+
if (form.homepage.trim() === '') {
|
|
426
|
+
return 'A posts page needs a homepage: pick the page the front page shows first.';
|
|
427
|
+
}
|
|
428
|
+
if (form.postsPage.trim() === form.homepage.trim()) {
|
|
429
|
+
return 'The homepage and the posts page have to be two different pages.';
|
|
430
|
+
}
|
|
431
|
+
return slugProblem(form.postsPage, 'A posts page');
|
|
432
|
+
},
|
|
433
|
+
timezone: (form) => isValidTimezone(form.timezone)
|
|
434
|
+
? undefined
|
|
435
|
+
: 'That is not an IANA time zone name, such as Europe/London.',
|
|
436
|
+
language: (form) => LANGUAGE_TAG_PATTERN.test(form.language.trim())
|
|
437
|
+
? undefined
|
|
438
|
+
: 'That is not a language tag, such as en, en-GB or pt-BR.',
|
|
439
|
+
// Empty is a value here — it is how a site says "the theme the package
|
|
440
|
+
// ships" — so only a name has anything to check. A name that is not a theme
|
|
441
|
+
// is refused rather than saved and warned about later: the screen has a list
|
|
442
|
+
// of the themes that are there, so the only way to type one that is not is a
|
|
443
|
+
// theme deleted between drawing the list and saving it, and the person is in
|
|
444
|
+
// front of the form and can be told.
|
|
445
|
+
theme: (form, context) => {
|
|
446
|
+
const name = form.theme.trim();
|
|
447
|
+
if (name === '')
|
|
448
|
+
return undefined;
|
|
449
|
+
const badName = themeNameProblem(name);
|
|
450
|
+
if (badName !== undefined)
|
|
451
|
+
return badName;
|
|
452
|
+
if (context.themesDir === undefined)
|
|
453
|
+
return undefined;
|
|
454
|
+
const read = readTheme(path.join(context.themesDir, name));
|
|
455
|
+
return read.ok ? undefined : `There is no theme called "${name}": ${read.reason}`;
|
|
456
|
+
},
|
|
457
|
+
comments: () => undefined,
|
|
458
|
+
// The empty string is refused rather than read as zero, which is what
|
|
459
|
+
// `Number('')` would make it: a cleared field is a mistake, and "never close
|
|
460
|
+
// comments" should have to be typed.
|
|
461
|
+
commentsCloseAfterDays: (form) => {
|
|
462
|
+
const typed = form.commentsCloseAfterDays.trim();
|
|
463
|
+
const days = Number(typed);
|
|
464
|
+
return typed === '' || !Number.isInteger(days) || days < 0
|
|
465
|
+
? 'Comments close after a whole number of days, or 0 for never.'
|
|
466
|
+
: undefined;
|
|
467
|
+
},
|
|
468
|
+
webmentionsSend: () => undefined,
|
|
469
|
+
webmentionsReceive: () => undefined,
|
|
470
|
+
// Empty is a value here — it is how a site turns real-time notification off
|
|
471
|
+
// — so only a non-empty one has to be a URL. http as well as https, because
|
|
472
|
+
// a notify server on a private network or a loopback port is a real one.
|
|
473
|
+
notifyServer: (form) => form.notifyServer.trim() !== '' && normalizeBaseUrl(form.notifyServer) === undefined
|
|
474
|
+
? 'A notify server is an absolute http:// or https:// URL, or empty for none.'
|
|
475
|
+
: undefined,
|
|
476
|
+
mailProvider: (form) => MAIL_PROVIDERS.includes(form.mailProvider)
|
|
477
|
+
? undefined
|
|
478
|
+
: `A mail provider is one of ${MAIL_PROVIDERS.join(', ')}.`,
|
|
479
|
+
mailFromName: () => undefined,
|
|
480
|
+
// Empty is a value for both of these — no From address falls back to
|
|
481
|
+
// `no-reply@` at the site's host, and no reply-to means replies go to the
|
|
482
|
+
// From address — so only a non-empty one has to look like an address.
|
|
483
|
+
mailFromAddress: (form) => form.mailFromAddress.trim() !== '' && !EMAIL_PATTERN.test(form.mailFromAddress.trim())
|
|
484
|
+
? 'A From address is an email address, such as blog@example.com, or empty for the default.'
|
|
485
|
+
: undefined,
|
|
486
|
+
mailReplyTo: (form) => form.mailReplyTo.trim() !== '' && !EMAIL_PATTERN.test(form.mailReplyTo.trim())
|
|
487
|
+
? 'A reply-to is an email address, such as hello@example.com, or empty to reply to the From address.'
|
|
488
|
+
: undefined,
|
|
489
|
+
// Empty is a value here too — it is how a site says "whichever admin has an
|
|
490
|
+
// address" — so only a non-empty one has to look like one.
|
|
491
|
+
contactEmail: (form) => form.contactEmail.trim() !== '' && !EMAIL_PATTERN.test(form.contactEmail.trim())
|
|
492
|
+
? 'A contact address is an email address, such as hello@example.com, or empty for the first admin with one.'
|
|
493
|
+
: undefined,
|
|
494
|
+
// A relay list is checked line by line, and the first bad line is what the
|
|
495
|
+
// field says: a textarea has one message, and pointing at the line somebody
|
|
496
|
+
// has to fix is more use than counting how many are wrong.
|
|
497
|
+
relays: (form) => {
|
|
498
|
+
const bad = relayLines(form.relays).find((line) => normalizeRelayInbox(line) === undefined);
|
|
499
|
+
return bad === undefined
|
|
500
|
+
? undefined
|
|
501
|
+
: `A relay is its inbox as an absolute http:// or https:// URL, one per line. ` +
|
|
502
|
+
`"${bad}" is not one.`;
|
|
503
|
+
},
|
|
504
|
+
// A checkbox is either submitted or not, so there is nothing a person could
|
|
505
|
+
// get wrong about it.
|
|
506
|
+
wordpressActivityPub: () => undefined,
|
|
507
|
+
// A menu is checked line by line like the relays, and for the same reason:
|
|
508
|
+
// one message on a textarea is more use pointing at the line to fix than
|
|
509
|
+
// counting how many are wrong.
|
|
510
|
+
navigation: (form) => {
|
|
511
|
+
const bad = navigationLines(form.navigation).find((line) => navigationItem(line) === undefined);
|
|
512
|
+
return bad === undefined
|
|
513
|
+
? undefined
|
|
514
|
+
: `A menu item is "Label | URL", one per line, where the URL is a path ` +
|
|
515
|
+
`like /about/ or an absolute http:// or https:// URL. "${bad}" is not one.`;
|
|
516
|
+
},
|
|
517
|
+
// The two archive bases are checked as a pair, because two of the rules —
|
|
518
|
+
// that they differ, and that neither takes a path the site already answers
|
|
519
|
+
// on — are about the pair rather than either one. They are on one page for
|
|
520
|
+
// exactly that reason.
|
|
521
|
+
tagBase: (form) => taxonomyBaseProblems({ tag: form.tagBase, category: form.categoryBase }).tag,
|
|
522
|
+
categoryBase: (form) => taxonomyBaseProblems({ tag: form.tagBase, category: form.categoryBase }).category,
|
|
523
|
+
};
|
|
524
|
+
/** Every field of the settings, in the order the form fields name them. */
|
|
525
|
+
export const SETTINGS_FIELD_NAMES = Object.keys(SETTINGS_FIELDS);
|
|
526
|
+
/**
|
|
527
|
+
* What is wrong with a submitted settings form, one message per field.
|
|
528
|
+
*
|
|
529
|
+
* `fields` is what a page carries: it validates its own fields and says
|
|
530
|
+
* nothing about the rest, so a page cannot refuse a save over a field it does
|
|
531
|
+
* not show and gives no way to fix. `context` is what a check needs beyond the
|
|
532
|
+
* form; see {@link SettingsContext}.
|
|
533
|
+
*/
|
|
534
|
+
export function settingsProblems(form, fields = SETTINGS_FIELD_NAMES, context = {}) {
|
|
214
535
|
const problems = {};
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
problems.baseUrl = 'The base URL has to be an absolute http:// or https:// URL.';
|
|
220
|
-
}
|
|
221
|
-
const perPage = Number(form.postsPerPage);
|
|
222
|
-
if (!Number.isInteger(perPage) || perPage < 1) {
|
|
223
|
-
problems.postsPerPage = 'Posts per page has to be a whole number of one or more.';
|
|
224
|
-
}
|
|
225
|
-
if (!isValidTimezone(form.timezone)) {
|
|
226
|
-
problems.timezone = 'That is not an IANA time zone name, such as Europe/London.';
|
|
227
|
-
}
|
|
228
|
-
if (!ACTOR_HANDLE_PATTERN.test(form.actorHandle)) {
|
|
229
|
-
problems.actorHandle =
|
|
230
|
-
'An actor handle is 1 to 64 letters, digits, dashes or underscores, with no @ and no dots.';
|
|
231
|
-
}
|
|
232
|
-
if (!ACTOR_TYPES.includes(form.actorType)) {
|
|
233
|
-
problems.actorType = `An actor type is one of ${ACTOR_TYPES.join(', ')}.`;
|
|
536
|
+
for (const name of fields) {
|
|
537
|
+
const problem = FIELD_CHECKS[name](form, context);
|
|
538
|
+
if (problem !== undefined)
|
|
539
|
+
problems[name] = problem;
|
|
234
540
|
}
|
|
235
541
|
return problems;
|
|
236
542
|
}
|
|
@@ -238,21 +544,45 @@ export function settingsProblems(form) {
|
|
|
238
544
|
* A validated form as settings. Only call it on a form
|
|
239
545
|
* {@link settingsProblems} found nothing wrong with.
|
|
240
546
|
*
|
|
241
|
-
* The
|
|
242
|
-
*
|
|
243
|
-
*
|
|
547
|
+
* The recorded archive renames are carried in rather than read off the form,
|
|
548
|
+
* because they are not on it: the taxonomy screens write them, and a save of
|
|
549
|
+
* the other fields keeps whatever is stored.
|
|
244
550
|
*/
|
|
245
|
-
export function settingsFromForm(form,
|
|
551
|
+
export function settingsFromForm(form, taxonomyRedirects = DEFAULT_SITE_SETTINGS.taxonomyRedirects) {
|
|
246
552
|
return {
|
|
247
|
-
|
|
553
|
+
taxonomyRedirects,
|
|
248
554
|
title: form.title.trim(),
|
|
249
555
|
tagline: form.tagline.trim(),
|
|
250
556
|
baseUrl: normalizeBaseUrl(form.baseUrl) ?? '',
|
|
251
557
|
timezone: form.timezone.trim(),
|
|
558
|
+
language: form.language.trim(),
|
|
252
559
|
postsPerPage: Number(form.postsPerPage),
|
|
560
|
+
homepage: form.homepage.trim(),
|
|
561
|
+
// A posts page means nothing without a homepage, and the validator has
|
|
562
|
+
// already refused the pair; this is what makes clearing the homepage clear
|
|
563
|
+
// the listing's own page with it rather than leave it stranded.
|
|
564
|
+
postsPage: form.homepage.trim() === '' ? '' : form.postsPage.trim(),
|
|
253
565
|
author: form.author.trim(),
|
|
254
|
-
|
|
255
|
-
|
|
566
|
+
theme: form.theme.trim(),
|
|
567
|
+
tagBase: form.tagBase.trim(),
|
|
568
|
+
categoryBase: form.categoryBase.trim(),
|
|
569
|
+
// A checkbox submits nothing at all when it is clear, which is what the
|
|
570
|
+
// empty string here means.
|
|
571
|
+
comments: form.comments !== '',
|
|
572
|
+
commentsCloseAfterDays: Number(form.commentsCloseAfterDays),
|
|
573
|
+
webmentionsSend: form.webmentionsSend !== '',
|
|
574
|
+
webmentionsReceive: form.webmentionsReceive !== '',
|
|
575
|
+
notifyServer: normalizeBaseUrl(form.notifyServer) ?? '',
|
|
576
|
+
mailProvider: MAIL_PROVIDERS.includes(form.mailProvider)
|
|
577
|
+
? form.mailProvider
|
|
578
|
+
: 'none',
|
|
579
|
+
mailFromName: form.mailFromName.trim(),
|
|
580
|
+
mailFromAddress: form.mailFromAddress.trim(),
|
|
581
|
+
mailReplyTo: form.mailReplyTo.trim(),
|
|
582
|
+
contactEmail: form.contactEmail.trim(),
|
|
583
|
+
relays: relayList(form.relays),
|
|
584
|
+
wordpressActivityPub: form.wordpressActivityPub !== '',
|
|
585
|
+
navigation: navigationList(form.navigation),
|
|
256
586
|
};
|
|
257
587
|
}
|
|
258
588
|
/** The settings as the form shows them. */
|
|
@@ -262,169 +592,110 @@ export function formFromSettings(settings) {
|
|
|
262
592
|
tagline: settings.tagline,
|
|
263
593
|
baseUrl: settings.baseUrl,
|
|
264
594
|
timezone: settings.timezone,
|
|
595
|
+
language: settings.language,
|
|
265
596
|
postsPerPage: String(settings.postsPerPage),
|
|
597
|
+
homepage: settings.homepage,
|
|
598
|
+
postsPage: settings.postsPage,
|
|
266
599
|
author: settings.author,
|
|
267
|
-
|
|
268
|
-
|
|
600
|
+
theme: settings.theme,
|
|
601
|
+
tagBase: settings.tagBase,
|
|
602
|
+
categoryBase: settings.categoryBase,
|
|
603
|
+
comments: settings.comments ? '1' : '',
|
|
604
|
+
commentsCloseAfterDays: String(settings.commentsCloseAfterDays),
|
|
605
|
+
webmentionsSend: settings.webmentionsSend ? '1' : '',
|
|
606
|
+
webmentionsReceive: settings.webmentionsReceive ? '1' : '',
|
|
607
|
+
notifyServer: settings.notifyServer,
|
|
608
|
+
mailProvider: settings.mailProvider,
|
|
609
|
+
mailFromName: settings.mailFromName,
|
|
610
|
+
mailFromAddress: settings.mailFromAddress,
|
|
611
|
+
mailReplyTo: settings.mailReplyTo,
|
|
612
|
+
contactEmail: settings.contactEmail,
|
|
613
|
+
relays: settings.relays.join('\n'),
|
|
614
|
+
wordpressActivityPub: settings.wordpressActivityPub ? '1' : '',
|
|
615
|
+
navigation: navigationText(settings.navigation),
|
|
269
616
|
};
|
|
270
617
|
}
|
|
271
618
|
/**
|
|
272
|
-
*
|
|
619
|
+
* A `taxonomy|from|to` block as the renames it names, which is how the old
|
|
620
|
+
* settings table spelled them ({@link migrateSettingsToFile}).
|
|
273
621
|
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
622
|
+
* The same tolerance the rest of this file reads its lists with: a line that
|
|
623
|
+
* is not three non-empty parts naming a real taxonomy is dropped rather than
|
|
624
|
+
* failing the read.
|
|
277
625
|
*/
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
// base URL keeps the value it had rather than being cleared by a save.
|
|
289
|
-
baseUrl: c.var.config.baseUrlSource === 'default'
|
|
290
|
-
? field(body[SETTINGS_FIELDS.baseUrl])
|
|
291
|
-
: stored.baseUrl === ''
|
|
292
|
-
? c.var.config.baseUrl
|
|
293
|
-
: stored.baseUrl,
|
|
294
|
-
timezone: field(body[SETTINGS_FIELDS.timezone]),
|
|
295
|
-
postsPerPage: field(body[SETTINGS_FIELDS.postsPerPage]),
|
|
296
|
-
author: field(body[SETTINGS_FIELDS.author]),
|
|
297
|
-
actorHandle: field(body[SETTINGS_FIELDS.actorHandle]),
|
|
298
|
-
actorType: field(body[SETTINGS_FIELDS.actorType]),
|
|
299
|
-
};
|
|
300
|
-
const problems = settingsProblems(submitted);
|
|
301
|
-
if (Object.keys(problems).length > 0) {
|
|
302
|
-
c.status(400);
|
|
303
|
-
return render(c, ADMIN_TEMPLATES.settings, {
|
|
304
|
-
...screen(c.var.config, stored),
|
|
305
|
-
form: submitted,
|
|
306
|
-
problems,
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
const settings = settingsFromForm(submitted, stored.avatar);
|
|
310
|
-
await store(c, settings);
|
|
311
|
-
// The name, the summary and the handle are the actor's profile as much as
|
|
312
|
-
// the avatar is, and a follower's copy of it is only as fresh as the last
|
|
313
|
-
// thing it was told.
|
|
314
|
-
const report = profileChanged(stored, settings)
|
|
315
|
-
? await c.var.delivery.updateActor()
|
|
316
|
-
: undefined;
|
|
317
|
-
flash(c, 'notice', `Settings saved.${toldFollowers(report)}`);
|
|
318
|
-
return c.redirect(SETTINGS_PATH, 303);
|
|
319
|
-
});
|
|
320
|
-
/**
|
|
321
|
-
* The avatar's own endpoint: one multipart form uploads an image, and a
|
|
322
|
-
* second, plain one takes it down again.
|
|
323
|
-
*
|
|
324
|
-
* It is separate from the settings form because a file cannot travel in a
|
|
325
|
-
* urlencoded body, and because the two should not share a fate: a rejected
|
|
326
|
-
* image must not lose an edit to the title, and a rejected title must not
|
|
327
|
-
* lose the avatar. A refusal is a flash and a redirect, so what is stored is
|
|
328
|
-
* exactly what it was and the screen says why.
|
|
329
|
-
*/
|
|
330
|
-
app.post(AVATAR_PATH, async (c) => {
|
|
331
|
-
const body = await c.req.parseBody();
|
|
332
|
-
const stored = readSiteSettings(c.var.admin);
|
|
333
|
-
if (field(body[AVATAR_FIELDS.action]) === AVATAR_REMOVE) {
|
|
334
|
-
if (stored.avatar === '') {
|
|
335
|
-
flash(c, 'notice', 'The site has no avatar.');
|
|
336
|
-
return c.redirect(SETTINGS_PATH, 303);
|
|
337
|
-
}
|
|
338
|
-
await store(c, { ...stored, avatar: '' });
|
|
339
|
-
const removal = await c.var.delivery.updateActor();
|
|
340
|
-
flash(c, 'notice', `Avatar removed.${toldFollowers(removal)}`);
|
|
341
|
-
return c.redirect(SETTINGS_PATH, 303);
|
|
342
|
-
}
|
|
343
|
-
const outcome = await storeUpload(body[AVATAR_FIELDS.file], c.var.config, {
|
|
344
|
-
imagesOnly: true,
|
|
626
|
+
function redirectList(value) {
|
|
627
|
+
const entries = [];
|
|
628
|
+
for (const line of value.split('\n')) {
|
|
629
|
+
const parts = line.split('|');
|
|
630
|
+
if (parts.length !== 3)
|
|
631
|
+
continue;
|
|
632
|
+
entries.push({
|
|
633
|
+
taxonomy: (parts[0] ?? '').trim(),
|
|
634
|
+
from: (parts[1] ?? '').trim(),
|
|
635
|
+
to: (parts[2] ?? '').trim(),
|
|
345
636
|
});
|
|
346
|
-
if (refusedUpload(outcome)) {
|
|
347
|
-
flash(c, 'error', `${outcome.error} The avatar is unchanged.`);
|
|
348
|
-
return c.redirect(SETTINGS_PATH, 303);
|
|
349
|
-
}
|
|
350
|
-
await store(c, { ...stored, avatar: outcome.url });
|
|
351
|
-
const report = await c.var.delivery.updateActor();
|
|
352
|
-
flash(c, 'notice', `Avatar saved.${toldFollowers(report)}`);
|
|
353
|
-
return c.redirect(SETTINGS_PATH, 303);
|
|
354
|
-
});
|
|
355
|
-
/**
|
|
356
|
-
* Write settings to SQLite and then to `content/_data/site.json`, in that
|
|
357
|
-
* order, so the store — which is what the theme reads — is never behind the
|
|
358
|
-
* file.
|
|
359
|
-
*/
|
|
360
|
-
async function store(c, settings) {
|
|
361
|
-
writeSiteSettings(c.var.admin, settings);
|
|
362
|
-
await writeSiteJson({ contentDir: c.var.config.contentDir, settings });
|
|
363
637
|
}
|
|
638
|
+
// Through the same reader `site.json` goes through, so the two spellings of
|
|
639
|
+
// the list cannot mean different things.
|
|
640
|
+
return taxonomyRedirectsOf(entries);
|
|
364
641
|
}
|
|
365
642
|
/**
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* the settings). The rest — the time zone, the page size — is the site's own
|
|
369
|
-
* business and nobody else's.
|
|
370
|
-
*
|
|
371
|
-
* The base URL is not here either, though the profile is built on it: it is
|
|
372
|
-
* settled at boot ({@link effectiveBaseUrl}), so an actor built the moment it
|
|
373
|
-
* is saved would carry the old one and say nothing new.
|
|
643
|
+
* A base URL, normalised the way `resolveConfig` normalises the configured
|
|
644
|
+
* one, or `undefined` when it is not an absolute http(s) URL.
|
|
374
645
|
*/
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
646
|
+
function normalizeBaseUrl(value) {
|
|
647
|
+
const trimmed = value.trim();
|
|
648
|
+
if (trimmed === '')
|
|
649
|
+
return undefined;
|
|
650
|
+
let parsed;
|
|
651
|
+
try {
|
|
652
|
+
parsed = new URL(trimmed);
|
|
653
|
+
}
|
|
654
|
+
catch {
|
|
655
|
+
return undefined;
|
|
656
|
+
}
|
|
657
|
+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
658
|
+
return undefined;
|
|
659
|
+
const pathname = parsed.pathname.endsWith('/') ? parsed.pathname.slice(0, -1) : parsed.pathname;
|
|
660
|
+
return parsed.origin + pathname;
|
|
381
661
|
}
|
|
382
662
|
/**
|
|
383
|
-
* The
|
|
384
|
-
*
|
|
385
|
-
*
|
|
663
|
+
* The non-empty lines of a relay textarea, trimmed.
|
|
664
|
+
*
|
|
665
|
+
* Blank lines are not an error: somebody pasting a list leaves them, and a
|
|
666
|
+
* blank line asks for nothing.
|
|
386
667
|
*/
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
? ' One follower has been told.'
|
|
393
|
-
: ` ${String(total)} followers have been told.`;
|
|
668
|
+
function relayLines(value) {
|
|
669
|
+
return value
|
|
670
|
+
.split('\n')
|
|
671
|
+
.map((line) => line.trim())
|
|
672
|
+
.filter((line) => line !== '');
|
|
394
673
|
}
|
|
395
|
-
/**
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
baseUrlSource: config.baseUrlSource,
|
|
412
|
-
baseUrlNote: overridden
|
|
413
|
-
? config.baseUrlSource === 'environment'
|
|
414
|
-
? 'GEEKITY_BASE_URL is set, so it is the base URL in effect and this field is not editable here.'
|
|
415
|
-
: 'The config file sets baseUrl, so it is the base URL in effect and this field is not editable here.'
|
|
416
|
-
: 'Absolute URLs, the feeds and the session cookie pick this up when the site next starts.',
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
/** A form field as a string. A file upload, or a missing field, is the empty one. */
|
|
420
|
-
function field(value) {
|
|
421
|
-
return typeof value === 'string' ? value : '';
|
|
674
|
+
/**
|
|
675
|
+
* A relay textarea as the list of inboxes it names: normalised, in the order
|
|
676
|
+
* they were given, with repeats dropped.
|
|
677
|
+
*
|
|
678
|
+
* Exported because the same parsing turns a stored setting, a submitted form
|
|
679
|
+
* and a `site.json` array into the one list; a second spelling of it would let
|
|
680
|
+
* the file and the database disagree about what a site subscribes to.
|
|
681
|
+
*/
|
|
682
|
+
export function relayList(value) {
|
|
683
|
+
const relays = [];
|
|
684
|
+
for (const line of relayLines(value)) {
|
|
685
|
+
const inbox = normalizeRelayInbox(line);
|
|
686
|
+
if (inbox !== undefined && !relays.includes(inbox))
|
|
687
|
+
relays.push(inbox);
|
|
688
|
+
}
|
|
689
|
+
return relays;
|
|
422
690
|
}
|
|
423
691
|
/**
|
|
424
|
-
* A
|
|
425
|
-
*
|
|
692
|
+
* A relay inbox URL, or `undefined` when it is not an absolute http(s) one.
|
|
693
|
+
*
|
|
694
|
+
* Unlike {@link normalizeBaseUrl} this keeps the whole URL bar a trailing
|
|
695
|
+
* slash: a relay inbox is a path — `/user/_____relay_____/inbox` — rather than
|
|
696
|
+
* an origin, and some relays hang one off a query string.
|
|
426
697
|
*/
|
|
427
|
-
function
|
|
698
|
+
export function normalizeRelayInbox(value) {
|
|
428
699
|
const trimmed = value.trim();
|
|
429
700
|
if (trimmed === '')
|
|
430
701
|
return undefined;
|
|
@@ -437,8 +708,23 @@ function normalizeBaseUrl(value) {
|
|
|
437
708
|
}
|
|
438
709
|
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')
|
|
439
710
|
return undefined;
|
|
440
|
-
const
|
|
441
|
-
return parsed.
|
|
711
|
+
const href = parsed.href;
|
|
712
|
+
return href.endsWith('/') && parsed.pathname !== '/' ? href.slice(0, -1) : href;
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* What a page slug may be made of on this screen: the shape
|
|
716
|
+
* {@link slugify} produces, which is what the editor writes.
|
|
717
|
+
*
|
|
718
|
+
* The setting travels no further than a lookup by slug, so this is about
|
|
719
|
+
* catching a hand-typed value rather than about safety.
|
|
720
|
+
*/
|
|
721
|
+
const PAGE_SLUG_PATTERN = /^[A-Za-z0-9._~-]{1,200}$/;
|
|
722
|
+
/** What is wrong with one page pick, or `undefined`. Empty is a value. */
|
|
723
|
+
function slugProblem(value, what) {
|
|
724
|
+
const slug = value.trim();
|
|
725
|
+
return slug === '' || PAGE_SLUG_PATTERN.test(slug)
|
|
726
|
+
? undefined
|
|
727
|
+
: `${what} is the slug of one of the site's pages, such as about.`;
|
|
442
728
|
}
|
|
443
729
|
/** Whether `Intl` knows the zone. An empty name is not a zone. */
|
|
444
730
|
function isValidTimezone(value) {
|
|
@@ -453,18 +739,74 @@ function isValidTimezone(value) {
|
|
|
453
739
|
return false;
|
|
454
740
|
}
|
|
455
741
|
}
|
|
742
|
+
/** One site.json as an object, empty when it is missing or will not parse. */
|
|
456
743
|
function readSiteJsonSync(file) {
|
|
744
|
+
return parseSiteJson(readFileIfPresentSync(file) ?? '');
|
|
745
|
+
}
|
|
746
|
+
/** The same, from bytes already in hand. */
|
|
747
|
+
function parseSiteJson(source) {
|
|
748
|
+
let parsed;
|
|
457
749
|
try {
|
|
458
|
-
|
|
750
|
+
parsed = JSON.parse(source);
|
|
459
751
|
}
|
|
460
752
|
catch {
|
|
461
753
|
return {};
|
|
462
754
|
}
|
|
463
|
-
}
|
|
464
|
-
function parseSiteJson(source) {
|
|
465
|
-
const parsed = JSON.parse(source);
|
|
466
755
|
return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)
|
|
467
756
|
? parsed
|
|
468
757
|
: {};
|
|
469
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* The non-empty lines of the navigation textarea, trimmed.
|
|
761
|
+
*
|
|
762
|
+
* Blank lines are not an error, exactly as they are not in the relay list: a
|
|
763
|
+
* pasted menu leaves them, and a blank line asks for nothing.
|
|
764
|
+
*/
|
|
765
|
+
function navigationLines(value) {
|
|
766
|
+
return value
|
|
767
|
+
.split('\n')
|
|
768
|
+
.map((line) => line.trim())
|
|
769
|
+
.filter((line) => line !== '');
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* One `Label | URL` line as a menu item, or `undefined` when it is not one.
|
|
773
|
+
*
|
|
774
|
+
* The split is at the first bar, so a URL holding one — a query string, say —
|
|
775
|
+
* survives and a label cannot hold one. The URL is either a site-root path or
|
|
776
|
+
* an absolute http(s) URL: a bare `about/` would be resolved against whatever
|
|
777
|
+
* page it was printed on, which is never what a menu means.
|
|
778
|
+
*/
|
|
779
|
+
function navigationItem(line) {
|
|
780
|
+
const bar = line.indexOf('|');
|
|
781
|
+
if (bar === -1)
|
|
782
|
+
return undefined;
|
|
783
|
+
const label = line.slice(0, bar).trim();
|
|
784
|
+
const url = line.slice(bar + 1).trim();
|
|
785
|
+
if (label === '' || url === '')
|
|
786
|
+
return undefined;
|
|
787
|
+
if (url.startsWith('/'))
|
|
788
|
+
return { label, url };
|
|
789
|
+
return normalizeRelayInbox(url) === undefined ? undefined : { label, url };
|
|
790
|
+
}
|
|
791
|
+
/**
|
|
792
|
+
* A navigation textarea as the ordered items it names.
|
|
793
|
+
*
|
|
794
|
+
* Exported nowhere: the same parsing turns the stored setting and the
|
|
795
|
+
* submitted form into one list, and `site.json` is read by
|
|
796
|
+
* {@link navigationItemsOf} instead, because the file holds objects rather
|
|
797
|
+
* than lines.
|
|
798
|
+
*/
|
|
799
|
+
function navigationList(value) {
|
|
800
|
+
const items = [];
|
|
801
|
+
for (const line of navigationLines(value)) {
|
|
802
|
+
const item = navigationItem(line);
|
|
803
|
+
if (item !== undefined)
|
|
804
|
+
items.push(item);
|
|
805
|
+
}
|
|
806
|
+
return items;
|
|
807
|
+
}
|
|
808
|
+
/** The items as the textarea shows them, and as the settings table holds them. */
|
|
809
|
+
function navigationText(items) {
|
|
810
|
+
return items.map((item) => `${item.label} | ${item.url}`).join('\n');
|
|
811
|
+
}
|
|
470
812
|
//# sourceMappingURL=settings.js.map
|