Add maintenance and 404 pages, template suites, and MCP skill

This commit is contained in:
2026-11-25 15:36:01 +08:00
parent 277610913a
commit 884ce10789
47 changed files with 470 additions and 52 deletions
+30
View File
@@ -0,0 +1,30 @@
---
name: laysite-mcp
description: Design or revise website pages as LaySite drafts through its MCP server. Use when asked to create a site page, choose a template, assemble reusable components, or hand a draft over for editing in the LaySite visual canvas.
---
# LaySite MCP
Use the configured LaySite MCP connection to the target site's `/mcp` endpoint. The server uses Streamable HTTP with a Bearer token. Keep the token in the client's credential configuration. Follow the repository's [MCP setup](../../../README.md#mcp) if the connection is missing.
## Work with drafts
1. Call `list_pages`, `list_templates`, and `list_designs`. Use `get_page` to inspect the page being revised and related site pages. Confirm the intended site and use the exact template keys and design IDs the server returns.
2. For a new page, call `create_draft` with a unique lowercase slug and a descriptive name. Pass `template` to start from a whole-page template. Keep the layout and content that fit the task.
3. For a revision, read the draft using `get_page` before calling `save_draft` with its latest `version`. Send only the fields that changed. When sending `sections`, include every section intended to remain, in display order. Keep existing keys and reconstruct dynamic feeds with their component's `preset` when that preset represents the current configuration. If the feed has custom settings the MCP schema cannot express, keep the existing section list and leave that adjustment for the canvas.
4. Read the draft back. Check content, section order, button destinations, design selections and image descriptions. Open the returned preview when the administrator session is available. Pass the returned `editor` and `preview` links to the human editor for refinement and publishing.
Treat a version conflict as a signal to reread the draft and reconcile any intervening changes. Leave published pages, shared headers and footers, and site settings under human control. For a published page revision, create a separate draft when the user wants a reviewable version.
## Keep page design consistent
- Follow the existing site's palette, spacing, button styles, navigation and terminology. Start with a matching template or reusable component. Use `header_id`, `footer_id`, and `palette_id` only when the task calls for a specific saved design.
- Give the page one clear primary heading and one primary action. Use each section's title as its heading, then start headings in the body at `h3`. Use semantic paragraphs, lists, links, figures and tables. Write meaningful labels and use the visitor's language.
- Reuse LaySite's CSS classes for buttons and components. Use plain, sanitizable HTML for custom bodies, and keep everything editable in the canvas. Keep scripts, event handlers, inline CSS and embedded forms out of draft markup. Check that the design can stack on narrow screens and stays readable at mobile widths.
- For hero actions, send `[href, label, style, opensNewTab]`. Use `solid` for the primary action and `outline`, `underline`, or `plain` for secondary actions. Internal links normally open in the same tab.
- Use stable, unique section keys such as `getting-started`. Reserve `home`, `contact`, `main-content`, `primary-navigation`, and `preview` for the application. Confirm destinations exist and use descriptive alt text for informative images.
- Keep SEO titles and summaries specific to the page. Use provided facts, assets, links and claims. Flag missing dates, prices, contact details or media in the handoff.
## Source changes
When the user asks to extend LaySite itself, follow its repository instructions. Use Webman controllers, PHP views, SQLite migrations when changing persisted data, native CSS and the existing jQuery handlers. Reuse the template registry, canvas and sanitizer. Store built-in previews as system assets and keep uploads in the user media library. Keep page-theme assets conditional and keep public routes, status codes and backups aligned with data changes.
+15 -3
View File
@@ -1,6 +1,6 @@
# LaySite
基于 PHP Webman、SQLite、原生 CSS 和 jQuery 的通用站点编辑器。页面由服务端渲染,公开页复用站点组件和配色。新装提供空白首页、可编辑的文章页,以及六套十二个整页模板。
基于 PHP Webman、SQLite、原生 CSS 和 jQuery 的通用站点编辑器。页面由服务端渲染,公开页复用站点组件和配色。新装提供空白首页、可编辑的文章页,以及九套十八个整页模板。
## 安装
@@ -36,13 +36,21 @@ php start.php start
- 选中元素可编辑四边的内外边距。选中文字后可修改字号、粗体、斜体和删除线。Enter 或 Shift+Enter 在当前元素内换行。正文用 Ctrl+Enter(macOS 上为 ⌘+Enter)或工具栏「换段」新建段落,列表中则新增列表项。
- 画布支持 Ctrl/⌘+Z 撤销和 Ctrl/⌘+Shift+Z 重做。页面设置的输入框保留浏览器原生撤销。
- 选中按钮后可复制。在「属性」中选择纯色填充、线框、下划线或无样式,并选择是否在新标签页打开。首屏支持最多八个按钮。
- 在「网站页面 → 新建页面」选择普通页面、页头或页脚。三种页面共用同一个画布。页头页脚版式在「组件 → 页头/页脚」,也可添加封面、视频、文章等常规区块,或在页面设置中显示首屏。
- 在「网站页面 → 新建页面」选择普通页面、页头、页脚、维护页或 404 页。它们共用同一个画布。页头页脚版式在「组件 → 页头/页脚」,也可添加封面、视频、文章等常规区块,或在页面设置中显示首屏。页脚组件默认附带可编辑的 Powered by LaySite 链接。
- 新站点的「基础页头」和「基础页脚」已经设为站点默认,可在「网站页面」用画布编辑。也可将其他页头页脚设为站点默认,取消后会恢复相应的基础版式。普通页面各用一个下拉框选择隐藏、站点默认或指定方案。配色方案在「站点设计」管理。
- 媒体库和媒体选择器只列出用户上传文件。编辑器图标、示例资产、字体、模板缩略图和产品标识随程序发布。
- 发布后的站点具备独立标题、描述、canonical、Open Graph、站点地图和 robots.txt。可在「站点设置」配置站点名称和静态资源 CDN。
画布样式以白名单 CSS 类保存。间距与字号使用限定范围内的整数,服务端生成带版本指纹的样式表,画布和使用这些类的公开页按需加载。内容经过 HTML 清理,内联 `style` 属性会被移除。
### 维护页与 404 页
在「网站页面 → 新建页面」选择相应类型,在画布中编辑并发布。然后在「站点设置 → 系统页面」选用已发布的页面。
- 勾选「开启维护模式」后,公开页面和 API 会返回维护页,HTTP 状态码为 `503`。后台与预览和画布所需的资源继续可用。若把当前维护页改回草稿,维护模式会自动关闭。
- 选中的 404 页会在公开请求找不到内容时显示,HTTP 状态码仍为 `404`。留空选项或将所选页面改回草稿时使用系统 404 页。
- 维护页和 404 页通过后台预览,站点地图只列出可独立访问的公开页面。使用 CDN 或反代缓存时,应保留源站的状态码和 `Cache-Control`,并在切换维护模式时清理已缓存的公开页面。
### 会员页头
在页头画布的「组件 → 页头」添加「会员导航」,即可打开「会员登录设置」。将配置好的页头用作默认,或应用于需要登录的页面。
@@ -83,11 +91,13 @@ php start.php start
Agent 可以编辑草稿,管理员在画布里检查、细改及发布。草稿 HTML 使用与人工画布相同的 HTML 过滤器。按钮参数为 `[href, label, style, opensNewTab]`,样式可选 `solid`、`outline`、`underline`、`plain`。MCP 与站点发布共用 SQLite 和编辑器修订号。
仓库自带 [`laysite-mcp` Agent Skill](.agents/skills/laysite-mcp/SKILL.md),涵盖模板复用、设计规范、草稿修订和人工交接。使用支持 `.agents/skills/` 的客户端时,可在项目中调用该 Skill。其他支持 Agent Skills 的客户端可将整个 `laysite-mcp` 目录导入其技能目录。
## 站点备份与更新
「站点设计 → 站点备份」支持导出和确认后覆盖导入。备份包是包含版本化 JSON 清单和校验和的 TAR,包含页面、区块、文章、站点设置、布局、配色和媒体数据。管理员密码、OAuth 客户端密钥、运行环境密钥和登录会话由目标安装独立管理。导入到原站点时,身份提供商配置一致的同一套页头会保留客户端密钥。导入到新站点后,在对应会员页头重新填写。备份存放在站点公开目录外。
当前导出格式为 v3,导入兼容 v1 和 v2。导入 v2 后,原有页头和页脚会转换成共享页面,原有引用继续有效。遇到较新的不兼容格式时会提示升级。上传大小受 Webman 与外层代理限制,较大站点可使用 CLI。
当前导出格式为 v4,包含维护页、404 页和对应站点设置。导入兼容 v1 至 v3。导入 v2 后,原有页头和页脚会转换成共享页面,原有引用继续有效。遇到较新的不兼容格式时会提示升级。上传大小受 Webman 与外层代理限制,较大站点可使用 CLI。
```sh
php bin/backup.php export /srv/backups/laysite-2026-11.tar
@@ -105,6 +115,8 @@ bin/update.sh v1.1.0 /srv/backups/pre-update.tar
从 v1.1.0 更新画布功能时,更新脚本会添加样式字段,并将已有页头和页脚迁到「网站页面」,保留页面引用和已有认证配置。手动更新源码后,运行 `php bin/install.php` 再启动 Webman。
更新到 v1.3.0 时,SQLite 迁移会加入系统页面类型。升级后的站点可在「站点设置」选用维护页和 404 页。
## 生产反代
在 `.env` 配置 `LAYSITE_SITE_URL=https://example.com` 和 `LAYSITE_SECURE_COOKIES=1`。下列示例假定代理和 Webman 在同一主机。代理应以实际访客来源覆盖 `X-Real-IP`,并将项目文件、数据库和媒体存储保持在公开根目录之外。
+1 -1
View File
@@ -1 +1 @@
1.2.0
1.3.0
+18
View File
@@ -24,6 +24,7 @@ final class BlockTemplates
'tag' => ['徽标', '<p><span class="studio-badge">填写标签</span></p>'],
'large-number' => ['重点数字', '<p class="price-value">填写数字</p>'],
'definition-list' => ['术语说明', '<dl class="studio-definitions"><dt>填写术语</dt><dd>填写术语说明。</dd></dl>'],
'paired-label' => ['标签与数值', '<p class="studio-paired-label"><strong>开放时间</strong><span>周六 10:00–17:00</span></p>'],
]],
'link-elements' => ['链接与按钮', [
'button' => ['主按钮', '<p><a class="button button-primary" href="#contact">联系站点</a></p>'],
@@ -33,6 +34,7 @@ final class BlockTemplates
'breadcrumbs' => ['面包屑', '<p class="breadcrumbs"><a href="/">首页</a><span> / </span><span>当前页面</span></p>'],
'download-link' => ['下载入口', '<p><a class="button button-outline" href="/articles">查看下载</a></p>'],
'email-link' => ['邮件链接', '<p><a href="mailto:hello@example.com">发送邮件</a></p>'],
'phone-link' => ['电话链接', '<p><a href="tel:+8610000000000">致电咨询</a></p>'],
]],
'media-elements' => ['图片与影音', [
'image' => ['图片', '', 'image/'],
@@ -40,6 +42,7 @@ final class BlockTemplates
'audio' => ['音频', '', 'audio/'],
'qr-image' => ['二维码', '', 'image/'],
'image-link' => ['图片链接', '<p><a href="/"><img src="/assets/system/sample.webp" alt="版式示意" loading="lazy"></a></p>'],
'captioned-image' => ['带图注的图片', '<figure class="studio-captioned"><img src="/assets/system/sample.webp" alt="示例界面" loading="lazy"><figcaption>在这里注明图片内容或来源。</figcaption></figure>'],
]],
'structure-elements' => ['版式与数据', [
'separator' => ['分割线', '<hr class="studio-divider">'],
@@ -54,6 +57,7 @@ final class BlockTemplates
'empty-card' => ['空状态', '<div class="studio-empty"><h3>暂无内容</h3><p>填写访客可以执行的下一步。</p><a href="/articles">查看站点动态</a></div>'],
'status-note' => ['状态提示', '<div class="studio-notice studio-success-note"><p><strong>已完成</strong></p><p>填写操作结果或服务状态。</p></div>'],
'disclosure' => ['折叠内容', '<div class="faq"><details><summary>填写折叠标题</summary><div><p>填写展开后的内容。</p></div></details></div>'],
'numbered-step' => ['带编号的步骤', '<article class="studio-numbered-step"><span class="studio-badge">01</span><div><h3>准备资料</h3><p>写明进入下一步前需要准备的信息。</p></div></article>'],
]],
];
@@ -100,6 +104,20 @@ final class BlockTemplates
'resources' => ['资料与链接', '<ul class="studio-resources"><li><a href="/articles">浏览资料</a><span>应用下载</span></li><li><a href="/articles">浏览动态与文档</a><span>网站资源</span></li></ul>'],
'contact-card' => ['联系方式', '<div class="studio-contact"><div><h3>联系团队</h3><p>填写咨询范围与回复时间。</p></div><dl class="studio-definitions"><dt>电子邮件</dt><dd><a href="mailto:hello@example.com">hello@example.com</a></dd><dt>服务时间</dt><dd>填写工作时间</dd></dl></div>'],
]],
'events' => ['活动与场地', [
'event-agenda' => ['当日议程', '<ol class="studio-agenda"><li><p>09:30</p><div><h3>签到与开场</h3><p>开放入口并介绍当天安排。</p></div><span>主会场</span></li><li><p>10:30</p><div><h3>专题工作坊</h3><p>跟随主持人完成一次实践。</p></div><span>工作区</span></li><li><p>14:00</p><div><h3>圆桌交流</h3><p>分享实践经验并回答问题。</p></div><span>交流区</span></li></ol>'],
'speaker-lineup' => ['嘉宾阵容', '<div class="card-grid studio-speakers"><article class="content-card"><p class="overline">主题分享</p><h3>嘉宾姓名</h3><p>填写嘉宾的角色和主题。</p></article><article class="content-card"><p class="overline">工作坊</p><h3>主持人姓名</h3><p>介绍实践主题和适合的听众。</p></article><article class="content-card"><p class="overline">圆桌交流</p><h3>主持人姓名</h3><p>介绍本场将讨论的议题。</p></article></div>'],
'venue-guide' => ['到场指南', '<div class="studio-two-column"><article class="content-card"><h3>开放与入场</h3><p>填写开放时间、预约方式和入口位置。</p></article><article class="content-card"><h3>交通与无障碍</h3><p>填写推荐交通方式和无障碍通道位置。</p></article></div>'],
]],
'commerce' => ['商品与服务', [
'product-spotlight' => ['商品展示', '<div class="studio-split studio-product"><img src="/assets/system/sample.webp" alt="商品展示示例" loading="lazy"><div><p class="overline">系列名称</p><h3>填写商品名称</h3><p>说明规格、适用场景与供货信息。</p><a class="button button-primary" href="#contact">联系订购</a></div></div>'],
'product-specifications' => ['规格清单', '<dl class="studio-specifications"><div><dt>材质</dt><dd>填写材料及维护方式。</dd></div><div><dt>尺寸</dt><dd>标注尺寸与单位。</dd></div><div><dt>交付</dt><dd>说明交付时间及适用范围。</dd></div></dl>'],
'service-process' => ['服务流程', '<ol class="studio-process"><li><h3>沟通需求</h3><p>说明首次沟通需要提供哪些资料。</p></li><li><h3>确认方案</h3><p>列出范围、周期和交付计划。</p></li><li><h3>交付与支持</h3><p>介绍验收方式和后续跟进安排。</p></li></ol>'],
]],
'editorial' => ['专题与编辑部', [
'editorial-feature' => ['专题导读', '<div class="studio-editorial"><p class="overline">本期主题</p><blockquote><p>写下一句概括专题观点的话。</p></blockquote><div><p>用一段话交代来由,并指出读者可以从哪里开始。</p><a href="/articles">浏览文章</a></div></div>'],
'reading-path' => ['阅读路径', '<ol class="studio-agenda studio-reading"><li><p>01</p><div><h3><a href="/articles">从背景开始</a></h3><p>了解这组文章要解决的问题。</p></div></li><li><p>02</p><div><h3><a href="/articles">阅读主题文章</a></h3><p>按主题深入阅读,并查看相关材料。</p></div></li></ol>'],
]],
];
public static function groups(): array
+4 -1
View File
@@ -11,7 +11,7 @@ use Throwable;
final class Database
{
private const SCHEMA_VERSION = 5;
private const SCHEMA_VERSION = 6;
// Avoid reusing a deleted ID that may still be open in an editing form.
public const NEXT_ARTICLE_ID = 'MAX(COALESCE((SELECT MAX(id) FROM articles), 0),
COALESCE((SELECT MAX(article_id) FROM article_deletions), 0)) + 1';
@@ -89,6 +89,9 @@ final class Database
}
$pdo->exec('CREATE UNIQUE INDEX IF NOT EXISTS pages_layout_id ON pages(layout_id)');
}
if ($version < 6 && !in_array('page_type', array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name'), true)) {
$pdo->exec("ALTER TABLE pages ADD COLUMN page_type TEXT NOT NULL DEFAULT 'page' CHECK (page_type IN ('page', 'maintenance', 'not-found'))");
}
if ($version < 5) {
LayoutPage::migrate($pdo);
}
+10 -3
View File
@@ -10,10 +10,17 @@ final class PageDraft
{
public const RESERVED = ['admin', 'assets', 'home', 'account', 'mcp', 'palette'];
public static function slug(mixed $value, array $reserved = self::RESERVED, bool $includeLayouts = false): string
public static function slug(mixed $value, array $reserved = self::RESERVED, bool $includeSpecial = false): string
{
if ($includeLayouts && is_string($value) && preg_match('/^layout--(?:header|footer)-[1-9][0-9]{0,18}$/D', $value)) {
return $value;
if ($includeSpecial && is_string($value)) {
if (preg_match('/^layout--(?:header|footer)-[1-9][0-9]{0,18}$/D', $value)) {
return $value;
}
foreach (array_keys(SystemPage::TYPES) as $type) {
if (SystemPage::slugMatches($type, $value)) {
return $value;
}
}
}
if (!is_string($value) || strlen($value) > 70 || !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value)
|| in_array($value, $reserved, true)) {
+14 -10
View File
@@ -30,28 +30,28 @@ final class Repository
public function pages(bool $publishedOnly = false): array
{
$where = $publishedOnly ? " WHERE pages.status = 'published' AND pages.layout_id IS NULL" : '';
$where = $publishedOnly ? " WHERE pages.status = 'published' AND pages.layout_id IS NULL AND pages.page_type = 'page'" : '';
return $this->pdo->query('SELECT pages.slug, pages.name, pages.title, pages.updated_at, pages.status, pages.version, d.kind AS layout_kind
return $this->pdo->query('SELECT pages.slug, pages.name, pages.title, pages.updated_at, pages.status, pages.version, pages.page_type, d.kind AS layout_kind
FROM pages LEFT JOIN design_presets d ON pages.layout_id = d.id' . $where . ' ORDER BY pages.rowid')->fetchAll();
}
public function createPage(string $slug, string $name, array $template = []): void
public function createPage(string $slug, string $name, array $template = [], string $type = 'page'): void
{
Database::write(static fn (PDO $pdo) => self::insertPage($pdo, $slug, $name, $template));
Database::write(static fn (PDO $pdo) => self::insertPage($pdo, $slug, $name, $template, type: $type));
}
public static function insertPage(PDO $pdo, string $slug, string $name, array $template = [], ?int $layoutId = null): void
public static function insertPage(PDO $pdo, string $slug, string $name, array $template = [], ?int $layoutId = null, string $type = 'page'): void
{
$query = $pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
lead, image, alt, actions, quicklinks, theme, visibility, header_id, footer_id, palette_id, layout_id, status, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
lead, image, alt, actions, quicklinks, theme, visibility, header_id, footer_id, palette_id, layout_id, page_type, status, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$query->execute([
$slug, $name, $template['title'] ?? $name, $template['description'] ?? '', $template['heading'] ?? $name,
$template['accent'] ?? '', $template['lead'] ?? '', $template['image'] ?? '', $template['alt'] ?? '',
Database::json($template['actions'] ?? []), Database::json($template['quicklinks'] ?? []),
$template['theme'] ?? '', Database::json($template['visibility'] ?? []), $template['header_id'] ?? null,
$template['footer_id'] ?? null, $template['palette_id'] ?? null, $layoutId, $layoutId === null ? 'draft' : 'published', self::now(),
$template['footer_id'] ?? null, $template['palette_id'] ?? null, $layoutId, $type, $layoutId === null ? 'draft' : 'published', self::now(),
]);
if ($query->rowCount() !== 1) {
throw new RuntimeException('此页面地址已存在。');
@@ -98,7 +98,7 @@ final class Repository
$catalog = $feed['mode'] === 'catalog';
$grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1);
$archivePath = '/articles/feed/' . $page['slug'] . '/' . $section['key'];
$section['archivePath'] = empty($page['layout_kind']) && $page['status'] === 'published' ? $archivePath : null;
$section['archivePath'] = empty($page['layout_kind']) && ($page['page_type'] ?? 'page') === 'page' && $page['status'] === 'published' ? $archivePath : null;
$section['articleFeed'] = [];
$section['networkFeed'] = $network;
$section['catalogFeed'] = $catalog;
@@ -125,7 +125,8 @@ final class Repository
{
return $this->one("SELECT sections.title, sections.feed FROM sections
JOIN pages ON pages.slug = sections.page_slug
WHERE pages.slug = ? AND pages.status = 'published' AND pages.layout_id IS NULL AND sections.key = ? AND sections.feed IS NOT NULL", [$page, $key]);
WHERE pages.slug = ? AND pages.status = 'published' AND pages.layout_id IS NULL AND pages.page_type = 'page'
AND sections.key = ? AND sections.feed IS NOT NULL", [$page, $key]);
}
public function savePage(string $slug, array $data, int $version, array $sections = [], bool $replaceDraftSections = false, ?array $sectionOrder = null): void
@@ -140,6 +141,9 @@ final class Repository
isset($data['presentation']) ? CanvasStyle::encode($data['presentation']) : null, $slug, $version,
]);
self::checkVersion($query->rowCount());
if ($data['status'] === 'draft' && str_starts_with($slug, 'system--')) {
SiteDesign::unsetSystemPage($pdo, $slug);
}
if ($replaceDraftSections) {
$pdo->prepare('DELETE FROM sections WHERE page_slug = ?')->execute([$slug]);
}
+25 -4
View File
@@ -12,7 +12,7 @@ use Throwable;
final class SiteBackup
{
private const FORMAT = 'laysite-site';
private const VERSION = 3;
private const VERSION = 4;
private const TABLES = [
'site_settings', 'design_presets', 'pages', 'sections', 'article_categories', 'articles',
'article_category_links', 'article_redirects', 'article_deletions', 'media',
@@ -140,7 +140,7 @@ final class SiteBackup
private static function prepare(mixed $manifest): array
{
if (!is_array($manifest) || ($manifest['format'] ?? '') !== self::FORMAT
|| !in_array($manifest['version'] ?? null, [1, 2, self::VERSION], true) || !is_array($manifest['tables'] ?? null)) {
|| !in_array($manifest['version'] ?? null, [1, 2, 3, self::VERSION], true) || !is_array($manifest['tables'] ?? null)) {
throw new RuntimeException('备份格式不受支持,请使用相同或更新版本的 LaySite。');
}
$tables = $manifest['tables'];
@@ -184,10 +184,18 @@ final class SiteBackup
$site['layout_defaults'][$kind] = self::selection($designs, $kind, $layoutDefaults[$kind]);
}
}
$tables['site_settings'] = [['id' => 1, 'payload' => Database::json($site)]];
$publishedSystemPages = [];
foreach ($tables['pages'] as &$row) {
$layout = $row['layout_id'] ?? null;
if ($layout === null) {
$row['page_type'] ??= 'page';
if ($row['page_type'] !== 'page') {
if ($layout !== null || !is_string($row['page_type']) || !SystemPage::slugMatches($row['page_type'], $row['slug'] ?? null)) {
throw new RuntimeException('备份包含无效的系统页面。');
}
if (($row['status'] ?? null) === 'published') {
$publishedSystemPages[$row['slug']] = $row['page_type'];
}
} elseif ($layout === null) {
PageDraft::slug($row['slug'] ?? null, array_diff(PageDraft::RESERVED, ['home']));
} else {
$kind = is_int($layout) ? ($designs[$layout] ?? null) : null;
@@ -210,6 +218,19 @@ final class SiteBackup
}
}
unset($row);
$systemPages = $settings['system_pages'] ?? [];
$maintenance = $settings['maintenance_enabled'] ?? false;
if (!is_array($systemPages) || !is_bool($maintenance) || ($maintenance && !isset($systemPages['maintenance']))) {
throw new RuntimeException('备份包含无效的系统页面设置。');
}
foreach ($systemPages as $type => $slug) {
if (!is_string($slug) || ($publishedSystemPages[$slug] ?? null) !== $type) {
throw new RuntimeException('备份引用了缺失或未发布的系统页面。');
}
}
$site['system_pages'] = $systemPages;
$site['maintenance_enabled'] = $maintenance;
$tables['site_settings'] = [['id' => 1, 'payload' => Database::json($site)]];
foreach ($tables['sections'] as &$row) {
PageDraft::slug($row['key'] ?? null, ['home', 'contact', 'main-content', 'primary-navigation', 'preview']);
if (!in_array($row['style'] ?? '', ['plain', 'tinted', 'hero-links', 'layout'], true)) {
+28 -2
View File
@@ -31,17 +31,43 @@ final class SiteDesign
return implode("\n", array_map(static fn (array $link): string => $link[1] . ' | ' . $link[0], $links));
}
public static function saveGeneral(string $name, string $origin, int $version): void
public static function saveGeneral(string $name, string $origin, int $version, array $systemPages, bool $maintenance): void
{
Database::write(function (PDO $pdo) use ($name, $origin, $version): void {
Database::write(function (PDO $pdo) use ($name, $origin, $version, $systemPages, $maintenance): void {
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
if (($site['revisions']['general'] ?? 0) !== $version) {
throw new RuntimeException('站点设置已更新,请重新打开后再保存。');
}
$repo = new Repository();
foreach ($systemPages as $type => $slug) {
if (!SystemPage::published($repo, $type, $slug)) {
throw new RuntimeException('请选择已发布的' . SystemPage::TYPES[$type] . '。');
}
}
if ($maintenance && !isset($systemPages['maintenance'])) {
throw new RuntimeException('请先发布并选择维护页,再开启维护模式。');
}
$site['name'] = $name;
$site['cdn'] = ['origin' => $origin];
$site['system_pages'] = $systemPages;
$site['maintenance_enabled'] = $maintenance;
$site['revisions']['general'] = $version + 1;
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
});
}
public static function unsetSystemPage(PDO $pdo, string $slug): void
{
$site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
$type = array_search($slug, $site['system_pages'] ?? [], true);
if ($type === false) {
return;
}
unset($site['system_pages'][$type]);
if ($type === 'maintenance') {
$site['maintenance_enabled'] = false;
}
$site['revisions']['general'] = ($site['revisions']['general'] ?? 0) + 1;
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace App\Content;
final class SystemPage
{
public const TYPES = ['maintenance' => '维护页', 'not-found' => '404 页'];
public static function slugMatches(string $type, mixed $slug): bool
{
return isset(self::TYPES[$type]) && is_string($slug)
&& preg_match('/^system--' . $type . '-[a-f0-9]{16}$/D', $slug) === 1;
}
public static function published(Repository $repo, string $type, mixed $slug): ?array
{
if (!self::slugMatches($type, $slug)) {
return null;
}
$page = $repo->page($slug);
return $page && $page['page_type'] === $type && $page['status'] === 'published' ? $page : null;
}
}
+1 -1
View File
@@ -323,7 +323,7 @@ class AdminController
$data['quicklinks'] = $request->post('quicklinks') === null ? $page['quicklinks'] : SiteDesign::parseLinks($this->input($request, 'quicklinks'));
if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
|| $data['title'] === '' || mb_strlen($data['title']) > 160 ||
(!$layout && $data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
(!$layout && $page['page_type'] === 'page' && $data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
(($data['visibility']['hero'] ?? true) && $data['heading'] === '') || mb_strlen($data['heading'] . $data['accent']) > 110 ||
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
($data['image_scale'] !== 0 && ($data['image_scale'] < 10 || $data['image_scale'] > 100)) ||
+19 -2
View File
@@ -9,6 +9,7 @@ use App\Content\DesignFieldError;
use App\Content\DesignLibrary;
use App\Content\Repository;
use App\Content\SiteDesign;
use App\Content\SystemPage;
use App\Http\Request;
use RuntimeException;
use support\Response;
@@ -76,10 +77,13 @@ final class DesignController extends AdminController
if ($failure = $this->guard($request)) {
return $failure;
}
$site = (new Repository())->site();
$repo = new Repository();
$site = $repo->site();
$error = '';
$name = $site['name'];
$cdn = $site['cdn']['origin'] ?? '';
$systemPages = $site['system_pages'] ?? [];
$maintenance = $site['maintenance_enabled'] ?? false;
$version = (int) ($site['revisions']['general'] ?? 0);
if ($request->method() === 'POST') {
try {
@@ -88,7 +92,12 @@ final class DesignController extends AdminController
if ($name === '' || mb_strlen($name) > 100) {
throw new RuntimeException('站点名称必须为 1 至 100 个字符。');
}
SiteDesign::saveGeneral($name, $cdn, $this->version($request));
$systemPages = array_filter([
'maintenance' => $this->input($request, 'maintenance_page'),
'not-found' => $this->input($request, 'not_found_page'),
], static fn (string $slug): bool => $slug !== '');
$maintenance = $request->post('maintenance_enabled') === '1';
SiteDesign::saveGeneral($name, $cdn, $this->version($request), $systemPages, $maintenance);
return $this->success($request, '/admin/settings?saved=1');
} catch (RuntimeException $ex) {
@@ -96,8 +105,16 @@ final class DesignController extends AdminController
}
}
$systemChoices = [];
foreach ($repo->pages() as $page) {
$type = $page['page_type'];
if (isset(SystemPage::TYPES[$type]) && $page['status'] === 'published') {
$systemChoices[$type][$page['slug']] = $page['name'];
}
}
return $this->render($request, 'studio-settings', [
'title' => '站点设置', 'name' => $name, 'cdn' => $cdn, 'version' => $version, 'error' => $error,
'systemPages' => $systemPages, 'systemChoices' => $systemChoices, 'maintenance' => $maintenance,
'saved' => $request->get('saved') === '1',
], $error === '' ? 200 : 422);
}
+1 -1
View File
@@ -122,7 +122,7 @@ final class McpController
try {
$data = match ($name) {
'list_pages' => $repo->pages(),
'get_page' => $this->read($repo, PageDraft::slug($args['slug'] ?? null, [], includeLayouts: true)),
'get_page' => $this->read($repo, PageDraft::slug($args['slug'] ?? null, [], includeSpecial: true)),
'list_templates' => $this->templates(),
'list_designs' => DesignLibrary::all(),
'create_draft' => $this->create($repo, $args),
+6 -5
View File
@@ -25,7 +25,8 @@ final class SiteController
{
$repo = new Repository();
$page = $repo->page($slug);
if (!$page || $page['layout_kind'] !== null || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
if (!$page || $page['layout_kind'] !== null || $page['page_type'] !== 'page'
|| $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
return $this->missing($request);
}
if ($slug === 'articles' && $request->get('page') !== null) {
@@ -41,7 +42,7 @@ final class SiteController
return $this->renderPage($repo, $page);
}
public function renderPage(Repository $repo, array $page, bool $preview = false, bool $canvas = false): Response
public function renderPage(Repository $repo, array $page, bool $preview = false, bool $canvas = false, int $status = 200): Response
{
$slug = $page['slug'];
$isHome = $slug === 'home';
@@ -51,13 +52,13 @@ final class SiteController
return View::render('page', [
'site' => $repo->site(),
'page' => $page,
'path' => $isHome ? '/' : '/' . $slug,
'path' => ($page['page_type'] ?? 'page') !== 'page' ? null : ($isHome ? '/' : '/' . $slug),
'title' => $page['title'],
'description' => $page['description'],
'socialImage' => $showHero ? $page['image'] : '',
'socialAlt' => $showHero ? $page['alt'] : '',
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
]);
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview || $status >= 400,
], $status);
}
public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
+19 -3
View File
@@ -12,6 +12,7 @@ use App\Content\Media;
use App\Content\PageDraft;
use App\Content\PageTemplates;
use App\Content\Repository;
use App\Content\SystemPage;
use App\Http\Request;
use RuntimeException;
use support\Response;
@@ -24,21 +25,36 @@ final class StudioController extends AdminController
if ($failure = $this->guard($request)) {
return $failure;
}
$types = LayoutPage::TYPES + SystemPage::TYPES;
$type = $request->get('type');
$data = [
'title' => '新建页面', 'name' => '', 'slug' => '', 'error' => '', 'pageTemplateDrawer' => true,
'openTemplates' => $request->get('templates') === '1',
'type' => is_string($type) && isset(LayoutPage::TYPES[$type]) ? $type : 'page',
'type' => is_string($type) && isset($types[$type]) ? $type : 'page',
'types' => $types,
];
if ($request->method() === 'POST') {
$data['name'] = $this->input($request, 'name');
$data['slug'] = $this->input($request, 'slug');
$data['type'] = $request->post('type') === null ? 'page' : $this->input($request, 'type');
try {
if (!isset(LayoutPage::TYPES[$data['type']]) || $data['name'] === '' || mb_strlen($data['name']) > 100) {
if (!isset($types[$data['type']]) || $data['name'] === '' || mb_strlen($data['name']) > 100) {
throw new RuntimeException('请填写页面名称并选择页面类型。');
}
if ($data['type'] !== 'page') {
if (isset(SystemPage::TYPES[$data['type']])) {
$type = $data['type'];
$slug = 'system--' . $type . '-' . bin2hex(random_bytes(8));
$maintenance = $type === 'maintenance';
(new Repository())->createPage($slug, $data['name'], [
'heading' => $maintenance ? '站点维护中' : '页面未找到',
'lead' => $maintenance ? '我们正在维护站点,请稍后再访问。' : '你访问的页面可能已移动或删除。',
'actions' => $maintenance ? [] : [['/', '返回首页', 'solid', false]],
'visibility' => $maintenance ? ['header' => false, 'footer' => false] : [],
], $type);
return $this->success($request, '/admin/pages/' . $slug);
}
if (in_array($data['type'], ['header', 'footer'], true)) {
$slug = LayoutPage::create($data['type'], $data['name']);
return $this->success($request, '/admin/pages/' . $slug);
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace App\Middleware;
use App\Content\Repository;
use App\Content\SystemPage;
use App\Controller\SiteController;
use Webman\Http\Request;
use Webman\Http\Response;
use Webman\MiddlewareInterface;
final class SiteStatus implements MiddlewareInterface
{
public function process(Request $request, callable $handler): Response
{
$path = $request->path();
if ($path === '/admin' || str_starts_with($path, '/admin/')) {
return $handler($request);
}
$repo = new Repository();
$site = $repo->site();
$controller = new SiteController();
$pages = $site['system_pages'] ?? [];
if (!empty($site['maintenance_enabled']) && ($page = SystemPage::published($repo, 'maintenance', $pages['maintenance'] ?? null))) {
// Media and styles must remain available for the maintenance page and the admin canvas.
if (in_array($request->method(), ['GET', 'HEAD'], true)
&& preg_match('~^/(?:assets/uploads/[a-f0-9]{32}\.[a-z0-9]+|palette/[0-9]+\.css|canvas-style\.css|favicon\.ico)$~D', $path)) {
$asset = $handler($request);
if ($asset->getStatusCode() !== 404) {
return $asset;
}
}
return $controller->renderPage($repo, $page, status: 503)->withHeader('Cache-Control', 'no-store');
}
$response = $handler($request);
if ($response->getStatusCode() === 404 && ($page = SystemPage::published($repo, 'not-found', $pages['not-found'] ?? null))) {
return $controller->renderPage($repo, $page, status: 404)->withHeader('Cache-Control', 'no-store');
}
return $response;
}
}
+19 -9
View File
@@ -1,9 +1,10 @@
<?php
use App\Content\LayoutPage;
use App\Content\SystemPage;
use App\Content\View;
$e = View::escape(...);
$regular = array_filter($pages, static fn (array $page): bool => $page['layout_kind'] === null);
$regular = array_filter($pages, static fn (array $page): bool => $page['layout_kind'] === null && $page['page_type'] === 'page');
$live = count(array_filter($regular, static fn (array $page): bool => $page['status'] === 'published'));
$defaultSlugs = [];
foreach (['header', 'footer'] as $kind) {
@@ -24,31 +25,40 @@ foreach (['header', 'footer'] as $kind) {
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
<div class="admin-heading compact">
<h2 id="pages-title">网站页面</h2>
<p class="field-note"><?= $live ?> 个已发布 · <?= count($regular) - $live ?> 个草稿 · <?= count($pages) - count($regular) ?> 个页头页脚</p>
<p class="field-note"><?= $live ?> 个已发布 · <?= count($regular) - $live ?> 个草稿 · <?= count($pages) - count($regular) ?> 个特殊页面</p>
</div>
<div class="dashboard-filters" data-page-filters hidden>
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
<label>发布状态<select data-page-status>
<option value="">全部状态</option>
<label>状态或类型<select data-page-status>
<option value="">全部页面</option>
<option value="published">已发布</option>
<option value="draft">草稿</option>
<option value="header">页头</option>
<option value="footer">页脚</option>
<?php foreach (SystemPage::TYPES as $type => $label): ?><option value="<?= $e($type) ?>"><?= $e($label) ?></option><?php endforeach ?>
</select></label>
</div>
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
<ul class="admin-list dashboard-page-list">
<?php foreach ($pages as $page): ?>
<?php $kind = $page['layout_kind']; $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $kind === null && $page['status'] === 'published'; ?>
<li data-page-item="<?= $e($kind ?? $page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . ($kind ? LayoutPage::TYPES[$kind] : $path)) ?>">
<?php
$type = $page['page_type'];
$kind = $page['layout_kind'] ?? (isset(SystemPage::TYPES[$type]) ? $type : null);
$label = (LayoutPage::TYPES + SystemPage::TYPES)[$kind] ?? '';
$path = $page['slug'] === 'home' ? '/' : '/' . $page['slug'];
$published = $page['status'] === 'published';
$public = $kind === null && $published;
?>
<li data-page-item="<?= $e($kind ?? $page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . ($kind ? $label : $path)) ?>">
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong>
<?php if (!$kind): ?><small><?= $e($path) ?></small>
<?php elseif (($defaultSlugs[$kind] ?? null) === $page['slug']): ?><small>站点默认</small><?php endif ?>
<?php elseif (($defaultSlugs[$kind] ?? null) === $page['slug']): ?><small>站点默认</small>
<?php elseif (($site['system_pages'][$kind] ?? null) === $page['slug']): ?><small><?= $kind === 'maintenance' ? ($site['maintenance_enabled'] ? '维护模式已开启' : '已选作维护页') : '已启用为 404 页' ?></small><?php endif ?>
</div>
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $kind ? $e(LayoutPage::TYPES[$kind]) : ($published ? '已发布' : '草稿') ?></span>
<span class="dashboard-page-state" data-published="<?= !$page['layout_kind'] && $published ? 'true' : 'false' ?>"><?= $kind ? $e($label) : ($published ? '已发布' : '草稿') ?><?= isset(SystemPage::TYPES[$type]) ? ($published ? ' · 已发布' : ' · 草稿') : '' ?></span>
<div class="dashboard-page-actions">
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
<a href="<?= $e($published ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $published ? '查看' : '预览' ?></a>
<a href="<?= $e($public ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $public ? '查看' : '预览' ?></a>
</div>
</li>
<?php endforeach ?>
+1
View File
@@ -66,6 +66,7 @@ $active = match (true) {
</div>
</header>
<main class="admin-wrap admin-main<?= !empty($wideAdmin) ? ' admin-wide' : '' ?>" id="admin-content"><?= $content ?></main>
<footer class="admin-wrap admin-version">LaySite ver <?= $e(trim(file_get_contents(dirname(__DIR__, 2) . '/VERSION'))) ?></footer>
<?php if ($user): ?>
<dialog class="media-picker" id="media-picker" aria-labelledby="picker-heading">
<header class="admin-heading compact"><h2 id="picker-heading">从媒体库选择</h2><button class="button button-outline" type="button" data-close-picker>关闭</button></header>
+5 -2
View File
@@ -4,18 +4,20 @@ use App\Content\CanvasStyle;
use App\Content\Database;
use App\Content\LayoutPage;
use App\Content\SiteDesign;
use App\Content\SystemPage;
use App\Content\View;
$e = View::escape(...);
$slug = $page['slug'];
$path = $slug === 'home' ? '/' : '/' . $slug;
$previewUrl = '/admin/pages/' . $slug . '/preview';
$systemLabel = SystemPage::TYPES[$page['page_type']] ?? null;
?>
<a class="back-link" href="/admin">返回页面</a>
<header class="admin-heading">
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta">
<?php if ($layout): ?><span class="dashboard-page-state"><?= $e(LayoutPage::TYPES[$layout['kind']]) ?></span>
<?php else: ?><code><?= $e($path) ?></code><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
<?php else: ?><?php if ($systemLabel): ?><span><?= $e($systemLabel) ?></span><?php else: ?><code><?= $e($path) ?></code><?php endif ?><span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span><?php endif ?>
</p></div>
<div class="actions">
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
@@ -26,7 +28,8 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
href="<?= $id ? '/admin/pages/' . $e(LayoutPage::slug($kind, $id)) : '/admin/new-page?type=' . $e($kind) ?>" target="_blank" rel="noopener"<?= !($page['visibility'][$kind] ?? true) ? ' hidden' : '' ?>><?= $e($label) ?></a>
<?php endforeach ?>
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
<?php if ($systemLabel): ?><a class="button button-outline" href="/admin/settings">站点设置</a>
<?php elseif ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
<?php endif ?>
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
</div>
+1
View File
@@ -22,5 +22,6 @@ $brand = $data['brand'] ?: $site['name'];
<small><?= $e($data['legal']) ?></small>
<?php endif ?>
<?php endforeach ?>
<small class="site-footer-credit">Powered by <a href="https://laysense.cn/laysite">LaySite</a></small>
</div>
</footer>
+2 -1
View File
@@ -6,6 +6,7 @@ use App\Content\View;
$e = View::escape(...);
$home = $page['slug'] === 'home';
$shared = !empty($page['layout_kind']);
$system = ($page['page_type'] ?? 'page') !== 'page';
$showHero = $page['visibility']['hero'] ?? true;
$heroLinks = array_filter($page['sections'], static fn (array $section): bool => $section['style'] === 'hero-links');
$alignments = $page['alignments'];
@@ -22,7 +23,7 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
<?php if ($showHero || $canvas): ?>
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>"<?= $canvas ? ' data-studio-hero-content' : '' ?><?= $showHero ? '' : ' hidden' ?>>
<div class="hero-copy">
<?php if (!$home && !$shared): ?>
<?php if (!$home && !$shared && !$system): ?>
<nav class="breadcrumbs" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList">
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/"><span itemprop="name">首页</span></a>
+1 -2
View File
@@ -1,5 +1,4 @@
<?php
use App\Content\LayoutPage;
use App\Content\View;
$e = View::escape(...);
@@ -13,7 +12,7 @@ $e = View::escape(...);
<form class="admin-form admin-panel" method="post" action="/admin/new-page">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<label>页面类型<select name="type" data-new-page-type>
<?php foreach (LayoutPage::TYPES as $value => $label): ?>
<?php foreach ($types as $value => $label): ?>
<option value="<?= $e($value) ?>" <?= $type === $value ? 'selected' : '' ?>><?= $e($label) ?></option>
<?php endforeach ?>
</select></label>
+16
View File
@@ -11,5 +11,21 @@ $e = View::escape(...);
<input type="hidden" name="version" value="<?= $e($version) ?>">
<label>站点名称<input name="name" value="<?= $e($name) ?>" maxlength="100" required></label>
<label>静态资源 CDN<input name="cdn" value="<?= $e($cdn) ?>" placeholder="https://cdn.example.com"><small>填写后,公开页面的 /assets/ 文件从该地址加载。</small></label>
<fieldset class="settings-stack">
<legend>系统页面</legend>
<?php foreach (['maintenance' => ['maintenance_page', '维护页', '选择已发布的维护页'], 'not-found' => ['not_found_page', '404 页', '使用系统 404 页']] as $type => [$field, $label, $placeholder]): ?>
<label><?= $e($label) ?><select name="<?= $e($field) ?>">
<option value=""><?= $e($placeholder) ?></option>
<?php foreach ($systemChoices[$type] ?? [] as $slug => $name): ?>
<option value="<?= $e($slug) ?>"<?= ($systemPages[$type] ?? null) === $slug ? ' selected' : '' ?>><?= $e($name) ?></option>
<?php endforeach ?>
</select></label>
<?php if (empty($systemChoices[$type])): ?>
<a class="back-link" href="/admin/new-page?type=<?= $e($type) ?>">新建<?= $e($label) ?></a>
<?php endif ?>
<?php endforeach ?>
<label><input type="checkbox" name="maintenance_enabled" value="1"<?= $maintenance ? ' checked' : '' ?>> 开启维护模式</label>
<p class="field-note">开启后,访客会看到维护页。后台仍可登录和编辑。</p>
</fieldset>
<button type="submit" class="button button-primary">保存设置</button>
</form>
+3
View File
@@ -0,0 +1,3 @@
<?php
return ['' => [App\Middleware\SiteStatus::class]];
+2 -1
View File
@@ -8,6 +8,7 @@ use App\Controller\SiteController;
use App\Controller\StudioController;
use App\Controller\MediaController;
use App\Controller\McpController;
use App\Middleware\SiteStatus;
use support\Request;
use Webman\Route;
@@ -57,4 +58,4 @@ Route::post('/admin/preview', [AdminController::class, 'preview']);
Route::get('/{slug:[a-z0-9-]+}', [SiteController::class, 'page']);
Route::fallback(static fn (Request $request) => (new SiteController())->missing($request));
Route::fallback(static fn (Request $request) => (new SiteStatus())->process($request, [new SiteController(), 'missing']));
+3 -1
View File
@@ -1,10 +1,12 @@
.admin-body { background: var(--paper); min-height: 100vh; }
.admin-body { background: var(--paper); min-height: 100vh; display: flex; flex-direction: column; }
.admin-wrap { width: min(calc(100% - 2rem), 67rem); margin-inline: auto; }
.admin-bar { background: var(--white); border-bottom: 1px solid var(--line); }
.admin-bar-inner, .admin-bar nav { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.15rem; }
.admin-bar-inner { justify-content: space-between; min-height: 4.5rem; padding-block: .45rem; }
.admin-bar nav > a { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none; font-weight: 550; }
.admin-main { padding-block: clamp(1.65rem, 4vw, 3.25rem); }
.admin-version { margin-block-start: auto; padding-block: 1rem; border-block-start: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.settings-stack { display: grid; gap: .9rem; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .65rem; min-inline-size: 0; }
.admin-main h1 { font-size: clamp(2rem, 4vw, 3.1rem); margin: 0; }
.admin-main h2 { font-size: 1.38rem; margin-bottom: 1rem; }
.admin-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; margin: 0 0 1.2rem; }
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

+56
View File
@@ -170,3 +170,59 @@
.theme-furrow .app-frame img { border-radius: .15rem; }
.theme-furrow .button { border-radius: .2rem; }
.theme-furrow .button-outline { border-color: #908764; background: var(--white); }
.page-theme:is(.theme-gather, .theme-market, .theme-dispatch) { --space-section: clamp(3rem, 5vw, 5.25rem); }
.page-theme:is(.theme-gather, .theme-market, .theme-dispatch) .hero-inner { min-height: clamp(23rem, 36vw, 35rem); }
.theme-gather {
--white: #fffcf5;
--paper: #f6efd9;
--ink: #30281d;
--muted: #625540;
--line: #d7c9ae;
--accent: #944022;
--accent-deep: #692714;
--accent-light: #f2dfc5;
}
.theme-gather .hero {
background: radial-gradient(circle at 88% 75%, #f6bd53 0 18%, transparent 18.15%),
radial-gradient(circle at 100% 78%, #ffd98d 0 32%, transparent 32.15%), var(--paper);
}
.theme-gather .button { border-radius: 2rem; }
.theme-market {
--white: #fcfdfb;
--paper: #eaf1e9;
--ink: #172923;
--muted: #465f55;
--line: #bdcec4;
--accent: #235d48;
--accent-deep: #163d2d;
--accent-light: #d9eadf;
}
.theme-market .hero {
background: linear-gradient(125deg, var(--paper) 0 59%, #d7e8dd 59% 76%, #c6ded0 76%);
}
.theme-market .app-frame { padding: .5rem; border: 1px solid #557669; background: var(--white); border-radius: .6rem; }
.theme-market .app-frame img { border-radius: .3rem; }
.theme-market .button { border-radius: .3rem; }
.theme-dispatch {
--white: #fdfaf8;
--paper: #f1eae7;
--ink: #291c28;
--muted: #655460;
--line: #ccbfc5;
--accent: #783849;
--accent-deep: #542136;
--accent-light: #f1dde4;
}
.theme-dispatch .hero { background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), #d8cbd0 calc(25% - 1px) 25%), var(--paper); }
.theme-dispatch .hero-copy { padding: 1.5rem; background: var(--paper); border-block: 1px solid var(--line); }
.theme-dispatch :is(h1, h2, h3) { font-family: 'Noto Serif CJK SC', 'Songti SC', Georgia, serif; }
.theme-dispatch .button { border-radius: 0; }
@media (max-width: 40rem) {
.theme-gather .hero { background: var(--paper); }
.theme-dispatch .hero-copy { padding-inline: .8rem; }
}
+48
View File
@@ -637,6 +637,54 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.site-footer-band .site-footer-nav a:hover { color: var(--ink); }
.site-footer-text { max-width: 48ch; white-space: pre-line; margin: 0; }
.site-footer-nav { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.site-footer-credit { color: var(--muted); font-size: .875rem; }
.site-footer-credit a { color: inherit; text-underline-offset: .18em; }
.site-footer-columns .site-footer-credit { grid-column: 1 / -1; }
.rich .studio-agenda, .rich .studio-process { padding: 0; margin: 0; list-style: none; }
.studio-agenda li {
display: grid;
grid-template-columns: 5rem minmax(0, 1fr) auto;
align-items: baseline;
gap: .45rem 1rem;
border-top: 1px solid var(--line);
padding-block: 1.1rem;
}
.studio-agenda li:last-child { border-bottom: 1px solid var(--line); }
.studio-agenda li > p { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 650; }
.studio-agenda li > span { color: var(--muted); font-size: .875rem; }
.studio-agenda :is(h3, p), .studio-process :is(h3, p), .studio-numbered-step :is(h3, p) { margin: 0; }
.studio-agenda h3, .studio-process h3, .studio-numbered-step h3 { margin-bottom: .3rem; }
.studio-speakers .overline, .studio-product .overline { margin-bottom: .85rem; }
.studio-specifications { margin: 0; border-top: 1px solid var(--line); }
.studio-specifications div {
display: grid;
grid-template-columns: minmax(4.5rem, 1fr) 3fr;
gap: .65rem 1rem;
border-bottom: 1px solid var(--line);
padding-block: .9rem;
}
.studio-specifications dt { font-weight: 650; }
.studio-specifications dd { margin: 0; color: var(--muted); }
.studio-process { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(14rem, 100%), 1fr)); gap: 1rem; counter-reset: studio-step; }
.studio-process li { border-top: 2px solid var(--accent); padding: 1.1rem; background: var(--paper); counter-increment: studio-step; }
.studio-process li::before { content: counter(studio-step, decimal-leading-zero); display: block; margin-bottom: .65rem; color: var(--accent); font-weight: 650; }
.studio-editorial { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); gap: .75rem 2rem; border-top: 2px solid var(--ink); padding-top: 1rem; }
.studio-editorial .overline { grid-column: 1 / -1; margin: 0; }
.studio-editorial blockquote { margin: 0; }
.studio-editorial blockquote p { margin: 0; font-size: clamp(1.35rem, 2.7vw, 2.35rem); font-weight: 620; }
.studio-editorial > div p { margin: 0 0 .6rem; }
.studio-reading li { grid-template-columns: 3rem minmax(0, 1fr); }
.studio-paired-label, .studio-numbered-step { display: flex; align-items: baseline; gap: .75rem; }
.studio-paired-label { justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: .6rem; }
.studio-captioned { margin: 0; }
.studio-captioned figcaption { margin-top: .55rem; color: var(--muted); font-size: .875rem; }
@media (max-width: 38rem) {
.studio-agenda li { grid-template-columns: 3.5rem minmax(0, 1fr); }
.studio-agenda li > span { grid-column: 2; }
.studio-editorial { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 44rem) {
.masthead .menu-toggle { margin-inline-start: auto; }
.masthead .primary-nav { order: 10; width: 100%; }
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

+48
View File
@@ -78,4 +78,52 @@ foreach ($themes as $theme => [$name, $description, $templates]) {
$groups[$theme] = compact('name', 'description', 'pages');
}
$suites = [
'gather' => ['Gather · 会场', '暖黄封面与平铺议程,适合会议、工作坊和展览。', [
'gather-conference' => ['会议与工作坊', '留一天,和同行动手做。', '汇总会议议程、嘉宾及到场信息。', [
['agenda', '当日议程', 'event-agenda'], ['speakers', '分享嘉宾', 'speaker-lineup'], ['venue', '如何到场', 'venue-guide'],
]],
'gather-exhibition' => ['展览导览', '用一个下午,走进你的展厅。', '呈现展览主题、参观方式和现场活动。', [
['exhibition', '展览主题', 'editorial-feature'], ['venue', '参观信息', 'venue-guide'], ['sessions', '现场活动', 'event-agenda'],
]],
]],
'market' => ['Market · 商店', '霜绿与墨色,适合商品详情和服务预约。', [
'market-product' => ['商品详情', '把材料和细节讲清楚。', '展示商品及规格,提供咨询和订购入口。', [
['product', '精选商品', 'product-spotlight'], ['specifications', '规格与交付', 'product-specifications'], ['get-in-touch', '订购咨询', 'contact-card'],
]],
'market-service' => ['服务预约', '从第一次沟通到完成交付。', '帮助客户了解服务流程、方案和咨询方式。', [
['process', '服务流程', 'service-process'], ['plans', '选择服务方案', 'pricing'], ['get-in-touch', '预约咨询', 'contact-card'],
]],
]],
'dispatch' => ['Dispatch · 编辑部', '高对比衬线标题和细分隔线,适合专题报道与刊物。', [
'dispatch-feature' => ['专题报道', '围绕一个问题,读得更深。', '把导读、相关报道和延伸资料串成一条路径。', [
['feature', '本期导读', 'editorial-feature'], ['reading', '按顺序阅读', 'reading-path'], ['resources', '延伸资料', 'resources'],
]],
'dispatch-magazine' => ['刊物首页', '把新一期放到读者面前。', '集中呈现最新文章、编辑说明和联系入口。', [
['issue', '最新文章', 'articles'], ['editors', '编辑手记', 'editorial-feature'], ['get-in-touch', '联系编辑部', 'contact-card'],
]],
]],
];
foreach ($suites as $theme => [$name, $description, $templates]) {
$pages = [];
foreach ($templates as $key => [$label, $heading, $lead, $blocks]) {
$sections = [];
foreach ($blocks as $index => [$anchor, $title, $component]) {
$block = BlockTemplates::find($component);
$body = $theme === 'market'
? str_replace(['href="#contact"', 'href="/#contact"'], 'href="#get-in-touch"', $block[1])
: $block[1];
$sections[] = [$anchor, $title, $index % 2 ? 'tinted' : 'plain', $body, $block[3] ?? null];
}
$visual = $key === 'market-product';
$pages[$key] = [
'name' => $label, 'heading' => $heading, 'description' => $lead,
'image' => $visual ? $sample : '', 'alt' => $visual ? '商品展示版式示例' : '',
'actions' => [['#' . $sections[0][0], '查看' . $sections[0][1], 'solid', false]],
'sections' => $sections,
];
}
$groups[$theme] = compact('name', 'description', 'pages');
}
return $groups;
+1
View File
@@ -36,6 +36,7 @@ CREATE TABLE IF NOT EXISTS pages (
footer_id INTEGER REFERENCES design_presets(id),
palette_id INTEGER REFERENCES design_presets(id),
layout_id INTEGER REFERENCES design_presets(id),
page_type TEXT NOT NULL DEFAULT 'page' CHECK (page_type IN ('page', 'maintenance', 'not-found')),
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
updated_at TEXT,
version INTEGER NOT NULL DEFAULT 0