Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2cf63b61ba | ||
|
|
2ef38bd716 | ||
|
|
62c10b09bc | ||
|
|
935bc7f071 | ||
|
|
1a025353b2 | ||
|
|
ef1ff93904 | ||
|
|
74e0de84a6 | ||
|
|
9bc0ee0e45 | ||
|
|
a2fc628f08 |
@@ -27,10 +27,11 @@ php bin/admin.php reset admin@example.com
|
|||||||
|
|
||||||
## 后台编辑
|
## 后台编辑
|
||||||
|
|
||||||
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。编辑器左侧可按分类和名称查找模板。悬停或键盘聚焦缩略图可放大,点击可打开预览。
|
- **网站后台**可按名称、地址或发布状态查找页面,从列表打开画布、公开页或草稿预览。
|
||||||
|
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。悬停或键盘聚焦缩略图可放大,点击可打开预览。
|
||||||
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
||||||
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
|
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
|
||||||
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。
|
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。「查看全部动态」和翻页只列出该区块所选的分类。
|
||||||
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
||||||
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
||||||
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
||||||
@@ -70,7 +71,7 @@ location = /admin/media {
|
|||||||
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
|
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
|
||||||
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
|
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
|
||||||
|
|
||||||
SQLite 已启用 WAL。本版需要新的 SQLite 文件。将 `LAYSENSE_DB` 指向新文件,执行 `php bin/install.php`,再按上面的步骤创建管理员并重启 Webman。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
|
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增加对齐字段,之后重启 Webman。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
|
||||||
|
|
||||||
### CDN
|
### CDN
|
||||||
|
|
||||||
|
|||||||
@@ -8,32 +8,76 @@ final class BlockTemplates
|
|||||||
{
|
{
|
||||||
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
|
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
|
||||||
|
|
||||||
|
public const ELEMENT_GROUPS = [
|
||||||
|
'text-elements' => ['文字与列表', [
|
||||||
|
'paragraph' => ['段落', '<p>填写正文。</p>'],
|
||||||
|
'subheading' => ['小标题', '<h3>填写小标题</h3>'],
|
||||||
|
'lead' => ['导语', '<p class="studio-lead">填写本节的导语。</p>'],
|
||||||
|
'blockquote' => ['引用', '<blockquote><p>填写需要引用的内容。</p></blockquote>'],
|
||||||
|
'bullet-list' => ['项目列表', '<ul><li>填写列表项</li><li>填写列表项</li></ul>'],
|
||||||
|
'ordered-list' => ['编号列表', '<ol><li>填写第一项</li><li>填写第二项</li></ol>'],
|
||||||
|
'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>'],
|
||||||
|
'email-link' => ['邮件链接', '<p><a href="mailto:hello@example.com">发送邮件</a></p>'],
|
||||||
|
]],
|
||||||
|
'media-elements' => ['图片与影音', [
|
||||||
|
'image' => ['图片', '', 'image/'],
|
||||||
|
'video' => ['视频', '', 'video/'],
|
||||||
|
'audio' => ['音频', '', 'audio/'],
|
||||||
|
]],
|
||||||
|
'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>'],
|
||||||
|
'disclosure' => ['折叠内容', '<div class="faq"><details><summary>填写折叠标题</summary><div><p>填写展开后的内容。</p></div></details></div>'],
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
|
||||||
public const GROUPS = [
|
public const GROUPS = [
|
||||||
'content' => ['标题与正文', [
|
'content' => ['标题与正文', [
|
||||||
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
|
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
|
||||||
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
||||||
'articles' => ['分类文章', ''],
|
'articles' => ['分类文章', ''],
|
||||||
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
|
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
|
||||||
|
'notice' => ['重点提示', '<div class="studio-notice"><h3>填写重要提示</h3><p>说明访客需要知悉的事项、条件或时间。</p></div>'],
|
||||||
]],
|
]],
|
||||||
'cover' => ['封面与横幅', [
|
'cover' => ['封面与横幅', [
|
||||||
'cover' => ['图文封面', '<div class="studio-cover"><img src="/assets/original/pagepan-example.webp" alt="" loading="lazy"><div><h3>用一句话介绍你的产品</h3><p>在首段说明访客能获得什么。</p><a class="button button-primary" href="/services">查看服务</a></div></div>'],
|
'cover' => ['图文封面', '<div class="studio-cover"><img src="/assets/original/pagepan-example.webp" alt="" loading="lazy"><div><h3>用一句话介绍你的产品</h3><p>在首段说明访客能获得什么。</p><a class="button button-primary" href="/services">查看服务</a></div></div>'],
|
||||||
'banner' => ['横幅', '<div class="studio-banner"><h3>用一句话介绍你的项目</h3><p>简要说明项目能为访客做什么。</p><a class="button button-primary" href="/services">了解更多</a></div>'],
|
'banner' => ['横幅', '<div class="studio-banner"><h3>用一句话介绍你的项目</h3><p>简要说明项目能为访客做什么。</p><a class="button button-primary" href="/services">了解更多</a></div>'],
|
||||||
|
'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' => ['图文与布局', [
|
'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>'],
|
'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' => ['媒体', [
|
||||||
|
'gallery' => ['三图画廊', '<div class="studio-gallery"><img src="/assets/original/pagepan-editor-optimized.webp" alt="PAGEPAN 编辑器" loading="lazy"><img src="/assets/original/highspeaker-ui-optimized.webp" alt="HighSpeaker DNS 管理界面" loading="lazy"><img src="/assets/original/home-hero.webp" alt="云端服务插画" loading="lazy"></div>'],
|
||||||
|
'video-demo' => ['视频演示', '<div class="studio-split"><video controls preload="none" poster="/assets/original/pagepan-editor-optimized.webp" src="/assets/original/drag-in-components.mp4"></video><div><h3>演示视频</h3><p>说明视频涵盖的功能与操作。</p></div></div>'],
|
||||||
|
]],
|
||||||
'features' => ['特性与口碑', [
|
'features' => ['特性与口碑', [
|
||||||
'features' => ['特性卡片', '<div class="card-grid feature-grid"><article class="content-card feature-card"><h3>特点一</h3><p>介绍这个特点。</p></article><article class="content-card feature-card"><h3>特点二</h3><p>介绍这个特点。</p></article><article class="content-card feature-card"><h3>特点三</h3><p>介绍这个特点。</p></article></div>'],
|
'features' => ['特性卡片', '<div class="card-grid feature-grid"><article class="content-card feature-card"><h3>特点一</h3><p>介绍这个特点。</p></article><article class="content-card feature-card"><h3>特点二</h3><p>介绍这个特点。</p></article><article class="content-card feature-card"><h3>特点三</h3><p>介绍这个特点。</p></article></div>'],
|
||||||
'quote' => ['引文', '<blockquote><p>在这里填写引用或用户反馈。</p></blockquote>'],
|
'quote' => ['引文', '<blockquote><p>在这里填写引用或用户反馈。</p></blockquote>'],
|
||||||
|
'metrics' => ['关键数据', '<dl class="studio-metrics"><div><dt>累计项目</dt><dd>100</dd></div><div><dt>服务覆盖</dt><dd>12</dd></div><div><dt>合作伙伴</dt><dd>8</dd></div></dl>'],
|
||||||
|
'testimonials' => ['用户评价', '<div class="studio-two-column studio-testimonials"><blockquote><p>填写用户的评价,并说明他们获得的结果。</p><p class="studio-attribution">用户姓名 · 公司或角色</p></blockquote><blockquote><p>填写另一条用户评价。</p><p class="studio-attribution">用户姓名 · 公司或角色</p></blockquote></div>'],
|
||||||
]],
|
]],
|
||||||
'details' => ['表格与问答', [
|
'details' => ['表格与问答', [
|
||||||
'table' => ['对比表格', '<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></tbody></table>'],
|
'table' => ['对比表格', '<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></tbody></table>'],
|
||||||
'faq' => ['常见问题', '<div class="faq"><details><summary>请输入问题</summary><div><p>请输入答案。</p></div></details></div>'],
|
'faq' => ['常见问题', '<div class="faq"><details><summary>请输入问题</summary><div><p>请输入答案。</p></div></details></div>'],
|
||||||
|
'timeline' => ['时间线', '<ol class="studio-timeline"><li><h3>确定目标</h3><p>填写这一阶段需要完成的事项。</p></li><li><h3>实施与验收</h3><p>填写交付时间与验收标准。</p></li></ol>'],
|
||||||
|
'checklist' => ['清单', '<ul class="studio-checklist"><li>填写必备材料</li><li>填写提交条件</li><li>填写确认事项</li></ul>'],
|
||||||
|
'changelog' => ['更新记录', '<div class="studio-releases"><article><h3>版本 2.0</h3><p>填写主要功能或改进。</p></article><article><h3>版本 1.0</h3><p>填写上一版本的更新内容。</p></article></div>'],
|
||||||
|
'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' => ['导航与引导', [
|
'actions' => ['导航与引导', [
|
||||||
'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>'],
|
'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>'],
|
'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>'],
|
||||||
|
'contact-card' => ['联系方式', '<div class="studio-contact"><div><h3>联系团队</h3><p>填写咨询范围与回复时间。</p></div><dl class="studio-definitions"><dt>电子邮件</dt><dd><a href="mailto:hello@example.com">hello@example.com</a></dd><dt>服务时间</dt><dd>填写工作时间</dd></dl></div>'],
|
||||||
]],
|
]],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,12 @@ final class Database
|
|||||||
throw new RuntimeException('请将 LAYSENSE_DB 指向一个新的 SQLite 文件,再运行安装命令。');
|
throw new RuntimeException('请将 LAYSENSE_DB 指向一个新的 SQLite 文件,再运行安装命令。');
|
||||||
}
|
}
|
||||||
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
||||||
|
foreach (['pages', 'sections'] as $table) {
|
||||||
|
$columns = array_column($pdo->query('PRAGMA table_info(' . $table . ')')->fetchAll(), 'name');
|
||||||
|
if (!in_array('alignments', $columns, true)) {
|
||||||
|
$pdo->exec("ALTER TABLE $table ADD COLUMN alignments TEXT NOT NULL DEFAULT '{}'");
|
||||||
|
}
|
||||||
|
}
|
||||||
$site = $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)');
|
$site = $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)');
|
||||||
$site->execute([self::json($seed['site'])]);
|
$site->execute([self::json($seed['site'])]);
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ use RuntimeException;
|
|||||||
|
|
||||||
final class Html
|
final class Html
|
||||||
{
|
{
|
||||||
|
public const ALIGNMENTS = ['left', 'center', 'right'];
|
||||||
|
|
||||||
private const TAGS = [
|
private const TAGS = [
|
||||||
'a' => ['href'], 'article' => [], 'audio' => ['src', 'controls', 'preload'], 'b' => [], 'blockquote' => [], 'br' => [],
|
'a' => ['href'], 'article' => [], 'audio' => ['src', 'controls', 'preload'], 'b' => [], 'blockquote' => [], 'br' => [],
|
||||||
'caption' => [], 'code' => [], 'dd' => [], 'details' => [], 'div' => ['role', 'aria-label', 'tabindex'],
|
'caption' => [], 'code' => [], 'dd' => [], 'details' => [], 'div' => ['role', 'aria-label', 'tabindex'],
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ final class Repository
|
|||||||
if (!$page) {
|
if (!$page) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (['actions', 'quicklinks'] as $key) {
|
foreach (['actions', 'quicklinks', 'alignments'] as $key) {
|
||||||
$page[$key] = json_decode($page[$key], true, flags: JSON_THROW_ON_ERROR);
|
$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');
|
$query = $this->pdo->prepare('SELECT * FROM sections WHERE page_slug = ? ORDER BY position, key');
|
||||||
@@ -67,14 +67,21 @@ final class Repository
|
|||||||
return $this->one('SELECT * FROM sections WHERE page_slug = ? AND key = ?', [$page, $key]);
|
return $this->one('SELECT * FROM sections WHERE page_slug = ? AND key = ?', [$page, $key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function publishedFeed(string $page, string $key): ?array
|
||||||
|
{
|
||||||
|
return $this->one("SELECT sections.title, sections.feed FROM sections
|
||||||
|
JOIN pages ON pages.slug = sections.page_slug
|
||||||
|
WHERE pages.slug = ? AND pages.status = 'published' AND sections.key = ? AND sections.feed IS NOT NULL", [$page, $key]);
|
||||||
|
}
|
||||||
|
|
||||||
public function savePage(string $slug, array $data, int $version, array $sections = []): void
|
public function savePage(string $slug, array $data, int $version, array $sections = []): void
|
||||||
{
|
{
|
||||||
Database::write(function (PDO $pdo) use ($slug, $data, $version, $sections): void {
|
Database::write(function (PDO $pdo) use ($slug, $data, $version, $sections): void {
|
||||||
$query = $pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
|
$query = $pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
|
||||||
image = ?, alt = ?, image_scale = ?, actions = ?, quicklinks = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
|
image = ?, alt = ?, image_scale = ?, alignments = ?, actions = ?, quicklinks = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
|
||||||
$query->execute([
|
$query->execute([
|
||||||
$data['name'], $data['title'], $data['description'], $data['heading'], $data['accent'], $data['lead'],
|
$data['name'], $data['title'], $data['description'], $data['heading'], $data['accent'], $data['lead'],
|
||||||
$data['image'], $data['alt'], $data['image_scale'], Database::json($data['actions']), Database::json($data['quicklinks']),
|
$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,
|
$data['status'], self::now(), $slug, $version,
|
||||||
]);
|
]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
@@ -98,9 +105,9 @@ final class Repository
|
|||||||
|
|
||||||
private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
|
private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
|
||||||
{
|
{
|
||||||
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, feed = ?, version = version + 1
|
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, feed = ?, alignments = COALESCE(?, alignments), version = version + 1
|
||||||
WHERE page_slug = ? AND key = ? AND version = ?');
|
WHERE page_slug = ? AND key = ? AND version = ?');
|
||||||
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $data['feed'] ?? null, $page, $key, $version]);
|
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $data['feed'] ?? null, $data['alignments'] ?? null, $page, $key, $version]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,9 +121,9 @@ final class Repository
|
|||||||
|
|
||||||
private static function insertSection(PDO $pdo, string $page, string $key, array $data): void
|
private static function insertSection(PDO $pdo, string $page, string $key, array $data): void
|
||||||
{
|
{
|
||||||
$query = $pdo->prepare('INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, feed, position)
|
$query = $pdo->prepare('INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, feed, alignments, position)
|
||||||
SELECT ?, ?, ?, ?, ?, ?, ?, COALESCE(MAX(position), -1) + 1 FROM sections WHERE page_slug = ?');
|
SELECT ?, ?, ?, ?, ?, ?, ?, ?, COALESCE(MAX(position), -1) + 1 FROM sections WHERE page_slug = ?');
|
||||||
$query->execute([$page, $key, $data['title'], $data['lead'], $data['style'], $data['body'], $data['feed'] ?? null, $page]);
|
$query->execute([$page, $key, $data['title'], $data['lead'], $data['style'], $data['body'], $data['feed'] ?? null, $data['alignments'] ?? '{}', $page]);
|
||||||
if ($query->rowCount() !== 1) {
|
if ($query->rowCount() !== 1) {
|
||||||
throw new RuntimeException('此区块锚点已被使用。');
|
throw new RuntimeException('此区块锚点已被使用。');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,20 @@ final class View
|
|||||||
return $value ? date($format, strtotime($value)) : '';
|
return $value ? date($format, strtotime($value)) : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function alignmentClass(?string $alignment): string
|
||||||
|
{
|
||||||
|
return in_array($alignment, Html::ALIGNMENTS, true) ? ' studio-align-' . $alignment : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function archivePage(string $path, int $page): string
|
||||||
|
{
|
||||||
|
if ($page === 1) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path . (str_contains($path, '?') ? '&' : '?') . 'page=' . $page;
|
||||||
|
}
|
||||||
|
|
||||||
public static function redirect(string $path, int $status = 303): Response
|
public static function redirect(string $path, int $status = 303): Response
|
||||||
{
|
{
|
||||||
return new Response($status, ['Location' => $path, 'Cache-Control' => $status === 301 ? 'public, max-age=300' : 'no-store'], '');
|
return new Response($status, ['Location' => $path, 'Cache-Control' => $status === 301 ? 'public, max-age=300' : 'no-store'], '');
|
||||||
|
|||||||
@@ -255,6 +255,9 @@ class AdminController
|
|||||||
}
|
}
|
||||||
$page = array_replace($page, $data, ['version' => $this->version($request)]);
|
$page = array_replace($page, $data, ['version' => $this->version($request)]);
|
||||||
try {
|
try {
|
||||||
|
$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'];
|
||||||
$data['quicklinks'] = $request->post('quicklinks') === null ? $page['quicklinks'] : SiteDesign::parseLinks($this->input($request, 'quicklinks'));
|
$data['quicklinks'] = $request->post('quicklinks') === null ? $page['quicklinks'] : SiteDesign::parseLinks($this->input($request, 'quicklinks'));
|
||||||
if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
|
if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
|
||||||
|| $data['title'] === '' || mb_strlen($data['title']) > 160 ||
|
|| $data['title'] === '' || mb_strlen($data['title']) > 160 ||
|
||||||
@@ -334,8 +337,9 @@ class AdminController
|
|||||||
$key = $change['key'] ?? null;
|
$key = $change['key'] ?? null;
|
||||||
$version = $change['version'] ?? null;
|
$version = $change['version'] ?? null;
|
||||||
$fields = $change['fields'] ?? null;
|
$fields = $change['fields'] ?? null;
|
||||||
|
$alignments = $change['alignments'] ?? null;
|
||||||
$isNew = is_array($change) && array_key_exists('version', $change) && $version === null;
|
$isNew = is_array($change) && array_key_exists('version', $change) && $version === null;
|
||||||
if (!is_string($key) || isset($updates[$key]) || !is_array($fields) || $fields === []
|
if (!is_string($key) || isset($updates[$key]) || !is_array($fields) || ($fields === [] && $alignments === null)
|
||||||
|| ($isNew ? (isset($available[$key]) || !preg_match('/^block-[a-f0-9]{32}$/D', $key))
|
|| ($isNew ? (isset($available[$key]) || !preg_match('/^block-[a-f0-9]{32}$/D', $key))
|
||||||
: (!isset($available[$key]) || !is_int($version) || $version !== (int) $available[$key]['version']))) {
|
: (!isset($available[$key]) || !is_int($version) || $version !== (int) $available[$key]['version']))) {
|
||||||
throw new RuntimeException('区块已变更或画布内容无效,请重新打开编辑页。');
|
throw new RuntimeException('区块已变更或画布内容无效,请重新打开编辑页。');
|
||||||
@@ -353,6 +357,9 @@ class AdminController
|
|||||||
}
|
}
|
||||||
$section[$field] = trim($value);
|
$section[$field] = trim($value);
|
||||||
}
|
}
|
||||||
|
if ($alignments !== null) {
|
||||||
|
$section['alignments'] = Database::json($this->alignmentMap($alignments, ['title', 'lead']));
|
||||||
|
}
|
||||||
$this->checkSection($section, $section['style']);
|
$this->checkSection($section, $section['style']);
|
||||||
if (isset($fields['body'])) {
|
if (isset($fields['body'])) {
|
||||||
$section['body'] = Html::sanitize($section['body']);
|
$section['body'] = Html::sanitize($section['body']);
|
||||||
@@ -367,6 +374,20 @@ class AdminController
|
|||||||
return $updates;
|
return $updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function alignmentMap(mixed $alignments, array $fields): array
|
||||||
|
{
|
||||||
|
if (!is_array($alignments) || array_diff(array_keys($alignments), $fields)) {
|
||||||
|
throw new RuntimeException('画布对齐设置无效。');
|
||||||
|
}
|
||||||
|
foreach ($alignments as $value) {
|
||||||
|
if (!in_array($value, Html::ALIGNMENTS, true)) {
|
||||||
|
throw new RuntimeException('画布对齐设置无效。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $alignments;
|
||||||
|
}
|
||||||
|
|
||||||
private function checkSection(array $section, string $savedStyle): void
|
private function checkSection(array $section, string $savedStyle): void
|
||||||
{
|
{
|
||||||
if ($section['title'] === '' || mb_strlen($section['title']) > 100 || mb_strlen($section['lead']) > 500
|
if ($section['title'] === '' || mb_strlen($section['title']) > 100 || mb_strlen($section['lead']) > 500
|
||||||
@@ -570,7 +591,7 @@ class AdminController
|
|||||||
], $status);
|
], $status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::render($view, $data + ['token' => $token, 'user' => $this->user], $status, true);
|
return View::render($view, $data + ['token' => $token, 'user' => $this->user, 'adminPath' => $request->path()], $status, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function error(Request $request, string $message, int $status): Response
|
protected function error(Request $request, string $message, int $status): Response
|
||||||
|
|||||||
@@ -39,10 +39,12 @@ final class SiteController
|
|||||||
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
|
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
|
||||||
$tabs = $feed['mode'] === 'tabs' && count($feed['categories']) > 1;
|
$tabs = $feed['mode'] === 'tabs' && count($feed['categories']) > 1;
|
||||||
$section['articleFeed'] = [];
|
$section['articleFeed'] = [];
|
||||||
|
$section['archivePath'] = $page['status'] === 'published' ? '/articles/feed/' . $slug . '/' . $section['key'] : null;
|
||||||
foreach ($tabs ? $feed['categories'] : [''] as $category) {
|
foreach ($tabs ? $feed['categories'] : [''] as $category) {
|
||||||
|
$selected = $category === '' ? $feed['categories'] : [$category];
|
||||||
$section['articleFeed'][] = [
|
$section['articleFeed'][] = [
|
||||||
'label' => $categories[$category] ?? '',
|
'categories' => $selected, 'label' => $categories[$category] ?? '',
|
||||||
'articles' => $repo->articles($category === '' ? $feed['categories'] : $category, limit: $feed['limit']),
|
'articles' => $repo->articles($selected, limit: $feed['limit']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +104,60 @@ final class SiteController
|
|||||||
}
|
}
|
||||||
$title = $category ? $categories[$category] : ($tag ?: '来笙动态');
|
$title = $category ? $categories[$category] : ($tag ?: '来笙动态');
|
||||||
$path = '/articles' . ($category ? '/category/' . $category : ($tag ? '/tag/' . rawurlencode($tag) : ''));
|
$path = '/articles' . ($category ? '/category/' . $category : ($tag ? '/tag/' . rawurlencode($tag) : ''));
|
||||||
|
|
||||||
|
$categoryLinks = [];
|
||||||
|
foreach (array_keys($categories) as $key) {
|
||||||
|
$categoryLinks[$key] = '/articles/category/' . $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderArchive($request, $repo, $category, $tag, [
|
||||||
|
'headline' => $title, 'description' => '查看来笙的公告、新闻和产品动态。',
|
||||||
|
'archivePath' => $path, 'allPath' => '/articles',
|
||||||
|
'categoryLinks' => $categoryLinks,
|
||||||
|
'categories' => $categories, 'category' => $category, 'tag' => $tag,
|
||||||
|
'backPath' => $category || $tag ? '/articles' : null, 'backLabel' => '全部动态',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function feedArchive(Request $request, string $slug, string $key): Response
|
||||||
|
{
|
||||||
|
$repo = new Repository();
|
||||||
|
$section = $repo->publishedFeed($slug, $key);
|
||||||
|
if (!$section) {
|
||||||
|
return $this->missing($request);
|
||||||
|
}
|
||||||
|
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
$labels = $repo->categories();
|
||||||
|
$categories = [];
|
||||||
|
foreach ($feed['categories'] as $value) {
|
||||||
|
if (isset($labels[$value])) {
|
||||||
|
$categories[$value] = $labels[$value];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$category = $request->get('category');
|
||||||
|
if (!$categories || ($category !== null && (!is_string($category) || !isset($categories[$category])))) {
|
||||||
|
return $this->missing($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
$allPath = '/articles/feed/' . $slug . '/' . $key;
|
||||||
|
$returnPath = ($slug === 'home' ? '/' : '/' . $slug) . '#' . $key;
|
||||||
|
$categoryLinks = [];
|
||||||
|
foreach (array_keys($categories) as $value) {
|
||||||
|
$categoryLinks[$value] = $allPath . '?category=' . rawurlencode((string) $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->renderArchive($request, $repo, $category ?? array_keys($categories), null, [
|
||||||
|
'headline' => $section['title'] . ($category !== null ? ' · ' . $categories[$category] : ''),
|
||||||
|
'description' => '查看' . implode('、', $categories) . '分类下的文章。',
|
||||||
|
'archivePath' => $category === null ? $allPath : $categoryLinks[$category], 'allPath' => $allPath,
|
||||||
|
'categoryLinks' => $categoryLinks, 'categories' => $categories, 'category' => $category, 'tag' => null,
|
||||||
|
'categoryScope' => $category === null ? array_keys($categories) : [$category],
|
||||||
|
'backPath' => $returnPath, 'backLabel' => '返回原页面', 'noindex' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function renderArchive(Request $request, Repository $repo, string|array|null $category, ?string $tag, array $view): Response
|
||||||
|
{
|
||||||
$number = $request->get('page', '1');
|
$number = $request->get('page', '1');
|
||||||
if (!is_scalar($number) || !preg_match('/^[1-9][0-9]{0,4}$/D', (string) $number)) {
|
if (!is_scalar($number) || !preg_match('/^[1-9][0-9]{0,4}$/D', (string) $number)) {
|
||||||
return $this->missing($request);
|
return $this->missing($request);
|
||||||
@@ -111,13 +167,12 @@ final class SiteController
|
|||||||
if ($page > 1 && $articles === []) {
|
if ($page > 1 && $articles === []) {
|
||||||
return $this->missing($request);
|
return $this->missing($request);
|
||||||
}
|
}
|
||||||
|
$path = $view['archivePath'];
|
||||||
|
|
||||||
return View::render('archive', [
|
return View::render('archive', $view + [
|
||||||
'site' => $repo->site(), 'title' => $title . ' · 来笙', 'headline' => $title,
|
'site' => $repo->site(), 'title' => $view['headline'] . ' · 来笙',
|
||||||
'description' => '查看来笙的公告、新闻和产品动态。',
|
'path' => $page > 1 ? View::archivePage($path, $page) : $path,
|
||||||
'path' => $path . ($page > 1 ? '?page=' . $page : ''), 'archivePath' => $path,
|
'pageNumber' => $page, 'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
|
||||||
'categories' => $categories, 'category' => $category, 'tag' => $tag, 'pageNumber' => $page,
|
|
||||||
'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
|
|
||||||
'noindex' => $articles === [],
|
'noindex' => $articles === [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ $filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
|
|||||||
<nav class="filter-nav" aria-label="筛选文章">
|
<nav class="filter-nav" aria-label="筛选文章">
|
||||||
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
<?php foreach ($categories as $key => $name): ?>
|
<?php foreach ($categories as $key => $name): ?>
|
||||||
<a href="/admin/articles?category=<?= $e($key) ?>" <?= $category === $key ? 'aria-current="page"' : '' ?>><?= $e($name) ?></a>
|
<a href="/admin/articles?category=<?= $e($key) ?>" <?= $category === (string) $key ? 'aria-current="page"' : '' ?>><?= $e($name) ?></a>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="admin-panel">
|
<div class="admin-panel">
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$checked = array_fill_keys($selected, true);
|
||||||
?>
|
?>
|
||||||
<fieldset class="category-checks">
|
<fieldset class="category-checks">
|
||||||
<legend><?= $e($legend) ?></legend>
|
<legend><?= $e($legend) ?></legend>
|
||||||
<div>
|
<div>
|
||||||
<?php foreach ($categories as $key => $label): ?>
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
<label><input type="checkbox" name="<?= $e($name) ?>[]" value="<?= $e($key) ?>" <?= in_array($key, $selected, true) ? 'checked' : '' ?>> <?= $e($label) ?></label>
|
<label><input type="checkbox" name="<?= $e($name) ?>[]" value="<?= $e($key) ?>" <?= isset($checked[$key]) ? 'checked' : '' ?>> <?= $e($label) ?></label>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
@@ -2,24 +2,58 @@
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$live = count(array_filter($pages, static fn (array $page): bool => $page['status'] === 'published'));
|
||||||
?>
|
?>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading dashboard-heading">
|
||||||
<div><h1>内容管理</h1><p>管理网站页面、文章、公告和产品动态。</p></div>
|
<h1>网站后台</h1>
|
||||||
<div class="actions"><a class="button button-primary" href="/admin/new-page">新建页面</a>
|
<div class="actions">
|
||||||
<a class="button button-outline" href="/admin/articles/new">新建文章</a></div>
|
<a class="button button-primary" href="/admin/new-page">新建页面</a>
|
||||||
|
<a class="button button-outline" href="/admin/articles/new">写文章</a>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<section class="admin-panel" aria-labelledby="pages-title">
|
<div class="dashboard-grid">
|
||||||
<h2 id="pages-title">网站页面</h2>
|
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
|
||||||
<ul class="admin-list">
|
<div class="admin-heading compact">
|
||||||
<?php foreach ($pages as $page): ?>
|
<h2 id="pages-title">网站页面</h2>
|
||||||
<li>
|
<p class="field-note"><?= $live ?> 个已发布 · <?= count($pages) - $live ?> 个草稿</p>
|
||||||
<div><strong><?= $e($page['name']) ?></strong><small><?= $e($page['slug'] === 'home' ? '/' : '/' . $page['slug']) ?> · <?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></small></div>
|
</div>
|
||||||
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
<div class="dashboard-filters" data-page-filters hidden>
|
||||||
</li>
|
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
|
||||||
<?php endforeach ?>
|
<label>发布状态<select data-page-status>
|
||||||
</ul>
|
<option value="">全部状态</option>
|
||||||
</section>
|
<option value="published">已发布</option>
|
||||||
<section class="admin-panel" aria-labelledby="recent-title">
|
<option value="draft">草稿</option>
|
||||||
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2><a href="/admin/articles">管理全部文章</a></div>
|
</select></label>
|
||||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
</div>
|
||||||
</section>
|
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
|
||||||
|
<ul class="admin-list dashboard-page-list">
|
||||||
|
<?php foreach ($pages as $page): ?>
|
||||||
|
<?php $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $page['status'] === 'published'; ?>
|
||||||
|
<li data-page-item="<?= $e($page['status']) ?>" data-page-label="<?= $e($page['name'] . ' ' . $page['title'] . ' ' . $path) ?>">
|
||||||
|
<div class="dashboard-page-label"><strong><?= $e($page['name']) ?></strong><small><?= $e($path) ?></small></div>
|
||||||
|
<span class="dashboard-page-state" data-published="<?= $published ? 'true' : 'false' ?>"><?= $published ? '已发布' : '草稿' ?></span>
|
||||||
|
<div class="dashboard-page-actions">
|
||||||
|
<a class="button button-outline" href="/admin/pages/<?= $e($page['slug']) ?>">编辑页面</a>
|
||||||
|
<a href="<?= $e($published ? $path : '/admin/pages/' . $page['slug'] . '/preview') ?>" target="_blank" rel="noopener"><?= $published ? '查看' : '预览' ?></a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<div class="dashboard-secondary">
|
||||||
|
<section class="admin-panel" aria-labelledby="recent-title">
|
||||||
|
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2></div>
|
||||||
|
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||||
|
<a class="back-link" href="/admin/articles">管理全部文章</a>
|
||||||
|
</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>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$active = match (true) {
|
||||||
|
str_starts_with($adminPath, '/admin/article') => 'articles',
|
||||||
|
str_starts_with($adminPath, '/admin/media') => 'media',
|
||||||
|
str_starts_with($adminPath, '/admin/settings') => 'settings',
|
||||||
|
$adminPath === '/admin/password' => '',
|
||||||
|
default => 'pages',
|
||||||
|
};
|
||||||
?>
|
?>
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
@@ -29,18 +36,25 @@ $e = View::escape(...);
|
|||||||
<div class="admin-wrap admin-bar-inner">
|
<div class="admin-wrap admin-bar-inner">
|
||||||
<a class="wordmark" href="/admin" aria-label="来笙内容管理首页"><img src="/assets/wordmark.webp" alt="来笙 Laysense" width="130" height="33"></a>
|
<a class="wordmark" href="/admin" aria-label="来笙内容管理首页"><img src="/assets/wordmark.webp" alt="来笙 Laysense" width="130" height="33"></a>
|
||||||
<?php if ($user): ?>
|
<?php if ($user): ?>
|
||||||
<nav aria-label="后台导航">
|
<nav class="admin-primary" aria-label="后台导航">
|
||||||
<a href="/admin">页面</a>
|
<a href="/admin"<?= $active === 'pages' ? ' aria-current="page"' : '' ?>>页面</a>
|
||||||
<a href="/admin/articles">文章</a>
|
<a href="/admin/articles"<?= $active === 'articles' ? ' aria-current="page"' : '' ?>>文章</a>
|
||||||
<a href="/admin/media">媒体库</a>
|
<a href="/admin/media"<?= $active === 'media' ? ' aria-current="page"' : '' ?>>媒体库</a>
|
||||||
<a href="/admin/settings/header">网站设置</a>
|
<a href="/admin/settings/header"<?= $active === 'settings' ? ' aria-current="page"' : '' ?>>网站设置</a>
|
||||||
<a href="/admin/password">修改密码</a>
|
|
||||||
<a href="/">访问网站</a>
|
|
||||||
<form method="post" action="/admin/logout">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<button class="button button-outline" type="submit">退出</button>
|
|
||||||
</form>
|
|
||||||
</nav>
|
</nav>
|
||||||
|
<div class="admin-utility">
|
||||||
|
<a href="/">访问网站</a>
|
||||||
|
<details class="admin-account">
|
||||||
|
<summary>账户</summary>
|
||||||
|
<div class="admin-account-menu">
|
||||||
|
<a href="/admin/password">修改密码</a>
|
||||||
|
<form method="post" action="/admin/logout">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<button type="submit">退出登录</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="back-link" href="/">返回网站</a>
|
<a class="back-link" href="/">返回网站</a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use App\Content\Database;
|
||||||
use App\Content\SiteDesign;
|
use App\Content\SiteDesign;
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
use App\Content\BlockTemplates;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
$slug = $page['slug'];
|
$slug = $page['slug'];
|
||||||
@@ -19,56 +19,8 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||||
<div class="studio-layout">
|
<div class="studio-layout">
|
||||||
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
|
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
|
||||||
<h2 id="studio-library-title">区块模板</h2>
|
<h2 id="studio-library-title">页面编辑</h2>
|
||||||
<?= View::fragment('studio-templates') ?>
|
<?= View::fragment('studio-templates', ['layers' => View::fragment('studio-layers', compact('page', 'slug', 'token'))]) ?>
|
||||||
<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): ?>
|
|
||||||
<li>
|
|
||||||
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
|
||||||
<div class="actions studio-block-actions">
|
|
||||||
<button class="button button-outline" type="button" data-canvas-jump="<?= $e($item['key']) ?>" hidden>在画布编辑</button>
|
|
||||||
<a class="button button-outline" href="/admin/pages/<?= $e($slug) ?>/<?= $e($item['key']) ?>">区块设置</a>
|
|
||||||
<form method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<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="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</details>
|
|
||||||
</aside>
|
</aside>
|
||||||
<div class="studio-workspace">
|
<div class="studio-workspace">
|
||||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
||||||
@@ -92,6 +44,11 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
<div class="studio-frame-window">
|
<div class="studio-frame-window">
|
||||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
<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-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>
|
||||||
|
</div>
|
||||||
<button type="button" data-element-properties>属性</button>
|
<button type="button" data-element-properties>属性</button>
|
||||||
<button type="button" data-element-copy>复制</button>
|
<button type="button" data-element-copy>复制</button>
|
||||||
<button type="button" data-element-delete>删除</button>
|
<button type="button" data-element-delete>删除</button>
|
||||||
@@ -103,7 +60,7 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="field-note">单击画布中的元素可打开浮动工具条。选中媒体后可拖动边缘手柄调整宽度。</p>
|
<p class="field-note">单击画布元素可设置对齐、复制或删除。选中媒体后可拖动边缘手柄调整宽度。</p>
|
||||||
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
|
<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>
|
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
|
||||||
<form class="admin-form" method="dialog">
|
<form class="admin-form" method="dialog">
|
||||||
@@ -130,6 +87,7 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
<input type="hidden" name="version" value="<?= $e($page['version']) ?>">
|
||||||
<input type="hidden" name="canvas_sections" value="">
|
<input type="hidden" name="canvas_sections" value="">
|
||||||
|
<input type="hidden" name="alignments" value="<?= $e(Database::json($page['alignments'])) ?>">
|
||||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
<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 标题<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>
|
<label>SEO 描述<textarea name="description" rows="2" maxlength="300"><?= $e($page['description']) ?></textarea></label>
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ $e = View::escape(...);
|
|||||||
<section class="section article-page" aria-labelledby="archive-title" data-enter>
|
<section class="section article-page" aria-labelledby="archive-title" data-enter>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
<?php if ($tag || $category): ?><a class="back-link" href="/articles">全部动态</a><?php endif ?>
|
<?php if ($backPath): ?><a class="back-link" href="<?= $e($backPath) ?>"><?= $e($backLabel) ?></a><?php endif ?>
|
||||||
<h1 id="archive-title"><?= $e($headline) ?></h1>
|
<h1 id="archive-title"><?= $e($headline) ?></h1>
|
||||||
<p>来笙的公告、新闻和产品动态。</p>
|
<p><?= $e($description) ?></p>
|
||||||
</div>
|
</div>
|
||||||
<nav class="filter-nav" aria-label="动态分类">
|
<nav class="filter-nav" aria-label="动态分类">
|
||||||
<a href="/articles" <?= !$category && !$tag ? 'aria-current="page"' : '' ?>>全部</a>
|
<a href="<?= $e($allPath) ?>" <?= !$category && !$tag ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
<?php foreach ($categories as $key => $label): ?>
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
<a href="/articles/category/<?= $e($key) ?>" <?= $category === $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
<a href="<?= $e($categoryLinks[$key]) ?>" <?= $category === (string) $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</nav>
|
</nav>
|
||||||
<?= View::fragment('article-list', ['articles' => $articles]) ?>
|
<?= View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
|
||||||
<?php if ($pageNumber > 1 || $hasNext): ?>
|
<?php if ($pageNumber > 1 || $hasNext): ?>
|
||||||
<nav class="pagination" aria-label="动态分页">
|
<nav class="pagination" aria-label="动态分页">
|
||||||
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="<?= $e($archivePath . ($pageNumber > 2 ? '?page=' . ($pageNumber - 1) : '')) ?>" rel="prev">上一页</a><?php endif ?>
|
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="<?= $e(View::archivePage($archivePath, $pageNumber - 1)) ?>" rel="prev">上一页</a><?php endif ?>
|
||||||
<span>第 <?= $e($pageNumber) ?> 页</span>
|
<span>第 <?= $e($pageNumber) ?> 页</span>
|
||||||
<?php if ($hasNext): ?><a class="button button-outline" href="<?= $e($archivePath . '?page=' . ($pageNumber + 1)) ?>" rel="next">下一页</a><?php endif ?>
|
<?php if ($hasNext): ?><a class="button button-outline" href="<?= $e(View::archivePage($archivePath, $pageNumber + 1)) ?>" rel="next">下一页</a><?php endif ?>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ $e = View::escape(...);
|
|||||||
<?php foreach ($groups as $index => $group): ?>
|
<?php foreach ($groups as $index => $group): ?>
|
||||||
<div id="<?= $e($sectionKey) ?>-articles-<?= $index ?>" data-tab-panel>
|
<div id="<?= $e($sectionKey) ?>-articles-<?= $index ?>" data-tab-panel>
|
||||||
<?php if ($group['label'] !== ''): ?><h3 data-tab-heading><?= $e($group['label']) ?></h3><?php endif ?>
|
<?php if ($group['label'] !== ''): ?><h3 data-tab-heading><?= $e($group['label']) ?></h3><?php endif ?>
|
||||||
<?= View::fragment('article-list', ['articles' => $group['articles']]) ?>
|
<?= View::fragment('article-list', ['articles' => $group['articles'], 'categoryScope' => $group['categories']]) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
<?php if ($archivePath !== null): ?>
|
||||||
|
<p class="article-feed-archive"><a class="back-link" href="<?= $e($archivePath) ?>">查看全部动态</a></p>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,13 +2,15 @@
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$scope = isset($categoryScope) ? array_flip($categoryScope) : null;
|
||||||
?>
|
?>
|
||||||
<?php if ($articles): ?>
|
<?php if ($articles): ?>
|
||||||
<ul class="article-list">
|
<ul class="article-list">
|
||||||
<?php foreach ($articles as $item): ?>
|
<?php foreach ($articles as $item): ?>
|
||||||
|
<?php $labels = $scope === null ? $item['categories'] : array_intersect_key($item['categories'], $scope); ?>
|
||||||
<li>
|
<li>
|
||||||
<a class="article-row" href="/articles/<?= $e($item['slug']) ?>">
|
<a class="article-row" href="/articles/<?= $e($item['slug']) ?>">
|
||||||
<span class="article-category"><?= $e(implode('、', $item['categories'])) ?></span>
|
<span class="article-category"><?= $e(implode('、', $labels)) ?></span>
|
||||||
<span class="article-row-title"><?= $e($item['title']) ?>
|
<span class="article-row-title"><?= $e($item['title']) ?>
|
||||||
<?php if ($item['summary']): ?><small><?= $e($item['summary']) ?></small><?php endif ?>
|
<?php if ($item['summary']): ?><small><?= $e($item['summary']) ?></small><?php endif ?>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -1,37 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<section class="section network" aria-label="支持项目与合作伙伴">
|
<section class="section network" aria-label="支持项目与合作伙伴">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php if (!$standalone): ?>
|
<?php if (!$standalone): ?>
|
||||||
<div class="section-heading inline-heading">
|
<div class="section-heading inline-heading">
|
||||||
<h2>支持项目与合作伙伴</h2>
|
<h2>支持项目与合作伙伴</h2>
|
||||||
<a class="button button-outline" href="/network">查看全部</a>
|
<a class="button button-outline" href="/network">查看全部</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php foreach ($network as $slug => $group): ?>
|
<?php foreach ($network as $slug => $group): ?>
|
||||||
<div class="network-group" id="<?= $e($slug) ?>">
|
<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 ($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 ?>
|
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
|
||||||
<ul class="network-list">
|
<ul class="network-list">
|
||||||
<?php foreach ($group['articles'] as $item): ?>
|
<?php foreach ($group['articles'] as $item): ?>
|
||||||
<?php $card = $item['card']; $articlePath = '/articles/' . $item['slug']; ?>
|
<?php
|
||||||
<li>
|
// 优先跳卡片配置的网址;没有网址时,只有文章本身有内容才回退到文章页,否则不渲染链接。
|
||||||
<a href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>">
|
$card = $item['card'];
|
||||||
<?php if (!empty($card['image'])): ?>
|
$articlePath = '/articles/' . $item['slug'];
|
||||||
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
$hasDetail = $item['body'] !== '' || $item['summary'] !== '';
|
||||||
<?php endif ?>
|
$target = ($card['url'] ?? '') ?: ($hasDetail ? $articlePath : '');
|
||||||
<span><?= $e($item['title']) ?></span>
|
?>
|
||||||
</a>
|
<li>
|
||||||
<?php if ($standalone && !empty($card['url']) && ($item['body'] !== '' || $item['summary'] !== '')): ?>
|
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
|
||||||
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
<?php if (!empty($card['image'])): ?>
|
||||||
<?php endif ?>
|
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
||||||
</li>
|
<?php endif ?>
|
||||||
<?php endforeach ?>
|
<span><?= $e($item['title']) ?></span>
|
||||||
</ul>
|
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
|
||||||
</div>
|
<?php if ($standalone && !empty($card['url']) && $hasDetail): ?>
|
||||||
<?php endforeach ?>
|
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
||||||
</div>
|
<?php endif ?>
|
||||||
</section>
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use App\Content\View;
|
|||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
$home = $page['slug'] === 'home';
|
$home = $page['slug'] === 'home';
|
||||||
$service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
|
$service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
|
||||||
|
$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 . '"' : '';
|
$field = static fn (string $name): string => $canvas ? ' data-studio-field="' . $name . '"' : '';
|
||||||
?>
|
?>
|
||||||
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
|
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
|
||||||
@@ -25,16 +27,16 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
|
|||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<p class="overline hero-label"><?= $e($site['footer']['name'] ?? $site['name']) ?></p>
|
<p class="overline hero-label"><?= $e($site['footer']['name'] ?? $site['name']) ?></p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<h1><span class="hero-heading-primary"<?= $field('heading') ?>><?= $e($page['heading']) ?></span><?php if ($canvas): ?><span class="studio-accent"<?= $field('accent') ?>><?= $e($page['accent']) ?></span><?php elseif ($page['accent'] !== ''): ?><br><span><?= $e($page['accent']) ?><?php if ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></span><?php elseif ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></h1>
|
<h1<?= isset($alignments['heading']) ? ' class="' . trim(View::alignmentClass($alignments['heading'])) . '"' : '' ?><?= $alignField('heading') ?>><span class="hero-heading-primary"<?= $field('heading') ?>><?= $e($page['heading']) ?></span><?php if ($canvas): ?><span class="studio-accent"<?= $field('accent') ?>><?= $e($page['accent']) ?></span><?php elseif ($page['accent'] !== ''): ?><br><span><?= $e($page['accent']) ?><?php if ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></span><?php elseif ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></h1>
|
||||||
<p class="hero-lead"<?= $field('lead') ?>><?= $e($page['lead']) ?></p>
|
<p class="hero-lead<?= View::alignmentClass($alignments['lead'] ?? null) ?>"<?= $field('lead') ?><?= $alignField('lead') ?>><?= $e($page['lead']) ?></p>
|
||||||
<div class="actions hero-actions">
|
<div class="actions hero-actions<?= View::alignmentClass($alignments['actions'] ?? null) ?>"<?= $alignField('actions') ?>>
|
||||||
<?php foreach ($canvas ? array_pad($page['actions'], 2, ['', '']) : $page['actions'] as $index => [$url, $label]): ?>
|
<?php foreach ($canvas ? array_pad($page['actions'], 2, ['', '']) : $page['actions'] as $index => [$url, $label]): ?>
|
||||||
<a class="button <?= $index ? 'button-outline' : 'button-primary' ?>" href="<?= $e($url) ?>"<?= $canvas ? ' data-studio-action="' . ($index + 1) . '"' : '' ?><?= $label === '' && $url === '' ? ' hidden' : '' ?>><?= $e($label) ?></a>
|
<a class="button <?= $index ? 'button-outline' : 'button-primary' ?>" href="<?= $e($url) ?>"<?= $canvas ? ' data-studio-action="' . ($index + 1) . '"' : '' ?><?= $label === '' && $url === '' ? ' hidden' : '' ?>><?= $e($label) ?></a>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($canvas || $page['image'] !== ''): ?>
|
<?php if ($canvas || $page['image'] !== ''): ?>
|
||||||
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?><?= $page['image_scale'] ? ' studio-media-' . $e($page['image_scale']) : '' ?>" data-visual<?= $page['image'] === '' ? ' hidden' : '' ?>>
|
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?><?= $page['image_scale'] ? ' studio-media-' . $e($page['image_scale']) : '' ?><?= View::alignmentClass($alignments['image'] ?? null) ?>" data-visual<?= $alignField('image') ?><?= $page['image'] === '' ? ' hidden' : '' ?>>
|
||||||
<img<?= $page['image'] === '' ? '' : ' src="' . $e($page['image']) . '"' ?> alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"<?= $canvas ? ' data-studio-hero-image' : '' ?>>
|
<img<?= $page['image'] === '' ? '' : ' src="' . $e($page['image']) . '"' ?> alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"<?= $canvas ? ' data-studio-hero-image' : '' ?>>
|
||||||
<?php if ($home && !$canvas && $page['image'] === '/assets/original/home-hero.webp'): ?>
|
<?php if ($home && !$canvas && $page['image'] === '/assets/original/home-hero.webp'): ?>
|
||||||
<svg class="home-pipe-flow" viewBox="0 0 640 480" aria-hidden="true" focusable="false">
|
<svg class="home-pipe-flow" viewBox="0 0 640 480" aria-hidden="true" focusable="false">
|
||||||
|
|||||||
@@ -3,16 +3,21 @@ use App\Content\View;
|
|||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
$canvas ??= false;
|
$canvas ??= false;
|
||||||
|
$body = $section['body'];
|
||||||
|
$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>') {
|
||||||
|
$body = '';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<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']) ?>" 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'])) . '"' : '' ?>>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
<h2 id="heading-<?= $e($section['key']) ?>"<?= $canvas ? ' data-studio-part="title"' : '' ?>><?= $e($section['title']) ?></h2>
|
<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<?= $canvas ? ' data-studio-part="lead"' : '' ?>><?= $e($section['lead']) ?></p><?php endif ?>
|
<?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>
|
</div>
|
||||||
<?php if (!empty($section['articleFeed'])): ?>
|
<?php if (!empty($section['articleFeed'])): ?>
|
||||||
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key']]) ?>
|
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key'], 'archivePath' => $section['archivePath']]) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($canvas || $section['body'] !== ''): ?><div class="rich<?= !empty($section['articleFeed']) ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $section['body'] ?></div><?php endif ?>
|
<?php if ($canvas || $body !== ''): ?><div class="rich<?= !empty($section['articleFeed']) ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,41 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<section class="section catalog-hero">
|
<section class="section catalog-hero">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
||||||
<h1>产品与服务</h1>
|
<h1>产品与服务</h1>
|
||||||
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="section catalog-listing" aria-label="产品与服务目录">
|
<section class="section catalog-listing" aria-label="产品与服务目录">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
||||||
<div class="catalog-grid">
|
<div class="catalog-grid">
|
||||||
<?php foreach ($products as $product): ?>
|
<?php foreach ($products as $product): ?>
|
||||||
<?php $card = $product['card']; $articlePath = '/articles/' . $product['slug']; ?>
|
<?php
|
||||||
<article class="catalog-card">
|
// 目录卡片指向卡片自己配置的网址;没有网址时,只有文章本身有内容才回退到文章页。
|
||||||
<?php if (!empty($card['image'])): ?>
|
$card = $product['card'];
|
||||||
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
$hasDetail = $product['body'] !== '' || $product['summary'] !== '';
|
||||||
<?php endif ?>
|
$target = ($card['url'] ?? '') ?: ($hasDetail ? '/articles/' . $product['slug'] : '');
|
||||||
<div class="catalog-content">
|
?>
|
||||||
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
<article class="catalog-card">
|
||||||
<h2><a href="<?= $e($articlePath) ?>"><?= $e($product['title']) ?></a></h2>
|
<?php if (!empty($card['image'])): ?>
|
||||||
<?php if ($product['summary']): ?>
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
||||||
<p><?= $e($product['summary']) ?></p>
|
<?php endif ?>
|
||||||
<?php else: ?>
|
<div class="catalog-content">
|
||||||
<div class="rich"><?= Html::articleBody($product) ?></div>
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
||||||
<?php endif ?>
|
<h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
|
||||||
<div class="actions">
|
<?php if ($product['summary']): ?>
|
||||||
<a class="button button-primary" href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a>
|
<p><?= $e($product['summary']) ?></p>
|
||||||
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
<?php else: ?>
|
||||||
</div>
|
<div class="rich"><?= Html::articleBody($product) ?></div>
|
||||||
</div>
|
<?php endif ?>
|
||||||
</article>
|
<?php if ($target !== '' || !empty($card['extra_url'])): ?>
|
||||||
<?php endforeach ?>
|
<div class="actions">
|
||||||
</div>
|
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
|
||||||
</div>
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
</section>
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?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): ?>
|
||||||
|
<li>
|
||||||
|
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
||||||
|
<div class="actions studio-block-actions">
|
||||||
|
<button class="button button-outline" type="button" data-canvas-jump="<?= $e($item['key']) ?>" hidden>在画布编辑</button>
|
||||||
|
<a class="button button-outline" href="/admin/pages/<?= $e($slug) ?>/<?= $e($item['key']) ?>">区块设置</a>
|
||||||
|
<form method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<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="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$modules = $kind === 'modules';
|
||||||
|
?>
|
||||||
|
<section role="tabpanel" id="studio-panel-<?= $kind ?>" aria-labelledby="studio-tab-<?= $kind ?>" data-library-panel="<?= $kind ?>" hidden>
|
||||||
|
<ul class="studio-library-categories" data-library-index>
|
||||||
|
<?php foreach ($groups as $group => [$category, $items]): ?>
|
||||||
|
<li><button type="button" data-library-category="<?= $e($group) ?>" data-library-label="<?= $e($category) ?>">
|
||||||
|
<span><?= $e($category) ?></span><small><?= count($items) ?></small>
|
||||||
|
</button></li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<div class="studio-library-content" data-library-content hidden>
|
||||||
|
<div class="studio-library-category-title">
|
||||||
|
<button type="button" data-library-back>返回分类</button>
|
||||||
|
<h3 data-library-title></h3>
|
||||||
|
</div>
|
||||||
|
<label class="studio-template-search">查找本分类<input type="search" data-template-search autocomplete="off"></label>
|
||||||
|
<?php if ($modules): ?>
|
||||||
|
<label class="studio-insert-mode"><input type="checkbox" data-template-inline> 插入当前正文</label>
|
||||||
|
<?php endif ?>
|
||||||
|
<p class="field-note" data-template-empty hidden role="status">没有匹配的<?= $modules ? '组件' : '元素' ?>。</p>
|
||||||
|
<?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 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) ?>"
|
||||||
|
aria-label="预览<?= $e($label) ?>组件">
|
||||||
|
<img src="/assets/template-previews/<?= $e($key) ?>.webp" alt="" width="768" height="480" loading="lazy">
|
||||||
|
</button>
|
||||||
|
<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>
|
||||||
|
</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 ?>
|
||||||
|
aria-label="插入<?= $e($label) ?>"><?= $e($label) ?></button>
|
||||||
|
<template data-element="<?= $e($key) ?>"><?= $markup ?></template>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php if ($modules): ?>
|
||||||
|
<p class="field-note" data-template-status role="status"></p>
|
||||||
|
<ul class="studio-pending" data-template-pending aria-label="待保存区块" hidden></ul>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="field-note" data-element-status role="status"></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</section>
|
||||||
@@ -4,42 +4,22 @@ use App\Content\BlockTemplates;
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
|
||||||
?>
|
?>
|
||||||
<div class="studio-presets" data-canvas-presets>
|
<div class="studio-presets" data-canvas-presets>
|
||||||
<label class="studio-template-search">搜索模板<input type="search" data-template-search placeholder="按名称或分类搜索" autocomplete="off"></label>
|
<div class="studio-library-tabs" role="tablist" aria-label="页面编辑工具" data-library-tabs hidden>
|
||||||
<div class="studio-template-filters" role="group" aria-label="模板分类">
|
<?php foreach ($labels as $kind => $label): ?>
|
||||||
<button type="button" data-template-filter="" aria-pressed="true">全部</button>
|
<button type="button" role="tab" id="studio-tab-<?= $kind ?>" aria-controls="studio-panel-<?= $kind ?>"
|
||||||
<?php foreach (BlockTemplates::GROUPS as $group => [$category]): ?>
|
aria-selected="false" tabindex="-1" data-library-tab="<?= $kind ?>"><?= $e($label) ?></button>
|
||||||
<button type="button" data-template-filter="<?= $e($group) ?>" aria-pressed="false"><?= $e($category) ?></button>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
|
||||||
<label class="studio-insert-mode"><input type="checkbox" data-template-inline> 插入当前正文</label>
|
|
||||||
<p class="field-note" data-template-status role="status"></p>
|
|
||||||
<ul class="studio-pending" data-template-pending hidden></ul>
|
|
||||||
<p class="field-note" data-template-empty hidden role="status">没有找到匹配的模板。</p>
|
|
||||||
<div class="studio-template-groups">
|
|
||||||
<?php foreach (BlockTemplates::GROUPS as $group => [$category, $templates]): ?>
|
|
||||||
<section class="studio-template-group" data-template-group="<?= $e($group) ?>" aria-labelledby="studio-template-<?= $e($group) ?>">
|
|
||||||
<h3 id="studio-template-<?= $e($group) ?>"><?= $e($category) ?></h3>
|
|
||||||
<div class="studio-template-cards">
|
|
||||||
<?php foreach ($templates as $preset => [$label, $markup]): ?>
|
|
||||||
<article class="studio-template-card" data-template-card data-template-search-text="<?= $e($label . ' ' . $category . ' ' . $preset) ?>">
|
|
||||||
<button type="button" class="studio-template-image" data-template-preview="<?= $e($preset) ?>" data-template-title="<?= $e($label) ?>"
|
|
||||||
aria-label="预览<?= $e($label) ?>模板">
|
|
||||||
<img src="/assets/template-previews/<?= $e($preset) ?>.webp" alt="" width="768" height="480" loading="lazy">
|
|
||||||
</button>
|
|
||||||
<div class="studio-template-meta">
|
|
||||||
<span><?= $e($label) ?></span>
|
|
||||||
<button type="button" class="button button-outline" disabled data-canvas-template="<?= $e($preset) ?>"
|
|
||||||
data-template-title="<?= $e($label) ?>" aria-label="添加<?= $e($label) ?>模板">添加</button>
|
|
||||||
</div>
|
|
||||||
<template data-preset="<?= $e($preset) ?>"><?= $markup ?></template>
|
|
||||||
</article>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</div>
|
</div>
|
||||||
|
<?php foreach (['modules' => BlockTemplates::GROUPS, 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
|
||||||
|
<?= View::fragment('studio-library-panel', compact('kind', 'groups')) ?>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<section role="tabpanel" id="studio-panel-layers" aria-labelledby="studio-tab-layers" data-library-panel="layers">
|
||||||
|
<?= $layers ?>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="studio-template-peek" data-template-peek aria-hidden="true" hidden>
|
<div class="studio-template-peek" data-template-peek aria-hidden="true" hidden>
|
||||||
<img alt="">
|
<img alt="">
|
||||||
<p></p>
|
<p></p>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::c
|
|||||||
Route::get('/articles', [SiteController::class, 'archive']);
|
Route::get('/articles', [SiteController::class, 'archive']);
|
||||||
Route::get('/articles/category/{category:[a-z0-9-]+}', [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/tag/{tag:[^/]+}', [SiteController::class, 'tagged']);
|
||||||
|
Route::get('/articles/feed/{slug:[a-z0-9-]+}/{key:[a-z0-9-]+}', [SiteController::class, 'feedArchive']);
|
||||||
Route::get('/articles/{slug:[a-z0-9-]+}', [SiteController::class, 'article']);
|
Route::get('/articles/{slug:[a-z0-9-]+}', [SiteController::class, 'article']);
|
||||||
Route::get('/main', static fn () => View::redirect('/articles', 301));
|
Route::get('/main', static fn () => View::redirect('/articles', 301));
|
||||||
Route::get('/main/category/{id:[0-9]+}.html', [SiteController::class, 'legacyCategory']);
|
Route::get('/main/category/{id:[0-9]+}.html', [SiteController::class, 'legacyCategory']);
|
||||||
|
|||||||
@@ -167,19 +167,29 @@
|
|||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: .5rem;
|
border-radius: .5rem;
|
||||||
}
|
}
|
||||||
.studio-template-filters { display: flex; gap: .3rem; flex-wrap: wrap; margin-block: .25rem; }
|
.studio-library-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .2rem; padding: .22rem; margin-bottom: .45rem; border-radius: .6rem; background: var(--paper); }
|
||||||
.studio-template-filters button {
|
.studio-library-tabs button, .studio-library-categories button, .studio-library-category-title button, .studio-element-items button {
|
||||||
min-height: 36px;
|
color: var(--ink); font-family: inherit; cursor: pointer;
|
||||||
padding: .2rem .5rem;
|
|
||||||
color: var(--muted);
|
|
||||||
font-size: .825rem;
|
|
||||||
border: 1px solid var(--line);
|
|
||||||
border-radius: .35rem;
|
|
||||||
background: var(--white);
|
|
||||||
}
|
}
|
||||||
.studio-template-filters button[aria-pressed="true"] { border-color: #9bb5fa; color: var(--accent-deep); background: var(--accent-light); }
|
.studio-library-tabs button { min-height: 2.4rem; padding: .3rem .18rem; border: 1px solid transparent; border-radius: .42rem; background: transparent; font-size: .84rem; }
|
||||||
.studio-template-group + .studio-template-group { margin-top: .9rem; }
|
.studio-library-tabs button[aria-selected="true"] { border-color: var(--line); background: var(--white); color: var(--accent-deep); font-weight: 650; box-shadow: 0 1px 2px #182e5110; }
|
||||||
.studio-template-group h3 { margin: 0 0 .4rem; font-size: .9rem; font-weight: 650; }
|
.studio-library-categories { list-style: none; padding: 0; margin: 0; }
|
||||||
|
.studio-library-categories li + li { border-top: 1px solid var(--line); }
|
||||||
|
.studio-library-categories button, .studio-element-items button {
|
||||||
|
display: flex; gap: .35rem; align-items: center; width: 100%; min-height: 2.65rem; padding: .4rem .32rem;
|
||||||
|
text-align: left; border: 1px solid transparent; border-radius: .35rem; background: transparent; font-size: .9rem;
|
||||||
|
}
|
||||||
|
.studio-library-categories button::after { content: ''; width: .38rem; height: .38rem; border: solid currentColor; border-width: 1px 1px 0 0; rotate: 45deg; margin-inline-end: .25rem; }
|
||||||
|
.studio-library-categories small { margin-inline-start: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
|
||||||
|
.studio-library-content { display: grid; gap: .55rem; min-width: 0; }
|
||||||
|
.studio-library-category-title { display: grid; gap: .28rem; }
|
||||||
|
.studio-library-category-title h3 { font-size: 1rem; margin: 0; }
|
||||||
|
.studio-library-category-title button { justify-self: start; min-height: 2.25rem; padding: .25rem .45rem; background: var(--white); border: 1px solid var(--line); border-radius: .38rem; font-size: .8rem; }
|
||||||
|
.studio-library-category-title button::before { content: '‹'; margin-inline-end: .3em; }
|
||||||
|
.studio-element-items { display: grid; gap: .35rem; }
|
||||||
|
.studio-element-items button { justify-content: space-between; padding-inline: .55rem; border-color: var(--line); background: var(--white); }
|
||||||
|
.studio-element-items button::after { content: '+'; color: var(--accent-deep); }
|
||||||
|
.studio-element-items button:disabled { opacity: .55; cursor: wait; }
|
||||||
.studio-template-cards { display: grid; gap: .48rem; }
|
.studio-template-cards { display: grid; gap: .48rem; }
|
||||||
.studio-template-card { min-width: 0; border: 1px solid var(--line); border-radius: .55rem; background: var(--white); }
|
.studio-template-card { min-width: 0; border: 1px solid var(--line); border-radius: .55rem; background: var(--white); }
|
||||||
.studio-template-card:focus-within { border-color: var(--accent); }
|
.studio-template-card:focus-within { border-color: var(--accent); }
|
||||||
@@ -213,7 +223,7 @@
|
|||||||
.studio-template-dialog > .actions { justify-content: flex-end; margin-top: .75rem; }
|
.studio-template-dialog > .actions { justify-content: flex-end; margin-top: .75rem; }
|
||||||
|
|
||||||
@media (max-width: 54rem) {
|
@media (max-width: 54rem) {
|
||||||
.studio-template-groups { max-height: 44dvh; overflow-y: auto; padding: .2rem; }
|
.studio-library-content { max-height: 55dvh; overflow-y: auto; padding: .2rem; }
|
||||||
.studio-template-cards { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
|
.studio-template-cards { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); }
|
||||||
.studio-template-meta { flex-wrap: wrap; }
|
.studio-template-meta { flex-wrap: wrap; }
|
||||||
.studio-template-peek { display: none; }
|
.studio-template-peek { display: none; }
|
||||||
@@ -234,3 +244,52 @@
|
|||||||
.article-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .45rem; }
|
.article-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .45rem; }
|
||||||
.article-editor-heading > .button { min-height: 2.1rem; padding: .25rem .6rem; }
|
.article-editor-heading > .button { min-height: 2.1rem; padding: .25rem .6rem; }
|
||||||
.article-editor-help:empty { display: none; }
|
.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; }
|
||||||
|
|
||||||
|
.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); }
|
||||||
|
.admin-utility { display: flex; gap: .8rem; align-items: center; font-size: .88rem; }
|
||||||
|
.admin-utility > a { padding-block: .55rem; white-space: nowrap; }
|
||||||
|
.admin-account { position: relative; z-index: 5; }
|
||||||
|
.admin-account summary {
|
||||||
|
min-height: 2.45rem; padding: .43rem .6rem; border: 1px solid var(--line);
|
||||||
|
border-radius: .45rem; color: var(--ink); cursor: pointer;
|
||||||
|
}
|
||||||
|
.admin-account-menu {
|
||||||
|
position: absolute; inset: calc(100% + .4rem) 0 auto auto; min-width: 8rem; padding: .3rem;
|
||||||
|
border: 1px solid var(--line); border-radius: .5rem; background: white; box-shadow: 0 .55rem 1.5rem #1d315026;
|
||||||
|
}
|
||||||
|
.admin-account-menu a, .admin-account-menu button {
|
||||||
|
display: block; width: 100%; padding: .52rem .65rem; border: 0; border-radius: .3rem; background: white;
|
||||||
|
color: var(--ink); text-align: left; text-decoration: none; font: inherit; cursor: pointer;
|
||||||
|
}
|
||||||
|
.admin-account-menu :is(a, button):hover { background: var(--paper); color: var(--accent-deep); }
|
||||||
|
.dashboard-heading { margin-bottom: 1.55rem; }
|
||||||
|
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 1.05rem; }
|
||||||
|
.dashboard-grid .admin-panel { padding: clamp(.95rem, 2.3vw, 1.55rem); }
|
||||||
|
.dashboard-filters { display: grid; grid-template-columns: 1fr minmax(6.8rem, 9rem); gap: .7rem; margin-bottom: .8rem; }
|
||||||
|
.dashboard-filters label { display: grid; min-width: 0; gap: .25rem; font-size: .83rem; color: var(--muted); }
|
||||||
|
.dashboard-filters :is(input, select) { width: 100%; min-height: 2.65rem; padding: .38rem .52rem; border: 1px solid var(--line); border-radius: .45rem; color: var(--ink); background: var(--white); font: inherit; }
|
||||||
|
.dashboard-page-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .55rem .85rem; }
|
||||||
|
.dashboard-page-label { min-width: 0; overflow-wrap: anywhere; }
|
||||||
|
.dashboard-page-state { padding: .15rem .48rem; border-radius: .35rem; background: var(--paper); color: var(--muted); font-size: .78rem; white-space: nowrap; }
|
||||||
|
.dashboard-page-state[data-published="true"] { background: #e9f6ef; color: #1b6744; }
|
||||||
|
.dashboard-page-actions { display: flex; align-items: center; gap: .55rem; white-space: nowrap; }
|
||||||
|
.dashboard-page-actions > a { font-size: .84rem; }
|
||||||
|
.dashboard-page-actions > .button { min-height: 2.25rem; padding: .28rem .55rem; }
|
||||||
|
.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; }
|
||||||
|
|
||||||
|
@media (max-width: 51rem) {
|
||||||
|
.dashboard-grid { grid-template-columns: 1fr; gap: 0; }
|
||||||
|
.admin-bar .admin-primary { order: 3; width: 100%; gap: .15rem .35rem; }
|
||||||
|
}
|
||||||
|
@media (max-width: 28rem) {
|
||||||
|
.dashboard-page-list li { grid-template-columns: minmax(0, 1fr) auto; }
|
||||||
|
.dashboard-page-actions { grid-column: 1 / -1; }
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,25 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jQuery(function ($) {
|
jQuery(function ($) {
|
||||||
|
$('[data-page-list]').each(function () {
|
||||||
|
const $panel = $(this);
|
||||||
|
const $search = $panel.find('[data-page-search]');
|
||||||
|
const $status = $panel.find('[data-page-status]');
|
||||||
|
const $pages = $panel.find('[data-page-item]');
|
||||||
|
$panel.find('[data-page-filters]').prop('hidden', false);
|
||||||
|
$search.add($status).on('input change', function () {
|
||||||
|
const query = $search.val().trim().toLowerCase();
|
||||||
|
const status = $status.val();
|
||||||
|
let count = 0;
|
||||||
|
$pages.each(function () {
|
||||||
|
const visible = (!status || this.dataset.pageItem === status) && this.dataset.pageLabel.toLowerCase().includes(query);
|
||||||
|
$(this).prop('hidden', !visible);
|
||||||
|
if (visible) count++;
|
||||||
|
});
|
||||||
|
$panel.find('[data-page-empty]').prop('hidden', count !== 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const formats = {
|
const formats = {
|
||||||
markdown: {
|
markdown: {
|
||||||
heading: ['## ', '', '小标题'],
|
heading: ['## ', '', '小标题'],
|
||||||
|
|||||||
@@ -647,3 +647,74 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.article-tabs button { padding: .38rem .8rem; background: white; border: 1px solid var(--line); border-radius: .45rem; color: inherit; cursor: pointer; }
|
.article-tabs button { padding: .38rem .8rem; background: white; border: 1px solid var(--line); border-radius: .45rem; color: inherit; cursor: pointer; }
|
||||||
.article-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
|
.article-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
|
||||||
.network-list .network-detail { min-height: 0; padding-block: .2rem; font-size: .85rem; }
|
.network-list .network-detail { min-height: 0; padding-block: .2rem; font-size: .85rem; }
|
||||||
|
|
||||||
|
.article-feed-archive { margin: 1rem 0 0; }
|
||||||
|
.studio-notice { padding: clamp(1rem, 3vw, 1.8rem); border-inline-start: 3px solid var(--accent); border-radius: .55rem; background: var(--accent-light); }
|
||||||
|
.studio-notice p, .studio-testimonials p:last-child, .studio-timeline li p:last-child { margin-bottom: 0; }
|
||||||
|
.studio-gallery, .studio-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
|
||||||
|
.studio-gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border: 1px solid var(--line); background: var(--paper); }
|
||||||
|
.studio-split video { width: 100%; aspect-ratio: 16 / 9; border-radius: .6rem; background: var(--navy); object-fit: contain; }
|
||||||
|
.studio-metrics { margin-block: 0 1rem; }
|
||||||
|
.studio-metrics div { padding: 1rem; border-block-start: 1px solid var(--line); }
|
||||||
|
.studio-metrics dd { margin: .4rem 0 0; color: var(--accent); font-size: clamp(1.65rem, 5vw, 3rem); font-weight: 700; }
|
||||||
|
.studio-testimonials blockquote { margin: 0; padding: 1.1rem 1.3rem; border: 1px solid var(--line); border-radius: .6rem; }
|
||||||
|
.studio-testimonials .studio-attribution { font-size: .88rem; color: var(--muted); }
|
||||||
|
.rich .studio-timeline { padding-inline-start: 1.4rem; border-inline-start: 1px solid var(--line); }
|
||||||
|
.studio-timeline li + li, .studio-checklist li + li { margin-top: .7rem; }
|
||||||
|
.studio-timeline li::marker, .studio-checklist li::marker { color: var(--accent); font-weight: 700; }
|
||||||
|
.studio-timeline h3 { font-size: 1.15rem; margin-bottom: .2rem; }
|
||||||
|
.rich .studio-resources { list-style: none; padding: 0; border-block-start: 1px solid var(--line); }
|
||||||
|
.studio-resources li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .35rem 1rem; padding: .7rem 0; border-block-end: 1px solid var(--line); }
|
||||||
|
.studio-resources span { font-size: .875rem; color: var(--muted); }
|
||||||
|
.studio-divider { width: 100%; margin-block: 1.25rem; border: 0; border-block-start: 1px solid var(--line); }
|
||||||
|
.studio-code { max-width: 100%; overflow: auto; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .5rem; background: var(--paper); }
|
||||||
|
@media (max-width: 36rem) {
|
||||||
|
.studio-gallery { grid-template-columns: 1fr; }
|
||||||
|
.studio-metrics { gap: .45rem; }
|
||||||
|
.studio-metrics div { padding: .55rem .3rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-align-left {
|
||||||
|
--studio-margin-left: 0; --studio-margin-right: auto; --studio-justify: start;
|
||||||
|
text-align: left; justify-self: start;
|
||||||
|
}
|
||||||
|
.studio-align-center {
|
||||||
|
--studio-margin-left: auto; --studio-margin-right: auto; --studio-justify: center;
|
||||||
|
text-align: center; justify-self: center;
|
||||||
|
}
|
||||||
|
.studio-align-right {
|
||||||
|
--studio-margin-left: auto; --studio-margin-right: 0; --studio-justify: end;
|
||||||
|
text-align: right; justify-self: end;
|
||||||
|
}
|
||||||
|
:is(.hero-lead, .section-heading > p, .rich > p)[class*="studio-align-"] {
|
||||||
|
margin-left: var(--studio-margin-left);
|
||||||
|
margin-right: var(--studio-margin-right);
|
||||||
|
}
|
||||||
|
.rich > p:is(.studio-align-left, .studio-align-center, .studio-align-right) { max-width: 47rem; }
|
||||||
|
:is(.rich, .editor-preview) :is(img, video, audio, a, ol, ul)[class*="studio-align-"] {
|
||||||
|
margin-left: var(--studio-margin-left);
|
||||||
|
margin-right: var(--studio-margin-right);
|
||||||
|
}
|
||||||
|
:is(.rich, .editor-preview) :is(img, video, audio)[class*="studio-align-"] { display: block; max-width: 100%; }
|
||||||
|
:is(.rich, .editor-preview) a[class*="studio-align-"] { display: flex; width: fit-content; max-width: 100%; }
|
||||||
|
:is(.rich, .editor-preview) :is(ol, ul)[class*="studio-align-"] { width: fit-content; max-width: 100%; }
|
||||||
|
.rich > img[class*="studio-align-"]:not([class*="studio-media-"]) { max-width: min(100%, 46rem); }
|
||||||
|
.rich table[class*="studio-align-"] :is(th, td) { text-align: inherit; }
|
||||||
|
.hero-visual[class*="studio-align-"] { justify-self: var(--studio-justify); }
|
||||||
|
.hero-actions[class*="studio-align-"] { justify-content: var(--studio-justify); }
|
||||||
|
|
||||||
|
.studio-lead { font-size: 1.2rem; color: var(--ink); }
|
||||||
|
.studio-definitions { margin: 0; }
|
||||||
|
.studio-definitions dt { font-weight: 650; }
|
||||||
|
.studio-definitions dd { margin: .2rem 0 .8rem; color: var(--muted); }
|
||||||
|
.studio-definitions dd:last-child { margin-bottom: 0; }
|
||||||
|
.studio-spacer { height: clamp(1.5rem, 4vw, 4rem); }
|
||||||
|
[data-studio-editing] .studio-spacer { border: 1px dashed var(--line); }
|
||||||
|
.studio-banner-two, .studio-contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem 2rem; }
|
||||||
|
.studio-banner-two p, .studio-contact p { margin-bottom: 0; }
|
||||||
|
.studio-banner-two .actions { margin: 0; }
|
||||||
|
.studio-contact { border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 4vw, 2rem); }
|
||||||
|
.studio-releases article { padding: 1.05rem 0; border-block-start: 1px solid var(--line); }
|
||||||
|
.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; } }
|
||||||
|
|||||||
@@ -182,44 +182,82 @@ jQuery(function ($) {
|
|||||||
|
|
||||||
$('[data-canvas-presets]').each(function () {
|
$('[data-canvas-presets]').each(function () {
|
||||||
const $gallery = $(this);
|
const $gallery = $(this);
|
||||||
const $search = $gallery.find('[data-template-search]');
|
const $tabs = $gallery.find('[data-library-tab]');
|
||||||
const $groups = $gallery.find('[data-template-group]');
|
const $panels = $gallery.find('[data-library-panel]');
|
||||||
const $filters = $gallery.find('[data-template-filter]');
|
|
||||||
const $peek = $gallery.find('[data-template-peek]');
|
const $peek = $gallery.find('[data-template-peek]');
|
||||||
const $dialog = $gallery.find('[data-template-dialog]');
|
const $dialog = $gallery.find('[data-template-dialog]');
|
||||||
const $use = $dialog.find('[data-template-use]');
|
const $use = $dialog.find('[data-template-use]');
|
||||||
let category = '';
|
|
||||||
let $selection;
|
let $selection;
|
||||||
|
|
||||||
function hidePeek() {
|
function hidePeek() {
|
||||||
$peek.prop('hidden', true);
|
$peek.prop('hidden', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter() {
|
function selectTab(kind, focus = false) {
|
||||||
const query = String($search.val()).trim().toLowerCase();
|
const $current = $tabs.filter((_, tab) => tab.dataset.libraryTab === kind);
|
||||||
let count = 0;
|
$tabs.attr({'aria-selected': 'false', tabindex: '-1'});
|
||||||
$groups.each(function () {
|
$current.attr({'aria-selected': 'true', tabindex: '0'});
|
||||||
const $group = $(this);
|
$panels.each(function () {
|
||||||
const allowed = !category || this.dataset.templateGroup === category;
|
$(this).prop('hidden', this.dataset.libraryPanel !== kind);
|
||||||
let groupCount = 0;
|
|
||||||
$group.find('[data-template-card]').each(function () {
|
|
||||||
const visible = allowed && this.dataset.templateSearchText.toLowerCase().includes(query);
|
|
||||||
$(this).prop('hidden', !visible);
|
|
||||||
if (visible) groupCount++;
|
|
||||||
});
|
|
||||||
$group.prop('hidden', groupCount === 0);
|
|
||||||
count += groupCount;
|
|
||||||
});
|
});
|
||||||
$gallery.find('[data-template-empty]').prop('hidden', count !== 0);
|
$gallery.closest('.studio-library').scrollTop(0);
|
||||||
|
hidePeek();
|
||||||
|
if (focus) $current.trigger('focus');
|
||||||
|
}
|
||||||
|
|
||||||
|
function filterItems($panel) {
|
||||||
|
const query = $panel.find('[data-template-search]').val().trim().toLowerCase();
|
||||||
|
let matches = 0;
|
||||||
|
$panel.find('[data-template-group]').filter((_, group) => !group.hidden).find('[data-library-item]').each(function () {
|
||||||
|
const visible = this.dataset.templateSearchText.toLowerCase().includes(query);
|
||||||
|
$(this).prop('hidden', !visible);
|
||||||
|
if (visible) matches++;
|
||||||
|
});
|
||||||
|
$panel.find('[data-template-empty]').prop('hidden', matches !== 0);
|
||||||
hidePeek();
|
hidePeek();
|
||||||
}
|
}
|
||||||
|
|
||||||
$search.on('input', filter);
|
$gallery.find('[data-library-tabs]').prop('hidden', false);
|
||||||
$filters.on('click', function () {
|
function openLayersFromHash() {
|
||||||
category = this.dataset.templateFilter;
|
if (window.location.hash !== '#blocks') return false;
|
||||||
$filters.attr('aria-pressed', 'false');
|
selectTab('layers');
|
||||||
$(this).attr('aria-pressed', 'true');
|
$gallery.find('#blocks').prop('open', true);
|
||||||
filter();
|
return true;
|
||||||
|
}
|
||||||
|
if (!openLayersFromHash()) selectTab('modules');
|
||||||
|
$(window).on('hashchange', openLayersFromHash);
|
||||||
|
$tabs.on('click', function () {
|
||||||
|
selectTab(this.dataset.libraryTab);
|
||||||
|
}).on('keydown', function (event) {
|
||||||
|
const index = $tabs.index(this);
|
||||||
|
const last = $tabs.length - 1;
|
||||||
|
const next = {Home: 0, End: last, ArrowLeft: index === 0 ? last : index - 1, ArrowRight: index === last ? 0 : index + 1}[event.key];
|
||||||
|
if (typeof next !== 'number') return;
|
||||||
|
event.preventDefault();
|
||||||
|
selectTab($tabs.get(next).dataset.libraryTab, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
$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-content]').prop('hidden', false);
|
||||||
|
$panel.find('[data-library-title]').text(this.dataset.libraryLabel);
|
||||||
|
$panel.find('[data-template-search]').val('');
|
||||||
|
const key = this.dataset.libraryCategory;
|
||||||
|
$panel.find('[data-template-group]').each(function () {
|
||||||
|
$(this).prop('hidden', this.dataset.templateGroup !== key);
|
||||||
|
});
|
||||||
|
filterItems($panel);
|
||||||
|
$panel.find('[data-library-back]').trigger('focus');
|
||||||
|
}).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);
|
||||||
|
hidePeek();
|
||||||
|
$($panel.data('categoryTrigger')).trigger('focus');
|
||||||
|
}).on('input', '[data-template-search]', function () {
|
||||||
|
filterItems($(this).closest('[data-library-panel]'));
|
||||||
});
|
});
|
||||||
|
|
||||||
$gallery.on('mouseenter focusin', '[data-template-preview]', function (event) {
|
$gallery.on('mouseenter focusin', '[data-template-preview]', function (event) {
|
||||||
@@ -265,7 +303,11 @@ jQuery(function ($) {
|
|||||||
const $settings = $layout.find('.studio-inspector');
|
const $settings = $layout.find('.studio-inspector');
|
||||||
const $sizing = $studio.find('[data-media-sizing]');
|
const $sizing = $studio.find('[data-media-sizing]');
|
||||||
const $elementTools = $studio.find('[data-element-tools]');
|
const $elementTools = $studio.find('[data-element-tools]');
|
||||||
|
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 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 bodyElements = 'a, article, blockquote, details, div, dl, dt, dd, figure, h1, h2, h3, h4, h5, h6, hr, li, ol, p, pre, table, ul';
|
||||||
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] img, [data-studio-part="body"] audio, [data-studio-part="body"] video';
|
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 $handle = $studio.find('[data-media-handle]');
|
||||||
@@ -328,7 +370,14 @@ jQuery(function ($) {
|
|||||||
function sectionChanges(withEdits = true) {
|
function sectionChanges(withEdits = true) {
|
||||||
return sections.flatMap(({key, version, fields, source, template}) => {
|
return sections.flatMap(({key, version, fields, source, template}) => {
|
||||||
const changes = {};
|
const changes = {};
|
||||||
for (const [field, {node, initial}] of Object.entries(fields)) {
|
const aligned = {};
|
||||||
|
let alignmentChanged = false;
|
||||||
|
for (const [field, {node, initial, initialAlignment}] of Object.entries(fields)) {
|
||||||
|
if (field !== 'body') {
|
||||||
|
const value = getAlignment(node);
|
||||||
|
if (value) aligned[field] = value;
|
||||||
|
if (value !== initialAlignment) alignmentChanged = true;
|
||||||
|
}
|
||||||
let value = field === 'body' ? node.innerHTML : node.textContent;
|
let value = field === 'body' ? node.innerHTML : node.textContent;
|
||||||
if (field === 'body' && node.contains(selectedElement)) {
|
if (field === 'body' && node.contains(selectedElement)) {
|
||||||
const copy = node.cloneNode(true);
|
const copy = node.cloneNode(true);
|
||||||
@@ -339,7 +388,8 @@ jQuery(function ($) {
|
|||||||
changes[field] = withEdits && field === 'body' && version !== null ? bodyEdits(source, value) : value;
|
changes[field] = withEdits && field === 'body' && version !== null ? bodyEdits(source, value) : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Object.keys(changes).length ? [{key, version, fields: changes, ...(template ? {template} : {})}] : [];
|
if (!Object.keys(changes).length && !alignmentChanged) return [];
|
||||||
|
return [{key, version, fields: changes, ...(alignmentChanged ? {alignments: aligned} : {}), ...(template ? {template} : {})}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +666,7 @@ jQuery(function ($) {
|
|||||||
} else {
|
} else {
|
||||||
configureText(node, label, part === 'lead');
|
configureText(node, label, part === 'lead');
|
||||||
}
|
}
|
||||||
fields[part] = {node, initial: body ? node.innerHTML : node.textContent};
|
fields[part] = {node, initial: body ? node.innerHTML : node.textContent, initialAlignment: body ? '' : getAlignment(node)};
|
||||||
}
|
}
|
||||||
const source = new TextDecoder('utf-8', {ignoreBOM: true}).decode(Uint8Array.from(
|
const source = new TextDecoder('utf-8', {ignoreBOM: true}).decode(Uint8Array.from(
|
||||||
atob(section.dataset.studioSource || ''), (byte) => byte.charCodeAt(0)
|
atob(section.dataset.studioSource || ''), (byte) => byte.charCodeAt(0)
|
||||||
@@ -662,11 +712,12 @@ jQuery(function ($) {
|
|||||||
const node = sizingTarget();
|
const node = sizingTarget();
|
||||||
if (node) {
|
if (node) {
|
||||||
const bounds = previewBounds(node);
|
const bounds = previewBounds(node);
|
||||||
|
const x = getAlignment(node) === 'right' ? bounds.left : bounds.right;
|
||||||
const y = (bounds.top + bounds.bottom) / 2;
|
const y = (bounds.top + bounds.bottom) / 2;
|
||||||
const visible = bounds.width > 0 && y >= 0 && y <= container.clientHeight
|
const visible = bounds.width > 0 && y >= 0 && y <= container.clientHeight
|
||||||
&& bounds.right > 0 && bounds.right <= container.clientWidth + 1;
|
&& x >= 0 && x <= container.clientWidth + 1;
|
||||||
$handle.prop('hidden', !mediaDrag && !visible);
|
$handle.prop('hidden', !mediaDrag && !visible);
|
||||||
$handle.css({left: Math.min(bounds.right, container.clientWidth - 11), top: y});
|
$handle.css({left: Math.max(11, Math.min(x, container.clientWidth - 11)), top: y});
|
||||||
} else {
|
} else {
|
||||||
$handle.prop('hidden', true);
|
$handle.prop('hidden', true);
|
||||||
}
|
}
|
||||||
@@ -706,6 +757,24 @@ jQuery(function ($) {
|
|||||||
return element !== body && body.contains(element) ? element : null;
|
return element !== body && body.contains(element) ? element : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAlignment(node) {
|
||||||
|
return alignments.find((value) => node.classList.contains('studio-align-' + value)) || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function alignmentTarget(node) {
|
||||||
|
if (!node) return null;
|
||||||
|
const hero = node.closest('[data-studio-align-field]');
|
||||||
|
if (hero) return hero;
|
||||||
|
return node.matches('[data-studio-part="title"], [data-studio-part="lead"]') || node.closest('[data-studio-part="body"]')
|
||||||
|
? node : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncAlignmentButtons(target) {
|
||||||
|
$alignTools.prop('hidden', !target).find('[data-align]').each(function () {
|
||||||
|
$(this).attr('aria-pressed', String(Boolean(target) && getAlignment(target) === this.dataset.align));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function selectElement(node) {
|
function selectElement(node) {
|
||||||
selectionObserver?.disconnect();
|
selectionObserver?.disconnect();
|
||||||
selectedElement?.removeAttribute('data-studio-selected');
|
selectedElement?.removeAttribute('data-studio-selected');
|
||||||
@@ -719,10 +788,13 @@ jQuery(function ($) {
|
|||||||
const inBody = node.closest('[data-studio-part="body"]') !== null;
|
const inBody = node.closest('[data-studio-part="body"]') !== null;
|
||||||
const canCopy = inBody || (nav && $(node).siblings().length < 19);
|
const canCopy = inBody || (nav && $(node).siblings().length < 19);
|
||||||
const hasProperties = selectedMedia || node.matches('a');
|
const hasProperties = selectedMedia || node.matches('a');
|
||||||
|
const aligned = alignmentTarget(node);
|
||||||
|
syncAlignmentButtons(aligned);
|
||||||
$elementTools.find('[data-element-copy]').prop('hidden', !canCopy);
|
$elementTools.find('[data-element-copy]').prop('hidden', !canCopy);
|
||||||
|
$elementTools.find('[data-element-delete]').prop('hidden', !inBody && !selectedMedia && !node.matches(heroOrOptional));
|
||||||
$elementTools.find('[data-element-properties]').prop('hidden', !hasProperties);
|
$elementTools.find('[data-element-properties]').prop('hidden', !hasProperties);
|
||||||
if (target) showMediaWidth(currentMediaWidth(target));
|
if (target) showMediaWidth(currentMediaWidth(target));
|
||||||
selectionObserver?.observe(target || node);
|
selectionObserver?.observe(target || aligned || node);
|
||||||
}
|
}
|
||||||
positionSelection();
|
positionSelection();
|
||||||
}
|
}
|
||||||
@@ -760,7 +832,22 @@ jQuery(function ($) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$elementTools.on('click', '[data-element-copy]', () => changeElement(true))
|
$elementTools.on('click', '[data-align]', function () {
|
||||||
|
const target = alignmentTarget(selectedElement);
|
||||||
|
const alignment = this.dataset.align;
|
||||||
|
if (!target || !alignments.includes(alignment)) return;
|
||||||
|
target.classList.remove(...alignmentClasses);
|
||||||
|
target.classList.add('studio-align-' + alignment);
|
||||||
|
const field = target.dataset.studioAlignField;
|
||||||
|
if (field) {
|
||||||
|
const $value = pageInput('alignments');
|
||||||
|
const values = {...JSON.parse($value.val())};
|
||||||
|
values[field] = alignment;
|
||||||
|
$value.val(JSON.stringify(values));
|
||||||
|
}
|
||||||
|
syncAlignmentButtons(target);
|
||||||
|
positionSelection();
|
||||||
|
}).on('click', '[data-element-copy]', () => changeElement(true))
|
||||||
.on('click', '[data-element-delete]', () => changeElement(false))
|
.on('click', '[data-element-delete]', () => changeElement(false))
|
||||||
.on('click', '[data-element-properties]', () => {
|
.on('click', '[data-element-properties]', () => {
|
||||||
if (selectedMedia) replaceMedia();
|
if (selectedMedia) replaceMedia();
|
||||||
@@ -790,9 +877,10 @@ jQuery(function ($) {
|
|||||||
const narrow = node.getBoundingClientRect();
|
const narrow = node.getBoundingClientRect();
|
||||||
if (classes === null) node.removeAttribute('class');
|
if (classes === null) node.removeAttribute('class');
|
||||||
else node.setAttribute('class', classes);
|
else node.setAttribute('class', classes);
|
||||||
const rightEdgeTravel = (full.right - narrow.right) / .9;
|
const fromLeft = getAlignment(node) === 'right';
|
||||||
const available = rightEdgeTravel > full.width * .15 ? rightEdgeTravel : full.width;
|
const edgeTravel = (fromLeft ? narrow.left - full.left : full.right - narrow.right) / .9;
|
||||||
return {available, initialWidth: width || Math.round(100 * natural / (full.width || natural || 1))};
|
const available = edgeTravel > full.width * .15 ? edgeTravel : full.width;
|
||||||
|
return {available, fromLeft, initialWidth: width || Math.round(100 * natural / (full.width || natural || 1))};
|
||||||
}
|
}
|
||||||
|
|
||||||
function resizeMedia(width) {
|
function resizeMedia(width) {
|
||||||
@@ -817,7 +905,8 @@ jQuery(function ($) {
|
|||||||
if (!mediaDrag || mediaDrag.id !== pointer.pointerId || !mediaDrag.available) return;
|
if (!mediaDrag || mediaDrag.id !== pointer.pointerId || !mediaDrag.available) return;
|
||||||
if (pointer.clientX !== mediaDrag.x || mediaDrag.moved) {
|
if (pointer.clientX !== mediaDrag.x || mediaDrag.moved) {
|
||||||
mediaDrag.moved = true;
|
mediaDrag.moved = true;
|
||||||
resizeMedia(mediaDrag.initialWidth + 100 * (pointer.clientX - mediaDrag.x) / (mediaDrag.available * mediaDrag.scale));
|
const distance = (pointer.clientX - mediaDrag.x) * (mediaDrag.fromLeft ? -1 : 1);
|
||||||
|
resizeMedia(mediaDrag.initialWidth + 100 * distance / (mediaDrag.available * mediaDrag.scale));
|
||||||
}
|
}
|
||||||
}).on('lostpointercapture', () => {
|
}).on('lostpointercapture', () => {
|
||||||
mediaDrag = null;
|
mediaDrag = null;
|
||||||
@@ -836,7 +925,44 @@ jQuery(function ($) {
|
|||||||
$layout.on('click', '[data-hero-control]', function () {
|
$layout.on('click', '[data-hero-control]', function () {
|
||||||
heroControls.get(this.dataset.heroControl)?.();
|
heroControls.get(this.dataset.heroControl)?.();
|
||||||
});
|
});
|
||||||
$presets.on('mousedown', '[data-canvas-template]', (event) => event.preventDefault());
|
function insertInBody(markup, body, range) {
|
||||||
|
if (!body.isConnected) return;
|
||||||
|
const insertion = doc.createRange();
|
||||||
|
// Insert between blocks so the browser doesn't split a paragraph or duplicate its ID.
|
||||||
|
let node = range?.endContainer;
|
||||||
|
if (!node || !body.contains(node)) {
|
||||||
|
insertion.selectNodeContents(body);
|
||||||
|
insertion.collapse(false);
|
||||||
|
} else if (node === body) {
|
||||||
|
insertion.setStart(body, range.endOffset);
|
||||||
|
} else {
|
||||||
|
while (node.parentNode !== body) node = node.parentNode;
|
||||||
|
insertion.setStartAfter(node);
|
||||||
|
}
|
||||||
|
editBody(body, insertion, 'insertHTML', markup);
|
||||||
|
}
|
||||||
|
|
||||||
|
$presets.on('mousedown', '[data-canvas-template], [data-canvas-element]', (event) => event.preventDefault());
|
||||||
|
$presets.on('click', '[data-canvas-element]', function () {
|
||||||
|
const $status = $presets.find('[data-element-status]');
|
||||||
|
const body = activeBody;
|
||||||
|
const range = savedRange?.cloneRange();
|
||||||
|
if (!body) {
|
||||||
|
$status.text('请先在画布中选中要插入的正文。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const add = (markup) => {
|
||||||
|
if (!markup) return;
|
||||||
|
insertInBody(markup, body, range);
|
||||||
|
selectElement(null);
|
||||||
|
$status.text('已插入' + $(this).text() + '。');
|
||||||
|
};
|
||||||
|
if (this.dataset.elementMime) {
|
||||||
|
openPicker(this.dataset.elementMime, (file) => add(mediaMarkup(file)));
|
||||||
|
} else {
|
||||||
|
add($presets.find('template[data-element="' + this.dataset.canvasElement + '"]').get(0).innerHTML);
|
||||||
|
}
|
||||||
|
});
|
||||||
$presets.on('click', '[data-canvas-template]', function () {
|
$presets.on('click', '[data-canvas-template]', function () {
|
||||||
const markup = $presets.find('template[data-preset="' + this.dataset.canvasTemplate + '"]').get(0).innerHTML;
|
const markup = $presets.find('template[data-preset="' + this.dataset.canvasTemplate + '"]').get(0).innerHTML;
|
||||||
const template = this.dataset.canvasTemplate;
|
const template = this.dataset.canvasTemplate;
|
||||||
@@ -849,10 +975,8 @@ jQuery(function ($) {
|
|||||||
$templateStatus.text('先在画布中选择要插入的区块正文。');
|
$templateStatus.text('先在画布中选择要插入的区块正文。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Insert at the saved caret without replacing any selected text.
|
insertInBody(markup, activeBody, savedRange);
|
||||||
const insertion = savedRange?.cloneRange();
|
selectElement(null);
|
||||||
insertion?.collapse(false);
|
|
||||||
editBody(activeBody, insertion, 'insertHTML', markup);
|
|
||||||
$templateStatus.text('已插入当前正文。');
|
$templateStatus.text('已插入当前正文。');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -920,8 +1044,8 @@ jQuery(function ($) {
|
|||||||
});
|
});
|
||||||
$doc.on('click.canvas', (event) => {
|
$doc.on('click.canvas', (event) => {
|
||||||
const node = event.target;
|
const node = event.target;
|
||||||
const optional = node.closest?.(heroOrOptional);
|
const field = node.closest?.(canvasFields);
|
||||||
selectElement(doc.getSelection()?.isCollapsed ? optional || editableBodyElement(node) : null);
|
selectElement(doc.getSelection()?.isCollapsed ? field || editableBodyElement(node) : null);
|
||||||
});
|
});
|
||||||
$doc.on('dblclick.canvas', '[data-studio-part="body"] a', function (event) {
|
$doc.on('dblclick.canvas', '[data-studio-part="body"] a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -950,7 +1074,7 @@ jQuery(function ($) {
|
|||||||
});
|
});
|
||||||
$toolbar.prop('hidden', false);
|
$toolbar.prop('hidden', false);
|
||||||
$layout.find('[data-canvas-jump]').prop('hidden', false);
|
$layout.find('[data-canvas-jump]').prop('hidden', false);
|
||||||
$layout.find('[data-canvas-template], [data-hero-control]').prop('disabled', false);
|
$layout.find('[data-canvas-template], [data-canvas-element], [data-hero-control]').prop('disabled', false);
|
||||||
$presets.triggerHandler('studio:canvas-ready');
|
$presets.triggerHandler('studio:canvas-ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 5.2 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 11 KiB |
@@ -13,6 +13,7 @@ CREATE TABLE IF NOT EXISTS pages (
|
|||||||
image TEXT NOT NULL,
|
image TEXT NOT NULL,
|
||||||
alt TEXT NOT NULL,
|
alt TEXT NOT NULL,
|
||||||
image_scale INTEGER NOT NULL DEFAULT 0,
|
image_scale INTEGER NOT NULL DEFAULT 0,
|
||||||
|
alignments TEXT NOT NULL DEFAULT '{}',
|
||||||
actions TEXT NOT NULL,
|
actions TEXT NOT NULL,
|
||||||
quicklinks TEXT NOT NULL,
|
quicklinks TEXT NOT NULL,
|
||||||
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
|
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
|
||||||
@@ -26,6 +27,7 @@ CREATE TABLE IF NOT EXISTS sections (
|
|||||||
lead TEXT NOT NULL,
|
lead TEXT NOT NULL,
|
||||||
style TEXT NOT NULL DEFAULT 'plain',
|
style TEXT NOT NULL DEFAULT 'plain',
|
||||||
feed TEXT,
|
feed TEXT,
|
||||||
|
alignments TEXT NOT NULL DEFAULT '{}',
|
||||||
body TEXT NOT NULL,
|
body TEXT NOT NULL,
|
||||||
position INTEGER NOT NULL,
|
position INTEGER NOT NULL,
|
||||||
version INTEGER NOT NULL DEFAULT 0,
|
version INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
"title": "来笙动态",
|
"title": "来笙动态",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"style": "plain",
|
"style": "plain",
|
||||||
"body": "<p><a class=\"back-link\" href=\"/articles\">查看全部动态</a></p>",
|
"body": "",
|
||||||
"feed": {
|
"feed": {
|
||||||
"categories": [
|
"categories": [
|
||||||
"announcement",
|
"announcement",
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
use App\Content\Database;
|
||||||
|
|
||||||
|
// 输出目录类文章:slug<TAB>卡片网址<TAB>是否已发布
|
||||||
|
$pdo = Database::connect();
|
||||||
|
$query = $pdo->query("SELECT a.slug, a.card, a.status FROM articles a
|
||||||
|
WHERE EXISTS (SELECT 1 FROM article_category_links l WHERE l.article_id = a.id
|
||||||
|
AND l.category_slug IN ('services', 'supported-projects', 'partners'))
|
||||||
|
ORDER BY a.id");
|
||||||
|
foreach ($query as $row) {
|
||||||
|
$card = json_decode($row['card'], true) ?: [];
|
||||||
|
echo $row['slug'], '|', $card['url'] ?? '', '|', $row['status'], "\n";
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# 目录页(/services、/network)的卡片链接必须指向卡片配置的网址,而不是 /articles/<slug>
|
||||||
|
set -u
|
||||||
|
cd "$(dirname "$0")/.." || exit 1
|
||||||
|
BASE=http://127.0.0.1:8787
|
||||||
|
PASS=0; FAIL=0
|
||||||
|
ok(){ PASS=$((PASS+1)); printf ' ok %s\n' "$1"; }
|
||||||
|
no(){ FAIL=$((FAIL+1)); printf ' FAIL %s -> %s\n' "$1" "${2:-}"; }
|
||||||
|
|
||||||
|
SERVICES=$(curl -s "$BASE/services")
|
||||||
|
NETWORK=$(curl -s "$BASE/network")
|
||||||
|
ROWS=$(php tests/dircheck.php)
|
||||||
|
|
||||||
|
echo "== /services 卡片链接 =="
|
||||||
|
while IFS='|' read -r slug url status; do
|
||||||
|
[ -z "$slug" ] && continue
|
||||||
|
[ -z "$url" ] && continue
|
||||||
|
if echo "$SERVICES" | grep -q "href=\"$url\""; then ok "$slug 标题/按钮指向 $url"; else no "$slug 未指向 $url"; fi
|
||||||
|
if echo "$SERVICES" | grep -q "href=\"/articles/$slug\""; then no "$slug 仍出现 /articles/$slug"; else ok "$slug 不再指向文章页"; fi
|
||||||
|
done <<< "$(echo "$ROWS" | grep -E '^service-')"
|
||||||
|
|
||||||
|
echo "== /network 卡片链接 =="
|
||||||
|
while IFS='|' read -r slug url status; do
|
||||||
|
[ -z "$slug" ] && continue
|
||||||
|
[ -z "$url" ] && continue
|
||||||
|
if echo "$NETWORK" | grep -q "href=\"$url\""; then ok "$slug 指向 $url"; else no "$slug 未指向 $url"; fi
|
||||||
|
if echo "$NETWORK" | grep -q "href=\"/articles/$slug\""; then no "$slug 仍出现 /articles/$slug"; else ok "$slug 不再指向文章页"; fi
|
||||||
|
done <<< "$(echo "$ROWS" | grep -E '^network-')"
|
||||||
|
|
||||||
|
echo "== 标题链接与按钮链接一致性 =="
|
||||||
|
python3 - "$BASE" <<'PY'
|
||||||
|
import re, sys, html, urllib.request
|
||||||
|
base = sys.argv[1]
|
||||||
|
def get(path):
|
||||||
|
return urllib.request.urlopen(base + path, timeout=10).read().decode()
|
||||||
|
page = get('/services')
|
||||||
|
cards = re.findall(r'<article class="catalog-card">.*?</article>', page, re.S)
|
||||||
|
bad = 0
|
||||||
|
for card in cards:
|
||||||
|
links = re.findall(r'<a[^>]*href="([^"]+)"', card)
|
||||||
|
title = re.search(r'<h2><a href="([^"]+)"', card)
|
||||||
|
if not title:
|
||||||
|
print(' FAIL 卡片缺标题链接'); bad += 1; continue
|
||||||
|
primary = [l for l in links if not l.startswith('/articles/')]
|
||||||
|
if primary and title.group(1) != primary[0]:
|
||||||
|
print(' FAIL 标题 href=%s 与主按钮 href=%s 不一致' % (title.group(1), primary[0])); bad += 1
|
||||||
|
print(' ok %d 张卡片标题与主按钮一致' % (len(cards) - bad) if bad == 0 else ' 共 %d 张卡片,%d 张不一致' % (len(cards), bad))
|
||||||
|
sys.exit(0 if bad == 0 else 1)
|
||||||
|
PY
|
||||||
|
[ $? -eq 0 ] && ok "标题与按钮目标一致" || no "标题与主按钮目标不一致"
|
||||||
|
|
||||||
|
echo "== 参考信息:目录条目在文章流中的可见性(不判定) =="
|
||||||
|
PUB=$(echo "$ROWS" | awk -F'|' '$3 == "published" {print $1}')
|
||||||
|
N=0
|
||||||
|
for slug in $PUB; do
|
||||||
|
if curl -s "$BASE/articles" | grep -q "href=\"/articles/$slug\""; then N=$((N+1)); fi
|
||||||
|
done
|
||||||
|
echo " /articles 列表中出现的目录条目: $N / $(echo "$PUB" | wc -l)"
|
||||||
|
M=0
|
||||||
|
for slug in $PUB; do
|
||||||
|
if curl -s "$BASE/sitemap.xml" | grep -q "/articles/$slug"; then M=$((M+1)); fi
|
||||||
|
done
|
||||||
|
echo " sitemap 中的目录条目: $M / $(echo "$PUB" | wc -l)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "== 结果: $PASS 通过, $FAIL 失败 =="
|
||||||
|
[ $FAIL -eq 0 ] || exit 1
|
||||||
@@ -33,6 +33,18 @@ async function run(browser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await post('/admin/new-page', {slug, name: '画布测试页'});
|
await post('/admin/new-page', {slug, name: '画布测试页'});
|
||||||
|
await page.goto('/admin');
|
||||||
|
const dashboard = page.locator('[data-page-list]');
|
||||||
|
await dashboard.locator('[data-page-search]').fill(slug);
|
||||||
|
assert.equal(await dashboard.locator('[data-page-item]:visible').count(), 1);
|
||||||
|
const draft = dashboard.locator('[data-page-item]:visible');
|
||||||
|
assert.equal(await draft.getAttribute('data-page-item'), 'draft');
|
||||||
|
assert.equal(await draft.getByRole('link', {name: '预览'}).getAttribute('href'), '/admin/pages/' + slug + '/preview');
|
||||||
|
await dashboard.locator('[data-page-status]').selectOption('published');
|
||||||
|
await dashboard.locator('[data-page-empty]').waitFor({state: 'visible'});
|
||||||
|
await dashboard.locator('[data-page-status]').selectOption('draft');
|
||||||
|
assert.equal(await dashboard.locator('[data-page-item]:visible').count(), 1);
|
||||||
|
assert.equal(await page.getByRole('navigation', {name: '后台导航'}).getByRole('link', {name: '页面'}).getAttribute('aria-current'), 'page');
|
||||||
await post('/admin/page-blocks/' + slug, {operation: 'create', key: 'fixtures', preset: 'text'});
|
await post('/admin/page-blocks/' + slug, {operation: 'create', key: 'fixtures', preset: 'text'});
|
||||||
await post('/admin/pages/' + slug + '/fixtures', {
|
await post('/admin/pages/' + slug + '/fixtures', {
|
||||||
version: '0', title: '媒体和链接', lead: '', style: 'plain',
|
version: '0', title: '媒体和链接', lead: '', style: 'plain',
|
||||||
@@ -54,6 +66,8 @@ async function run(browser) {
|
|||||||
const frame = page.frameLocator('iframe[title="可编辑页面画布"]');
|
const frame = page.frameLocator('iframe[title="可编辑页面画布"]');
|
||||||
const sizing = page.locator('[data-media-sizing]');
|
const sizing = page.locator('[data-media-sizing]');
|
||||||
const properties = page.locator('[data-canvas-properties]');
|
const properties = page.locator('[data-canvas-properties]');
|
||||||
|
const tools = page.getByRole('group', {name: '所选元素'});
|
||||||
|
const align = (label) => tools.getByRole('button', {name: label, exact: true}).click();
|
||||||
const closeProperties = () => properties.locator('[data-property-close]').click();
|
const closeProperties = () => properties.locator('[data-property-close]').click();
|
||||||
|
|
||||||
const image = frame.locator('#fixtures img');
|
const image = frame.locator('#fixtures img');
|
||||||
@@ -77,6 +91,18 @@ async function run(browser) {
|
|||||||
await properties.locator('[name=url]').fill('/assets/original/home-hero.webp');
|
await properties.locator('[name=url]').fill('/assets/original/home-hero.webp');
|
||||||
await properties.locator('button[type=submit]').click();
|
await properties.locator('button[type=submit]').click();
|
||||||
assert.equal(await image.getAttribute('src'), '/assets/original/home-hero.webp');
|
assert.equal(await image.getAttribute('src'), '/assets/original/home-hero.webp');
|
||||||
|
await image.click();
|
||||||
|
await align('居右');
|
||||||
|
const rightEdge = await image.boundingBox();
|
||||||
|
const leftHandle = await handle.boundingBox();
|
||||||
|
assert(Math.abs(rightEdge.x - (leftHandle.x + leftHandle.width / 2)) < 2);
|
||||||
|
await align('居中');
|
||||||
|
const centeredImage = await image.evaluate((node) => {
|
||||||
|
const bounds = node.getBoundingClientRect();
|
||||||
|
const parent = node.parentElement.getBoundingClientRect();
|
||||||
|
return Math.abs((bounds.left + bounds.right) / 2 - (parent.left + parent.right) / 2) < 2;
|
||||||
|
});
|
||||||
|
assert(centeredImage);
|
||||||
|
|
||||||
const hero = frame.locator('[data-studio-hero-image]');
|
const hero = frame.locator('[data-studio-hero-image]');
|
||||||
await page.locator('iframe[title="可编辑页面画布"]').evaluate((iframe) => iframe.contentWindow.scrollTo(0, 0));
|
await page.locator('iframe[title="可编辑页面画布"]').evaluate((iframe) => iframe.contentWindow.scrollTo(0, 0));
|
||||||
@@ -88,8 +114,11 @@ async function run(browser) {
|
|||||||
await sizing.locator('[data-replace-media]').click();
|
await sizing.locator('[data-replace-media]').click();
|
||||||
assert.equal(await properties.locator('h2').textContent(), '首屏图片');
|
assert.equal(await properties.locator('h2').textContent(), '首屏图片');
|
||||||
await closeProperties();
|
await closeProperties();
|
||||||
|
const heroTitle = frame.locator('[data-studio-field=heading]');
|
||||||
|
await heroTitle.click();
|
||||||
|
await align('居右');
|
||||||
|
assert.equal(await heroTitle.evaluate((node) => getComputedStyle(node.parentElement).textAlign), 'right');
|
||||||
|
|
||||||
const tools = page.getByRole('group', {name: '所选元素'});
|
|
||||||
await frame.locator('#fixtures a').click();
|
await frame.locator('#fixtures a').click();
|
||||||
await tools.getByRole('button', {name: '属性'}).click();
|
await tools.getByRole('button', {name: '属性'}).click();
|
||||||
await properties.waitFor({state: 'visible'});
|
await properties.waitFor({state: 'visible'});
|
||||||
@@ -108,6 +137,11 @@ async function run(browser) {
|
|||||||
|
|
||||||
const copyText = frame.locator('#fixtures').getByText('待复制段落', {exact: true});
|
const copyText = frame.locator('#fixtures').getByText('待复制段落', {exact: true});
|
||||||
await copyText.click();
|
await copyText.click();
|
||||||
|
await align('居中');
|
||||||
|
await align('居左');
|
||||||
|
assert.equal(await copyText.evaluate((node) => getComputedStyle(node).textAlign), 'left');
|
||||||
|
await align('居右');
|
||||||
|
assert.equal(await copyText.evaluate((node) => getComputedStyle(node).textAlign), 'right');
|
||||||
await tools.getByRole('button', {name: '复制'}).click();
|
await tools.getByRole('button', {name: '复制'}).click();
|
||||||
assert.equal(await copyText.count(), 2);
|
assert.equal(await copyText.count(), 2);
|
||||||
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
||||||
@@ -119,17 +153,47 @@ async function run(browser) {
|
|||||||
await tools.getByRole('button', {name: '删除'}).click();
|
await tools.getByRole('button', {name: '删除'}).click();
|
||||||
assert.equal(await page.locator('[name=lead]').inputValue(), '');
|
assert.equal(await page.locator('[name=lead]').inputValue(), '');
|
||||||
|
|
||||||
|
const sectionTitle = frame.locator('#fixtures [data-studio-part=title]');
|
||||||
|
await sectionTitle.click();
|
||||||
|
await align('居中');
|
||||||
|
assert.equal(await sectionTitle.evaluate((node) => getComputedStyle(node).textAlign), 'center');
|
||||||
|
|
||||||
const gallery = page.locator('[data-canvas-presets]');
|
const gallery = page.locator('[data-canvas-presets]');
|
||||||
assert.equal(await gallery.locator('[data-template-group]').count(), 6);
|
const modules = gallery.locator('[data-library-panel=modules]');
|
||||||
assert.equal(await gallery.locator('[data-template-card]').count(), 14);
|
const elements = gallery.locator('[data-library-panel=elements]');
|
||||||
const brokenPreviews = await gallery.locator('[data-template-card] img').evaluateAll(async (images) => {
|
const moduleTab = gallery.getByRole('tab', {name: '组件'});
|
||||||
|
const elementTab = gallery.getByRole('tab', {name: '元素'});
|
||||||
|
const backToModules = () => modules.getByRole('button', {name: '返回分类'}).click();
|
||||||
|
const openModule = (key) => modules.locator('[data-library-category="' + key + '"]').click();
|
||||||
|
assert.equal(await modules.locator('[data-library-category]:visible').count(), 7);
|
||||||
|
assert.equal(await modules.locator('[data-template-card]:visible').count(), 0);
|
||||||
|
assert.equal(await modules.locator('[data-template-card]').count(), 26);
|
||||||
|
|
||||||
|
await copyText.first().click();
|
||||||
|
await moduleTab.press('ArrowRight');
|
||||||
|
assert.equal(await elementTab.getAttribute('aria-selected'), 'true');
|
||||||
|
assert.equal(await elements.locator('[data-library-category]:visible').count(), 4);
|
||||||
|
assert.equal(await elements.locator('[data-canvas-element]:visible').count(), 0);
|
||||||
|
const structural = elements.locator('[data-library-category=structure-elements]');
|
||||||
|
await structural.click();
|
||||||
|
assert.equal(await elements.locator('[data-library-category]:visible').count(), 0);
|
||||||
|
assert.equal(await elements.locator('[data-canvas-element]:visible').count(), 5);
|
||||||
|
await elements.getByRole('button', {name: '插入分割线'}).click();
|
||||||
|
await frame.locator('#fixtures .studio-divider').waitFor();
|
||||||
|
await elements.getByRole('button', {name: '插入留白'}).click();
|
||||||
|
await frame.locator('#fixtures .studio-spacer').waitFor();
|
||||||
|
await elements.getByRole('button', {name: '返回分类'}).click();
|
||||||
|
assert(await structural.evaluate((button) => button === document.activeElement));
|
||||||
|
await moduleTab.click();
|
||||||
|
|
||||||
|
const brokenPreviews = await modules.locator('[data-template-card] img').evaluateAll(async (images) => {
|
||||||
for (const image of images) image.loading = 'eager';
|
for (const image of images) image.loading = 'eager';
|
||||||
await Promise.all(images.map((image) => image.decode()));
|
await Promise.all(images.map((image) => image.decode()));
|
||||||
return images.filter((image) => image.naturalWidth !== 768).length;
|
return images.filter((image) => image.naturalWidth !== 768).length;
|
||||||
});
|
});
|
||||||
assert.equal(brokenPreviews, 0);
|
assert.equal(brokenPreviews, 0);
|
||||||
await gallery.locator('[data-template-filter=cover]').click();
|
await openModule('cover');
|
||||||
assert.equal(await gallery.locator('[data-template-card]:visible').count(), 2);
|
assert.equal(await modules.locator('[data-template-card]:visible').count(), 3);
|
||||||
const cover = gallery.locator('[data-template-preview=cover]');
|
const cover = gallery.locator('[data-template-preview=cover]');
|
||||||
await cover.hover();
|
await cover.hover();
|
||||||
const peek = gallery.locator('[data-template-peek]');
|
const peek = gallery.locator('[data-template-peek]');
|
||||||
@@ -143,14 +207,26 @@ async function run(browser) {
|
|||||||
await dialog.locator('[data-template-use]').click();
|
await dialog.locator('[data-template-use]').click();
|
||||||
await frame.locator('section[id^=block-] h2').filter({hasText: '图文封面'}).waitFor();
|
await frame.locator('section[id^=block-] h2').filter({hasText: '图文封面'}).waitFor();
|
||||||
|
|
||||||
await gallery.locator('[data-template-filter=""]').click();
|
await backToModules();
|
||||||
const search = gallery.locator('[data-template-search]');
|
await openModule('layout');
|
||||||
|
const search = modules.locator('[data-template-search]');
|
||||||
await search.fill('does-not-exist');
|
await search.fill('does-not-exist');
|
||||||
await gallery.locator('[data-template-empty]').waitFor({state: 'visible'});
|
await modules.locator('[data-template-empty]').waitFor({state: 'visible'});
|
||||||
await search.fill('双栏');
|
await search.fill('双栏');
|
||||||
assert.equal(await gallery.locator('[data-template-card]:visible').count(), 1);
|
assert.equal(await modules.locator('[data-template-card]:visible').count(), 1);
|
||||||
|
await search.fill('重点提示');
|
||||||
|
await modules.locator('[data-template-empty]').waitFor({state: 'visible'});
|
||||||
|
await backToModules();
|
||||||
|
await openModule('details');
|
||||||
|
await modules.locator('[data-canvas-template=pricing]').click();
|
||||||
|
await frame.locator('.studio-pricing').waitFor();
|
||||||
|
await backToModules();
|
||||||
|
await openModule('content');
|
||||||
|
await search.fill('重点提示');
|
||||||
|
await modules.locator('[data-canvas-template=notice]').click();
|
||||||
|
await frame.locator('.studio-notice').waitFor();
|
||||||
await search.fill('分类文章');
|
await search.fill('分类文章');
|
||||||
await gallery.locator('[data-canvas-template=articles]').click();
|
await modules.locator('[data-canvas-template=articles]').click();
|
||||||
await frame.locator('section[id^=block-] h2').filter({hasText: '分类文章'}).waitFor();
|
await frame.locator('section[id^=block-] h2').filter({hasText: '分类文章'}).waitFor();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@@ -161,7 +237,14 @@ async function run(browser) {
|
|||||||
await frame.locator('section[id^=block-] .studio-cover').waitFor();
|
await frame.locator('section[id^=block-] .studio-cover').waitFor();
|
||||||
assert.equal(await frame.locator('#fixtures a').getAttribute('href'), '/articles');
|
assert.equal(await frame.locator('#fixtures a').getAttribute('href'), '/articles');
|
||||||
assert.equal(await frame.locator('#fixtures img').getAttribute('src'), '/assets/original/home-hero.webp');
|
assert.equal(await frame.locator('#fixtures img').getAttribute('src'), '/assets/original/home-hero.webp');
|
||||||
assert.equal(await frame.locator('#fixtures img').getAttribute('class'), imageSize);
|
assert.deepEqual((await image.getAttribute('class')).split(/\s+/).sort(), [imageSize, 'studio-align-center'].sort());
|
||||||
|
assert.equal(await heroTitle.evaluate((node) => getComputedStyle(node.parentElement).textAlign), 'right');
|
||||||
|
assert.equal(await sectionTitle.evaluate((node) => getComputedStyle(node).textAlign), 'center');
|
||||||
|
assert.deepEqual(await copyText.evaluateAll((nodes) => nodes.map((node) => getComputedStyle(node).textAlign)), ['right', 'right']);
|
||||||
|
await frame.locator('.studio-notice').waitFor();
|
||||||
|
await frame.locator('#fixtures .studio-divider').waitFor();
|
||||||
|
await frame.locator('#fixtures .studio-spacer').waitFor();
|
||||||
|
await frame.locator('.studio-pricing').waitFor();
|
||||||
assert.match(await frame.locator('[data-visual]').getAttribute('class'), /studio-media-99/);
|
assert.match(await frame.locator('[data-visual]').getAttribute('class'), /studio-media-99/);
|
||||||
assert.equal(await copyText.count(), 2);
|
assert.equal(await copyText.count(), 2);
|
||||||
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
||||||
@@ -179,10 +262,13 @@ async function run(browser) {
|
|||||||
phonePage.on('pageerror', (error) => errors.push(error.message));
|
phonePage.on('pageerror', (error) => errors.push(error.message));
|
||||||
await phonePage.goto(editorPath);
|
await phonePage.goto(editorPath);
|
||||||
const phoneGallery = phonePage.locator('[data-canvas-presets]');
|
const phoneGallery = phonePage.locator('[data-canvas-presets]');
|
||||||
await phoneGallery.locator('[data-template-filter=cover]').tap();
|
await phoneGallery.locator('[data-library-category=cover]').tap();
|
||||||
await phoneGallery.locator('[data-template-preview=banner]').tap();
|
await phoneGallery.locator('[data-template-preview=banner]').tap();
|
||||||
await phoneGallery.locator('[data-template-dialog]').waitFor({state: 'visible'});
|
await phoneGallery.locator('[data-template-dialog]').waitFor({state: 'visible'});
|
||||||
assert.equal(await phoneGallery.locator('[data-template-dialog] h2').textContent(), '横幅');
|
assert.equal(await phoneGallery.locator('[data-template-dialog] h2').textContent(), '横幅');
|
||||||
|
await phonePage.goto(editorPath + '#blocks');
|
||||||
|
assert.equal(await phoneGallery.getByRole('tab', {name: '图层'}).getAttribute('aria-selected'), 'true');
|
||||||
|
assert(await phoneGallery.locator('#blocks').evaluate((details) => details.open));
|
||||||
await phone.close();
|
await phone.close();
|
||||||
await verifyArticleLibrary(browser, context, page, post, slug, feedId);
|
await verifyArticleLibrary(browser, context, page, post, slug, feedId);
|
||||||
assert.deepEqual(errors, []);
|
assert.deepEqual(errors, []);
|
||||||
@@ -190,7 +276,7 @@ async function run(browser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function verifyArticleLibrary(browser, context, page, post, slug, feedId) {
|
async function verifyArticleLibrary(browser, context, page, post, slug, feedId) {
|
||||||
const category = slug + '-category';
|
const category = String(Date.now());
|
||||||
await post('/admin/article-categories', {slug: category, name: '自定义测试分类'});
|
await post('/admin/article-categories', {slug: category, name: '自定义测试分类'});
|
||||||
const articleSlug = slug + '-article';
|
const articleSlug = slug + '-article';
|
||||||
await page.goto('/admin/articles/new');
|
await page.goto('/admin/articles/new');
|
||||||
@@ -202,6 +288,7 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
await page.locator('[name=title]').fill('测试 Markdown 和富文本');
|
await page.locator('[name=title]').fill('测试 Markdown 和富文本');
|
||||||
await page.locator('[name=slug]').fill(articleSlug);
|
await page.locator('[name=slug]').fill(articleSlug);
|
||||||
await page.locator('[name="categories[]"][value="' + category + '"]').check();
|
await page.locator('[name="categories[]"][value="' + category + '"]').check();
|
||||||
|
await page.locator('[name="categories[]"][value=product]').check();
|
||||||
await page.locator('[name=status]').selectOption('published');
|
await page.locator('[name=status]').selectOption('published');
|
||||||
await markdown.fill('**Markdown 分屏**');
|
await markdown.fill('**Markdown 分屏**');
|
||||||
await preview.locator('strong').getByText('Markdown 分屏').waitFor();
|
await preview.locator('strong').getByText('Markdown 分屏').waitFor();
|
||||||
@@ -211,7 +298,7 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
const publishedPath = '/articles/' + articleSlug;
|
const publishedPath = '/articles/' + articleSlug;
|
||||||
const sourcePage = await context.newPage();
|
const sourcePage = await context.newPage();
|
||||||
await sourcePage.goto(publishedPath);
|
await sourcePage.goto(publishedPath);
|
||||||
assert.equal(await sourcePage.locator('[itemprop=articleSection]').count(), 2);
|
assert.equal(await sourcePage.locator('[itemprop=articleSection]').count(), 3);
|
||||||
await sourcePage.locator('[itemprop=articleBody] strong').getByText('Markdown 分屏').waitFor();
|
await sourcePage.locator('[itemprop=articleBody] strong').getByText('Markdown 分屏').waitFor();
|
||||||
await page.goto(articleAdmin);
|
await page.goto(articleAdmin);
|
||||||
await editor.locator('.toastui-editor-mode-switch').getByText('所见即所得', {exact: true}).click();
|
await editor.locator('.toastui-editor-mode-switch').getByText('所见即所得', {exact: true}).click();
|
||||||
@@ -241,6 +328,7 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
await page.locator('[name="feed_categories[]"][value="' + category + '"]').check();
|
await page.locator('[name="feed_categories[]"][value="' + category + '"]').check();
|
||||||
await page.getByRole('button', {name: '保存区块'}).click();
|
await page.getByRole('button', {name: '保存区块'}).click();
|
||||||
await page.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
await page.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
||||||
|
assert(await page.locator('[name="feed_categories[]"][value="' + category + '"]').isChecked());
|
||||||
let contentVersion = await page.locator('[name=version]').inputValue();
|
let contentVersion = await page.locator('[name=version]').inputValue();
|
||||||
assert.equal(contentVersion, '1');
|
assert.equal(contentVersion, '1');
|
||||||
const canvasPath = '/admin/pages/' + slug + '/preview';
|
const canvasPath = '/admin/pages/' + slug + '/preview';
|
||||||
@@ -268,6 +356,7 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
assert.equal(await noJSPage.locator('#' + feedId + ' a[href="' + publishedPath + '"]:visible').count(), 2);
|
assert.equal(await noJSPage.locator('#' + feedId + ' a[href="' + publishedPath + '"]:visible').count(), 2);
|
||||||
await noJS.close();
|
await noJS.close();
|
||||||
assert((await context.request.get('/articles/category/' + category)).ok());
|
assert((await context.request.get('/articles/category/' + category)).ok());
|
||||||
|
await verifyScopedArchive(context, page, sourcePage, post, slug, feedId, category, publishedPath);
|
||||||
await sourcePage.goto('/services');
|
await sourcePage.goto('/services');
|
||||||
await sourcePage.locator('.catalog-card').first().waitFor();
|
await sourcePage.locator('.catalog-card').first().waitFor();
|
||||||
await sourcePage.goto('/network');
|
await sourcePage.goto('/network');
|
||||||
@@ -275,11 +364,61 @@ async function verifyArticleLibrary(browser, context, page, post, slug, feedId)
|
|||||||
await sourcePage.close();
|
await sourcePage.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function verifyScopedArchive(context, admin, page, post, slug, feedId, category, articlePath) {
|
||||||
|
const scope = '/articles/feed/' + slug + '/' + feedId;
|
||||||
|
const scopedResponse = (query = '') => context.request.get(scope + query);
|
||||||
|
assert.equal((await scopedResponse()).status(), 404);
|
||||||
|
await admin.goto('/admin/pages/' + slug);
|
||||||
|
await admin.locator('[name=description]').fill('公开文章区块筛选测试。');
|
||||||
|
await admin.locator('[name=status]').selectOption('published');
|
||||||
|
await admin.getByRole('button', {name: '保存页面', exact: true}).first().click();
|
||||||
|
await admin.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
||||||
|
|
||||||
|
const excluded = await post('/admin/articles/new', {
|
||||||
|
title: '分类范围外测试文章', slug: slug + '-excluded', body_format: 'markdown',
|
||||||
|
body: '只属于公告分类。', status: 'published', 'categories[]': 'announcement',
|
||||||
|
});
|
||||||
|
assert(excluded.redirect);
|
||||||
|
await page.goto('/' + slug);
|
||||||
|
const archiveLink = page.locator('#' + feedId).getByRole('link', {name: '查看全部动态'});
|
||||||
|
assert.equal(await archiveLink.getAttribute('href'), scope);
|
||||||
|
await archiveLink.click();
|
||||||
|
await page.waitForURL('**' + scope);
|
||||||
|
const list = page.locator('main .article-list');
|
||||||
|
assert.equal(await list.locator('a[href="' + articlePath + '"]').count(), 1);
|
||||||
|
assert.equal(await list.locator('a[href="/articles/' + slug + '-excluded"]').count(), 0);
|
||||||
|
assert.doesNotMatch(await list.locator('a[href="' + articlePath + '"] .article-category').textContent(), /产品/);
|
||||||
|
const filters = page.getByRole('navigation', {name: '动态分类'});
|
||||||
|
assert.deepEqual(await filters.getByRole('link').allTextContents(), ['全部', '新闻', '自定义测试分类']);
|
||||||
|
assert.equal((await scopedResponse('?category=announcement')).status(), 404);
|
||||||
|
assert.equal((await scopedResponse('?category[]=news')).status(), 404);
|
||||||
|
assert.equal((await scopedResponse('?categories=announcement')).status(), 200);
|
||||||
|
assert.doesNotMatch(await (await scopedResponse('?categories=announcement')).text(), /分类范围外测试文章/);
|
||||||
|
|
||||||
|
for (let index = 0; index < 21; index++) {
|
||||||
|
await post('/admin/articles/new', {
|
||||||
|
title: '分类分页样例 ' + index, slug: slug + '-sample-' + index, body_format: 'markdown',
|
||||||
|
body: '所选分类中的分页样例。', status: 'published', 'categories[]': category,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const categoryPath = scope + '?category=' + category;
|
||||||
|
await filters.getByRole('link', {name: '自定义测试分类'}).click();
|
||||||
|
await page.waitForURL('**' + categoryPath);
|
||||||
|
const next = page.getByRole('link', {name: '下一页'});
|
||||||
|
assert.equal(await next.getAttribute('href'), categoryPath + '&page=2');
|
||||||
|
await next.click();
|
||||||
|
await page.waitForURL('**' + categoryPath + '&page=2');
|
||||||
|
assert.equal(await list.locator('a').count(), 2);
|
||||||
|
assert.equal(await page.getByRole('link', {name: '上一页'}).getAttribute('href'), categoryPath);
|
||||||
|
assert.equal(await filters.getByRole('link', {name: '全部'}).getAttribute('href'), scope);
|
||||||
|
assert.equal(await page.getByRole('link', {name: '返回原页面'}).getAttribute('href'), '/' + slug + '#' + feedId);
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
||||||
try {
|
try {
|
||||||
await run(browser);
|
await run(browser);
|
||||||
console.log('Passed Chromium canvas media/link interactions, template gallery, persistence, and the article library.');
|
console.log('Passed Chromium dashboard, categorized library, canvas persistence, and scoped article archives.');
|
||||||
} finally {
|
} finally {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|||||||