@cossackframework/cms 0.0.0 → 0.9.2
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 +21 -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 +709 -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 +114 -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 +62 -0
- package/app/src/dashboard/avatar-field.ts +58 -0
- package/app/src/dashboard/bulk.ts +22 -0
- package/app/src/dashboard/head.ts +29 -0
- package/app/src/dashboard/icons.ts +15 -0
- package/app/src/dashboard/list-table.ts +28 -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 +18 -0
- package/app/src/dashboard/session-list.ts +98 -0
- package/app/src/dashboard/tabs.ts +2 -0
- package/app/src/dashboard/time-ago.ts +16 -0
- package/app/src/dashboard/types.ts +43 -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 +82 -0
- package/app/src/pages/auth/layout.ts +32 -0
- package/app/src/pages/auth/login/index.ts +205 -0
- package/app/src/pages/auth/magic/index.ts +68 -0
- package/app/src/pages/auth/register/index.ts +124 -0
- package/app/src/pages/auth/reset-password/index.ts +74 -0
- package/app/src/pages/auth/setup/index.ts +194 -0
- package/app/src/pages/auth/two-factor/index.ts +69 -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 +183 -0
- package/app/src/pages/dashboard/index.ts +214 -0
- package/app/src/pages/dashboard/layout.ts +227 -0
- package/app/src/pages/dashboard/profile/index.ts +211 -0
- package/app/src/pages/dashboard/profile/security/index.ts +249 -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,317 @@
|
|
|
1
|
+
import { Cossack, Page, State, ClientState, Server, Client, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { AlertDialog, Button, Card, CardBody, Field, Input, Tabs, Textarea } from '@cossackframework/ui';
|
|
3
|
+
import { html, component, type TemplateResult } from '@cossackframework/renderer';
|
|
4
|
+
import { formatBytes, imageUrl, isCmsError, mediaKind, mediaUrl, PERMISSIONS, transformable, type ImageEdits, type ImageRect, type MediaKind } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { mediaUsage, type MediaUse } from '#app/cms/media-usage';
|
|
7
|
+
import { notice, pageHeader, shortDate, statusBadge } from '#app/cms/ui';
|
|
8
|
+
|
|
9
|
+
interface Details { title: string; alt: string; caption: string; description: string }
|
|
10
|
+
|
|
11
|
+
const ASPECTS: [string, number | null][] = [['Free', null], ['Square', 1], ['4:3', 4 / 3], ['3:2', 3 / 2], ['16:9', 16 / 9]];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* One media file: preview, its public URL, editable details and deletion. Images can be
|
|
15
|
+
* cropped and given a focal point, which every resized variant keeps in view.
|
|
16
|
+
*/
|
|
17
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.upload, PERMISSIONS.manageMedia)] })
|
|
18
|
+
export default class MediaDetails extends Cossack {
|
|
19
|
+
@State() file: { id: string; url: string; name: string; kind: MediaKind; contentType: string; size: string; dimensions: string; createdAt: number; uploadedBy: string } | null = null;
|
|
20
|
+
@State() details: Details = { title: '', alt: '', caption: '', description: '' };
|
|
21
|
+
@State() error = '';
|
|
22
|
+
/** What the last save or copy did. */
|
|
23
|
+
@State() message = '';
|
|
24
|
+
@State() confirmDelete = false;
|
|
25
|
+
/** Entries and widget areas that use the file. */
|
|
26
|
+
@State() usage: MediaUse[] = [];
|
|
27
|
+
/** Image editing: available when the host resizes images. */
|
|
28
|
+
@State() editable = false;
|
|
29
|
+
@State() source = { width: 0, height: 0, version: 0 };
|
|
30
|
+
@State() crop: ImageRect | null = null;
|
|
31
|
+
@State() focus: { x: number; y: number } | null = null;
|
|
32
|
+
@ClientState() mode: 'focus' | 'crop' = 'focus';
|
|
33
|
+
@ClientState() aspect = 0;
|
|
34
|
+
@ClientState() editsChanged = false;
|
|
35
|
+
private stage?: HTMLElement;
|
|
36
|
+
private dragging: { id: number; kind: 'move' | 'resize'; x: number; y: number; start: ImageRect } | null = null;
|
|
37
|
+
|
|
38
|
+
head(): HeadValue {
|
|
39
|
+
return { title: this.file ? `${__('Edit media')}: ${this.details.title || this.file.name}` : __('Media') };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async init() {
|
|
43
|
+
const cms = this.c.get('cms');
|
|
44
|
+
const file = await cms.files?.get(this.c.req.param('id') ?? '');
|
|
45
|
+
if (!file) { this.error = __('This file does not exist.'); this.c.status(404); return; }
|
|
46
|
+
const owner = file.owner ? await cms.users.get(file.owner) : null;
|
|
47
|
+
this.file = { id: file.id, url: mediaUrl(file), name: file.name, kind: mediaKind(file.contentType), contentType: file.contentType, size: formatBytes(file.size),
|
|
48
|
+
dimensions: file.width && file.height ? `${file.width} × ${file.height} px` : '', createdAt: file.createdAt, uploadedBy: owner?.name ?? '' };
|
|
49
|
+
this.details = { title: file.title, alt: file.alt, caption: file.caption, description: file.description };
|
|
50
|
+
this.editable = Boolean(cms.files?.resizes && transformable(file.contentType) && file.width && file.height);
|
|
51
|
+
this.source = { width: file.width ?? 0, height: file.height ?? 0, version: file.updatedAt };
|
|
52
|
+
this.crop = file.edits?.crop ?? null;
|
|
53
|
+
this.focus = file.edits?.focus ?? null;
|
|
54
|
+
this.usage = await mediaUsage(cms, file.id, this.c.get('principal'));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// --- Crop and focal point ------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
@Client()
|
|
60
|
+
stageRef(element: Element | undefined) {
|
|
61
|
+
this.stage = element as HTMLElement | undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Source pixels per displayed pixel. */
|
|
65
|
+
private scale(): number {
|
|
66
|
+
return this.stage && this.stage.clientWidth ? this.source.width / this.stage.clientWidth : 1;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Client()
|
|
70
|
+
pickFocus(event: PointerEvent) {
|
|
71
|
+
if (!this.stage) return;
|
|
72
|
+
const box = this.stage.getBoundingClientRect();
|
|
73
|
+
const x = Math.min(Math.max((event.clientX - box.left) / box.width, 0), 1);
|
|
74
|
+
const y = Math.min(Math.max((event.clientY - box.top) / box.height, 0), 1);
|
|
75
|
+
// The focal point is relative to the cropped image, which this view shows.
|
|
76
|
+
this.focus = { x: Math.round(x * 1000) / 1000, y: Math.round(y * 1000) / 1000 };
|
|
77
|
+
this.editsChanged = true;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Client()
|
|
81
|
+
startCrop(event: PointerEvent, kind: 'move' | 'resize') {
|
|
82
|
+
if (event.button !== 0) return;
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
event.stopPropagation();
|
|
85
|
+
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
|
|
86
|
+
const start = this.crop ?? { x: 0, y: 0, width: this.source.width, height: this.source.height };
|
|
87
|
+
this.dragging = { id: event.pointerId, kind, x: event.clientX, y: event.clientY, start };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Client()
|
|
91
|
+
moveCrop(event: PointerEvent) {
|
|
92
|
+
const drag = this.dragging;
|
|
93
|
+
if (!drag || drag.id !== event.pointerId) return;
|
|
94
|
+
const scale = this.scale();
|
|
95
|
+
const dx = Math.round((event.clientX - drag.x) * scale);
|
|
96
|
+
const dy = Math.round((event.clientY - drag.y) * scale);
|
|
97
|
+
const { width: maxWidth, height: maxHeight } = this.source;
|
|
98
|
+
if (drag.kind === 'move') {
|
|
99
|
+
this.crop = { ...drag.start, x: Math.min(Math.max(drag.start.x + dx, 0), maxWidth - drag.start.width), y: Math.min(Math.max(drag.start.y + dy, 0), maxHeight - drag.start.height) };
|
|
100
|
+
} else {
|
|
101
|
+
let width = Math.min(Math.max(drag.start.width + dx, 16), maxWidth - drag.start.x);
|
|
102
|
+
let height = Math.min(Math.max(drag.start.height + dy, 16), maxHeight - drag.start.y);
|
|
103
|
+
if (this.aspect) {
|
|
104
|
+
height = Math.round(width / this.aspect);
|
|
105
|
+
if (drag.start.y + height > maxHeight) { height = maxHeight - drag.start.y; width = Math.round(height * this.aspect); }
|
|
106
|
+
}
|
|
107
|
+
this.crop = { ...drag.start, width, height };
|
|
108
|
+
}
|
|
109
|
+
this.editsChanged = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Client()
|
|
113
|
+
endCrop() {
|
|
114
|
+
this.dragging = null;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Apply a shape: the largest crop of that shape, centred in the current one. */
|
|
118
|
+
@Client()
|
|
119
|
+
setAspect(value: number) {
|
|
120
|
+
this.aspect = value;
|
|
121
|
+
if (!value) return;
|
|
122
|
+
const base = this.crop ?? { x: 0, y: 0, width: this.source.width, height: this.source.height };
|
|
123
|
+
let width = base.width;
|
|
124
|
+
let height = Math.round(width / value);
|
|
125
|
+
if (height > base.height) { height = base.height; width = Math.round(height * value); }
|
|
126
|
+
this.crop = { x: base.x + Math.round((base.width - width) / 2), y: base.y + Math.round((base.height - height) / 2), width, height };
|
|
127
|
+
this.editsChanged = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Client()
|
|
131
|
+
setCropValue(key: keyof ImageRect, value: string) {
|
|
132
|
+
const number = Math.round(Number(value));
|
|
133
|
+
if (!Number.isFinite(number)) return;
|
|
134
|
+
this.crop = { ...(this.crop ?? { x: 0, y: 0, width: this.source.width, height: this.source.height }), [key]: number };
|
|
135
|
+
this.editsChanged = true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@Client()
|
|
139
|
+
resetEdits() {
|
|
140
|
+
this.crop = null;
|
|
141
|
+
this.focus = null;
|
|
142
|
+
this.aspect = 0;
|
|
143
|
+
this.editsChanged = true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
@Client()
|
|
147
|
+
async submitEdits() {
|
|
148
|
+
this.message = '';
|
|
149
|
+
await this.saveEdits({ ...(this.crop ? { crop: this.crop } : {}), ...(this.focus ? { focus: this.focus } : {}) });
|
|
150
|
+
if (!this.error) { this.editsChanged = false; this.message = __('Image edits saved. Pages show the new version.'); }
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@Server()
|
|
154
|
+
async saveEdits(edits: ImageEdits) {
|
|
155
|
+
this.error = '';
|
|
156
|
+
try {
|
|
157
|
+
const updated = await this.c.get('cms').files!.setEdits(this.c.req.param('id') ?? '', edits.crop || edits.focus ? edits : null, { principal: this.c.get('principal') });
|
|
158
|
+
this.crop = updated.edits?.crop ?? null;
|
|
159
|
+
this.focus = updated.edits?.focus ?? null;
|
|
160
|
+
this.source = { ...this.source, version: updated.updatedAt };
|
|
161
|
+
} catch (error) {
|
|
162
|
+
this.error = isCmsError(error) ? error.message : __('The edits could not be saved.');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private imageEditor(file: NonNullable<MediaDetails['file']>): TemplateResult {
|
|
167
|
+
const { width, height } = this.source;
|
|
168
|
+
const crop = this.crop ?? { x: 0, y: 0, width, height };
|
|
169
|
+
const percent = (value: number, total: number) => `${(value / total) * 100}%`;
|
|
170
|
+
const cropped = { id: file.id, name: file.name, contentType: file.contentType, width, height, edits: this.crop ? { crop: this.crop } : null, version: this.source.version };
|
|
171
|
+
const panel = this.mode === 'focus' ? html`<p class="text-xs text-muted-foreground">${__('Click the part that must stay in view when the image is cut to fit a shape, such as a face.')}</p>
|
|
172
|
+
<div class="relative mx-auto w-fit cursor-crosshair" ref=${(element: Element) => this.stageRef(element)} @pointerdown=${(event: PointerEvent) => this.pickFocus(event)} data-focus-stage>
|
|
173
|
+
<img src=${this.crop && this.editsChanged ? file.url : this.crop ? imageUrl(cropped, { width: Math.min(crop.width, 1280) }) : file.url} alt=${this.details.alt}
|
|
174
|
+
class=${`block max-h-[60vh] max-w-full select-none ${this.crop && this.editsChanged ? 'opacity-60' : ''}`} draggable="false">
|
|
175
|
+
${this.focus ? html`<span aria-hidden="true" class="pointer-events-none absolute size-6 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white bg-primary/60 shadow ring-2 ring-black/40"
|
|
176
|
+
style=${`left: ${this.focus.x * 100}%; top: ${this.focus.y * 100}%`}></span>` : null}
|
|
177
|
+
</div>
|
|
178
|
+
<p class="text-xs text-muted-foreground" aria-live="polite">${this.focus ? `${__('Focal point')}: ${Math.round(this.focus.x * 100)}% × ${Math.round(this.focus.y * 100)}%` : __('No focal point: images are cut around their centre.')}
|
|
179
|
+
${this.crop && this.editsChanged ? html` ${__('Save the crop to place the point on the cropped image.')}` : null}</p>`
|
|
180
|
+
: html`<div class="flex flex-wrap items-center gap-2 text-xs">
|
|
181
|
+
<span class="text-muted-foreground">${__('Shape')}:</span>
|
|
182
|
+
${ASPECTS.map(([label, value]) => html`<button type="button" class=${`rounded border px-2 py-1 cursor-pointer ${(this.aspect || 0) === (value ?? 0) ? 'border-primary text-foreground' : 'border-border bg-background text-muted-foreground'}`}
|
|
183
|
+
@click=${() => this.setAspect(value ?? 0)}>${__(label)}</button>`)}
|
|
184
|
+
</div>
|
|
185
|
+
<div class="relative mx-auto w-fit touch-none select-none" ref=${(element: Element) => this.stageRef(element)} data-crop-stage>
|
|
186
|
+
<img src=${file.url} alt=${this.details.alt} class="block max-h-[60vh] max-w-full" draggable="false">
|
|
187
|
+
<div class="absolute border-2 border-white shadow-[0_0_0_9999px_rgba(0,0,0,0.45)] cursor-move" data-crop-box
|
|
188
|
+
style=${`left: ${percent(crop.x, width)}; top: ${percent(crop.y, height)}; width: ${percent(crop.width, width)}; height: ${percent(crop.height, height)}`}
|
|
189
|
+
@pointerdown=${(event: PointerEvent) => this.startCrop(event, 'move')} @pointermove=${(event: PointerEvent) => this.moveCrop(event)}
|
|
190
|
+
@pointerup=${() => this.endCrop()} @pointercancel=${() => this.endCrop()}>
|
|
191
|
+
<span class="absolute -bottom-2 -right-2 size-4 cursor-se-resize rounded-sm border-2 border-white bg-primary" aria-hidden="true"
|
|
192
|
+
@pointerdown=${(event: PointerEvent) => this.startCrop(event, 'resize')} @pointermove=${(event: PointerEvent) => this.moveCrop(event)}
|
|
193
|
+
@pointerup=${() => this.endCrop()} @pointercancel=${() => this.endCrop()}></span>
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
<fieldset class="grid grid-cols-2 gap-2 sm:grid-cols-4"><legend class="sr-only">${__('Crop in pixels')}</legend>
|
|
197
|
+
${(['x', 'y', 'width', 'height'] as const).map(key => html`<label class="space-y-1 text-xs"><span class="block text-muted-foreground">${({ x: __('Left'), y: __('Top'), width: __('Width'), height: __('Height') })[key]}</span>
|
|
198
|
+
<input type="number" min="0" class="w-full rounded-md border border-input bg-background px-2 py-1 text-sm text-foreground" .value=${String(crop[key])}
|
|
199
|
+
@change=${(event: Event) => this.setCropValue(key, (event.target as HTMLInputElement).value)}></label>`)}
|
|
200
|
+
</fieldset>`;
|
|
201
|
+
return html`<div class="space-y-3">
|
|
202
|
+
<div class="flex justify-end gap-2">
|
|
203
|
+
${component(Button, { type: 'button', size: 'sm', variant: 'ghost', '@click': () => this.resetEdits() }, __('Reset'))}
|
|
204
|
+
${component(Button, { type: 'button', size: 'sm', disabled: !this.editsChanged, '@click': () => this.submitEdits() }, __('Save image edits'))}
|
|
205
|
+
</div>
|
|
206
|
+
${component(Tabs, {
|
|
207
|
+
id: 'image-editing', label: __('Image editing'), value: this.mode, variant: 'underline',
|
|
208
|
+
onValueChange: (mode: string) => { this.mode = mode as 'focus' | 'crop'; },
|
|
209
|
+
items: [
|
|
210
|
+
{ value: 'focus', label: __('Focal point'), content: this.mode === 'focus' ? html`<div class="space-y-3">${panel}</div>` : null },
|
|
211
|
+
{ value: 'crop', label: __('Crop'), content: this.mode === 'crop' ? html`<div class="space-y-3">${panel}</div>` : null },
|
|
212
|
+
],
|
|
213
|
+
})}
|
|
214
|
+
</div>`;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@Client()
|
|
218
|
+
async submit(event: Event) {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
this.message = '';
|
|
221
|
+
await this.save(this.details);
|
|
222
|
+
if (!this.error) this.message = __('Media details saved.');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@Server()
|
|
226
|
+
async save(details: Details) {
|
|
227
|
+
this.error = '';
|
|
228
|
+
try {
|
|
229
|
+
const updated = await this.c.get('cms').files!.update(this.c.req.param('id') ?? '', details, { principal: this.c.get('principal') });
|
|
230
|
+
this.details = { title: updated.title, alt: updated.alt, caption: updated.caption, description: updated.description };
|
|
231
|
+
} catch (error) {
|
|
232
|
+
this.error = isCmsError(error) ? error.message : __('The details could not be saved.');
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@Server()
|
|
237
|
+
async deleteFile() {
|
|
238
|
+
this.error = '';
|
|
239
|
+
this.message = '';
|
|
240
|
+
try {
|
|
241
|
+
await this.c.get('cms').files!.delete(this.c.req.param('id') ?? '', { principal: this.c.get('principal') });
|
|
242
|
+
return this.redirect('/dashboard/media');
|
|
243
|
+
} catch (error) {
|
|
244
|
+
this.error = isCmsError(error) ? error.message : __('The file could not be deleted.');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@Client()
|
|
249
|
+
async copyUrl() {
|
|
250
|
+
if (!this.file) return;
|
|
251
|
+
this.error = '';
|
|
252
|
+
this.message = '';
|
|
253
|
+
try { await navigator.clipboard.writeText(new URL(this.file.url, location.origin).href); this.message = __('URL copied.'); }
|
|
254
|
+
catch { this.error = __('Copy the URL from the field instead.'); }
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@Client()
|
|
258
|
+
set(name: keyof Details, value: string) {
|
|
259
|
+
this.details = { ...this.details, [name]: value };
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
render() {
|
|
263
|
+
const file = this.file;
|
|
264
|
+
if (!file) return html`<div class="space-y-4">${notice(this.error || __('Loading…'), 'error')}<a href="/dashboard/media" class="text-primary">← ${__('Media library')}</a></div>`;
|
|
265
|
+
return html`<div class="space-y-6">
|
|
266
|
+
${pageHeader(__('Edit media'), { actions: html`<a href="/dashboard/media" class="text-sm text-muted-foreground hover:text-foreground">← ${__('Media library')}</a>` })}
|
|
267
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
268
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
269
|
+
<div class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_22rem]">
|
|
270
|
+
${component(Card, {}, component(CardBody, { class: this.editable ? 'bg-muted/40 p-4' : 'flex items-center justify-center bg-muted/40 p-4' },
|
|
271
|
+
file.kind === 'image' && this.editable ? this.imageEditor(file)
|
|
272
|
+
: file.kind === 'image' ? html`<img src=${file.url} alt=${this.details.alt} class="max-h-[70vh] max-w-full rounded object-contain">`
|
|
273
|
+
: file.kind === 'video' ? html`<video src=${file.url} controls class="max-h-[70vh] max-w-full"></video>`
|
|
274
|
+
: file.kind === 'audio' ? html`<audio src=${file.url} controls class="w-full"></audio>`
|
|
275
|
+
: html`<a href=${file.url} class="text-primary hover:underline">${__('Open')} ${file.name}</a>`))}
|
|
276
|
+
<div class="space-y-4">
|
|
277
|
+
<dl class="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-lg border border-border p-4 text-xs">
|
|
278
|
+
<dt class="text-muted-foreground">${__('File name')}</dt><dd class="truncate text-foreground">${file.name}</dd>
|
|
279
|
+
<dt class="text-muted-foreground">${__('Type')}</dt><dd class="text-foreground">${file.contentType}</dd>
|
|
280
|
+
<dt class="text-muted-foreground">${__('Size')}</dt><dd class="text-foreground">${file.size}</dd>
|
|
281
|
+
${file.dimensions ? html`<dt class="text-muted-foreground">${__('Dimensions')}</dt><dd class="text-foreground">${file.dimensions}</dd>` : null}
|
|
282
|
+
<dt class="text-muted-foreground">${__('Uploaded')}</dt><dd class="text-foreground">${shortDate(file.createdAt)}</dd>
|
|
283
|
+
${file.uploadedBy ? html`<dt class="text-muted-foreground">${__('Uploaded by')}</dt><dd class="text-foreground">${file.uploadedBy}</dd>` : null}
|
|
284
|
+
</dl>
|
|
285
|
+
<div class="flex gap-2">
|
|
286
|
+
${component(Input, { size: 'sm', class: 'bg-muted font-mono text-xs', readonly: true, '.value': file.url, 'aria-label': __('File URL') })}
|
|
287
|
+
${component(Button, { type: 'button', size: 'sm', variant: 'outline', '@click': () => this.copyUrl() }, __('Copy'))}
|
|
288
|
+
</div>
|
|
289
|
+
<form class="space-y-4" @submit=${(event: Event) => this.submit(event)}>
|
|
290
|
+
${component(Field, { label: __('Title'), for: 'media-title', control: attributes => component(Input, { ...attributes, '.value': this.details.title, '@input': (event: Event) => this.set('title', (event.target as HTMLInputElement).value) }) })}
|
|
291
|
+
${file.kind === 'image' ? component(Field, { label: __('Alternative text'), for: 'media-alt', hint: __('Describe the image for people who cannot see it. Leave empty if it is decorative.'),
|
|
292
|
+
control: attributes => component(Textarea, { ...attributes, rows: 2, '.value': this.details.alt, '@input': (event: Event) => this.set('alt', (event.target as HTMLTextAreaElement).value) }) }) : null}
|
|
293
|
+
${component(Field, { label: __('Caption'), for: 'media-caption', control: attributes => component(Textarea, { ...attributes, rows: 2, '.value': this.details.caption, '@input': (event: Event) => this.set('caption', (event.target as HTMLTextAreaElement).value) }) })}
|
|
294
|
+
${component(Field, { label: __('Description'), for: 'media-description', control: attributes => component(Textarea, { ...attributes, rows: 3, '.value': this.details.description, '@input': (event: Event) => this.set('description', (event.target as HTMLTextAreaElement).value) }) })}
|
|
295
|
+
<div class="flex items-center justify-between gap-2">
|
|
296
|
+
${component(Button, { type: 'button', variant: 'link', class: 'px-0 text-destructive', '@click': () => { this.confirmDelete = true; } }, __('Delete permanently'))}
|
|
297
|
+
${component(Button, { type: 'submit' }, __('Update'))}
|
|
298
|
+
</div>
|
|
299
|
+
</form>
|
|
300
|
+
<section class="rounded-lg border border-border p-4" aria-labelledby="media-usage">
|
|
301
|
+
<h2 id="media-usage" class="text-sm font-semibold text-foreground">${__('Used in')}</h2>
|
|
302
|
+
${this.usage.length ? html`<ul class="mt-2 space-y-1.5 text-sm">${this.usage.map(use => html`<li class="flex items-center justify-between gap-2">
|
|
303
|
+
<span class="min-w-0 truncate"><a href=${use.href} class="text-primary hover:underline">${use.title}</a> <span class="text-xs text-muted-foreground">${use.kind}</span></span>
|
|
304
|
+
${use.status && use.status !== 'published' ? statusBadge(use.status) : null}</li>`)}</ul>`
|
|
305
|
+
: html`<p class="mt-2 text-xs text-muted-foreground">${__('No entry uses this file.')}</p>`}
|
|
306
|
+
</section>
|
|
307
|
+
</div>
|
|
308
|
+
</div>
|
|
309
|
+
${component(AlertDialog, {
|
|
310
|
+
id: 'delete-media-dialog', open: this.confirmDelete, title: __('Delete this file?'),
|
|
311
|
+
description: this.usage.length ? `${this.usage.length} ${this.usage.length === 1 ? __('place uses this file and will show nothing in its place.') : __('places use this file and will show nothing in their place.')} ${__('This cannot be undone.')}` : __('This cannot be undone.'),
|
|
312
|
+
cancelLabel: __('Cancel'), actionLabel: __('Delete'), actionVariant: 'destructive',
|
|
313
|
+
onAction: () => { this.confirmDelete = false; void this.deleteFile(); }, onOpenChange: () => { this.confirmDelete = false; },
|
|
314
|
+
})}
|
|
315
|
+
</div>`;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Cossack, Page, State, Server, Client, flash, flashed, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Button, Card, CardBody, Icon, Input, NativeSelect, Pagination } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { formatBytes, isSameOriginPost, mediaKind, mediaUrl, PERMISSIONS, type MediaKind } from '@cossackframework/cms';
|
|
5
|
+
import { requireAny } from '#app/cms/guards';
|
|
6
|
+
import { icon } from '#app/cms/icons';
|
|
7
|
+
import { formFiles, uploadFiles } from '#app/cms/uploads';
|
|
8
|
+
import { uploadFile } from '#app/cms/media-chooser';
|
|
9
|
+
import { notice, pageHeader, shortDate } from '#app/cms/ui';
|
|
10
|
+
|
|
11
|
+
const PAGE_SIZE = 40;
|
|
12
|
+
|
|
13
|
+
interface MediaRow { id: string; url: string; name: string; title: string; alt: string; kind: MediaKind; size: string; dimensions: string; createdAt: number }
|
|
14
|
+
|
|
15
|
+
/** The media library: a grid of uploads with type and text filters, and an uploader that takes dropped files. */
|
|
16
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.upload, PERMISSIONS.manageMedia)] })
|
|
17
|
+
export default class MediaLibrary extends Cossack {
|
|
18
|
+
/** The plain upload form posts up to ten files at the size Settings → Media allows; `uploadFiles` checks each. */
|
|
19
|
+
static maxBodyBytes = 1024 * 1024 * 1024;
|
|
20
|
+
|
|
21
|
+
@State() items: MediaRow[] = [];
|
|
22
|
+
@State() total = 0;
|
|
23
|
+
@State() page = 1;
|
|
24
|
+
@State() kind = '';
|
|
25
|
+
@State() search = '';
|
|
26
|
+
@State() uploading = false;
|
|
27
|
+
@State() showUploader = false;
|
|
28
|
+
@State() dragging = false;
|
|
29
|
+
@State() message = '';
|
|
30
|
+
@State() errors: string[] = [];
|
|
31
|
+
@State() configured = true;
|
|
32
|
+
|
|
33
|
+
head(): HeadValue {
|
|
34
|
+
return { title: 'Files' };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async init() {
|
|
38
|
+
this.kind = this.c.req.query('kind') ?? '';
|
|
39
|
+
this.search = (this.c.req.query('q') ?? '').slice(0, 100);
|
|
40
|
+
const page = Number(this.c.req.query('page'));
|
|
41
|
+
this.page = Number.isSafeInteger(page) && page > 0 ? page : 1;
|
|
42
|
+
this.showUploader = this.c.req.query('upload') === '1';
|
|
43
|
+
const flashedErrors = flashed<string[]>('cms.media.errors');
|
|
44
|
+
this.errors = flashedErrors ?? [];
|
|
45
|
+
this.message = flashed<string>('cms.media.message') ?? '';
|
|
46
|
+
await this.load();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Server()
|
|
50
|
+
async load() {
|
|
51
|
+
const files = this.c.get('cms').files;
|
|
52
|
+
this.configured = files !== null;
|
|
53
|
+
if (!files) return;
|
|
54
|
+
const result = await files.list({ ...(this.kind ? { kind: this.kind as MediaKind } : {}), search: this.search, limit: PAGE_SIZE, offset: (this.page - 1) * PAGE_SIZE });
|
|
55
|
+
this.total = result.total;
|
|
56
|
+
this.items = result.items.map(file => ({
|
|
57
|
+
id: file.id, url: mediaUrl(file), name: file.name, title: file.title, alt: file.alt, kind: mediaKind(file.contentType), size: formatBytes(file.size),
|
|
58
|
+
dimensions: file.width && file.height ? `${file.width} × ${file.height}` : '', createdAt: file.createdAt,
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Uploads from the plain form, without JavaScript. */
|
|
63
|
+
async post() {
|
|
64
|
+
if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
|
|
65
|
+
const result = await uploadFiles(this.c.get('cms'), formFiles(await this.c.req.formData()), this.c.get('principal'), this.c.req.raw.signal);
|
|
66
|
+
if (result.files.length) flash('cms.media.message', `${__('Uploaded')} ${result.files.length} ${result.files.length === 1 ? __('file') : __('files')}.`);
|
|
67
|
+
if (result.errors.length) flash('cms.media.errors', result.errors);
|
|
68
|
+
return this.redirect('/dashboard/media');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Client()
|
|
72
|
+
async sendFiles(files: File[]) {
|
|
73
|
+
if (!files.length) return;
|
|
74
|
+
this.uploading = true;
|
|
75
|
+
this.errors = [];
|
|
76
|
+
this.message = '';
|
|
77
|
+
let uploaded = 0;
|
|
78
|
+
for (const file of files) {
|
|
79
|
+
try { await uploadFile(file); uploaded++; }
|
|
80
|
+
catch (error) { this.errors = [...this.errors, (error as Error).message || `${file.name}: ${__('the upload failed.')}`]; }
|
|
81
|
+
}
|
|
82
|
+
this.uploading = false;
|
|
83
|
+
if (uploaded) {
|
|
84
|
+
this.message = `${__('Uploaded')} ${uploaded} ${uploaded === 1 ? __('file') : __('files')}.`;
|
|
85
|
+
this.page = 1;
|
|
86
|
+
await this.load();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Client()
|
|
91
|
+
onDrop(event: DragEvent) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
this.dragging = false;
|
|
94
|
+
void this.sendFiles([...(event.dataTransfer?.files ?? [])]);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Client()
|
|
98
|
+
onPick(event: Event) {
|
|
99
|
+
const input = event.currentTarget as HTMLInputElement;
|
|
100
|
+
const files = [...(input.files ?? [])];
|
|
101
|
+
input.value = '';
|
|
102
|
+
void this.sendFiles(files);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private href(page: number) {
|
|
106
|
+
const params = new URLSearchParams();
|
|
107
|
+
if (this.kind) params.set('kind', this.kind);
|
|
108
|
+
if (this.search) params.set('q', this.search);
|
|
109
|
+
if (page > 1) params.set('page', String(page));
|
|
110
|
+
const query = params.toString();
|
|
111
|
+
return `/dashboard/media${query ? `?${query}` : ''}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
render() {
|
|
115
|
+
const totalPages = Math.max(1, Math.ceil(this.total / PAGE_SIZE));
|
|
116
|
+
return html`<div class="space-y-6">
|
|
117
|
+
${pageHeader(__('Files'), { titleActions: component(Button, { type: 'button', size: 'sm', '@click': () => { this.showUploader = !this.showUploader; } }, __('New file')) })}
|
|
118
|
+
${this.configured ? null : notice(__('File storage is not configured. Bind an R2 bucket as MEDIA, or set S3_BUCKET or MEDIA_DIR.'), 'error')}
|
|
119
|
+
${this.message ? notice(this.message, 'success') : null}
|
|
120
|
+
${this.errors.map(error => notice(error, 'error'))}
|
|
121
|
+
${this.showUploader ? html`<form method="post" enctype="multipart/form-data"
|
|
122
|
+
class=${`flex flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 text-center transition-colors ${this.dragging ? 'border-primary bg-primary/5' : 'border-border'}`}
|
|
123
|
+
@dragover=${(event: DragEvent) => { event.preventDefault(); this.dragging = true; }} @dragleave=${() => { this.dragging = false; }} @drop=${(event: DragEvent) => this.onDrop(event)}>
|
|
124
|
+
<p class="text-lg font-medium text-foreground">${this.uploading ? __('Uploading…') : __('Drop files to upload')}</p>
|
|
125
|
+
<p class="text-sm text-muted-foreground">${__('or')}</p>
|
|
126
|
+
<label class="inline-flex cursor-pointer items-center rounded-md border border-border px-4 py-2 text-sm font-medium text-foreground hover:bg-muted">
|
|
127
|
+
${__('Select files')}<input type="file" name="file" multiple class="sr-only" @change=${(event: Event) => this.onPick(event)}>
|
|
128
|
+
</label>
|
|
129
|
+
<noscript><button type="submit" class="rounded-md bg-primary px-4 py-2 text-sm text-primary-foreground">${__('Upload')}</button></noscript>
|
|
130
|
+
<p class="text-xs text-muted-foreground">${__('Any kind of file. The size limit is in Settings → Files.')}</p>
|
|
131
|
+
</form>` : null}
|
|
132
|
+
<form method="get" action="/dashboard/media" class="flex flex-wrap items-center gap-2" role="search">
|
|
133
|
+
<div class="w-44">${component(NativeSelect, { name: 'kind', size: 'sm', 'aria-label': __('File type') }, html`
|
|
134
|
+
${[['', __('All files')], ['image', __('Images')], ['video', __('Video')], ['audio', __('Audio')], ['document', __('Documents')], ['archive', __('Archives')]]
|
|
135
|
+
.map(([value, label]) => html`<option value=${value} ?selected=${this.kind === value}>${label}</option>`)}`)}</div>
|
|
136
|
+
<div class="w-64 max-w-full">${component(Input, { type: 'search', name: 'q', size: 'sm', value: this.search, placeholder: __('Search files'), 'aria-label': __('Search files') })}</div>
|
|
137
|
+
${component(Button, { type: 'submit', size: 'sm', variant: 'outline', class: 'gap-1.5' }, html`${component(Icon, { entry: icon('filter'), size: 16 })}${__('Filter')}`)}
|
|
138
|
+
<span class="ml-auto text-xs text-muted-foreground">${this.total} ${this.total === 1 ? __('item') : __('items')}</span>
|
|
139
|
+
</form>
|
|
140
|
+
${this.items.length ? html`<ul class="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 xl:grid-cols-6">
|
|
141
|
+
${this.items.map(item => html`<li>
|
|
142
|
+
<a href=${`/dashboard/media/${item.id}`} class="group block overflow-hidden rounded-lg border border-border bg-card no-underline hover:ring-2 hover:ring-ring">
|
|
143
|
+
${item.kind === 'image' ? html`<img src=${item.url} alt=${item.alt} class="aspect-square w-full bg-muted object-cover" loading="lazy">`
|
|
144
|
+
: html`<span class="flex aspect-square w-full items-center justify-center bg-muted p-3 text-center text-xs font-medium uppercase text-muted-foreground">${item.kind}<br>${item.name}</span>`}
|
|
145
|
+
<span class="block truncate px-2 py-1.5 text-xs text-foreground">${item.title || item.name}</span>
|
|
146
|
+
<span class="block truncate px-2 pb-1.5 text-[11px] text-muted-foreground">${item.size}${item.dimensions ? ` · ${item.dimensions}` : ''} · ${shortDate(item.createdAt)}</span>
|
|
147
|
+
</a>
|
|
148
|
+
</li>`)}
|
|
149
|
+
</ul>` : component(Card, {}, component(CardBody, {}, html`<p class="py-8 text-center text-sm text-muted-foreground">${__('No files found.')}</p>`))}
|
|
150
|
+
${totalPages > 1 ? component(Pagination, {
|
|
151
|
+
page: this.page, totalPages, label: __('Pagination'), previousLabel: __('Previous page'), nextLabel: __('Next page'),
|
|
152
|
+
pageLabel: (page: number) => `${__('Page')} ${page}`, href: (page: number) => this.href(page),
|
|
153
|
+
}) : null}
|
|
154
|
+
</div>`;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Cossack, Page } from '@cossackframework/core';
|
|
2
|
+
|
|
3
|
+
/** "New" opens the library with its uploader. */
|
|
4
|
+
@Page({ transport: 'http' })
|
|
5
|
+
export default class AddMedia extends Cossack {
|
|
6
|
+
async get() {
|
|
7
|
+
return this.c.redirect('/dashboard/media?upload=1');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Client, Cossack, Page, Server, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Button, Card, CardBody, CardHeader, SegmentBar } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { formatBytes, PERMISSIONS, type MediaKind } from '@cossackframework/cms';
|
|
5
|
+
import type { FileSummary } from '@cossackframework/cms/server';
|
|
6
|
+
import { requireAny } from '#app/cms/guards';
|
|
7
|
+
import { notice, pageHeader } from '#app/cms/ui';
|
|
8
|
+
import { timeAgo } from '#app/dashboard/time-ago';
|
|
9
|
+
|
|
10
|
+
/** The summary is kept a day: counting a large library takes a while, and the totals move slowly. */
|
|
11
|
+
const DAY = 24 * 60 * 60_000;
|
|
12
|
+
const KEY = 'cms:files:summary';
|
|
13
|
+
const KIND_LABELS: Readonly<Record<MediaKind, string>> = { image: 'Images', video: 'Video', audio: 'Audio', document: 'Documents', archive: 'Archives' };
|
|
14
|
+
|
|
15
|
+
/** Files → Summary: how much the library holds, by kind, and the resized copies of images. */
|
|
16
|
+
@Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.upload, PERMISSIONS.manageMedia)] })
|
|
17
|
+
export default class FilesSummary extends Cossack {
|
|
18
|
+
@State() summary: FileSummary | null = null;
|
|
19
|
+
/** When the summary was counted, and when the page was rendered, for "3 hours ago". */
|
|
20
|
+
@State() at = 0;
|
|
21
|
+
@State() now = 0;
|
|
22
|
+
@State() error = '';
|
|
23
|
+
@State() refreshing = false;
|
|
24
|
+
|
|
25
|
+
head(): HeadValue {
|
|
26
|
+
return { title: 'Files summary' };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async init() {
|
|
30
|
+
await this.load(false);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Server()
|
|
34
|
+
async load(fresh: boolean) {
|
|
35
|
+
const cms = this.c.get('cms');
|
|
36
|
+
this.error = '';
|
|
37
|
+
if (!cms.files) { this.error = __('File storage is not configured.'); return; }
|
|
38
|
+
try {
|
|
39
|
+
const files = cms.files;
|
|
40
|
+
const entry = await cms.cache.remember(KEY, DAY, () => files.summary(), { fresh });
|
|
41
|
+
this.summary = entry.value;
|
|
42
|
+
this.at = entry.at;
|
|
43
|
+
this.now = Date.now();
|
|
44
|
+
} catch { this.error = __('The summary could not be counted.'); }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Client()
|
|
48
|
+
async refresh() {
|
|
49
|
+
this.refreshing = true;
|
|
50
|
+
try { await this.load(true); } finally { this.refreshing = false; }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
render() {
|
|
54
|
+
const summary = this.summary;
|
|
55
|
+
const refresh = component(Button, { type: 'button', variant: 'outline', size: 'sm', disabled: this.refreshing, '@click': () => this.refresh() }, this.refreshing ? __('Counting…') : __('Refresh'));
|
|
56
|
+
return html`<div class="max-w-3xl space-y-6">
|
|
57
|
+
${pageHeader(__('Files summary'), { description: __('How much the library holds. Counted once a day; Refresh counts again now.'), actions: refresh })}
|
|
58
|
+
${this.error ? notice(this.error, 'error') : null}
|
|
59
|
+
${summary ? html`
|
|
60
|
+
<dl class="grid gap-4 sm:grid-cols-3">
|
|
61
|
+
${[[__('Files'), String(summary.files)], [__('Total size'), formatBytes(summary.bytes)], [__('Resized copies'), `${summary.variants.files} · ${formatBytes(summary.variants.bytes)}`]].map(([label, value]) => html`
|
|
62
|
+
<div class="rounded-lg border border-border bg-card p-4"><dt class="text-xs uppercase tracking-wide text-muted-foreground">${label}</dt><dd class="mt-1 text-2xl font-semibold tabular-nums text-foreground">${value}</dd></div>`)}
|
|
63
|
+
</dl>
|
|
64
|
+
${component(Card, {}, html`
|
|
65
|
+
${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Size by kind')}</h2>`)}
|
|
66
|
+
${component(CardBody, {}, summary.kinds.length ? component(SegmentBar, { label: __('Size by kind'), items: summary.kinds.map(entry => ({
|
|
67
|
+
id: entry.kind, label: `${__(KIND_LABELS[entry.kind])} (${entry.files})`, value: entry.bytes, valueText: formatBytes(entry.bytes),
|
|
68
|
+
})) }) : html`<p class="text-sm text-muted-foreground">${__('The library is empty.')}</p>`)}
|
|
69
|
+
`)}
|
|
70
|
+
<p class="text-xs text-muted-foreground">${__('Counted')} <time datetime=${new Date(this.at).toISOString()} title=${new Date(this.at).toISOString().slice(0, 16).replace('T', ' ')}>${timeAgo(new Date(this.at).toISOString(), this.now)}</time>.</p>
|
|
71
|
+
` : null}
|
|
72
|
+
</div>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
|
|
2
|
+
import { Card, CardBody } from '@cossackframework/ui';
|
|
3
|
+
import { html, component } from '@cossackframework/renderer';
|
|
4
|
+
import { MAIN_SITE, type SiteStatus } from '@cossackframework/cms/server';
|
|
5
|
+
import { pageHeader } from '#app/cms/ui';
|
|
6
|
+
import { network, siteLinks } from '#app/cms/network-ui';
|
|
7
|
+
import { siteStatus } from '#app/cms/network-view';
|
|
8
|
+
|
|
9
|
+
interface MySite {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
address: string;
|
|
13
|
+
home: string;
|
|
14
|
+
dashboard: string;
|
|
15
|
+
status: SiteStatus;
|
|
16
|
+
current: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The sites the signed-in account is a member of, with their dashboards: the Start menu's and the sidebar's My sites. */
|
|
20
|
+
@Page({ transport: 'http' })
|
|
21
|
+
export default class MySitesPage extends Cossack {
|
|
22
|
+
@State() sites: MySite[] = [];
|
|
23
|
+
|
|
24
|
+
head(): HeadValue {
|
|
25
|
+
return { title: 'My sites' };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async init() {
|
|
29
|
+
const principal = this.c.get('principal');
|
|
30
|
+
if (principal?.kind !== 'user') return;
|
|
31
|
+
const net = network(this.c);
|
|
32
|
+
const here = this.c.get('site')?.id ?? MAIN_SITE;
|
|
33
|
+
const mainTitle = await net.main.settings.get('general.siteTitle').catch(() => '');
|
|
34
|
+
this.sites = (await net.memberSites(principal.id)).map(site => {
|
|
35
|
+
const links = siteLinks(this.c, site);
|
|
36
|
+
return {
|
|
37
|
+
id: site.id, name: site.name ?? (mainTitle || __('Main site')), address: site.host ?? new URL(links.home, this.c.req.url).host,
|
|
38
|
+
home: links.home, dashboard: links.dashboard, status: site.status, current: site.id === here,
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
const th = 'px-3 py-2 font-medium';
|
|
45
|
+
return html`<div class="max-w-4xl space-y-6">
|
|
46
|
+
${pageHeader(__('My sites'), { description: __('Every site your account belongs to. Your account signs you in to each one.') })}
|
|
47
|
+
${component(Card, {}, component(CardBody, { class: 'p-0' }, html`<div class="overflow-x-auto"><table class="w-full text-sm">
|
|
48
|
+
<thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
|
|
49
|
+
<th class=${th}>${__('Site')}</th><th class=${th}>${__('Address')}</th><th class=${th}>${__('Status')}</th><th class=${`${th} text-right`}>${__('Actions')}</th>
|
|
50
|
+
</tr></thead>
|
|
51
|
+
<tbody>${this.sites.map(site => html`<tr data-site=${site.id} class="border-b border-border last:border-0">
|
|
52
|
+
<td class="px-3 py-3 font-medium text-foreground">${site.name}${site.current ? html` <span class="text-xs font-normal text-muted-foreground">(${__('this site')})</span>` : null}</td>
|
|
53
|
+
<td class="px-3 py-3 text-muted-foreground">${site.address}</td>
|
|
54
|
+
<td class="px-3 py-3">${siteStatus(site.status)}</td>
|
|
55
|
+
<td class="px-3 py-3"><div class="flex justify-end gap-3">
|
|
56
|
+
<a href=${site.dashboard} class="text-sm text-primary hover:underline">${__('Dashboard')}</a>
|
|
57
|
+
<a href=${site.home} class="text-sm text-primary hover:underline">${__('Visit')}</a>
|
|
58
|
+
</div></td>
|
|
59
|
+
</tr>`)}</tbody></table>
|
|
60
|
+
${this.sites.length ? null : html`<p role="status" class="px-4 py-10 text-center text-sm text-muted-foreground">${__('Your account belongs to no site.')}</p>`}</div>`))}
|
|
61
|
+
</div>`;
|
|
62
|
+
}
|
|
63
|
+
}
|