@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,263 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Button, Card, CardBody, CodeEditor, ColorPicker, Field, Input } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { customCssProblem, hasPermission, isCmsError, PERMISSIONS, presetOverridesProblem, resolvePresets, slugify, type Preset } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { findSettingsMedia, settingControl, settingInput, settingRows, type SettingRow, type SettingValues } from '#app/cms/settings-form';
|
|
7
|
+
import { linkButton, notice, pageHeader } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
/** A palette color or a gradient as the screen edits it: the theme's value, and the site's when changed. */
|
|
10
|
+
interface ColorRow { slug: string; name: string; value: string; themeValue: string }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The active theme's options, such as its accent color; its palette and gradients, which
|
|
14
|
+
* blocks' Style tabs pick from, with the site's own; and the site's Additional CSS. Options
|
|
15
|
+
* save as settings named after the theme; the preset changes and the CSS as Appearance settings.
|
|
16
|
+
*/
|
|
17
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageAppearance)] })
|
|
18
|
+
export default class CustomizePage extends Cossack {
|
|
19
|
+
@State() theme = { name: '', label: '' };
|
|
20
|
+
@State() rows: SettingRow[] = [];
|
|
21
|
+
@State() values: SettingValues = {};
|
|
22
|
+
@State() colors: ColorRow[] = [];
|
|
23
|
+
@State() custom: Preset[] = [];
|
|
24
|
+
@State() gradients: ColorRow[] = [];
|
|
25
|
+
@State() customGradients: Preset[] = [];
|
|
26
|
+
@State() customCss = '';
|
|
27
|
+
@State() errors: Record<string, string> = {};
|
|
28
|
+
@State() error = '';
|
|
29
|
+
@State() mediaEnabled = false;
|
|
30
|
+
@State() mediaUpload = false;
|
|
31
|
+
private mediaEpoch = 0;
|
|
32
|
+
/** What the last publish did. */
|
|
33
|
+
@State() message = '';
|
|
34
|
+
|
|
35
|
+
head(): HeadValue {
|
|
36
|
+
return { title: __('Customize') };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async init() {
|
|
40
|
+
const cms = this.c.get('cms');
|
|
41
|
+
const principal = this.c.get('principal');
|
|
42
|
+
this.mediaEnabled = !!cms.files && [PERMISSIONS.upload, PERMISSIONS.manageMedia, PERMISSIONS.manageUsers].some(permission => hasPermission(principal, permission));
|
|
43
|
+
this.mediaUpload = !!cms.files && hasPermission(principal, PERMISSIONS.upload);
|
|
44
|
+
const name = await cms.activeTheme();
|
|
45
|
+
const theme = cms.themes().find(entry => entry.name === name);
|
|
46
|
+
if (!theme) return;
|
|
47
|
+
this.theme = { name: theme.name, label: theme.label };
|
|
48
|
+
if (theme.options) ({ rows: this.rows, values: this.values } = await settingRows(cms, theme.options, this.c.get('principal')));
|
|
49
|
+
const settings = await cms.settings.all();
|
|
50
|
+
const overrides = settings['appearance.presets']?.[theme.name] ?? null;
|
|
51
|
+
const themePresets = resolvePresets(theme.presets);
|
|
52
|
+
this.colors = themePresets.colors.map(color => ({ slug: color.slug, name: color.name, themeValue: color.value, value: overrides?.colors?.[color.slug] ?? color.value }));
|
|
53
|
+
this.custom = (overrides?.custom ?? []).filter(color => !themePresets.colors.some(entry => entry.slug === color.slug)).map(color => ({ ...color }));
|
|
54
|
+
this.gradients = themePresets.gradients.map(gradient => ({ slug: gradient.slug, name: gradient.name, themeValue: gradient.value, value: overrides?.gradients?.[gradient.slug] ?? gradient.value }));
|
|
55
|
+
this.customGradients = (overrides?.customGradients ?? []).filter(gradient => !themePresets.gradients.some(entry => entry.slug === gradient.slug)).map(gradient => ({ ...gradient }));
|
|
56
|
+
this.customCss = settings['appearance.customCss'] ?? '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Client()
|
|
60
|
+
setGradient(slug: string, value: string) {
|
|
61
|
+
this.gradients = this.gradients.map(gradient => gradient.slug === slug ? { ...gradient, value } : gradient);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@Client()
|
|
65
|
+
setCustomGradient(index: number, patch: Partial<Preset>) {
|
|
66
|
+
this.customGradients = this.customGradients.map((gradient, at) => at === index ? { ...gradient, ...patch } : gradient);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A new gradient of the site's own, named once like a custom color. */
|
|
70
|
+
@Client()
|
|
71
|
+
addCustomGradient() {
|
|
72
|
+
const taken = new Set([...this.gradients, ...this.customGradients].map(gradient => gradient.slug));
|
|
73
|
+
let index = this.customGradients.length + 1;
|
|
74
|
+
while (taken.has(`gradient-${index}`)) index += 1;
|
|
75
|
+
this.customGradients = [...this.customGradients, { slug: `gradient-${index}`, name: `${__('Gradient')} ${index}`, value: 'linear-gradient(135deg, #2563eb 0%, #7c3aed 100%)' }];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Client()
|
|
79
|
+
removeCustomGradient(index: number) {
|
|
80
|
+
this.customGradients = this.customGradients.filter((_, at) => at !== index);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Client()
|
|
84
|
+
set(name: string, value: string | boolean | null) {
|
|
85
|
+
this.values = { ...this.values, [name]: value };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Client()
|
|
89
|
+
setColor(slug: string, value: string) {
|
|
90
|
+
this.colors = this.colors.map(color => color.slug === slug ? { ...color, value } : color);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Client()
|
|
94
|
+
setCustom(index: number, patch: Partial<Preset>) {
|
|
95
|
+
this.custom = this.custom.map((color, at) => at === index ? { ...color, ...patch } : color);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** A new custom color: its slug comes from its name once, so blocks using it keep it when it is renamed. */
|
|
99
|
+
@Client()
|
|
100
|
+
addCustom() {
|
|
101
|
+
const taken = new Set([...this.colors, ...this.custom].map(color => color.slug));
|
|
102
|
+
let index = this.custom.length + 1;
|
|
103
|
+
while (taken.has(`custom-${index}`)) index += 1;
|
|
104
|
+
this.custom = [...this.custom, { slug: `custom-${index}`, name: `${__('Custom')} ${index}`, value: '#000000' }];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Client()
|
|
108
|
+
removeCustom(index: number) {
|
|
109
|
+
this.custom = this.custom.filter((_, at) => at !== index);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Client()
|
|
113
|
+
async submit(event: Event) {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
this.mediaEpoch++;
|
|
116
|
+
this.message = '';
|
|
117
|
+
await this.save(this.values, this.colors.map(color => ({ slug: color.slug, value: color.value })), this.custom, this.customCss,
|
|
118
|
+
this.gradients.map(gradient => ({ slug: gradient.slug, value: gradient.value })), this.customGradients);
|
|
119
|
+
if (!this.error) this.message = __('Your changes are live.');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Server()
|
|
123
|
+
async findSettingFiles(search: string, kind: string) {
|
|
124
|
+
return findSettingsMedia(this.c.get('cms'), this.c.get('principal'), search, kind);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Server()
|
|
128
|
+
async save(values: SettingValues, colors: { slug: string; value: string }[] = [], custom: Preset[] = [], customCss?: string, gradients: { slug: string; value: string }[] = [], customGradients: Preset[] = []) {
|
|
129
|
+
this.error = '';
|
|
130
|
+
this.errors = {};
|
|
131
|
+
const cms = this.c.get('cms');
|
|
132
|
+
const theme = cms.themes().find(entry => entry.name === this.theme.name);
|
|
133
|
+
if (!theme) { this.error = __('No theme is active.'); return; }
|
|
134
|
+
// The palette and the gradients: only values that differ from the theme's are kept, so a theme update reaches untouched ones.
|
|
135
|
+
const themePresets = resolvePresets(theme.presets);
|
|
136
|
+
const changes = (kind: 'colors' | 'gradients', list: { slug: string; value: string }[]) => Object.fromEntries(list.filter(entry => {
|
|
137
|
+
const original = themePresets[kind].find(preset => preset.slug === entry.slug);
|
|
138
|
+
return original && entry.value.trim() && entry.value.trim() !== original.value;
|
|
139
|
+
}).map(entry => [entry.slug, entry.value.trim()]));
|
|
140
|
+
const additions = (list: Preset[], fallback: string) => list.map(preset => {
|
|
141
|
+
const slug = /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(preset.slug) ? preset.slug : slugify(preset.name) || fallback;
|
|
142
|
+
return { slug, name: preset.name.trim(), value: preset.value.trim() };
|
|
143
|
+
});
|
|
144
|
+
const changed = changes('colors', colors);
|
|
145
|
+
const added = additions(custom, 'custom');
|
|
146
|
+
const changedGradients = changes('gradients', gradients);
|
|
147
|
+
const addedGradients = additions(customGradients, 'gradient');
|
|
148
|
+
const overrides = { ...(Object.keys(changed).length ? { colors: changed } : {}), ...(added.length ? { custom: added } : {}),
|
|
149
|
+
...(Object.keys(changedGradients).length ? { gradients: changedGradients } : {}), ...(addedGradients.length ? { customGradients: addedGradients } : {}) };
|
|
150
|
+
const colorProblem = presetOverridesProblem({ ...(overrides.colors ? { colors: overrides.colors } : {}), ...(overrides.custom ? { custom: overrides.custom } : {}) });
|
|
151
|
+
if (colorProblem) { this.errors = { colors: colorProblem }; this.error = __('Some colors are invalid.'); return; }
|
|
152
|
+
const gradientProblem = presetOverridesProblem({ ...(overrides.gradients ? { gradients: overrides.gradients } : {}), ...(overrides.customGradients ? { customGradients: overrides.customGradients } : {}) });
|
|
153
|
+
if (gradientProblem) { this.errors = { gradients: gradientProblem }; this.error = __('Some gradients are invalid.'); return; }
|
|
154
|
+
const cssProblem = customCss === undefined ? undefined : customCssProblem(customCss);
|
|
155
|
+
if (cssProblem) { this.errors = { customCss: cssProblem }; this.error = cssProblem; return; }
|
|
156
|
+
if (theme.options) {
|
|
157
|
+
const { input, errors } = settingInput(theme.options, values);
|
|
158
|
+
if (Object.keys(errors).length) { this.errors = errors; this.error = __('Some options are invalid.'); return; }
|
|
159
|
+
try { await cms.settings.update(theme.options.id, input, { principal: this.c.get('principal') }); }
|
|
160
|
+
catch (error) {
|
|
161
|
+
this.errors = isCmsError(error) && error.fields ? { ...error.fields } : {};
|
|
162
|
+
this.error = isCmsError(error) ? error.message : __('The options could not be saved.');
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
const presets = { ...((await cms.settings.get('appearance.presets')) ?? {}) };
|
|
168
|
+
if (Object.keys(overrides).length) presets[theme.name] = overrides; else delete presets[theme.name];
|
|
169
|
+
await cms.settings.update('appearance', { presets, ...(customCss === undefined ? {} : { customCss }) }, { principal: this.c.get('principal') });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
this.error = isCmsError(error) ? error.message : __('The changes could not be saved.');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private colorRow(color: Preset & { themeValue?: string }, change: (patch: Partial<Preset>) => void, remove?: () => void): TemplateResult {
|
|
176
|
+
const changed = color.themeValue !== undefined && color.value !== color.themeValue;
|
|
177
|
+
// One row whatever the width: the name and the value shrink, the picker and the buttons do not.
|
|
178
|
+
return html`<li class="flex items-center gap-2" data-color=${color.slug}>
|
|
179
|
+
<span class="shrink-0">${component(ColorPicker, { value: color.value, label: `${color.name} ${__('picker')}`, onChange: (value: string) => change({ value }) })}</span>
|
|
180
|
+
${remove ? component(Input, { type: 'text', class: 'min-w-0', maxlength: 40, '.value': color.name, 'aria-label': __('Name'), '@input': (event: Event) => change({ name: (event.target as HTMLInputElement).value }) })
|
|
181
|
+
: html`<span class="min-w-0 flex-1 truncate text-sm font-medium text-foreground" title=${color.name}>${color.name}</span>`}
|
|
182
|
+
<span class="w-36 shrink-0">${component(Input, { type: 'text', class: 'font-mono text-xs', maxlength: 80, '.value': color.value, 'aria-label': `${color.name} ${__('value')}`, '@input': (event: Event) => change({ value: (event.target as HTMLInputElement).value }) })}</span>
|
|
183
|
+
${changed ? html`<button type="button" class="shrink-0 border-none bg-transparent text-xs text-muted-foreground hover:text-foreground cursor-pointer" @click=${() => change({ value: color.themeValue! })}>${__('Reset')}</button>` : null}
|
|
184
|
+
${remove ? html`<button type="button" class="shrink-0 border-none bg-transparent text-xs text-destructive hover:underline cursor-pointer" @click=${remove}>${__('Remove')}</button>` : null}
|
|
185
|
+
</li>`;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A gradient: its swatch, its name (editable for the site's own), its CSS value, and Reset or Remove. */
|
|
189
|
+
private gradientRow(gradient: Preset & { themeValue?: string }, change: (patch: Partial<Preset>) => void, remove?: () => void): TemplateResult {
|
|
190
|
+
const changed = gradient.themeValue !== undefined && gradient.value !== gradient.themeValue;
|
|
191
|
+
return html`<li class="flex items-center gap-2" data-gradient=${gradient.slug}>
|
|
192
|
+
<span aria-hidden="true" class="inline-block h-8 w-14 shrink-0 rounded border border-border" style=${`background: ${gradient.value}`}></span>
|
|
193
|
+
${remove ? html`<span class="w-28 shrink-0">${component(Input, { type: 'text', maxlength: 40, '.value': gradient.name, 'aria-label': __('Name'), '@input': (event: Event) => change({ name: (event.target as HTMLInputElement).value }) })}</span>`
|
|
194
|
+
: html`<span class="w-28 shrink-0 truncate text-sm font-medium text-foreground" title=${gradient.name}>${gradient.name}</span>`}
|
|
195
|
+
${component(Input, { type: 'text', class: 'min-w-0 flex-1 font-mono text-xs', maxlength: 400, '.value': gradient.value, 'aria-label': `${gradient.name} ${__('value')}`, '@input': (event: Event) => change({ value: (event.target as HTMLInputElement).value }) })}
|
|
196
|
+
${changed ? html`<button type="button" class="shrink-0 border-none bg-transparent text-xs text-muted-foreground hover:text-foreground cursor-pointer" @click=${() => change({ value: gradient.themeValue! })}>${__('Reset')}</button>` : null}
|
|
197
|
+
${remove ? html`<button type="button" class="shrink-0 border-none bg-transparent text-xs text-destructive hover:underline cursor-pointer" @click=${remove}>${__('Remove')}</button>` : null}
|
|
198
|
+
</li>`;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private gradientsSection(): TemplateResult {
|
|
202
|
+
return html`<section class="space-y-3" aria-labelledby="customize-gradients">
|
|
203
|
+
<div>
|
|
204
|
+
<h2 id="customize-gradients" class="text-sm font-semibold text-foreground">${__('Gradients')}</h2>
|
|
205
|
+
<p class="text-xs text-muted-foreground">${__('Backgrounds for groups, columns and grids, under Advanced background on their Style tab. A CSS gradient, which may use the palette: linear-gradient(135deg, var(--cms-color-primary), #7c3aed).')}</p>
|
|
206
|
+
</div>
|
|
207
|
+
${this.gradients.length || this.customGradients.length ? html`<ul class="space-y-2">
|
|
208
|
+
${this.gradients.map(gradient => this.gradientRow(gradient, patch => this.setGradient(gradient.slug, patch.value ?? gradient.value)))}
|
|
209
|
+
${this.customGradients.map((gradient, index) => this.gradientRow(gradient, patch => this.setCustomGradient(index, patch), () => this.removeCustomGradient(index)))}
|
|
210
|
+
</ul>` : null}
|
|
211
|
+
${this.errors.gradients ? html`<p role="alert" class="text-xs text-destructive">${this.errors.gradients}</p>` : null}
|
|
212
|
+
${this.customGradients.length < 12 ? component(Button, { type: 'button', variant: 'outline', size: 'sm', '@click': () => this.addCustomGradient() }, __('Add gradient')) : null}
|
|
213
|
+
</section>`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
private colorsSection(): TemplateResult {
|
|
217
|
+
return html`<section class="space-y-3" aria-labelledby="customize-colors">
|
|
218
|
+
<div>
|
|
219
|
+
<h2 id="customize-colors" class="text-sm font-semibold text-foreground">${__('Colors')}</h2>
|
|
220
|
+
<p class="text-xs text-muted-foreground">${__('The palette blocks pick from on their Style tab. Change a theme color, or add your own; blocks keep their choice when a value changes.')}</p>
|
|
221
|
+
</div>
|
|
222
|
+
${this.colors.length || this.custom.length ? html`<ul class="space-y-2">
|
|
223
|
+
${this.colors.map(color => this.colorRow(color, patch => this.setColor(color.slug, patch.value ?? color.value)))}
|
|
224
|
+
${this.custom.map((color, index) => this.colorRow(color, patch => this.setCustom(index, patch), () => this.removeCustom(index)))}
|
|
225
|
+
</ul>` : html`<p class="text-sm text-muted-foreground">${__('The theme has no palette yet.')}</p>`}
|
|
226
|
+
${this.errors.colors ? html`<p role="alert" class="text-xs text-destructive">${this.errors.colors}</p>` : null}
|
|
227
|
+
${this.custom.length < 12 ? component(Button, { type: 'button', variant: 'outline', size: 'sm', '@click': () => this.addCustom() }, __('Add color')) : null}
|
|
228
|
+
</section>`;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private cssSection(): TemplateResult {
|
|
232
|
+
return html`<section class="space-y-2" aria-labelledby="customize-css">
|
|
233
|
+
<h2 id="customize-css" class="text-sm font-semibold text-foreground">${__('Additional CSS')}</h2>
|
|
234
|
+
<p class="text-xs text-muted-foreground">${__('Added to every page of the site after the theme\'s styles. It cannot load other files or run scripts.')}</p>
|
|
235
|
+
${component(CodeEditor, { id: 'customize-custom-css', value: this.customCss, language: 'css', label: __('Additional CSS'), class: 'min-h-[12rem] rounded-md border border-input bg-background shadow-xs focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]', onChange: (value: string) => { this.customCss = value; } })}
|
|
236
|
+
${this.errors.customCss ? html`<p role="alert" class="text-xs text-destructive">${this.errors.customCss}</p>` : null}
|
|
237
|
+
</section>`;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
render() {
|
|
241
|
+
if (!this.theme.name) return html`<div class="space-y-4">${pageHeader(__('Customize'))}${notice(__('No theme is active. Activate one under Appearance → Themes.'))}</div>`;
|
|
242
|
+
return html`<div class="max-w-3xl space-y-6">
|
|
243
|
+
${pageHeader(`${__('Customize')} ${this.theme.label}`, {
|
|
244
|
+
description: __('Options, colors and CSS of the active theme. Site title and tagline are General settings; menus have their own screen.'),
|
|
245
|
+
actions: html`${linkButton(__('Menus'), '/dashboard/appearance/menus', 'outline')}<a href="/" target="_blank" rel="noopener" class="text-sm text-primary hover:underline">${__('View site')} ↗</a>`,
|
|
246
|
+
})}
|
|
247
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
248
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
249
|
+
${component(Card, {}, component(CardBody, {}, html`<form class="space-y-6" @submit=${(event: Event) => this.submit(event)}>
|
|
250
|
+
${this.rows.length ? html`<section class="space-y-5" aria-labelledby="customize-options">
|
|
251
|
+
<h2 id="customize-options" class="text-sm font-semibold text-foreground">${__('Options')}</h2>
|
|
252
|
+
${this.rows.map(row => settingControl(row, this.values[row.name], this.errors[row.name], value => this.set(row.name, value), this.mediaEnabled ? {
|
|
253
|
+
find: (search, kind) => this.findSettingFiles(search, kind), canUpload: this.mediaUpload, epoch: () => this.mediaEpoch,
|
|
254
|
+
} : undefined))}
|
|
255
|
+
</section>` : null}
|
|
256
|
+
${this.colorsSection()}
|
|
257
|
+
${this.gradientsSection()}
|
|
258
|
+
${this.cssSection()}
|
|
259
|
+
<div>${component(Button, { type: 'submit' }, __('Publish changes'))}</div>
|
|
260
|
+
</form>`))}
|
|
261
|
+
</div>`;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { Client, ClientState, Cossack, Page, Server, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { input } from '@cossackframework/core/input';
|
|
3
|
+
import { Button, Card, CardBody, CardHeader, Field, IconPicker, Input } from '@cossackframework/ui';
|
|
4
|
+
import { component, html, repeat } from '@cossackframework/renderer';
|
|
5
|
+
import { applyDashboardMenu, dashboardLinkModuleId, dashboardMenuOf, dashboardMenuProblems, DASHBOARD_MENU_LIMITS, isCmsError, PERMISSIONS, type DashboardMenu, type DashboardMenuLink } from '@cossackframework/cms';
|
|
6
|
+
import { requireAny } from '#app/cms/guards';
|
|
7
|
+
import { iconButton, notice, pageHeader } from '#app/cms/ui';
|
|
8
|
+
import { defaultNavigation } from '#app/dashboard/access';
|
|
9
|
+
import { ICON_CATALOG } from '#app/cms/icons';
|
|
10
|
+
|
|
11
|
+
interface Row { id: string; label: string; href: string; link: boolean }
|
|
12
|
+
|
|
13
|
+
/** Icons a custom link may carry, from the dashboard's set. */
|
|
14
|
+
/**
|
|
15
|
+
* Appearance → Dashboard menu: administrators arrange the dashboard's navigation for everyone.
|
|
16
|
+
* Modules can be hidden and reordered, and links added (to a dashboard screen, a page of the site
|
|
17
|
+
* or another address). Stored in the `dashboard.menu` setting; each user still sees only the
|
|
18
|
+
* modules their permissions allow, in this order. The account menu is not part of it.
|
|
19
|
+
*/
|
|
20
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageAppearance)] })
|
|
21
|
+
export default class DashboardMenuPage extends Cossack {
|
|
22
|
+
/** The default modules of the administrator editing, as the sidebar would show them without a menu. */
|
|
23
|
+
@State() modules: Row[] = [];
|
|
24
|
+
@State() menu: DashboardMenu = { order: [], hidden: [], links: [] };
|
|
25
|
+
@State() draft: { label: string; href: string; icon: string } = { label: '', href: '', icon: 'link' };
|
|
26
|
+
@State() error = '';
|
|
27
|
+
@State() message = '';
|
|
28
|
+
@State() dirty = false;
|
|
29
|
+
/** A drag in progress: the row dragged, where it would land (an index among the rows), the drop line's offset, and whether the pointer moved. */
|
|
30
|
+
@ClientState() drag: { from: number; to: number; y: number; moved: boolean } | null = null;
|
|
31
|
+
private pointer: { id: number; x: number; y: number; tops: number[]; bottoms: number[] } | null = null;
|
|
32
|
+
private list?: HTMLElement;
|
|
33
|
+
private rowElements = new Map<string, HTMLElement>();
|
|
34
|
+
|
|
35
|
+
head(): HeadValue {
|
|
36
|
+
return { title: 'Dashboard menu' };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async init() {
|
|
40
|
+
await this.load();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Server()
|
|
44
|
+
async load() {
|
|
45
|
+
const cms = this.c.get('cms');
|
|
46
|
+
const [modules, stored] = await Promise.all([defaultNavigation(this.c), cms.settings.get('dashboard.menu').catch(() => null)]);
|
|
47
|
+
// As the sidebar lists them: no account modules, and a module nested in its parent's menu (Roles under Users) is not a row of its own.
|
|
48
|
+
const top = modules.filter(module => module.placement !== 'account');
|
|
49
|
+
this.modules = top.filter(module => !module.parent || !top.some(other => other.id === module.parent)).map(module => ({ id: module.id, label: module.label, href: module.href, link: false }));
|
|
50
|
+
this.menu = dashboardMenuOf(stored);
|
|
51
|
+
this.dirty = false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Server({ input: input.args(input.record<DashboardMenu>()) })
|
|
55
|
+
async save(menu: DashboardMenu) {
|
|
56
|
+
this.error = '';
|
|
57
|
+
const problems = dashboardMenuProblems(menu);
|
|
58
|
+
if (problems.length) { this.error = problems.join(' '); return; }
|
|
59
|
+
try {
|
|
60
|
+
await this.c.get('cms').settings.update('dashboard', { menu: { order: menu.order, hidden: menu.hidden, links: menu.links } }, { principal: this.c.get('principal') });
|
|
61
|
+
await this.load();
|
|
62
|
+
this.message = __('Dashboard menu saved. The sidebar shows the new order after a reload.');
|
|
63
|
+
} catch (error) {
|
|
64
|
+
if (!isCmsError(error)) throw error;
|
|
65
|
+
this.error = error.message;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Every row in the menu's order, hidden ones included, so they can be shown again. */
|
|
70
|
+
private rows(): Row[] {
|
|
71
|
+
return applyDashboardMenu(this.modules, { ...this.menu, hidden: [] }, link => ({ id: dashboardLinkModuleId(link), label: link.label, href: link.href, link: true }));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@Client()
|
|
75
|
+
private update(menu: DashboardMenu) {
|
|
76
|
+
this.menu = menu;
|
|
77
|
+
this.dirty = true;
|
|
78
|
+
this.message = '';
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Client()
|
|
82
|
+
private move(id: string, by: -1 | 1) {
|
|
83
|
+
const ids = this.rows().map(row => row.id);
|
|
84
|
+
const index = ids.indexOf(id);
|
|
85
|
+
const target = index + by;
|
|
86
|
+
if (index < 0 || target < 0 || target >= ids.length) return;
|
|
87
|
+
[ids[index], ids[target]] = [ids[target]!, ids[index]!];
|
|
88
|
+
this.update({ ...this.menu, order: ids });
|
|
89
|
+
requestAnimationFrame(() => (this.rowElements.get(id)?.querySelector('[data-handle]') as HTMLElement | null)?.focus());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Place the row at `from` before the row at `to` (counting without the dragged row). */
|
|
93
|
+
@Client()
|
|
94
|
+
private place(from: number, to: number) {
|
|
95
|
+
const ids = this.rows().map(row => row.id);
|
|
96
|
+
const [id] = ids.splice(from, 1);
|
|
97
|
+
ids.splice(to, 0, id!);
|
|
98
|
+
this.update({ ...this.menu, order: ids });
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Client()
|
|
102
|
+
private rowRef(id: string, element: Element | undefined) {
|
|
103
|
+
if (element) this.rowElements.set(id, element as HTMLElement); else this.rowElements.delete(id);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@Client()
|
|
107
|
+
private startDrag(event: PointerEvent, index: number) {
|
|
108
|
+
if (event.button !== 0 || !this.list) return;
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
|
|
111
|
+
const top = this.list.getBoundingClientRect().top;
|
|
112
|
+
const rects = this.rows().map(row => this.rowElements.get(row.id)?.getBoundingClientRect());
|
|
113
|
+
this.pointer = { id: event.pointerId, x: event.clientX, y: event.clientY, tops: rects.map(rect => (rect?.top ?? 0) - top), bottoms: rects.map(rect => (rect?.bottom ?? 0) - top) };
|
|
114
|
+
this.drag = { from: index, to: index, y: 0, moved: false };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Client()
|
|
118
|
+
private moveDrag(event: PointerEvent) {
|
|
119
|
+
const pointer = this.pointer;
|
|
120
|
+
const drag = this.drag;
|
|
121
|
+
if (!pointer || !drag || event.pointerId !== pointer.id || !this.list) return;
|
|
122
|
+
if (!drag.moved && Math.abs(event.clientY - pointer.y) < 4 && Math.abs(event.clientX - pointer.x) < 4) return;
|
|
123
|
+
const y = event.clientY - this.list.getBoundingClientRect().top;
|
|
124
|
+
// The rows other than the dragged one, in order; the drop goes before the first whose middle is below the pointer.
|
|
125
|
+
const rest = pointer.tops.map((_, index) => index).filter(index => index !== drag.from);
|
|
126
|
+
let to = 0;
|
|
127
|
+
while (to < rest.length && (pointer.tops[rest[to]!]! + pointer.bottoms[rest[to]!]!) / 2 < y) to++;
|
|
128
|
+
const line = to < rest.length ? pointer.tops[rest[to]!]! : pointer.bottoms[rest.at(-1) ?? 0] ?? 0;
|
|
129
|
+
if (drag.to !== to || !drag.moved) this.drag = { ...drag, to, y: line - 2, moved: true };
|
|
130
|
+
if (event.clientY < 60) window.scrollBy(0, -12);
|
|
131
|
+
else if (event.clientY > window.innerHeight - 60) window.scrollBy(0, 12);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@Client()
|
|
135
|
+
private endDrag(event: PointerEvent) {
|
|
136
|
+
const drag = this.drag;
|
|
137
|
+
if (!this.pointer || event.pointerId !== this.pointer.id) return;
|
|
138
|
+
this.pointer = null;
|
|
139
|
+
this.drag = null;
|
|
140
|
+
if (!drag?.moved || drag.to === drag.from) return;
|
|
141
|
+
this.place(drag.from, drag.to);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@Client()
|
|
145
|
+
private cancelDrag() {
|
|
146
|
+
this.pointer = null;
|
|
147
|
+
this.drag = null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@Client()
|
|
151
|
+
private handleKey(event: KeyboardEvent, id: string) {
|
|
152
|
+
if (event.key === 'Escape' && this.drag) { this.cancelDrag(); return; }
|
|
153
|
+
const by = event.key === 'ArrowUp' ? -1 : event.key === 'ArrowDown' ? 1 : 0;
|
|
154
|
+
if (!by) return;
|
|
155
|
+
event.preventDefault();
|
|
156
|
+
this.move(id, by);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
@Client()
|
|
160
|
+
private toggle(id: string) {
|
|
161
|
+
const hidden = this.menu.hidden.includes(id) ? this.menu.hidden.filter(entry => entry !== id) : [...this.menu.hidden, id];
|
|
162
|
+
this.update({ ...this.menu, hidden });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@Client()
|
|
166
|
+
private removeLink(id: string) {
|
|
167
|
+
const moduleId = dashboardLinkModuleId({ id });
|
|
168
|
+
this.update({ order: this.menu.order.filter(entry => entry !== moduleId), hidden: this.menu.hidden.filter(entry => entry !== moduleId), links: this.menu.links.filter(link => link.id !== id) });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@Client()
|
|
172
|
+
private addLink(event: Event) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
const label = this.draft.label.trim();
|
|
175
|
+
const href = this.draft.href.trim();
|
|
176
|
+
if (!label || !href) return;
|
|
177
|
+
const base = label.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 30) || 'link';
|
|
178
|
+
let id = base;
|
|
179
|
+
for (let n = 2; this.menu.links.some(link => link.id === id); n++) id = `${base}-${n}`;
|
|
180
|
+
const link: DashboardMenuLink = { id, label, href, icon: this.draft.icon };
|
|
181
|
+
const problems = dashboardMenuProblems({ links: [link] });
|
|
182
|
+
if (problems.length) { this.error = problems.join(' '); return; }
|
|
183
|
+
this.error = '';
|
|
184
|
+
// New links take their place at the end of the current order.
|
|
185
|
+
this.update({ ...this.menu, order: [...this.rows().map(row => row.id), dashboardLinkModuleId(link)], links: [...this.menu.links, link] });
|
|
186
|
+
this.draft = { label: '', href: '', icon: 'link' };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
@Client()
|
|
190
|
+
private reset() {
|
|
191
|
+
this.update({ order: [], hidden: [], links: [] });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
render() {
|
|
195
|
+
const rows = this.rows();
|
|
196
|
+
const field = (key: 'label' | 'href', label: string, extra: Record<string, unknown> = {}) => component(Field, { label, for: `menu-link-${key}`, control: attributes => component(Input, { ...attributes, ...extra, '.value': this.draft[key], '@input': (event: Event) => { this.draft = { ...this.draft, [key]: (event.target as HTMLInputElement).value }; } }) });
|
|
197
|
+
return html`<div class="space-y-6">
|
|
198
|
+
${pageHeader(__('Dashboard menu'), { description: __('Arrange the sidebar for everyone: hide modules, change their order and add links. Each person still sees only what their role allows.') })}
|
|
199
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
200
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
201
|
+
<div class="grid gap-6 xl:grid-cols-[minmax(0,1fr)_24rem]">
|
|
202
|
+
${component(Card, {}, html`${component(CardHeader, { class: 'flex items-center justify-between gap-2' }, html`<h2 class="text-base font-semibold text-foreground">${__('Menu')}</h2>
|
|
203
|
+
<span class="flex gap-2">${component(Button, { type: 'button', variant: 'outline', size: 'sm', '@click': () => this.reset() }, __('Reset to default'))}${component(Button, { type: 'button', size: 'sm', disabled: !this.dirty, '@click': () => this.save(this.menu) }, __('Save'))}</span>`)}
|
|
204
|
+
${component(CardBody, { class: 'p-0' }, html`<p id="dashboard-menu-help" class="px-4 pt-3 text-xs text-muted-foreground">${__('Drag the handles to reorder. On a handle, the arrow keys move the item.')}</p>
|
|
205
|
+
<div class="relative" ref=${(element: Element) => { this.list = element as HTMLElement | undefined; }}>
|
|
206
|
+
<ol class="divide-y divide-border" aria-label=${__('Dashboard menu items')}>${repeat(rows, row => row.id, (row, index) => {
|
|
207
|
+
const hidden = this.menu.hidden.includes(row.id);
|
|
208
|
+
const linkId = row.link ? row.id.slice('link-'.length) : '';
|
|
209
|
+
const dragging = this.drag?.moved && this.drag.from === index;
|
|
210
|
+
return html`<li class=${`flex flex-wrap items-center gap-2 px-2 py-2 text-sm transition-opacity ${hidden ? 'opacity-60' : ''} ${dragging ? 'opacity-40' : ''}`} data-menu-row=${row.id} ref=${(element: Element) => this.rowRef(row.id, element)}>
|
|
211
|
+
<button type="button" class="flex h-8 w-6 shrink-0 cursor-grab touch-none items-center justify-center rounded border-none bg-transparent text-muted-foreground hover:bg-muted active:cursor-grabbing"
|
|
212
|
+
aria-label=${`${__('Move')} ${row.label}. ${__('Drag, or use the arrow keys.')}`} aria-describedby="dashboard-menu-help" data-handle
|
|
213
|
+
@pointerdown=${(event: PointerEvent) => this.startDrag(event, index)} @pointermove=${(event: PointerEvent) => this.moveDrag(event)}
|
|
214
|
+
@pointerup=${(event: PointerEvent) => this.endDrag(event)} @pointercancel=${() => this.cancelDrag()} @lostpointercapture=${() => this.cancelDrag()}
|
|
215
|
+
@keydown=${(event: KeyboardEvent) => this.handleKey(event, row.id)}>
|
|
216
|
+
<svg aria-hidden="true" viewBox="0 0 10 16" class="h-4 w-2.5 fill-current"><circle cx="2" cy="2" r="1.5"/><circle cx="8" cy="2" r="1.5"/><circle cx="2" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="2" cy="14" r="1.5"/><circle cx="8" cy="14" r="1.5"/></svg>
|
|
217
|
+
</button>
|
|
218
|
+
<span class="min-w-0 flex-1">
|
|
219
|
+
<span class=${`font-medium ${hidden ? 'line-through text-muted-foreground' : 'text-foreground'}`}>${__(row.label)}</span>
|
|
220
|
+
<span class="ml-2 text-xs text-muted-foreground">${row.href}</span>
|
|
221
|
+
</span>
|
|
222
|
+
<span class="flex items-center gap-1">
|
|
223
|
+
${iconButton(`menu-${row.id}-hide`, hidden ? 'eye-closed' : 'eye', hidden ? `${__('Show')} ${row.label}` : `${__('Hide')} ${row.label}`, () => this.toggle(row.id), { pressed: hidden })}
|
|
224
|
+
${row.link ? iconButton(`menu-${row.id}-remove`, 'trash-bin-trash', `${__('Remove')} ${row.label}`, () => this.removeLink(linkId), { danger: true }) : null}
|
|
225
|
+
</span>
|
|
226
|
+
</li>`;
|
|
227
|
+
})}</ol>
|
|
228
|
+
${this.drag?.moved ? html`<div aria-hidden="true" class="pointer-events-none absolute inset-x-2 h-1 rounded-full bg-primary" style=${`top: ${this.drag.y}px`}></div>` : null}
|
|
229
|
+
</div>`)}`)}
|
|
230
|
+
${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Add a link')}</h2>`)}
|
|
231
|
+
${component(CardBody, {}, html`<form class="space-y-4" @submit=${(event: Event) => this.addLink(event)}>
|
|
232
|
+
${field('label', __('Label'), { required: true, maxlength: DASHBOARD_MENU_LIMITS.label })}
|
|
233
|
+
${field('href', __('Address'), { required: true, placeholder: '/dashboard/tools/health or https://…' })}
|
|
234
|
+
${component(Field, { label: __('Icon'), for: 'menu-link-icon-picker', control: () => component(IconPicker, { id: 'menu-link-icon', value: this.draft.icon, icons: ICON_CATALOG, label: __('Icon'), allowEmpty: false, onChange: (name: string) => { this.draft = { ...this.draft, icon: name }; } }) })}
|
|
235
|
+
${component(Button, { type: 'submit', variant: 'outline', disabled: this.menu.links.length >= DASHBOARD_MENU_LIMITS.links }, __('Add link'))}
|
|
236
|
+
<p class="text-xs text-muted-foreground">${__('Links show for everyone who can open the dashboard. Save the menu to keep them.')}</p>
|
|
237
|
+
</form>`)}`)}
|
|
238
|
+
</div>
|
|
239
|
+
</div>`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Badge, Button, Card, CardBody } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { isCmsError, PERMISSIONS } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { artwork, authorLine, linkButton, notice, pageHeader } from '#app/cms/ui';
|
|
7
|
+
|
|
8
|
+
interface ThemeRow { name: string; label: string; description: string; version: string; author: { name: string; url: string; email: string } | null; locations: string[]; parent: string; options: boolean; problems: string[]; active: boolean; logo: string | null; cover: string | null }
|
|
9
|
+
|
|
10
|
+
/** Themes, WordPress style: every theme plugin as a card, the active one first. */
|
|
11
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageAppearance)] })
|
|
12
|
+
export default class ThemesPage extends Cossack {
|
|
13
|
+
@State() themes: ThemeRow[] = [];
|
|
14
|
+
@State() error = '';
|
|
15
|
+
/** What the last activation did. */
|
|
16
|
+
@State() message = '';
|
|
17
|
+
|
|
18
|
+
head(): HeadValue {
|
|
19
|
+
return { title: __('Themes') };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async init() {
|
|
23
|
+
await this.load();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@Server()
|
|
27
|
+
async load() {
|
|
28
|
+
const cms = this.c.get('cms');
|
|
29
|
+
const active = await cms.activeTheme();
|
|
30
|
+
const labels = new Map(cms.themes().map(theme => [theme.name, theme.label]));
|
|
31
|
+
// Themes the network hides are not offered.
|
|
32
|
+
this.themes = (await cms.availableThemes()).map(theme => ({
|
|
33
|
+
name: theme.name, label: theme.label, description: theme.description, version: theme.version, author: theme.author, locations: theme.locations.map(location => location.label),
|
|
34
|
+
parent: theme.parent ? labels.get(theme.parent) ?? theme.parent : '',
|
|
35
|
+
options: Boolean(theme.options), problems: [...theme.problems], active: theme.name === active, logo: theme.logo, cover: theme.cover,
|
|
36
|
+
})).sort((a, b) => Number(b.active) - Number(a.active));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Server()
|
|
40
|
+
async activate(name: string) {
|
|
41
|
+
this.error = '';
|
|
42
|
+
try { await this.c.get('cms').activateTheme(name, this.c.get('principal')); }
|
|
43
|
+
catch (error) { this.error = isCmsError(error) ? error.message : __('The theme could not be activated.'); }
|
|
44
|
+
await this.load();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Client()
|
|
48
|
+
async choose(theme: ThemeRow) {
|
|
49
|
+
this.message = '';
|
|
50
|
+
await this.activate(theme.name);
|
|
51
|
+
if (!this.error) this.message = `${theme.label} ${__('is now the active theme.')}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
render() {
|
|
55
|
+
return html`<div class="space-y-6">
|
|
56
|
+
${pageHeader(__('Themes'), {
|
|
57
|
+
description: __('A theme is a plugin that draws the public site. Add one with cossack add plugin, or copy src/plugins/default-theme to start your own.'),
|
|
58
|
+
actions: html`${linkButton(__('Customize'), '/dashboard/appearance/customize', 'outline')}${linkButton(__('Menus'), '/dashboard/appearance/menus', 'outline')}`,
|
|
59
|
+
})}
|
|
60
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
61
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
62
|
+
${this.themes.length ? html`<ul class="grid gap-4 md:grid-cols-2 xl:grid-cols-3">${this.themes.map(theme => html`<li>
|
|
63
|
+
${component(Card, { class: `overflow-hidden ${theme.active ? 'ring-2 ring-primary' : ''}` }, html`
|
|
64
|
+
${artwork('cover', theme.cover, theme.name, theme.label, 'aspect-[4/3] border-b border-border')}
|
|
65
|
+
${component(CardBody, { class: 'space-y-3 pt-5' }, html`
|
|
66
|
+
<div class="flex items-start justify-between gap-3">
|
|
67
|
+
<div class="flex min-w-0 items-center gap-4">
|
|
68
|
+
${artwork('logo', theme.logo, theme.name, theme.label)}
|
|
69
|
+
<div class="min-w-0">
|
|
70
|
+
<h2 class="truncate text-base font-semibold text-foreground">${theme.label}</h2>
|
|
71
|
+
<p class="text-xs text-muted-foreground">${theme.name} · ${__('version')} ${theme.version}</p>
|
|
72
|
+
${authorLine(theme.author)}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
${theme.active ? component(Badge, { variant: 'success' }, __('Active')) : theme.problems.length ? component(Badge, { variant: 'destructive' }, __('Broken')) : null}
|
|
76
|
+
</div>
|
|
77
|
+
${theme.description ? html`<p class="text-sm text-muted-foreground">${theme.description}</p>` : null}
|
|
78
|
+
${theme.parent ? html`<p class="text-xs text-muted-foreground">${__('Child theme of')} ${theme.parent}</p>` : null}
|
|
79
|
+
${theme.locations.length ? html`<p class="text-xs text-muted-foreground">${__('Menu locations')}: ${theme.locations.join(', ')}</p>` : null}
|
|
80
|
+
${theme.problems.length ? html`<ul role="alert" class="list-disc space-y-1 pl-5 text-xs text-destructive">${theme.problems.map(problem => html`<li>${problem}</li>`)}</ul>` : null}
|
|
81
|
+
<div class="flex flex-wrap gap-2 pt-1">
|
|
82
|
+
${theme.active
|
|
83
|
+
? html`${theme.options ? linkButton(__('Customize'), '/dashboard/appearance/customize') : null}<a href="/" target="_blank" rel="noopener" class="inline-flex items-center rounded-md px-4 py-2 text-sm text-primary hover:underline">${__('View site')} ↗</a>`
|
|
84
|
+
: component(Button, { type: 'button', size: 'sm', disabled: theme.problems.length > 0, '@click': () => this.choose(theme) }, __('Activate'))}
|
|
85
|
+
</div>`)}`)}
|
|
86
|
+
</li>`)}</ul>` : notice(__('No themes are installed. The site uses plain built-in templates until you add one.'))}
|
|
87
|
+
</div>`;
|
|
88
|
+
}
|
|
89
|
+
}
|