9 Commits
108 changed files with 2004 additions and 315 deletions
+57 -5
View File
@@ -28,20 +28,25 @@ php bin/admin.php reset admin@example.com
## 后台编辑
- **网站后台**可按名称、地址或发布状态查找页面,从列表打开画布、公开页或草稿预览。
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。悬停或键盘聚焦缩略图可放大,点击可打开预览。
- **整页模板**可以从后台首页、新建页面或画布打开独立抽屉。先选套系,再选页面,查看缩略图或完整预览后创建草稿。主题样式只由使用模板的公开页及预览加载,抽屉资源只由有入口的后台页面加载。六个套系共十二个页面,参考 [Hallmark](https://github.com/nutlope/hallmark) 的 Cobalt、Studio、Dusk、Vantage、Ribbon 和 Furrow。
- **页面显示**可以分别开关页头、首屏和页脚。选中画布里的首屏标题可移除首屏,并在页面设置中恢复。选中普通区块标题可删除整个区块,保存页面后生效。
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。可在功能分类中复用产品图文、特性组、服务报价等内置模板,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。「查看全部动态」和翻页只列出该区块所选的分类。
- **普通页面**包括 `/services`、`/articles` 和 `/contact`。产品目录和分类文章模块的设置可在画布编辑。动态页默认显示公告、新闻和产品动态。
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。编辑页底部可永久删除文章,重复安装也会保留删除结果。已发布文章改网址标识后,旧标识会自动跳转。
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
## 生产运行
1. 以运行服务的用户执行 `composer install --no-dev --optimize-autoloader`、`php bin/install.php` 和管理员创建命令。
2. 通过 systemd 或其他进程管理器以前台命令 `php start.php start` 运行。为生产服务设置 `LAYSENSE_SECURE_COOKIES=1`,使 Webman 签发 Secure 会话 Cookie。默认监听 `127.0.0.1:8787`。
3. 由 Nginx 等反向代理处理 `laysense.cn` 的 HTTPS,并将请求转发给 Webman。项目根目录保持在公共站点根目录之外。
3. 由 Nginx 或 Caddy 处理 `laysense.cn` 的 HTTPS,并将请求转发给 Webman。项目根目录保持在公共站点根目录之外。
### Nginx
下面的 Nginx 片段可放入现有 HTTPS 虚拟主机。Nginx 会覆盖请求携带的 `X-Real-IP`,应用默认信任本机回环地址传来的该请求头。密码验证失败的请求按来源计数,超过阈值后返回 429。正确密码仍可登录。
@@ -61,6 +66,48 @@ location = /admin/media {
}
```
### Caddy v2
下面的 Caddyfile 适用于 Caddy v2.10.0 及以上版本,假定 Caddy 直接面对访客,与 Webman 运行在同一台机器上。把域名解析到 Caddy,并开放 80 和 443 端口,Caddy 会自动申请证书。`header_up` 用连接对端的 IP 覆盖 `X-Real-IP`,供 Webman 按访客来源计数。
```caddyfile
laysense.cn {
@media path /admin/media
@pages not path /admin/media
request_body @media {
max_size 66MiB
}
request_body @pages {
max_size 2MiB
}
reverse_proxy 127.0.0.1:8787 {
header_up X-Real-IP {remote_host}
}
}
```
用 `caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile` 验证,再用 `caddy reload --config /etc/caddy/Caddyfile --adapter caddyfile` 重载。较早的 Caddy v2 可以省略两个匹配器及 `request_body` 块,保留反代。Webman 仍限制请求包大小,并将单个媒体文件限制在 64 MiB。
### Caddy v1
下例适用于仍在运行的 Caddy 1.x。`transparent` 保留请求的 Host,并用连接对端的 IP 设置 `X-Real-IP`。Caddy v1 的 `limits` 按路径前缀匹配,`MB` 以 1024 为进制。
```caddyfile
laysense.cn {
limits {
body /admin/media 66MB
body / 2MB
}
proxy / 127.0.0.1:8787 {
transparent
}
}
```
用 `caddy -validate -conf /etc/caddy/Caddyfile` 验证,再通过进程管理器重载。Caddy v1 已停止维护,新的部署使用 v2。
两个示例都把 HTTPS 终止在 Caddy,生产环境的 Webman 继续使用 `LAYSENSE_SECURE_COOKIES=1`。如果 Caddy 与 Webman 分开运行,将 `LAYSENSE_TRUSTED_PROXIES` 设为 Webman 实际看到的 Caddy 来源 IP,并把 Webman 的监听地址限制在只有 Caddy 能访问的网络。
| 环境变量 | 默认值与用途 |
| --- | --- |
| `LAYSENSE_SITE_URL` | `https://laysense.cn` · canonical、分享链接和站点地图的正式站点地址 |
@@ -71,7 +118,7 @@ location = /admin/media {
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增加对齐字段,之后重启 Webman。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。安装会补齐 `/services`、`/articles` 和 `/contact` 的页面记录,并一次性导入首页五联导航和伙伴动态模块。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
### CDN
@@ -85,6 +132,11 @@ SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当
- SHNU 旧页首屏写 ¥69,详细报价表与正文写 ¥66。新版保留报价表中的 ¥66,并保留旧页学生资格及学分说明。两处普通软著页面的咨询按钮现在直达该页既有的企业微信入口。
- 中文公开页复用页头、页尾、首屏、内容区块、动态列表及同一套 CSS。历史迁移内容见 `resources/seed.json`,结构见 `resources/schema.sql`。
## 整页模板素材
- 工作室照片是 Adam Lusch 的《Wood Type close-up》,按 CC BY-SA 2.0 许可提供,已缩放并转为 WebP。 [照片](https://commons.wikimedia.org/wiki/File:Wood_Type_close-up.jpg) · [许可证](https://creativecommons.org/licenses/by-sa/2.0/)
- 暮色照片是 Bob Wick / BLM Utah 的《Utah Dunes Landscape》,公有领域,已缩放并转为 WebP。 [照片](https://commons.wikimedia.org/wiki/File:Utah_Dunes_Landscape_-_West_Desert_District.jpg)
## 画布浏览器回归
`tests/studio-browser.cjs` 用 Playwright 在真实 Chromium 内检查媒体拖拽、链接、模板预览、编辑器、文章分类和公开页面。使用已启动的测试实例、独立的 SQLite 数据库和管理员账户。测试会在该库创建页面、分类和测试文章。
+73 -3
View File
@@ -8,6 +8,12 @@ final class BlockTemplates
{
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
public const NETWORK_FEED = '{"categories":["supported-projects","partners"],"mode":"network","limit":30}';
public const CATALOG_FEED = '{"categories":["services"],"mode":"catalog","limit":30}';
public const PRODUCT_LINKS = '<div class="hero-directory"><a class="overline directory-label" href="/services">产品与服务</a><a href="/pagepan"><span>PAGEPAN</span><small>可视化建站</small></a><a href="/highspeaker"><span>HighSpeaker DNS</span><small>开源智能解析</small></a><a href="/sc"><span>软著代理</span><small>登记申请与材料服务</small></a><a href="/shnu-sc"><span>SHNU 学生</span><small>软著申请方案</small></a></div>';
public const ELEMENT_GROUPS = [
'text-elements' => ['文字与列表', [
'paragraph' => ['段落', '<p>填写正文。</p>'],
@@ -16,24 +22,39 @@ final class BlockTemplates
'blockquote' => ['引用', '<blockquote><p>填写需要引用的内容。</p></blockquote>'],
'bullet-list' => ['项目列表', '<ul><li>填写列表项</li><li>填写列表项</li></ul>'],
'ordered-list' => ['编号列表', '<ol><li>填写第一项</li><li>填写第二项</li></ol>'],
'heading-kicker' => ['标题眉标', '<p class="overline">填写分类名称</p>'],
'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>'],
]],
'link-elements' => ['链接与按钮', [
'button' => ['主按钮', '<p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
'outline-button' => ['描边按钮', '<p><a class="button button-outline" href="/services">查看服务</a></p>'],
'text-link' => ['文字链接', '<p><a href="/articles">阅读文章</a></p>'],
'button-group' => ['按钮组', '<div class="actions studio-button-group"><a class="button button-primary" href="/services">查看服务</a><a class="button button-outline" href="#contact">联系团队</a></div>'],
'breadcrumbs' => ['面包屑', '<p class="breadcrumbs"><a href="/">首页</a><span> / </span><span>当前页面</span></p>'],
'download-link' => ['下载入口', '<p><a class="button button-outline" href="/pagepan#download">查看下载</a></p>'],
'email-link' => ['邮件链接', '<p><a href="mailto:hello@example.com">发送邮件</a></p>'],
]],
'media-elements' => ['图片与影音', [
'image' => ['图片', '', 'image/'],
'video' => ['视频', '', 'video/'],
'audio' => ['音频', '', 'audio/'],
'qr-image' => ['二维码', '', 'image/'],
'image-link' => ['图片链接', '<p><a href="/pagepan"><img src="/assets/original/pagepan-example.webp" alt="PAGEPAN 产品预览" loading="lazy"></a></p>'],
]],
'structure-elements' => ['版式与数据', [
'separator' => ['分割线', '<hr class="studio-divider">'],
'spacer' => ['留白', '<div class="studio-spacer"></div>'],
'code' => ['代码块', '<pre class="studio-code"><code>填写代码</code></pre>'],
'basic-table' => ['数据表格', '<table><thead><tr><th scope="col">名称</th><th scope="col">数据</th></tr></thead><tbody><tr><td>填写名称</td><td>填写数据</td></tr></tbody></table>'],
'progress' => ['进度条', '<div class="studio-progress"><p>完成进度</p><progress max="100" value="65">65%</progress></div>'],
'alert' => ['提示卡', '<div class="studio-notice"><p><strong>请注意</strong></p><p>填写一条提示信息。</p></div>'],
'simple-card' => ['内容卡片', '<article class="content-card"><h3>填写卡片标题</h3><p>填写卡片内容。</p></article>'],
'link-card' => ['链接卡片', '<article class="content-card"><h3>查看资料</h3><p>填写链接指向的资料说明。</p><a href="/articles">打开资料</a></article>'],
'list-group' => ['列表组', '<ul class="studio-resources"><li><a href="/services">产品与服务</a><span>目录</span></li><li><a href="/articles">来笙动态</a><span>文章</span></li></ul>'],
'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>'],
]],
];
@@ -42,7 +63,8 @@ final class BlockTemplates
'content' => ['标题与正文', [
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
'articles' => ['分类文章', ''],
'articles' => ['分类文章', '', '', self::ARTICLE_FEED],
'network' => ['支持项目与合作伙伴', '', '', self::NETWORK_FEED],
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
'notice' => ['重点提示', '<div class="studio-notice"><h3>填写重要提示</h3><p>说明访客需要知悉的事项、条件或时间。</p></div>'],
]],
@@ -52,7 +74,7 @@ final class BlockTemplates
'two-actions' => ['双按钮横幅', '<div class="studio-banner studio-banner-two"><div><h3>选择下一步</h3><p>介绍访客可以立即做什么。</p></div><div class="actions"><a class="button button-primary" href="/services">查看服务</a><a class="button button-outline" href="/#contact">联系我们</a></div></div>'],
]],
'layout' => ['图文与布局', [
'image' => ['图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
'image' => ['产品图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
'grid' => ['双栏网格', '<div class="studio-two-column"><article class="content-card"><h3>第一栏</h3><p>填写主要内容。</p></article><article class="content-card"><h3>第二栏</h3><p>补充相关信息。</p></article></div>'],
]],
'media' => ['媒体', [
@@ -74,6 +96,8 @@ final class BlockTemplates
'pricing' => ['双方案报价', '<div class="card-grid price-grid studio-pricing"><article class="content-card price-card"><h3>基础方案</h3><p class="price-value">填写价格</p><p>填写方案包含的服务。</p><a class="button button-outline" href="/#contact">咨询基础方案</a></article><article class="content-card price-card"><h3>进阶方案</h3><p class="price-value">填写价格</p><p>填写扩展服务或权益。</p><a class="button button-primary" href="/#contact">咨询进阶方案</a></article></div>'],
]],
'actions' => ['导航与引导', [
'service-catalog' => ['产品与服务目录', '', '', self::CATALOG_FEED],
'product-links' => ['产品与服务五联导航', self::PRODUCT_LINKS],
'navigation' => ['快速导航', '<ul class="studio-quick-nav"><li><a href="/services">产品与服务</a></li><li><a href="/articles">动态与文章</a></li><li><a href="/#contact">联系来笙</a></li></ul>'],
'cta' => ['行动按钮', '<p>说明下一步。</p><p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
'resources' => ['资料与链接', '<ul class="studio-resources"><li><a href="/pagepan#download">获取 PAGEPAN</a><span>应用下载</span></li><li><a href="/articles">浏览动态与文档</a><span>网站资源</span></li></ul>'],
@@ -81,9 +105,55 @@ final class BlockTemplates
]],
];
public static function groups(): array
{
static $groups;
if ($groups !== null) {
return $groups;
}
$groups = self::GROUPS;
$seed = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR);
$sectionGroups = [
'product' => 'layout', 'about' => 'content', 'blog' => 'content',
'features' => 'features', 'support' => 'features', 'why' => 'features', 'stories' => 'features',
'pricing' => 'details', 'comparison' => 'details', 'materials' => 'details', 'fees' => 'details',
'faq' => 'details', 'terms' => 'details',
'get' => 'actions', 'options' => 'actions', 'go' => 'actions', 'benefits' => 'layout',
];
foreach ($seed['pages'] as $page) {
if (!in_array($page['slug'], ['home', 'highspeaker', 'sc', 'shnu-sc'], true)) {
continue;
}
$links = '';
foreach ($page['actions'] as [$url, $label]) {
$links .= '<a class="button button-outline" href="' . View::escape($url) . '">' . View::escape($label) . '</a>';
}
$hero = '<div class="studio-cover"><img src="' . View::escape($page['image']) . '" alt="' . View::escape($page['alt']) . '" loading="lazy">'
. '<div><h3>' . View::escape(trim($page['heading'] . ' ' . $page['accent'])) . '</h3><p>' . View::escape($page['lead'])
. '</p><div class="actions">' . $links . '</div></div></div>';
$prefix = 'existing-' . $page['slug'] . '-';
$groups['cover'][1][$prefix . 'hero'] = ['产品图文 · ' . $page['name'], $hero];
foreach ($page['sections'] as $section) {
$group = $sectionGroups[$section['key']] ?? null;
if ($group === null) {
continue;
}
$groups[$group][1][$prefix . $section['key']] = [
$section['key'] === 'features' ? '特性组' : $section['title'],
Html::sanitize($section['body']), $section['lead'],
isset($section['feed']) ? Database::json($section['feed']) : null,
$section['style'],
];
}
}
return $groups;
}
public static function find(string $key): ?array
{
foreach (self::GROUPS as [, $templates]) {
foreach (self::groups() as [, $templates]) {
if (isset($templates[$key])) {
return $templates[$key];
}
+30 -3
View File
@@ -10,6 +10,10 @@ use Throwable;
final class Database
{
// 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';
private static ?PDO $connection = null;
public static function connect(): PDO
@@ -50,6 +54,13 @@ final class Database
$pdo->exec("ALTER TABLE $table ADD COLUMN alignments TEXT NOT NULL DEFAULT '{}'");
}
}
$pageColumns = array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name');
if (!in_array('theme', $pageColumns, true)) {
$pdo->exec("ALTER TABLE pages ADD COLUMN theme TEXT NOT NULL DEFAULT ''");
}
if (!in_array('visibility', $pageColumns, true)) {
$pdo->exec("ALTER TABLE pages ADD COLUMN visibility TEXT NOT NULL DEFAULT '{}'");
}
$site = $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)');
$site->execute([self::json($seed['site'])]);
@@ -75,13 +86,29 @@ final class Database
}
}
if ((int) $pdo->query('PRAGMA user_version')->fetchColumn() === 0) {
$heroDirectory = $pdo->prepare("INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, position)
VALUES ('home', 'hero-directory', '产品与服务导航', '', 'hero-links', ?, -1)");
$heroDirectory->execute([BlockTemplates::PRODUCT_LINKS]);
$network = $pdo->prepare("INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, feed, position)
SELECT 'home', 'network', '支持项目与合作伙伴', '', 'plain', '', ?, COALESCE(MAX(position), -1) + 1
FROM sections WHERE page_slug = 'home'");
$network->execute([BlockTemplates::NETWORK_FEED]);
if ($heroDirectory->rowCount() + $network->rowCount() > 0) {
$pdo->exec("UPDATE pages SET version = version + 1 WHERE slug = 'home'");
}
$pdo->exec('PRAGMA user_version = 1');
}
$category = $pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
foreach (Repository::CATEGORIES as $slug => $name) {
$category->execute([$slug, $name]);
}
$article = $pdo->prepare("INSERT OR IGNORE INTO articles
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)");
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
SELECT " . self::NEXT_ARTICLE_ID . ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)
AND NOT EXISTS (SELECT 1 FROM article_deletions WHERE slug = ?)");
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
foreach ($seed['articles'] as $item) {
$format = $item['body_format'] ?? 'markdown';
@@ -90,7 +117,7 @@ final class Database
$item['slug'], $item['title'], $item['summary'] ?? '',
$format === 'html' ? Html::sanitize($item['body']) : $item['body'], $format,
self::json($item['card'] ?? []), self::json($item['tags'] ?? []),
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'],
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'], $item['slug'],
]);
if ($article->rowCount() === 1) {
$id = $pdo->lastInsertId();
+17 -1
View File
@@ -88,7 +88,7 @@ final class Html
return $result;
}
public static function sanitize(string $html): string
public static function sanitize(string $html, ?string $anchorPrefix = null): string
{
$document = new DOMDocument('1.0', 'UTF-8');
$document->loadHTML('<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>' . $html . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
@@ -97,6 +97,22 @@ final class Html
return '';
}
self::sanitizeChildren($body);
if ($anchorPrefix !== null) {
$ids = [];
foreach ($body->getElementsByTagName('*') as $element) {
$id = $element->getAttribute('id');
if ($id !== '') {
$ids[$id] = $anchorPrefix . '-' . $id;
$element->setAttribute('id', $ids[$id]);
}
}
foreach ($body->getElementsByTagName('a') as $link) {
$href = $link->getAttribute('href');
if (str_starts_with($href, '#') && isset($ids[substr($href, 1)])) {
$link->setAttribute('href', '#' . $ids[substr($href, 1)]);
}
}
}
$output = '';
foreach ($body->childNodes as $child) {
$output .= $document->saveHTML($child);
+49
View File
@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Content;
final class PageTemplates
{
public static function groups(): array
{
static $groups;
return $groups ??= require dirname(__DIR__, 2) . '/resources/page-templates.php';
}
public static function find(string $key): ?array
{
foreach (self::groups() as $theme => $group) {
if (!isset($group['pages'][$key])) {
continue;
}
$template = $group['pages'][$key];
$sections = [];
$quicklinks = [];
foreach ($template['sections'] as [$anchor, $title, $style, $body, $feed]) {
$sections[] = ['key' => $anchor, 'title' => $title, 'style' => $style, 'body' => Html::sanitize($body, $anchor),
'lead' => '', 'feed' => $feed, 'alignments' => '{}', 'version' => 0];
$quicklinks[] = ['#' . $anchor, $title];
}
return array_replace($template, [
'slug' => $key, 'theme' => $theme, 'title' => $template['name'] . ' · 来笙', 'accent' => '',
'lead' => $template['description'], 'quicklinks' => $quicklinks, 'status' => 'draft',
'alignments' => [], 'image_scale' => 0, 'sections' => $sections,
]);
}
return null;
}
public static function photoCredit(string $image): ?array
{
return match ($image) {
'/assets/page-templates/studio-letterpress.webp' => ['Adam Lusch', 'CC BY-SA 2.0', 'https://commons.wikimedia.org/wiki/File:Wood_Type_close-up.jpg', 'https://creativecommons.org/licenses/by-sa/2.0/'],
'/assets/page-templates/dusk-dunes.webp' => ['Bob Wick / BLM Utah', '公有领域', 'https://commons.wikimedia.org/wiki/File:Utah_Dunes_Landscape_-_West_Desert_District.jpg', null],
default => null,
};
}
}
+55 -18
View File
@@ -35,15 +35,25 @@ final class Repository
return $this->pdo->query('SELECT slug, name, title, updated_at, status FROM pages' . $where . ' ORDER BY rowid')->fetchAll();
}
public function createPage(string $slug, string $name): void
public function createPage(string $slug, string $name, array $template = []): void
{
$query = $this->pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
lead, image, alt, actions, quicklinks, status, updated_at)
VALUES (?, ?, ?, '', ?, '', '', '', '', '[]', '[]', 'draft', ?)");
$query->execute([$slug, $name, $name . ' · 来笙', $name, self::now()]);
Database::write(function (PDO $pdo) use ($slug, $name, $template): void {
$query = $pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
lead, image, alt, actions, quicklinks, theme, status, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'draft', ?)");
$query->execute([
$slug, $name, $name . ' · 来笙', $template['description'] ?? '', $template['heading'] ?? $name,
$template['accent'] ?? '', $template['lead'] ?? '', $template['image'] ?? '', $template['alt'] ?? '',
Database::json($template['actions'] ?? []), Database::json($template['quicklinks'] ?? []),
$template['theme'] ?? '', self::now(),
]);
if ($query->rowCount() !== 1) {
throw new RuntimeException('此页面地址已存在。');
}
foreach ($template['sections'] ?? [] as $section) {
self::insertSection($pdo, $slug, $section['key'], $section);
}
});
}
public function page(string $slug): ?array
@@ -52,7 +62,7 @@ final class Repository
if (!$page) {
return null;
}
foreach (['actions', 'quicklinks', 'alignments'] as $key) {
foreach (['actions', 'quicklinks', 'alignments', 'visibility'] as $key) {
$page[$key] = json_decode($page[$key], true, flags: JSON_THROW_ON_ERROR);
}
$query = $this->pdo->prepare('SELECT * FROM sections WHERE page_slug = ? ORDER BY position, key');
@@ -78,15 +88,17 @@ final class Repository
{
Database::write(function (PDO $pdo) use ($slug, $data, $version, $sections): void {
$query = $pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
image = ?, alt = ?, image_scale = ?, alignments = ?, actions = ?, quicklinks = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
image = ?, alt = ?, image_scale = ?, alignments = ?, actions = ?, quicklinks = ?, visibility = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
$query->execute([
$data['name'], $data['title'], $data['description'], $data['heading'], $data['accent'], $data['lead'],
$data['image'], $data['alt'], $data['image_scale'], Database::json($data['alignments']), Database::json($data['actions']), Database::json($data['quicklinks']),
$data['status'], self::now(), $slug, $version,
Database::json($data['visibility']), $data['status'], self::now(), $slug, $version,
]);
self::checkVersion($query->rowCount());
foreach ($sections as $section) {
if ($section['version'] === null) {
if (!empty($section['delete'])) {
self::deleteSection($pdo, $slug, $section['key'], $section['version']);
} elseif ($section['version'] === null) {
self::insertSection($pdo, $slug, $section['key'], $section);
} else {
self::updateSection($pdo, $slug, $section['key'], $section, $section['version']);
@@ -111,10 +123,10 @@ final class Repository
self::checkVersion($query->rowCount());
}
public function createSection(string $page, string $key, string $title, string $style, string $body, ?string $feed = null): void
public function createSection(string $page, string $key, string $title, string $style, string $body, ?string $feed = null, string $lead = ''): void
{
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body, $feed): void {
self::insertSection($pdo, $page, $key, compact('title', 'style', 'body', 'feed') + ['lead' => '']);
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body, $feed, $lead): void {
self::insertSection($pdo, $page, $key, compact('title', 'style', 'body', 'feed', 'lead'));
self::touchPage($pdo, $page, structureChanged: true);
});
}
@@ -129,6 +141,17 @@ final class Repository
}
}
private static function deleteSection(PDO $pdo, string $page, string $key, int $version): void
{
$query = $pdo->prepare('DELETE FROM sections WHERE page_slug = ? AND key = ? AND version = ?');
$query->execute([$page, $key, $version]);
self::checkVersion($query->rowCount());
$pdo->prepare("UPDATE pages SET
quicklinks = (SELECT json_group_array(json(value)) FROM json_each(quicklinks) WHERE json_extract(value, '$[0]') <> :anchor),
actions = (SELECT json_group_array(json(value)) FROM json_each(actions) WHERE json_extract(value, '$[0]') <> :anchor)
WHERE slug = :slug")->execute(['anchor' => '#' . $key, 'slug' => $page]);
}
public function arrangeSection(string $page, string $key, string $operation, int $version, int $pageVersion): void
{
Database::write(function (PDO $pdo) use ($page, $key, $operation, $version, $pageVersion): void {
@@ -137,14 +160,12 @@ final class Repository
$revision = $current->fetchColumn();
self::checkVersion($revision !== false && (int) $revision === $pageVersion ? 1 : 0);
if ($operation === 'delete') {
$query = $pdo->prepare('DELETE FROM sections WHERE page_slug = ? AND key = ? AND version = ?');
$query->execute([$page, $key, $version]);
self::checkVersion($query->rowCount());
self::deleteSection($pdo, $page, $key, $version);
self::touchPage($pdo, $page, structureChanged: true);
return;
}
$query = $pdo->prepare('SELECT key, version FROM sections WHERE page_slug = ? ORDER BY position, key');
$query = $pdo->prepare("SELECT key, version FROM sections WHERE page_slug = ? AND style <> 'hero-links' ORDER BY position, key");
$query->execute([$page]);
$revisions = $query->fetchAll(PDO::FETCH_KEY_PAIR);
if (!array_key_exists($key, $revisions)) {
@@ -257,8 +278,8 @@ final class Repository
];
if ($id === null) {
$query = $pdo->prepare('INSERT INTO articles
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
VALUES (' . Database::NEXT_ARTICLE_ID . ', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
$query->execute($values);
$id = (int) $pdo->lastInsertId();
} else {
@@ -282,6 +303,22 @@ final class Repository
});
}
public function deleteArticle(int $id, int $version): void
{
Database::write(function (PDO $pdo) use ($id, $version): void {
// Keep the original seed slug even if the article has been renamed.
$deletions = $pdo->prepare('INSERT INTO article_deletions (slug, article_id)
SELECT slug, id FROM articles WHERE id = :id
UNION ALL SELECT slug, article_id FROM article_redirects WHERE article_id = :id
ON CONFLICT (slug) DO UPDATE SET article_id = excluded.article_id');
$deletions->execute(['id' => $id]);
$delete = $pdo->prepare('DELETE FROM articles WHERE id = ? AND version = ?');
$delete->execute([$id, $version]);
self::checkVersion($delete->rowCount());
});
}
public function sitemapArticles(): iterable
{
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
+2 -2
View File
@@ -12,7 +12,7 @@ final class SiteDesign
public const DEFAULT_HEADER = [
'logo' => '/assets/wordmark.webp', 'alt' => 'Laysense 来笙',
'links' => [['/', '首页'], ['/services', '产品与服务'], ['/articles', '动态'], ['/#about', '关于来笙']],
'button' => ['#contact', '联系来笙'],
'button' => ['/contact', '联系来笙'],
];
public const DEFAULT_FOOTER = [
@@ -23,7 +23,7 @@ final class SiteDesign
'products_title' => '产品与服务',
'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']],
'company_title' => '公司',
'company' => [['/#about', '关于来笙'], ['#contact', '联系来笙']],
'company' => [['/#about', '关于来笙'], ['/contact', '联系来笙']],
'resources_title' => '资源',
'resources' => [['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']],
+77 -14
View File
@@ -117,6 +117,7 @@ class AdminController
return $this->render($request, 'admin-dashboard', [
'title' => '内容管理', 'pages' => $repo->pages(), 'articles' => $repo->articles(public: false, limit: 5),
'pageTemplateDrawer' => true,
]);
}
@@ -135,6 +136,7 @@ class AdminController
return $this->render($request, 'admin-articles', [
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page,
'hasNext' => count($articles) > 30, 'categories' => $categories, 'category' => $category,
'deleted' => $request->get('deleted') === '1',
]);
}
@@ -221,6 +223,21 @@ class AdminController
], $error !== '' ? 422 : 200);
}
public function deleteArticle(Request $request, string $id): Response
{
if ($failure = $this->guard($request)) {
return $failure;
}
try {
(new Repository())->deleteArticle((int) $id, $this->version($request));
} catch (RuntimeException $exception) {
return $this->error($request, $this->validationMessage($exception), $exception instanceof \PDOException ? 500 : 409);
}
return $this->success($request, '/admin/articles?deleted=1');
}
public function page(Request $request, string $slug): Response
{
if ($failure = $this->guard($request)) {
@@ -255,6 +272,18 @@ class AdminController
}
$page = array_replace($page, $data, ['version' => $this->version($request)]);
try {
$data['visibility'] = $page['visibility'];
foreach (['hero', 'header', 'footer'] as $area) {
$value = $request->post('show_' . $area);
if ($value === null) {
continue;
}
if (!in_array($value, ['0', '1'], true)) {
throw new RuntimeException('页面显示选项不正确。');
}
$data['visibility'][$area] = $value === '1';
}
$page['visibility'] = $data['visibility'];
$data['alignments'] = $request->post('alignments') === null ? $page['alignments']
: $this->alignmentMap(json_decode($this->input($request, 'alignments'), true), ['heading', 'lead', 'actions', 'image']);
$page['alignments'] = $data['alignments'];
@@ -262,13 +291,13 @@ class AdminController
if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
|| $data['title'] === '' || mb_strlen($data['title']) > 160 ||
($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
$data['heading'] === '' || mb_strlen($data['heading'] . $data['accent']) > 110 ||
(($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)) ||
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true)) || !$validButtons) {
throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
}
$sections = $this->canvasSections($request->post('canvas_sections', ''), $page['sections']);
$sections = $this->canvasSections($request->post('canvas_sections', ''), $page['sections'], $repo->categories());
$repo->savePage($slug, $data, $this->version($request), $sections);
return $this->success($request, '/admin/pages/' . $slug . '?saved=1');
@@ -278,7 +307,8 @@ class AdminController
}
return $this->render($request, 'admin-page', [
'title' => '编辑 ' . $page['name'], 'page' => $page, 'wideAdmin' => true, 'error' => $error, 'saved' => $request->get('saved') === '1',
'title' => '编辑 ' . $page['name'], 'page' => $page, 'categories' => $repo->categories(), 'wideAdmin' => true, 'error' => $error, 'saved' => $request->get('saved') === '1',
'pageTemplateDrawer' => true,
], $error !== '' ? 422 : 200);
}
@@ -299,12 +329,12 @@ class AdminController
$data = [
'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
'body' => $this->input($request, 'body'),
'style' => $request->post('style') === null ? $section['style'] : $this->input($request, 'style'),
'style' => $savedStyle === 'hero-links' || $request->post('style') === null ? $savedStyle : $this->input($request, 'style'),
'feed' => $section['feed'],
];
$section = array_replace($section, $data, ['version' => $this->version($request)]);
try {
if ($request->post('feed_mode') !== null) {
if ($savedStyle !== 'hero-links' && $request->post('feed_mode') !== null) {
$data['feed'] = $section['feed'] = $this->feedInput($request, $categories);
}
$this->checkSection($data, $savedStyle);
@@ -322,7 +352,7 @@ class AdminController
], $error !== '' ? 422 : 200);
}
private function canvasSections(mixed $payload, array $sections): array
private function canvasSections(mixed $payload, array $sections, array $categories): array
{
if ($payload === '') {
return [];
@@ -336,15 +366,46 @@ class AdminController
foreach ($changes as $change) {
$key = $change['key'] ?? null;
$version = $change['version'] ?? null;
$fields = $change['fields'] ?? null;
$fields = $change['fields'] ?? [];
$alignments = $change['alignments'] ?? null;
$feed = $change['feed'] ?? null;
$delete = ($change['delete'] ?? false) === true;
$isNew = is_array($change) && array_key_exists('version', $change) && $version === null;
if (!is_string($key) || isset($updates[$key]) || !is_array($fields) || ($fields === [] && $alignments === null)
if (!is_string($key) || isset($updates[$key]) || !is_array($fields) || (!$delete && $fields === [] && $alignments === null && $feed === null)
|| ($isNew ? (isset($available[$key]) || !preg_match('/^block-[a-f0-9]{32}$/D', $key))
: (!isset($available[$key]) || !is_int($version) || $version !== (int) $available[$key]['version']))) {
throw new RuntimeException('区块已变更或画布内容无效,请重新打开编辑页。');
}
if ($delete) {
if ($isNew) {
throw new RuntimeException('未保存的区块无需提交删除。');
}
$updates[$key] = compact('key', 'version', 'delete');
continue;
}
$section = $available[$key] ?? ['key' => $key, 'title' => '', 'lead' => '', 'body' => '', 'style' => 'plain'];
if ($isNew && isset($change['template'])) {
$preset = is_string($change['template']) ? BlockTemplates::find($change['template']) : null;
if ($preset === null) {
throw new RuntimeException('区块模板已失效。');
}
$section['feed'] = $preset[3] ?? null;
$section['style'] = $preset[4] ?? 'plain';
}
if ($isNew && isset($change['copyOf'])) {
$source = $change['copyOf']['key'] ?? null;
$sourceVersion = $change['copyOf']['version'] ?? null;
if (!is_string($source) || empty($available[$source]['feed']) || $sourceVersion !== (int) $available[$source]['version']) {
throw new RuntimeException('原模块已变更,请刷新画布后再复制。');
}
$section = array_replace($available[$source], ['key' => $key]);
}
if ($feed !== null) {
if (!is_array($feed) || empty($section['feed'])) {
throw new RuntimeException('模块设置不正确。');
}
$section['feed'] = $this->encodeFeed($feed['mode'] ?? null, $feed['categories'] ?? null, $feed['limit'] ?? null, $categories);
}
foreach ($fields as $field => $value) {
if (!in_array($field, ['title', 'lead', 'body'], true)) {
throw new RuntimeException('画布内容无效。');
@@ -364,9 +425,6 @@ class AdminController
if (isset($fields['body'])) {
$section['body'] = Html::sanitize($section['body']);
}
if ($isNew && ($change['template'] ?? null) === 'articles') {
$section['feed'] = BlockTemplates::ARTICLE_FEED;
}
$section['version'] = $version;
$updates[$key] = $section;
}
@@ -546,9 +604,14 @@ class AdminController
if ($mode === 'off') {
return null;
}
$categories = $this->selectedCategories($request->post('feed_categories'));
$limit = filter_var($this->input($request, 'feed_limit'), FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]);
if (!in_array($mode, ['merged', 'tabs'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
return $this->encodeFeed($mode, $request->post('feed_categories'), $this->input($request, 'feed_limit'), $available);
}
private function encodeFeed(mixed $mode, mixed $selected, mixed $value, array $available): string
{
$categories = $this->selectedCategories($selected);
$limit = filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]);
if (!in_array($mode, ['merged', 'tabs', 'network', 'catalog'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
throw new RuntimeException('请选择文章分类,并将展示数量设为 1 至 30。');
}
+29 -25
View File
@@ -24,6 +24,16 @@ final class SiteController
if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
return $this->missing($request);
}
if ($slug === 'articles' && $request->get('page') !== null) {
foreach ($page['sections'] as $section) {
$feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
if (in_array($feed['mode'] ?? null, ['merged', 'tabs'], true)) {
return $this->feedArchive($request, $slug, $section['key']);
}
}
return $this->missing($request);
}
return $this->renderPage($repo, $page);
}
@@ -31,20 +41,30 @@ final class SiteController
{
$slug = $page['slug'];
$isHome = $slug === 'home';
$showHero = $page['visibility']['hero'] ?? true;
$categories = $repo->categories();
foreach ($page['sections'] as &$section) {
if (!$section['feed']) {
continue;
}
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
$tabs = $feed['mode'] === 'tabs' && count($feed['categories']) > 1;
$network = $feed['mode'] === 'network';
$catalog = $feed['mode'] === 'catalog';
$grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1);
$archivePath = '/articles/feed/' . $slug . '/' . $section['key'];
if ($network && count($feed['categories']) === 2 && !array_diff($feed['categories'], ['supported-projects', 'partners'])) {
$archivePath = '/network';
}
$section['archivePath'] = $page['status'] === 'published' ? $archivePath : null;
$section['articleFeed'] = [];
$section['archivePath'] = $page['status'] === 'published' ? '/articles/feed/' . $slug . '/' . $section['key'] : null;
foreach ($tabs ? $feed['categories'] : [''] as $category) {
$section['networkFeed'] = $network;
$section['catalogFeed'] = $catalog;
$section['feedLimit'] = $feed['limit'];
foreach ($grouped ? $feed['categories'] : [''] as $category) {
$selected = $category === '' ? $feed['categories'] : [$category];
$section['articleFeed'][] = [
'categories' => $selected, 'label' => $categories[$category] ?? '',
'articles' => $repo->articles($selected, limit: $feed['limit']),
'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network || $catalog),
];
}
}
@@ -56,25 +76,12 @@ final class SiteController
'path' => $isHome ? '/' : '/' . $slug,
'title' => $page['title'],
'description' => $page['description'],
'socialImage' => $page['image'],
'socialAlt' => $page['alt'],
'network' => $isHome ? $this->networkGroups($repo) : [],
'socialImage' => $showHero ? $page['image'] : '',
'socialAlt' => $showHero ? $page['alt'] : '',
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
]);
}
public function services(Request $request): Response
{
$repo = new Repository();
return View::render('services', [
'site' => $repo->site(), 'path' => '/services',
'title' => '产品与服务 · 来笙 Laysense',
'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。',
'products' => $repo->articles('services', limit: -1, directoryOrder: true),
]);
}
public function network(Request $request): Response
{
$repo = new Repository();
@@ -152,6 +159,7 @@ final class SiteController
'archivePath' => $category === null ? $allPath : $categoryLinks[$category], 'allPath' => $allPath,
'categoryLinks' => $categoryLinks, 'categories' => $categories, 'category' => $category, 'tag' => null,
'categoryScope' => $category === null ? array_keys($categories) : [$category],
'catalog' => $feed['mode'] === 'catalog',
'backPath' => $returnPath, 'backLabel' => '返回原页面', 'noindex' => true,
]);
}
@@ -163,7 +171,7 @@ final class SiteController
return $this->missing($request);
}
$page = (int) $number;
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20);
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20, directoryOrder: $view['catalog'] ?? false);
if ($page > 1 && $articles === []) {
return $this->missing($request);
}
@@ -235,11 +243,7 @@ final class SiteController
$repo = new Repository();
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
$pages = $repo->pages(publishedOnly: true);
$pages[] = ['slug' => 'services', 'updated_at' => null];
$pages[] = ['slug' => 'network', 'updated_at' => null];
if ($repo->articles(limit: 1)) {
$pages[] = ['slug' => 'articles', 'updated_at' => null];
}
foreach ($pages as $page) {
$xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']);
}
@@ -264,7 +268,7 @@ final class SiteController
$normal = rtrim($path, '/');
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
if ($known || in_array($normal, ['/services', '/network'], true) || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) {
if ($known || $normal === '/network' || preg_match('~^/articles(?:/[a-z0-9-]+){1,2}$~D', $normal)) {
$query = $request->queryString();
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
+24 -4
View File
@@ -8,6 +8,7 @@ use App\Content\Assets;
use App\Content\BlockTemplates;
use App\Content\Html;
use App\Content\Media;
use App\Content\PageTemplates;
use App\Content\Repository;
use App\Content\SiteDesign;
use App\Http\Request;
@@ -22,16 +23,24 @@ final class StudioController extends AdminController
if ($failure = $this->guard($request)) {
return $failure;
}
$data = ['title' => '新建页面', 'name' => '', 'slug' => '', 'error' => ''];
$data = [
'title' => '新建页面', 'name' => '', 'slug' => '', 'error' => '', 'pageTemplateDrawer' => true,
'openTemplates' => $request->get('templates') === '1',
];
if ($request->method() === 'POST') {
$data['name'] = $this->input($request, 'name');
$data['slug'] = $this->input($request, 'slug');
try {
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'network', 'news', 'main', 'favicon'], true)
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'home', 'network', 'news', 'main', 'favicon'], true)
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
throw new RuntimeException('请填写页面名称及可用的网址标识。');
}
(new Repository())->createPage($data['slug'], $data['name']);
$key = $this->input($request, 'template');
$template = $key === '' ? [] : PageTemplates::find($key);
if ($template === null) {
throw new RuntimeException('找不到所选整页模板。');
}
(new Repository())->createPage($data['slug'], $data['name'], $template);
return $this->success($request, '/admin/pages/' . $data['slug']);
} catch (RuntimeException $error) {
@@ -42,6 +51,17 @@ final class StudioController extends AdminController
return $this->render($request, 'studio-new-page', $data, $data['error'] === '' ? 200 : 422);
}
public function previewTemplate(Request $request, string $key): Response
{
if ($failure = $this->guard($request)) {
return $failure;
}
$template = PageTemplates::find($key);
return $template ? (new SiteController())->renderPage(new Repository(), $template, true)
: $this->error($request, '找不到所选整页模板。', 404);
}
public function previewPage(Request $request, string $slug): Response
{
if ($failure = $this->guard($request)) {
@@ -74,7 +94,7 @@ final class StudioController extends AdminController
if ($preset === null) {
throw new RuntimeException('请选择区块类型。');
}
$repo->createSection($slug, $key, $preset[0], 'plain', $preset[1], $type === 'articles' ? BlockTemplates::ARTICLE_FEED : null);
$repo->createSection($slug, $key, $preset[0], $preset[4] ?? 'plain', Html::sanitize($preset[1], $key), $preset[3] ?? null, $preset[2] ?? '');
return $this->success($request, "/admin/pages/$slug/$key");
}
+11
View File
@@ -51,3 +51,14 @@ $e = View::escape(...);
<button class="button button-primary" type="submit">保存文章</button>
</div>
</form>
<?php if ($articleId !== null): ?>
<details class="admin-panel admin-options">
<summary>删除文章</summary>
<form method="post" action="/admin/articles/<?= $e($articleId) ?>/delete">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
<p class="field-note">删除后,文章及其目录卡片会从网站移除,且无法恢复。</p>
<button class="button button-danger" type="submit">永久删除</button>
</form>
</details>
<?php endif ?>
+1
View File
@@ -12,6 +12,7 @@ $filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
</div>
</header>
<?php if ($deleted): ?><p class="feedback success" role="status">文章已删除。</p><?php endif ?>
<nav class="filter-nav" aria-label="筛选文章">
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
<?php foreach ($categories as $key => $name): ?>
+7 -5
View File
@@ -8,6 +8,7 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
<h1>网站后台</h1>
<div class="actions">
<a class="button button-primary" href="/admin/new-page">新建页面</a>
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
<a class="button button-outline" href="/admin/articles/new">写文章</a>
</div>
</header>
@@ -48,12 +49,13 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu
</section>
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
<h2 id="quick-title">站点编辑</h2>
<ul>
<li><a href="/admin/settings/header">编辑页头</a></li>
<li><a href="/admin/settings/footer">编辑页脚</a></li>
<li><a href="/admin/settings/cdn">静态资源 CDN</a></li>
<li><a href="/admin/media">打开媒体库</a></li>
<ul class="dashboard-setting-buttons">
<li><a class="button button-outline" href="/admin/settings/header">编辑页头</a></li>
<li><a class="button button-outline" href="/admin/settings/footer">编辑页脚</a></li>
<li><a class="button button-outline" href="/admin/settings/cdn">静态资源 CDN</a></li>
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
</ul>
</section>
</div>
</div>
<?= View::fragment('studio-page-templates', compact('token')) ?>
+4
View File
@@ -23,6 +23,10 @@ $active = match (true) {
<script src="/assets/jquery-4.0.0.min.js" defer></script>
<script src="/assets/admin.js" defer></script>
<script src="/assets/studio.js" defer></script>
<?php if (!empty($pageTemplateDrawer)): ?>
<link rel="stylesheet" href="/assets/page-template-drawer.css">
<script src="/assets/page-template-drawer.js" defer></script>
<?php endif ?>
<?php if (!empty($articleEditor)): ?>
<link rel="stylesheet" href="/assets/vendor/toastui/toastui-editor.min.css">
<script src="/assets/vendor/toastui/toastui-editor.min.js" defer></script>
+51 -9
View File
@@ -10,8 +10,11 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
?>
<a class="back-link" href="/admin">返回页面</a>
<header class="admin-heading">
<div><h1><?= $e($title) ?></h1><p><?= $e($path) ?> · <?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></p></div>
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta"><code><?= $e($path) ?></code>
<span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span></p></div>
<div class="actions">
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
<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 ?>
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
</div>
@@ -20,7 +23,10 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
<div class="studio-layout">
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
<h2 id="studio-library-title">页面编辑</h2>
<?= View::fragment('studio-templates', ['layers' => View::fragment('studio-layers', compact('page', 'slug', 'token'))]) ?>
<?= View::fragment('studio-templates', [
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
'anchorForm' => View::fragment('studio-anchor-form', compact('slug', 'token')),
]) ?>
</aside>
<div class="studio-workspace">
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
@@ -45,13 +51,13 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
<div class="studio-element-tools" data-element-tools role="group" aria-label="所选元素" hidden>
<div class="studio-element-align" data-element-align role="group" aria-label="对齐">
<button type="button" data-align="left" aria-pressed="false">居左</button>
<button type="button" data-align="center" aria-pressed="false">居中</button>
<button type="button" data-align="right" aria-pressed="false">居右</button>
<?php foreach (['left' => '居左', 'center' => '居中', 'right' => '居右'] as $value => $label): ?>
<button type="button" data-align="<?= $value ?>" aria-pressed="false" aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', ['icon' => $value]) ?></button>
<?php endforeach ?>
</div>
<button type="button" data-element-properties>属性</button>
<button type="button" data-element-copy>复制</button>
<button type="button" data-element-delete>删除</button>
<?php foreach (['module-settings' => ['settings', '模块设置'], 'properties' => ['edit', '属性'], 'copy' => ['copy', '复制'], 'delete' => ['delete', '删除']] as $action => [$icon, $label]): ?>
<button type="button" data-element-<?= $action ?> aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', compact('icon')) ?></button>
<?php endforeach ?>
</div>
<button class="studio-media-handle" type="button" role="slider" aria-label="媒体宽度" aria-valuemin="10" aria-valuemax="100" aria-valuenow="100" data-media-handle hidden></button>
<div class="studio-media-sizing" data-media-sizing hidden>
@@ -60,14 +66,17 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
</div>
</div>
<p class="field-note">单击画布元素可设置对齐、复制或删除。选中媒体后可拖动边缘手柄调整宽度。</p>
<p class="field-note studio-canvas-status" data-canvas-status role="status"></p>
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
<form class="admin-form" method="dialog">
<label data-property-row="label">文案<input name="label"></label>
<label data-property-row="note">副标题<input name="note" maxlength="200"></label>
<label data-property-row="url">地址<input name="url" maxlength="1000"></label>
<label data-property-row="alt">图片替代文本<input name="alt" maxlength="200"></label>
<label data-property-row="quicklinks">目录链接<textarea name="quicklinks" rows="5" placeholder="概览 | #overview"></textarea><small>每行填写「文案 | 链接」。</small></label>
<label data-property-row="value">当前值<input name="value" inputmode="numeric"></label>
<label data-property-row="max">最大值<input name="max" inputmode="numeric"></label>
<label data-property-row="poster">视频封面<input name="poster" maxlength="1000"></label>
<p class="feedback error" role="alert" data-property-error hidden></p>
<div class="actions">
@@ -80,6 +89,19 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
</div>
</form>
</dialog>
<dialog class="media-picker canvas-module-settings" data-module-dialog aria-labelledby="module-settings-title">
<div class="admin-heading compact"><h2 id="module-settings-title">模块设置</h2></div>
<form class="admin-form" method="dialog">
<label>模块标题<input name="module_title" maxlength="100" required></label>
<label>模块简介<textarea name="module_lead" rows="2" maxlength="500"></textarea></label>
<?= View::fragment('studio-feed-fields', ['categories' => $categories, 'feed' => [], 'allowOff' => false]) ?>
<p class="feedback error" role="alert" data-module-error hidden></p>
<div class="actions">
<button class="button button-primary" type="submit">应用</button>
<button class="button button-outline" data-module-close type="button">取消</button>
</div>
</form>
</dialog>
</section>
</div>
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" method="post" action="/admin/pages/<?= $e($slug) ?>">
@@ -88,9 +110,28 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
<input type="hidden" name="canvas_sections" value="">
<input type="hidden" name="alignments" value="<?= $e(Database::json($page['alignments'])) ?>">
<details class="studio-hero-settings">
<summary>首屏与目录</summary>
<div class="studio-hero-controls">
<button class="button button-outline" type="button" disabled data-hero-control="image">首屏图片</button>
<button class="button button-outline" type="button" disabled data-hero-control="1">首屏按钮 1</button>
<button class="button button-outline" type="button" disabled data-hero-control="2">首屏按钮 2</button>
<button class="button button-outline" type="button" disabled data-hero-control="navigation">本页目录</button>
</div>
</details>
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
<label>SEO 标题<input name="title" value="<?= $e($page['title']) ?>" required maxlength="160"></label>
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
<fieldset class="admin-options form-grid">
<legend>页面显示</legend>
<?php foreach (['header' => '页头', 'hero' => '首屏', 'footer' => '页脚'] as $area => $label): ?>
<?php $visible = $page['visibility'][$area] ?? true; ?>
<label><?= $e($label) ?><select name="show_<?= $e($area) ?>">
<option value="1" <?= $visible ? 'selected' : '' ?>>显示</option>
<option value="0" <?= !$visible ? 'selected' : '' ?>>隐藏</option>
</select></label>
<?php endforeach ?>
</fieldset>
<?php
$contentFields = [
'heading' => $page['heading'], 'accent' => $page['accent'], 'lead' => $page['lead'],
@@ -116,3 +157,4 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
<div class="form-submit"><button class="button button-primary" type="submit">保存页面</button></div>
</form>
</div>
<?= View::fragment('studio-page-templates', compact('token')) ?>
+4 -10
View File
@@ -17,23 +17,17 @@ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
<input type="hidden" name="version" value="<?= $e($section['version']) ?>">
<label>区块标题<input name="title" value="<?= $e($section['title']) ?>" required maxlength="100"></label>
<label>区块简介<textarea name="lead" rows="2" maxlength="500"><?= $e($section['lead']) ?></textarea></label>
<?php if ($savedStyle !== 'hero-links'): ?>
<label>区块背景<select name="style">
<?php foreach (array_unique([$savedStyle, 'plain', 'tinted']) as $style): ?>
<option value="<?= $e($style) ?>" <?= $style === $section['style'] ? 'selected' : '' ?>><?= $e(['plain' => '默认', 'tinted' => '浅色背景'][$style] ?? '保留原布局') ?></option>
<?php endforeach ?>
</select></label>
<details class="admin-options" <?= $feed ? 'open' : '' ?>>
<summary>文章组件</summary>
<div class="form-grid">
<label>展示方式<select name="feed_mode">
<?php foreach (['off' => '不展示', 'merged' => '合并为一个列表', 'tabs' => '按分类分标签页'] as $mode => $label): ?>
<option value="<?= $mode ?>" <?= ($feed['mode'] ?? 'off') === $mode ? 'selected' : '' ?>><?= $e($label) ?></option>
<?php endforeach ?>
</select></label>
<label>展示数量<input name="feed_limit" type="number" min="1" max="30" value="<?= $e($feed['limit'] ?? 6) ?>"><small>分标签页时,每个分类独立计数。</small></label>
</div>
<?= View::fragment('admin-category-checkboxes', ['name' => 'feed_categories', 'selected' => $feed['categories'] ?? [], 'categories' => $categories, 'legend' => '展示哪些分类(可多选)']) ?>
<summary>动态模块</summary>
<?= View::fragment('studio-feed-fields', ['categories' => $categories, 'feed' => $feed, 'allowOff' => true]) ?>
</details>
<?php endif ?>
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
</form>
+4
View File
@@ -16,7 +16,11 @@ $e = View::escape(...);
<a href="<?= $e($categoryLinks[$key]) ?>" <?= $category === (string) $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
<?php endforeach ?>
</nav>
<?php if (!empty($catalog)): ?>
<?= View::fragment('service-cards', ['products' => $articles]) ?>
<?php else: ?>
<?= View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
<?php endif ?>
<?php if ($pageNumber > 1 || $hasNext): ?>
<nav class="pagination" aria-label="动态分页">
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="<?= $e(View::archivePage($archivePath, $pageNumber - 1)) ?>" rel="prev">上一页</a><?php endif ?>
+1 -1
View File
@@ -3,7 +3,7 @@ use App\Content\View;
$e = View::escape(...);
?>
<footer class="site-footer" id="contact">
<footer class="site-footer" id="contact"<?= empty($hideFooter) ? '' : ' hidden' ?>>
<div class="wrap">
<div class="footer-grid">
<div class="footer-company" itemscope itemtype="https://schema.org/Organization">
+11 -3
View File
@@ -16,6 +16,9 @@ $header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
$footer = SiteDesign::footer($site);
$nav = $header['links'];
$contact = $header['button'];
$theme = $page['theme'] ?? '';
$showHeader = $page['visibility']['header'] ?? true;
$showFooter = $page['visibility']['footer'] ?? true;
?>
<!doctype html>
<html lang="zh-CN" data-type="<?= $e($kind) ?>" data-buttons="solid" data-motion="on">
@@ -46,12 +49,14 @@ $contact = $header['button'];
<meta name="twitter:card" content="summary_large_image">
<link rel="icon" href="/assets/favicon.png" type="image/png">
<link rel="stylesheet" href="/assets/site.css">
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
<script src="/assets/jquery-4.0.0.min.js" defer></script>
<script src="/assets/site.js" defer></script>
</head>
<body<?= $kind === 'service' ? ' class="copyright-service"' : '' ?>>
<a class="skip-link" href="#main-content">跳到内容</a>
<header class="masthead">
<?php if ($showHeader || !empty($canvas)): ?>
<header class="masthead"<?= $showHeader ? '' : ' hidden' ?>>
<div class="wrap masthead-inner">
<a class="wordmark" href="/" aria-label="来笙 Laysense 首页">
<?php if ($header['logo'] !== ''): ?>
@@ -75,7 +80,10 @@ $contact = $header['button'];
<?php endif ?>
</div>
</header>
<main id="main-content" tabindex="-1"><?= $content ?></main>
<?= View::fragment('footer', ['footer' => $footer]) ?>
<?php endif ?>
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
<?php if ($showFooter || !empty($canvas)): ?>
<?= View::fragment('footer', ['footer' => $footer, 'hideFooter' => !$showFooter]) ?>
<?php endif ?>
</body>
</html>
+1 -21
View File
@@ -1,6 +1,4 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
@@ -17,25 +15,7 @@ $e = View::escape(...);
<div class="network-group" id="<?= $e($slug) ?>">
<?php if ($standalone): ?><h2><?= $e($group['name']) ?></h2><?php else: ?><h3><?= $e($group['name']) ?></h3><?php endif ?>
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
<ul class="network-list">
<?php foreach ($group['articles'] as $item): ?>
<?php
$card = $item['card'];
['primary' => $target, 'detail' => $detail] = DirectoryCard::links($item, Html::articleBody($item));
?>
<li>
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
<?php if (!empty($card['image'])): ?>
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
<?php endif ?>
<span><?= $e($item['title']) ?></span>
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
<?php if ($standalone && $detail !== ''): ?>
<a class="network-detail" href="<?= $e($detail) ?>">查看详情</a>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
<?= View::fragment('network-items', ['articles' => $group['articles'], 'standalone' => $standalone]) ?>
</div>
<?php endforeach ?>
</div>
+27
View File
@@ -0,0 +1,27 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?>
<ul class="network-list">
<?php foreach ($articles as $item): ?>
<?php
$card = $item['card'];
['primary' => $target, 'detail' => $detail] = DirectoryCard::links($item, Html::articleBody($item));
?>
<li>
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
<?php if (!empty($card['image'])): ?>
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
<?php endif ?>
<span><?= $e($item['title']) ?></span>
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
<?php if ($standalone && $detail !== ''): ?>
<a class="network-detail" href="<?= $e($detail) ?>">查看详情</a>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
+19 -13
View File
@@ -1,16 +1,22 @@
<?php
use App\Content\PageTemplates;
use App\Content\View;
$e = View::escape(...);
$home = $page['slug'] === 'home';
$service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
$showHero = $page['visibility']['hero'] ?? true;
$heroLinks = array_filter($page['sections'], static fn (array $section): bool => $section['style'] === 'hero-links');
$alignments = $page['alignments'];
$alignField = static fn (string $name): string => $canvas ? ' data-studio-align-field="' . $name . '"' : '';
$field = static fn (string $name): string => $canvas ? ' data-studio-field="' . $name . '"' : '';
?>
<?php if (!$showHero && !$canvas): ?><h1 class="sr-only"><?= $e($page['name']) ?></h1><?php endif ?>
<?php if ($showHero || $canvas || $heroLinks): ?>
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>">
<?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): ?>
<nav class="breadcrumbs" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList">
@@ -55,16 +61,12 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
</div>
<?php endif ?>
</div>
<?php if ($home): ?>
<div class="wrap hero-directory">
<a class="overline directory-label" href="/services">产品与服务</a>
<a href="/pagepan"><span>PAGEPAN</span><small>可视化建站</small></a>
<a href="/highspeaker"><span>HighSpeaker DNS</span><small>开源智能解析</small></a>
<a href="/sc"><span>软著代理</span><small>登记申请与材料服务</small></a>
<a href="/shnu-sc"><span>SHNU 学生</span><small>软著申请方案</small></a>
</div>
<?php endif ?>
<?php foreach ($heroLinks as $section): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
<?php endforeach ?>
</section>
<?php endif ?>
<?php if ($canvas || $page['quicklinks']): ?>
<nav class="section-nav" aria-label="本页目录"<?= $canvas ? ' data-studio-navigation' : '' ?><?= !$page['quicklinks'] ? ' hidden' : '' ?>>
<div class="wrap section-nav-inner">
@@ -75,14 +77,18 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
</nav>
<?php endif ?>
<?php foreach ($page['sections'] as $section): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => $home && $section['key'] === 'about', 'canvas' => $canvas]) ?>
<?php if ($section['style'] !== 'hero-links'): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => $home && $section['key'] === 'about', 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
<?php endif ?>
<?php endforeach ?>
<?php if (($showHero || $canvas) && ($credit = PageTemplates::photoCredit($page['image']))): ?>
<p class="wrap page-photo-credit"<?= $showHero ? '' : ' hidden' ?>>摄影 <a href="<?= $e($credit[2]) ?>"><?= $e($credit[0]) ?></a> ·
<?php if ($credit[3]): ?><a href="<?= $e($credit[3]) ?>"><?= $e($credit[1]) ?></a><?php else: ?><?= $e($credit[1]) ?><?php endif ?>
</p>
<?php endif ?>
<?php if ($canvas): ?>
<template data-studio-section-end><?= View::fragment('section', [
'section' => ['style' => 'plain', 'key' => 'new', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
'moment' => false, 'canvas' => true,
]) ?></template>
<?php endif ?>
<?php if ($home): ?>
<?= View::fragment('network-groups', ['network' => $network, 'standalone' => false]) ?>
<?php endif ?>
+35 -4
View File
@@ -4,20 +4,51 @@ use App\Content\View;
$e = View::escape(...);
$canvas ??= false;
$body = $section['body'];
$dynamic = isset($section['feed']);
$studio = $canvas ? ' data-studio-section="' . $e($section['version']) . '" data-studio-source="' . $e(base64_encode($section['body'])) . '"' : '';
if ($canvas && $dynamic) {
$studio .= ' data-studio-dynamic data-studio-feed="' . $e($section['feed']) . '" tabindex="0"';
}
if ($section['style'] === 'hero-links'):
?>
<div class="wrap hero-directory-slot" id="<?= $e($section['key']) ?>"<?= $studio ?>>
<?php if ($canvas): ?><span data-studio-part="title" hidden><?= $e($section['title']) ?></span><span data-studio-part="lead" hidden><?= $e($section['lead']) ?></span><?php endif ?>
<div<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div>
</div>
<?php
return;
endif;
$alignments = json_decode($section['alignments'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
if (isset($section['articleFeed']) && $body === '<p><a class="back-link" href="/articles">查看全部动态</a></p>') {
if ($dynamic && $body === '<p><a class="back-link" href="/articles">查看全部动态</a></p>') {
$body = '';
}
$network = $section['networkFeed'] ?? false;
$catalog = $section['catalogFeed'] ?? false;
?>
<section class="section section-<?= $e($section['style']) ?>" id="<?= $e($section['key']) ?>" aria-labelledby="heading-<?= $e($section['key']) ?>" <?= $moment ? 'data-moment="iris-opens"' : '' ?><?= $canvas ? ' data-studio-section="' . $e($section['version']) . '" data-studio-source="' . $e(base64_encode($section['body'])) . '"' : '' ?>>
<section class="section section-<?= $e($section['style']) ?><?= $network ? ' network' : '' ?>" id="<?= $e($section['key']) ?>" aria-labelledby="heading-<?= $e($section['key']) ?>" <?= $moment ? 'data-moment="iris-opens"' : '' ?><?= $studio ?>>
<div class="wrap">
<div class="section-heading">
<h2 id="heading-<?= $e($section['key']) ?>"<?= isset($alignments['title']) ? ' class="' . trim(View::alignmentClass($alignments['title'])) . '"' : '' ?><?= $canvas ? ' data-studio-part="title"' : '' ?>><?= $e($section['title']) ?></h2>
<?php if ($canvas || $section['lead']): ?><p<?= isset($alignments['lead']) ? ' class="' . trim(View::alignmentClass($alignments['lead'])) . '"' : '' ?><?= $canvas ? ' data-studio-part="lead"' : '' ?>><?= $e($section['lead']) ?></p><?php endif ?>
</div>
<?php if (!empty($section['articleFeed'])): ?>
<?php if ($network): ?>
<?php foreach ($section['articleFeed'] as $group): ?>
<?php $slug = $group['categories'][0]; $anchor = ($pageSlug ?? '') === 'home' && $section['key'] === 'network' ? $slug : $section['key'] . '-group-' . $slug; ?>
<div class="network-group" id="<?= $e($anchor) ?>">
<h3><?= $e($group['label']) ?></h3>
<?= View::fragment('network-items', ['articles' => $group['articles'], 'standalone' => false]) ?>
</div>
<?php endforeach ?>
<?php if ($section['archivePath'] !== null): ?><p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p><?php endif ?>
<?php elseif ($catalog): ?>
<?= View::fragment('service-cards', ['products' => $section['articleFeed'][0]['articles']]) ?>
<?php if ($section['archivePath'] !== null && count($section['articleFeed'][0]['articles']) >= $section['feedLimit']): ?>
<p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p>
<?php endif ?>
<?php elseif (!empty($section['articleFeed'])): ?>
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key'], 'archivePath' => $section['archivePath']]) ?>
<?php endif ?>
<?php if ($canvas || $body !== ''): ?><div class="rich<?= !empty($section['articleFeed']) ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div><?php endif ?>
<?php if ($canvas || $body !== ''): ?><div class="rich<?= $dynamic ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div><?php endif ?>
</div>
</section>
+38
View File
@@ -0,0 +1,38 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?>
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
<div class="catalog-grid">
<?php foreach ($products as $product): ?>
<?php
$card = $product['card'];
$body = Html::articleBody($product);
$target = DirectoryCard::links($product, $body)['primary'];
$extra = $card['extra_url'] ?? '';
?>
<article class="catalog-card">
<?php if (!empty($card['image'])): ?>
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
<?php endif ?>
<div class="catalog-content">
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<h3><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h3>
<?php if ($product['summary']): ?>
<p><?= $e($product['summary']) ?></p>
<?php else: ?>
<div class="rich"><?= $body ?></div>
<?php endif ?>
<?php if ($target !== '' || $extra !== ''): ?>
<div class="actions">
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
</div>
<?php endif ?>
</div>
</article>
<?php endforeach ?>
</div>
-50
View File
@@ -1,50 +0,0 @@
<?php
use App\Content\DirectoryCard;
use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?>
<section class="section catalog-hero">
<div class="wrap">
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
<h1>产品与服务</h1>
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
</div>
</section>
<section class="section catalog-listing" aria-label="产品与服务目录">
<div class="wrap">
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
<div class="catalog-grid">
<?php foreach ($products as $product): ?>
<?php
$card = $product['card'];
$body = Html::articleBody($product);
['primary' => $target, 'detail' => $detail] = DirectoryCard::links($product, $body);
$extra = $card['extra_url'] ?? '';
?>
<article class="catalog-card">
<?php if (!empty($card['image'])): ?>
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
<?php endif ?>
<div class="catalog-content">
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
<?php if ($product['summary']): ?>
<p><?= $e($product['summary']) ?></p>
<?php else: ?>
<div class="rich"><?= $body ?></div>
<?php endif ?>
<?php if ($target !== '' || $extra !== ''): ?>
<div class="actions">
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
<?php if ($detail !== '' && $detail !== $extra): ?><a class="catalog-detail" href="<?= $e($detail) ?>">查看详情</a><?php endif ?>
</div>
<?php endif ?>
</div>
</article>
<?php endforeach ?>
</div>
</div>
</section>
+24
View File
@@ -0,0 +1,24 @@
<?php
use App\Content\BlockTemplates;
use App\Content\View;
$e = View::escape(...);
?>
<details class="studio-anchor-create">
<summary>按锚点新建区块</summary>
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="operation" value="create">
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
<label>模板<select name="preset">
<?php foreach (BlockTemplates::groups() as [$category, $templates]): ?>
<optgroup label="<?= $e($category) ?>">
<?php foreach ($templates as $preset => [$label]): ?>
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
<?php endforeach ?>
</optgroup>
<?php endforeach ?>
</select></label>
<button type="submit" class="button button-outline">新建</button>
</form>
</details>
+15
View File
@@ -0,0 +1,15 @@
<?php
use App\Content\View;
$e = View::escape(...);
$modes = ($allowOff ? ['off' => '不展示'] : []) + ['merged' => '合并列表', 'tabs' => '分类标签页', 'network' => '项目与伙伴卡片', 'catalog' => '产品与服务卡片'];
?>
<div class="form-grid">
<label>展示方式<select name="feed_mode">
<?php foreach ($modes as $mode => $label): ?>
<option value="<?= $mode ?>" <?= ($feed['mode'] ?? 'off') === $mode ? 'selected' : '' ?>><?= $e($label) ?></option>
<?php endforeach ?>
</select></label>
<label>展示数量<input name="feed_limit" type="number" required min="1" max="30" value="<?= $e($feed['limit'] ?? 6) ?>"><small>分组时每个分类独立计数。</small></label>
</div>
<?= View::fragment('admin-category-checkboxes', ['name' => 'feed_categories', 'selected' => $feed['categories'] ?? [], 'categories' => $categories, 'legend' => '展示分类']) ?>
+12
View File
@@ -0,0 +1,12 @@
<?php
$paths = [
'left' => '<path d="M3 6h18M3 10h12M3 14h18M3 18h12"/>',
'center' => '<path d="M3 6h18M6 10h12M3 14h18M6 18h12"/>',
'right' => '<path d="M3 6h18M9 10h12M3 14h18M9 18h12"/>',
'settings' => '<path d="M4 6h12m4 0h0M4 12h3m4 0h9M4 18h10m4 0h2"/><circle cx="17" cy="6" r="2"/><circle cx="9" cy="12" r="2"/><circle cx="16" cy="18" r="2"/>',
'edit' => '<path d="m14 5 5 5M5 19l4-.8L20 7.3 16.7 4 5.8 15z"/>',
'copy' => '<rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 4H6a2 2 0 0 0-2 2v10"/>',
'delete' => '<path d="M4 7h16M9 7V4h6v3m3 0-.8 13H6.8L6 7m4 4v5m4-5v5"/>',
];
?>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><?= $paths[$icon] ?></svg>
+3 -28
View File
@@ -1,39 +1,14 @@
<?php
use App\Content\BlockTemplates;
use App\Content\View;
$e = View::escape(...);
?>
<details class="studio-layers">
<summary>首屏与目录</summary>
<button type="button" disabled data-hero-control="image">首屏图片</button>
<button type="button" disabled data-hero-control="1">首屏按钮 1</button>
<button type="button" disabled data-hero-control="2">首屏按钮 2</button>
<button type="button" disabled data-hero-control="navigation">本页目录</button>
</details>
<details class="studio-layers">
<summary>按锚点新建区块</summary>
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="operation" value="create">
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
<label>模板<select name="preset">
<?php foreach (BlockTemplates::GROUPS as [$category, $templates]): ?>
<optgroup label="<?= $e($category) ?>">
<?php foreach ($templates as $preset => [$label]): ?>
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
<?php endforeach ?>
</optgroup>
<?php endforeach ?>
</select></label>
<button type="submit" class="button button-outline">新建</button>
</form>
</details>
<details class="studio-layers" id="blocks">
<summary>区块顺序</summary>
<ul class="admin-list studio-blocks">
<?php foreach ($page['sections'] as $index => $item): ?>
<?php $fixedSlot = $item['style'] === 'hero-links'; ?>
<li>
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
<div class="actions studio-block-actions">
@@ -44,8 +19,8 @@ $e = View::escape(...);
<input type="hidden" name="key" value="<?= $e($item['key']) ?>">
<input type="hidden" name="page_version" value="<?= $e($page['version']) ?>">
<input type="hidden" name="version" value="<?= $e($item['version']) ?>">
<button class="button button-outline" name="operation" value="up" type="submit" <?= $index === 0 ? 'disabled' : '' ?>>上移</button>
<button class="button button-outline" name="operation" value="down" type="submit" <?= $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
<button class="button button-outline" name="operation" value="up" type="submit" <?= $fixedSlot || $index === 0 || $page['sections'][$index - 1]['style'] === 'hero-links' ? 'disabled' : '' ?>>上移</button>
<button class="button button-outline" name="operation" value="down" type="submit" <?= $fixedSlot || $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
<button class="button button-outline" name="operation" value="delete" type="submit" data-confirm="删除这个区块?">删除</button>
</form>
</div>
+5 -3
View File
@@ -13,6 +13,7 @@ $modules = $kind === 'modules';
</button></li>
<?php endforeach ?>
</ul>
<?php if ($modules): ?><?= $anchorForm ?><?php endif ?>
<div class="studio-library-content" data-library-content hidden>
<div class="studio-library-category-title">
<button type="button" data-library-back>返回分类</button>
@@ -26,7 +27,7 @@ $modules = $kind === 'modules';
<?php foreach ($groups as $group => [$category, $items]): ?>
<div class="<?= $modules ? 'studio-template-cards' : 'studio-element-items' ?>" data-template-group="<?= $e($group) ?>" hidden>
<?php foreach ($items as $key => $item): ?>
<?php [$label, $markup, $mime] = array_pad($item, 3, ''); ?>
<?php [$label, $markup, $option, $feed] = array_pad($item, 4, null); ?>
<?php if ($modules): ?>
<article class="studio-template-card" data-template-card data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
<button type="button" class="studio-template-image" data-template-preview="<?= $e($key) ?>" data-template-title="<?= $e($label) ?>"
@@ -36,14 +37,15 @@ $modules = $kind === 'modules';
<div class="studio-template-meta">
<span><?= $e($label) ?></span>
<button type="button" class="button button-outline" disabled data-canvas-template="<?= $e($key) ?>"
data-template-title="<?= $e($label) ?>" aria-label="添加<?= $e($label) ?>组件">添加</button>
data-template-title="<?= $e($label) ?>" data-template-lead="<?= $e($option) ?>" data-template-style="<?= $e($item[4] ?? 'plain') ?>"
<?= $feed !== null ? 'data-template-feed="' . $e($feed) . '"' : '' ?> aria-label="添加<?= $e($label) ?>组件">添加</button>
</div>
<template data-preset="<?= $e($key) ?>"><?= $markup ?></template>
</article>
<?php else: ?>
<div data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
<button type="button" disabled data-canvas-element="<?= $e($key) ?>"
<?php if ($mime): ?>data-element-mime="<?= $e($mime) ?>"<?php endif ?>
<?php if ($option): ?>data-element-mime="<?= $e($option) ?>"<?php endif ?>
aria-label="插入<?= $e($label) ?>"><?= $e($label) ?></button>
<template data-element="<?= $e($key) ?>"><?= $markup ?></template>
</div>
+5 -1
View File
@@ -4,7 +4,10 @@ use App\Content\View;
$e = View::escape(...);
?>
<a class="back-link" href="/admin">返回页面</a>
<header class="admin-heading"><h1>新建页面</h1></header>
<header class="admin-heading">
<h1>新建页面</h1>
<button type="button" class="button button-outline" data-open-page-templates hidden>整页模板</button>
</header>
<?= View::fragment('admin-feedback', ['error' => $error, 'saved' => false]) ?>
<form class="admin-form admin-panel" method="post" action="/admin/new-page">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
@@ -14,3 +17,4 @@ $e = View::escape(...);
</label>
<div class="form-submit"><button type="submit" class="button button-primary">创建草稿</button></div>
</form>
<?= View::fragment('studio-page-templates', compact('token', 'openTemplates')) ?>
+60
View File
@@ -0,0 +1,60 @@
<?php
use App\Content\PageTemplates;
use App\Content\View;
$e = View::escape(...);
$groups = PageTemplates::groups();
$previewRoot = '/assets/page-templates/';
?>
<dialog class="page-template-drawer" data-page-template-drawer<?= !empty($openTemplates) ? ' data-open-on-load' : '' ?> aria-labelledby="page-template-title">
<header class="page-template-header">
<h2 id="page-template-title">整页模板</h2>
<button type="button" class="button button-outline" data-close-page-templates>关闭</button>
</header>
<div class="page-template-content">
<section data-template-panel="groups" aria-labelledby="page-template-groups">
<h3 id="page-template-groups" tabindex="-1">选择套系</h3>
<div class="page-template-groups">
<?php foreach ($groups as $key => $group): ?>
<button type="button" class="page-template-card" data-template-group="<?= $e($key) ?>">
<span class="page-template-image"><img src="<?= $e($previewRoot . $key . '.webp') ?>" width="768" height="480" alt="" loading="lazy"></span>
<span class="page-template-card-copy"><strong><?= $e($group['name']) ?></strong><small><?= $e($group['description']) ?></small></span>
</button>
<?php endforeach ?>
</div>
</section>
<?php foreach ($groups as $key => $group): ?>
<section data-template-panel="<?= $e($key) ?>" aria-labelledby="page-template-<?= $e($key) ?>" hidden>
<button type="button" class="button button-outline page-template-back" data-template-back="groups">返回套系</button>
<h3 id="page-template-<?= $e($key) ?>" tabindex="-1"><?= $e($group['name']) ?></h3>
<div class="page-template-pages">
<?php foreach ($group['pages'] as $pageKey => $pageTemplate): ?>
<button type="button" class="page-template-card" data-page-template="<?= $e($pageKey) ?>">
<span class="page-template-image"><img src="<?= $e($previewRoot . $pageKey . '.webp') ?>" width="768" height="480" alt="" loading="lazy"></span>
<span class="page-template-card-copy"><strong><?= $e($pageTemplate['name']) ?></strong></span>
</button>
<?php endforeach ?>
</div>
</section>
<?php endforeach ?>
<section data-template-panel="detail" aria-labelledby="page-template-detail-heading" hidden>
<button type="button" class="button button-outline page-template-back" data-template-back="pages">返回套内页面</button>
<h3 id="page-template-detail-heading" data-template-name tabindex="-1"></h3>
<div class="page-template-detail">
<div>
<div class="page-template-image"><img data-template-preview width="768" height="480" alt=""></div>
<a class="button button-outline page-template-preview-link" data-template-live target="_blank" rel="noopener">打开完整页面预览</a>
</div>
<form class="admin-form" method="post" action="/admin/new-page">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="template">
<div class="form-grid">
<label>页面名称<input name="name" maxlength="100" required></label>
<label>网址标识<input name="slug" maxlength="70" pattern="[a-z0-9]+(-[a-z0-9]+)*" required></label>
</div>
<div class="form-submit"><button type="submit" class="button button-primary">用此模板创建草稿</button></div>
</form>
</div>
</section>
</div>
</dialog>
+2 -2
View File
@@ -13,8 +13,8 @@ $labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
aria-selected="false" tabindex="-1" data-library-tab="<?= $kind ?>"><?= $e($label) ?></button>
<?php endforeach ?>
</div>
<?php foreach (['modules' => BlockTemplates::GROUPS, 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
<?= View::fragment('studio-library-panel', compact('kind', 'groups')) ?>
<?php foreach (['modules' => BlockTemplates::groups(), 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
<?= View::fragment('studio-library-panel', compact('kind', 'groups', 'anchorForm')) ?>
<?php endforeach ?>
<section role="tabpanel" id="studio-panel-layers" aria-labelledby="studio-tab-layers" data-library-panel="layers">
<?= $layers ?>
+2 -2
View File
@@ -10,10 +10,8 @@ use Webman\Route;
Route::disableDefaultRoute();
Route::get('/', [SiteController::class, 'home']);
Route::get('/services', [SiteController::class, 'services']);
Route::get('/network', [SiteController::class, 'network']);
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
Route::get('/articles', [SiteController::class, 'archive']);
Route::get('/articles/category/{category:[a-z0-9-]+}', [SiteController::class, 'archive']);
Route::get('/articles/tag/{tag:[^/]+}', [SiteController::class, 'tagged']);
Route::get('/articles/feed/{slug:[a-z0-9-]+}/{key:[a-z0-9-]+}', [SiteController::class, 'feedArchive']);
@@ -33,7 +31,9 @@ Route::add(['GET', 'POST'], '/admin/article-categories', [AdminController::class
Route::get('/admin/articles', [AdminController::class, 'articles']);
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
Route::post('/admin/articles/{id:[0-9]+}/delete', [AdminController::class, 'deleteArticle']);
Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPage']);
Route::get('/admin/page-templates/{key:[a-z0-9-]+}/preview', [StudioController::class, 'previewTemplate']);
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
Route::add(['GET', 'POST'], '/admin/settings/{part:header|footer|cdn}', [StudioController::class, 'settings']);
+32 -11
View File
@@ -37,6 +37,8 @@
.feedback { padding: .8rem 1rem; border-radius: .5rem; }
.feedback.error { background: #feebeb; color: #9c252a; }
.feedback.success { background: #e5f6ed; color: #126044; }
.button-danger { color: #9c252a; background: transparent; border-color: #e6b6b9; }
.button-danger:hover { color: #9c252a; background: #feebeb; }
.editor { display: grid; gap: .45rem; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
@@ -132,16 +134,19 @@
.studio-layers .studio-block-actions .button { min-height: 2.25rem; padding: .25rem .5rem; font-size: .8rem; }
.studio-media-sizing { position: absolute; z-index: 1; inset: auto .6rem .6rem auto; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .45rem .6rem; max-width: calc(100% - 1.2rem); background: var(--accent-light); border: 1px solid var(--line); border-radius: .45rem; }
.studio-element-tools {
position: absolute; z-index: 3; display: flex; align-items: center; gap: .15rem; padding: .2rem;
border: 1px solid #3f62e0; border-radius: .65rem; background: #244bc8;
box-shadow: 0 .22rem .7rem #13297538;
position: absolute; z-index: 3; display: flex; align-items: center; gap: .12rem; padding: .18rem;
border: 1px solid #c7d6f3; border-radius: .52rem; background: var(--white);
box-shadow: 0 .22rem .85rem #16305230;
}
.studio-element-tools button {
min-height: 2rem; padding: .22rem .6rem; border: 0; border-radius: .42rem;
background: transparent; color: white; font-size: .84rem; white-space: nowrap; cursor: pointer;
display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
border: 0; border-radius: .32rem; background: transparent; color: #35496d; cursor: pointer;
}
.studio-element-tools button:hover, .studio-element-tools button:focus-visible { background: #ffffff32; }
.studio-element-tools button:focus-visible { outline: 1px solid white; outline-offset: -2px; }
.studio-element-tools button svg { width: 1rem; height: 1rem; pointer-events: none; }
.studio-element-tools button:hover, .studio-element-tools button:focus-visible { background: var(--accent-light); color: var(--accent-deep); }
.studio-element-tools button:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
.studio-element-tools button[data-element-delete]:hover { color: #a12727; background: #fceeee; }
.studio-element-tools.is-module [data-element-module-settings] { background: var(--accent-light); color: var(--accent-deep); }
.studio-media-handle {
position: absolute; z-index: 2; width: 1.4rem; height: 2.8rem; translate: -50% -50%;
display: grid; place-content: center; border: 2px solid white; border-radius: .42rem;
@@ -245,9 +250,8 @@
.article-editor-heading > .button { min-height: 2.1rem; padding: .25rem .6rem; }
.article-editor-help:empty { display: none; }
.studio-element-align { display: flex; gap: .05rem; padding-inline-end: .2rem; border-inline-end: 1px solid #ffffff55; }
.studio-element-align button { padding-inline: .38rem; }
.studio-element-align button[aria-pressed="true"] { background: white; color: #244bc8; }
.studio-element-align { display: flex; gap: .05rem; padding-inline-end: .15rem; border-inline-end: 1px solid var(--line); }
.studio-element-align button[aria-pressed="true"] { background: var(--accent-light); color: var(--accent-deep); }
.admin-primary a { padding: .28rem .65rem; border-radius: .48rem; color: var(--muted); }
.admin-primary a[aria-current="page"] { background: var(--accent-light); color: var(--accent-deep); }
@@ -283,7 +287,8 @@
.dashboard-secondary .admin-list li { gap: .35rem .65rem; }
.dashboard-secondary .admin-list .button { min-height: 2.15rem; padding: .25rem .5rem; font-size: .82rem; }
.dashboard-settings h2 { margin-bottom: .55rem; }
.dashboard-settings ul { display: flex; flex-wrap: wrap; gap: .45rem 1.15rem; list-style: none; padding: 0; margin: 0; }
.dashboard-setting-buttons { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: 0; margin: 0; }
.dashboard-setting-buttons .button { min-height: 2.45rem; padding: .3rem .6rem; font-size: .85rem; }
@media (max-width: 51rem) {
.dashboard-grid { grid-template-columns: 1fr; gap: 0; }
@@ -293,3 +298,19 @@
.dashboard-page-list li { grid-template-columns: minmax(0, 1fr) auto; }
.dashboard-page-actions { grid-column: 1 / -1; }
}
.studio-page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.studio-page-meta code { color: var(--muted); font-size: .86rem; }
.studio-anchor-create, .studio-hero-settings { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .45rem; }
.studio-anchor-create { margin-top: .55rem; font-size: .84rem; }
.studio-anchor-create summary, .studio-hero-settings summary { cursor: pointer; font-weight: 630; }
.studio-anchor-create[open] form, .studio-hero-controls { margin-top: .6rem; }
.studio-hero-controls { display: flex; flex-wrap: wrap; gap: .42rem; }
.studio-hero-controls .button { min-height: 2.35rem; padding: .3rem .62rem; font-size: .85rem; }
.studio-canvas-status:empty { display: none; }
.canvas-module-settings { max-width: min(92vw, 40rem); }
@media (pointer: coarse) {
.studio-element-tools button { width: 2.5rem; height: 2.5rem; }
}
.canvas-module-settings .category-checks { max-height: min(15rem, 27dvh); overflow-y: auto; }
.canvas-module-settings .actions { position: sticky; bottom: 0; padding-block: .35rem; margin: 0; background: var(--white); }
+64
View File
@@ -0,0 +1,64 @@
.page-template-drawer {
position: fixed;
inset: 0 0 0 auto;
margin: 0;
width: min(100%, clamp(45rem, 80vw, 78rem));
max-width: none;
height: 100dvh;
max-height: none;
overflow: auto;
overscroll-behavior: contain;
border: 0;
padding: 0;
background: var(--white);
color: var(--ink);
box-shadow: -16px 0 48px #111a2e29;
}
.page-template-drawer::backdrop { background: #111a2e60; }
.page-template-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
position: sticky;
top: 0;
z-index: 1;
padding: .9rem clamp(1rem, 4vw, 1.6rem);
background: var(--white);
border-bottom: 1px solid var(--line);
}
.page-template-header h2 { margin: 0; }
.page-template-content { padding: 1.3rem clamp(1rem, 4vw, 1.6rem) 2rem; }
.page-template-content h3 { margin-bottom: 1rem; }
.page-template-content h3:focus { outline: none; }
.page-template-back { margin-bottom: 1.15rem; }
.page-template-groups, .page-template-pages { display: grid; gap: .75rem; }
.page-template-groups { grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.page-template-pages { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-template-detail { display: grid; gap: clamp(1rem, 3vw, 2rem); align-items: start; }
.page-template-card {
display: grid;
grid-template-columns: 1fr;
width: 100%;
padding: 0;
overflow: hidden;
color: var(--ink);
background: var(--white);
border: 1px solid var(--line);
border-radius: .7rem;
text-align: start;
}
.page-template-card:hover, .page-template-card:focus-visible { border-color: var(--accent); }
.page-template-card-copy { display: grid; align-content: center; gap: .24rem; padding: clamp(.65rem, 2vw, 1rem); }
.page-template-card-copy small { line-height: 1.5; color: var(--muted); }
.page-template-image { display: block; overflow: hidden; background: var(--paper); }
.page-template-image img { width: 100%; height: auto; transition: transform 180ms ease; }
.page-template-card:hover img, .page-template-card:focus-visible img { transform: scale(1.035); }
.page-template-preview-link { margin-block: .8rem 1.2rem; }
@media (min-width: 49rem) {
.page-template-detail { grid-template-columns: minmax(0, 1.8fr) minmax(17rem, 1fr); }
.page-template-detail .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 30rem) {
.page-template-pages { grid-template-columns: 1fr; }
}
+51
View File
@@ -0,0 +1,51 @@
'use strict';
jQuery(function ($) {
$('[data-page-template-drawer]').each(function () {
const drawer = this;
const $drawer = $(drawer);
const $opener = $('[data-open-page-templates]').prop('hidden', false);
const $panels = $drawer.find('[data-template-panel]');
const $detail = $panels.filter('[data-template-panel=detail]');
const $form = $detail.find('form');
let $groupButton;
let $pageButton;
function showPanel(key, $focus) {
const $panel = $panels.filter((_, panel) => panel.dataset.templatePanel === key);
$panels.prop('hidden', true);
$panel.prop('hidden', false);
$drawer.scrollTop(0);
($focus ?? $panel.find('h3')).trigger('focus');
}
function open() {
drawer.showModal();
showPanel('groups');
}
$opener.on('click', open);
$drawer.on('close', () => $opener.trigger('focus'))
.on('click', '[data-close-page-templates]', () => drawer.close())
.on('click', '[data-template-group]', function () {
$groupButton = $(this);
showPanel(this.dataset.templateGroup);
})
.on('click', '[data-page-template]', function () {
$pageButton = $(this);
const key = this.dataset.pageTemplate;
const name = $pageButton.find('strong').text();
$detail.find('[data-template-name]').text(name);
$detail.find('[data-template-preview]').attr('src', $pageButton.find('img').attr('src'));
$detail.find('[data-template-live]').attr('href', '/admin/page-templates/' + key + '/preview');
$form.find('[name=template], [name=slug]').val(key);
$form.find('[name=name]').val(name);
$form.children('.ajax-feedback').prop('hidden', true);
showPanel('detail');
})
.on('click', '[data-template-back=groups]', () => showPanel('groups', $groupButton))
.on('click', '[data-template-back=pages]', () => showPanel($groupButton.attr('data-template-group'), $pageButton));
if ($drawer.is('[data-open-on-load]')) open();
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

+172
View File
@@ -0,0 +1,172 @@
.page-theme {
color: var(--ink);
background: var(--white);
--space-section: clamp(3.5rem, 7vw, 7rem);
}
.page-theme .hero-inner { min-height: clamp(29rem, 46vw, 44rem); }
.page-theme .hero h1 { font-size: clamp(2.65rem, 5vw, 5.2rem); text-wrap: balance; }
.page-theme .hero-text-only .hero-copy { max-width: 49rem; }
.page-theme .app-frame img { aspect-ratio: 4 / 3; object-fit: contain; }
.page-theme .section-heading h2 { font-size: clamp(1.9rem, 4vw, 3.6rem); }
.page-theme .page-photo-credit { padding-bottom: 1.4rem; margin-bottom: 0; color: var(--muted); font-size: .875rem; }
.page-theme .studio-code { color: #e7eeff; background: #202938; border-color: #39465d; }
.page-theme .studio-code code { white-space: pre-wrap; overflow-wrap: anywhere; }
.theme-cobalt {
--white: #fdfdff;
--paper: #f0f4fb;
--ink: #162237;
--muted: #46586f;
--line: #cbd7e5;
--accent: #184ed3;
--accent-deep: #153a9b;
}
.theme-cobalt .hero {
background: radial-gradient(ellipse at 77% 28%, #c9dafa 0, transparent 45%),
radial-gradient(circle, #96adc8 1px, transparent 1px) 0 0 / 16px 16px, var(--paper);
}
.theme-cobalt .app-frame {
border-radius: 1.1rem .2rem;
border-color: #4c6284;
background: #252f40;
box-shadow: 0 24px 45px -30px #2136569c;
}
.theme-cobalt .button { border-radius: .25rem; border-bottom-width: 3px; }
.theme-cobalt .button-outline { background: var(--white); }
.theme-cobalt .button-primary { border-bottom-color: #123884; }
.template-ledger { border-block-start: 2px solid var(--ink); }
.template-ledger article { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 1rem; padding: 1.35rem 0; border-bottom: 1px solid var(--line); }
.template-ledger article h3 { margin: 0; }
.theme-studio {
--white: #fbfaf7;
--paper: #eeeae2;
--ink: #211e19;
--muted: #5f5547;
--line: #cfc5b6;
--accent: #9c3818;
--accent-deep: #78290f;
--accent-light: #ffe7d5;
}
.theme-studio .hero {
background: radial-gradient(circle, #9d8269 1px, transparent 1px) 0 0 / 24px 24px, var(--paper);
}
.theme-studio .hero-copy { background: var(--paper); padding-block: .85rem 1.25rem; }
.theme-studio :is(h1, h2, h3) {
font-family: 'Noto Serif CJK SC', 'Songti SC', 'STSong', Georgia, serif;
font-weight: 560;
letter-spacing: -.055em;
}
.theme-studio .app-frame {
padding: .45rem;
border-radius: 0;
border-color: #6f5342;
outline: 1px solid #a24528;
outline-offset: .45rem;
background: var(--white);
box-shadow: 12px 19px 0 -9px #684e3429;
}
.theme-studio .app-frame img { border-radius: 0; object-fit: cover; }
.theme-studio .button { border-radius: .15rem; }
.theme-studio .button-primary { color: #231911; background: #f3a578; border-color: #713a24; }
.theme-studio .button-primary:hover { background: #f8ba96; }
.theme-studio .button-outline { background: var(--white); border-color: #827261; }
.template-portfolio { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.4rem, 5vw, 4rem); }
.template-portfolio img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border: 1px solid var(--line); border-radius: 0; background: var(--paper); }
.template-portfolio h3 { margin-top: 1rem; }
.theme-dusk {
--white: #191d2b;
--paper: #222739;
--ink: #f7f4f2;
--muted: #bfc5d8;
--line: #505971;
--accent: #bdc7ff;
--accent-deep: #dbe1ff;
--accent-light: #343d5e;
}
.theme-dusk .hero { background: radial-gradient(ellipse at 77% 48%, #454255 0, #222639 46%, #191d2b 78%); }
.theme-dusk .app-frame {
border: 1px solid #8b869c;
background: #514d6370;
padding: .6rem;
box-shadow: 0 21px 65px -20px #090a18ab;
}
.theme-dusk .app-frame img { object-fit: cover; }
.theme-dusk .button-primary, .theme-dusk .button-primary:hover { color: #151a30; }
.theme-dusk .button-outline { color: var(--ink); border-color: #8c96b0; }
.theme-dusk .button-outline:hover { color: var(--accent-deep); background: var(--paper); }
.theme-dusk .crumb-divider { color: var(--muted); }
.theme-dusk .article-tabs button { background: var(--white); }
.template-steps {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: clamp(1.25rem, 4vw, 3rem);
border-block-start: 1px solid var(--line);
}
.rich .template-steps { padding-inline-start: 1.6rem; }
.template-steps li { padding: 1.35rem .25rem 0; }
.template-steps li::marker { color: var(--accent); font-weight: 650; }
@media (max-width: 44rem) {
.page-theme .hero-inner { min-height: auto; }
.template-ledger article, .template-portfolio, .template-steps { grid-template-columns: 1fr; }
.template-ledger article { gap: .4rem; }
.template-steps { gap: .8rem; }
}
.theme-vantage {
--white: #121b20;
--paper: #1b272d;
--ink: #eef4f1;
--muted: #bdcdc8;
--line: #53676b;
--accent: #bfe971;
--accent-deep: #d7ffa0;
--accent-light: #2e4233;
}
.theme-vantage .hero {
background: radial-gradient(ellipse at 82% 35%, #243b39, transparent 65%),
radial-gradient(circle, #4b6959 1px, transparent 1.4px) 0 0 / 18px 18px, var(--white);
}
.theme-vantage .hero-copy { background: #121b20; padding-block: 1rem; }
.theme-vantage .app-frame { border: 1px solid #618076; border-radius: .2rem; background: #263738; box-shadow: 8px 8px 0 #172e26; }
.theme-vantage .app-frame img, .theme-vantage .button { border-radius: .2rem; }
.theme-vantage .button-primary, .theme-vantage .button-primary:hover { color: #172318; }
.theme-vantage .button-outline { border-color: #7d9b8e; color: var(--ink); }
.theme-vantage .button-outline:hover { background: var(--paper); }
.theme-ribbon {
--white: #fffdfb;
--paper: #f0eaf8;
--ink: #2d2546;
--muted: #5a516e;
--line: #d9cce8;
--accent: #633ab1;
--accent-deep: #4d268e;
--accent-light: #ebdfff;
}
.theme-ribbon .hero { background: radial-gradient(ellipse at 88% 24%, #d9c5f3, transparent 60%), #f5eff9; }
.theme-ribbon .app-frame { border-color: #b9a1db; border-radius: clamp(1.4rem, 4vw, 3rem); background: #fffafc; box-shadow: 0 22px 65px -31px #68489b83; }
.theme-ribbon .app-frame img { border-radius: 1rem; object-fit: cover; }
.theme-ribbon .button { border-radius: 2rem; }
.theme-ribbon .button-outline { border-color: #ac99c8; background: var(--white); }
.theme-ribbon .studio-split img { border-radius: 1.4rem; border: 1px solid var(--line); }
.theme-furrow {
--white: #fdf9ee;
--paper: #f1e9d5;
--ink: #262b1c;
--muted: #5a5847;
--line: #c9bd9f;
--accent: #325335;
--accent-deep: #233a27;
--accent-light: #e3ecd9;
}
.theme-furrow .hero { background: linear-gradient(115deg, #f7f0dd, #eee2c5); }
.theme-furrow .hero-copy { border-inline-start: .3rem solid #b67e28; padding-inline-start: clamp(1rem, 2.6vw, 2.2rem); }
.theme-furrow :is(h1, h2) { font-family: 'Noto Serif CJK SC', 'Songti SC', Georgia, serif; }
.theme-furrow .app-frame { border: 1px solid #9f946f; border-radius: .3rem; background: #fff8e7; box-shadow: 9px 9px 0 #c6ae7d56; }
.theme-furrow .app-frame img { border-radius: .15rem; }
.theme-furrow .button { border-radius: .2rem; }
.theme-furrow .button-outline { border-color: #908764; background: var(--white); }
+22 -10
View File
@@ -152,15 +152,14 @@ address { font-style: normal; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumb-divider { color: #74859d; }
.hero-directory {
display: grid;
grid-template-columns: minmax(0, .9fr) repeat(4, minmax(0, 1fr));
display: flex;
border: 1px solid var(--line);
border-radius: .85rem .85rem 0 0;
background: #ffffffb8;
min-height: 7rem;
border-bottom: 0;
}
.hero-directory > * { display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); }
.hero-directory > * { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); overflow-wrap: anywhere; }
.hero-directory a { color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); transition: background-color 160ms ease, color 160ms ease; }
.hero-directory a:hover { color: var(--accent); background: #fff; }
.hero-directory a span { font-size: 1.12rem; font-weight: 670; }
@@ -263,7 +262,7 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.contact-panel { display: flex; flex-wrap: wrap; gap: 1.4rem 3rem; align-items: center; }
.contact-panel img { width: 10rem; border: 1px solid var(--line); }
.resource-box { max-width: 46rem; }
.faq { max-width: 62rem; border-top: 1px solid var(--line); }
.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 1.05rem 2.5rem 1.05rem 0; min-height: 48px; position: relative; list-style: none; font-weight: 630; }
.faq summary::-webkit-details-marker { display: none; }
@@ -350,10 +349,11 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.hero-lead { margin-bottom: 1.3rem; }
.hero-illustration { border-radius: 1.15rem; }
.hero-illustration img { border-radius: .8rem; }
.hero-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .2rem; }
.hero-directory > .overline { grid-column: 1 / -1; }
.hero-directory { flex-wrap: wrap; margin-top: .2rem; }
.hero-directory > * { flex-basis: 50%; }
.hero-directory > .directory-label { flex-basis: 100%; border-top: 0; }
.hero-directory a { border-top: 1px solid var(--line); min-height: 4rem; padding-inline: .8rem; }
.hero-directory a:nth-child(even) { border-inline-start: 0; }
.hero-directory > a:nth-child(odd of :not(.directory-label)) { border-inline-start: 0; }
.section-nav-inner { column-gap: 1.1rem; }
.section-nav a { font-size: .875rem; }
.project, .project:nth-child(even) { grid-template-columns: 1fr; gap: 1rem; }
@@ -384,13 +384,12 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.catalog-hero { background: var(--paper); padding-block: clamp(3rem, 6vw, 6rem); }
.catalog-hero h1 { margin-bottom: .85rem; }
.catalog-hero p { margin: 0; font-size: 1.15rem; }
.catalog-listing { padding-block: clamp(3rem, 6vw, 6rem); }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2rem); }
.catalog-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.catalog-image { aspect-ratio: 16 / 8; padding: clamp(.8rem, 3vw, 1.8rem); background: var(--paper); display: grid; place-items: center; }
.catalog-image img { max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.catalog-content { padding: clamp(1.25rem, 3vw, 2rem); flex: 1; display: flex; flex-direction: column; }
.catalog-content h2 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
.catalog-content h3 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
.catalog-content .overline { margin-bottom: .4rem; }
.catalog-content .actions { margin-top: auto; padding-top: 1rem; }
@@ -474,13 +473,13 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
}
@media (max-width: 44rem) {
.catalog-grid, .copyright-service #materials .feature-grid { grid-template-columns: 1fr; }
.hero-directory > .directory-label { grid-column: 1 / -1; border-top: 0; }
.copyright-service #go > .wrap { padding: 1.55rem; min-height: 0; }
.copyright-service #go .contact-panel { display: flex; gap: 1rem; }
.copyright-service #go .contact-panel img { position: static; transform: none; width: 7rem; }
}
.hero h1 .hero-heading-primary { color: inherit; }
.studio-accent { display: block; }
[data-studio-editing] .hero:has(> [data-studio-hero-content][hidden]):not(:has(> .hero-directory-slot)) { display: none; }
[data-studio-editing] [contenteditable], [data-studio-editing] [data-studio-action],
[data-studio-editing] [data-studio-navigation] a, [data-studio-editing] [data-studio-hero-image] {
outline: 1px dashed #7896d5;
@@ -725,3 +724,16 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.studio-releases article:last-child { border-block-end: 1px solid var(--line); }
.studio-pricing { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 36rem) { .studio-pricing { grid-template-columns: 1fr; } }
.hero-directory-slot > [data-studio-part="body"] { min-height: 2.2rem; }
[data-studio-editing] [data-studio-dynamic] { cursor: pointer; }
[data-studio-editing] [data-studio-dynamic]:focus-visible { outline: 1px solid var(--accent); }
.studio-module-note { margin: 1rem 0 0; color: var(--accent-deep); padding: .6rem .8rem; background: var(--accent-light); border-radius: .4rem; }
.studio-badge { display: inline-flex; padding: .13rem .63rem; border-radius: 999px; background: var(--accent-light); color: var(--accent-deep); font-size: .85rem; }
.studio-progress progress { width: min(100%, 28rem); accent-color: var(--accent); display: block; }
.studio-progress p { margin-bottom: .3rem; }
.studio-empty { text-align: center; border: 1px dashed var(--line); border-radius: .6rem; padding: clamp(1.25rem, 4vw, 2.7rem); }
.studio-success-note { border-inline-start-color: #257b50; background: #e7f6ed; }
.rich .hero-directory { border-bottom: 1px solid var(--line); border-radius: .85rem; }
.hero:is(.hero-services, .hero-articles, .hero-contact) .hero-text-only { min-height: auto; }
+253 -46
View File
@@ -240,7 +240,7 @@ jQuery(function ($) {
$gallery.on('click', '[data-library-category]', function () {
const $panel = $(this).closest('[data-library-panel]');
$panel.data('categoryTrigger', this);
$panel.find('[data-library-index]').prop('hidden', true);
$panel.find('[data-library-index], .studio-anchor-create').prop('hidden', true);
$panel.find('[data-library-content]').prop('hidden', false);
$panel.find('[data-library-title]').text(this.dataset.libraryLabel);
$panel.find('[data-template-search]').val('');
@@ -253,7 +253,7 @@ jQuery(function ($) {
}).on('click', '[data-library-back]', function () {
const $panel = $(this).closest('[data-library-panel]');
$panel.find('[data-library-content]').prop('hidden', true);
$panel.find('[data-library-index]').prop('hidden', false);
$panel.find('[data-library-index], .studio-anchor-create').prop('hidden', false);
hidePeek();
$($panel.data('categoryTrigger')).trigger('focus');
}).on('input', '[data-template-search]', function () {
@@ -306,9 +306,8 @@ jQuery(function ($) {
const $alignTools = $elementTools.find('[data-element-align]');
const alignments = ['left', 'center', 'right'];
const alignmentClasses = alignments.map((value) => 'studio-align-' + value);
const heroOrOptional = '[data-studio-field="accent"], [data-studio-field="lead"], [data-studio-part="lead"], [data-studio-action], [data-studio-nav-index]';
const canvasFields = heroOrOptional + ', [data-studio-field="heading"], [data-studio-part="title"]';
const bodyElements = 'a, article, blockquote, details, div, dl, dt, dd, figure, h1, h2, h3, h4, h5, h6, hr, li, ol, p, pre, table, ul';
const canvasFields = '[data-studio-field="heading"], [data-studio-field="accent"], [data-studio-field="lead"], [data-studio-part="title"], [data-studio-part="lead"], [data-studio-action], [data-studio-nav-index]';
const bodyElements = 'a, article, blockquote, details, div, dl, dt, dd, figure, h1, h2, h3, h4, h5, h6, hr, li, ol, p, pre, progress, table, ul';
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] img, [data-studio-part="body"] audio, [data-studio-part="body"] video';
const $handle = $studio.find('[data-media-handle]');
const $mediaSize = $sizing.find('[data-media-size]');
@@ -355,6 +354,11 @@ jQuery(function ($) {
const $properties = $studio.find('[data-canvas-properties]');
const $propertyForm = $properties.find('form');
const $propertyError = $properties.find('[data-property-error]');
const $moduleDialog = $studio.find('[data-module-dialog]');
const $moduleForm = $moduleDialog.find('form');
const moduleInput = (name) => $moduleForm.find('[name="' + name + '"]');
let editedModule;
let deletedSections = [];
const propertyInput = (name) => $propertyForm.find('[name="' + name + '"]');
const pageInput = (name) => $settings.find('[name="' + name + '"]');
const settingsSnapshot = () => $settings.serializeArray()
@@ -368,7 +372,7 @@ jQuery(function ($) {
let saveComplete = false;
function sectionChanges(withEdits = true) {
return sections.flatMap(({key, version, fields, source, template}) => {
const edits = sections.flatMap(({key, version, fields, source, template, copyOf, feed, initialFeed}) => {
const changes = {};
const aligned = {};
let alignmentChanged = false;
@@ -388,9 +392,16 @@ jQuery(function ($) {
changes[field] = withEdits && field === 'body' && version !== null ? bodyEdits(source, value) : value;
}
}
if (!Object.keys(changes).length && !alignmentChanged) return [];
return [{key, version, fields: changes, ...(alignmentChanged ? {alignments: aligned} : {}), ...(template ? {template} : {})}];
const feedChanged = feed && (version === null || JSON.stringify(feed) !== initialFeed);
if (!Object.keys(changes).length && !alignmentChanged && !feedChanged) return [];
const edit = {key, version, fields: changes};
if (alignmentChanged || (version === null && Object.keys(aligned).length)) edit.alignments = aligned;
if (template) edit.template = template;
if (copyOf) edit.copyOf = copyOf;
if (feedChanged) edit.feed = feed;
return [edit];
});
return [...edits, ...deletedSections];
}
$settings.on('studio:sync', () => pageInput('canvas_sections').val(JSON.stringify(sectionChanges())));
@@ -409,7 +420,7 @@ jQuery(function ($) {
function openProperties(heading, values, apply, mime = null, allowEmptyUrl = false) {
$properties.find('[data-property-heading]').text(heading);
$propertyError.prop('hidden', true);
for (const key of ['label', 'url', 'alt', 'poster', 'quicklinks']) {
for (const key of ['label', 'note', 'url', 'alt', 'poster', 'quicklinks', 'value', 'max']) {
const visible = Object.hasOwn(values, key);
$propertyForm.find('[data-property-row="' + key + '"]').prop('hidden', !visible);
propertyInput(key).val(visible ? values[key] : '');
@@ -502,6 +513,15 @@ jQuery(function ($) {
}
function bindPage($doc) {
const visibilityTargets = {header: '.masthead', hero: '[data-studio-hero-content], .page-photo-credit', footer: '.site-footer'};
for (const [area, selector] of Object.entries(visibilityTargets)) {
const $input = pageInput('show_' + area);
const $target = $doc.find(selector);
$input.on('change.canvas', () => {
selectElement(null);
$target.prop('hidden', $input.val() === '0');
});
}
const labels = {name: '页面名称', heading: '首屏标题', accent: '标题第二行', lead: '首屏简介'};
$doc.find('[data-studio-field]').each(function () {
const field = this.dataset.studioField;
@@ -610,6 +630,20 @@ jQuery(function ($) {
return $navContent.find('[data-studio-nav-index="' + (index + 1) + '"]').get(0);
});
$navInput.on('input.canvas', syncNavigation);
heroControls.set('remove-section-links', (key) => {
const anchor = '#' + key;
$navInput.val(navLines().filter((line) => {
const separator = line.indexOf('|');
return separator < 0 || line.slice(separator + 1).trim() !== anchor;
}).join('\n'));
syncNavigation();
for (const index of [1, 2]) {
const $url = pageInput('url' + index);
if ($url.val().trim() !== anchor) continue;
pageInput('label' + index).val('');
$url.val('').trigger('input');
}
});
heroControls.set('navigation', () => {
openProperties('本页目录', {quicklinks: $navInput.val()}, ({quicklinks}) => {
$navInput.val(quicklinks);
@@ -621,16 +655,40 @@ jQuery(function ($) {
function editResource(node) {
const tag = node.localName;
if (tag === 'progress') {
openProperties('进度条', {value: node.getAttribute('value') || '0', max: node.getAttribute('max') || '100'}, ({value, max}) => {
if (!/^\d+$/.test(value) || !/^\d+$/.test(max) || Number(max) < 1 || Number(value) > Number(max)) {
$propertyError.prop('hidden', false).text('请输入不超过最大值的非负整数。');
return false;
}
node.max = Number(max);
node.value = Number(value);
node.textContent = Math.round(100 * node.value / node.max) + '%';
});
return;
}
if (tag === 'a') {
const product = node.parentElement.matches('.hero-directory');
const title = product ? node.querySelector(':scope > span') : null;
const note = product ? node.querySelector(':scope > small') : null;
const onlyChild = node.firstElementChild;
const text = node.childElementCount === 0 ? node : (
const text = title || (node.childElementCount === 0 ? node : (
node.childElementCount === 1 && onlyChild.matches('span, strong, b, em, i, small')
&& !onlyChild.childElementCount && node.textContent.trim() === onlyChild.textContent.trim() ? onlyChild : null
);
));
const values = text ? {label: text.textContent, url: node.getAttribute('href') || ''} : {url: node.getAttribute('href') || ''};
openProperties('正文链接', values, ({label, url}) => {
if (title) values.note = note?.textContent || '';
openProperties(product ? '导航卡片' : '正文链接', values, ({label, note: description, url}) => {
if (text && !label) {
$propertyError.prop('hidden', false).text('请填写链接文案。');
return false;
}
node.setAttribute('href', url);
if (text && label !== values.label) text.textContent = label;
if (description !== undefined) {
if (note) $(note).text(description);
else if (description) $('<small>').text(description).appendTo(node);
}
});
return;
}
@@ -653,17 +711,18 @@ jQuery(function ($) {
}, (tag === 'img' ? 'image' : tag) + '/');
}
function registerSection(section, version = Number(section.dataset.studioSection)) {
function registerSection(section, version = Number(section.dataset.studioSection), metadata = {}) {
const fields = {};
const feed = section.dataset.studioFeed ? JSON.parse(section.dataset.studioFeed) : null;
for (const node of section.querySelectorAll('[data-studio-part]')) {
const part = node.dataset.studioPart;
const body = part === 'body';
const label = {title: '区块标题', lead: '添加区块简介', body: '区块正文'}[part];
if (body) {
if (!feed && body) {
node.contentEditable = 'true';
node.setAttribute('aria-label', label);
node.dataset.studioPlaceholder = label;
} else {
} else if (!feed && !node.hidden) {
configureText(node, label, part === 'lead');
}
fields[part] = {node, initial: body ? node.innerHTML : node.textContent, initialAlignment: body ? '' : getAlignment(node)};
@@ -671,7 +730,9 @@ jQuery(function ($) {
const source = new TextDecoder('utf-8', {ignoreBOM: true}).decode(Uint8Array.from(
atob(section.dataset.studioSource || ''), (byte) => byte.charCodeAt(0)
));
sections.push({key: section.id, version, fields, source, template: section.dataset.studioTemplate});
const entry = {node: section, key: section.id, version, fields, source, feed, initialFeed: JSON.stringify(feed), ...metadata};
sections.push(entry);
return entry;
}
function setMediaWidth(node, width) {
@@ -779,6 +840,8 @@ jQuery(function ($) {
selectionObserver?.disconnect();
selectedElement?.removeAttribute('data-studio-selected');
selectedElement = node;
const dynamic = node?.hasAttribute('data-studio-dynamic');
$elementTools.toggleClass('is-module', Boolean(dynamic)).find('[data-element-module-settings]').prop('hidden', !dynamic);
selectedMedia = node?.matches(mediaTargets) ? node : null;
$sizing.prop('hidden', !selectedMedia);
if (node) {
@@ -786,12 +849,15 @@ jQuery(function ($) {
const target = sizingTarget();
const nav = node.hasAttribute('data-studio-nav-index');
const inBody = node.closest('[data-studio-part="body"]') !== null;
const canCopy = inBody || (nav && $(node).siblings().length < 19);
const hasProperties = selectedMedia || node.matches('a');
const aligned = alignmentTarget(node);
const canCopy = dynamic || inBody || (nav && $(node).siblings().length < 19);
const hasProperties = !dynamic && (selectedMedia || node.matches('a, progress'));
const aligned = dynamic ? null : alignmentTarget(node);
syncAlignmentButtons(aligned);
$elementTools.find('[data-element-copy]').prop('hidden', !canCopy);
$elementTools.find('[data-element-delete]').prop('hidden', !inBody && !selectedMedia && !node.matches(heroOrOptional));
const deleteLabel = node.dataset.studioField === 'heading' ? '删除首屏'
: node.dataset.studioPart === 'title' ? '删除区块' : '删除';
$elementTools.find('[data-element-delete]').attr({'aria-label': deleteLabel, title: deleteLabel})
.prop('hidden', !dynamic && !inBody && !selectedMedia && !node.matches(canvasFields));
$elementTools.find('[data-element-properties]').prop('hidden', !hasProperties);
if (target) showMediaWidth(currentMediaWidth(target));
selectionObserver?.observe(target || aligned || node);
@@ -802,7 +868,20 @@ jQuery(function ($) {
function changeElement(copy) {
const node = selectedElement;
if (!node?.isConnected) return;
if (node.hasAttribute('data-studio-dynamic')) {
changeModule(sections.find((section) => section.node === node), copy);
return;
}
const {studioField, studioAction, studioNavIndex} = node.dataset;
if (!copy && studioField === 'heading') {
pageInput('show_hero').val('0').trigger('change');
$studio.find('[data-canvas-status]').text('首屏已移除,可在页面设置中恢复。');
return;
}
if (!copy && node.dataset.studioPart === 'title') {
changeModule(sections.find((section) => section.node === node.closest('[data-studio-section]')), false);
return;
}
const inBody = node.closest('[data-studio-part="body"]') !== null;
selectElement(null);
if (inBody) {
@@ -853,13 +932,120 @@ jQuery(function ($) {
if (selectedMedia) replaceMedia();
else if (selectedElement?.matches('[data-studio-action], [data-studio-nav-index]')) {
$(selectedElement).triggerHandler('studio:properties');
} else if (selectedElement?.matches('a')) {
} else if (selectedElement?.matches('a, progress')) {
editResource(selectedElement);
}
}).on('keydown', (event) => {
if (event.key === 'Escape') selectElement(null);
});
function noteModule(section, text) {
const $body = $(section).find('[data-studio-part="body"]');
let $note = $(section).find('[data-studio-module-note]');
if (!$note.length) $note = $('<p>', {class: 'studio-module-note', 'data-studio-module-note': ''}).insertBefore($body);
$note.text(text);
}
$elementTools.on('click', '[data-element-module-settings]', () => {
editedModule = sections.find(({node}) => node === selectedElement);
if (!editedModule?.feed) return;
const {fields, feed} = editedModule;
moduleInput('module_title').val(fields.title.node.textContent);
moduleInput('module_lead').val(fields.lead.node.textContent);
moduleInput('feed_mode').val(feed.mode);
moduleInput('feed_limit').val(feed.limit);
moduleInput('feed_categories[]').each(function () {
this.checked = feed.categories.includes(this.value);
});
$moduleDialog.find('[data-module-error]').prop('hidden', true);
$moduleDialog.get(0).showModal();
});
$moduleDialog.on('click', '[data-module-close]', () => $moduleDialog.get(0).close());
$moduleForm.on('submit', (event) => {
event.preventDefault();
const categories = moduleInput('feed_categories[]').filter(':checked').map((_, node) => node.value).get();
const title = moduleInput('module_title').val().trim();
if (!title || !categories.length) {
$moduleDialog.find('[data-module-error]').text('请填写标题并至少选择一个分类。').prop('hidden', false);
return;
}
const {node, fields} = editedModule;
editedModule.feed = {mode: moduleInput('feed_mode').val(), categories, limit: Number(moduleInput('feed_limit').val())};
fields.title.node.textContent = title;
fields.lead.node.textContent = moduleInput('module_lead').val().trim();
noteModule(node, '模块设置将在保存页面后更新。');
$moduleDialog.get(0).close();
positionSelection();
});
function newSectionId() {
return 'block-' + Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('');
}
function addPending(section) {
const $button = $('<button>', {type: 'button', text: '取消新增:' + section.fields.title.node.textContent});
section.$pending = $('<li>').append($button).appendTo($pending);
$pending.prop('hidden', false);
$button.on('click', () => removeSection(section));
}
function removeSection(section) {
if (section.node.contains(activeBody)) selectBody(null);
if (section.node.contains(selectedElement)) selectElement(null);
if (section.version !== null) deletedSections.push({key: section.key, version: section.version, delete: true});
section.node.remove();
sections = sections.filter((entry) => entry !== section);
heroControls.get('remove-section-links')(section.key);
section.$pending?.remove();
$pending.prop('hidden', !$pending.children().length);
}
function scopeTemplateIds(root, prefix, oldKey = '') {
const ids = new Map();
$(root).find('[id]').addBack('[id]').each(function () {
const next = oldKey && this.id.includes(oldKey) ? this.id.replace(oldKey, prefix) : prefix + '-' + this.id;
ids.set(this.id, next);
this.id = next;
});
$(root).find('[aria-labelledby], [aria-controls], [href^="#"]').addBack('[aria-labelledby]').each(function () {
for (const attribute of ['aria-labelledby', 'aria-controls', 'href']) {
const value = this.getAttribute(attribute);
if (!value) continue;
if (attribute === 'href') {
const target = ids.get(value.slice(1));
if (value.startsWith('#') && target) this.setAttribute('href', '#' + target);
} else {
this.setAttribute(attribute, value.split(' ').map((part) => ids.get(part) || part).join(' '));
}
}
});
}
function changeModule(section, copy) {
if (!section) return;
if (!copy) {
if (window.confirm('删除此区块?保存页面后生效。')) {
removeSection(section);
$studio.find('[data-canvas-status]').text('区块已移除,保存页面后生效。');
}
return;
}
if (sections.filter(({version}) => version === null).length >= 50) return;
selectElement(null);
const clone = section.node.cloneNode(true);
const id = newSectionId();
scopeTemplateIds(clone, id, section.key);
clone.dataset.studioFeed = JSON.stringify(section.feed);
doc.querySelector('[data-studio-section-end]').before(clone);
const copyOf = section.copyOf || (section.version === null ? null : {key: section.key, version: section.version});
const entry = registerSection(clone, null, {template: copyOf ? null : section.template, copyOf});
addPending(entry);
noteModule(clone, '模块副本将在保存页面后生效。');
clone.scrollIntoView({block: 'start'});
selectElement(clone);
$studio.find('[data-canvas-status]').text('已复制模块,保存页面后生效。');
}
function replaceMedia() {
if (!selectedMedia?.isConnected) return;
if (selectedMedia.hasAttribute('data-studio-hero-image')) heroControls.get('image')();
@@ -939,7 +1125,10 @@ jQuery(function ($) {
while (node.parentNode !== body) node = node.parentNode;
insertion.setStartAfter(node);
}
editBody(body, insertion, 'insertHTML', markup);
const template = doc.createElement('template');
template.innerHTML = markup;
if (template.content.querySelector('[id]')) scopeTemplateIds(template.content, newSectionId());
editBody(body, insertion, 'insertHTML', template.innerHTML);
}
$presets.on('mousedown', '[data-canvas-template], [data-canvas-element]', (event) => event.preventDefault());
@@ -966,9 +1155,10 @@ jQuery(function ($) {
$presets.on('click', '[data-canvas-template]', function () {
const markup = $presets.find('template[data-preset="' + this.dataset.canvasTemplate + '"]').get(0).innerHTML;
const template = this.dataset.canvasTemplate;
const feed = this.dataset.templateFeed;
if ($presets.find('[data-template-inline]').prop('checked')) {
if (template === 'articles') {
$templateStatus.text('分类文章需要作为独立区块添加。');
if (feed) {
$templateStatus.text('动态模块需要作为独立区块添加。');
return;
}
if (!activeBody) {
@@ -986,34 +1176,29 @@ jQuery(function ($) {
}
const end = doc.querySelector('[data-studio-section-end]');
const section = end.content.firstElementChild.cloneNode(true);
const id = 'block-' + Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('');
const id = newSectionId();
section.id = id;
section.classList.replace('section-plain', 'section-' + this.dataset.templateStyle);
const title = section.querySelector('[data-studio-part="title"]');
title.id = 'heading-' + id;
title.textContent = this.dataset.templateTitle;
section.setAttribute('aria-labelledby', title.id);
section.querySelector('[data-studio-part="body"]').innerHTML = markup;
if (template === 'articles') {
section.dataset.studioTemplate = template;
$('<p>', {class: 'empty-state', text: '保存页面后可在图层的区块设置中选择分类和展示方式。'})
.insertBefore($(section).find('[data-studio-part="body"]'));
section.querySelector('[data-studio-part="lead"]').textContent = this.dataset.templateLead || '';
const body = section.querySelector('[data-studio-part="body"]');
body.innerHTML = markup;
scopeTemplateIds(body, id);
if (feed) {
section.dataset.studioDynamic = '';
section.dataset.studioFeed = feed;
section.tabIndex = 0;
noteModule(section, '保存页面后将加载动态内容。');
}
end.before(section);
registerSection(section, null);
const entry = registerSection(section, null, {template});
addPending(entry);
section.scrollIntoView({block: 'start'});
section.querySelector('[data-studio-part="body"]').focus({preventScroll: true});
const $cancel = $('<button>', {type: 'button', text: '取消新增:' + title.textContent});
const $item = $('<li>').append($cancel).appendTo($pending);
$pending.prop('hidden', false);
$cancel.on('click', () => {
if (section.contains(activeBody)) selectBody(null);
if (section.contains(selectedElement)) selectElement(null);
section.remove();
sections = sections.filter(({key}) => key !== id);
$item.remove();
$pending.prop('hidden', !$pending.children().length);
$templateStatus.text('已取消新增区块。');
});
if (feed) selectElement(section);
else entry.fields.body.node.focus({preventScroll: true});
$templateStatus.text('已添加 ' + title.textContent + ' 区块。');
});
@@ -1028,6 +1213,7 @@ jQuery(function ($) {
selectElement(null);
$pending.empty().prop('hidden', true);
sections = [];
deletedSections = [];
$doc.find('[data-studio-section]').each((_, section) => registerSection(section));
$doc.on('focusin.canvas', '[contenteditable]', function () {
@@ -1038,22 +1224,42 @@ jQuery(function ($) {
$doc.on('click.canvas dblclick.canvas', mediaTargets, function (event) {
event.preventDefault();
event.stopPropagation();
const dynamic = this.closest('[data-studio-dynamic]');
if (dynamic) {
selectBody(null);
selectElement(dynamic);
return;
}
selectBody(this.closest('[data-studio-part="body"]'));
selectElement(this);
if (event.type === 'dblclick') replaceMedia();
});
$doc.on('click.canvas', (event) => {
const node = event.target;
const dynamic = node.closest?.('[data-studio-dynamic]');
if (dynamic) {
selectBody(null);
selectElement(dynamic);
return;
}
const field = node.closest?.(canvasFields);
selectElement(doc.getSelection()?.isCollapsed ? field || editableBodyElement(node) : null);
});
$doc.on('dblclick.canvas', '[data-studio-part="body"] a', function (event) {
event.preventDefault();
if (!event.target.closest(mediaTargets)) editResource(this);
if (!this.closest('[data-studio-dynamic]') && !event.target.closest(mediaTargets)) editResource(this);
});
$doc.on('keydown.canvas', (event) => {
if (event.key === 'Escape') selectElement(null);
});
$doc.on('keydown.canvas', '[data-studio-dynamic]', function (event) {
if ((event.key === 'Enter' || event.key === ' ') && event.target === this) {
event.preventDefault();
selectBody(null);
selectElement(this);
$elementTools.find('[data-element-module-settings]').trigger('focus');
}
});
$doc.on('keydown.canvas', '[data-studio-hero-image]', function (event) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
@@ -1086,7 +1292,8 @@ jQuery(function ($) {
if (!body) return;
$studio.get(0).scrollIntoView({block: 'start'});
section.scrollIntoView({block: 'start'});
body.focus({preventScroll: true});
if (section.hasAttribute('data-studio-dynamic')) selectElement(section);
else body.focus({preventScroll: true});
});
});
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

+104
View File
@@ -0,0 +1,104 @@
<?php
return [
'vantage' => [
'name' => 'Vantage · 观测台',
'description' => '蓝黑底色、仪表边框和青柠色操作入口,适合基础设施与运维说明。',
'pages' => [
'vantage-infrastructure' => [
'name' => '基础设施概览',
'heading' => '从一个界面看清解析服务。',
'description' => '为自托管服务整理部署入口、解析策略和故障排查资料。',
'image' => '/assets/original/highspeaker-ui-optimized.webp',
'alt' => 'HighSpeaker DNS 控制台',
'actions' => [['#deployment', '查看部署说明'], ['/highspeaker', '产品主页']],
'sections' => [
['deployment', '部署与管理', 'plain', <<<'HTML'
<div class="template-ledger"><article><h3>节点与入口</h3><p>记录实例位置、访问方式和部署依赖。</p></article><article><h3>解析策略</h3><p>按域名与访问来源整理实际使用的记录。</p></article><article><h3>变更流程</h3><p>先在测试环境复核结果,再更新对外服务。</p></article></div>
HTML, null],
['visibility', '检查服务可用性', 'tinted', <<<'HTML'
<div class="studio-split"><div><h3>记录预期结果</h3><p>每次变更后,从服务节点和外部网络分别发起查询。</p></div><pre class="studio-code"><code>dig @127.0.0.1 example.com A</code></pre></div>
HTML, null],
['infra-resources', '产品与支持', 'plain', '<ul class="studio-resources"><li><a href="/highspeaker">查看 HighSpeaker DNS</a><span>产品文档</span></li><li><a href="/contact">联系来笙</a><span>技术咨询</span></li></ul>', null],
],
],
'vantage-runbook' => [
'name' => '运维操作手册',
'heading' => '按步骤排查服务故障。',
'description' => '把常用的检查、回退和交接步骤集中到一页,方便团队值班时使用。',
'image' => '',
'alt' => '',
'actions' => [['#first-checks', '开始排查']],
'sections' => [
['first-checks', '先核对这三项', 'plain', '<ol class="template-steps"><li><h3>确认影响范围</h3><p>检查是单一区域受影响,还是所有请求都失败。</p></li><li><h3>查看最近变更</h3><p>核对配置、证书与部署记录。</p></li><li><h3>比对响应</h3><p>比较本地与公开地址的访问结果。</p></li></ol>', null],
['recovery', '恢复与回退', 'tinted', '<ul class="studio-checklist"><li>保留当前配置与日志。</li><li>按团队约定恢复最近的可用配置。</li><li>从两个网络确认服务恢复。</li></ul>', null],
['handover', '交接记录', 'plain', '<div class="table-scroll"><table><thead><tr><th scope="col">事项</th><th scope="col">记录内容</th></tr></thead><tbody><tr><td>异常时间</td><td>开始、发现及恢复时间。</td></tr><tr><td>变更</td><td>执行过的动作和结果。</td></tr><tr><td>负责人</td><td>后续处理人和待办事项。</td></tr></tbody></table></div>', null],
],
],
],
],
'ribbon' => [
'name' => 'Ribbon · 柔彩',
'description' => '柔紫色封面、圆角图片与清晰的步骤组合,适合入门教程与帮助中心。',
'pages' => [
'ribbon-onboarding' => [
'name' => '新手入门页',
'heading' => '做出你的第一个网页。',
'description' => '从选模板、编辑组件到检查手机预览,走完一次完整的建站流程。',
'image' => '/assets/original/pagepan-example.webp',
'alt' => 'PAGEPAN 网页模板示例',
'actions' => [['#start-building', '开始学习'], ['/pagepan', '查看 PAGEPAN']],
'sections' => [
['start-building', '从三个动作开始', 'plain', '<ol class="template-steps"><li><h3>选一个版式</h3><p>用符合内容结构的模板开工。</p></li><li><h3>替换内容</h3><p>换上自己的文案、照片和链接。</p></li><li><h3>检查预览</h3><p>分别用桌面和手机尺寸浏览。</p></li></ol>', null],
['editor-tour', '认识编辑器', 'tinted', '<div class="studio-split"><img src="/assets/original/pagepan-editor-optimized.webp" alt="PAGEPAN 画布" loading="lazy"><div><h3>在画布上选中元素</h3><p>修改内容后,保留必要的导航和行动按钮。</p></div></div>', null],
['more-lessons', '继续学习', 'plain', '<ul class="studio-resources"><li><a href="/pagepan#download">获取 PAGEPAN</a><span>下载</span></li><li><a href="/articles">浏览产品动态</a><span>更新与文章</span></li></ul>', null],
],
],
'ribbon-help' => [
'name' => '产品帮助中心',
'heading' => '找到你眼下需要的帮助。',
'description' => '给访客一个独立入口,集中查看入门资料、常见问题和联系渠道。',
'image' => '/assets/original/home-hero.webp',
'alt' => '来笙云服务插画',
'actions' => [['#common-questions', '查看常见问题'], ['/contact', '联系支持']],
'sections' => [
['documentation', '快速入口', 'plain', '<ul class="studio-resources"><li><a href="/pagepan">可视化建站</a><span>PAGEPAN</span></li><li><a href="/highspeaker">智能 DNS</a><span>HighSpeaker DNS</span></li><li><a href="/articles">公告与动态</a><span>最新文章</span></li></ul>', null],
['common-questions', '常见问题', 'tinted', '<div class="faq"><details><summary>在哪里找下载入口?</summary><div><p>打开产品页,再查看页面中的下载区块。</p></div></details><details><summary>如何反馈问题?</summary><div><p>通过联系页发送所用产品和版本、操作步骤及遇到的问题。</p></div></details></div>', null],
['support-options', '联系团队', 'plain', '<p class="actions"><a class="button button-primary" href="/contact">查看联系方式</a></p>', null],
],
],
],
],
'furrow' => [
'name' => 'Furrow · 田垄',
'description' => '暖纸色、墨绿和琥珀色线条,适合服务介绍与办理清单。',
'pages' => [
'furrow-service' => [
'name' => '服务说明页',
'heading' => '从准备材料到提交申请。',
'description' => '清楚列出软件著作权服务的办理流程,以及申请人需要准备的材料。',
'image' => '/assets/original/copyright.webp',
'alt' => '软件著作权服务配图',
'actions' => [['#service-steps', '了解流程'], ['/sc', '查看服务详情']],
'sections' => [
['service-steps', '服务如何开展', 'plain', '<ol class="studio-timeline"><li><h3>了解项目</h3><p>先明确软件用途、申请主体和材料现状。</p></li><li><h3>核对材料</h3><p>按项目情况整理代码、使用说明与必要文件。</p></li><li><h3>提交并跟进</h3><p>核对信息后提交,并按办理进度补充材料。</p></li></ol>', null],
['prepare', '申请前准备', 'tinted', '<div class="studio-two-column"><article><h3>已经有项目</h3><p>整理项目代码、软件说明和主体信息。</p></article><article><h3>需要协助</h3><p>说明当前进度,方便团队判断需要哪些服务。</p></article></div>', null],
['service-contact', '咨询办理方案', 'plain', '<p class="actions"><a class="button button-primary" href="/contact">联系来笙</a></p>', null],
],
],
'furrow-checklist' => [
'name' => '办事准备清单',
'heading' => '把要准备的材料一次列清。',
'description' => '适合发布可逐项核对的材料清单、办理须知与后续链接。',
'image' => '',
'alt' => '',
'actions' => [['#materials-list', '查看材料清单']],
'sections' => [
['materials-list', '准备材料', 'plain', '<ul class="studio-checklist"><li>软件名称、版本与用途说明</li><li>可用于提交的代码材料</li><li>能够说明安装和操作的用户指南</li><li>适用时准备合作开发和主体证明材料</li></ul>', null],
['before-submitting', '提交前核对', 'tinted', '<div class="template-ledger"><article><h3>名称一致</h3><p>核对各材料中的软件名称和版本。</p></article><article><h3>说明完整</h3><p>确保文档能解释主要操作。</p></article><article><h3>文件齐全</h3><p>按申请类型核对所需证明。</p></article></div>', null],
['next-actions', '下一步', 'plain', '<ul class="studio-resources"><li><a href="/sc">查看软著服务</a><span>流程与方案</span></li><li><a href="/contact">咨询材料问题</a><span>联系方式</span></li></ul>', null],
],
],
],
],
];
+136
View File
@@ -0,0 +1,136 @@
<?php
use App\Content\BlockTemplates;
return [
'cobalt' => [
'name' => 'Cobalt · 钴蓝',
'description' => '冷白纸面、细分隔线与钴蓝按钮,适合开发工具和技术文档。',
'pages' => [
'cobalt-product' => [
'name' => '开发者工具首页',
'heading' => '让 DNS 放回你手里。',
'description' => '在自己的服务器上管理域名、解析策略与 API。用一个控制台看清每一条记录。',
'image' => '/assets/original/highspeaker-ui-optimized.webp',
'alt' => 'HighSpeaker DNS 管理面板',
'actions' => [['#capabilities', '查看能力'], ['/highspeaker', 'HighSpeaker DNS']],
'sections' => [
['capabilities', '一处管理解析策略', 'plain', <<<'HTML'
<div class="template-ledger">
<article><h3>按来源应答</h3><p>为不同地区或网络来源返回对应记录。</p></article>
<article><h3>程序化管理</h3><p>从脚本或控制面板更新记录,保留人工检查入口。</p></article>
<article><h3>自主部署</h3><p>选择服务器与部署方式,把解析服务放在自己管理的环境中。</p></article>
</div>
HTML, null],
['workflow', '从测试到切换', 'tinted', <<<'HTML'
<div class="studio-split"><pre class="studio-code"><code>dig @127.0.0.1 example.com A</code></pre><ol class="studio-timeline"><li><h3>录入记录</h3><p>先填写域名和解析目标。</p></li><li><h3>验证应答</h3><p>确认返回结果,再切换正式流量。</p></li></ol></div>
HTML, null],
['resources', '开始部署', 'plain', <<<'HTML'
<ul class="studio-resources"><li><a href="/highspeaker">阅读产品说明</a><span>HighSpeaker DNS</span></li><li><a href="/contact">联系技术团队</a><span>部署咨询</span></li></ul>
HTML, null],
],
],
'cobalt-guide' => [
'name' => '技术快速入门',
'heading' => '从首次查询开始。',
'description' => '用三个步骤搭建一个可验证的测试环境,在接入正式流量前确认解析结果。',
'image' => '',
'alt' => '',
'actions' => [['#first-query', '执行首次查询']],
'sections' => [
['first-query', '验证第一条记录', 'plain', <<<'HTML'
<div class="studio-split"><div><h3>从本机发起查询</h3><p>将地址改为你的测试服务器,并将示例域名替换成已配置的域名。</p></div><pre class="studio-code"><code>dig @127.0.0.1 example.com A +short</code></pre></div>
HTML, null],
['checks', '上线前检查', 'tinted', <<<'HTML'
<div class="table-scroll"><table><thead><tr><th scope="col">检查项</th><th scope="col">预期结果</th></tr></thead><tbody><tr><td>域名</td><td>与控制台中的区域一致。</td></tr><tr><td>记录类型</td><td>查询类型与配置匹配。</td></tr><tr><td>解析结果</td><td>目标地址与部署计划一致。</td></tr></tbody></table></div>
HTML, null],
['troubleshooting', '常见问题', 'plain', <<<'HTML'
<div class="faq"><details><summary>查询一直超时怎么办?</summary><div><p>先确认服务在监听,再核对防火墙和查询地址。</p></div></details><details><summary>为什么旧结果还在?</summary><div><p>递归解析器可能仍在缓存上一条记录,检查该记录的 TTL。</p></div></details></div>
HTML, null],
],
],
],
],
'studio' => [
'name' => 'Studio · 工作室',
'description' => '衬线标题、校样网格与橙色标记,适合案例和项目介绍。',
'pages' => [
'studio-portfolio' => [
'name' => '作品与服务',
'heading' => '从一张校样,到一个网站。',
'description' => '汇集网站和视觉系统的项目作品,向访客展示你能合作的方式。',
'image' => '/assets/page-templates/studio-letterpress.webp',
'alt' => '排印工作台上的木质活字',
'actions' => [['#selected-work', '看作品'], ['/contact', '聊聊项目']],
'sections' => [
['selected-work', '项目档案', 'plain', <<<'HTML'
<div class="template-portfolio">
<article><img src="/assets/original/pagepan-example.webp" alt="PAGEPAN 网页版式" loading="lazy"><h3><a href="/pagepan">PAGEPAN 可视化建站</a></h3><p>从可视化画布组装响应式网页。</p></article>
<article><img src="/assets/original/highspeaker-ui-optimized.webp" alt="HighSpeaker DNS 控制台" loading="lazy"><h3><a href="/highspeaker">HighSpeaker DNS</a></h3><p>把解析记录放进可自主部署的控制面板。</p></article>
</div>
HTML, null],
['practice', '一起把方案落地', 'tinted', <<<'HTML'
<div class="studio-two-column"><article><h3>梳理内容</h3><p>先确认访客需要看到什么、完成什么,再安排页面顺序。</p></article><article><h3>交付与维护</h3><p>交付可编辑的网站,帮助团队把内容更新纳入日常工作。</p></article></div>
HTML, null],
['enquiries', '有项目想讨论?', 'plain', '<p class="actions"><a class="button button-primary" href="/contact">联系来笙</a></p>', null],
],
],
'studio-case' => [
'name' => '单个项目案例',
'heading' => '把建站流程放到画布上。',
'description' => '从内容结构、组件组合到发布,记录一个可视化建站项目的设计思路。',
'image' => '/assets/original/pagepan-editor-optimized.webp',
'alt' => 'PAGEPAN 可视化编辑界面',
'actions' => [['#project-brief', '阅读案例'], ['/pagepan', '查看 PAGEPAN']],
'sections' => [
['project-brief', '项目概要', 'plain', <<<'HTML'
<dl class="studio-metrics"><div><dt>目标</dt><dd>可视化编辑</dd></div><div><dt>范围</dt><dd>组件与发布</dd></div><div><dt>交付</dt><dd>自托管网站</dd></div></dl>
HTML, null],
['design-notes', '设计过程', 'tinted', <<<'HTML'
<div class="studio-split"><img src="/assets/original/pagepan-example.webp" alt="PAGEPAN 页面示例" loading="lazy"><div><h3>先定内容,再定版式</h3><p>把首屏、介绍和行动按钮拆成区块,让团队直接在页面里替换文字、图片和链接。</p></div></div>
HTML, null],
['next-step', '查看可用工具', 'plain', '<p class="actions"><a class="button button-primary" href="/services">浏览产品与服务</a></p>', null],
],
],
],
],
'dusk' => [
'name' => 'Dusk · 暮色',
'description' => '暮色摄影、深石板背景和淡紫按钮,适合产品发布和更新说明。',
'pages' => [
'dusk-launch' => [
'name' => '产品发布页',
'heading' => '把上线的每一步安排好。',
'description' => '给团队一份从预览、核对到上线的清晰路径,让第一次发布更从容。',
'image' => '/assets/page-templates/dusk-dunes.webp',
'alt' => '暮色下的犹他沙丘',
'actions' => [['#release-plan', '查看发布流程'], ['/contact', '联系支持']],
'sections' => [
['release-plan', '发布流程', 'plain', <<<'HTML'
<ol class="template-steps"><li><h3>在草稿中预览</h3><p>检查标题、版式和页面主链接。</p></li><li><h3>确认资源可加载</h3><p>查看手机布局,确认图片和视频可用。</p></li><li><h3>发布并记录变更</h3><p>检查公开地址,留下更新说明。</p></li></ol>
HTML, null],
['release-checks', '准备上线', 'tinted', <<<'HTML'
<ul class="studio-checklist"><li>核对公开标题与分享图</li><li>在不同窗口尺寸下检查首屏</li><li>为站点维护人员交接编辑入口</li></ul>
HTML, null],
['support', '需要发布协助?', 'plain', '<p class="actions"><a class="button button-primary" href="/contact">联系来笙</a></p>', null],
],
],
'dusk-updates' => [
'name' => '版本与动态',
'heading' => '每一次更新,都找得到。',
'description' => '把版本说明和站点动态放在同一页,方便读者了解改动和后续安排。',
'image' => '/assets/original/home-hero.webp',
'alt' => '来笙云端服务插画',
'actions' => [['#latest-notes', '看最新动态']],
'sections' => [
['latest-notes', '最新动态', 'plain', '', BlockTemplates::ARTICLE_FEED],
['release-notes', '版本说明', 'tinted', <<<'HTML'
<div class="studio-releases"><article><h3>主要改动</h3><p>在这里总结本次发布解决的问题,以及用户可以如何使用新功能。</p></article><article><h3>升级与迁移</h3><p>列出更新前需要备份的内容、操作步骤和验证方法。</p></article></div>
HTML, null],
['feedback', '反馈与联系', 'plain', '<p class="actions"><a class="button button-primary" href="/contact">提交反馈</a></p>', null],
],
],
],
],
...require __DIR__ . '/page-templates-extra.php',
];
+7
View File
@@ -16,6 +16,8 @@ CREATE TABLE IF NOT EXISTS pages (
alignments TEXT NOT NULL DEFAULT '{}',
actions TEXT NOT NULL,
quicklinks TEXT NOT NULL,
theme TEXT NOT NULL DEFAULT '',
visibility TEXT NOT NULL DEFAULT '{}',
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
updated_at TEXT,
version INTEGER NOT NULL DEFAULT 0
@@ -63,6 +65,11 @@ CREATE TABLE IF NOT EXISTS article_redirects (
slug TEXT PRIMARY KEY,
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS article_deletions (
slug TEXT PRIMARY KEY,
article_id INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS article_deletions_id ON article_deletions (article_id);
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY,
email TEXT NOT NULL UNIQUE COLLATE NOCASE,
+87
View File
@@ -428,6 +428,93 @@
"style": "plain"
}
]
},
{
"slug": "services",
"name": "产品与服务",
"title": "产品与服务 · 来笙 Laysense",
"heading": "产品与服务",
"accent": "",
"description": "自托管建站、开源智能 DNS 与软件著作权代理服务。",
"lead": "自托管建站、开源智能 DNS 与软件著作权代理服务。",
"image": "",
"alt": "",
"actions": [],
"quicklinks": [],
"sections": [
{
"key": "catalog",
"title": "服务目录",
"lead": "",
"body": "",
"style": "plain",
"feed": {
"categories": [
"services"
],
"mode": "catalog",
"limit": 30
}
}
]
},
{
"slug": "articles",
"name": "来笙动态",
"title": "来笙动态 · 来笙 Laysense",
"heading": "来笙动态",
"accent": "",
"description": "查看来笙的公告、新闻和产品动态。",
"lead": "查看来笙的公告、新闻和产品动态。",
"image": "",
"alt": "",
"actions": [],
"quicklinks": [],
"sections": [
{
"key": "updates",
"title": "公告、新闻与产品动态",
"lead": "",
"body": "",
"style": "plain",
"feed": {
"categories": [
"announcement",
"news",
"product"
],
"mode": "tabs",
"limit": 8
}
}
]
},
{
"slug": "contact",
"name": "联系来笙",
"title": "联系来笙 · 来笙 Laysense",
"heading": "联系来笙",
"accent": "",
"description": "联系上海来笙信息科技有限公司,咨询产品、技术支持或合作。",
"lead": "联系上海来笙信息科技有限公司,咨询产品、技术支持或合作。",
"image": "",
"alt": "",
"actions": [
[
"mailto:public@laysense.cn",
"发送邮件"
]
],
"quicklinks": [],
"sections": [
{
"key": "contact-information",
"title": "联系方式",
"lead": "",
"body": "<div class=\"studio-contact\"><div><h3>上海来笙信息科技有限公司</h3><p>上海自贸试验区世博村路231号2单元3层328室</p></div><dl class=\"studio-definitions\"><dt>电子邮件</dt><dd><a href=\"mailto:public@laysense.cn\">public@laysense.cn</a></dd><dt>全球号码</dt><dd><a href=\"tel:+16699004532\">+1 (669) 900 4532</a> / <a href=\"tel:+85257012856\">+852 5701 2856</a></dd></dl></div>",
"style": "plain"
}
]
}
],
"articles": [
@@ -0,0 +1,35 @@
<?php
return array (
'/www/laysense.cn/app/Controller/MediaController.php' =>
array (
'mtime' => 1795327093,
'hasAttributes' => false,
'class' => 'App\\Controller\\MediaController',
'type' => 'class',
'psr4' => true,
),
'/www/laysense.cn/app/Controller/StudioController.php' =>
array (
'mtime' => 1795327093,
'hasAttributes' => false,
'class' => 'App\\Controller\\StudioController',
'type' => 'class',
'psr4' => true,
),
'/www/laysense.cn/app/Controller/AdminController.php' =>
array (
'mtime' => 1795327093,
'hasAttributes' => false,
'class' => 'App\\Controller\\AdminController',
'type' => 'class',
'psr4' => true,
),
'/www/laysense.cn/app/Controller/SiteController.php' =>
array (
'mtime' => 1795327093,
'hasAttributes' => false,
'class' => 'App\\Controller\\SiteController',
'type' => 'class',
'psr4' => true,
),
);
View File
+9
View File
@@ -0,0 +1,9 @@
2026-11-22 14:02:02 pid:2955562 Workerman[start.php] start in DEBUG mode
2026-11-22 14:02:25 pid:2955562 Workerman[start.php] received signal SIGINT
2026-11-22 14:02:25 pid:2955562 Workerman[start.php] stopping
2026-11-22 14:02:25 pid:2955562 Workerman[start.php] has been stopped
2026-11-22 14:02:31 pid:2955711 Workerman[start.php] start in DAEMON mode
2026-11-26 00:07:46 pid:2955713 Workerman[start.php] received signal SIGINT
2026-11-26 00:07:46 pid:2955713 Workerman[start.php] stopping
2026-11-26 00:07:48 pid:2955713 Workerman[start.php] has been stopped
2026-11-26 00:09:21 pid:4048930 Workerman[start.php] start in DAEMON mode

Some files were not shown because too many files have changed in this diff Show More