@cossackframework/cms 0.0.0 → 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 +145 -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 +114 -2
- 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,172 @@
|
|
|
1
|
+
import { Client, ClientState, Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Card, CardBody, Input, NativeSelect, Button } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { hasPermission, isCmsError, isNetworkAdmin, isSameOriginPost, PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { artwork, authorLine, notice, pageHeader, unrestrictedConfirm, unrestrictedNotice } from '#app/cms/ui';
|
|
7
|
+
import { settingsSectionHref } from '#app/cms/settings-search';
|
|
8
|
+
|
|
9
|
+
interface PluginRow {
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
description: string;
|
|
13
|
+
author: { name: string; url: string; email: string } | null;
|
|
14
|
+
logo: string | null;
|
|
15
|
+
cover: string | null;
|
|
16
|
+
themeOnly: boolean;
|
|
17
|
+
/** Asks for unrestricted access: a danger notice, and a grant of its own. */
|
|
18
|
+
unrestricted: boolean;
|
|
19
|
+
/** Its server code runs in a Worker of its own, or in the application with only the build's checks. */
|
|
20
|
+
runtime: 'isolated' | 'app';
|
|
21
|
+
active: boolean;
|
|
22
|
+
reason: string;
|
|
23
|
+
missing: string[];
|
|
24
|
+
settings: boolean;
|
|
25
|
+
/** The network runs it on every site; site admins cannot turn it off. */
|
|
26
|
+
networkActive: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type PluginFilter = 'all' | 'active' | 'inactive' | 'themes';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Plugins rendered into src/plugins/, as a table with search, a status filter and bulk
|
|
33
|
+
* enable and disable (a plain form, so it works without JavaScript). A plugin runs only after its schema is migrated and an
|
|
34
|
+
* administrator grants what its manifest requests; an upgrade that requests more needs a new grant.
|
|
35
|
+
* Themes alone have nothing to grant and are chosen under Appearance.
|
|
36
|
+
*/
|
|
37
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.managePlugins)] })
|
|
38
|
+
export default class PluginsPage extends Cossack {
|
|
39
|
+
@State() plugins: PluginRow[] = [];
|
|
40
|
+
@State() message = '';
|
|
41
|
+
/** Only a network admin can grant unrestricted access. */
|
|
42
|
+
@State() networkAdmin = false;
|
|
43
|
+
@ClientState() search = '';
|
|
44
|
+
@ClientState() filter: PluginFilter = 'all';
|
|
45
|
+
|
|
46
|
+
head(): HeadValue {
|
|
47
|
+
return { title: 'Plugins' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async init() {
|
|
51
|
+
const status = await this.c.get('cms').status();
|
|
52
|
+
const configurable = new Set(hasPermission(this.c.get('principal'), PERMISSIONS.manageSettings)
|
|
53
|
+
? this.c.get('cms').settings.catalog({ principal: this.c.get('principal') }).map(group => group.plugin).filter(Boolean) : []);
|
|
54
|
+
// Plugins the network hides are not offered.
|
|
55
|
+
this.plugins = status.plugins.filter(plugin => plugin.network !== 'hidden').map(plugin => ({
|
|
56
|
+
name: plugin.name, version: plugin.version, description: plugin.description, author: plugin.author, logo: plugin.logo, cover: plugin.cover, themeOnly: plugin.themeOnly, unrestricted: plugin.unrestricted, runtime: plugin.runtime,
|
|
57
|
+
active: plugin.active, reason: plugin.reason ?? '', missing: [...plugin.missing], settings: configurable.has(plugin.name), networkActive: plugin.network === 'network',
|
|
58
|
+
}));
|
|
59
|
+
this.networkAdmin = isNetworkAdmin(this.c.get('principal'));
|
|
60
|
+
this.message = flashed<string>('cms.message') ?? '';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async post() {
|
|
64
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
65
|
+
const form = await this.c.req.formData();
|
|
66
|
+
// A row's button names its plugin and action (`grant:name`); the bulk bar sends the checked `plugins` and `_action`.
|
|
67
|
+
const row = String(form.get('_row') ?? '');
|
|
68
|
+
const action = row ? row.slice(0, row.indexOf(':')) : String(form.get('_action') ?? '');
|
|
69
|
+
const names = row ? [row.slice(row.indexOf(':') + 1)] : [...new Set([...form.getAll('plugins'), form.get('plugin')].map(value => String(value ?? '')).filter(Boolean))];
|
|
70
|
+
const cms = this.c.get('cms');
|
|
71
|
+
const principal = this.c.get('principal');
|
|
72
|
+
if (action !== 'grant' && action !== 'disable') { flash('cms.message', 'Choose an action.'); return this.redirect('/dashboard/plugins'); }
|
|
73
|
+
// Only a row's own ticked box confirms unrestricted access, so a bulk grant never does.
|
|
74
|
+
const accepted = new Set(row ? form.getAll('accept-unrestricted').map(String) : []);
|
|
75
|
+
const messages: string[] = [];
|
|
76
|
+
for (const name of names.slice(0, 100)) {
|
|
77
|
+
try {
|
|
78
|
+
if (action === 'disable') {
|
|
79
|
+
await cms.revokePlugin(name, principal);
|
|
80
|
+
messages.push(`Disabled ${name}.`);
|
|
81
|
+
} else {
|
|
82
|
+
const status = await cms.grantPlugin(name, principal, { unrestricted: accepted.has(name) });
|
|
83
|
+
messages.push(status.active ? `Enabled ${name}.` : `Granted ${name}. ${status.reason ?? ''}`.trim());
|
|
84
|
+
}
|
|
85
|
+
} catch (error) {
|
|
86
|
+
messages.push(isCmsError(error) ? error.message : `${name} could not be changed.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
flash('cms.message', messages.length ? messages.join(' ') : 'Select at least one plugin.');
|
|
90
|
+
return this.redirect('/dashboard/plugins');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Client()
|
|
94
|
+
setSearch(value: string) {
|
|
95
|
+
this.search = value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Client()
|
|
99
|
+
setFilter(value: string) {
|
|
100
|
+
this.filter = (['all', 'active', 'inactive', 'themes'] as const).find(entry => entry === value) ?? 'all';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private shown(plugin: PluginRow): boolean {
|
|
104
|
+
if (this.filter === 'themes' ? !plugin.themeOnly : this.filter === 'active' ? plugin.themeOnly || !plugin.active : this.filter === 'inactive' ? plugin.themeOnly || plugin.active : false) return false;
|
|
105
|
+
const words = this.search.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
|
106
|
+
const text = [plugin.name, plugin.description, plugin.author?.name ?? ''].join(' ').toLowerCase();
|
|
107
|
+
return words.every(word => text.includes(word));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
const button = 'inline-flex items-center justify-center rounded-md px-2.5 py-1 text-xs font-medium cursor-pointer';
|
|
112
|
+
const counts = { all: this.plugins.length, active: this.plugins.filter(plugin => !plugin.themeOnly && plugin.active).length, inactive: this.plugins.filter(plugin => !plugin.themeOnly && !plugin.active).length, themes: this.plugins.filter(plugin => plugin.themeOnly).length };
|
|
113
|
+
const labels: Record<PluginFilter, string> = { all: __('All'), active: __('Active'), inactive: __('Inactive'), themes: __('Themes') };
|
|
114
|
+
const rows = this.plugins.filter(plugin => this.shown(plugin));
|
|
115
|
+
const th = 'px-3 py-2 font-medium';
|
|
116
|
+
return html`<div class="space-y-6">
|
|
117
|
+
${pageHeader(__('Plugins'), { description: __('A plugin runs after its schema is applied and you grant what it requests.') })}
|
|
118
|
+
${this.message ? notice(this.message) : null}
|
|
119
|
+
${this.plugins.filter(plugin => plugin.unrestricted && plugin.missing.length).map(plugin => unrestrictedNotice(plugin.name, plugin.networkActive ? null : this.networkAdmin
|
|
120
|
+
? unrestrictedConfirm({ name: 'accept-unrestricted', value: plugin.name }, { name: '_row', value: `grant:${plugin.name}`, label: __('Grant unrestricted access') })
|
|
121
|
+
: html`<p class="mt-2 text-sm">${__('Only a network admin can grant this.')}</p>`))}
|
|
122
|
+
${this.plugins.length ? html`<form method="post" class="space-y-3" id="plugins-form">
|
|
123
|
+
<div class="flex flex-wrap items-center justify-between gap-3">
|
|
124
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
125
|
+
<div class="w-44">${component(NativeSelect, { name: '_action', size: 'sm', 'aria-label': __('Bulk actions') }, html`
|
|
126
|
+
<option value="">${__('Bulk actions')}</option><option value="grant">${__('Grant and enable')}</option><option value="disable">${__('Disable')}</option>`)}</div>
|
|
127
|
+
${component(Button, { type: 'submit', size: 'sm', variant: 'outline' }, __('Apply'))}
|
|
128
|
+
</div>
|
|
129
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
130
|
+
<div class="w-36">${component(NativeSelect, { size: 'sm', 'aria-label': __('Show'), '@change': (event: Event) => this.setFilter((event.target as HTMLSelectElement).value) }, html`
|
|
131
|
+
${(['all', 'active', 'inactive', 'themes'] as const).map(entry => html`<option value=${entry} ?selected=${this.filter === entry}>${labels[entry]} (${counts[entry]})</option>`)}`)}</div>
|
|
132
|
+
<div class="w-56">${component(Input, { type: 'search', size: 'sm', placeholder: __('Search plugins'), 'aria-label': __('Search plugins'), '.value': this.search,
|
|
133
|
+
'@input': (event: Event) => this.setSearch((event.target as HTMLInputElement).value) })}</div>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
${component(Card, {}, component(CardBody, { class: 'p-0' }, html`<div class="overflow-x-auto"><table class="w-full text-sm">
|
|
137
|
+
<thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
|
|
138
|
+
<th class="w-10 px-3 py-2"><span class="sr-only">${__('Select')}</span></th><th class=${th}>${__('Plugin')}</th><th class=${th}>${__('Description')}</th><th class=${th}>${__('Status')}</th><th class=${`${th} text-right`}>${__('Actions')}</th>
|
|
139
|
+
</tr></thead>
|
|
140
|
+
<tbody>${rows.map(plugin => html`<tr data-plugin=${plugin.name} data-version=${plugin.version} data-active=${plugin.active ? 'true' : 'false'} class="border-b border-border last:border-0 align-top">
|
|
141
|
+
<td class="px-3 py-3">${plugin.themeOnly || plugin.networkActive ? null : html`<input type="checkbox" name="plugins" value=${plugin.name} aria-label=${`${__('Select')} ${plugin.name}`} class="size-4 cursor-pointer accent-primary">`}</td>
|
|
142
|
+
<td class="px-3 py-3"><div class="flex min-w-[12rem] items-center gap-3">
|
|
143
|
+
${artwork('logo', plugin.logo, plugin.name, plugin.name)}
|
|
144
|
+
<div class="min-w-0">
|
|
145
|
+
<p class="truncate font-semibold text-foreground">${plugin.name}</p>
|
|
146
|
+
<p class="text-xs text-muted-foreground">${__('version')} ${plugin.version}</p>
|
|
147
|
+
${authorLine(plugin.author)}
|
|
148
|
+
</div>
|
|
149
|
+
</div></td>
|
|
150
|
+
<td class="px-3 py-3 text-muted-foreground">
|
|
151
|
+
${plugin.description ? html`<p>${plugin.description}</p>` : null}
|
|
152
|
+
${plugin.reason ? html`<p class="mt-1">${plugin.reason}</p>` : null}
|
|
153
|
+
${plugin.missing.length ? html`<p class="mt-1 text-xs">${__('Requests')}: ${plugin.missing.join(', ')}</p>` : null}
|
|
154
|
+
${plugin.runtime === 'app' && !plugin.themeOnly && !plugin.unrestricted ? html`<p class="mt-1 text-xs" data-testid=${`plugin-in-app-${plugin.name}`}>${__('Runs in the application: its permissions are checked when the site is built, not enforced while it runs.')}</p>` : null}
|
|
155
|
+
</td>
|
|
156
|
+
<td class="px-3 py-3">${plugin.themeOnly ? component(Badge, { variant: 'secondary' }, __('Theme'))
|
|
157
|
+
: plugin.networkActive ? component(Badge, { variant: plugin.active ? 'success' : 'warning' }, __('Network active'))
|
|
158
|
+
: component(Badge, { variant: plugin.active ? 'success' : 'secondary' }, plugin.active ? __('Active') : __('Inactive'))}
|
|
159
|
+
${plugin.unrestricted ? html`<div class="mt-1">${component(Badge, { variant: 'destructive' }, __('Unrestricted'))}</div>` : null}
|
|
160
|
+
${plugin.runtime === 'isolated' && !plugin.themeOnly ? html`<div class="mt-1" data-testid=${`plugin-isolated-${plugin.name}`} title=${__('Its server code runs in a Worker of its own and reaches only what it is granted.')}>${component(Badge, { variant: 'outline' }, __('Isolated'))}</div>` : null}</td>
|
|
161
|
+
<td class="px-3 py-3"><div class="flex flex-wrap items-center justify-end gap-3">
|
|
162
|
+
${plugin.settings ? html`<a href=${settingsSectionHref(`plugin:${plugin.name}`)} class="text-sm text-primary hover:underline">${__('Settings')}</a>` : null}
|
|
163
|
+
${plugin.networkActive ? null : plugin.themeOnly ? html`<a href="/dashboard/appearance" class="text-sm text-primary hover:underline">${__('Manage in Appearance')} →</a>` : html`
|
|
164
|
+
${plugin.missing.length && !plugin.unrestricted ? component(Button, { type: 'submit', size: 'sm', name: '_row', value: `grant:${plugin.name}` }, __('Grant and enable')) : null}
|
|
165
|
+
${plugin.active ? html`<button type="submit" name="_row" value=${`disable:${plugin.name}`} class="cursor-pointer border-none bg-transparent p-0 text-sm text-destructive hover:underline">${__('Disable')}</button>` : null}`}
|
|
166
|
+
</div></td>
|
|
167
|
+
</tr>`)}</tbody></table>
|
|
168
|
+
${rows.length ? null : html`<p role="status" class="px-4 py-10 text-center text-sm text-muted-foreground">${__('No plugins match.')}</p>`}</div>`))}
|
|
169
|
+
</form>` : html`<p class="text-sm text-muted-foreground">${__('No plugins. Render one with')} <code>cossack add plugin</code>.</p>`}
|
|
170
|
+
</div>`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { input } from '@cossackframework/core/input';
|
|
3
|
+
import { Button, Card, CardBody, CardHeader, Field, Input, Textarea } from '@cossackframework/ui';
|
|
4
|
+
import { html, component } from '@cossackframework/renderer';
|
|
5
|
+
import { AUTHOR_FIELDS, authorUrl, isCmsError } from '@cossackframework/cms';
|
|
6
|
+
import { siteOrigin } from '#app/cms/seo';
|
|
7
|
+
import { notice, pageHeader } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
/** The author profile as the form holds it. */
|
|
10
|
+
interface PublicProfile { slug: string; bio: string; jobTitle: string; website: string; profiles: string }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The signed-in user's public profile: the author page's address, bio, job title, website
|
|
14
|
+
* and profiles elsewhere. Their articles name them as the author with these, and their author
|
|
15
|
+
* page shows them when Settings → SEO turns author pages on.
|
|
16
|
+
*/
|
|
17
|
+
@Page({ transport: 'http' })
|
|
18
|
+
export default class PublicProfilePage extends Cossack {
|
|
19
|
+
@State() form: PublicProfile = { slug: '', bio: '', jobTitle: '', website: '', profiles: '' };
|
|
20
|
+
@State() authorPages = true;
|
|
21
|
+
@State() origin = '';
|
|
22
|
+
@State() error = '';
|
|
23
|
+
/** What the last save did. */
|
|
24
|
+
@State() message = '';
|
|
25
|
+
@State() errors: Record<string, string> = {};
|
|
26
|
+
|
|
27
|
+
head(): HeadValue {
|
|
28
|
+
return { title: __('Public profile') };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async init() {
|
|
32
|
+
const cms = this.c.get('cms');
|
|
33
|
+
const user = this.user ? await cms.users.get(this.user.id) : null;
|
|
34
|
+
if (!user) return;
|
|
35
|
+
const meta = user.meta;
|
|
36
|
+
this.form = { slug: user.slug ?? '', bio: String(meta.bio ?? ''), jobTitle: String(meta.jobTitle ?? ''), website: String(meta.website ?? ''), profiles: String(meta.profiles ?? '') };
|
|
37
|
+
this.authorPages = await cms.settings.get('seo.authorPages');
|
|
38
|
+
this.origin = siteOrigin(this.c);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@Client()
|
|
42
|
+
set<K extends keyof PublicProfile>(key: K, value: PublicProfile[K]) {
|
|
43
|
+
this.form = { ...this.form, [key]: value };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Client()
|
|
47
|
+
async submit(event: Event) {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
this.message = '';
|
|
50
|
+
await this.save(this.form);
|
|
51
|
+
if (!this.error) this.message = __('Profile saved.');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Server({ input: input.args(input.object({
|
|
55
|
+
slug: input.string({ maxLength: 200 }), bio: input.string({ maxLength: 10_000 }), jobTitle: input.string({ maxLength: 500 }),
|
|
56
|
+
website: input.string({ maxLength: 2000 }), profiles: input.string({ maxLength: 10_000 }),
|
|
57
|
+
})) })
|
|
58
|
+
async save(form: PublicProfile) {
|
|
59
|
+
this.error = '';
|
|
60
|
+
this.errors = {};
|
|
61
|
+
const cms = this.c.get('cms');
|
|
62
|
+
if (!this.user) return;
|
|
63
|
+
const slug = form.slug.trim().toLowerCase();
|
|
64
|
+
if (slug && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) { this.errors = { slug: __('uses lowercase letters, digits and hyphens.') }; this.error = __('The address is invalid.'); return; }
|
|
65
|
+
const meta: Record<string, string> = {};
|
|
66
|
+
for (const key of Object.keys(AUTHOR_FIELDS)) meta[key] = String(form[key as keyof PublicProfile] ?? '').trim();
|
|
67
|
+
try {
|
|
68
|
+
await cms.users.update(this.user.id, { meta, ...(slug ? { slug } : {}) });
|
|
69
|
+
const user = await cms.users.get(this.user.id);
|
|
70
|
+
this.form = { slug: user?.slug ?? slug, bio: form.bio, jobTitle: form.jobTitle, website: form.website, profiles: form.profiles };
|
|
71
|
+
} catch (error) {
|
|
72
|
+
this.errors = isCmsError(error) && error.fields ? { ...error.fields } : {};
|
|
73
|
+
this.error = isCmsError(error) ? error.message : __('The profile could not be saved.');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
render() {
|
|
78
|
+
const field = (key: keyof PublicProfile, label: string, options: { hint?: string; rows?: number; placeholder?: string } = {}) => component(Field, {
|
|
79
|
+
label, for: `profile-${key}`, ...(options.hint ? { hint: options.hint } : {}), ...(this.errors[key] ? { error: `${label} ${this.errors[key]}` } : {}),
|
|
80
|
+
control: attributes => options.rows
|
|
81
|
+
? component(Textarea, { ...attributes, rows: options.rows, ...(options.placeholder ? { placeholder: options.placeholder } : {}), '.value': this.form[key], '@input': (event: Event) => this.set(key, (event.target as HTMLTextAreaElement).value) })
|
|
82
|
+
: component(Input, { ...attributes, ...(options.placeholder ? { placeholder: options.placeholder } : {}), '.value': this.form[key], '@input': (event: Event) => this.set(key, (event.target as HTMLInputElement).value) }),
|
|
83
|
+
});
|
|
84
|
+
const page = authorUrl(this.form.slug);
|
|
85
|
+
return html`<div class="max-w-2xl space-y-6">
|
|
86
|
+
${pageHeader(__('Public profile'), { description: __('What readers and search engines learn about you as an author. Your name and picture come from your profile.'),
|
|
87
|
+
actions: html`<a href="/dashboard/profile" class="text-sm text-primary hover:underline">← ${__('Profile')}</a>` })}
|
|
88
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
89
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
90
|
+
${component(Card, {}, html`
|
|
91
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Author page')}</h2>
|
|
92
|
+
<p class="text-sm text-muted-foreground">${this.authorPages && page
|
|
93
|
+
? html`${__('Your entries are listed at')} <a href=${`${this.origin}${page}`} class="text-primary hover:underline" target="_blank" rel="noopener">${this.origin}${page}</a>`
|
|
94
|
+
: __('Author pages are off in Settings → SEO; your articles still name you as the author.')}</p>`)}
|
|
95
|
+
${component(CardBody, {}, html`<form class="space-y-4" @submit=${(event: Event) => this.submit(event)}>
|
|
96
|
+
${field('slug', __('Address'), { hint: __('The last part of your author page\'s URL: /author/<address>. Changing it breaks links to the old one.'), placeholder: 'ada-lovelace' })}
|
|
97
|
+
${field('jobTitle', __('Job title'), { placeholder: __('Senior editor') })}
|
|
98
|
+
${field('bio', __('Bio'), { rows: 4, hint: String(AUTHOR_FIELDS.bio!.description) })}
|
|
99
|
+
${field('website', __('Website'), { placeholder: 'https://' })}
|
|
100
|
+
${field('profiles', __('Profiles'), { rows: 4, hint: String(AUTHOR_FIELDS.profiles!.description), placeholder: 'https://www.linkedin.com/in/…\nhttps://x.com/…' })}
|
|
101
|
+
<div>${component(Button, { type: 'submit' }, __('Save profile'))}</div>
|
|
102
|
+
</form>`)}`)}
|
|
103
|
+
</div>`;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Card, CardBody } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, isSameOriginPost, PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { approveRegistration } from '#app/auth';
|
|
6
|
+
import { requireAny } from '#app/cms/guards';
|
|
7
|
+
import { notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
8
|
+
import { actionButton } from '#app/cms/network-view';
|
|
9
|
+
|
|
10
|
+
interface Waiting { id: string; name: string; email: string; verified: boolean; createdAt: number }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Users → Registrations: the accounts that wait for an administrator's approval, when Settings →
|
|
14
|
+
* General asks for it. Approve one to let them sign in (they get an email), or delete it.
|
|
15
|
+
*/
|
|
16
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageUsers)] })
|
|
17
|
+
export default class RegistrationsPage extends Cossack {
|
|
18
|
+
@State() waiting: Waiting[] = [];
|
|
19
|
+
@State() required = false;
|
|
20
|
+
@State() message = '';
|
|
21
|
+
@State() error = '';
|
|
22
|
+
|
|
23
|
+
head(): HeadValue {
|
|
24
|
+
return { title: 'Registrations' };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async init() {
|
|
28
|
+
const cms = this.c.get('cms');
|
|
29
|
+
this.required = await cms.settings.get('general.approveRegistrations');
|
|
30
|
+
this.waiting = (await cms.users.registrations({ limit: 200 })).map(({ user, verified, createdAt }) => ({ id: user.id, name: user.name, email: user.email, verified, createdAt }));
|
|
31
|
+
this.message = flashed<string>('registrations.message') ?? '';
|
|
32
|
+
this.error = flashed<string>('registrations.error') ?? '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async post() {
|
|
36
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
37
|
+
const form = await this.c.req.formData();
|
|
38
|
+
const action = String(form.get('action') ?? '');
|
|
39
|
+
const id = String(form.get('id') ?? '');
|
|
40
|
+
const cms = this.c.get('cms');
|
|
41
|
+
try {
|
|
42
|
+
if (!(await cms.users.awaitingApproval(id))) throw new Error(__('This account does not wait for approval.'));
|
|
43
|
+
if (action === 'approve') {
|
|
44
|
+
await approveRegistration(id);
|
|
45
|
+
flash('registrations.message', __('Approved. They can sign in now and got an email saying so.'));
|
|
46
|
+
} else if (action === 'delete') {
|
|
47
|
+
await cms.users.delete(id);
|
|
48
|
+
flash('registrations.message', __('Deleted the account.'));
|
|
49
|
+
} else throw new Error(__('Unknown action.'));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
flash('registrations.error', isCmsError(error) || error instanceof Error ? (error as Error).message : __('The action failed.'));
|
|
52
|
+
}
|
|
53
|
+
return this.redirect('/dashboard/registrations');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
render() {
|
|
57
|
+
return html`<div class="space-y-6">
|
|
58
|
+
${pageHeader(__('Registrations'), { description: __('New accounts that wait for approval before they can sign in.') })}
|
|
59
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
60
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
61
|
+
${!this.required ? notice(__('Settings → General does not ask for approval now: new accounts are active at once. Accounts below still wait.'), 'info') : null}
|
|
62
|
+
${component(Card, {}, component(CardBody, { class: 'p-0' }, this.waiting.length ? html`<ul class="divide-y divide-border" data-testid="registrations">${this.waiting.map(entry => html`<li class="flex flex-wrap items-center justify-between gap-3 px-4 py-3 text-sm" data-registration=${entry.id}>
|
|
63
|
+
<span><span class="font-medium text-foreground">${entry.name}</span> <span class="text-muted-foreground">${entry.email}</span>
|
|
64
|
+
<span class="mt-0.5 flex flex-wrap items-center gap-2 text-xs text-muted-foreground">${__('Registered')} ${shortDate(entry.createdAt)}
|
|
65
|
+
${entry.verified ? component(Badge, { variant: 'secondary' }, __('Email confirmed')) : component(Badge, { variant: 'outline' }, __('Email not confirmed yet'))}</span></span>
|
|
66
|
+
<span class="flex gap-2">${entry.verified ? actionButton('approve', __('Approve'), { id: entry.id }) : null}${actionButton('delete', __('Delete'), { id: entry.id }, { danger: true })}</span>
|
|
67
|
+
</li>`)}</ul>` : html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('No account waits for approval.')}</p>`))}
|
|
68
|
+
</div>`;
|
|
69
|
+
}
|
|
70
|
+
}
|