@jant/core 0.10.0 → 0.11.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/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -1,36 +1,302 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The feed docs describe the feeds a site actually serves.
|
|
3
3
|
*
|
|
4
4
|
* `docs/feed-reading.md` is the public contract for the `https://jant.me/ns`
|
|
5
|
-
* elements and attributes; `docs/feeds.md` covers `jant:discover
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* elements and attributes; `docs/feeds.md` covers `jant:discover` and every
|
|
6
|
+
* feed address. Scanning the renderer's source for `jant:` found element names
|
|
7
|
+
* but not the attributes on them, and nothing checked that an address in the
|
|
8
|
+
* docs resolved at all. These render a site with every kind of content a feed
|
|
9
|
+
* writes something for, and request every address the docs name.
|
|
9
10
|
*/
|
|
10
11
|
|
|
11
12
|
import { readFileSync } from "node:fs";
|
|
12
13
|
import { join, resolve } from "node:path";
|
|
14
|
+
import { eq } from "drizzle-orm";
|
|
13
15
|
import { describe, expect, it } from "vitest";
|
|
16
|
+
import { createApp } from "../app.js";
|
|
17
|
+
import type { Database } from "../db/index.js";
|
|
18
|
+
import { posts } from "../db/schema.js";
|
|
19
|
+
import type { StorageDriver } from "../lib/storage.js";
|
|
20
|
+
import { createServices } from "../services/index.js";
|
|
21
|
+
import type { Bindings, CreatePost } from "../types.js";
|
|
22
|
+
import { createTestDatabase, DEFAULT_TEST_SITE_ID } from "./helpers/db.js";
|
|
14
23
|
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
24
|
+
const REPO_ROOT = resolve(import.meta.dirname, "../../../..");
|
|
25
|
+
const ORIGIN = "https://blog.example";
|
|
26
|
+
|
|
27
|
+
const executionCtx = {
|
|
28
|
+
waitUntil() {},
|
|
29
|
+
passThroughOnException() {},
|
|
30
|
+
props: {},
|
|
31
|
+
} as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
|
|
32
|
+
|
|
33
|
+
function readDoc(path: string): string {
|
|
34
|
+
return readFileSync(join(REPO_ROOT, path), "utf8");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Storage that accepts writes; the feed only needs the keys. */
|
|
38
|
+
const storage = {
|
|
39
|
+
async put() {},
|
|
40
|
+
async get() {
|
|
41
|
+
return null;
|
|
42
|
+
},
|
|
43
|
+
async delete() {},
|
|
44
|
+
} as unknown as StorageDriver;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A multilingual site with Discover on, collections, and a thread long enough
|
|
48
|
+
* to fold, whose posts carry every attachment kind, a Link preview image, and
|
|
49
|
+
* a summary cut short.
|
|
50
|
+
*/
|
|
51
|
+
async function createRichSite() {
|
|
52
|
+
const { db, sqlite } = createTestDatabase();
|
|
53
|
+
const services = createServices(
|
|
54
|
+
db as unknown as Database,
|
|
55
|
+
{ query: async () => [] } as unknown as Parameters<
|
|
56
|
+
typeof createServices
|
|
57
|
+
>[1],
|
|
58
|
+
DEFAULT_TEST_SITE_ID,
|
|
59
|
+
{ slugIdLength: 5 },
|
|
60
|
+
);
|
|
61
|
+
await services.settings.completeOnboarding();
|
|
62
|
+
await services.settings.set("RSS_PUBLISH_DELAY_SECONDS", "0");
|
|
63
|
+
await services.settings.set("DISCOVER", "latest");
|
|
64
|
+
await services.settings.set("MULTILINGUAL_ENABLED", "true");
|
|
65
|
+
await services.settings.set("ADDITIONAL_LANGUAGES", "ja");
|
|
66
|
+
|
|
67
|
+
const reading = await services.collections.create({
|
|
68
|
+
slug: "reading",
|
|
69
|
+
title: "Reading",
|
|
70
|
+
});
|
|
71
|
+
await services.collections.create({ slug: "cooking", title: "Cooking" });
|
|
72
|
+
|
|
73
|
+
const root = await services.posts.createWithAttachments(
|
|
74
|
+
{
|
|
75
|
+
format: "note",
|
|
76
|
+
title: "Root",
|
|
77
|
+
bodyMarkdown: `${"A long paragraph of words. ".repeat(80)}\n\nMore.`,
|
|
78
|
+
collectionIds: [reading.id],
|
|
79
|
+
featuredAt: 1_700_000_000,
|
|
80
|
+
language: "en",
|
|
81
|
+
},
|
|
82
|
+
[{ type: "text", contentFormat: "markdown", content: "# Notes" }],
|
|
83
|
+
{
|
|
84
|
+
media: services.media,
|
|
85
|
+
storage,
|
|
86
|
+
storageDriver: "local",
|
|
87
|
+
maxFileSizeMB: 10,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
await services.media.create({
|
|
91
|
+
filename: "v.mp4",
|
|
92
|
+
originalName: "v.mp4",
|
|
93
|
+
mimeType: "video/mp4",
|
|
94
|
+
size: 1,
|
|
95
|
+
storageKey: "media/site/v.mp4",
|
|
96
|
+
postId: root.id,
|
|
97
|
+
durationSeconds: 12,
|
|
98
|
+
posterKey: "media/site/v-poster.jpg",
|
|
99
|
+
width: 16,
|
|
100
|
+
height: 9,
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// A thread is a chain: each reply answers the one before it.
|
|
104
|
+
let tail = root;
|
|
105
|
+
const reply = async (data: Omit<CreatePost, "replyToId">) => {
|
|
106
|
+
tail = await services.posts.create({
|
|
107
|
+
...data,
|
|
108
|
+
language: "en",
|
|
109
|
+
replyToId: tail.id,
|
|
110
|
+
});
|
|
111
|
+
return tail;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const link = await reply({
|
|
115
|
+
format: "link",
|
|
116
|
+
title: "A link",
|
|
117
|
+
url: "https://example.org",
|
|
118
|
+
bodyMarkdown: "Why",
|
|
119
|
+
});
|
|
120
|
+
await db
|
|
121
|
+
.update(posts)
|
|
122
|
+
.set({ previewImageKey: "media/site/preview.jpg" })
|
|
123
|
+
.where(eq(posts.id, link.id));
|
|
124
|
+
|
|
125
|
+
const photo = await reply({ format: "note" });
|
|
126
|
+
await services.media.create({
|
|
127
|
+
filename: "img.webp",
|
|
128
|
+
originalName: "img.webp",
|
|
129
|
+
mimeType: "image/webp",
|
|
130
|
+
size: 3,
|
|
131
|
+
storageKey: "media/site/img.webp",
|
|
132
|
+
postId: photo.id,
|
|
133
|
+
width: 10,
|
|
134
|
+
height: 10,
|
|
135
|
+
alt: "Alt",
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
await reply({ format: "quote", quoteText: "Words", title: "Someone" });
|
|
139
|
+
await reply({ format: "note", bodyMarkdown: "Four." });
|
|
140
|
+
await reply({ format: "note", bodyMarkdown: "Five." });
|
|
141
|
+
await reply({
|
|
142
|
+
format: "note",
|
|
143
|
+
title: "Last",
|
|
144
|
+
bodyMarkdown: "The newest reply, cut short. ".repeat(80),
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const app = createApp();
|
|
148
|
+
const request = (path: string) =>
|
|
149
|
+
app.fetch(
|
|
150
|
+
new Request(`${ORIGIN}${path}`),
|
|
151
|
+
{
|
|
152
|
+
SITE_ORIGIN: ORIGIN,
|
|
153
|
+
AUTH_SECRET: "x".repeat(40),
|
|
154
|
+
NODE_SQLITE: sqlite,
|
|
155
|
+
} as unknown as Bindings,
|
|
156
|
+
executionCtx,
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
return { request };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Every name a feed writes in the jant namespace, and every attribute on an
|
|
164
|
+
* element in the jant or Media RSS namespace.
|
|
165
|
+
*/
|
|
166
|
+
function collectFeedNames(xml: string) {
|
|
167
|
+
const elements = new Map<string, Set<string>>();
|
|
168
|
+
for (const [, name = "", attrs = ""] of xml.matchAll(
|
|
169
|
+
/<((?:jant|media):[a-z]+)((?:\s+[a-zA-Z:]+="[^"]*")*)\s*\/?>/g,
|
|
170
|
+
)) {
|
|
171
|
+
const seen = elements.get(name) ?? new Set<string>();
|
|
172
|
+
for (const [, attr = ""] of attrs.matchAll(/([a-zA-Z:]+)="/g)) {
|
|
173
|
+
seen.add(attr);
|
|
174
|
+
}
|
|
175
|
+
elements.set(name, seen);
|
|
176
|
+
}
|
|
177
|
+
const jantAttributes = new Set(
|
|
178
|
+
[...xml.matchAll(/\s(jant:[a-z]+)="/g)].map((match) => match[1] ?? ""),
|
|
179
|
+
);
|
|
180
|
+
return { elements, jantAttributes };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Backticked site paths a doc names, placeholders left out. */
|
|
184
|
+
function documentedPaths(doc: string): string[] {
|
|
185
|
+
return [
|
|
186
|
+
...new Set(
|
|
187
|
+
[...doc.matchAll(/`(\/[^`\s]*)`/g)]
|
|
188
|
+
.map((match) => match[1] ?? "")
|
|
189
|
+
.filter((path) => !path.includes("{")),
|
|
190
|
+
),
|
|
191
|
+
];
|
|
192
|
+
}
|
|
19
193
|
|
|
20
194
|
describe("feed docs", () => {
|
|
21
|
-
it("document every
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
195
|
+
it("document every element and attribute a served feed writes", async () => {
|
|
196
|
+
const { request } = await createRichSite();
|
|
197
|
+
const res = await request("/latest/feed");
|
|
198
|
+
expect(res.status).toBe(200);
|
|
199
|
+
const xml = await res.text();
|
|
200
|
+
const { elements, jantAttributes } = collectFeedNames(xml);
|
|
201
|
+
|
|
202
|
+
// The fixture has to reach what it claims to, or the rest passes empty.
|
|
203
|
+
expect([...elements.keys()]).toEqual(
|
|
204
|
+
expect.arrayContaining([
|
|
205
|
+
"jant:discover",
|
|
206
|
+
"jant:id",
|
|
207
|
+
"jant:format",
|
|
208
|
+
"jant:thread",
|
|
209
|
+
"jant:post",
|
|
210
|
+
"jant:truncated",
|
|
211
|
+
"media:content",
|
|
212
|
+
"media:thumbnail",
|
|
213
|
+
]),
|
|
214
|
+
);
|
|
215
|
+
expect(elements.get("jant:thread")).toEqual(
|
|
216
|
+
new Set(["posts", "hidden", "gap", "latest"]),
|
|
217
|
+
);
|
|
218
|
+
expect([...(elements.get("jant:post") ?? [])]).toEqual(
|
|
219
|
+
expect.arrayContaining(["url", "thumbnail", "folded", "truncated"]),
|
|
28
220
|
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
221
|
+
expect([...jantAttributes].sort()).toEqual(["jant:page", "jant:post"]);
|
|
222
|
+
|
|
223
|
+
const docs = [
|
|
224
|
+
readDoc("docs/feed-reading.md"),
|
|
225
|
+
readDoc("docs/feeds.md"),
|
|
226
|
+
].join("\n");
|
|
227
|
+
const missing: string[] = [];
|
|
228
|
+
for (const [name, attrs] of elements) {
|
|
229
|
+
if (name.startsWith("jant:") && !docs.includes(name)) missing.push(name);
|
|
230
|
+
for (const attr of attrs) {
|
|
231
|
+
if (!docs.includes(`\`${attr}\``) && !docs.includes(`@${attr}`)) {
|
|
232
|
+
missing.push(`${name}/@${attr}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
for (const attr of jantAttributes) {
|
|
237
|
+
if (!docs.includes(attr)) missing.push(`@${attr}`);
|
|
238
|
+
}
|
|
239
|
+
expect(missing).toEqual([]);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("carry every jant: name from the feed guide into its translation", () => {
|
|
243
|
+
const names = (doc: string) =>
|
|
244
|
+
new Set([...doc.matchAll(/jant:[a-z]+/g)].map((match) => match[0]));
|
|
245
|
+
const english = names(readDoc("docs/feeds.md"));
|
|
246
|
+
const chinese = names(readDoc("docs/zh-Hans/feeds.md"));
|
|
247
|
+
|
|
248
|
+
expect(english.size).toBeGreaterThan(0);
|
|
249
|
+
expect([...english].filter((name) => !chinese.has(name))).toEqual([]);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("resolve every address the feed guide names", async () => {
|
|
253
|
+
const { request } = await createRichSite();
|
|
254
|
+
const english = readDoc("docs/feeds.md");
|
|
255
|
+
const paths = new Set([
|
|
256
|
+
...documentedPaths(english),
|
|
257
|
+
...documentedPaths(readDoc("docs/zh-Hans/feeds.md")),
|
|
258
|
+
]);
|
|
259
|
+
expect(paths).toContain("/ja/reading/feed");
|
|
260
|
+
expect(paths).toContain("/collections/reading+cooking/feed");
|
|
261
|
+
|
|
262
|
+
const broken: string[] = [];
|
|
263
|
+
for (const path of paths) {
|
|
264
|
+
let res = await request(path);
|
|
265
|
+
for (
|
|
266
|
+
let hops = 0;
|
|
267
|
+
hops < 3 && res.status >= 300 && res.status < 400;
|
|
268
|
+
hops++
|
|
269
|
+
) {
|
|
270
|
+
const next = new URL(res.headers.get("location") ?? "", ORIGIN);
|
|
271
|
+
res = await request(next.pathname + next.search);
|
|
272
|
+
}
|
|
273
|
+
const isFeed = /\/feed(\?|$)/.test(path);
|
|
274
|
+
const type = res.headers.get("content-type") ?? "";
|
|
275
|
+
if (res.status !== 200 || (isFeed && !type.includes("atom+xml"))) {
|
|
276
|
+
broken.push(`${path} → ${res.status} ${type}`);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
expect(broken).toEqual([]);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it("redirect every older address to the one the guide names", async () => {
|
|
283
|
+
const { request } = await createRichSite();
|
|
284
|
+
const rows = [
|
|
285
|
+
...readDoc("docs/feeds.md").matchAll(
|
|
286
|
+
/^\| `(\/[^`]+)` +\| `(\/[^`]+)` +\|$/gm,
|
|
287
|
+
),
|
|
288
|
+
];
|
|
289
|
+
expect(rows.length).toBeGreaterThan(5);
|
|
32
290
|
|
|
33
|
-
|
|
34
|
-
|
|
291
|
+
const wrong: string[] = [];
|
|
292
|
+
for (const [, from = "", to = ""] of rows) {
|
|
293
|
+
const res = await request(from);
|
|
294
|
+
const location = res.headers.get("location");
|
|
295
|
+
const target = location ? new URL(location, ORIGIN).pathname : null;
|
|
296
|
+
if (![301, 308].includes(res.status) || target !== to) {
|
|
297
|
+
wrong.push(`${from} → ${res.status} ${target ?? ""}`);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
expect(wrong).toEqual([]);
|
|
35
301
|
});
|
|
36
302
|
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A reply has one address in every feed.
|
|
3
|
+
*
|
|
4
|
+
* The latest and featured feeds named a reply by its custom URL while the
|
|
5
|
+
* archive, collection, and smart collection feeds named it by its slug, so a
|
|
6
|
+
* reader following two of them saw the same reply as two posts. Every feed
|
|
7
|
+
* now builds its entries through one function; this walks the feeds of one
|
|
8
|
+
* site and compares.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { describe, expect, it } from "vitest";
|
|
12
|
+
import { createApp } from "../app.js";
|
|
13
|
+
import type { Database } from "../db/index.js";
|
|
14
|
+
import { createServices } from "../services/index.js";
|
|
15
|
+
import type { Bindings } from "../types.js";
|
|
16
|
+
import { createTestDatabase, DEFAULT_TEST_SITE_ID } from "./helpers/db.js";
|
|
17
|
+
|
|
18
|
+
const executionCtx = {
|
|
19
|
+
waitUntil() {},
|
|
20
|
+
passThroughOnException() {},
|
|
21
|
+
props: {},
|
|
22
|
+
} as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
|
|
23
|
+
|
|
24
|
+
describe("reply addresses across feeds", () => {
|
|
25
|
+
it("names a reply by its custom URL in every feed", async () => {
|
|
26
|
+
const { db, sqlite } = createTestDatabase();
|
|
27
|
+
const services = createServices(
|
|
28
|
+
db as unknown as Database,
|
|
29
|
+
{ query: async () => [] } as unknown as Parameters<
|
|
30
|
+
typeof createServices
|
|
31
|
+
>[1],
|
|
32
|
+
DEFAULT_TEST_SITE_ID,
|
|
33
|
+
{ slugIdLength: 5 },
|
|
34
|
+
);
|
|
35
|
+
await services.settings.completeOnboarding();
|
|
36
|
+
await services.settings.set("RSS_PUBLISH_DELAY_SECONDS", "0");
|
|
37
|
+
const collection = await services.collections.create({
|
|
38
|
+
slug: "walks",
|
|
39
|
+
title: "Walks",
|
|
40
|
+
});
|
|
41
|
+
await services.smartCollections.create({
|
|
42
|
+
slug: "notes",
|
|
43
|
+
title: "Notes",
|
|
44
|
+
selection: { format: "note" },
|
|
45
|
+
});
|
|
46
|
+
const root = await services.posts.create({
|
|
47
|
+
format: "note",
|
|
48
|
+
title: "A long walk",
|
|
49
|
+
bodyMarkdown: "Out past the river.",
|
|
50
|
+
collectionIds: [collection.id],
|
|
51
|
+
featuredAt: 1_700_000_000,
|
|
52
|
+
});
|
|
53
|
+
const reply = await services.posts.create({
|
|
54
|
+
format: "note",
|
|
55
|
+
bodyMarkdown: "And back again.",
|
|
56
|
+
replyToId: root.id,
|
|
57
|
+
});
|
|
58
|
+
await services.customUrls.create({
|
|
59
|
+
path: "walks/back-again",
|
|
60
|
+
targetType: "post",
|
|
61
|
+
targetId: reply.id,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const app = createApp();
|
|
65
|
+
const feed = async (path: string) => {
|
|
66
|
+
const res = await app.fetch(
|
|
67
|
+
new Request(`https://blog.example${path}`),
|
|
68
|
+
{
|
|
69
|
+
SITE_ORIGIN: "https://blog.example",
|
|
70
|
+
AUTH_SECRET: "x".repeat(40),
|
|
71
|
+
NODE_SQLITE: sqlite,
|
|
72
|
+
} as unknown as Bindings,
|
|
73
|
+
executionCtx,
|
|
74
|
+
);
|
|
75
|
+
expect(res.status, path).toBe(200);
|
|
76
|
+
return res.text();
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const replyRows = new Map<string, string[]>();
|
|
80
|
+
for (const path of [
|
|
81
|
+
"/latest/feed",
|
|
82
|
+
"/featured/feed",
|
|
83
|
+
"/archive/feed",
|
|
84
|
+
"/walks/feed",
|
|
85
|
+
"/notes/feed",
|
|
86
|
+
]) {
|
|
87
|
+
const xml = await feed(path);
|
|
88
|
+
replyRows.set(
|
|
89
|
+
path,
|
|
90
|
+
[...xml.matchAll(/<jant:post href="([^"]+)"/g)]
|
|
91
|
+
.map((match) => match[1] ?? "")
|
|
92
|
+
.filter((href) => href !== "https://blog.example/" + root.slug),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
for (const [path, hrefs] of replyRows) {
|
|
97
|
+
expect(hrefs, path).toEqual(["https://blog.example/walks/back-again"]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* With feeds off, every feed route answers 404, and nothing else does.
|
|
3
|
+
*
|
|
4
|
+
* The switch used to be a middleware that matched any path ending in `/feed`,
|
|
5
|
+
* which also took down a post whose custom URL happens to end that way. It
|
|
6
|
+
* now lives in the routes that render a feed; this walks the whole app to
|
|
7
|
+
* check that each of them still refuses.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, expect, it } from "vitest";
|
|
11
|
+
import { createApp } from "../app.js";
|
|
12
|
+
import type { Database } from "../db/index.js";
|
|
13
|
+
import { createServices } from "../services/index.js";
|
|
14
|
+
import type { Bindings } from "../types.js";
|
|
15
|
+
import { createTestDatabase, DEFAULT_TEST_SITE_ID } from "./helpers/db.js";
|
|
16
|
+
|
|
17
|
+
const executionCtx = {
|
|
18
|
+
waitUntil() {},
|
|
19
|
+
passThroughOnException() {},
|
|
20
|
+
props: {},
|
|
21
|
+
} as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
|
|
22
|
+
|
|
23
|
+
async function createSite({ feeds }: { feeds: boolean }) {
|
|
24
|
+
const { db, sqlite } = createTestDatabase();
|
|
25
|
+
const services = createServices(
|
|
26
|
+
db as unknown as Database,
|
|
27
|
+
{ query: async () => [] } as unknown as Parameters<
|
|
28
|
+
typeof createServices
|
|
29
|
+
>[1],
|
|
30
|
+
DEFAULT_TEST_SITE_ID,
|
|
31
|
+
{ slugIdLength: 5 },
|
|
32
|
+
);
|
|
33
|
+
await services.settings.completeOnboarding();
|
|
34
|
+
await services.settings.set("RSS_FEEDS_ENABLED", String(feeds));
|
|
35
|
+
await services.collections.create({ slug: "reading", title: "Reading" });
|
|
36
|
+
await services.collections.create({ slug: "movies", title: "Movies" });
|
|
37
|
+
await services.smartCollections.create({
|
|
38
|
+
slug: "quotes",
|
|
39
|
+
title: "Quotes",
|
|
40
|
+
selection: { format: "quote" },
|
|
41
|
+
});
|
|
42
|
+
const post = await services.posts.create({
|
|
43
|
+
format: "note",
|
|
44
|
+
title: "Field notes",
|
|
45
|
+
bodyMarkdown: "Kept at an address that ends in feed.",
|
|
46
|
+
});
|
|
47
|
+
await services.customUrls.create({
|
|
48
|
+
path: "notes/feed",
|
|
49
|
+
targetType: "post",
|
|
50
|
+
targetId: post.id,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const app = createApp();
|
|
54
|
+
return (path: string) =>
|
|
55
|
+
app.fetch(
|
|
56
|
+
new Request(`https://blog.example${path}`),
|
|
57
|
+
{
|
|
58
|
+
SITE_ORIGIN: "https://blog.example",
|
|
59
|
+
AUTH_SECRET: "x".repeat(40),
|
|
60
|
+
NODE_SQLITE: sqlite,
|
|
61
|
+
} as unknown as Bindings,
|
|
62
|
+
executionCtx,
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const FEED_PATHS = [
|
|
67
|
+
"/feed",
|
|
68
|
+
"/feed/latest",
|
|
69
|
+
"/feed/atom.xml",
|
|
70
|
+
"/latest/feed",
|
|
71
|
+
"/latest/feed/atom.xml",
|
|
72
|
+
"/featured/feed",
|
|
73
|
+
"/archive/feed",
|
|
74
|
+
"/archive/feed/atom.xml",
|
|
75
|
+
"/reading/feed",
|
|
76
|
+
"/quotes/feed",
|
|
77
|
+
"/collections/reading+movies/feed",
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
describe("feeds turned off", () => {
|
|
81
|
+
it.each(FEED_PATHS)("answers 404 at %s", async (path) => {
|
|
82
|
+
const get = await createSite({ feeds: false });
|
|
83
|
+
expect((await get(path)).status).toBe(404);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// The same site with feeds on, so the 404s above are the switch's.
|
|
87
|
+
it.each(FEED_PATHS)("answers at %s once feeds are on", async (path) => {
|
|
88
|
+
const get = await createSite({ feeds: true });
|
|
89
|
+
expect([200, 301, 308]).toContain((await get(path)).status);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("still serves a post whose custom URL ends in /feed", async () => {
|
|
93
|
+
const get = await createSite({ feeds: false });
|
|
94
|
+
const res = await get("/notes/feed");
|
|
95
|
+
expect(res.status).toBe(200);
|
|
96
|
+
expect(await res.text()).toContain("Field notes");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Collection pages: aliases",
|
|
3
|
+
"Collection pages: display_layout",
|
|
4
|
+
"Collection pages: selection",
|
|
5
|
+
"Collection pages: slug",
|
|
6
|
+
"Collection pages: sort_order",
|
|
7
|
+
"Collection pages: summary_text",
|
|
8
|
+
"Collection pages: title",
|
|
9
|
+
"Collection pages: type",
|
|
10
|
+
"Each media entry: alt",
|
|
11
|
+
"Each media entry: blurhash",
|
|
12
|
+
"Each media entry: chars",
|
|
13
|
+
"Each media entry: duration_seconds",
|
|
14
|
+
"Each media entry: height",
|
|
15
|
+
"Each media entry: kind",
|
|
16
|
+
"Each media entry: mime_type",
|
|
17
|
+
"Each media entry: original_name",
|
|
18
|
+
"Each media entry: poster",
|
|
19
|
+
"Each media entry: size",
|
|
20
|
+
"Each media entry: src",
|
|
21
|
+
"Each media entry: summary",
|
|
22
|
+
"Each media entry: waveform",
|
|
23
|
+
"Each media entry: width",
|
|
24
|
+
"Post files: aliases",
|
|
25
|
+
"Post files: build",
|
|
26
|
+
"Post files: collections",
|
|
27
|
+
"Post files: created",
|
|
28
|
+
"Post files: date",
|
|
29
|
+
"Post files: draft",
|
|
30
|
+
"Post files: featured_at",
|
|
31
|
+
"Post files: format",
|
|
32
|
+
"Post files: id",
|
|
33
|
+
"Post files: language",
|
|
34
|
+
"Post files: last_activity_at",
|
|
35
|
+
"Post files: link_url",
|
|
36
|
+
"Post files: media",
|
|
37
|
+
"Post files: pinned_at",
|
|
38
|
+
"Post files: quiet_reply",
|
|
39
|
+
"Post files: quote_text",
|
|
40
|
+
"Post files: rating",
|
|
41
|
+
"Post files: root_aliases",
|
|
42
|
+
"Post files: slug",
|
|
43
|
+
"Post files: source_name",
|
|
44
|
+
"Post files: source_url",
|
|
45
|
+
"Post files: status",
|
|
46
|
+
"Post files: title",
|
|
47
|
+
"Post files: translation_group",
|
|
48
|
+
"Post files: type",
|
|
49
|
+
"Post files: updated",
|
|
50
|
+
"Post files: visibility",
|
|
51
|
+
"Post files: weight",
|
|
52
|
+
"data/jant.toml: apple_touch_icon_path",
|
|
53
|
+
"data/jant.toml: apple_touch_mode",
|
|
54
|
+
"data/jant.toml: custom_url",
|
|
55
|
+
"data/jant.toml: default_theme_id",
|
|
56
|
+
"data/jant.toml: directory",
|
|
57
|
+
"data/jant.toml: favicon_mode",
|
|
58
|
+
"data/jant.toml: favicon_path",
|
|
59
|
+
"data/jant.toml: font_theme_id",
|
|
60
|
+
"data/jant.toml: format",
|
|
61
|
+
"data/jant.toml: nav",
|
|
62
|
+
"data/jant.toml: noindex",
|
|
63
|
+
"data/jant.toml: public_api_enabled",
|
|
64
|
+
"data/jant.toml: rss_feeds_enabled",
|
|
65
|
+
"data/jant.toml: show_header_avatar",
|
|
66
|
+
"data/jant.toml: show_jant_branding_on_home",
|
|
67
|
+
"data/jant.toml: site_avatar_mode",
|
|
68
|
+
"data/jant.toml: site_avatar_url",
|
|
69
|
+
"data/jant.toml: site_description",
|
|
70
|
+
"data/jant.toml: site_footer_markdown",
|
|
71
|
+
"data/jant.toml: site_language",
|
|
72
|
+
"data/jant.toml: site_name",
|
|
73
|
+
"data/jant.toml: theme_id",
|
|
74
|
+
"data/jant.toml: theme_mode",
|
|
75
|
+
"data/jant.toml: version"
|
|
76
|
+
]
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[
|
|
2
|
+
"Collection pages: aliases",
|
|
3
|
+
"Collection pages: description",
|
|
4
|
+
"Collection pages: display_layout",
|
|
5
|
+
"Collection pages: selection",
|
|
6
|
+
"Collection pages: slug",
|
|
7
|
+
"Collection pages: sort_order",
|
|
8
|
+
"Collection pages: title",
|
|
9
|
+
"Collection pages: type",
|
|
10
|
+
"Each media entry: alt",
|
|
11
|
+
"Each media entry: blurhash",
|
|
12
|
+
"Each media entry: chars",
|
|
13
|
+
"Each media entry: duration_seconds",
|
|
14
|
+
"Each media entry: height",
|
|
15
|
+
"Each media entry: kind",
|
|
16
|
+
"Each media entry: mime_type",
|
|
17
|
+
"Each media entry: original_name",
|
|
18
|
+
"Each media entry: poster",
|
|
19
|
+
"Each media entry: size",
|
|
20
|
+
"Each media entry: src",
|
|
21
|
+
"Each media entry: summary",
|
|
22
|
+
"Each media entry: waveform",
|
|
23
|
+
"Each media entry: width",
|
|
24
|
+
"Post files: aliases",
|
|
25
|
+
"Post files: build",
|
|
26
|
+
"Post files: collections",
|
|
27
|
+
"Post files: created",
|
|
28
|
+
"Post files: date",
|
|
29
|
+
"Post files: draft",
|
|
30
|
+
"Post files: featured_at",
|
|
31
|
+
"Post files: format",
|
|
32
|
+
"Post files: id",
|
|
33
|
+
"Post files: language",
|
|
34
|
+
"Post files: last_activity_at",
|
|
35
|
+
"Post files: link_url",
|
|
36
|
+
"Post files: media",
|
|
37
|
+
"Post files: pinned_at",
|
|
38
|
+
"Post files: quiet_reply",
|
|
39
|
+
"Post files: quote_text",
|
|
40
|
+
"Post files: rating",
|
|
41
|
+
"Post files: root_aliases",
|
|
42
|
+
"Post files: slug",
|
|
43
|
+
"Post files: source_name",
|
|
44
|
+
"Post files: source_url",
|
|
45
|
+
"Post files: status",
|
|
46
|
+
"Post files: title",
|
|
47
|
+
"Post files: translation_group",
|
|
48
|
+
"Post files: type",
|
|
49
|
+
"Post files: updated",
|
|
50
|
+
"Post files: visibility",
|
|
51
|
+
"Post files: weight",
|
|
52
|
+
"data/jant.toml: additional_languages",
|
|
53
|
+
"data/jant.toml: apple_touch_icon_path",
|
|
54
|
+
"data/jant.toml: apple_touch_mode",
|
|
55
|
+
"data/jant.toml: custom_url",
|
|
56
|
+
"data/jant.toml: default_theme_id",
|
|
57
|
+
"data/jant.toml: directory",
|
|
58
|
+
"data/jant.toml: favicon_mode",
|
|
59
|
+
"data/jant.toml: favicon_path",
|
|
60
|
+
"data/jant.toml: font_theme_id",
|
|
61
|
+
"data/jant.toml: format",
|
|
62
|
+
"data/jant.toml: main_rss_feed",
|
|
63
|
+
"data/jant.toml: multilingual_enabled",
|
|
64
|
+
"data/jant.toml: nav",
|
|
65
|
+
"data/jant.toml: noindex",
|
|
66
|
+
"data/jant.toml: public_api_enabled",
|
|
67
|
+
"data/jant.toml: rss_feeds_enabled",
|
|
68
|
+
"data/jant.toml: show_header_avatar",
|
|
69
|
+
"data/jant.toml: show_jant_branding_on_home",
|
|
70
|
+
"data/jant.toml: site_avatar_mode",
|
|
71
|
+
"data/jant.toml: site_avatar_url",
|
|
72
|
+
"data/jant.toml: site_description",
|
|
73
|
+
"data/jant.toml: site_footer_markdown",
|
|
74
|
+
"data/jant.toml: site_language",
|
|
75
|
+
"data/jant.toml: site_name",
|
|
76
|
+
"data/jant.toml: theme_id",
|
|
77
|
+
"data/jant.toml: theme_mode",
|
|
78
|
+
"data/jant.toml: time_zone",
|
|
79
|
+
"data/jant.toml: version"
|
|
80
|
+
]
|