@basicbenframework/cms 0.0.0-stage → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +9 -0
- package/README.md +206 -2
- package/db/migrations/001_create_users.js +15 -0
- package/db/migrations/002_create_posts.js +18 -0
- package/db/migrations/003_create_categories.js +19 -0
- package/db/migrations/004_create_tags.js +16 -0
- package/db/migrations/005_create_post_tags.js +16 -0
- package/db/migrations/006_create_pages.js +26 -0
- package/db/migrations/007_create_comments.js +24 -0
- package/db/migrations/008_create_media.js +22 -0
- package/db/migrations/009_update_posts_blogging.js +27 -0
- package/db/migrations/010_create_settings.js +29 -0
- package/db/migrations/011_add_user_roles.js +23 -0
- package/db/migrations/012_create_auth_tokens.js +30 -0
- package/db/migrations/013_add_email_verified.js +24 -0
- package/db/migrations/014_create_user_two_factor.js +30 -0
- package/db/migrations/015_create_user_credentials.js +35 -0
- package/db/migrations/016_create_rate_limits.js +31 -0
- package/db/migrations/017_add_content_html.js +38 -0
- package/db/migrations/018_create_api_tokens.js +34 -0
- package/db/migrations/019_create_post_categories.js +40 -0
- package/db/migrations/020_add_author_profiles.js +60 -0
- package/db/migrations/021_add_page_featured_image.js +23 -0
- package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
- package/db/migrations/023_add_user_session_controls.js +25 -0
- package/db/migrations/024_add_post_status_and_trash.js +45 -0
- package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
- package/db/migrations/026_create_post_revisions.js +29 -0
- package/db/migrations/027_add_media_dimensions.js +19 -0
- package/db/migrations/028_create_navigation_menus.js +65 -0
- package/db/migrations/029_create_redirects.js +40 -0
- package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
- package/db/migrations/031_create_post_locks.js +38 -0
- package/db/migrations/032_create_snippets.js +31 -0
- package/db/migrations/033_create_members.js +70 -0
- package/db/migrations/034_add_post_visibility.js +28 -0
- package/db/migrations/035_create_newsletters.js +72 -0
- package/db/migrations/036_create_analytics.js +89 -0
- package/db/migrations/037_create_ops_heartbeats.js +30 -0
- package/db/migrations/038_create_content_types.js +84 -0
- package/db/migrations/039_create_content_type_fields.js +47 -0
- package/db/migrations/040_create_taxonomies.js +80 -0
- package/db/migrations/041_add_newsletter_handoff.js +28 -0
- package/db/migrations/042_create_mysendbox_contacts.js +63 -0
- package/lib/cli/backup.d.mts +2 -0
- package/lib/cli/backup.mjs +124 -0
- package/lib/cli/export.d.mts +2 -0
- package/lib/cli/export.mjs +54 -0
- package/lib/cli/import-ghost.d.mts +2 -0
- package/lib/cli/import-ghost.mjs +50 -0
- package/lib/cli/import-json.d.mts +2 -0
- package/lib/cli/import-json.mjs +61 -0
- package/lib/cli/import-wordpress.d.mts +2 -0
- package/lib/cli/import-wordpress.mjs +169 -0
- package/lib/cli/import-wxr.d.mts +2 -0
- package/lib/cli/import-wxr.mjs +55 -0
- package/lib/cli/index.d.mts +2 -0
- package/lib/cli/index.mjs +53 -0
- package/lib/cli/lib/backup.d.mts +112 -0
- package/lib/cli/lib/backup.mjs +297 -0
- package/lib/cli/lib/ghost.d.mts +30 -0
- package/lib/cli/lib/ghost.mjs +201 -0
- package/lib/cli/lib/html-to-markdown.d.mts +61 -0
- package/lib/cli/lib/html-to-markdown.mjs +523 -0
- package/lib/cli/lib/import-common.d.mts +100 -0
- package/lib/cli/lib/import-common.mjs +252 -0
- package/lib/cli/lib/json-import.d.mts +22 -0
- package/lib/cli/lib/json-import.mjs +422 -0
- package/lib/cli/lib/site-import.d.mts +32 -0
- package/lib/cli/lib/site-import.mjs +456 -0
- package/lib/cli/lib/wordpress-rest.d.mts +25 -0
- package/lib/cli/lib/wordpress-rest.mjs +177 -0
- package/lib/cli/lib/wxr.d.mts +18 -0
- package/lib/cli/lib/wxr.mjs +307 -0
- package/lib/cli/lib/xml.d.mts +33 -0
- package/lib/cli/lib/xml.mjs +186 -0
- package/lib/cli/restore.d.mts +2 -0
- package/lib/cli/restore.mjs +98 -0
- package/lib/client/components/Alert.d.ts +7 -0
- package/lib/client/components/Alert.js +8 -0
- package/lib/client/components/Avatar.d.ts +15 -0
- package/lib/client/components/Avatar.js +10 -0
- package/lib/client/components/BackLink.d.ts +7 -0
- package/lib/client/components/BackLink.js +6 -0
- package/lib/client/components/Button.d.ts +7 -0
- package/lib/client/components/Button.js +12 -0
- package/lib/client/components/Card.d.ts +7 -0
- package/lib/client/components/Card.js +6 -0
- package/lib/client/components/CommentThread.d.ts +15 -0
- package/lib/client/components/CommentThread.js +101 -0
- package/lib/client/components/Empty.d.ts +6 -0
- package/lib/client/components/Empty.js +6 -0
- package/lib/client/components/Input.d.ts +6 -0
- package/lib/client/components/Input.js +6 -0
- package/lib/client/components/Link.d.ts +31 -0
- package/lib/client/components/Link.js +49 -0
- package/lib/client/components/Loading.d.ts +1 -0
- package/lib/client/components/Loading.js +6 -0
- package/lib/client/components/Logo.d.ts +5 -0
- package/lib/client/components/Logo.js +4 -0
- package/lib/client/components/MarkdownEditor.d.ts +41 -0
- package/lib/client/components/MarkdownEditor.js +156 -0
- package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
- package/lib/client/components/Nav/DarkModeToggle.js +6 -0
- package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
- package/lib/client/components/Nav/DesktopNav.js +9 -0
- package/lib/client/components/Nav/MobileNav.d.ts +9 -0
- package/lib/client/components/Nav/MobileNav.js +15 -0
- package/lib/client/components/NavLink.d.ts +8 -0
- package/lib/client/components/NavLink.js +6 -0
- package/lib/client/components/PageHeader.d.ts +8 -0
- package/lib/client/components/PageHeader.js +6 -0
- package/lib/client/components/PostCard.d.ts +8 -0
- package/lib/client/components/PostCard.js +7 -0
- package/lib/client/components/Textarea.d.ts +6 -0
- package/lib/client/components/Textarea.js +6 -0
- package/lib/client/components/ThemeContext.d.ts +18 -0
- package/lib/client/components/ThemeContext.js +8 -0
- package/lib/client/components/admin/AdminIcons.d.ts +13 -0
- package/lib/client/components/admin/AdminIcons.js +66 -0
- package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
- package/lib/client/components/admin/ContentModelPanels.js +93 -0
- package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
- package/lib/client/components/admin/FeaturedImageBox.js +24 -0
- package/lib/client/components/admin/MediaGrid.d.ts +23 -0
- package/lib/client/components/admin/MediaGrid.js +69 -0
- package/lib/client/components/admin/MediaPicker.d.ts +17 -0
- package/lib/client/components/admin/MediaPicker.js +61 -0
- package/lib/client/components/admin/Pagination.d.ts +27 -0
- package/lib/client/components/admin/Pagination.js +29 -0
- package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
- package/lib/client/components/admin/SnippetPicker.js +65 -0
- package/lib/client/components/admin/TermPicker.d.ts +52 -0
- package/lib/client/components/admin/TermPicker.js +58 -0
- package/lib/client/contexts/ToastContext.d.ts +12 -0
- package/lib/client/contexts/ToastContext.js +49 -0
- package/lib/client/features.d.ts +11 -0
- package/lib/client/features.js +7 -0
- package/lib/client/hooks/useContentTypes.d.ts +48 -0
- package/lib/client/hooks/useContentTypes.js +48 -0
- package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
- package/lib/client/hooks/useMediaLibrary.js +189 -0
- package/lib/client/hooks/usePostLock.d.ts +32 -0
- package/lib/client/hooks/usePostLock.js +107 -0
- package/lib/client/host/index.d.ts +71 -0
- package/lib/client/host/index.js +58 -0
- package/lib/client/i18n/index.d.ts +79 -0
- package/lib/client/i18n/index.js +177 -0
- package/lib/client/i18n/locales/es/content.d.ts +4 -0
- package/lib/client/i18n/locales/es/content.js +220 -0
- package/lib/client/i18n/locales/es/editor.d.ts +9 -0
- package/lib/client/i18n/locales/es/editor.js +144 -0
- package/lib/client/i18n/locales/es/index.d.ts +8 -0
- package/lib/client/i18n/locales/es/index.js +7 -0
- package/lib/client/i18n/locales/es/layout.d.ts +4 -0
- package/lib/client/i18n/locales/es/layout.js +35 -0
- package/lib/client/i18n/locales/es/people.d.ts +4 -0
- package/lib/client/i18n/locales/es/people.js +187 -0
- package/lib/client/i18n/locales/es/site.d.ts +4 -0
- package/lib/client/i18n/locales/es/site.js +208 -0
- package/lib/client/layouts/AdminLayout.d.ts +7 -0
- package/lib/client/layouts/AdminLayout.js +1046 -0
- package/lib/client/layouts/AppLayout.d.ts +6 -0
- package/lib/client/layouts/AppLayout.js +19 -0
- package/lib/client/layouts/AuthLayout.d.ts +6 -0
- package/lib/client/layouts/AuthLayout.js +14 -0
- package/lib/client/layouts/DocsLayout.d.ts +6 -0
- package/lib/client/layouts/DocsLayout.js +28 -0
- package/lib/client/layouts/RootLayout.d.ts +6 -0
- package/lib/client/layouts/RootLayout.js +11 -0
- package/lib/client/pages/AcceptInvite.d.ts +8 -0
- package/lib/client/pages/AcceptInvite.js +60 -0
- package/lib/client/pages/Auth.d.ts +1 -0
- package/lib/client/pages/Auth.js +40 -0
- package/lib/client/pages/Authentication.d.ts +1 -0
- package/lib/client/pages/Authentication.js +230 -0
- package/lib/client/pages/Content.d.ts +1 -0
- package/lib/client/pages/Content.js +21 -0
- package/lib/client/pages/Database.d.ts +1 -0
- package/lib/client/pages/Database.js +264 -0
- package/lib/client/pages/Extending.d.ts +1 -0
- package/lib/client/pages/Extending.js +28 -0
- package/lib/client/pages/Feed.d.ts +1 -0
- package/lib/client/pages/Feed.js +19 -0
- package/lib/client/pages/FeedPost.d.ts +1 -0
- package/lib/client/pages/FeedPost.js +31 -0
- package/lib/client/pages/ForgotPassword.d.ts +8 -0
- package/lib/client/pages/ForgotPassword.js +38 -0
- package/lib/client/pages/GettingStarted.d.ts +1 -0
- package/lib/client/pages/GettingStarted.js +84 -0
- package/lib/client/pages/Headless.d.ts +1 -0
- package/lib/client/pages/Headless.js +49 -0
- package/lib/client/pages/Home.d.ts +1 -0
- package/lib/client/pages/Home.js +67 -0
- package/lib/client/pages/PostForm.d.ts +1 -0
- package/lib/client/pages/PostForm.js +55 -0
- package/lib/client/pages/Posts.d.ts +1 -0
- package/lib/client/pages/Posts.js +35 -0
- package/lib/client/pages/Profile.d.ts +1 -0
- package/lib/client/pages/Profile.js +153 -0
- package/lib/client/pages/ResetPassword.d.ts +8 -0
- package/lib/client/pages/ResetPassword.js +52 -0
- package/lib/client/pages/Routing.d.ts +1 -0
- package/lib/client/pages/Routing.js +192 -0
- package/lib/client/pages/Storage.d.ts +1 -0
- package/lib/client/pages/Storage.js +54 -0
- package/lib/client/pages/Testing.d.ts +1 -0
- package/lib/client/pages/Testing.js +141 -0
- package/lib/client/pages/Validation.d.ts +1 -0
- package/lib/client/pages/Validation.js +123 -0
- package/lib/client/pages/admin/Categories.d.ts +2 -0
- package/lib/client/pages/admin/Categories.js +75 -0
- package/lib/client/pages/admin/Comments.d.ts +11 -0
- package/lib/client/pages/admin/Comments.js +247 -0
- package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
- package/lib/client/pages/admin/ContentTypes.js +163 -0
- package/lib/client/pages/admin/Dashboard.d.ts +2 -0
- package/lib/client/pages/admin/Dashboard.js +66 -0
- package/lib/client/pages/admin/Health.d.ts +12 -0
- package/lib/client/pages/admin/Health.js +148 -0
- package/lib/client/pages/admin/Media.d.ts +2 -0
- package/lib/client/pages/admin/Media.js +101 -0
- package/lib/client/pages/admin/Navigation.d.ts +9 -0
- package/lib/client/pages/admin/Navigation.js +230 -0
- package/lib/client/pages/admin/Pages.d.ts +2 -0
- package/lib/client/pages/admin/Pages.js +53 -0
- package/lib/client/pages/admin/PostEditor.d.ts +17 -0
- package/lib/client/pages/admin/PostEditor.js +532 -0
- package/lib/client/pages/admin/Posts.d.ts +2 -0
- package/lib/client/pages/admin/Posts.js +152 -0
- package/lib/client/pages/admin/Redirects.d.ts +10 -0
- package/lib/client/pages/admin/Redirects.js +87 -0
- package/lib/client/pages/admin/Settings.d.ts +2 -0
- package/lib/client/pages/admin/Settings.js +111 -0
- package/lib/client/pages/admin/Snippets.d.ts +14 -0
- package/lib/client/pages/admin/Snippets.js +85 -0
- package/lib/client/pages/admin/Tags.d.ts +2 -0
- package/lib/client/pages/admin/Tags.js +74 -0
- package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
- package/lib/client/pages/admin/Taxonomies.js +130 -0
- package/lib/client/pages/admin/Tokens.d.ts +9 -0
- package/lib/client/pages/admin/Tokens.js +260 -0
- package/lib/client/pages/admin/Tools.d.ts +12 -0
- package/lib/client/pages/admin/Tools.js +111 -0
- package/lib/client/pages/admin/Users.d.ts +13 -0
- package/lib/client/pages/admin/Users.js +313 -0
- package/lib/client/pages/api-reference.d.ts +33 -0
- package/lib/client/pages/api-reference.js +198 -0
- package/lib/client/styles.css +37 -0
- package/lib/config.d.ts +24 -0
- package/lib/config.js +39 -0
- package/lib/controllers/AdminController.d.ts +46 -0
- package/lib/controllers/AdminController.js +134 -0
- package/lib/controllers/AuthController.d.ts +15 -0
- package/lib/controllers/AuthController.js +194 -0
- package/lib/controllers/AuthorController.d.ts +17 -0
- package/lib/controllers/AuthorController.js +19 -0
- package/lib/controllers/CategoryController.d.ts +10 -0
- package/lib/controllers/CategoryController.js +88 -0
- package/lib/controllers/CommentController.d.ts +68 -0
- package/lib/controllers/CommentController.js +438 -0
- package/lib/controllers/ContentTypeController.d.ts +24 -0
- package/lib/controllers/ContentTypeController.js +91 -0
- package/lib/controllers/EmailVerificationController.d.ts +33 -0
- package/lib/controllers/EmailVerificationController.js +116 -0
- package/lib/controllers/ExportController.d.ts +15 -0
- package/lib/controllers/ExportController.js +41 -0
- package/lib/controllers/FeedController.d.ts +14 -0
- package/lib/controllers/FeedController.js +246 -0
- package/lib/controllers/HealthController.d.ts +21 -0
- package/lib/controllers/HealthController.js +176 -0
- package/lib/controllers/HomeController.d.ts +12 -0
- package/lib/controllers/HomeController.js +16 -0
- package/lib/controllers/MediaController.d.ts +24 -0
- package/lib/controllers/MediaController.js +189 -0
- package/lib/controllers/NavigationController.d.ts +22 -0
- package/lib/controllers/NavigationController.js +176 -0
- package/lib/controllers/PageController.d.ts +13 -0
- package/lib/controllers/PageController.js +172 -0
- package/lib/controllers/PasskeyController.d.ts +36 -0
- package/lib/controllers/PasskeyController.js +201 -0
- package/lib/controllers/PasswordResetController.d.ts +44 -0
- package/lib/controllers/PasswordResetController.js +160 -0
- package/lib/controllers/PostController.d.ts +51 -0
- package/lib/controllers/PostController.js +538 -0
- package/lib/controllers/PostLockController.d.ts +62 -0
- package/lib/controllers/PostLockController.js +101 -0
- package/lib/controllers/ProfileController.d.ts +13 -0
- package/lib/controllers/ProfileController.js +160 -0
- package/lib/controllers/PublicApiController.d.ts +23 -0
- package/lib/controllers/PublicApiController.js +100 -0
- package/lib/controllers/RedirectController.d.ts +32 -0
- package/lib/controllers/RedirectController.js +95 -0
- package/lib/controllers/SettingsController.d.ts +28 -0
- package/lib/controllers/SettingsController.js +105 -0
- package/lib/controllers/SnippetController.d.ts +27 -0
- package/lib/controllers/SnippetController.js +123 -0
- package/lib/controllers/TagController.d.ts +9 -0
- package/lib/controllers/TagController.js +70 -0
- package/lib/controllers/TaxonomyController.d.ts +24 -0
- package/lib/controllers/TaxonomyController.js +149 -0
- package/lib/controllers/TokenController.d.ts +27 -0
- package/lib/controllers/TokenController.js +83 -0
- package/lib/controllers/TwoFactorController.d.ts +31 -0
- package/lib/controllers/TwoFactorController.js +213 -0
- package/lib/controllers/UserController.d.ts +110 -0
- package/lib/controllers/UserController.js +504 -0
- package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
- package/lib/features/analytics/AnalyticsPage.js +123 -0
- package/lib/features/analytics/admin.d.ts +3 -0
- package/lib/features/analytics/admin.js +9 -0
- package/lib/features/analytics/controller.d.ts +19 -0
- package/lib/features/analytics/controller.js +79 -0
- package/lib/features/analytics/helpers.d.ts +84 -0
- package/lib/features/analytics/helpers.js +181 -0
- package/lib/features/analytics/i18n/es.d.ts +4 -0
- package/lib/features/analytics/i18n/es.js +31 -0
- package/lib/features/analytics/index.d.ts +28 -0
- package/lib/features/analytics/index.js +91 -0
- package/lib/features/analytics/manifest.d.ts +8 -0
- package/lib/features/analytics/manifest.js +18 -0
- package/lib/features/analytics/model.d.ts +130 -0
- package/lib/features/analytics/model.js +206 -0
- package/lib/features/members/Member.d.ts +93 -0
- package/lib/features/members/Member.js +194 -0
- package/lib/features/members/MemberAdminController.d.ts +60 -0
- package/lib/features/members/MemberAdminController.js +262 -0
- package/lib/features/members/MemberController.d.ts +88 -0
- package/lib/features/members/MemberController.js +250 -0
- package/lib/features/members/MembersPage.d.ts +10 -0
- package/lib/features/members/MembersPage.js +216 -0
- package/lib/features/members/PostAccessBox.d.ts +15 -0
- package/lib/features/members/PostAccessBox.js +70 -0
- package/lib/features/members/admin.d.ts +3 -0
- package/lib/features/members/admin.js +12 -0
- package/lib/features/members/csv.d.ts +21 -0
- package/lib/features/members/csv.js +74 -0
- package/lib/features/members/events.d.ts +34 -0
- package/lib/features/members/events.js +34 -0
- package/lib/features/members/i18n/es.d.ts +4 -0
- package/lib/features/members/i18n/es.js +106 -0
- package/lib/features/members/index.d.ts +44 -0
- package/lib/features/members/index.js +106 -0
- package/lib/features/members/manifest.d.ts +8 -0
- package/lib/features/members/manifest.js +18 -0
- package/lib/features/members/middleware.d.ts +42 -0
- package/lib/features/members/middleware.js +74 -0
- package/lib/features/members/newsletter.d.ts +177 -0
- package/lib/features/members/newsletter.js +439 -0
- package/lib/features/members/rate-limits.d.ts +34 -0
- package/lib/features/members/rate-limits.js +50 -0
- package/lib/features/members/request.d.ts +13 -0
- package/lib/features/members/request.js +6 -0
- package/lib/features/members/routes.d.ts +15 -0
- package/lib/features/members/routes.js +59 -0
- package/lib/features/members/session.d.ts +102 -0
- package/lib/features/members/session.js +158 -0
- package/lib/features/members/settings.d.ts +14 -0
- package/lib/features/members/settings.js +23 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
- package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
- package/lib/features/mysendbox/admin.d.ts +3 -0
- package/lib/features/mysendbox/admin.js +9 -0
- package/lib/features/mysendbox/broadcasts.d.ts +61 -0
- package/lib/features/mysendbox/broadcasts.js +124 -0
- package/lib/features/mysendbox/client.d.ts +95 -0
- package/lib/features/mysendbox/client.js +61 -0
- package/lib/features/mysendbox/config.d.ts +27 -0
- package/lib/features/mysendbox/config.js +74 -0
- package/lib/features/mysendbox/contacts.d.ts +121 -0
- package/lib/features/mysendbox/contacts.js +378 -0
- package/lib/features/mysendbox/controller.d.ts +11 -0
- package/lib/features/mysendbox/controller.js +47 -0
- package/lib/features/mysendbox/i18n/es.d.ts +4 -0
- package/lib/features/mysendbox/i18n/es.js +28 -0
- package/lib/features/mysendbox/index.d.ts +18 -0
- package/lib/features/mysendbox/index.js +71 -0
- package/lib/features/mysendbox/manifest.d.ts +7 -0
- package/lib/features/mysendbox/manifest.js +6 -0
- package/lib/features/mysendbox/routes.d.ts +6 -0
- package/lib/features/mysendbox/routes.js +14 -0
- package/lib/features/mysendbox/webhook.d.ts +23 -0
- package/lib/features/mysendbox/webhook.js +104 -0
- package/lib/features/theme/OEmbedController.d.ts +31 -0
- package/lib/features/theme/OEmbedController.js +128 -0
- package/lib/features/theme/ThemeController.d.ts +20 -0
- package/lib/features/theme/ThemeController.js +256 -0
- package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
- package/lib/features/theme/ThemeSettingsCard.js +12 -0
- package/lib/features/theme/admin.d.ts +3 -0
- package/lib/features/theme/admin.js +9 -0
- package/lib/features/theme/html.d.ts +48 -0
- package/lib/features/theme/html.js +97 -0
- package/lib/features/theme/i18n/es.d.ts +4 -0
- package/lib/features/theme/i18n/es.js +9 -0
- package/lib/features/theme/index.d.ts +11 -0
- package/lib/features/theme/index.js +23 -0
- package/lib/features/theme/manifest.d.ts +7 -0
- package/lib/features/theme/manifest.js +6 -0
- package/lib/features/theme/oembed.d.ts +36 -0
- package/lib/features/theme/oembed.js +58 -0
- package/lib/features/theme/routes.d.ts +17 -0
- package/lib/features/theme/routes.js +54 -0
- package/lib/features/theme/templates.d.ts +103 -0
- package/lib/features/theme/templates.js +283 -0
- package/lib/features.d.ts +15 -0
- package/lib/features.js +6 -0
- package/lib/features.manifest.d.ts +10 -0
- package/lib/features.manifest.js +6 -0
- package/lib/helpers/access.d.ts +62 -0
- package/lib/helpers/access.js +92 -0
- package/lib/helpers/api.d.ts +20 -0
- package/lib/helpers/api.js +44 -0
- package/lib/helpers/comment-guard.d.ts +145 -0
- package/lib/helpers/comment-guard.js +253 -0
- package/lib/helpers/comment-mail.d.ts +53 -0
- package/lib/helpers/comment-mail.js +188 -0
- package/lib/helpers/content-model.d.ts +50 -0
- package/lib/helpers/content-model.js +84 -0
- package/lib/helpers/content-paths.d.ts +107 -0
- package/lib/helpers/content-paths.js +200 -0
- package/lib/helpers/export-data.d.ts +85 -0
- package/lib/helpers/export-data.js +229 -0
- package/lib/helpers/gating.d.ts +53 -0
- package/lib/helpers/gating.js +83 -0
- package/lib/helpers/health.d.ts +91 -0
- package/lib/helpers/health.js +279 -0
- package/lib/helpers/heartbeat.d.ts +35 -0
- package/lib/helpers/heartbeat.js +55 -0
- package/lib/helpers/image-size.d.ts +18 -0
- package/lib/helpers/image-size.js +83 -0
- package/lib/helpers/images.d.ts +29 -0
- package/lib/helpers/images.js +41 -0
- package/lib/helpers/mail-templates.d.ts +11 -0
- package/lib/helpers/mail-templates.js +42 -0
- package/lib/helpers/publish-due.d.ts +28 -0
- package/lib/helpers/publish-due.js +67 -0
- package/lib/helpers/redirects.d.ts +43 -0
- package/lib/helpers/redirects.js +80 -0
- package/lib/helpers/seo-fields.d.ts +13 -0
- package/lib/helpers/seo-fields.js +52 -0
- package/lib/helpers/session.d.ts +30 -0
- package/lib/helpers/session.js +27 -0
- package/lib/helpers/site-settings.d.ts +98 -0
- package/lib/helpers/site-settings.js +232 -0
- package/lib/helpers/site.d.ts +14 -0
- package/lib/helpers/site.js +23 -0
- package/lib/helpers/write-hooks.d.ts +33 -0
- package/lib/helpers/write-hooks.js +37 -0
- package/lib/hooks.d.ts +17 -0
- package/lib/hooks.js +101 -0
- package/lib/host/core-tasks.d.ts +4 -0
- package/lib/host/core-tasks.js +26 -0
- package/lib/host/cron.d.ts +39 -0
- package/lib/host/cron.js +85 -0
- package/lib/host/enabled.d.ts +4 -0
- package/lib/host/enabled.js +40 -0
- package/lib/host/index.d.ts +81 -0
- package/lib/host/index.js +87 -0
- package/lib/host/manifest.d.ts +34 -0
- package/lib/host/manifest.js +7 -0
- package/lib/host/menu.d.ts +18 -0
- package/lib/host/menu.js +15 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +24 -0
- package/lib/middleware/api-auth.d.ts +59 -0
- package/lib/middleware/api-auth.js +164 -0
- package/lib/middleware/auth.d.ts +49 -0
- package/lib/middleware/auth.js +112 -0
- package/lib/middleware/cache.d.ts +17 -0
- package/lib/middleware/cache.js +52 -0
- package/lib/middleware/rate-limits.d.ts +199 -0
- package/lib/middleware/rate-limits.js +276 -0
- package/lib/middleware/viewer.d.ts +13 -0
- package/lib/middleware/viewer.js +16 -0
- package/lib/models/Category.d.ts +24 -0
- package/lib/models/Category.js +102 -0
- package/lib/models/Comment.d.ts +120 -0
- package/lib/models/Comment.js +283 -0
- package/lib/models/ContentType.d.ts +142 -0
- package/lib/models/ContentType.js +462 -0
- package/lib/models/Credential.d.ts +21 -0
- package/lib/models/Credential.js +31 -0
- package/lib/models/Media.d.ts +53 -0
- package/lib/models/Media.js +132 -0
- package/lib/models/Menu.d.ts +131 -0
- package/lib/models/Menu.js +312 -0
- package/lib/models/Page.d.ts +55 -0
- package/lib/models/Page.js +218 -0
- package/lib/models/Post.d.ts +136 -0
- package/lib/models/Post.js +406 -0
- package/lib/models/PostLock.d.ts +67 -0
- package/lib/models/PostLock.js +112 -0
- package/lib/models/PostRevision.d.ts +45 -0
- package/lib/models/PostRevision.js +82 -0
- package/lib/models/PublicContent.d.ts +283 -0
- package/lib/models/PublicContent.js +577 -0
- package/lib/models/Redirect.d.ts +123 -0
- package/lib/models/Redirect.js +225 -0
- package/lib/models/Settings.d.ts +61 -0
- package/lib/models/Settings.js +128 -0
- package/lib/models/Snippet.d.ts +36 -0
- package/lib/models/Snippet.js +64 -0
- package/lib/models/Tag.d.ts +23 -0
- package/lib/models/Tag.js +117 -0
- package/lib/models/Taxonomy.d.ts +127 -0
- package/lib/models/Taxonomy.js +321 -0
- package/lib/models/TwoFactor.d.ts +26 -0
- package/lib/models/TwoFactor.js +60 -0
- package/lib/models/User.d.ts +49 -0
- package/lib/models/User.js +128 -0
- package/lib/models/derive.d.ts +69 -0
- package/lib/models/derive.js +81 -0
- package/lib/models/pagination.d.ts +30 -0
- package/lib/models/pagination.js +36 -0
- package/lib/models/visibility.d.ts +31 -0
- package/lib/models/visibility.js +47 -0
- package/lib/routes/App.d.ts +2 -0
- package/lib/routes/App.js +146 -0
- package/lib/routes/api/admin.d.ts +6 -0
- package/lib/routes/api/admin.js +11 -0
- package/lib/routes/api/auth.d.ts +6 -0
- package/lib/routes/api/auth.js +24 -0
- package/lib/routes/api/authors.d.ts +5 -0
- package/lib/routes/api/authors.js +8 -0
- package/lib/routes/api/categories.d.ts +8 -0
- package/lib/routes/api/categories.js +15 -0
- package/lib/routes/api/comments.d.ts +8 -0
- package/lib/routes/api/comments.js +35 -0
- package/lib/routes/api/content-model.d.ts +17 -0
- package/lib/routes/api/content-model.js +67 -0
- package/lib/routes/api/cron.d.ts +6 -0
- package/lib/routes/api/cron.js +9 -0
- package/lib/routes/api/export.d.ts +5 -0
- package/lib/routes/api/export.js +11 -0
- package/lib/routes/api/feed.d.ts +5 -0
- package/lib/routes/api/feed.js +16 -0
- package/lib/routes/api/media.d.ts +8 -0
- package/lib/routes/api/media.js +25 -0
- package/lib/routes/api/navigation.d.ts +12 -0
- package/lib/routes/api/navigation.js +17 -0
- package/lib/routes/api/ops.d.ts +9 -0
- package/lib/routes/api/ops.js +19 -0
- package/lib/routes/api/pages.d.ts +8 -0
- package/lib/routes/api/pages.js +21 -0
- package/lib/routes/api/passkeys.d.ts +7 -0
- package/lib/routes/api/passkeys.js +13 -0
- package/lib/routes/api/posts.d.ts +8 -0
- package/lib/routes/api/posts.js +39 -0
- package/lib/routes/api/profile.d.ts +6 -0
- package/lib/routes/api/profile.js +8 -0
- package/lib/routes/api/redirects.d.ts +12 -0
- package/lib/routes/api/redirects.js +13 -0
- package/lib/routes/api/settings.d.ts +8 -0
- package/lib/routes/api/settings.js +15 -0
- package/lib/routes/api/snippets.d.ts +15 -0
- package/lib/routes/api/snippets.js +16 -0
- package/lib/routes/api/tags.d.ts +8 -0
- package/lib/routes/api/tags.js +14 -0
- package/lib/routes/api/tokens.d.ts +7 -0
- package/lib/routes/api/tokens.js +15 -0
- package/lib/routes/api/two-factor.d.ts +7 -0
- package/lib/routes/api/two-factor.js +15 -0
- package/lib/routes/api/users.d.ts +8 -0
- package/lib/routes/api/users.js +25 -0
- package/lib/routes/api/v1.d.ts +12 -0
- package/lib/routes/api/v1.js +55 -0
- package/lib/routes/api/verification.d.ts +6 -0
- package/lib/routes/api/verification.js +11 -0
- package/lib/server/index.d.ts +24 -0
- package/lib/server/index.js +110 -0
- package/lib/types/index.d.ts +298 -0
- package/lib/types/index.js +1 -0
- package/lib/vite.d.ts +2 -0
- package/lib/vite.js +101 -0
- package/mail/comment-moderation.html +27 -0
- package/mail/comment-moderation.txt +13 -0
- package/mail/comment-reply.html +28 -0
- package/mail/comment-reply.txt +14 -0
- package/mail/invitation.html +25 -0
- package/mail/invitation.txt +11 -0
- package/mail/member-magic-link.html +23 -0
- package/mail/member-magic-link.txt +10 -0
- package/mail/newsletter.html +26 -0
- package/mail/newsletter.txt +13 -0
- package/mail/password-reset.html +26 -0
- package/mail/password-reset.txt +10 -0
- package/mail/verify-email.html +25 -0
- package/mail/verify-email.txt +8 -0
- package/package.json +85 -4
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { strongEtag, conditional } from '@basicbenframework/core/etag';
|
|
4
|
+
import { PublicContent } from "../../models/PublicContent.js";
|
|
5
|
+
import { Settings } from "../../models/Settings.js";
|
|
6
|
+
import { ContentType } from "../../models/ContentType.js";
|
|
7
|
+
import { Taxonomy } from "../../models/Taxonomy.js";
|
|
8
|
+
import { Menu } from "../../models/Menu.js";
|
|
9
|
+
import { Redirect } from "../../models/Redirect.js";
|
|
10
|
+
import { normalizeRedirectSource, RESERVED_ROUTE_SEGMENTS, POST_ROUTE_BASE } from "../../helpers/content-paths.js";
|
|
11
|
+
import { renderListing, renderEntry, renderPage, renderNotFound, pathOf } from "./templates.js";
|
|
12
|
+
/**
|
|
13
|
+
* The reference public site, rendered on the server.
|
|
14
|
+
*
|
|
15
|
+
* Off unless `PUBLIC_THEME=ssr` is set or the `public_theme` setting is `ssr`
|
|
16
|
+
* (`PUBLIC_THEME=off` forces it off whatever the setting says). While it is
|
|
17
|
+
* off, every route here answers exactly as the SPA fallback would, so
|
|
18
|
+
* registering the routes changes nothing for a site that has not opted in.
|
|
19
|
+
*
|
|
20
|
+
* Every read goes through `PublicContent` — the functions behind
|
|
21
|
+
* `/api/v1` — so what a visitor may see is decided in one place for the API
|
|
22
|
+
* and the theme alike.
|
|
23
|
+
*/
|
|
24
|
+
/** How long a shared cache may reuse a page: the content API's own figure. */
|
|
25
|
+
const MAX_AGE_SECONDS = 60;
|
|
26
|
+
/** How long a decision about whether the theme is on is reused, per instance. */
|
|
27
|
+
const ENABLED_TTL_MS = 30_000;
|
|
28
|
+
let enabledCache = null;
|
|
29
|
+
export async function themeEnabled() {
|
|
30
|
+
if (process.env.DISABLE_PUBLIC_SITE === 'true')
|
|
31
|
+
return false;
|
|
32
|
+
if (process.env.PUBLIC_THEME === 'ssr')
|
|
33
|
+
return true;
|
|
34
|
+
if (process.env.PUBLIC_THEME === 'off')
|
|
35
|
+
return false;
|
|
36
|
+
if (enabledCache && Date.now() - enabledCache.at < ENABLED_TTL_MS)
|
|
37
|
+
return enabledCache.value;
|
|
38
|
+
let value = false;
|
|
39
|
+
try {
|
|
40
|
+
value = (await Settings.get('public_theme')) === 'ssr';
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
value = false;
|
|
44
|
+
}
|
|
45
|
+
enabledCache = { value, at: Date.now() };
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
/** For tests and for the settings screen: forget the cached decision. */
|
|
49
|
+
export function resetThemeCache() {
|
|
50
|
+
enabledCache = null;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* First segments the SPA owns. A request for one of these is never the
|
|
54
|
+
* theme's, even with the theme on: `/login`, `/admin/...` and friends go to
|
|
55
|
+
* the app shell exactly as before.
|
|
56
|
+
*/
|
|
57
|
+
const SPA_SEGMENTS = new Set([
|
|
58
|
+
'admin', 'login', 'register', 'logout', 'forgot-password', 'reset-password', 'invite',
|
|
59
|
+
'profile', 'posts', 'docs', 'feed'
|
|
60
|
+
]);
|
|
61
|
+
/** The SPA's index.html, as the framework's own fallback would serve it. */
|
|
62
|
+
function sendAppShell(req, res) {
|
|
63
|
+
// The framework's fallback answers these with a JSON 404 rather than the
|
|
64
|
+
// shell — an API path or a missing asset must not receive HTML — so these
|
|
65
|
+
// routes, which can match them, must too.
|
|
66
|
+
const path = req.path || '/';
|
|
67
|
+
if (path.startsWith('/api/') || /\.(?!html?$)[a-z0-9]+$/i.test(path))
|
|
68
|
+
return res.json({ error: 'Not Found' }, 404);
|
|
69
|
+
const dir = process.env.NODE_ENV === 'production' ? 'dist/client' : 'public';
|
|
70
|
+
const index = join(resolve(process.cwd(), dir), 'index.html');
|
|
71
|
+
const raw = res;
|
|
72
|
+
try {
|
|
73
|
+
if (!statSync(index).isFile())
|
|
74
|
+
throw new Error('no shell');
|
|
75
|
+
raw.statusCode = 200;
|
|
76
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
77
|
+
// Same rule as the framework: the shell names hashed assets, so it must
|
|
78
|
+
// never be served stale.
|
|
79
|
+
res.setHeader('Cache-Control', 'no-cache');
|
|
80
|
+
raw.end(req.method === 'HEAD' ? undefined : readFileSync(index, 'utf-8'));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
res.json({ error: 'Not Found' }, 404);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/** Send a rendered page with an ETag, as `cacheable` does for JSON. */
|
|
87
|
+
function sendHtml(req, res, body, status = 200) {
|
|
88
|
+
const raw = res;
|
|
89
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
90
|
+
// Anonymous and identical for every visitor, so a CDN may share it. A 404
|
|
91
|
+
// is cached briefly too — a typo'd URL hammered by a crawler should not
|
|
92
|
+
// reach the database each time — but without an ETag, as cache.ts does.
|
|
93
|
+
res.setHeader('Vary', 'Accept-Encoding');
|
|
94
|
+
if (status === 200) {
|
|
95
|
+
if (conditional(req, res, { etag: strongEtag(body), cacheControl: `public, max-age=${MAX_AGE_SECONDS}` }))
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
res.setHeader('Cache-Control', `public, max-age=${MAX_AGE_SECONDS}`);
|
|
100
|
+
}
|
|
101
|
+
raw.statusCode = status;
|
|
102
|
+
raw.end(req.method === 'HEAD' ? undefined : body);
|
|
103
|
+
}
|
|
104
|
+
async function context(req) {
|
|
105
|
+
const [site, types, menus] = await Promise.all([
|
|
106
|
+
Settings.siteInfo(),
|
|
107
|
+
ContentType.all(),
|
|
108
|
+
Menu.publicNavigation('primary').catch(() => ({}))
|
|
109
|
+
]);
|
|
110
|
+
return {
|
|
111
|
+
site,
|
|
112
|
+
path: req.path || '/',
|
|
113
|
+
types,
|
|
114
|
+
menu: menus.primary ?? []
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function pageNumber(req) {
|
|
118
|
+
const fromPath = Number(req.params.page);
|
|
119
|
+
const fromQuery = Number(req.query.page);
|
|
120
|
+
const page = Number.isInteger(fromPath) && fromPath > 0 ? fromPath : fromQuery;
|
|
121
|
+
return Number.isInteger(page) && page > 0 ? Math.min(page, 10_000) : 1;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Nothing matched: apply the redirects table, then render the 404.
|
|
125
|
+
*
|
|
126
|
+
* The CMS has always kept redirects for a front end to apply; with the theme
|
|
127
|
+
* on, this is that front end. Checked only on a miss, so a live post can never
|
|
128
|
+
* be shadowed by a stale rule (Redirect.releasePath also guarantees that).
|
|
129
|
+
*/
|
|
130
|
+
async function notFound(req, res, ctx) {
|
|
131
|
+
const path = normalizeRedirectSource(req.path || '/');
|
|
132
|
+
if (path) {
|
|
133
|
+
const match = await Redirect.lookup(path);
|
|
134
|
+
if (match) {
|
|
135
|
+
await Redirect.hit(match.id);
|
|
136
|
+
res.setHeader('Cache-Control', `public, max-age=${MAX_AGE_SECONDS}`);
|
|
137
|
+
return res.redirect(match.to_path, Number(match.status) === 302 ? 302 : 301);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
sendHtml(req, res, renderNotFound(ctx ?? (await context(req))), 404);
|
|
141
|
+
}
|
|
142
|
+
async function listing(req, res, options, ctx, extra = {}) {
|
|
143
|
+
const page = pageNumber(req);
|
|
144
|
+
const perPage = await Settings.getPostsPerPage();
|
|
145
|
+
const { posts, total } = await PublicContent.posts({
|
|
146
|
+
perPage,
|
|
147
|
+
offset: (page - 1) * perPage,
|
|
148
|
+
type: options.type ?? 'post',
|
|
149
|
+
category: options.category,
|
|
150
|
+
tag: options.tag,
|
|
151
|
+
author: options.author,
|
|
152
|
+
taxonomy: options.taxonomy
|
|
153
|
+
});
|
|
154
|
+
const totalPages = Math.max(1, Math.ceil(total / perPage));
|
|
155
|
+
// Past the last page is a 404, not an empty listing: a crawler following
|
|
156
|
+
// `?page=` forever should be told to stop.
|
|
157
|
+
if (page > totalPages)
|
|
158
|
+
return notFound(req, res, ctx);
|
|
159
|
+
sendHtml(req, res, renderListing(ctx, { ...options, posts, page, totalPages, author: extra.author }));
|
|
160
|
+
}
|
|
161
|
+
/** Render one entry, or 404 if it is not live — or not of this type. */
|
|
162
|
+
async function entry(req, res, type, slug, ctx) {
|
|
163
|
+
const post = await PublicContent.post(slug, 'html', { type: type.key });
|
|
164
|
+
if (!post)
|
|
165
|
+
return notFound(req, res, ctx);
|
|
166
|
+
// Reached by id, or by a path that is not its own: send it to its address
|
|
167
|
+
// so each entry has exactly one URL.
|
|
168
|
+
const own = pathOf(ctx, post);
|
|
169
|
+
if (own !== req.path)
|
|
170
|
+
return res.redirect(own, 301);
|
|
171
|
+
sendHtml(req, res, renderEntry(ctx, post));
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Gate every theme handler: off means the SPA, and an SPA path means the SPA
|
|
175
|
+
* whether the theme is on or not.
|
|
176
|
+
*/
|
|
177
|
+
function themed(handler) {
|
|
178
|
+
return async (req, res) => {
|
|
179
|
+
const first = String((req.path || '/').split('/')[1] || '').toLowerCase();
|
|
180
|
+
if (!(await themeEnabled()) || SPA_SEGMENTS.has(first))
|
|
181
|
+
return sendAppShell(req, res);
|
|
182
|
+
await handler(req, res, await context(req));
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export const ThemeController = {
|
|
186
|
+
home: themed(async (req, res, ctx) => {
|
|
187
|
+
await listing(req, res, { title: ctx.site.name, intro: ctx.site.description, basePath: '/', heading: false }, ctx);
|
|
188
|
+
}),
|
|
189
|
+
/** `/blog/:slug` — a blog post. */
|
|
190
|
+
post: themed(async (req, res, ctx) => {
|
|
191
|
+
const type = ctx.types.find((candidate) => candidate.key === 'post');
|
|
192
|
+
await entry(req, res, type, req.params.slug, ctx);
|
|
193
|
+
}),
|
|
194
|
+
/** `/:segment` — a type's archive if a type lives there, otherwise a page. */
|
|
195
|
+
single: themed(async (req, res, ctx) => {
|
|
196
|
+
const segment = req.params.slug;
|
|
197
|
+
if (`/${segment}` === POST_ROUTE_BASE)
|
|
198
|
+
return res.redirect('/', 301);
|
|
199
|
+
const type = ctx.types.find((candidate) => !candidate.builtin && candidate.public && candidate.route_base === `/${segment}`);
|
|
200
|
+
if (type) {
|
|
201
|
+
return listing(req, res, { title: type.plural_label, intro: type.description, basePath: type.route_base, type: type.key }, ctx);
|
|
202
|
+
}
|
|
203
|
+
const page = await PublicContent.page(segment);
|
|
204
|
+
if (!page)
|
|
205
|
+
return notFound(req, res, ctx);
|
|
206
|
+
if (page.slug !== segment)
|
|
207
|
+
return res.redirect(`/${page.slug}`, 301);
|
|
208
|
+
sendHtml(req, res, renderPage(ctx, page));
|
|
209
|
+
}),
|
|
210
|
+
/** `/:base/:slug` — an entry of a custom type. Anything else two segments deep is the SPA's or a 404. */
|
|
211
|
+
typed: themed(async (req, res, ctx) => {
|
|
212
|
+
const type = ctx.types.find((candidate) => !candidate.builtin && candidate.public && candidate.route_base === `/${req.params.base}`);
|
|
213
|
+
if (!type) {
|
|
214
|
+
return RESERVED_ROUTE_SEGMENTS.includes(req.params.base) ? sendAppShell(req, res) : notFound(req, res, ctx);
|
|
215
|
+
}
|
|
216
|
+
await entry(req, res, type, req.params.slug, ctx);
|
|
217
|
+
}),
|
|
218
|
+
/** `/page/:page` — the home page, paginated the WordPress way. */
|
|
219
|
+
homePage: themed(async (req, res, ctx) => {
|
|
220
|
+
await listing(req, res, { title: ctx.site.name, intro: ctx.site.description, basePath: '/', heading: false }, ctx);
|
|
221
|
+
}),
|
|
222
|
+
category: themed(async (req, res, ctx) => {
|
|
223
|
+
const category = (await PublicContent.categories()).find((c) => c.slug === req.params.slug);
|
|
224
|
+
if (!category)
|
|
225
|
+
return notFound(req, res, ctx);
|
|
226
|
+
await listing(req, res, { title: category.name, intro: category.description, basePath: `/category/${category.slug}`, category: category.slug, type: 'any' }, ctx);
|
|
227
|
+
}),
|
|
228
|
+
tag: themed(async (req, res, ctx) => {
|
|
229
|
+
const tag = (await PublicContent.tags()).find((t) => t.slug === req.params.slug);
|
|
230
|
+
if (!tag)
|
|
231
|
+
return notFound(req, res, ctx);
|
|
232
|
+
await listing(req, res, { title: `Tagged “${tag.name}”`, basePath: `/tag/${tag.slug}`, tag: tag.slug, type: 'any' }, ctx);
|
|
233
|
+
}),
|
|
234
|
+
author: themed(async (req, res, ctx) => {
|
|
235
|
+
const author = await PublicContent.author(req.params.slug);
|
|
236
|
+
if (!author || !author.slug)
|
|
237
|
+
return notFound(req, res, ctx);
|
|
238
|
+
await listing(req, res, { title: author.name, intro: author.bio, basePath: `/author/${author.slug}`, author: author.slug, type: 'any' }, ctx, { author });
|
|
239
|
+
}),
|
|
240
|
+
/** `/taxonomy/:key/:slug` — a custom taxonomy term's archive. */
|
|
241
|
+
term: themed(async (req, res, ctx) => {
|
|
242
|
+
const taxonomy = await Taxonomy.findByKey(req.params.key);
|
|
243
|
+
if (!taxonomy || !taxonomy.public)
|
|
244
|
+
return notFound(req, res, ctx);
|
|
245
|
+
const term = await Taxonomy.findTermBySlug(taxonomy.id, req.params.slug);
|
|
246
|
+
if (!term)
|
|
247
|
+
return notFound(req, res, ctx);
|
|
248
|
+
await listing(req, res, {
|
|
249
|
+
title: `${taxonomy.singular_label}: ${term.name}`,
|
|
250
|
+
intro: term.description,
|
|
251
|
+
basePath: `/taxonomy/${taxonomy.key}/${term.slug}`,
|
|
252
|
+
taxonomy: { [taxonomy.key]: term.slug },
|
|
253
|
+
type: 'any'
|
|
254
|
+
}, ctx);
|
|
255
|
+
})
|
|
256
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SettingsSectionProps } from '../../client/host/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Whether this app renders the public site. Off by default, so a site using
|
|
4
|
+
* its own front end (or the SPA) sees no change; the PUBLIC_THEME environment
|
|
5
|
+
* variable overrides this either way.
|
|
6
|
+
*/
|
|
7
|
+
export default function ThemeSettingsCard({ values, onChange }: SettingsSectionProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useT } from "../../client/i18n/index.js";
|
|
3
|
+
const hint = { color: 'var(--fg-muted)', fontSize: '0.875rem', marginTop: '0.25rem' };
|
|
4
|
+
/**
|
|
5
|
+
* Whether this app renders the public site. Off by default, so a site using
|
|
6
|
+
* its own front end (or the SPA) sees no change; the PUBLIC_THEME environment
|
|
7
|
+
* variable overrides this either way.
|
|
8
|
+
*/
|
|
9
|
+
export default function ThemeSettingsCard({ values, onChange }) {
|
|
10
|
+
const { t } = useT();
|
|
11
|
+
return (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: t('Public site') }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "public_theme", children: t('Render the public site') }), _jsxs("select", { id: "public_theme", name: "public_theme", value: values.public_theme ?? '', onChange: e => onChange({ public_theme: e.target.value }), className: "admin-input", children: [_jsx("option", { value: "", children: t('No — a separate front end (or the built-in app) renders it') }), _jsx("option", { value: "ssr", children: t('Yes — with the built-in server-rendered theme') })] }), _jsx("p", { style: hint, children: t('Serves the home page, posts, pages, archives and custom content types as HTML from this app, with full SEO tags and oEmbed. Takes up to 30 seconds to apply.') })] })] }));
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference theme's only templating primitive: escape by default.
|
|
3
|
+
*
|
|
4
|
+
* Templates are tagged template literals. Every interpolated value is escaped
|
|
5
|
+
* unless it is already a `SafeHtml` — the result of another `html` template, or
|
|
6
|
+
* of `raw()`. So the safe thing is what happens when you write the obvious
|
|
7
|
+
* thing, and markup has to be asked for by name. `raw()` is used in exactly
|
|
8
|
+
* two kinds of place: `content_html`, which the framework's sanitizer produced
|
|
9
|
+
* at save time, and the admin's code injection, which is trusted by design
|
|
10
|
+
* (see helpers/site-settings.ts).
|
|
11
|
+
*
|
|
12
|
+
* No dependencies and no DOM, so tests import this directly.
|
|
13
|
+
*/
|
|
14
|
+
/** Escape text for an HTML text node or a quoted attribute value. */
|
|
15
|
+
export declare function escapeHtml(value: unknown): string;
|
|
16
|
+
/** Markup that is already safe to emit as-is. */
|
|
17
|
+
export declare class SafeHtml {
|
|
18
|
+
readonly value: string;
|
|
19
|
+
constructor(value: string);
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mark a string as trusted markup. The name is the warning: only for HTML
|
|
24
|
+
* that was sanitized on the way in, or that an administrator wrote on purpose.
|
|
25
|
+
*/
|
|
26
|
+
export declare function raw(value: string | null | undefined): SafeHtml;
|
|
27
|
+
/**
|
|
28
|
+
* Interpolations become text unless they are SafeHtml. Arrays are joined,
|
|
29
|
+
* each item following the same rule, so `${items.map(item => html`…`)}` works.
|
|
30
|
+
* `null`, `undefined` and `false` render nothing, so `${cond && html`…`}` does.
|
|
31
|
+
*/
|
|
32
|
+
export declare function html(strings: TemplateStringsArray, ...values: unknown[]): SafeHtml;
|
|
33
|
+
/**
|
|
34
|
+
* JSON for a `<script type="application/ld+json">` block.
|
|
35
|
+
*
|
|
36
|
+
* JSON.stringify does not escape `<`, so a title containing `</script>` would
|
|
37
|
+
* end the block and the rest would be parsed as markup. Escaping `<`, `>` and
|
|
38
|
+
* `&` as unicode escapes keeps it valid JSON and inert HTML; U+2028/2029 are
|
|
39
|
+
* escaped because some parsers still treat them as line terminators.
|
|
40
|
+
*/
|
|
41
|
+
export declare function jsonForScript(value: unknown): SafeHtml;
|
|
42
|
+
/**
|
|
43
|
+
* An href a template may emit: http(s), mailto, or a root-relative path.
|
|
44
|
+
* Anything else — `javascript:`, `data:` — becomes `#`. Defence in depth: the
|
|
45
|
+
* values that reach templates were validated on save, but a theme should not
|
|
46
|
+
* depend on every writer having been careful.
|
|
47
|
+
*/
|
|
48
|
+
export declare function safeHref(value: string | null | undefined): string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference theme's only templating primitive: escape by default.
|
|
3
|
+
*
|
|
4
|
+
* Templates are tagged template literals. Every interpolated value is escaped
|
|
5
|
+
* unless it is already a `SafeHtml` — the result of another `html` template, or
|
|
6
|
+
* of `raw()`. So the safe thing is what happens when you write the obvious
|
|
7
|
+
* thing, and markup has to be asked for by name. `raw()` is used in exactly
|
|
8
|
+
* two kinds of place: `content_html`, which the framework's sanitizer produced
|
|
9
|
+
* at save time, and the admin's code injection, which is trusted by design
|
|
10
|
+
* (see helpers/site-settings.ts).
|
|
11
|
+
*
|
|
12
|
+
* No dependencies and no DOM, so tests import this directly.
|
|
13
|
+
*/
|
|
14
|
+
const ESCAPES = {
|
|
15
|
+
'&': '&',
|
|
16
|
+
'<': '<',
|
|
17
|
+
'>': '>',
|
|
18
|
+
'"': '"',
|
|
19
|
+
"'": ''',
|
|
20
|
+
'`': '`'
|
|
21
|
+
};
|
|
22
|
+
/** Escape text for an HTML text node or a quoted attribute value. */
|
|
23
|
+
export function escapeHtml(value) {
|
|
24
|
+
return String(value ?? '').replace(/[&<>"'`]/g, (char) => ESCAPES[char]);
|
|
25
|
+
}
|
|
26
|
+
/** Markup that is already safe to emit as-is. */
|
|
27
|
+
export class SafeHtml {
|
|
28
|
+
// A plain field rather than a constructor parameter property: Node's type
|
|
29
|
+
// stripping (how tests load this file) only erases syntax, never rewrites it.
|
|
30
|
+
value;
|
|
31
|
+
constructor(value) {
|
|
32
|
+
this.value = value;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return this.value;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Mark a string as trusted markup. The name is the warning: only for HTML
|
|
40
|
+
* that was sanitized on the way in, or that an administrator wrote on purpose.
|
|
41
|
+
*/
|
|
42
|
+
export function raw(value) {
|
|
43
|
+
return new SafeHtml(value ?? '');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Interpolations become text unless they are SafeHtml. Arrays are joined,
|
|
47
|
+
* each item following the same rule, so `${items.map(item => html`…`)}` works.
|
|
48
|
+
* `null`, `undefined` and `false` render nothing, so `${cond && html`…`}` does.
|
|
49
|
+
*/
|
|
50
|
+
export function html(strings, ...values) {
|
|
51
|
+
let out = strings[0];
|
|
52
|
+
values.forEach((value, index) => {
|
|
53
|
+
out += render(value) + strings[index + 1];
|
|
54
|
+
});
|
|
55
|
+
return new SafeHtml(out);
|
|
56
|
+
}
|
|
57
|
+
function render(value) {
|
|
58
|
+
if (value === null || value === undefined || value === false)
|
|
59
|
+
return '';
|
|
60
|
+
if (value instanceof SafeHtml)
|
|
61
|
+
return value.value;
|
|
62
|
+
if (Array.isArray(value))
|
|
63
|
+
return value.map(render).join('');
|
|
64
|
+
return escapeHtml(value);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* JSON for a `<script type="application/ld+json">` block.
|
|
68
|
+
*
|
|
69
|
+
* JSON.stringify does not escape `<`, so a title containing `</script>` would
|
|
70
|
+
* end the block and the rest would be parsed as markup. Escaping `<`, `>` and
|
|
71
|
+
* `&` as unicode escapes keeps it valid JSON and inert HTML; U+2028/2029 are
|
|
72
|
+
* escaped because some parsers still treat them as line terminators.
|
|
73
|
+
*/
|
|
74
|
+
export function jsonForScript(value) {
|
|
75
|
+
return raw(JSON.stringify(value)
|
|
76
|
+
.replace(/</g, '\\u003c')
|
|
77
|
+
.replace(/>/g, '\\u003e')
|
|
78
|
+
.replace(/&/g, '\\u0026')
|
|
79
|
+
.replace(LINE_SEPARATORS, (char) => '\\u' + char.charCodeAt(0).toString(16)));
|
|
80
|
+
}
|
|
81
|
+
// Built from char codes: the raw characters in a source file are themselves
|
|
82
|
+
// line terminators to some tools.
|
|
83
|
+
const LINE_SEPARATORS = new RegExp('[' + String.fromCharCode(0x2028, 0x2029) + ']', 'g');
|
|
84
|
+
/**
|
|
85
|
+
* An href a template may emit: http(s), mailto, or a root-relative path.
|
|
86
|
+
* Anything else — `javascript:`, `data:` — becomes `#`. Defence in depth: the
|
|
87
|
+
* values that reach templates were validated on save, but a theme should not
|
|
88
|
+
* depend on every writer having been careful.
|
|
89
|
+
*/
|
|
90
|
+
export function safeHref(value) {
|
|
91
|
+
const url = String(value ?? '').trim();
|
|
92
|
+
if (/^(https?:\/\/|mailto:)/i.test(url))
|
|
93
|
+
return url;
|
|
94
|
+
if (url.startsWith('/') && !url.startsWith('//'))
|
|
95
|
+
return url;
|
|
96
|
+
return '#';
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Spanish for the theme feature. Merged over the admin's own dictionary. */
|
|
2
|
+
const strings = {
|
|
3
|
+
"Public site": "Sitio público",
|
|
4
|
+
"Render the public site": "Generar el sitio público",
|
|
5
|
+
"No — a separate front end (or the built-in app) renders it": "No — lo genera un front end aparte (o la aplicación integrada)",
|
|
6
|
+
"Yes — with the built-in server-rendered theme": "Sí — con el tema integrado generado en el servidor",
|
|
7
|
+
"Serves the home page, posts, pages, archives and custom content types as HTML from this app, with full SEO tags and oEmbed. Takes up to 30 seconds to apply.": "Sirve la página de inicio, las entradas, las páginas, los archivos y los tipos de contenido personalizados como HTML desde esta aplicación, con etiquetas SEO completas y oEmbed. Tarda hasta 30 segundos en aplicarse."
|
|
8
|
+
};
|
|
9
|
+
export default strings;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference public site: a server-rendered theme, and the oEmbed provider.
|
|
3
|
+
*
|
|
4
|
+
* Remove this folder and its lines in src/features.ts, src/client/features.ts
|
|
5
|
+
* and src/features.manifest.ts, and the core runs headless: the content API,
|
|
6
|
+
* feeds and sitemap are core and carry on. Listed last, because its `/:slug`
|
|
7
|
+
* and `/:base/:slug` routes would catch any route mounted after them.
|
|
8
|
+
*/
|
|
9
|
+
import type { Feature } from '../../host/index.ts';
|
|
10
|
+
declare const theme: Feature;
|
|
11
|
+
export default theme;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reference public site: a server-rendered theme, and the oEmbed provider.
|
|
3
|
+
*
|
|
4
|
+
* Remove this folder and its lines in src/features.ts, src/client/features.ts
|
|
5
|
+
* and src/features.manifest.ts, and the core runs headless: the content API,
|
|
6
|
+
* feeds and sitemap are core and carry on. Listed last, because its `/:slug`
|
|
7
|
+
* and `/:base/:slug` routes would catch any route mounted after them.
|
|
8
|
+
*/
|
|
9
|
+
import { checks } from "../../helpers/site-settings.js";
|
|
10
|
+
import { themeRoutes } from "./routes.js";
|
|
11
|
+
const theme = {
|
|
12
|
+
name: 'theme',
|
|
13
|
+
register(host) {
|
|
14
|
+
host.settings.define({
|
|
15
|
+
// Whether this app renders the public site itself (`ssr`) or leaves it
|
|
16
|
+
// to the SPA / a headless front end (blank). The PUBLIC_THEME
|
|
17
|
+
// environment variable, when set, wins: `ssr` or `off`.
|
|
18
|
+
public_theme: { group: 'reading', check: checks.oneOf(['', 'ssr']) }
|
|
19
|
+
});
|
|
20
|
+
host.routes(themeRoutes);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export default theme;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static facts about the theme feature. It has no admin page of its own (its
|
|
3
|
+
* one setting sits on the Settings page) and no tables.
|
|
4
|
+
*/
|
|
5
|
+
import type { FeatureManifest } from '../../host/manifest.ts';
|
|
6
|
+
declare const manifest: FeatureManifest;
|
|
7
|
+
export default manifest;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The oEmbed response body, from what the controller found.
|
|
3
|
+
*
|
|
4
|
+
* Pure — the size arithmetic and the card markup are the parts worth testing,
|
|
5
|
+
* and neither needs a database. See OEmbedController for the request side.
|
|
6
|
+
*/
|
|
7
|
+
export interface OEmbedTarget {
|
|
8
|
+
/** `rich` for posts and custom-type entries, `link` for pages. */
|
|
9
|
+
kind: 'rich' | 'link';
|
|
10
|
+
title: string;
|
|
11
|
+
description: string | null;
|
|
12
|
+
authorName: string | null;
|
|
13
|
+
/** Site-relative; made absolute against the provider URL. */
|
|
14
|
+
authorUrl: string | null;
|
|
15
|
+
thumbnail: {
|
|
16
|
+
url: string;
|
|
17
|
+
width: number | null;
|
|
18
|
+
height: number | null;
|
|
19
|
+
} | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Fit `width × height` inside the bounds, keeping the aspect ratio. Never
|
|
23
|
+
* scales up: a consumer that asks for at most 1200 wide has not asked for a
|
|
24
|
+
* 600-pixel image to be stretched.
|
|
25
|
+
*/
|
|
26
|
+
export declare function fit(width: number, height: number, maxWidth: number | null, maxHeight: number | null): {
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
};
|
|
30
|
+
export declare function resolveOEmbed(input: OEmbedTarget & {
|
|
31
|
+
url: string;
|
|
32
|
+
providerName: string;
|
|
33
|
+
providerUrl: string;
|
|
34
|
+
maxWidth: number | null;
|
|
35
|
+
maxHeight: number | null;
|
|
36
|
+
}): Record<string, unknown>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The oEmbed response body, from what the controller found.
|
|
3
|
+
*
|
|
4
|
+
* Pure — the size arithmetic and the card markup are the parts worth testing,
|
|
5
|
+
* and neither needs a database. See OEmbedController for the request side.
|
|
6
|
+
*/
|
|
7
|
+
import { html } from "./html.js";
|
|
8
|
+
/** The card's natural size, before a consumer's maxwidth/maxheight. */
|
|
9
|
+
const CARD_WIDTH = 600;
|
|
10
|
+
const CARD_HEIGHT = 200;
|
|
11
|
+
/** How long a consumer may keep the response, in seconds (oEmbed `cache_age`). */
|
|
12
|
+
const CACHE_AGE = 3600;
|
|
13
|
+
/**
|
|
14
|
+
* Fit `width × height` inside the bounds, keeping the aspect ratio. Never
|
|
15
|
+
* scales up: a consumer that asks for at most 1200 wide has not asked for a
|
|
16
|
+
* 600-pixel image to be stretched.
|
|
17
|
+
*/
|
|
18
|
+
export function fit(width, height, maxWidth, maxHeight) {
|
|
19
|
+
let scale = 1;
|
|
20
|
+
if (maxWidth && width > maxWidth)
|
|
21
|
+
scale = Math.min(scale, maxWidth / width);
|
|
22
|
+
if (maxHeight && height > maxHeight)
|
|
23
|
+
scale = Math.min(scale, maxHeight / height);
|
|
24
|
+
return { width: Math.max(1, Math.floor(width * scale)), height: Math.max(1, Math.floor(height * scale)) };
|
|
25
|
+
}
|
|
26
|
+
export function resolveOEmbed(input) {
|
|
27
|
+
const body = {
|
|
28
|
+
version: '1.0',
|
|
29
|
+
type: input.kind,
|
|
30
|
+
title: input.title,
|
|
31
|
+
provider_name: input.providerName,
|
|
32
|
+
provider_url: input.providerUrl,
|
|
33
|
+
cache_age: CACHE_AGE,
|
|
34
|
+
...(input.authorName ? { author_name: input.authorName } : {}),
|
|
35
|
+
...(input.authorUrl ? { author_url: `${input.providerUrl}${input.authorUrl}` } : {})
|
|
36
|
+
};
|
|
37
|
+
// A thumbnail is only offered when it can be shown to fit. The spec says
|
|
38
|
+
// the thumbnail must respect maxwidth/maxheight too, and an image of unknown
|
|
39
|
+
// size cannot be promised to.
|
|
40
|
+
const thumb = input.thumbnail;
|
|
41
|
+
if (thumb) {
|
|
42
|
+
if (thumb.width && thumb.height) {
|
|
43
|
+
const size = fit(thumb.width, thumb.height, input.maxWidth, input.maxHeight);
|
|
44
|
+
Object.assign(body, { thumbnail_url: thumb.url, thumbnail_width: size.width, thumbnail_height: size.height });
|
|
45
|
+
}
|
|
46
|
+
else if (!input.maxWidth && !input.maxHeight) {
|
|
47
|
+
body.thumbnail_url = thumb.url;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (input.kind === 'rich') {
|
|
51
|
+
const size = fit(CARD_WIDTH, CARD_HEIGHT, input.maxWidth, input.maxHeight);
|
|
52
|
+
// Every value escaped: this string is inserted into someone else's page
|
|
53
|
+
// as markup, and the title is whatever an author typed.
|
|
54
|
+
const card = html `<blockquote class="basicben-embed" style="max-width:${size.width}px;margin:0;padding:1em;border-left:4px solid #ccc"><p><a href="${input.url}">${input.title}</a></p>${input.description ? html `<p>${input.description}</p>` : ''}<p>— ${input.authorName ? html `${input.authorName}, ` : ''}<a href="${input.providerUrl}">${input.providerName}</a></p></blockquote>`;
|
|
55
|
+
Object.assign(body, { html: card.value, width: size.width, height: size.height });
|
|
56
|
+
}
|
|
57
|
+
return body;
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Router } from '../../host/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The reference public site (server-rendered theme) and the oEmbed provider.
|
|
4
|
+
*
|
|
5
|
+
* This feature goes **last** in src/features.ts, so these routes are mounted
|
|
6
|
+
* after core's and every other feature's. The router answers
|
|
7
|
+
* with the first route that matches, and `/:slug` and `/:base/:slug` match a
|
|
8
|
+
* great deal: registered last, `/api/...`, `/feed.xml`, `/sitemap.xml` and
|
|
9
|
+
* every other real route are matched before them. Static files are served by
|
|
10
|
+
* middleware that runs before any route, so assets are never shadowed either.
|
|
11
|
+
* Paths the SPA owns (`/admin`, `/login`, …) are handed the app shell by the
|
|
12
|
+
* controller, theme on or off.
|
|
13
|
+
*
|
|
14
|
+
* With DISABLE_PUBLIC_SITE nothing is registered, for the same reason the
|
|
15
|
+
* feeds are not: there is no public site to render or to embed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function themeRoutes(router: Router): void;
|