@cossackframework/cms 0.0.0-stage → 0.9.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 +21 -0
- package/README.md +147 -2
- package/agent-docs.json +259 -0
- package/app/README.md +78 -0
- package/app/cossack-recipe.json +43 -0
- package/app/src/auth-bot-check.ts +32 -0
- package/app/src/auth-bot-token.ts +11 -0
- package/app/src/auth-input.ts +35 -0
- package/app/src/auth-options.ts +18 -0
- package/app/src/auth-providers.ts +16 -0
- package/app/src/auth.ts +1082 -0
- package/app/src/brand.ts +68 -0
- package/app/src/cms/ai.ts +54 -0
- package/app/src/cms/analytics.ts +33 -0
- package/app/src/cms/block-errors.ts +55 -0
- package/app/src/cms/block-inserter.ts +111 -0
- package/app/src/cms/block-panel.ts +68 -0
- package/app/src/cms/block-rows.ts +44 -0
- package/app/src/cms/block-tree.ts +585 -0
- package/app/src/cms/blocks.css +708 -0
- package/app/src/cms/builder.ts +126 -0
- package/app/src/cms/cache.ts +44 -0
- package/app/src/cms/carousel.client.ts +52 -0
- package/app/src/cms/collab/presence.ts +69 -0
- package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
- package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
- package/app/src/cms/collab/room.ts +881 -0
- package/app/src/cms/compare.client.ts +47 -0
- package/app/src/cms/condition-control.ts +109 -0
- package/app/src/cms/content-api.ts +143 -0
- package/app/src/cms/content.ts +524 -0
- package/app/src/cms/countdown.client.ts +37 -0
- package/app/src/cms/editor-layout-editor.ts +260 -0
- package/app/src/cms/editor-layout-view.ts +37 -0
- package/app/src/cms/editor.ts +381 -0
- package/app/src/cms/entry.ts +26 -0
- package/app/src/cms/feeds.ts +145 -0
- package/app/src/cms/field-controls.ts +222 -0
- package/app/src/cms/field-group-editor.ts +105 -0
- package/app/src/cms/field-group-view.ts +211 -0
- package/app/src/cms/form-view.ts +203 -0
- package/app/src/cms/form.client.ts +203 -0
- package/app/src/cms/guards.ts +27 -0
- package/app/src/cms/handoff.ts +202 -0
- package/app/src/cms/headings.ts +51 -0
- package/app/src/cms/icons.ts +80 -0
- package/app/src/cms/import.client.ts +16 -0
- package/app/src/cms/index.ts +191 -0
- package/app/src/cms/lightbox.client.ts +109 -0
- package/app/src/cms/machine.ts +118 -0
- package/app/src/cms/maintenance.ts +97 -0
- package/app/src/cms/manage.ts +1236 -0
- package/app/src/cms/mcp-tools.ts +388 -0
- package/app/src/cms/mcp.ts +242 -0
- package/app/src/cms/media-chooser.ts +123 -0
- package/app/src/cms/media-usage.ts +57 -0
- package/app/src/cms/middleware.ts +199 -0
- package/app/src/cms/middlewares.ts +13 -0
- package/app/src/cms/network-ui.ts +36 -0
- package/app/src/cms/network-view.ts +38 -0
- package/app/src/cms/notes-announce.ts +65 -0
- package/app/src/cms/notes-rail.ts +207 -0
- package/app/src/cms/notification-rules.ts +66 -0
- package/app/src/cms/recovery.ts +82 -0
- package/app/src/cms/replace.ts +63 -0
- package/app/src/cms/reserved-paths.ts +19 -0
- package/app/src/cms/rich-text-field.ts +325 -0
- package/app/src/cms/rich-text-schema.ts +91 -0
- package/app/src/cms/rich-text.client.ts +255 -0
- package/app/src/cms/search.client.ts +116 -0
- package/app/src/cms/seo-head.ts +78 -0
- package/app/src/cms/seo.ts +241 -0
- package/app/src/cms/settings-draft.ts +218 -0
- package/app/src/cms/settings-file.ts +127 -0
- package/app/src/cms/settings-form.ts +180 -0
- package/app/src/cms/settings-languages.ts +125 -0
- package/app/src/cms/settings-nav.ts +102 -0
- package/app/src/cms/settings-network.ts +151 -0
- package/app/src/cms/settings-permalinks.ts +114 -0
- package/app/src/cms/settings-scroll.ts +10 -0
- package/app/src/cms/settings-search.ts +77 -0
- package/app/src/cms/settings-section.ts +38 -0
- package/app/src/cms/share.client.ts +27 -0
- package/app/src/cms/site-editing.ts +219 -0
- package/app/src/cms/site-editor.client.ts +1008 -0
- package/app/src/cms/site-editor.ts +99 -0
- package/app/src/cms/site-export.ts +60 -0
- package/app/src/cms/site-forms.ts +143 -0
- package/app/src/cms/site-import.ts +28 -0
- package/app/src/cms/site-session.ts +36 -0
- package/app/src/cms/site-taskbar.ts +77 -0
- package/app/src/cms/site-view.ts +1014 -0
- package/app/src/cms/site.ts +1322 -0
- package/app/src/cms/sitemaps.ts +131 -0
- package/app/src/cms/stat.client.ts +56 -0
- package/app/src/cms/style-controls.ts +252 -0
- package/app/src/cms/tabs.client.ts +36 -0
- package/app/src/cms/taskbar.ts +134 -0
- package/app/src/cms/term-icons.ts +10 -0
- package/app/src/cms/traffic.ts +26 -0
- package/app/src/cms/ui.ts +170 -0
- package/app/src/cms/updates.ts +124 -0
- package/app/src/cms/uploads.ts +26 -0
- package/app/src/cms/worker.ts +13 -0
- package/app/src/config/auth.ts +30 -0
- package/app/src/config/cms.ts +18 -0
- package/app/src/dashboard/access.ts +344 -0
- package/app/src/dashboard/agent-icons.ts +44 -0
- package/app/src/dashboard/app-passwords.ts +74 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +53 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +120 -0
- package/app/src/dashboard/modules/roles.ts +15 -0
- package/app/src/dashboard/modules/sessions.ts +15 -0
- package/app/src/dashboard/modules/settings.ts +15 -0
- package/app/src/dashboard/modules/users.ts +18 -0
- package/app/src/dashboard/page.ts +67 -0
- package/app/src/dashboard/registry.ts +13 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +26 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +40 -0
- package/app/src/dashboard/user-sections.ts +172 -0
- package/app/src/lib/permissions.ts +84 -0
- package/app/src/middlewares/auth.ts +117 -0
- package/app/src/pages/(site)/[...path]/index.ts +609 -0
- package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
- package/app/src/pages/(site)/feed/index.ts +12 -0
- package/app/src/pages/(site)/index.ts +11 -0
- package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
- package/app/src/pages/(site)/layout.ts +219 -0
- package/app/src/pages/(site)/llms.txt/index.ts +23 -0
- package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
- package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
- package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
- package/app/src/pages/(site)/robots.txt/index.ts +29 -0
- package/app/src/pages/(site)/search/index.ts +36 -0
- package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
- package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
- package/app/src/pages/api/auth/session.ts +48 -0
- package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
- package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
- package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
- package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
- package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
- package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
- package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
- package/app/src/pages/api/cms/cache/purge.ts +6 -0
- package/app/src/pages/api/cms/collections/index.ts +6 -0
- package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
- package/app/src/pages/api/cms/comments/[id].ts +9 -0
- package/app/src/pages/api/cms/comments/index.ts +126 -0
- package/app/src/pages/api/cms/comments/queue.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
- package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
- package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
- package/app/src/pages/api/cms/export/[collection].ts +37 -0
- package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
- package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
- package/app/src/pages/api/cms/import/[collection].ts +23 -0
- package/app/src/pages/api/cms/mcp.ts +29 -0
- package/app/src/pages/api/cms/me/index.ts +6 -0
- package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
- package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
- package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
- package/app/src/pages/api/cms/media/[id].ts +6 -0
- package/app/src/pages/api/cms/media.ts +26 -0
- package/app/src/pages/api/cms/menus/[location].ts +14 -0
- package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
- package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
- package/app/src/pages/api/cms/network/sites/index.ts +14 -0
- package/app/src/pages/api/cms/notes/[id].ts +13 -0
- package/app/src/pages/api/cms/notes/index.ts +6 -0
- package/app/src/pages/api/cms/payments/webhook.ts +28 -0
- package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
- package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
- package/app/src/pages/api/cms/plugins/index.ts +6 -0
- package/app/src/pages/api/cms/recovery.ts +29 -0
- package/app/src/pages/api/cms/redirects/index.ts +9 -0
- package/app/src/pages/api/cms/roles/index.ts +6 -0
- package/app/src/pages/api/cms/schema/[collection].ts +13 -0
- package/app/src/pages/api/cms/search.ts +16 -0
- package/app/src/pages/api/cms/settings/[group].ts +9 -0
- package/app/src/pages/api/cms/settings/index.ts +9 -0
- package/app/src/pages/api/cms/site-export.ts +34 -0
- package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
- package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
- package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
- package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
- package/app/src/pages/api/cms/uploads/index.ts +26 -0
- package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
- package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
- package/app/src/pages/api/cms/users/index.ts +12 -0
- package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
- package/app/src/pages/api/cms/webhooks/index.ts +9 -0
- package/app/src/pages/auth/[provider]/callback.ts +11 -0
- package/app/src/pages/auth/[provider]/redirect.ts +9 -0
- package/app/src/pages/auth/forgot-password/index.ts +75 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +198 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +117 -0
- package/app/src/pages/auth/reset-password/index.ts +65 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +67 -0
- package/app/src/pages/auth/verify/index.ts +62 -0
- package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
- package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
- package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
- package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
- package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
- package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
- package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
- package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
- package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
- package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
- package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
- package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
- package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
- package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
- package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
- package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
- package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
- package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
- package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
- package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
- package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
- package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
- package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
- package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
- package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
- package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
- package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
- package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
- package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
- package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
- package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
- package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
- package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
- package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
- package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
- package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
- package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
- package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
- package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
- package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
- package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
- package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
- package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
- package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
- package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
- package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
- package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
- package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +320 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +255 -0
- package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
- package/app/src/pages/dashboard/roles/index.ts +134 -0
- package/app/src/pages/dashboard/roles/new/index.ts +95 -0
- package/app/src/pages/dashboard/sessions/index.ts +105 -0
- package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
- package/app/src/pages/dashboard/users/index.ts +299 -0
- package/app/src/pages/dashboard/users/new/index.ts +123 -0
- package/app/src/passkeys.client.ts +18 -0
- package/app/src/plugins/default-theme/assets/cover.svg +31 -0
- package/app/src/plugins/default-theme/assets/logo.svg +8 -0
- package/app/src/plugins/default-theme/parts/comments.ts +66 -0
- package/app/src/plugins/default-theme/parts/list.ts +38 -0
- package/app/src/plugins/default-theme/parts/media.ts +15 -0
- package/app/src/plugins/default-theme/parts/options.ts +45 -0
- package/app/src/plugins/default-theme/plugin.json +275 -0
- package/app/src/plugins/default-theme/templates/archive.ts +14 -0
- package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
- package/app/src/plugins/default-theme/templates/entry.ts +27 -0
- package/app/src/plugins/default-theme/templates/home.ts +8 -0
- package/app/src/plugins/default-theme/templates/layout.ts +40 -0
- package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
- package/app/src/plugins/default-theme/templates/search.ts +32 -0
- package/app/src/services/rbac.ts +65 -0
- package/app/src/services/roles.ts +89 -0
- package/app/src/services/users.ts +173 -0
- package/package.json +123 -3
- package/src/automations.ts +95 -0
- package/src/bindings.ts +138 -0
- package/src/block-references.ts +239 -0
- package/src/block-shape.ts +155 -0
- package/src/blocks.ts +1157 -0
- package/src/cache.ts +54 -0
- package/src/checks.ts +198 -0
- package/src/cloudflare-workers.d.ts +13 -0
- package/src/cloudflare.ts +61 -0
- package/src/collab.ts +372 -0
- package/src/collections.ts +421 -0
- package/src/comments.ts +46 -0
- package/src/cron.ts +95 -0
- package/src/dashboard-menu.ts +105 -0
- package/src/diff.ts +113 -0
- package/src/editor-layout.ts +316 -0
- package/src/errors.ts +50 -0
- package/src/field-groups.ts +498 -0
- package/src/fields.ts +411 -0
- package/src/form-builder.ts +1053 -0
- package/src/forms.ts +109 -0
- package/src/highlight.ts +134 -0
- package/src/hooks.ts +510 -0
- package/src/icon-catalog.ts +55 -0
- package/src/icons.ts +128 -0
- package/src/images.ts +149 -0
- package/src/index.ts +100 -0
- package/src/isolate-core.ts +245 -0
- package/src/isolate.ts +19 -0
- package/src/isolation.ts +69 -0
- package/src/mail.ts +182 -0
- package/src/manifest.ts +476 -0
- package/src/media.ts +193 -0
- package/src/menus.ts +287 -0
- package/src/module.ts +32 -0
- package/src/modules/content.ts +64 -0
- package/src/modules/forms.ts +35 -0
- package/src/node.ts +66 -0
- package/src/notes.ts +237 -0
- package/src/permissions.ts +139 -0
- package/src/plugin-settings.ts +114 -0
- package/src/records.ts +56 -0
- package/src/redirects.ts +59 -0
- package/src/resource.ts +245 -0
- package/src/richtext.ts +402 -0
- package/src/schema-json.ts +112 -0
- package/src/search.ts +89 -0
- package/src/seo.ts +477 -0
- package/src/server/accounts.ts +418 -0
- package/src/server/ai.ts +33 -0
- package/src/server/api-tokens.ts +91 -0
- package/src/server/areas.ts +116 -0
- package/src/server/audit.ts +94 -0
- package/src/server/auth.ts +89 -0
- package/src/server/automations.ts +190 -0
- package/src/server/autosaves.ts +69 -0
- package/src/server/brand-icons.ts +50 -0
- package/src/server/brands.ts +86 -0
- package/src/server/budget.ts +97 -0
- package/src/server/cache.ts +104 -0
- package/src/server/capabilities.ts +333 -0
- package/src/server/cloudflare.ts +92 -0
- package/src/server/comments.ts +237 -0
- package/src/server/drafts.ts +176 -0
- package/src/server/field-groups.ts +88 -0
- package/src/server/files.ts +780 -0
- package/src/server/forms.ts +726 -0
- package/src/server/handoffs.ts +107 -0
- package/src/server/host-schema.ts +312 -0
- package/src/server/host.ts +2892 -0
- package/src/server/images.ts +34 -0
- package/src/server/index.ts +59 -0
- package/src/server/indexnow.ts +91 -0
- package/src/server/isolation.ts +183 -0
- package/src/server/locked.ts +45 -0
- package/src/server/mail.ts +93 -0
- package/src/server/markdown.ts +24 -0
- package/src/server/menus.ts +286 -0
- package/src/server/network-policy.ts +60 -0
- package/src/server/network.ts +665 -0
- package/src/server/notes.ts +275 -0
- package/src/server/outbox.ts +213 -0
- package/src/server/path-moves.ts +33 -0
- package/src/server/payments.ts +59 -0
- package/src/server/previews.ts +62 -0
- package/src/server/purge.ts +140 -0
- package/src/server/reconcile.ts +38 -0
- package/src/server/redirects.ts +183 -0
- package/src/server/repository.ts +1107 -0
- package/src/server/schedules.ts +105 -0
- package/src/server/schema.ts +562 -0
- package/src/server/security.ts +391 -0
- package/src/server/seed.ts +52 -0
- package/src/server/shared-fields.ts +34 -0
- package/src/server/site-export.ts +151 -0
- package/src/server/site-import.ts +482 -0
- package/src/server/site-search.ts +289 -0
- package/src/server/site-settings.ts +286 -0
- package/src/server/sites.ts +243 -0
- package/src/server/stores.ts +314 -0
- package/src/server/stripe.ts +173 -0
- package/src/server/taxonomies.ts +415 -0
- package/src/server/tokens.ts +25 -0
- package/src/server/traffic.ts +118 -0
- package/src/server/users.ts +653 -0
- package/src/server/webhooks.ts +245 -0
- package/src/settings-controls.ts +54 -0
- package/src/settings-document.ts +111 -0
- package/src/settings.ts +426 -0
- package/src/storage/cloudflare.ts +94 -0
- package/src/storage/index.ts +30 -0
- package/src/storage/node.ts +114 -0
- package/src/taxonomy.ts +51 -0
- package/src/theme.ts +1135 -0
- package/src/to-markdown.ts +179 -0
- package/src/updates.ts +126 -0
- package/src/version.ts +2 -0
- package/src/vite.d.ts +25 -0
- package/src/vite.js +199 -0
- package/src/webhooks.ts +107 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The theme's options as styles: accent color, the content measures and typography. */
|
|
2
|
+
import type { ThemeHelpers } from '@cossackframework/cms';
|
|
3
|
+
|
|
4
|
+
/** Accent colors as the UI kit's primary tokens, light and dark. */
|
|
5
|
+
const ACCENTS: Record<string, [string, string] | undefined> = {
|
|
6
|
+
blue: ['oklch(0.546 0.245 262.881)', 'oklch(0.985 0 0)'],
|
|
7
|
+
emerald: ['oklch(0.596 0.145 163.225)', 'oklch(0.985 0 0)'],
|
|
8
|
+
violet: ['oklch(0.541 0.281 293.009)', 'oklch(0.985 0 0)'],
|
|
9
|
+
rose: ['oklch(0.586 0.253 17.585)', 'oklch(0.985 0 0)'],
|
|
10
|
+
amber: ['oklch(0.769 0.188 70.08)', 'oklch(0.205 0 0)'],
|
|
11
|
+
};
|
|
12
|
+
/** The measures by width option: the content column, the wide measure and the gutter blocks keep from the edges (`cms-item`, `cms-measure`). */
|
|
13
|
+
const MEASURES: Record<string, string> = {
|
|
14
|
+
narrow: '--cms-content: 48rem; --cms-wide: 72rem; --cms-gutter: 1.5rem;',
|
|
15
|
+
wide: '--cms-content: 64rem; --cms-wide: 80rem; --cms-gutter: 1.5rem;',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const measureStyle = (helpers: ThemeHelpers) => MEASURES[String(helpers.options.width)] ?? MEASURES.narrow!;
|
|
19
|
+
|
|
20
|
+
export function accentStyle(helpers: ThemeHelpers): string {
|
|
21
|
+
const accent = ACCENTS[String(helpers.options.accent)];
|
|
22
|
+
return accent ? `--primary: ${accent[0]}; --primary-foreground: ${accent[1]}; --ring: ${accent[0]};` : '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Font stacks by option: system fonts, so nothing is downloaded. */
|
|
26
|
+
const FONTS: Record<string, string> = {
|
|
27
|
+
sans: 'ui-sans-serif, system-ui, sans-serif',
|
|
28
|
+
humanist: 'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", source-sans-pro, sans-serif',
|
|
29
|
+
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
30
|
+
mono: 'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',
|
|
31
|
+
};
|
|
32
|
+
const SIZES: Record<string, string> = { small: '15px', medium: '16px', large: '18px' };
|
|
33
|
+
const WEIGHTS: Record<string, string> = { normal: '400', medium: '500', semibold: '600', bold: '700' };
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The typography options as a stylesheet the layout embeds: the root font size (so rem-based
|
|
37
|
+
* sizes scale with it), the font stack, and the weight of every heading, which wins over
|
|
38
|
+
* the templates' weight classes.
|
|
39
|
+
*/
|
|
40
|
+
export function typographyCss(helpers: ThemeHelpers): string {
|
|
41
|
+
const font = FONTS[String(helpers.options.fontFamily)] ?? FONTS.sans!;
|
|
42
|
+
const size = SIZES[String(helpers.options.baseSize)] ?? SIZES.medium!;
|
|
43
|
+
const weight = WEIGHTS[String(helpers.options.headingWeight)] ?? WEIGHTS.bold!;
|
|
44
|
+
return `html { font-size: ${size}; } [data-theme="default-theme"] { font-family: ${font}; } [data-theme="default-theme"][data-theme] :is(h1, h2, h3, h4, h5, h6) { font-weight: ${weight}; }`;
|
|
45
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "default-theme",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "The default site theme of the Cossack CMS. Edit it, or copy it to start your own theme.",
|
|
6
|
+
"compatibility": {
|
|
7
|
+
"@cossackframework/cms": ">=0.9.0"
|
|
8
|
+
},
|
|
9
|
+
"logo": "assets/logo.svg",
|
|
10
|
+
"cover": "assets/cover.svg",
|
|
11
|
+
"fieldGroups": [
|
|
12
|
+
{
|
|
13
|
+
"id": "default-theme-menu",
|
|
14
|
+
"title": "Menu item details",
|
|
15
|
+
"description": "Shown with the link in a mega menu panel.",
|
|
16
|
+
"targets": [
|
|
17
|
+
{
|
|
18
|
+
"kind": "menus"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"blocks": [
|
|
22
|
+
{
|
|
23
|
+
"_id": "icon",
|
|
24
|
+
"type": "field/media",
|
|
25
|
+
"data": {
|
|
26
|
+
"name": "icon",
|
|
27
|
+
"label": "Icon",
|
|
28
|
+
"description": "A small image or SVG from the library, shown before the link."
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"_id": "badge",
|
|
33
|
+
"type": "field/text",
|
|
34
|
+
"data": {
|
|
35
|
+
"name": "badge",
|
|
36
|
+
"label": "Badge",
|
|
37
|
+
"max": 20,
|
|
38
|
+
"description": "A short word after the link, such as New."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"theme": {
|
|
45
|
+
"label": "Cossack Default",
|
|
46
|
+
"description": "A clean, readable theme: a header and footer built from blocks, a menu with dropdowns and mega panels, search and an accent color.",
|
|
47
|
+
"locations": {
|
|
48
|
+
"primary": "Primary menu",
|
|
49
|
+
"mobile": "Mobile menu",
|
|
50
|
+
"footer": "Footer menu"
|
|
51
|
+
},
|
|
52
|
+
"areas": {
|
|
53
|
+
"header": {
|
|
54
|
+
"label": "Header",
|
|
55
|
+
"blocks": [
|
|
56
|
+
{
|
|
57
|
+
"_id": "header-row",
|
|
58
|
+
"type": "core/group",
|
|
59
|
+
"data": {
|
|
60
|
+
"align": "full",
|
|
61
|
+
"direction": "row",
|
|
62
|
+
"justify": "between"
|
|
63
|
+
},
|
|
64
|
+
"children": [
|
|
65
|
+
{
|
|
66
|
+
"_id": "header-logo",
|
|
67
|
+
"type": "core/site-logo",
|
|
68
|
+
"data": {
|
|
69
|
+
"showTagline": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"_id": "header-tools",
|
|
74
|
+
"type": "core/group",
|
|
75
|
+
"data": {
|
|
76
|
+
"direction": "row",
|
|
77
|
+
"justify": "end"
|
|
78
|
+
},
|
|
79
|
+
"children": [
|
|
80
|
+
{
|
|
81
|
+
"_id": "header-menu",
|
|
82
|
+
"type": "core/navigation",
|
|
83
|
+
"data": {
|
|
84
|
+
"location": "primary",
|
|
85
|
+
"style": "dropdowns",
|
|
86
|
+
"mobile": "mobile"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"_id": "header-search",
|
|
91
|
+
"type": "core/search",
|
|
92
|
+
"data": {},
|
|
93
|
+
"layout": {
|
|
94
|
+
"hide": [
|
|
95
|
+
"sm"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"_id": "header-languages",
|
|
101
|
+
"type": "core/languages",
|
|
102
|
+
"data": {}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
],
|
|
107
|
+
"style": {
|
|
108
|
+
"padding": "medium"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
"footer": "Footer widgets",
|
|
114
|
+
"footer-bar": {
|
|
115
|
+
"label": "Footer bar",
|
|
116
|
+
"blocks": [
|
|
117
|
+
{
|
|
118
|
+
"_id": "footer-row",
|
|
119
|
+
"type": "core/group",
|
|
120
|
+
"data": {
|
|
121
|
+
"align": "full",
|
|
122
|
+
"direction": "row",
|
|
123
|
+
"justify": "between"
|
|
124
|
+
},
|
|
125
|
+
"children": [
|
|
126
|
+
{
|
|
127
|
+
"_id": "footer-menu",
|
|
128
|
+
"type": "core/navigation",
|
|
129
|
+
"data": {
|
|
130
|
+
"location": "footer",
|
|
131
|
+
"style": "inline"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"_id": "footer-languages",
|
|
136
|
+
"type": "core/languages",
|
|
137
|
+
"data": {}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"_id": "footer-text",
|
|
141
|
+
"type": "core/paragraph",
|
|
142
|
+
"data": {
|
|
143
|
+
"text": "© {{ $site.year }} {{ $site.title }} · [RSS](/feed) · [Log in](/auth/login)"
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"style": {
|
|
148
|
+
"padding": "medium"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"presets": {
|
|
155
|
+
"colors": [
|
|
156
|
+
{
|
|
157
|
+
"slug": "base",
|
|
158
|
+
"name": "Base",
|
|
159
|
+
"value": "#ffffff"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"slug": "contrast",
|
|
163
|
+
"name": "Contrast",
|
|
164
|
+
"value": "#111827"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"slug": "primary",
|
|
168
|
+
"name": "Primary",
|
|
169
|
+
"value": "#2563eb"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"slug": "secondary",
|
|
173
|
+
"name": "Secondary",
|
|
174
|
+
"value": "#f1f5f9"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"slug": "accent",
|
|
178
|
+
"name": "Accent",
|
|
179
|
+
"value": "#f59e0b"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"slug": "muted",
|
|
183
|
+
"name": "Muted",
|
|
184
|
+
"value": "#64748b"
|
|
185
|
+
}
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
"options": {
|
|
189
|
+
"accent": {
|
|
190
|
+
"kind": "enum",
|
|
191
|
+
"values": [
|
|
192
|
+
"neutral",
|
|
193
|
+
"blue",
|
|
194
|
+
"emerald",
|
|
195
|
+
"violet",
|
|
196
|
+
"rose",
|
|
197
|
+
"amber"
|
|
198
|
+
],
|
|
199
|
+
"default": "neutral",
|
|
200
|
+
"label": "Accent color",
|
|
201
|
+
"choices": {
|
|
202
|
+
"neutral": "Neutral",
|
|
203
|
+
"blue": "Blue",
|
|
204
|
+
"emerald": "Emerald",
|
|
205
|
+
"violet": "Violet",
|
|
206
|
+
"rose": "Rose",
|
|
207
|
+
"amber": "Amber"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
"width": {
|
|
211
|
+
"kind": "enum",
|
|
212
|
+
"values": [
|
|
213
|
+
"narrow",
|
|
214
|
+
"wide"
|
|
215
|
+
],
|
|
216
|
+
"default": "narrow",
|
|
217
|
+
"label": "Content width",
|
|
218
|
+
"choices": {
|
|
219
|
+
"narrow": "Narrow, best for reading",
|
|
220
|
+
"wide": "Wide"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"fontFamily": {
|
|
224
|
+
"kind": "enum",
|
|
225
|
+
"values": [
|
|
226
|
+
"sans",
|
|
227
|
+
"humanist",
|
|
228
|
+
"serif",
|
|
229
|
+
"mono"
|
|
230
|
+
],
|
|
231
|
+
"default": "sans",
|
|
232
|
+
"label": "Font",
|
|
233
|
+
"description": "System fonts: nothing to download.",
|
|
234
|
+
"choices": {
|
|
235
|
+
"sans": "Sans-serif",
|
|
236
|
+
"humanist": "Humanist sans-serif",
|
|
237
|
+
"serif": "Serif",
|
|
238
|
+
"mono": "Monospace"
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"baseSize": {
|
|
242
|
+
"kind": "enum",
|
|
243
|
+
"values": [
|
|
244
|
+
"small",
|
|
245
|
+
"medium",
|
|
246
|
+
"large"
|
|
247
|
+
],
|
|
248
|
+
"default": "medium",
|
|
249
|
+
"label": "Text size",
|
|
250
|
+
"choices": {
|
|
251
|
+
"small": "Small (15px)",
|
|
252
|
+
"medium": "Medium (16px)",
|
|
253
|
+
"large": "Large (18px)"
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"headingWeight": {
|
|
257
|
+
"kind": "enum",
|
|
258
|
+
"values": [
|
|
259
|
+
"normal",
|
|
260
|
+
"medium",
|
|
261
|
+
"semibold",
|
|
262
|
+
"bold"
|
|
263
|
+
],
|
|
264
|
+
"default": "bold",
|
|
265
|
+
"label": "Heading weight",
|
|
266
|
+
"choices": {
|
|
267
|
+
"normal": "Normal",
|
|
268
|
+
"medium": "Medium",
|
|
269
|
+
"semibold": "Semibold",
|
|
270
|
+
"bold": "Bold"
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A collection or term archive. Copy to archive-<collection>.ts, term.ts or term-<taxonomy>.ts for a narrower one. */
|
|
2
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
3
|
+
import type { ArchiveContext } from '@cossackframework/cms';
|
|
4
|
+
import { list } from '../parts/list';
|
|
5
|
+
|
|
6
|
+
export default function archive({ view }: ArchiveContext): TemplateResult {
|
|
7
|
+
return html`<div class="cms-measure space-y-10">
|
|
8
|
+
<header class="space-y-2 border-b border-border pb-6">
|
|
9
|
+
<h1 class="text-3xl font-bold text-foreground">${view.title}</h1>
|
|
10
|
+
${view.description ? html`<p class="text-muted-foreground">${view.description}</p>` : null}
|
|
11
|
+
</header>
|
|
12
|
+
${list(view, __('Nothing here yet.'))}
|
|
13
|
+
</div>`;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A blank canvas for landing and marketing pages: the entry's blocks and nothing else. The
|
|
3
|
+
* layout leaves out its header and footer for this template, so the content owns the page.
|
|
4
|
+
* Choose it under Template in the editor's sidebar.
|
|
5
|
+
*/
|
|
6
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
7
|
+
import type { EntryContext } from '@cossackframework/cms';
|
|
8
|
+
|
|
9
|
+
export default function entryBlank({ entry, helpers }: EntryContext): TemplateResult {
|
|
10
|
+
return html`<article class="cms-blank" data-template="entry-blank">
|
|
11
|
+
${helpers.layout(entry.content)}
|
|
12
|
+
</article>`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One entry: a post, a page or an entry of another collection. Copy to entry-<collection>.ts for
|
|
3
|
+
* one collection. Custom fields reach the page through the content's blocks (`{{ $.price }}` in a
|
|
4
|
+
* block's text, or a data block), never as a list of every field; `entry.fields` has them all.
|
|
5
|
+
*/
|
|
6
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
7
|
+
import type { EntryContext } from '@cossackframework/cms';
|
|
8
|
+
import { comments } from '../parts/comments';
|
|
9
|
+
import { image } from '../parts/media';
|
|
10
|
+
|
|
11
|
+
// The title, meta and image keep the content measure; the blocks are the page's constrained layout, so a full-width group spans the page.
|
|
12
|
+
export default function entry({ entry, helpers }: EntryContext): TemplateResult {
|
|
13
|
+
return html`<article class="space-y-6">
|
|
14
|
+
<header class="cms-measure space-y-3">
|
|
15
|
+
<h1 class="text-4xl font-bold tracking-tight text-foreground">${entry.title}</h1>
|
|
16
|
+
${entry.date || entry.authors.length ? html`<p class="text-sm text-muted-foreground">${entry.date ? html`<time>${entry.date}</time>` : null}${entry.readingTime ? html` · ${entry.readingTime} ${__('min read')}` : null}${entry.authors.length ? html` · ${entry.authors.map((author, index) => html`${index ? ', ' : ''}${author.url ? html`<a href=${author.url} rel="author" class="text-muted-foreground hover:text-primary">${author.name}</a>` : author.name}`)}` : null}${entry.updated && entry.updated !== entry.date ? html` · ${__('Updated')} <time>${entry.updated}</time>` : null}</p>` : null}
|
|
17
|
+
</header>
|
|
18
|
+
${entry.summary ? html`<p class="cms-measure text-xl leading-8 text-muted-foreground">${entry.summary}</p>` : null}
|
|
19
|
+
${entry.image ? html`<figure class="cms-measure">${image(entry.image, 'aspect-video w-full rounded-xl object-cover', '(min-width: 1024px) 1024px, 100vw', true)}${entry.image.caption ? html`<figcaption class="mt-2 text-sm text-muted-foreground">${entry.image.caption}</figcaption>` : null}</figure>` : null}
|
|
20
|
+
${entry.content.length ? helpers.layout(entry.content) : null}
|
|
21
|
+
${entry.terms.some(group => group.terms.length) ? html`<footer class="cms-measure space-y-1 border-t border-border pt-4 text-sm text-muted-foreground">
|
|
22
|
+
${entry.terms.filter(group => group.terms.length).map(group => html`<p>${group.label}: ${group.terms.map((term, index) => html`${index ? ', ' : ''}${term.url
|
|
23
|
+
? html`<a href=${term.url} class="text-primary hover:underline">${term.name}</a>` : term.name}`)}</p>`)}
|
|
24
|
+
</footer>` : null}
|
|
25
|
+
${entry.comments ? html`<div class="cms-measure">${comments(entry.comments)}</div>` : null}
|
|
26
|
+
</article>`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The front page when it lists the latest posts. */
|
|
2
|
+
import type { TemplateResult } from '@cossackframework/renderer';
|
|
3
|
+
import type { ArchiveContext } from '@cossackframework/cms';
|
|
4
|
+
import { list } from '../parts/list';
|
|
5
|
+
|
|
6
|
+
export default function home({ view }: ArchiveContext): TemplateResult {
|
|
7
|
+
return list(view, __('Nothing published yet.'));
|
|
8
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default site theme's frame: the header and the footer bar are widget areas with the
|
|
3
|
+
* theme's default blocks (a site logo, the primary menu with its dropdowns and mega panels,
|
|
4
|
+
* search and the language switcher; the footer menu, the switcher and a copyright line), so
|
|
5
|
+
* they are edited in place and under Appearance → Widgets; the footer widgets grid sits
|
|
6
|
+
* between the content and the bar. Nothing here frames the blocks: the root sets the measures
|
|
7
|
+
* (`--cms-content`, `--cms-wide`, `--cms-gutter`) from the width option, `helpers.layout`
|
|
8
|
+
* renders each area as a constrained layout, and the templates keep their own parts at the
|
|
9
|
+
* content measure with `cms-measure`, so a full-width group makes a band across the page. A
|
|
10
|
+
* theme is a plugin: `plugin.json` declares its menu locations, areas and options, and each
|
|
11
|
+
* file in `templates/` default-exports one template (`layout`, `entry`, `archive`, `home`,
|
|
12
|
+
* `search`, `not-found`, and narrower ones such as `entry-posts` or `term-category`). Shared
|
|
13
|
+
* pieces live in `parts/`. Edit this theme, or copy the directory to `src/plugins/<your-theme>/`,
|
|
14
|
+
* rename it in `plugin.json` and activate it under Appearance → Themes.
|
|
15
|
+
*/
|
|
16
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
17
|
+
import { presetStyle, type LayoutContext } from '@cossackframework/cms';
|
|
18
|
+
import { accentStyle, measureStyle, typographyCss } from '../parts/options';
|
|
19
|
+
|
|
20
|
+
export default function layout({ site, content, helpers }: LayoutContext): TemplateResult {
|
|
21
|
+
// The presets' variables and the measures sit on the root, so widget areas outside the content root resolve them too.
|
|
22
|
+
const rootStyle = `${accentStyle(helpers)} ${presetStyle(helpers.presets)} ${measureStyle(helpers)}`;
|
|
23
|
+
// A blank canvas: the page's content alone, with the theme's colors and type but no header or footer.
|
|
24
|
+
if (site.template === 'entry-blank') return html`<div class="min-h-screen bg-background text-foreground" style=${rootStyle} data-theme="default-theme" data-frame="blank">
|
|
25
|
+
<style data-theme-typography>${typographyCss(helpers)}</style>
|
|
26
|
+
<main id="content">${content}</main>
|
|
27
|
+
</div>`;
|
|
28
|
+
// The typography options as a stylesheet here rather than in a head template, so a child theme with its own head keeps them.
|
|
29
|
+
return html`<div class="flex min-h-screen flex-col bg-background text-foreground" style=${rootStyle} data-theme="default-theme">
|
|
30
|
+
<style data-theme-typography>${typographyCss(helpers)}</style>
|
|
31
|
+
<a href="#content" class="sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-background focus:px-3 focus:py-2 focus:shadow">${__('Skip to content')}</a>
|
|
32
|
+
<header class="relative border-b border-border">${helpers.layout(site.areas.header ?? [])}</header>
|
|
33
|
+
<main id="content" class="flex-1 py-10">${content}</main>
|
|
34
|
+
<footer class="border-t border-border">
|
|
35
|
+
${site.areas.footer?.length ? html`<div class="border-b border-border py-8"><div class="cms-measure-wide grid gap-8 text-sm sm:grid-cols-2 lg:grid-cols-3">
|
|
36
|
+
${site.areas.footer.map(block => html`<div class="cms-content min-w-0">${helpers.block(block)}</div>`)}</div></div>` : null}
|
|
37
|
+
${helpers.layout(site.areas['footer-bar'] ?? [], { class: 'text-sm text-muted-foreground' })}
|
|
38
|
+
</footer>
|
|
39
|
+
</div>`;
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The 404 page. */
|
|
2
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
3
|
+
|
|
4
|
+
export default function notFound(): TemplateResult {
|
|
5
|
+
return html`<section class="cms-measure space-y-3 py-16 text-center">
|
|
6
|
+
<h1 class="text-3xl font-bold text-foreground">${__('Page not found')}</h1>
|
|
7
|
+
<p class="text-muted-foreground">${__('The page you are looking for does not exist.')}</p>
|
|
8
|
+
<a href="/" class="text-primary hover:underline">${__('Go to the home page')}</a>
|
|
9
|
+
</section>`;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Search results, with the search form: each result's snippet marks the words that matched. */
|
|
2
|
+
import { html, type TemplateResult } from '@cossackframework/renderer';
|
|
3
|
+
import type { ArchiveContext, EntryView } from '@cossackframework/cms';
|
|
4
|
+
import { pageHref } from '../parts/list';
|
|
5
|
+
|
|
6
|
+
function result(entry: EntryView): TemplateResult {
|
|
7
|
+
const snippet = entry.snippet?.length ? entry.snippet : entry.excerpt ? [{ text: entry.excerpt, match: false }] : [];
|
|
8
|
+
return html`<article class="space-y-1">
|
|
9
|
+
<p class="text-xs text-muted-foreground">${entry.kind}${entry.date ? ` · ${entry.date}` : ''}</p>
|
|
10
|
+
<h2 class="text-lg font-semibold"><a href=${entry.url ?? '#'} class="text-foreground no-underline hover:text-primary">${entry.title}</a></h2>
|
|
11
|
+
${snippet.length ? html`<p class="text-sm leading-6 text-muted-foreground">${snippet.map(part => part.match ? html`<mark class="rounded-sm bg-primary/15 px-0.5 text-foreground">${part.text}</mark>` : part.text)}</p>` : null}
|
|
12
|
+
</article>`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default function search({ view }: ArchiveContext): TemplateResult {
|
|
16
|
+
const { paging } = view;
|
|
17
|
+
return html`<div class="cms-measure space-y-8">
|
|
18
|
+
<form method="get" action="" role="search" class="flex gap-2">
|
|
19
|
+
<input type="search" name="q" .value=${view.query} aria-label=${__('Search')} placeholder=${__('Search')}
|
|
20
|
+
class="flex-1 rounded-md border border-input bg-background px-4 py-2 text-base focus:outline-none focus:ring-2 focus:ring-ring">
|
|
21
|
+
<button type="submit" class="rounded-md border-none bg-primary px-4 py-2 text-sm font-medium text-primary-foreground cursor-pointer">${__('Search')}</button>
|
|
22
|
+
</form>
|
|
23
|
+
${view.query ? html`<h1 class="text-2xl font-bold text-foreground">${view.title}</h1>
|
|
24
|
+
${view.loose ? html`<p class="text-sm text-muted-foreground">${__('Nothing has every word; these have some of them.')}</p>` : null}
|
|
25
|
+
<div class="space-y-8">${view.entries.length ? view.entries.map(result) : html`<p class="py-10 text-center text-muted-foreground">${__('Nothing matched your search.')}</p>`}</div>
|
|
26
|
+
${paging.page > 1 || paging.pages > paging.page ? html`<nav aria-label=${__('Pages')} class="flex items-center justify-between border-t border-border pt-6 text-sm">
|
|
27
|
+
${paging.page > 1 ? html`<a href=${pageHref(paging, paging.page - 1)} class="text-primary hover:underline" rel="prev">← ${__('Previous')}</a>` : html`<span></span>`}
|
|
28
|
+
<span class="text-muted-foreground">${__('Page')} ${paging.page}</span>
|
|
29
|
+
${paging.pages > paging.page ? html`<a href=${pageHref(paging, paging.page + 1)} class="text-primary hover:underline" rel="next">${__('Next')} →</a>` : html`<span></span>`}
|
|
30
|
+
</nav>` : null}` : null}
|
|
31
|
+
</div>`;
|
|
32
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/services/rbac.ts
|
|
2
|
+
//
|
|
3
|
+
// The authorization surface. `guard` is the @cossackframework/auth authorizer kit: pages
|
|
4
|
+
// opt into checks with `@Page({ middlewares: [guard.requireRole('admin')] })`.
|
|
5
|
+
//
|
|
6
|
+
// With the CMS, permissions are patterns such as `cms:users` or `cms/posts:*`, and the
|
|
7
|
+
// shared dashboard's `admin` role means "may manage users".
|
|
8
|
+
|
|
9
|
+
import { createAuthorizer } from '@cossackframework/auth';
|
|
10
|
+
import { hasPermission, holdsAll, isNetworkAdmin, PERMISSIONS } from '@cossackframework/cms';
|
|
11
|
+
import { isTransportPath } from '@cossackframework/core/transport-routes';
|
|
12
|
+
import type { PublicUser } from '../auth';
|
|
13
|
+
import type { MiddlewareHandler } from 'hono';
|
|
14
|
+
|
|
15
|
+
export type { RoleAssignment } from '../auth';
|
|
16
|
+
|
|
17
|
+
export const guard = createAuthorizer<PublicUser>({
|
|
18
|
+
hasRole: (user, role) => role === 'admin' ? hasPermission(user.principal, PERMISSIONS.manageUsers) : user.roles.some(entry => entry.id === role),
|
|
19
|
+
hasPermission: (user, permission) => hasPermission(user.principal, permission),
|
|
20
|
+
// Unauthenticated → login page. Forbidden → the dashboard, friendlier than a bare 403.
|
|
21
|
+
onUnauthorized: (c, reason) => {
|
|
22
|
+
if (isTransportPath(c.req.path, 'rpc', 'upload', 'websocket')) {
|
|
23
|
+
return c.json({ error: reason === 'unauthenticated' ? 'Authentication required' : 'Forbidden',
|
|
24
|
+
code: reason === 'unauthenticated' ? 'COSSACK_RPC_UNAUTHENTICATED' : 'COSSACK_RPC_FORBIDDEN' }, reason === 'unauthenticated' ? 401 : 403);
|
|
25
|
+
}
|
|
26
|
+
return c.redirect(reason === 'unauthenticated' ? `${config('auth.redirectAfterLogout')}` : '/dashboard');
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/** Who may define roles and choose users' roles: holders of `cms:roles`, administrators by default. */
|
|
31
|
+
export function canAssignRoles(user: PublicUser | null | undefined): boolean {
|
|
32
|
+
return !!user && hasPermission(user.principal, PERMISSIONS.manageRoles);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Who may see and end a user's sessions and application passwords: the user, and role managers
|
|
37
|
+
* who may change the account (`canManageUser`, and `manageableHere` for a network account), so
|
|
38
|
+
* nobody mints a token for a stronger account or reads and ends its sessions.
|
|
39
|
+
*/
|
|
40
|
+
export function canManageAccess(user: PublicUser | null | undefined, target: { id: string; roles: readonly { permissions: readonly string[] }[]; networkAdmin?: boolean; lockedProfile?: string }): boolean {
|
|
41
|
+
if (!user) return false;
|
|
42
|
+
if (user.id === target.id) return true;
|
|
43
|
+
// A network account this request may not change (`manageableHere`): its sessions show where it signs in on every site.
|
|
44
|
+
if (target.lockedProfile) return false;
|
|
45
|
+
return canAssignRoles(user) && canManageUser(user, target);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Guard of the role screens. */
|
|
49
|
+
export const requireRoleManager: MiddlewareHandler = guard.requirePermission(PERMISSIONS.manageRoles);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether the user may change another account: one whose roles hold no permission the user
|
|
53
|
+
* lacks, so nobody takes over a stronger account by setting its password or email; a network
|
|
54
|
+
* admin's account, which holds no site role for it, stays with network admins.
|
|
55
|
+
*/
|
|
56
|
+
export function canManageUser(user: PublicUser | null | undefined, target: { roles: readonly { permissions: readonly string[] }[]; networkAdmin?: boolean }): boolean {
|
|
57
|
+
if (!user) return false;
|
|
58
|
+
if (target.networkAdmin && !isNetworkAdmin(user.principal)) return false;
|
|
59
|
+
return holdsAll(user.principal, target.roles.flatMap(role => role.permissions));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether the user may give these roles: a role manager, holding every permission the roles hold. */
|
|
63
|
+
export function canGrantRoles(user: PublicUser | null | undefined, roles: readonly { permissions: readonly string[] }[]): boolean {
|
|
64
|
+
return canAssignRoles(user) && holdsAll(user!.principal, roles.flatMap(role => role.permissions));
|
|
65
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ClientVisibleError, getRequestContext } from '@cossackframework/core';
|
|
2
|
+
import { ANONYMOUS, isCmsError, type Principal } from '@cossackframework/cms';
|
|
3
|
+
import type { CmsRole } from '@cossackframework/cms/server';
|
|
4
|
+
import { currentCms } from '../cms/index';
|
|
5
|
+
import type { Permission } from '../lib/permissions';
|
|
6
|
+
|
|
7
|
+
export interface RoleDetail {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
permissions: string[];
|
|
11
|
+
createdAt: string;
|
|
12
|
+
userCount?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ListRolesOptions {
|
|
16
|
+
search?: string;
|
|
17
|
+
page?: number;
|
|
18
|
+
pageSize?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ListRolesResult {
|
|
22
|
+
items: RoleDetail[];
|
|
23
|
+
total: number;
|
|
24
|
+
page: number;
|
|
25
|
+
pageSize: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CreateRoleInput {
|
|
29
|
+
name: string;
|
|
30
|
+
permissions?: Permission[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface UpdateRoleInput {
|
|
34
|
+
name?: string;
|
|
35
|
+
permissions?: Permission[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function detail(role: CmsRole): RoleDetail {
|
|
39
|
+
return { id: role.id, name: role.name, permissions: [...role.permissions], createdAt: new Date(role.createdAt).toISOString(),
|
|
40
|
+
...(role.userCount === undefined ? {} : { userCount: role.userCount }) };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function visible<T>(work: Promise<T>): Promise<T> {
|
|
44
|
+
try { return await work; }
|
|
45
|
+
catch (error) { throw isCmsError(error) ? new ClientVisibleError(error.message) : error; }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function listRoles(): Promise<RoleDetail[]>;
|
|
49
|
+
export async function listRoles(options: ListRolesOptions): Promise<ListRolesResult>;
|
|
50
|
+
export async function listRoles(options: ListRolesOptions = {}): Promise<RoleDetail[] | ListRolesResult> {
|
|
51
|
+
const users = currentCms().users;
|
|
52
|
+
if (options.page === undefined && options.pageSize === undefined && options.search === undefined) return (await users.roles()).map(detail);
|
|
53
|
+
const page = Math.max(1, options.page ?? 1);
|
|
54
|
+
const pageSize = Math.min(Math.max(1, options.pageSize ?? 20), 200);
|
|
55
|
+
const [items, total] = await Promise.all([users.roles({ search: options.search, limit: pageSize, offset: (page - 1) * pageSize }), users.countRoles({ search: options.search })]);
|
|
56
|
+
return { items: items.map(detail), total, page, pageSize };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The role new accounts get: General settings' default role, when it exists. */
|
|
60
|
+
export async function defaultRole(): Promise<RoleDetail | null> {
|
|
61
|
+
const cms = currentCms();
|
|
62
|
+
const id = await cms.settings.get('general.defaultRole');
|
|
63
|
+
const role = id ? await cms.users.role(id) : null;
|
|
64
|
+
return role ? detail(role) : null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function getRole(id: string): Promise<RoleDetail | null> {
|
|
68
|
+
const role = await currentCms().users.role(id);
|
|
69
|
+
return role ? detail(role) : null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Who is changing roles: the request's principal, which may give only the permissions it holds. */
|
|
73
|
+
function actor(): Principal {
|
|
74
|
+
return (getRequestContext()?.get('principal') as Principal | undefined) ?? ANONYMOUS;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function createRole(input: CreateRoleInput): Promise<RoleDetail> {
|
|
78
|
+
return detail(await visible(currentCms().users.createRole({ name: input.name, permissions: input.permissions ?? [] }, { actor: actor() })));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The administrator role cannot be changed, and a role stronger than the actor stays as it is. */
|
|
82
|
+
export async function updateRole(id: string, patch: UpdateRoleInput): Promise<void> {
|
|
83
|
+
if (!(await visible(currentCms().users.updateRole(id, patch, { actor: actor() })))) throw new ClientVisibleError('Role not found.');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The administrator role cannot be deleted, nor a role stronger than the actor. Its holders keep their other roles. */
|
|
87
|
+
export async function deleteRole(id: string): Promise<void> {
|
|
88
|
+
await visible(currentCms().users.deleteRole(id, { actor: actor() }));
|
|
89
|
+
}
|