Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4db9af6404 | ||
|
|
02e8685bc2 | ||
|
|
92354d7e4a | ||
|
|
828dfc09f9 | ||
|
|
904812fd95 | ||
|
|
d6fee652db | ||
|
|
abccb8c004 | ||
|
|
2cf63b61ba | ||
|
|
2b01537cf3 | ||
|
|
2ef38bd716 | ||
|
|
62c10b09bc | ||
|
|
935bc7f071 | ||
|
|
1a025353b2 | ||
|
|
ef1ff93904 | ||
|
|
74e0de84a6 | ||
|
|
9bc0ee0e45 | ||
|
|
a2fc628f08 | ||
|
|
a5b3408358 | ||
|
|
6efcdefadf | ||
|
|
d4548393d5 | ||
|
|
e7c7a8928e | ||
|
|
00d7d6f9ad | ||
|
|
faba214971 | ||
|
|
a910f03929 |
@@ -27,11 +27,15 @@ php bin/admin.php reset admin@example.com
|
|||||||
|
|
||||||
## 后台编辑
|
## 后台编辑
|
||||||
|
|
||||||
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。
|
- **网站后台**可按名称、地址或发布状态查找页面,从列表打开画布、公开页或草稿预览。
|
||||||
|
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。可在功能分类中复用产品图文、特性组、服务报价等内置模板,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。
|
||||||
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
||||||
- **产品与服务**在 `/services` 显示独立的服务端 HTML 目录。后台支持添加、排序、修改和移除条目,并设置分类、封面、简介和按钮链接。
|
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
|
||||||
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
- **普通页面**包括 `/services`、`/articles` 和 `/contact`。产品目录和分类文章模块的设置可在画布编辑。动态页默认显示公告、新闻和产品动态。
|
||||||
- **文章与动态**使用 Markdown,支持正文预览、摘要、标签和公告、新闻、产品分类。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。
|
||||||
|
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
||||||
|
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
||||||
|
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。编辑页底部可永久删除文章,重复安装也会保留删除结果。已发布文章改网址标识后,旧标识会自动跳转。
|
||||||
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
||||||
|
|
||||||
## 生产运行
|
## 生产运行
|
||||||
@@ -68,7 +72,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。迁移服务器或做线上备份时,可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"` 取得一致备份。更新代码时保留数据库文件及其存放目录,以同一 `LAYSENSE_DB` 执行 `php bin/install.php` 应用迁移,然后重启服务。已有数据库会补回 PAGEPAN 原始功能图标,保留已编辑的文案和已有图像。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份站点时一并保存 SQLite 和媒体目录。
|
SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。安装会补齐 `/services`、`/articles` 和 `/contact` 的页面记录,并一次性导入首页五联导航和伙伴动态模块。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
|
||||||
|
|
||||||
### CDN
|
### CDN
|
||||||
|
|
||||||
@@ -81,3 +85,15 @@ SQLite 已启用 WAL。迁移服务器或做线上备份时,可用 `sqlite3 st
|
|||||||
- 旧站 2024 年 11 月 10 日关于减少全球服务器部署的公告返回空白正文。迁移保留标题、日期、标签和旧链接,正文补录前会标记为不索引。
|
- 旧站 2024 年 11 月 10 日关于减少全球服务器部署的公告返回空白正文。迁移保留标题、日期、标签和旧链接,正文补录前会标记为不索引。
|
||||||
- SHNU 旧页首屏写 ¥69,详细报价表与正文写 ¥66。新版保留报价表中的 ¥66,并保留旧页学生资格及学分说明。两处普通软著页面的咨询按钮现在直达该页既有的企业微信入口。
|
- SHNU 旧页首屏写 ¥69,详细报价表与正文写 ¥66。新版保留报价表中的 ¥66,并保留旧页学生资格及学分说明。两处普通软著页面的咨询按钮现在直达该页既有的企业微信入口。
|
||||||
- 中文公开页复用页头、页尾、首屏、内容区块、动态列表及同一套 CSS。历史迁移内容见 `resources/seed.json`,结构见 `resources/schema.sql`。
|
- 中文公开页复用页头、页尾、首屏、内容区块、动态列表及同一套 CSS。历史迁移内容见 `resources/seed.json`,结构见 `resources/schema.sql`。
|
||||||
|
|
||||||
|
## 画布浏览器回归
|
||||||
|
|
||||||
|
`tests/studio-browser.cjs` 用 Playwright 在真实 Chromium 内检查媒体拖拽、链接、模板预览、编辑器、文章分类和公开页面。使用已启动的测试实例、独立的 SQLite 数据库和管理员账户。测试会在该库创建页面、分类和测试文章。
|
||||||
|
|
||||||
|
```sh
|
||||||
|
LAYSENSE_TEST_URL=http://127.0.0.1:8787 \
|
||||||
|
LAYSENSE_TEST_EMAIL=studio-test@example.com \
|
||||||
|
node tests/studio-browser.cjs
|
||||||
|
```
|
||||||
|
|
||||||
|
先安装 Playwright 和 Chromium,并在测试进程的环境里设置 `LAYSENSE_TEST_PASSWORD`。已安装在独立目录的 Playwright 可通过 `PLAYWRIGHT_MODULE` 指定模块路径。系统 Chromium 可通过 `CHROMIUM_EXECUTABLE` 指定。
|
||||||
|
|||||||
@@ -0,0 +1,164 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Content;
|
||||||
|
|
||||||
|
final class BlockTemplates
|
||||||
|
{
|
||||||
|
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
|
||||||
|
|
||||||
|
public const NETWORK_FEED = '{"categories":["supported-projects","partners"],"mode":"network","limit":30}';
|
||||||
|
|
||||||
|
public const CATALOG_FEED = '{"categories":["services"],"mode":"catalog","limit":30}';
|
||||||
|
|
||||||
|
public const PRODUCT_LINKS = '<div class="hero-directory"><a class="overline directory-label" href="/services">产品与服务</a><a href="/pagepan"><span>PAGEPAN</span><small>可视化建站</small></a><a href="/highspeaker"><span>HighSpeaker DNS</span><small>开源智能解析</small></a><a href="/sc"><span>软著代理</span><small>登记申请与材料服务</small></a><a href="/shnu-sc"><span>SHNU 学生</span><small>软著申请方案</small></a></div>';
|
||||||
|
|
||||||
|
public const ELEMENT_GROUPS = [
|
||||||
|
'text-elements' => ['文字与列表', [
|
||||||
|
'paragraph' => ['段落', '<p>填写正文。</p>'],
|
||||||
|
'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>'],
|
||||||
|
'heading-kicker' => ['标题眉标', '<p class="overline">填写分类名称</p>'],
|
||||||
|
'tag' => ['徽标', '<p><span class="studio-badge">填写标签</span></p>'],
|
||||||
|
'large-number' => ['重点数字', '<p class="price-value">填写数字</p>'],
|
||||||
|
'definition-list' => ['术语说明', '<dl class="studio-definitions"><dt>填写术语</dt><dd>填写术语说明。</dd></dl>'],
|
||||||
|
]],
|
||||||
|
'link-elements' => ['链接与按钮', [
|
||||||
|
'button' => ['主按钮', '<p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
||||||
|
'outline-button' => ['描边按钮', '<p><a class="button button-outline" href="/services">查看服务</a></p>'],
|
||||||
|
'text-link' => ['文字链接', '<p><a href="/articles">阅读文章</a></p>'],
|
||||||
|
'button-group' => ['按钮组', '<div class="actions studio-button-group"><a class="button button-primary" href="/services">查看服务</a><a class="button button-outline" href="#contact">联系团队</a></div>'],
|
||||||
|
'breadcrumbs' => ['面包屑', '<p class="breadcrumbs"><a href="/">首页</a><span> / </span><span>当前页面</span></p>'],
|
||||||
|
'download-link' => ['下载入口', '<p><a class="button button-outline" href="/pagepan#download">查看下载</a></p>'],
|
||||||
|
'email-link' => ['邮件链接', '<p><a href="mailto:hello@example.com">发送邮件</a></p>'],
|
||||||
|
]],
|
||||||
|
'media-elements' => ['图片与影音', [
|
||||||
|
'image' => ['图片', '', 'image/'],
|
||||||
|
'video' => ['视频', '', 'video/'],
|
||||||
|
'audio' => ['音频', '', 'audio/'],
|
||||||
|
'qr-image' => ['二维码', '', 'image/'],
|
||||||
|
'image-link' => ['图片链接', '<p><a href="/pagepan"><img src="/assets/original/pagepan-example.webp" alt="PAGEPAN 产品预览" loading="lazy"></a></p>'],
|
||||||
|
]],
|
||||||
|
'structure-elements' => ['版式与数据', [
|
||||||
|
'separator' => ['分割线', '<hr class="studio-divider">'],
|
||||||
|
'spacer' => ['留白', '<div class="studio-spacer"></div>'],
|
||||||
|
'code' => ['代码块', '<pre class="studio-code"><code>填写代码</code></pre>'],
|
||||||
|
'basic-table' => ['数据表格', '<table><thead><tr><th scope="col">名称</th><th scope="col">数据</th></tr></thead><tbody><tr><td>填写名称</td><td>填写数据</td></tr></tbody></table>'],
|
||||||
|
'progress' => ['进度条', '<div class="studio-progress"><p>完成进度</p><progress max="100" value="65">65%</progress></div>'],
|
||||||
|
'alert' => ['提示卡', '<div class="studio-notice"><p><strong>请注意</strong></p><p>填写一条提示信息。</p></div>'],
|
||||||
|
'simple-card' => ['内容卡片', '<article class="content-card"><h3>填写卡片标题</h3><p>填写卡片内容。</p></article>'],
|
||||||
|
'link-card' => ['链接卡片', '<article class="content-card"><h3>查看资料</h3><p>填写链接指向的资料说明。</p><a href="/articles">打开资料</a></article>'],
|
||||||
|
'list-group' => ['列表组', '<ul class="studio-resources"><li><a href="/services">产品与服务</a><span>目录</span></li><li><a href="/articles">来笙动态</a><span>文章</span></li></ul>'],
|
||||||
|
'empty-card' => ['空状态', '<div class="studio-empty"><h3>暂无内容</h3><p>填写访客可以执行的下一步。</p><a href="/articles">查看站点动态</a></div>'],
|
||||||
|
'status-note' => ['状态提示', '<div class="studio-notice studio-success-note"><p><strong>已完成</strong></p><p>填写操作结果或服务状态。</p></div>'],
|
||||||
|
'disclosure' => ['折叠内容', '<div class="faq"><details><summary>填写折叠标题</summary><div><p>填写展开后的内容。</p></div></details></div>'],
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
|
||||||
|
public const GROUPS = [
|
||||||
|
'content' => ['标题与正文', [
|
||||||
|
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
|
||||||
|
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
||||||
|
'articles' => ['分类文章', '', '', self::ARTICLE_FEED],
|
||||||
|
'network' => ['支持项目与合作伙伴', '', '', self::NETWORK_FEED],
|
||||||
|
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
|
||||||
|
'notice' => ['重点提示', '<div class="studio-notice"><h3>填写重要提示</h3><p>说明访客需要知悉的事项、条件或时间。</p></div>'],
|
||||||
|
]],
|
||||||
|
'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>'],
|
||||||
|
'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' => ['图文与布局', [
|
||||||
|
'image' => ['产品图文', '<div class="studio-split"><img src="/assets/original/home-hero.webp" alt="" loading="lazy"><div><h3>介绍主题</h3><p>在这里说明图片或产品。</p></div></div>'],
|
||||||
|
'grid' => ['双栏网格', '<div class="studio-two-column"><article class="content-card"><h3>第一栏</h3><p>填写主要内容。</p></article><article class="content-card"><h3>第二栏</h3><p>补充相关信息。</p></article></div>'],
|
||||||
|
]],
|
||||||
|
'media' => ['媒体', [
|
||||||
|
'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' => ['特性卡片', '<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>'],
|
||||||
|
'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' => ['表格与问答', [
|
||||||
|
'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>'],
|
||||||
|
'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' => ['导航与引导', [
|
||||||
|
'service-catalog' => ['产品与服务目录', '', '', self::CATALOG_FEED],
|
||||||
|
'product-links' => ['产品与服务五联导航', self::PRODUCT_LINKS],
|
||||||
|
'navigation' => ['快速导航', '<ul class="studio-quick-nav"><li><a href="/services">产品与服务</a></li><li><a href="/articles">动态与文章</a></li><li><a href="/#contact">联系来笙</a></li></ul>'],
|
||||||
|
'cta' => ['行动按钮', '<p>说明下一步。</p><p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
||||||
|
'resources' => ['资料与链接', '<ul class="studio-resources"><li><a href="/pagepan#download">获取 PAGEPAN</a><span>应用下载</span></li><li><a href="/articles">浏览动态与文档</a><span>网站资源</span></li></ul>'],
|
||||||
|
'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>'],
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function groups(): array
|
||||||
|
{
|
||||||
|
static $groups;
|
||||||
|
if ($groups !== null) {
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups = self::GROUPS;
|
||||||
|
$seed = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
$sectionGroups = [
|
||||||
|
'product' => 'layout', 'about' => 'content', 'blog' => 'content',
|
||||||
|
'features' => 'features', 'support' => 'features', 'why' => 'features', 'stories' => 'features',
|
||||||
|
'pricing' => 'details', 'comparison' => 'details', 'materials' => 'details', 'fees' => 'details',
|
||||||
|
'faq' => 'details', 'terms' => 'details',
|
||||||
|
'get' => 'actions', 'options' => 'actions', 'go' => 'actions', 'benefits' => 'layout',
|
||||||
|
];
|
||||||
|
foreach ($seed['pages'] as $page) {
|
||||||
|
if (!in_array($page['slug'], ['home', 'highspeaker', 'sc', 'shnu-sc'], true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$links = '';
|
||||||
|
foreach ($page['actions'] as [$url, $label]) {
|
||||||
|
$links .= '<a class="button button-outline" href="' . View::escape($url) . '">' . View::escape($label) . '</a>';
|
||||||
|
}
|
||||||
|
$hero = '<div class="studio-cover"><img src="' . View::escape($page['image']) . '" alt="' . View::escape($page['alt']) . '" loading="lazy">'
|
||||||
|
. '<div><h3>' . View::escape(trim($page['heading'] . ' ' . $page['accent'])) . '</h3><p>' . View::escape($page['lead'])
|
||||||
|
. '</p><div class="actions">' . $links . '</div></div></div>';
|
||||||
|
$prefix = 'existing-' . $page['slug'] . '-';
|
||||||
|
$groups['cover'][1][$prefix . 'hero'] = ['产品图文 · ' . $page['name'], $hero];
|
||||||
|
foreach ($page['sections'] as $section) {
|
||||||
|
$group = $sectionGroups[$section['key']] ?? null;
|
||||||
|
if ($group === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$groups[$group][1][$prefix . $section['key']] = [
|
||||||
|
$section['key'] === 'features' ? '特性组' : $section['title'],
|
||||||
|
Html::sanitize($section['body']), $section['lead'],
|
||||||
|
isset($section['feed']) ? Database::json($section['feed']) : null,
|
||||||
|
$section['style'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function find(string $key): ?array
|
||||||
|
{
|
||||||
|
foreach (self::groups() as [, $templates]) {
|
||||||
|
if (isset($templates[$key])) {
|
||||||
|
return $templates[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,10 @@ use Throwable;
|
|||||||
|
|
||||||
final class Database
|
final class Database
|
||||||
{
|
{
|
||||||
|
// Avoid reusing a deleted ID that may still be open in an editing form.
|
||||||
|
public const NEXT_ARTICLE_ID = 'MAX(COALESCE((SELECT MAX(id) FROM articles), 0),
|
||||||
|
COALESCE((SELECT MAX(article_id) FROM article_deletions), 0)) + 1';
|
||||||
|
|
||||||
private static ?PDO $connection = null;
|
private static ?PDO $connection = null;
|
||||||
|
|
||||||
public static function connect(): PDO
|
public static function connect(): PDO
|
||||||
@@ -39,23 +43,30 @@ final class Database
|
|||||||
$pdo->exec('PRAGMA journal_mode = WAL');
|
$pdo->exec('PRAGMA journal_mode = WAL');
|
||||||
|
|
||||||
self::write(function (PDO $pdo) use ($root, $seed): void {
|
self::write(function (PDO $pdo) use ($root, $seed): void {
|
||||||
|
$articleColumns = array_column($pdo->query('PRAGMA table_info(articles)')->fetchAll(), 'name');
|
||||||
|
if (in_array('category', $articleColumns, true)) {
|
||||||
|
throw new RuntimeException('请将 LAYSENSE_DB 指向一个新的 SQLite 文件,再运行安装命令。');
|
||||||
|
}
|
||||||
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
||||||
if (!in_array('status', array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name'), true)) {
|
foreach (['pages', 'sections'] as $table) {
|
||||||
$pdo->exec("ALTER TABLE pages ADD COLUMN status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published'))");
|
$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'])]);
|
||||||
|
|
||||||
$pageQuery = $pdo->prepare('INSERT OR IGNORE INTO pages
|
$pageQuery = $pdo->prepare('INSERT OR IGNORE INTO pages
|
||||||
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks, partners)
|
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
$sectionQuery = $pdo->prepare('INSERT OR IGNORE INTO sections
|
$sectionQuery = $pdo->prepare('INSERT OR IGNORE INTO sections
|
||||||
(page_slug, key, title, lead, style, body, position) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
(page_slug, key, title, lead, style, body, feed, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
foreach ($seed['pages'] as $page) {
|
foreach ($seed['pages'] as $page) {
|
||||||
$pageQuery->execute([
|
$pageQuery->execute([
|
||||||
$page['slug'], $page['name'], $page['title'], $page['description'], $page['heading'],
|
$page['slug'], $page['name'], $page['title'], $page['description'], $page['heading'],
|
||||||
$page['accent'], $page['lead'], $page['image'], $page['alt'],
|
$page['accent'], $page['lead'], $page['image'], $page['alt'],
|
||||||
self::json($page['actions']), self::json($page['quicklinks']), self::json($page['partners'] ?? []),
|
self::json($page['actions']), self::json($page['quicklinks']),
|
||||||
]);
|
]);
|
||||||
if ($pageQuery->rowCount() !== 1) {
|
if ($pageQuery->rowCount() !== 1) {
|
||||||
continue;
|
continue;
|
||||||
@@ -63,34 +74,50 @@ final class Database
|
|||||||
foreach ($page['sections'] as $index => $section) {
|
foreach ($page['sections'] as $index => $section) {
|
||||||
$sectionQuery->execute([
|
$sectionQuery->execute([
|
||||||
$page['slug'], $section['key'], $section['title'], $section['lead'],
|
$page['slug'], $section['key'], $section['title'], $section['lead'],
|
||||||
$section['style'], Html::sanitize($section['body']), $index,
|
$section['style'], Html::sanitize($section['body']), isset($section['feed']) ? self::json($section['feed']) : null, $index,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = $pdo->prepare('INSERT OR IGNORE INTO articles
|
if ((int) $pdo->query('PRAGMA user_version')->fetchColumn() === 0) {
|
||||||
(slug, title, category, summary, body, tags, status, published_at, updated_at, legacy_path)
|
$heroDirectory = $pdo->prepare("INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, position)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
VALUES ('home', 'hero-directory', '产品与服务导航', '', 'hero-links', ?, -1)");
|
||||||
|
$heroDirectory->execute([BlockTemplates::PRODUCT_LINKS]);
|
||||||
|
$network = $pdo->prepare("INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, feed, position)
|
||||||
|
SELECT 'home', 'network', '支持项目与合作伙伴', '', 'plain', '', ?, COALESCE(MAX(position), -1) + 1
|
||||||
|
FROM sections WHERE page_slug = 'home'");
|
||||||
|
$network->execute([BlockTemplates::NETWORK_FEED]);
|
||||||
|
if ($heroDirectory->rowCount() + $network->rowCount() > 0) {
|
||||||
|
$pdo->exec("UPDATE pages SET version = version + 1 WHERE slug = 'home'");
|
||||||
|
}
|
||||||
|
$pdo->exec('PRAGMA user_version = 1');
|
||||||
|
}
|
||||||
|
|
||||||
|
$category = $pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
|
||||||
|
foreach (Repository::CATEGORIES as $slug => $name) {
|
||||||
|
$category->execute([$slug, $name]);
|
||||||
|
}
|
||||||
|
$article = $pdo->prepare("INSERT OR IGNORE INTO articles
|
||||||
|
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
|
||||||
|
SELECT " . self::NEXT_ARTICLE_ID . ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM article_deletions WHERE slug = ?)");
|
||||||
|
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
||||||
foreach ($seed['articles'] as $item) {
|
foreach ($seed['articles'] as $item) {
|
||||||
$exists = $pdo->prepare('SELECT 1 FROM article_redirects WHERE slug = ?');
|
$format = $item['body_format'] ?? 'markdown';
|
||||||
$exists->execute([$item['slug']]);
|
$date = $item['date'] ?? null;
|
||||||
if ($exists->fetchColumn()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$article->execute([
|
$article->execute([
|
||||||
$item['slug'], $item['title'], $item['category'], $item['summary'], $item['body'],
|
$item['slug'], $item['title'], $item['summary'] ?? '',
|
||||||
self::json($item['tags']), $item['status'], $item['date'], $item['date'], $item['legacy'],
|
$format === 'html' ? Html::sanitize($item['body']) : $item['body'], $format,
|
||||||
|
self::json($item['card'] ?? []), self::json($item['tags'] ?? []),
|
||||||
|
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'], $item['slug'],
|
||||||
]);
|
]);
|
||||||
|
if ($article->rowCount() === 1) {
|
||||||
|
$id = $pdo->lastInsertId();
|
||||||
|
foreach ($item['categories'] as $slug) {
|
||||||
|
$link->execute([$id, $slug]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$migration = $pdo->prepare('INSERT OR IGNORE INTO schema_migrations (name) VALUES (?)');
|
|
||||||
$migration->execute(['restore_pagepan_feature_icons']);
|
|
||||||
if ($migration->rowCount() === 1) {
|
|
||||||
PagepanFeatureIcons::migrate($pdo);
|
|
||||||
}
|
}
|
||||||
$migration->execute(['product_directory_and_service_icons']);
|
|
||||||
if ($migration->rowCount() === 1) {
|
|
||||||
DesignMigration::apply($pdo);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Content;
|
|
||||||
|
|
||||||
use DOMDocument;
|
|
||||||
use DOMElement;
|
|
||||||
use DOMXPath;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
final class DesignMigration
|
|
||||||
{
|
|
||||||
public static function apply(PDO $pdo): void
|
|
||||||
{
|
|
||||||
$stock = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR);
|
|
||||||
$home = array_column($stock['pages'], null, 'slug')['home'];
|
|
||||||
$stockBody = Html::sanitize(array_column($home['sections'], 'body', 'key')['product']);
|
|
||||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$doc->loadHTML('<meta charset="UTF-8">' . $stockBody, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
|
||||||
$xpath = new DOMXPath($doc);
|
|
||||||
$insert = $pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, extra_url, extra_label, position)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
|
||||||
foreach ($xpath->query('//article[contains(concat(" ", @class, " "), " project ")]') as $position => $card) {
|
|
||||||
$image = $xpath->query('.//img', $card)->item(0);
|
|
||||||
$links = $xpath->query('.//a', $card);
|
|
||||||
$body = '';
|
|
||||||
foreach ($xpath->query('.//p', $card) as $paragraph) {
|
|
||||||
$body .= $doc->saveHTML($paragraph);
|
|
||||||
}
|
|
||||||
$insert->execute([
|
|
||||||
trim($xpath->evaluate('string(.//h3)', $card)), trim($xpath->evaluate('string(.//span)', $card)),
|
|
||||||
Html::sanitize($body), $image->getAttribute('src'), $image->getAttribute('alt'),
|
|
||||||
$links->item(0)->getAttribute('href'), trim($links->item(0)->textContent),
|
|
||||||
$links->item(1)?->getAttribute('href') ?? '', trim($links->item(1)?->textContent ?? ''), $position * 10,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
||||||
->execute(['SHNU 学生软著服务', '校园服务', '<p>面向 SHNU 学生的软件著作权申请服务。</p>',
|
|
||||||
'/assets/original/shnu-hero.webp', '', '/shnu-sc', '查看学生方案', 30]);
|
|
||||||
$pdo->prepare("UPDATE sections SET body = ?, version = version + 1
|
|
||||||
WHERE page_slug = 'home' AND key = 'product' AND version = 0 AND body = ?")
|
|
||||||
->execute(['<p>浏览来笙的建站工具、智能 DNS 和软件著作权服务。</p><a class="button button-primary" href="/services">查看产品与服务</a>', $stockBody]);
|
|
||||||
|
|
||||||
$choices = $pdo->query("SELECT page_slug, body FROM sections WHERE key = 'why' AND page_slug IN ('sc', 'shnu-sc')");
|
|
||||||
$updateChoice = $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = ? AND key = 'why'");
|
|
||||||
foreach ($choices->fetchAll() as $section) {
|
|
||||||
$body = preg_replace('~(<article\b[^>]*class="[^"]*\bfeature-card)("(?:[^>]*>)\s*<h[2-4]>选择来笙</h[2-4]>)~u',
|
|
||||||
'$1 choice-card$2', $section['body']);
|
|
||||||
if ($body !== null && $body !== $section['body']) {
|
|
||||||
$updateChoice->execute([$body, $section['page_slug']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$icons = ['/assets/original/10-1.png' => '/assets/service/project.svg',
|
|
||||||
'/assets/original/10-2.png' => '/assets/service/code.svg', '/assets/original/10-3.png' => '/assets/service/support.svg'];
|
|
||||||
$sections = $pdo->query("SELECT page_slug, body FROM sections WHERE key = 'options' AND page_slug IN ('sc', 'shnu-sc')");
|
|
||||||
$update = $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = ? AND key = 'options'");
|
|
||||||
foreach ($sections->fetchAll() as $section) {
|
|
||||||
$body = strtr($section['body'], $icons);
|
|
||||||
$body = preg_replace('/(<article\b[^>]*>)\s*<li\b[^>]*>(.*?)<\/li>\s*(<\/article>)/s', '$1$2$3', $body);
|
|
||||||
if ($body !== $section['body']) {
|
|
||||||
$update->execute([$body, $section['page_slug']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Content;
|
||||||
|
|
||||||
|
use DOMDocument;
|
||||||
|
use DOMXPath;
|
||||||
|
|
||||||
|
final class DirectoryCard
|
||||||
|
{
|
||||||
|
public static function links(array $article, string $body): array
|
||||||
|
{
|
||||||
|
$detail = self::hasText($article['summary']) || self::hasBody($body) ? '/articles/' . $article['slug'] : '';
|
||||||
|
$primary = ($article['card']['url'] ?? '') ?: $detail;
|
||||||
|
|
||||||
|
return ['primary' => $primary, 'detail' => $primary === $detail ? '' : $detail];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function hasText(string $text): bool
|
||||||
|
{
|
||||||
|
return preg_match('/[^\s\p{Z}\p{Cf}]/u', $text) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function hasBody(string $html): bool
|
||||||
|
{
|
||||||
|
if (self::hasText(html_entity_decode(strip_tags($html), ENT_QUOTES | ENT_HTML5, 'UTF-8'))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!str_contains($html, 'src=')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$document = new DOMDocument();
|
||||||
|
$document->loadHTML('<meta charset="utf-8">' . $html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
||||||
|
$xpath = new DOMXPath($document);
|
||||||
|
|
||||||
|
return (bool) $xpath->evaluate('boolean(//img[@src] | //audio[@src] | //video[@src] | //audio/source[@src] | //video/source[@src])');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,13 @@ namespace App\Content;
|
|||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use DOMNode;
|
use DOMNode;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\GithubFlavoredMarkdownConverter;
|
||||||
|
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'],
|
||||||
@@ -42,14 +45,50 @@ final class Html
|
|||||||
public static function markdown(string $text): string
|
public static function markdown(string $text): string
|
||||||
{
|
{
|
||||||
static $converter;
|
static $converter;
|
||||||
$converter ??= new CommonMarkConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]);
|
$converter ??= new GithubFlavoredMarkdownConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]);
|
||||||
|
|
||||||
$html = $converter->convert($text)->getContent();
|
$html = $converter->convert($text)->getContent();
|
||||||
|
|
||||||
return str_replace(['<h1>', '</h1>'], ['<h2>', '</h2>'], $html);
|
return str_replace(['<h1>', '</h1>'], ['<h2>', '</h2>'], $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sanitize(string $html): string
|
public static function articleBody(array $article): string
|
||||||
|
{
|
||||||
|
return $article['body_format'] === 'html' ? self::sanitize($article['body']) : self::markdown($article['body']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function applyCanvasEdits(string $body, array $edits): string
|
||||||
|
{
|
||||||
|
if (!array_is_list($edits) || count($edits) > 512) {
|
||||||
|
throw new RuntimeException('正文增量无效。');
|
||||||
|
}
|
||||||
|
$size = strlen($body);
|
||||||
|
$cursor = 0;
|
||||||
|
$result = '';
|
||||||
|
foreach ($edits as $edit) {
|
||||||
|
if (!is_array($edit) || !array_is_list($edit) || count($edit) !== 3) {
|
||||||
|
throw new RuntimeException('正文增量无效。');
|
||||||
|
}
|
||||||
|
[$offset, $remove, $insert] = $edit;
|
||||||
|
if (!is_int($offset) || !is_int($remove) || !is_string($insert)
|
||||||
|
|| $offset < $cursor || $offset > $size || $remove < 0 || $remove > $size - $offset) {
|
||||||
|
throw new RuntimeException('正文增量无效。');
|
||||||
|
}
|
||||||
|
$result .= substr($body, $cursor, $offset - $cursor) . $insert;
|
||||||
|
$cursor = $offset + $remove;
|
||||||
|
if (strlen($result) > 300000) {
|
||||||
|
throw new RuntimeException('正文太长。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$result .= substr($body, $cursor);
|
||||||
|
if (strlen($result) > 300000 || !mb_check_encoding($result, 'UTF-8')) {
|
||||||
|
throw new RuntimeException('正文太长或编码无效。');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sanitize(string $html, ?string $anchorPrefix = null): string
|
||||||
{
|
{
|
||||||
$document = new DOMDocument('1.0', 'UTF-8');
|
$document = new DOMDocument('1.0', 'UTF-8');
|
||||||
$document->loadHTML('<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>' . $html . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
$document->loadHTML('<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>' . $html . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
||||||
@@ -58,6 +97,22 @@ final class Html
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
self::sanitizeChildren($body);
|
self::sanitizeChildren($body);
|
||||||
|
if ($anchorPrefix !== null) {
|
||||||
|
$ids = [];
|
||||||
|
foreach ($body->getElementsByTagName('*') as $element) {
|
||||||
|
$id = $element->getAttribute('id');
|
||||||
|
if ($id !== '') {
|
||||||
|
$ids[$id] = $anchorPrefix . '-' . $id;
|
||||||
|
$element->setAttribute('id', $ids[$id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($body->getElementsByTagName('a') as $link) {
|
||||||
|
$href = $link->getAttribute('href');
|
||||||
|
if (str_starts_with($href, '#') && isset($ids[substr($href, 1)])) {
|
||||||
|
$link->setAttribute('href', '#' . $ids[substr($href, 1)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$output = '';
|
$output = '';
|
||||||
foreach ($body->childNodes as $child) {
|
foreach ($body->childNodes as $child) {
|
||||||
$output .= $document->saveHTML($child);
|
$output .= $document->saveHTML($child);
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Content;
|
|
||||||
|
|
||||||
use DOMDocument;
|
|
||||||
use DOMElement;
|
|
||||||
use DOMXPath;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
final class PagepanFeatureIcons
|
|
||||||
{
|
|
||||||
public static function migrate(PDO $pdo): void
|
|
||||||
{
|
|
||||||
$query = $pdo->query("SELECT body FROM sections WHERE page_slug = 'pagepan' AND key = 'features'");
|
|
||||||
$body = $query->fetchColumn();
|
|
||||||
if (!is_string($body) || $body === '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$paths = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/pagepan-feature-icons.json'), true, flags: JSON_THROW_ON_ERROR);
|
|
||||||
$document = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$document->loadHTML('<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>' . $body . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
|
||||||
$xpath = new DOMXPath($document);
|
|
||||||
|
|
||||||
$changed = false;
|
|
||||||
foreach ($xpath->query('//article[contains(concat(" ", normalize-space(@class), " "), " feature-card ")]') as $card) {
|
|
||||||
$heading = $xpath->query('(./h2 | ./h3 | ./h4)[1]', $card)->item(0);
|
|
||||||
if (!$heading instanceof DOMElement || $card->getElementsByTagName('img')->length > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$title = trim($heading->textContent);
|
|
||||||
if (!isset($paths[$title])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$icon = $document->createElement('img');
|
|
||||||
foreach (['src' => $paths[$title], 'alt' => '', 'width' => '50', 'height' => '50', 'loading' => 'lazy'] as $key => $value) {
|
|
||||||
$icon->setAttribute($key, $value);
|
|
||||||
}
|
|
||||||
$card->insertBefore($icon, $card->firstChild);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($changed) {
|
|
||||||
$updated = '';
|
|
||||||
foreach ($document->getElementsByTagName('body')->item(0)->childNodes as $child) {
|
|
||||||
$updated .= $document->saveHTML($child);
|
|
||||||
}
|
|
||||||
$pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = 'pagepan' AND key = 'features'")
|
|
||||||
->execute([trim($updated)]);
|
|
||||||
$pdo->prepare("UPDATE pages SET updated_at = ? WHERE slug = 'pagepan'")
|
|
||||||
->execute([(new \DateTimeImmutable('now', new \DateTimeZone('Asia/Shanghai')))->format('Y-m-d H:i:s')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,13 @@ use RuntimeException;
|
|||||||
|
|
||||||
final class Repository
|
final class Repository
|
||||||
{
|
{
|
||||||
public const CATEGORIES = ['announcement' => '公告', 'news' => '新闻', 'product' => '产品'];
|
public const DIRECTORIES = [
|
||||||
|
'services' => '产品与服务', 'supported-projects' => '来笙支持项目', 'partners' => '来笙合作伙伴',
|
||||||
|
];
|
||||||
|
public const CATEGORIES = ['announcement' => '公告', 'news' => '新闻', 'product' => '产品'] + self::DIRECTORIES;
|
||||||
|
private const ARTICLE_FIELDS = 'articles.*, (SELECT json_group_object(c.slug, c.name)
|
||||||
|
FROM article_category_links l JOIN article_categories c ON c.slug = l.category_slug
|
||||||
|
WHERE l.article_id = articles.id) AS categories';
|
||||||
private PDO $pdo;
|
private PDO $pdo;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -32,8 +38,8 @@ final class Repository
|
|||||||
public function createPage(string $slug, string $name): void
|
public function createPage(string $slug, string $name): void
|
||||||
{
|
{
|
||||||
$query = $this->pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
|
$query = $this->pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
|
||||||
lead, image, alt, actions, quicklinks, partners, status, updated_at)
|
lead, image, alt, actions, quicklinks, status, updated_at)
|
||||||
VALUES (?, ?, ?, '', ?, '', '', '', '', '[]', '[]', '[]', 'draft', ?)");
|
VALUES (?, ?, ?, '', ?, '', '', '', '', '[]', '[]', 'draft', ?)");
|
||||||
$query->execute([$slug, $name, $name . ' · 来笙', $name, self::now()]);
|
$query->execute([$slug, $name, $name . ' · 来笙', $name, self::now()]);
|
||||||
if ($query->rowCount() !== 1) {
|
if ($query->rowCount() !== 1) {
|
||||||
throw new RuntimeException('此页面地址已存在。');
|
throw new RuntimeException('此页面地址已存在。');
|
||||||
@@ -46,7 +52,7 @@ final class Repository
|
|||||||
if (!$page) {
|
if (!$page) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (['actions', 'quicklinks', 'partners'] 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');
|
||||||
@@ -61,61 +67,99 @@ 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 savePage(string $slug, array $data, int $version): void
|
public function publishedFeed(string $page, string $key): ?array
|
||||||
{
|
{
|
||||||
$query = $this->pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
|
return $this->one("SELECT sections.title, sections.feed FROM sections
|
||||||
image = ?, alt = ?, actions = ?, quicklinks = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
|
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
|
||||||
|
{
|
||||||
|
Database::write(function (PDO $pdo) use ($slug, $data, $version, $sections): void {
|
||||||
|
$query = $pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
|
||||||
|
image = ?, alt = ?, image_scale = ?, alignments = ?, actions = ?, quicklinks = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
|
||||||
$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'], 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());
|
||||||
|
foreach ($sections as $section) {
|
||||||
|
if (!empty($section['delete'])) {
|
||||||
|
self::deleteSection($pdo, $slug, $section['key'], $section['version']);
|
||||||
|
} elseif ($section['version'] === null) {
|
||||||
|
self::insertSection($pdo, $slug, $section['key'], $section);
|
||||||
|
} else {
|
||||||
|
self::updateSection($pdo, $slug, $section['key'], $section, $section['version']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSection(string $page, string $key, array $data, int $version): void
|
public function saveSection(string $page, string $key, array $data, int $version): void
|
||||||
{
|
{
|
||||||
Database::write(function (PDO $pdo) use ($page, $key, $data, $version): void {
|
Database::write(function (PDO $pdo) use ($page, $key, $data, $version): void {
|
||||||
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, version = version + 1
|
self::updateSection($pdo, $page, $key, $data, $version);
|
||||||
WHERE page_slug = ? AND key = ? AND version = ?');
|
self::touchPage($pdo, $page);
|
||||||
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $page, $key, $version]);
|
|
||||||
self::checkVersion($query->rowCount());
|
|
||||||
$query = $pdo->prepare('UPDATE pages SET updated_at = ? WHERE slug = ?');
|
|
||||||
$query->execute([self::now(), $page]);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSection(string $page, string $key, string $title, string $style, string $body): void
|
private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
|
||||||
{
|
{
|
||||||
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body): void {
|
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, feed = ?, alignments = COALESCE(?, alignments), version = version + 1
|
||||||
$query = $pdo->prepare('INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, position)
|
WHERE page_slug = ? AND key = ? AND version = ?');
|
||||||
SELECT ?, ?, ?, ?, ?, ?, COALESCE(MAX(position), -1) + 1 FROM sections WHERE page_slug = ?');
|
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $data['feed'] ?? null, $data['alignments'] ?? null, $page, $key, $version]);
|
||||||
$query->execute([$page, $key, $title, '', $style, $body, $page]);
|
self::checkVersion($query->rowCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createSection(string $page, string $key, string $title, string $style, string $body, ?string $feed = null, string $lead = ''): void
|
||||||
|
{
|
||||||
|
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body, $feed, $lead): void {
|
||||||
|
self::insertSection($pdo, $page, $key, compact('title', 'style', 'body', 'feed', 'lead'));
|
||||||
|
self::touchPage($pdo, $page, structureChanged: true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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, alignments, position)
|
||||||
|
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, $data['alignments'] ?? '{}', $page]);
|
||||||
if ($query->rowCount() !== 1) {
|
if ($query->rowCount() !== 1) {
|
||||||
throw new RuntimeException('此区块锚点已被使用。');
|
throw new RuntimeException('此区块锚点已被使用。');
|
||||||
}
|
}
|
||||||
self::touchPage($pdo, $page);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function arrangeSection(string $page, string $key, string $operation, int $version): void
|
private static function deleteSection(PDO $pdo, string $page, string $key, int $version): void
|
||||||
{
|
{
|
||||||
Database::write(function (PDO $pdo) use ($page, $key, $operation, $version): void {
|
|
||||||
if ($operation === 'delete') {
|
|
||||||
$query = $pdo->prepare('DELETE FROM sections WHERE page_slug = ? AND key = ? AND version = ?');
|
$query = $pdo->prepare('DELETE FROM sections WHERE page_slug = ? AND key = ? AND version = ?');
|
||||||
$query->execute([$page, $key, $version]);
|
$query->execute([$page, $key, $version]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
self::touchPage($pdo, $page);
|
}
|
||||||
|
|
||||||
|
public function arrangeSection(string $page, string $key, string $operation, int $version, int $pageVersion): void
|
||||||
|
{
|
||||||
|
Database::write(function (PDO $pdo) use ($page, $key, $operation, $version, $pageVersion): void {
|
||||||
|
$current = $pdo->prepare('SELECT version FROM pages WHERE slug = ?');
|
||||||
|
$current->execute([$page]);
|
||||||
|
$revision = $current->fetchColumn();
|
||||||
|
self::checkVersion($revision !== false && (int) $revision === $pageVersion ? 1 : 0);
|
||||||
|
if ($operation === 'delete') {
|
||||||
|
self::deleteSection($pdo, $page, $key, $version);
|
||||||
|
self::touchPage($pdo, $page, structureChanged: true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$query = $pdo->prepare('SELECT key FROM sections WHERE page_slug = ? ORDER BY position, key');
|
$query = $pdo->prepare("SELECT key, version FROM sections WHERE page_slug = ? AND style <> 'hero-links' ORDER BY position, key");
|
||||||
$query->execute([$page]);
|
$query->execute([$page]);
|
||||||
$keys = $query->fetchAll(PDO::FETCH_COLUMN);
|
$revisions = $query->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
$index = array_search($key, $keys, true);
|
if (!array_key_exists($key, $revisions)) {
|
||||||
if ($index === false) {
|
|
||||||
throw new RuntimeException('找不到该区块。');
|
throw new RuntimeException('找不到该区块。');
|
||||||
}
|
}
|
||||||
|
self::checkVersion((int) $revisions[$key] === $version ? 1 : 0);
|
||||||
|
$keys = array_map('strval', array_keys($revisions));
|
||||||
|
$index = array_search($key, $keys, true);
|
||||||
$other = $index + ($operation === 'up' ? -1 : 1);
|
$other = $index + ($operation === 'up' ? -1 : 1);
|
||||||
if (!isset($keys[$other])) {
|
if (!isset($keys[$other])) {
|
||||||
return;
|
return;
|
||||||
@@ -125,32 +169,54 @@ final class Repository
|
|||||||
foreach ($keys as $position => $section) {
|
foreach ($keys as $position => $section) {
|
||||||
$query->execute([$position, $page, $section]);
|
$query->execute([$position, $page, $section]);
|
||||||
}
|
}
|
||||||
self::touchPage($pdo, $page);
|
self::touchPage($pdo, $page, structureChanged: true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function touchPage(PDO $pdo, string $slug): void
|
private static function touchPage(PDO $pdo, string $slug, bool $structureChanged = false): void
|
||||||
{
|
{
|
||||||
$pdo->prepare('UPDATE pages SET updated_at = ? WHERE slug = ?')->execute([self::now(), $slug]);
|
$revision = $structureChanged ? ', version = version + 1' : '';
|
||||||
|
$pdo->prepare('UPDATE pages SET updated_at = ?' . $revision . ' WHERE slug = ?')->execute([self::now(), $slug]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articles(?string $category = null, ?string $tag = null, bool $public = true, int $limit = 30, int $offset = 0): array
|
public function categories(): array
|
||||||
{
|
{
|
||||||
$sql = 'SELECT * FROM articles WHERE 1 = 1';
|
return $this->pdo->query('SELECT slug, name FROM article_categories ORDER BY rowid')->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createCategory(string $slug, string $name): void
|
||||||
|
{
|
||||||
|
$query = $this->pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
|
||||||
|
$query->execute([$slug, $name]);
|
||||||
|
if ($query->rowCount() !== 1) {
|
||||||
|
throw new RuntimeException('此分类网址标识已被使用。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function articles(string|array|null $category = null, ?string $tag = null, bool $public = true,
|
||||||
|
int $limit = 30, int $offset = 0, bool $directoryOrder = false): array
|
||||||
|
{
|
||||||
|
if ($category === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$sql = 'SELECT ' . self::ARTICLE_FIELDS . ' FROM articles WHERE 1 = 1';
|
||||||
$args = [];
|
$args = [];
|
||||||
if ($public) {
|
if ($public) {
|
||||||
$sql .= " AND status = 'published' AND published_at IS NOT NULL";
|
$sql .= " AND status = 'published'";
|
||||||
}
|
}
|
||||||
if ($category !== null) {
|
if ($category !== null) {
|
||||||
$sql .= ' AND category = ?';
|
$args = (array) $category;
|
||||||
$args[] = $category;
|
$marks = implode(', ', array_fill(0, count($args), '?'));
|
||||||
|
$sql .= " AND EXISTS (SELECT 1 FROM article_category_links
|
||||||
|
WHERE article_id = articles.id AND category_slug IN ($marks))";
|
||||||
}
|
}
|
||||||
if ($tag !== null) {
|
if ($tag !== null) {
|
||||||
$sql .= ' AND EXISTS (SELECT 1 FROM json_each(articles.tags) WHERE value = ?)';
|
$sql .= ' AND EXISTS (SELECT 1 FROM json_each(articles.tags) WHERE value = ?)';
|
||||||
$args[] = $tag;
|
$args[] = $tag;
|
||||||
}
|
}
|
||||||
$order = $public ? 'published_at' : 'updated_at';
|
$order = $public ? 'published_at' : 'updated_at';
|
||||||
$query = $this->pdo->prepare($sql . ' ORDER BY ' . $order . ' DESC, id DESC LIMIT ? OFFSET ?');
|
$order = $directoryOrder ? "COALESCE(json_extract(card, '$.position'), 0), id" : "$order DESC, id DESC";
|
||||||
|
$query = $this->pdo->prepare($sql . ' ORDER BY ' . $order . ' LIMIT ? OFFSET ?');
|
||||||
$query->execute([...$args, $limit, $offset]);
|
$query->execute([...$args, $limit, $offset]);
|
||||||
|
|
||||||
return array_map(self::decodeArticle(...), $query->fetchAll());
|
return array_map(self::decodeArticle(...), $query->fetchAll());
|
||||||
@@ -158,12 +224,12 @@ final class Repository
|
|||||||
|
|
||||||
public function articleById(int $id): ?array
|
public function articleById(int $id): ?array
|
||||||
{
|
{
|
||||||
return self::decodeArticle($this->one('SELECT * FROM articles WHERE id = ?', [$id]));
|
return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . ' FROM articles WHERE id = ?', [$id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function published(string $slug): ?array
|
public function published(string $slug): ?array
|
||||||
{
|
{
|
||||||
return self::decodeArticle($this->one("SELECT * FROM articles WHERE slug = ? AND status = 'published'", [$slug]));
|
return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . " FROM articles WHERE slug = ? AND status = 'published'", [$slug]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articleRedirect(string $slug): ?array
|
public function articleRedirect(string $slug): ?array
|
||||||
@@ -190,34 +256,60 @@ final class Repository
|
|||||||
if (($existing && $existing['id'] !== $id) || ($redirect && $redirect['article_id'] !== $id)) {
|
if (($existing && $existing['id'] !== $id) || ($redirect && $redirect['article_id'] !== $id)) {
|
||||||
throw new RuntimeException('此网址标识已被使用。');
|
throw new RuntimeException('此网址标识已被使用。');
|
||||||
}
|
}
|
||||||
$publishedAt = $old['published_at'] ?? ($data['status'] === 'published' ? self::now() : null);
|
$publishedAt = $old['published_at'] ?? ($data['status'] === 'published' && ($old['status'] ?? '') !== 'published' ? self::now() : null);
|
||||||
$values = [
|
$values = [
|
||||||
$data['slug'], $data['title'], $data['category'], $data['summary'], $data['body'],
|
$data['slug'], $data['title'], $data['summary'], $data['body'],
|
||||||
|
$data['body_format'], Database::json($data['card']),
|
||||||
Database::json($data['tags']), $data['status'], $publishedAt, self::now(),
|
Database::json($data['tags']), $data['status'], $publishedAt, self::now(),
|
||||||
];
|
];
|
||||||
if ($id === null) {
|
if ($id === null) {
|
||||||
$query = $pdo->prepare('INSERT INTO articles
|
$query = $pdo->prepare('INSERT INTO articles
|
||||||
(slug, title, category, summary, body, tags, status, published_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
(id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
|
||||||
|
VALUES (' . Database::NEXT_ARTICLE_ID . ', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
$query->execute($values);
|
$query->execute($values);
|
||||||
|
$id = (int) $pdo->lastInsertId();
|
||||||
return (int) $pdo->lastInsertId();
|
} else {
|
||||||
}
|
|
||||||
if ($old['slug'] !== $data['slug']) {
|
if ($old['slug'] !== $data['slug']) {
|
||||||
$pdo->prepare('DELETE FROM article_redirects WHERE slug = ? AND article_id = ?')->execute([$data['slug'], $id]);
|
$pdo->prepare('DELETE FROM article_redirects WHERE slug = ? AND article_id = ?')->execute([$data['slug'], $id]);
|
||||||
$pdo->prepare('INSERT INTO article_redirects (slug, article_id) VALUES (?, ?)')->execute([$old['slug'], $id]);
|
$pdo->prepare('INSERT INTO article_redirects (slug, article_id) VALUES (?, ?)')->execute([$old['slug'], $id]);
|
||||||
}
|
}
|
||||||
$query = $pdo->prepare('UPDATE articles SET slug = ?, title = ?, category = ?, summary = ?, body = ?, tags = ?,
|
$query = $pdo->prepare('UPDATE articles SET slug = ?, title = ?, summary = ?, body = ?,
|
||||||
status = ?, published_at = ?, updated_at = ?, version = version + 1 WHERE id = ? AND version = ?');
|
body_format = ?, card = ?, tags = ?, status = ?, published_at = ?, updated_at = ?, version = version + 1
|
||||||
|
WHERE id = ? AND version = ?');
|
||||||
$query->execute([...$values, $id, $version]);
|
$query->execute([...$values, $id, $version]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
|
$pdo->prepare('DELETE FROM article_category_links WHERE article_id = ?')->execute([$id]);
|
||||||
|
}
|
||||||
|
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
||||||
|
foreach ($data['categories'] as $category) {
|
||||||
|
$link->execute([$id, $category]);
|
||||||
|
}
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteArticle(int $id, int $version): void
|
||||||
|
{
|
||||||
|
Database::write(function (PDO $pdo) use ($id, $version): void {
|
||||||
|
// Keep the original seed slug even if the article has been renamed.
|
||||||
|
$deletions = $pdo->prepare('INSERT INTO article_deletions (slug, article_id)
|
||||||
|
SELECT slug, id FROM articles WHERE id = :id
|
||||||
|
UNION ALL SELECT slug, article_id FROM article_redirects WHERE article_id = :id
|
||||||
|
ON CONFLICT (slug) DO UPDATE SET article_id = excluded.article_id');
|
||||||
|
$deletions->execute(['id' => $id]);
|
||||||
|
|
||||||
|
$delete = $pdo->prepare('DELETE FROM articles WHERE id = ? AND version = ?');
|
||||||
|
$delete->execute([$id, $version]);
|
||||||
|
self::checkVersion($delete->rowCount());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function sitemapArticles(): iterable
|
public function sitemapArticles(): iterable
|
||||||
{
|
{
|
||||||
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published' AND trim(body) <> '' ORDER BY slug");
|
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
|
||||||
|
AND (trim(body) <> '' OR trim(summary) <> '' OR json_extract(card, '$.image') <> '' OR json_extract(card, '$.url') <> '')
|
||||||
|
ORDER BY slug");
|
||||||
yield from $query;
|
yield from $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +364,9 @@ final class Repository
|
|||||||
private static function decodeArticle(?array $article): ?array
|
private static function decodeArticle(?array $article): ?array
|
||||||
{
|
{
|
||||||
if ($article !== null) {
|
if ($article !== null) {
|
||||||
$article['tags'] = json_decode($article['tags'], true, flags: JSON_THROW_ON_ERROR);
|
foreach (['tags', 'categories', 'card'] as $field) {
|
||||||
|
$article[$field] = json_decode($article[$field], true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $article;
|
return $article;
|
||||||
|
|||||||
@@ -12,18 +12,44 @@ final class SiteDesign
|
|||||||
public const DEFAULT_HEADER = [
|
public const DEFAULT_HEADER = [
|
||||||
'logo' => '/assets/wordmark.webp', 'alt' => 'Laysense 来笙',
|
'logo' => '/assets/wordmark.webp', 'alt' => 'Laysense 来笙',
|
||||||
'links' => [['/', '首页'], ['/services', '产品与服务'], ['/articles', '动态'], ['/#about', '关于来笙']],
|
'links' => [['/', '首页'], ['/services', '产品与服务'], ['/articles', '动态'], ['/#about', '关于来笙']],
|
||||||
'button' => ['#contact', '联系来笙'],
|
'button' => ['/contact', '联系来笙'],
|
||||||
];
|
];
|
||||||
|
|
||||||
public const DEFAULT_FOOTER = [
|
public const DEFAULT_FOOTER = [
|
||||||
'logo' => '/assets/wordmark.webp', 'alt' => '来笙 Laysense',
|
'logo' => '/assets/original/footer-wordmark.webp', 'alt' => '来笙 Laysense',
|
||||||
|
'name' => '上海来笙信息科技有限公司',
|
||||||
|
'address' => '中国(上海)自由贸易试验区世博村路231号2单元3层328室',
|
||||||
|
'email' => 'public@laysense.cn',
|
||||||
'products_title' => '产品与服务',
|
'products_title' => '产品与服务',
|
||||||
'products' => [['/pagepan', 'PAGEPAN 小飞页'], ['/highspeaker', 'HighSpeaker DNS'], ['/sc', '软著代理服务'], ['/shnu-sc', 'SHNU 学生软著服务']],
|
'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']],
|
||||||
'company_title' => '公司',
|
'company_title' => '公司',
|
||||||
'company' => [['/#about', '关于来笙'], ['/articles', '来笙动态'], ['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
|
'company' => [['/#about', '关于来笙'], ['/contact', '联系来笙']],
|
||||||
|
'resources_title' => '资源',
|
||||||
|
'resources' => [['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
|
||||||
'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']],
|
'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']],
|
||||||
|
'copyright' => '© Shanghai Laysense Information Technology Co. Ltd. 2024',
|
||||||
|
'terms' => '本网站中产品价格仅作展示,不作为订立合同、邀约或要约邀请的有效因素。',
|
||||||
|
'registration' => '沪ICP备2024051698号-1',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static function footer(array $site): array
|
||||||
|
{
|
||||||
|
$saved = $site['footer'] ?? null;
|
||||||
|
if ($saved === null) {
|
||||||
|
return self::DEFAULT_FOOTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Older configurations store the entire footer navigation in two columns.
|
||||||
|
if (!array_key_exists('resources', $saved)) {
|
||||||
|
$saved += ['resources' => [], 'resources_title' => ''];
|
||||||
|
if (!empty($saved['copyright'])) {
|
||||||
|
$saved['copyright'] .= ' 2024–' . date('Y');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $saved + self::DEFAULT_FOOTER;
|
||||||
|
}
|
||||||
|
|
||||||
public static function parseLinks(string $value): array
|
public static function parseLinks(string $value): array
|
||||||
{
|
{
|
||||||
$links = [];
|
$links = [];
|
||||||
@@ -58,50 +84,4 @@ final class SiteDesign
|
|||||||
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function catalog(): array
|
|
||||||
{
|
|
||||||
return Database::connect()->query('SELECT * FROM catalog ORDER BY position, id')->fetchAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function product(int $id): ?array
|
|
||||||
{
|
|
||||||
$query = Database::connect()->prepare('SELECT * FROM catalog WHERE id = ?');
|
|
||||||
$query->execute([$id]);
|
|
||||||
|
|
||||||
return $query->fetch() ?: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function saveProduct(?int $id, array $product, int $version): int
|
|
||||||
{
|
|
||||||
$pdo = Database::connect();
|
|
||||||
$fields = ['name', 'category', 'body', 'image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'position'];
|
|
||||||
$values = array_map(static fn (string $field) => $product[$field], $fields);
|
|
||||||
if ($id === null) {
|
|
||||||
$pdo->prepare('INSERT INTO catalog (' . implode(', ', $fields) . ') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
||||||
->execute($values);
|
|
||||||
|
|
||||||
return (int) $pdo->lastInsertId();
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $pdo->prepare('UPDATE catalog SET ' . implode(' = ?, ', $fields) . ' = ?, version = version + 1 WHERE id = ? AND version = ?');
|
|
||||||
$query->execute([...$values, $id, $version]);
|
|
||||||
self::checkProduct($query->rowCount());
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function deleteProduct(int $id, int $version): void
|
|
||||||
{
|
|
||||||
$query = Database::connect()->prepare('DELETE FROM catalog WHERE id = ? AND version = ?');
|
|
||||||
$query->execute([$id, $version]);
|
|
||||||
self::checkProduct($query->rowCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function checkProduct(int $count): void
|
|
||||||
{
|
|
||||||
if ($count !== 1) {
|
|
||||||
throw new RuntimeException('此项目已在另一页面更新,请重新打开。');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,16 @@ final class View
|
|||||||
$html = self::fragment($template, $data);
|
$html = self::fragment($template, $data);
|
||||||
$page = Assets::rewrite(self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]), $cdn);
|
$page = Assets::rewrite(self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]), $cdn);
|
||||||
$assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
|
$assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
|
||||||
|
$articleEditor = $admin && !empty($data['articleEditor']);
|
||||||
|
$editorImages = $articleEditor ? ' data:' : '';
|
||||||
|
$editorStyles = $articleEditor ? "style-src-attr 'unsafe-inline'; " : '';
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type' => 'text/html; charset=utf-8',
|
'Content-Type' => 'text/html; charset=utf-8',
|
||||||
'X-Content-Type-Options' => 'nosniff',
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
'Referrer-Policy' => 'strict-origin-when-cross-origin',
|
'Referrer-Policy' => 'strict-origin-when-cross-origin',
|
||||||
'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
|
'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
|
||||||
'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:; media-src 'self' https:; "
|
'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:$editorImages; media-src 'self' https:; "
|
||||||
. "style-src $assetSources; script-src $assetSources; font-src $assetSources; frame-src 'self'; frame-ancestors "
|
. "style-src $assetSources; {$editorStyles}script-src $assetSources; font-src $assetSources; frame-src 'self'; frame-ancestors "
|
||||||
. (!empty($data['previewMode']) ? "'self'" : "'none'") . "; form-action 'self'; base-uri 'none'; object-src 'none'",
|
. (!empty($data['previewMode']) ? "'self'" : "'none'") . "; form-action 'self'; base-uri 'none'; object-src 'none'",
|
||||||
];
|
];
|
||||||
if ($admin || !empty($data['previewMode'])) {
|
if ($admin || !empty($data['previewMode'])) {
|
||||||
@@ -62,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'], '');
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Content\BlockTemplates;
|
||||||
use App\Content\Database;
|
use App\Content\Database;
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\Passwords;
|
use App\Content\Passwords;
|
||||||
@@ -125,22 +126,59 @@ class AdminController
|
|||||||
return $failure;
|
return $failure;
|
||||||
}
|
}
|
||||||
$page = max(1, min(10000, (int) $request->get('page', 1)));
|
$page = max(1, min(10000, (int) $request->get('page', 1)));
|
||||||
$articles = (new Repository())->articles(public: false, limit: 31, offset: ($page - 1) * 30);
|
$repo = new Repository();
|
||||||
|
$categories = $repo->categories();
|
||||||
|
$category = $request->get('category');
|
||||||
|
$category = is_string($category) && isset($categories[$category]) ? $category : null;
|
||||||
|
$articles = $repo->articles($category, public: false, limit: 31, offset: ($page - 1) * 30);
|
||||||
|
|
||||||
return $this->render($request, 'admin-articles', [
|
return $this->render($request, 'admin-articles', [
|
||||||
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page, 'hasNext' => count($articles) > 30,
|
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page,
|
||||||
|
'hasNext' => count($articles) > 30, 'categories' => $categories, 'category' => $category,
|
||||||
|
'deleted' => $request->get('deleted') === '1',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function articleCategories(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($failure = $this->guard($request)) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
$repo = new Repository();
|
||||||
|
$name = $slug = $error = '';
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
$slug = $this->input($request, 'slug');
|
||||||
|
$name = $this->input($request, 'name');
|
||||||
|
try {
|
||||||
|
if (!preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $slug) || strlen($slug) > 60 || $name === '' || mb_strlen($name) > 60) {
|
||||||
|
throw new RuntimeException('请填写分类名称及网址标识。');
|
||||||
|
}
|
||||||
|
$repo->createCategory($slug, $name);
|
||||||
|
|
||||||
|
return $this->success($request, '/admin/article-categories?saved=1');
|
||||||
|
} catch (RuntimeException $exception) {
|
||||||
|
$error = $this->validationMessage($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($request, 'admin-article-categories', [
|
||||||
|
'title' => '文章分类', 'categories' => $repo->categories(), 'name' => $name, 'slug' => $slug,
|
||||||
|
'error' => $error, 'saved' => $request->get('saved') === '1',
|
||||||
|
], $error === '' ? 200 : 422);
|
||||||
|
}
|
||||||
|
|
||||||
public function article(Request $request, ?string $id = null): Response
|
public function article(Request $request, ?string $id = null): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
return $failure;
|
return $failure;
|
||||||
}
|
}
|
||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
|
$categories = $repo->categories();
|
||||||
|
$preset = $request->get('category');
|
||||||
|
$preset = is_string($preset) && isset($categories[$preset]) ? $preset : 'news';
|
||||||
$article = $id !== null ? $repo->articleById((int) $id) : [
|
$article = $id !== null ? $repo->articleById((int) $id) : [
|
||||||
'title' => '', 'slug' => '', 'summary' => '', 'category' => 'news', 'body' => '',
|
'title' => '', 'slug' => '', 'summary' => '', 'body' => '', 'body_format' => 'markdown',
|
||||||
'tags' => [], 'status' => 'draft', 'version' => 0,
|
'categories' => [$preset => $categories[$preset]], 'card' => [], 'tags' => [], 'status' => 'draft', 'version' => 0,
|
||||||
];
|
];
|
||||||
if (!$article) {
|
if (!$article) {
|
||||||
return $this->error($request, '找不到这篇文章。', 404);
|
return $this->error($request, '找不到这篇文章。', 404);
|
||||||
@@ -148,16 +186,26 @@ class AdminController
|
|||||||
$error = '';
|
$error = '';
|
||||||
if ($request->method() === 'POST') {
|
if ($request->method() === 'POST') {
|
||||||
$data = $this->articleInput($request);
|
$data = $this->articleInput($request);
|
||||||
$article = array_replace($article, $data, ['version' => $this->version($request)]);
|
$article = array_replace($article, $data, [
|
||||||
|
'categories' => array_intersect_key($categories, array_flip($data['categories'])),
|
||||||
|
'version' => $this->version($request),
|
||||||
|
]);
|
||||||
try {
|
try {
|
||||||
if (mb_strlen($data['title']) < 1 || mb_strlen($data['title']) > 120
|
if (mb_strlen($data['title']) < 1 || mb_strlen($data['title']) > 120
|
||||||
|| !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $data['slug']) || strlen($data['slug']) > 100
|
|| !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $data['slug']) || strlen($data['slug']) > 100
|
||||||
|| mb_strlen($data['summary']) > 250 || strlen($data['body']) > 200000
|
|| mb_strlen($data['summary']) > 250 || strlen($data['body']) > 200000
|
||||||
|| !isset(Repository::CATEGORIES[$data['category']])
|
|| $data['categories'] === [] || array_diff($data['categories'], array_keys($categories))
|
||||||
|
|| !in_array($data['body_format'], ['markdown', 'html'], true)
|
||||||
|| !in_array($data['status'], ['draft', 'published'], true)) {
|
|| !in_array($data['status'], ['draft', 'published'], true)) {
|
||||||
throw new RuntimeException('请检查标题、网址标识、分类、摘要和正文长度。');
|
throw new RuntimeException('请检查标题、网址标识、分类、摘要和正文长度。');
|
||||||
}
|
}
|
||||||
if ($data['status'] === 'published' && trim(Html::markdown($data['body'])) === '') {
|
$this->checkArticleCard($data['card']);
|
||||||
|
if ($data['body_format'] === 'html') {
|
||||||
|
$data['body'] = Html::sanitize($data['body']);
|
||||||
|
}
|
||||||
|
if ($data['status'] === 'published' && trim(Html::articleBody($data)) === ''
|
||||||
|
&& (!array_intersect($data['categories'], array_keys(Repository::DIRECTORIES))
|
||||||
|
|| ($data['summary'] === '' && empty($data['card']['url']) && empty($data['card']['image'])))) {
|
||||||
throw new RuntimeException('发布前请填写文章正文。');
|
throw new RuntimeException('发布前请填写文章正文。');
|
||||||
}
|
}
|
||||||
$saved = $repo->saveArticle($id === null ? null : (int) $id, $data, $this->version($request));
|
$saved = $repo->saveArticle($id === null ? null : (int) $id, $data, $this->version($request));
|
||||||
@@ -170,10 +218,25 @@ class AdminController
|
|||||||
|
|
||||||
return $this->render($request, 'admin-article', [
|
return $this->render($request, 'admin-article', [
|
||||||
'title' => $id === null ? '新建文章' : '编辑文章', 'article' => $article, 'error' => $error,
|
'title' => $id === null ? '新建文章' : '编辑文章', 'article' => $article, 'error' => $error,
|
||||||
'articleId' => $id, 'saved' => $request->get('saved') === '1',
|
'articleId' => $id, 'categories' => $categories, 'articleEditor' => true, 'saved' => $request->get('saved') === '1',
|
||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteArticle(Request $request, string $id): Response
|
||||||
|
{
|
||||||
|
if ($failure = $this->guard($request)) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
(new Repository())->deleteArticle((int) $id, $this->version($request));
|
||||||
|
} catch (RuntimeException $exception) {
|
||||||
|
return $this->error($request, $this->validationMessage($exception), $exception instanceof \PDOException ? 500 : 409);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->success($request, '/admin/articles?deleted=1');
|
||||||
|
}
|
||||||
|
|
||||||
public function page(Request $request, string $slug): Response
|
public function page(Request $request, string $slug): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
@@ -192,6 +255,9 @@ class AdminController
|
|||||||
}
|
}
|
||||||
$data['name'] = $request->post('name') === null ? $page['name'] : $this->input($request, 'name');
|
$data['name'] = $request->post('name') === null ? $page['name'] : $this->input($request, 'name');
|
||||||
$data['status'] = $request->post('status') === null || $slug === 'home' ? $page['status'] : $this->input($request, 'status');
|
$data['status'] = $request->post('status') === null || $slug === 'home' ? $page['status'] : $this->input($request, 'status');
|
||||||
|
$scale = $this->input($request, 'image_scale');
|
||||||
|
$data['image_scale'] = $request->post('image_scale') === null ? (int) $page['image_scale']
|
||||||
|
: (ctype_digit($scale) ? (int) $scale : -1);
|
||||||
$data['actions'] = [];
|
$data['actions'] = [];
|
||||||
$validButtons = true;
|
$validButtons = true;
|
||||||
foreach ([1, 2] as $index) {
|
foreach ([1, 2] as $index) {
|
||||||
@@ -205,16 +271,21 @@ 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 ||
|
||||||
($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
|
($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
|
||||||
$data['heading'] === '' || mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
$data['heading'] === '' || mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
||||||
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
|
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
|
||||||
|
($data['image_scale'] !== 0 && ($data['image_scale'] < 10 || $data['image_scale'] > 100)) ||
|
||||||
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true)) || !$validButtons) {
|
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true)) || !$validButtons) {
|
||||||
throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
|
throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
|
||||||
}
|
}
|
||||||
$repo->savePage($slug, $data, $this->version($request));
|
$sections = $this->canvasSections($request->post('canvas_sections', ''), $page['sections'], $repo->categories());
|
||||||
|
$repo->savePage($slug, $data, $this->version($request), $sections);
|
||||||
|
|
||||||
return $this->success($request, '/admin/pages/' . $slug . '?saved=1');
|
return $this->success($request, '/admin/pages/' . $slug . '?saved=1');
|
||||||
} catch (RuntimeException $exception) {
|
} catch (RuntimeException $exception) {
|
||||||
@@ -223,7 +294,7 @@ class AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($request, 'admin-page', [
|
return $this->render($request, 'admin-page', [
|
||||||
'title' => '编辑 ' . $page['name'], 'page' => $page, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
'title' => '编辑 ' . $page['name'], 'page' => $page, 'categories' => $repo->categories(), 'wideAdmin' => true, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,19 +309,21 @@ class AdminController
|
|||||||
return $this->error($request, '找不到此区块。', 404);
|
return $this->error($request, '找不到此区块。', 404);
|
||||||
}
|
}
|
||||||
$savedStyle = $section['style'];
|
$savedStyle = $section['style'];
|
||||||
|
$categories = $repo->categories();
|
||||||
$error = '';
|
$error = '';
|
||||||
if ($request->method() === 'POST') {
|
if ($request->method() === 'POST') {
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
|
'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
|
||||||
'body' => $this->input($request, 'body'),
|
'body' => $this->input($request, 'body'),
|
||||||
'style' => $request->post('style') === null ? $section['style'] : $this->input($request, 'style'),
|
'style' => $savedStyle === 'hero-links' || $request->post('style') === null ? $savedStyle : $this->input($request, 'style'),
|
||||||
|
'feed' => $section['feed'],
|
||||||
];
|
];
|
||||||
$section = array_replace($section, $data, ['version' => $this->version($request)]);
|
$section = array_replace($section, $data, ['version' => $this->version($request)]);
|
||||||
try {
|
try {
|
||||||
if ($data['title'] === '' || mb_strlen($data['title']) > 100 || mb_strlen($data['lead']) > 500 || strlen($data['body']) > 300000
|
if ($savedStyle !== 'hero-links' && $request->post('feed_mode') !== null) {
|
||||||
|| !in_array($data['style'], [$savedStyle, 'plain', 'tinted'], true)) {
|
$data['feed'] = $section['feed'] = $this->feedInput($request, $categories);
|
||||||
throw new RuntimeException('请填写区块标题,并检查说明及正文长度。');
|
|
||||||
}
|
}
|
||||||
|
$this->checkSection($data, $savedStyle);
|
||||||
$data['body'] = Html::sanitize($data['body']);
|
$data['body'] = Html::sanitize($data['body']);
|
||||||
$repo->saveSection($slug, $key, $data, $this->version($request));
|
$repo->saveSection($slug, $key, $data, $this->version($request));
|
||||||
|
|
||||||
@@ -261,10 +334,112 @@ class AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($request, 'admin-section', [
|
return $this->render($request, 'admin-section', [
|
||||||
'title' => '编辑区块', 'section' => $section, 'savedStyle' => $savedStyle, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
'title' => '编辑区块', 'section' => $section, 'categories' => $categories, 'savedStyle' => $savedStyle, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function canvasSections(mixed $payload, array $sections, array $categories): array
|
||||||
|
{
|
||||||
|
if ($payload === '') {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$changes = is_string($payload) ? json_decode($payload, true) : null;
|
||||||
|
if (!is_array($changes) || !array_is_list($changes) || count($changes) > count($sections) + 50) {
|
||||||
|
throw new RuntimeException('区块已变更或画布内容无效,请重新打开编辑页。');
|
||||||
|
}
|
||||||
|
$available = array_column($sections, null, 'key');
|
||||||
|
$updates = [];
|
||||||
|
foreach ($changes as $change) {
|
||||||
|
$key = $change['key'] ?? null;
|
||||||
|
$version = $change['version'] ?? null;
|
||||||
|
$fields = $change['fields'] ?? [];
|
||||||
|
$alignments = $change['alignments'] ?? null;
|
||||||
|
$feed = $change['feed'] ?? null;
|
||||||
|
$delete = ($change['delete'] ?? false) === true;
|
||||||
|
$isNew = is_array($change) && array_key_exists('version', $change) && $version === null;
|
||||||
|
if (!is_string($key) || isset($updates[$key]) || !is_array($fields) || (!$delete && $fields === [] && $alignments === null && $feed === null)
|
||||||
|
|| ($isNew ? (isset($available[$key]) || !preg_match('/^block-[a-f0-9]{32}$/D', $key))
|
||||||
|
: (!isset($available[$key]) || !is_int($version) || $version !== (int) $available[$key]['version']))) {
|
||||||
|
throw new RuntimeException('区块已变更或画布内容无效,请重新打开编辑页。');
|
||||||
|
}
|
||||||
|
if ($delete) {
|
||||||
|
if ($isNew || empty($available[$key]['feed'])) {
|
||||||
|
throw new RuntimeException('此区块不能通过模块工具删除。');
|
||||||
|
}
|
||||||
|
$updates[$key] = compact('key', 'version', 'delete');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$section = $available[$key] ?? ['key' => $key, 'title' => '', 'lead' => '', 'body' => '', 'style' => 'plain'];
|
||||||
|
if ($isNew && isset($change['template'])) {
|
||||||
|
$preset = is_string($change['template']) ? BlockTemplates::find($change['template']) : null;
|
||||||
|
if ($preset === null) {
|
||||||
|
throw new RuntimeException('区块模板已失效。');
|
||||||
|
}
|
||||||
|
$section['feed'] = $preset[3] ?? null;
|
||||||
|
$section['style'] = $preset[4] ?? 'plain';
|
||||||
|
}
|
||||||
|
if ($isNew && isset($change['copyOf'])) {
|
||||||
|
$source = $change['copyOf']['key'] ?? null;
|
||||||
|
$sourceVersion = $change['copyOf']['version'] ?? null;
|
||||||
|
if (!is_string($source) || empty($available[$source]['feed']) || $sourceVersion !== (int) $available[$source]['version']) {
|
||||||
|
throw new RuntimeException('原模块已变更,请刷新画布后再复制。');
|
||||||
|
}
|
||||||
|
$section = array_replace($available[$source], ['key' => $key]);
|
||||||
|
}
|
||||||
|
if ($feed !== null) {
|
||||||
|
if (!is_array($feed) || empty($section['feed'])) {
|
||||||
|
throw new RuntimeException('模块设置不正确。');
|
||||||
|
}
|
||||||
|
$section['feed'] = $this->encodeFeed($feed['mode'] ?? null, $feed['categories'] ?? null, $feed['limit'] ?? null, $categories);
|
||||||
|
}
|
||||||
|
foreach ($fields as $field => $value) {
|
||||||
|
if (!in_array($field, ['title', 'lead', 'body'], true)) {
|
||||||
|
throw new RuntimeException('画布内容无效。');
|
||||||
|
}
|
||||||
|
if ($field === 'body' && is_array($value)) {
|
||||||
|
$value = Html::applyCanvasEdits($section['body'], $value);
|
||||||
|
}
|
||||||
|
if (!is_string($value)) {
|
||||||
|
throw new RuntimeException('画布内容无效。');
|
||||||
|
}
|
||||||
|
$section[$field] = trim($value);
|
||||||
|
}
|
||||||
|
if ($alignments !== null) {
|
||||||
|
$section['alignments'] = Database::json($this->alignmentMap($alignments, ['title', 'lead']));
|
||||||
|
}
|
||||||
|
$this->checkSection($section, $section['style']);
|
||||||
|
if (isset($fields['body'])) {
|
||||||
|
$section['body'] = Html::sanitize($section['body']);
|
||||||
|
}
|
||||||
|
$section['version'] = $version;
|
||||||
|
$updates[$key] = $section;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if ($section['title'] === '' || mb_strlen($section['title']) > 100 || mb_strlen($section['lead']) > 500
|
||||||
|
|| strlen($section['body']) > 300000 || !in_array($section['style'], [$savedStyle, 'plain', 'tinted'], true)) {
|
||||||
|
throw new RuntimeException('请填写区块标题,并检查说明及正文长度。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function preview(Request $request): Response
|
public function preview(Request $request): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
@@ -368,9 +543,14 @@ class AdminController
|
|||||||
private function articleInput(Request $request): array
|
private function articleInput(Request $request): array
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach (['title', 'slug', 'category', 'summary', 'body', 'status'] as $key) {
|
foreach (['title', 'slug', 'summary', 'body', 'status'] as $key) {
|
||||||
$data[$key] = $this->input($request, $key);
|
$data[$key] = $this->input($request, $key);
|
||||||
}
|
}
|
||||||
|
$data['body_format'] = $this->input($request, 'body_format');
|
||||||
|
$data['categories'] = $this->selectedCategories($request->post('categories'));
|
||||||
|
foreach (['image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'category_label', 'position'] as $field) {
|
||||||
|
$data['card'][$field] = $this->input($request, 'card_' . $field);
|
||||||
|
}
|
||||||
$tags = preg_split('/[,,\r\n]+/u', $this->input($request, 'tags'));
|
$tags = preg_split('/[,,\r\n]+/u', $this->input($request, 'tags'));
|
||||||
$data['tags'] = array_values(array_unique(array_slice(array_filter(
|
$data['tags'] = array_values(array_unique(array_slice(array_filter(
|
||||||
array_map('trim', $tags),
|
array_map('trim', $tags),
|
||||||
@@ -380,6 +560,50 @@ class AdminController
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkArticleCard(array &$card): void
|
||||||
|
{
|
||||||
|
foreach (['image', 'url', 'extra_url'] as $field) {
|
||||||
|
if (!empty($card[$field]) && (strlen($card[$field]) > 2000 || !Html::url($card[$field], $field === 'image'))) {
|
||||||
|
throw new RuntimeException('请检查目录卡片的媒体地址和链接。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (['alt', 'label', 'extra_label', 'category_label'] as $field) {
|
||||||
|
if (mb_strlen($card[$field] ?? '') > 120) {
|
||||||
|
throw new RuntimeException('目录卡片的文字不得超过 120 字。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$position = filter_var(($card['position'] ?? '') === '' ? 0 : $card['position'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 9999]]);
|
||||||
|
if ($position === false) {
|
||||||
|
throw new RuntimeException('目录排序应为 0 到 9999 的整数。');
|
||||||
|
}
|
||||||
|
$card['position'] = $position;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectedCategories(mixed $input): array
|
||||||
|
{
|
||||||
|
return is_array($input) ? array_values(array_unique(array_filter($input, 'is_string'))) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function feedInput(Request $request, array $available): ?string
|
||||||
|
{
|
||||||
|
$mode = $this->input($request, 'feed_mode');
|
||||||
|
if ($mode === 'off') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $this->encodeFeed($mode, $request->post('feed_categories'), $this->input($request, 'feed_limit'), $available);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function encodeFeed(mixed $mode, mixed $selected, mixed $value, array $available): string
|
||||||
|
{
|
||||||
|
$categories = $this->selectedCategories($selected);
|
||||||
|
$limit = filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]);
|
||||||
|
if (!in_array($mode, ['merged', 'tabs', 'network', 'catalog'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
|
||||||
|
throw new RuntimeException('请选择文章分类,并将展示数量设为 1 至 30。');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Database::json(compact('categories', 'mode', 'limit'));
|
||||||
|
}
|
||||||
|
|
||||||
protected function validationMessage(RuntimeException $exception): string
|
protected function validationMessage(RuntimeException $exception): string
|
||||||
{
|
{
|
||||||
if ($exception instanceof \PDOException) {
|
if ($exception instanceof \PDOException) {
|
||||||
@@ -416,7 +640,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
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\Repository;
|
use App\Content\Repository;
|
||||||
use App\Content\SiteDesign;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
@@ -25,13 +24,50 @@ final class SiteController
|
|||||||
if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
|
if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
|
||||||
return $this->missing($request);
|
return $this->missing($request);
|
||||||
}
|
}
|
||||||
|
if ($slug === 'articles' && $request->get('page') !== null) {
|
||||||
|
foreach ($page['sections'] as $section) {
|
||||||
|
$feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if (in_array($feed['mode'] ?? null, ['merged', 'tabs'], true)) {
|
||||||
|
return $this->feedArchive($request, $slug, $section['key']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->missing($request);
|
||||||
|
}
|
||||||
return $this->renderPage($repo, $page);
|
return $this->renderPage($repo, $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderPage(Repository $repo, array $page, bool $preview = false): Response
|
public function renderPage(Repository $repo, array $page, bool $preview = false, bool $canvas = false): Response
|
||||||
{
|
{
|
||||||
$slug = $page['slug'];
|
$slug = $page['slug'];
|
||||||
$isHome = $slug === 'home';
|
$isHome = $slug === 'home';
|
||||||
|
$categories = $repo->categories();
|
||||||
|
foreach ($page['sections'] as &$section) {
|
||||||
|
if (!$section['feed']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
$network = $feed['mode'] === 'network';
|
||||||
|
$catalog = $feed['mode'] === 'catalog';
|
||||||
|
$grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1);
|
||||||
|
$archivePath = '/articles/feed/' . $slug . '/' . $section['key'];
|
||||||
|
if ($network && count($feed['categories']) === 2 && !array_diff($feed['categories'], ['supported-projects', 'partners'])) {
|
||||||
|
$archivePath = '/network';
|
||||||
|
}
|
||||||
|
$section['archivePath'] = $page['status'] === 'published' ? $archivePath : null;
|
||||||
|
$section['articleFeed'] = [];
|
||||||
|
$section['networkFeed'] = $network;
|
||||||
|
$section['catalogFeed'] = $catalog;
|
||||||
|
$section['feedLimit'] = $feed['limit'];
|
||||||
|
foreach ($grouped ? $feed['categories'] : [''] as $category) {
|
||||||
|
$selected = $category === '' ? $feed['categories'] : [$category];
|
||||||
|
$section['articleFeed'][] = [
|
||||||
|
'categories' => $selected, 'label' => $categories[$category] ?? '',
|
||||||
|
'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network || $catalog),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($section);
|
||||||
|
|
||||||
return View::render('page', [
|
return View::render('page', [
|
||||||
'site' => $repo->site(),
|
'site' => $repo->site(),
|
||||||
@@ -41,42 +77,109 @@ final class SiteController
|
|||||||
'description' => $page['description'],
|
'description' => $page['description'],
|
||||||
'socialImage' => $page['image'],
|
'socialImage' => $page['image'],
|
||||||
'socialAlt' => $page['alt'],
|
'socialAlt' => $page['alt'],
|
||||||
'articles' => $isHome ? $repo->articles(limit: 3) : [],
|
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
|
||||||
'previewMode' => $preview, 'noindex' => $preview,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function services(Request $request): Response
|
public function network(Request $request): Response
|
||||||
{
|
{
|
||||||
return View::render('services', [
|
$repo = new Repository();
|
||||||
'site' => (new Repository())->site(), 'path' => '/services',
|
|
||||||
'title' => '产品与服务 · 来笙 Laysense',
|
return View::render('network', [
|
||||||
'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。',
|
'site' => $repo->site(), 'path' => '/network', 'title' => '支持项目与合作伙伴 · 来笙',
|
||||||
'products' => SiteDesign::catalog(),
|
'description' => '浏览来笙支持的开源项目和合作伙伴。', 'network' => $this->networkGroups($repo),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function networkGroups(Repository $repo): array
|
||||||
|
{
|
||||||
|
$groups = [];
|
||||||
|
foreach (array_diff_key(Repository::DIRECTORIES, ['services' => true]) as $slug => $name) {
|
||||||
|
$groups[$slug] = ['name' => $name, 'articles' => $repo->articles($slug, limit: -1, directoryOrder: true)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
|
public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
|
||||||
{
|
{
|
||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
$title = $category ? Repository::CATEGORIES[$category] : ($tag ?: '来笙动态');
|
$categories = $repo->categories();
|
||||||
|
if ($category !== null && !isset($categories[$category])) {
|
||||||
|
return $this->missing($request);
|
||||||
|
}
|
||||||
|
$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],
|
||||||
|
'catalog' => $feed['mode'] === 'catalog',
|
||||||
|
'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);
|
||||||
}
|
}
|
||||||
$page = (int) $number;
|
$page = (int) $number;
|
||||||
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20);
|
$articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20, directoryOrder: $view['catalog'] ?? false);
|
||||||
if ($page > 1 && $articles === []) {
|
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),
|
||||||
'category' => $category, 'tag' => $tag, 'pageNumber' => $page,
|
|
||||||
'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
|
|
||||||
'noindex' => $articles === [],
|
'noindex' => $articles === [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -100,13 +203,15 @@ final class SiteController
|
|||||||
|
|
||||||
return $redirect ? View::redirect('/articles/' . $redirect['slug'], 301) : $this->missing($request);
|
return $redirect ? View::redirect('/articles/' . $redirect['slug'], 301) : $this->missing($request);
|
||||||
}
|
}
|
||||||
$articleHtml = Html::markdown($article['body']);
|
$articleHtml = Html::articleBody($article);
|
||||||
|
|
||||||
return View::render('article', [
|
return View::render('article', [
|
||||||
'site' => $repo->site(), 'article' => $article, 'articleHtml' => $articleHtml,
|
'site' => $repo->site(), 'article' => $article, 'articleHtml' => $articleHtml,
|
||||||
'title' => $article['title'] . ' · 来笙',
|
'title' => $article['title'] . ' · 来笙',
|
||||||
'description' => $article['summary'] ?: mb_substr(trim(strip_tags($articleHtml)), 0, 150) ?: $article['title'],
|
'description' => $article['summary'] ?: mb_substr(trim(strip_tags($articleHtml)), 0, 150) ?: $article['title'],
|
||||||
'path' => '/articles/' . $article['slug'], 'noindex' => trim($articleHtml) === '',
|
'path' => '/articles/' . $article['slug'],
|
||||||
|
'socialImage' => $article['card']['image'] ?? '', 'socialAlt' => $article['card']['alt'] ?? '',
|
||||||
|
'noindex' => trim($articleHtml) === '' && !$article['summary'] && empty($article['card']['url']) && empty($article['card']['image']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,10 +242,7 @@ final class SiteController
|
|||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
|
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
|
||||||
$pages = $repo->pages(publishedOnly: true);
|
$pages = $repo->pages(publishedOnly: true);
|
||||||
$pages[] = ['slug' => 'services', 'updated_at' => null];
|
$pages[] = ['slug' => 'network', 'updated_at' => null];
|
||||||
if ($repo->articles(limit: 1)) {
|
|
||||||
$pages[] = ['slug' => 'articles', 'updated_at' => null];
|
|
||||||
}
|
|
||||||
foreach ($pages as $page) {
|
foreach ($pages as $page) {
|
||||||
$xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']);
|
$xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']);
|
||||||
}
|
}
|
||||||
@@ -165,7 +267,7 @@ final class SiteController
|
|||||||
$normal = rtrim($path, '/');
|
$normal = rtrim($path, '/');
|
||||||
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
|
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
|
||||||
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
|
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
|
||||||
if ($known || $normal === '/services' || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) {
|
if ($known || $normal === '/network' || preg_match('~^/articles(?:/[a-z0-9-]+){1,2}$~D', $normal)) {
|
||||||
$query = $request->queryString();
|
$query = $request->queryString();
|
||||||
|
|
||||||
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
|
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Content\Assets;
|
use App\Content\Assets;
|
||||||
|
use App\Content\BlockTemplates;
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\Media;
|
use App\Content\Media;
|
||||||
use App\Content\Repository;
|
use App\Content\Repository;
|
||||||
@@ -16,13 +17,6 @@ use Webman\Http\UploadFile;
|
|||||||
|
|
||||||
final class StudioController extends AdminController
|
final class StudioController extends AdminController
|
||||||
{
|
{
|
||||||
private const BLOCKS = [
|
|
||||||
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
|
||||||
'image' => ['图文', '<p>介绍图片内容,然后从媒体库插入图片。</p>'],
|
|
||||||
'cta' => ['行动按钮', '<p>说明下一步。</p><p><a class="button button-primary" href="#contact">联系来笙</a></p>'],
|
|
||||||
'faq' => ['常见问题', '<div class="faq"><details><summary>请输入问题</summary><div><p>请输入答案。</p></div></details></div>'],
|
|
||||||
];
|
|
||||||
|
|
||||||
public function newPage(Request $request): Response
|
public function newPage(Request $request): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
@@ -33,7 +27,7 @@ final class StudioController extends AdminController
|
|||||||
$data['name'] = $this->input($request, 'name');
|
$data['name'] = $this->input($request, 'name');
|
||||||
$data['slug'] = $this->input($request, 'slug');
|
$data['slug'] = $this->input($request, 'slug');
|
||||||
try {
|
try {
|
||||||
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'news', 'main', 'favicon'], true)
|
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'home', 'network', 'news', 'main', 'favicon'], true)
|
||||||
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
|
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
|
||||||
throw new RuntimeException('请填写页面名称及可用的网址标识。');
|
throw new RuntimeException('请填写页面名称及可用的网址标识。');
|
||||||
}
|
}
|
||||||
@@ -56,7 +50,7 @@ final class StudioController extends AdminController
|
|||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
$page = $repo->page($slug);
|
$page = $repo->page($slug);
|
||||||
|
|
||||||
return $page ? (new SiteController())->renderPage($repo, $page, true) : $this->error($request, '找不到此页面。', 404);
|
return $page ? (new SiteController())->renderPage($repo, $page, true, $request->get('canvas') === '1') : $this->error($request, '找不到此页面。', 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function blocks(Request $request, string $slug): Response
|
public function blocks(Request $request, string $slug): Response
|
||||||
@@ -71,22 +65,24 @@ final class StudioController extends AdminController
|
|||||||
$action = $this->input($request, 'operation');
|
$action = $this->input($request, 'operation');
|
||||||
$key = $this->input($request, 'key');
|
$key = $this->input($request, 'key');
|
||||||
try {
|
try {
|
||||||
if (!$this->slug($key) || in_array($key, ['preview', 'home', 'contact', 'main-content', 'blog', 'partners', 'supported-projects'], true)) {
|
if (!$this->slug($key) || in_array($key, ['preview', 'home', 'contact', 'main-content', 'partners', 'supported-projects'], true)) {
|
||||||
throw new RuntimeException('区块锚点不可用。');
|
throw new RuntimeException('区块锚点不可用。');
|
||||||
}
|
}
|
||||||
if ($action === 'create') {
|
if ($action === 'create') {
|
||||||
$preset = self::BLOCKS[$this->input($request, 'preset')] ?? null;
|
$type = $this->input($request, 'preset');
|
||||||
|
$preset = BlockTemplates::find($type);
|
||||||
if ($preset === null) {
|
if ($preset === null) {
|
||||||
throw new RuntimeException('请选择区块类型。');
|
throw new RuntimeException('请选择区块类型。');
|
||||||
}
|
}
|
||||||
$repo->createSection($slug, $key, $preset[0], 'plain', $preset[1]);
|
$repo->createSection($slug, $key, $preset[0], $preset[4] ?? 'plain', Html::sanitize($preset[1], $key), $preset[3] ?? null, $preset[2] ?? '');
|
||||||
|
|
||||||
return $this->success($request, "/admin/pages/$slug/$key");
|
return $this->success($request, "/admin/pages/$slug/$key");
|
||||||
}
|
}
|
||||||
if (!in_array($action, ['up', 'down', 'delete'], true)) {
|
if (!in_array($action, ['up', 'down', 'delete'], true)) {
|
||||||
throw new RuntimeException('操作不可用。');
|
throw new RuntimeException('操作不可用。');
|
||||||
}
|
}
|
||||||
$repo->arrangeSection($slug, $key, $action, $this->version($request));
|
$pageVersion = $this->input($request, 'page_version');
|
||||||
|
$repo->arrangeSection($slug, $key, $action, $this->version($request), ctype_digit($pageVersion) ? (int) $pageVersion : -1);
|
||||||
|
|
||||||
return $this->success($request, "/admin/pages/$slug#blocks");
|
return $this->success($request, "/admin/pages/$slug#blocks");
|
||||||
} catch (RuntimeException $error) {
|
} catch (RuntimeException $error) {
|
||||||
@@ -102,15 +98,16 @@ final class StudioController extends AdminController
|
|||||||
$site = (new Repository())->site();
|
$site = (new Repository())->site();
|
||||||
$defaults = match ($part) {
|
$defaults = match ($part) {
|
||||||
'header' => SiteDesign::DEFAULT_HEADER,
|
'header' => SiteDesign::DEFAULT_HEADER,
|
||||||
'footer' => SiteDesign::DEFAULT_FOOTER + array_intersect_key($site, array_flip(['name', 'address', 'email', 'copyright', 'registration', 'terms'])),
|
'footer' => SiteDesign::DEFAULT_FOOTER,
|
||||||
'cdn' => ['origin' => ''],
|
'cdn' => ['origin' => ''],
|
||||||
};
|
};
|
||||||
$config = ($site[$part] ?? []) + $defaults;
|
$config = $part === 'footer' ? SiteDesign::footer($site) : ($site[$part] ?? []) + $defaults;
|
||||||
$version = $site['revisions'][$part] ?? 0;
|
$version = $site['revisions'][$part] ?? 0;
|
||||||
$error = '';
|
$error = '';
|
||||||
if ($request->method() === 'POST') {
|
if ($request->method() === 'POST') {
|
||||||
try {
|
try {
|
||||||
$config = $this->settingsInput($request, $part, $defaults);
|
$config = $part === 'footer' && $request->post('operation') === 'restore-footer'
|
||||||
|
? $defaults : $this->settingsInput($request, $part, $defaults, $config);
|
||||||
SiteDesign::saveSettings($part, $config, $this->version($request));
|
SiteDesign::saveSettings($part, $config, $this->version($request));
|
||||||
|
|
||||||
return $this->success($request, '/admin/settings/' . $part . '?saved=1');
|
return $this->success($request, '/admin/settings/' . $part . '?saved=1');
|
||||||
@@ -126,53 +123,6 @@ final class StudioController extends AdminController
|
|||||||
], $error === '' ? 200 : 422);
|
], $error === '' ? 200 : 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function catalog(Request $request): Response
|
|
||||||
{
|
|
||||||
if ($failure = $this->guard($request)) {
|
|
||||||
return $failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render($request, 'studio-catalog', ['title' => '产品与服务', 'products' => SiteDesign::catalog()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function product(Request $request, ?string $id = null): Response
|
|
||||||
{
|
|
||||||
if ($failure = $this->guard($request)) {
|
|
||||||
return $failure;
|
|
||||||
}
|
|
||||||
$fields = ['name', 'category', 'body', 'image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'position'];
|
|
||||||
$product = $id !== null ? SiteDesign::product((int) $id) : array_fill_keys($fields, '') + ['version' => 0];
|
|
||||||
if (!$product) {
|
|
||||||
return $this->error($request, '找不到此产品或服务。', 404);
|
|
||||||
}
|
|
||||||
$error = '';
|
|
||||||
if ($request->method() === 'POST') {
|
|
||||||
try {
|
|
||||||
if ($id !== null && $this->input($request, 'operation') === 'delete') {
|
|
||||||
SiteDesign::deleteProduct((int) $id, $this->version($request));
|
|
||||||
|
|
||||||
return $this->success($request, '/admin/catalog');
|
|
||||||
}
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$product[$field] = $this->input($request, $field);
|
|
||||||
}
|
|
||||||
$product['version'] = $this->version($request);
|
|
||||||
$this->checkProduct($product);
|
|
||||||
$product['body'] = Html::sanitize($product['body']);
|
|
||||||
$savedId = SiteDesign::saveProduct($id === null ? null : (int) $id, $product, $product['version']);
|
|
||||||
|
|
||||||
return $this->success($request, '/admin/catalog/' . $savedId . '?saved=1');
|
|
||||||
} catch (RuntimeException $exception) {
|
|
||||||
$error = $this->validationMessage($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render($request, 'studio-product', [
|
|
||||||
'title' => $id === null ? '添加产品或服务' : '编辑产品或服务', 'product' => $product,
|
|
||||||
'id' => $id, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
|
||||||
], $error === '' ? 200 : 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function media(Request $request): Response
|
public function media(Request $request): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
@@ -228,13 +178,18 @@ final class StudioController extends AdminController
|
|||||||
return $this->success($request, '/admin/media');
|
return $this->success($request, '/admin/media');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function settingsInput(Request $request, string $part, array $defaults): array
|
private function settingsInput(Request $request, string $part, array $defaults, array $current): array
|
||||||
{
|
{
|
||||||
if ($part === 'cdn') {
|
if ($part === 'cdn') {
|
||||||
return ['origin' => Assets::cdn($this->input($request, 'origin'))];
|
return ['origin' => Assets::cdn($this->input($request, 'origin'))];
|
||||||
}
|
}
|
||||||
$result = [];
|
$result = [];
|
||||||
|
$hasResources = $request->post('resources') !== null;
|
||||||
foreach ($defaults as $key => $default) {
|
foreach ($defaults as $key => $default) {
|
||||||
|
if ($part === 'footer' && !$hasResources && in_array($key, ['resources', 'resources_title'], true)) {
|
||||||
|
$result[$key] = $current[$key];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$input = $this->input($request, $key);
|
$input = $this->input($request, $key);
|
||||||
if (is_array($default)) {
|
if (is_array($default)) {
|
||||||
$result[$key] = SiteDesign::parseLinks($input);
|
$result[$key] = SiteDesign::parseLinks($input);
|
||||||
@@ -261,23 +216,6 @@ final class StudioController extends AdminController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkProduct(array $item): void
|
|
||||||
{
|
|
||||||
if ($item['name'] === '' || mb_strlen($item['name']) > 100 || $item['category'] === '' || mb_strlen($item['category']) > 70
|
|
||||||
|| strlen($item['body']) > 300000 || strlen($item['image']) > 1000 || mb_strlen($item['alt']) > 200
|
|
||||||
|| ($item['image'] !== '' && !Html::url($item['image'], true)) || !preg_match('/^-?\d{1,6}$/D', $item['position'])) {
|
|
||||||
throw new RuntimeException('请检查名称、分类、简介、封面及排序字段。');
|
|
||||||
}
|
|
||||||
foreach ([['url', 'label'], ['extra_url', 'extra_label']] as [$href, $label]) {
|
|
||||||
if ($href === 'extra_url' && $item[$href] === '' && $item[$label] === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strlen($item[$href]) > 1000 || !Html::url($item[$href]) || $item[$label] === '' || mb_strlen($item[$label]) > 70) {
|
|
||||||
throw new RuntimeException('请填写按钮文案和有效链接。');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function slug(string $value): bool
|
private function slug(string $value): bool
|
||||||
{
|
{
|
||||||
return strlen($value) <= 70 && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value) === 1;
|
return strlen($value) <= 70 && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value) === 1;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<a class="back-link" href="/admin/articles">返回文章列表</a>
|
||||||
|
<header class="admin-heading"><h1>文章分类</h1></header>
|
||||||
|
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||||
|
<form class="admin-form admin-panel" method="post" action="/admin/article-categories">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>分类名称<input name="name" value="<?= $e($name) ?>" required maxlength="60"></label>
|
||||||
|
<label>网址标识<input name="slug" value="<?= $e($slug) ?>" required maxlength="60" pattern="[a-z0-9]+(-[a-z0-9]+)*"></label>
|
||||||
|
</div>
|
||||||
|
<div class="form-submit"><button class="button button-primary" type="submit">创建分类</button></div>
|
||||||
|
</form>
|
||||||
|
<nav class="filter-nav" aria-label="查看分类">
|
||||||
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
|
<a href="/admin/articles?category=<?= $e($key) ?>"><?= $e($label) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</nav>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -9,7 +8,7 @@ $e = View::escape(...);
|
|||||||
<?php foreach ($articles as $item): ?>
|
<?php foreach ($articles as $item): ?>
|
||||||
<li>
|
<li>
|
||||||
<div><strong><?= $e($item['title']) ?></strong>
|
<div><strong><?= $e($item['title']) ?></strong>
|
||||||
<small><?= $e(Repository::CATEGORIES[$item['category']]) ?> · <?= $item['status'] === 'published' ? '已发布' : '草稿' ?> · <?= $e(View::date($item['updated_at'])) ?></small>
|
<small><?= $e(implode('、', $item['categories'])) ?> · <?= $item['status'] === 'published' ? '已发布' : '草稿' ?> · <?= $e(View::date($item['updated_at'])) ?></small>
|
||||||
</div>
|
</div>
|
||||||
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>">编辑文章</a>
|
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>">编辑文章</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -16,17 +16,33 @@ $e = View::escape(...);
|
|||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
||||||
<label>文章标题<input name="title" value="<?= $e($article['title']) ?>" required maxlength="120"></label>
|
<label>文章标题<input name="title" value="<?= $e($article['title']) ?>" required maxlength="120"></label>
|
||||||
<div class="form-grid">
|
|
||||||
<label>网址标识<input name="slug" value="<?= $e($article['slug']) ?>" required maxlength="100" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="product-update"><small>使用小写英文字母、数字和连字符。</small></label>
|
<label>网址标识<input name="slug" value="<?= $e($article['slug']) ?>" required maxlength="100" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="product-update"><small>使用小写英文字母、数字和连字符。</small></label>
|
||||||
<label>分类<select name="category">
|
<?= View::fragment('admin-category-checkboxes', ['name' => 'categories', 'selected' => array_keys($article['categories']), 'categories' => $categories, 'legend' => '文章分类(可多选)']) ?>
|
||||||
<?php foreach (Repository::CATEGORIES as $key => $label): ?>
|
|
||||||
<option value="<?= $e($key) ?>" <?= $article['category'] === $key ? 'selected' : '' ?>><?= $e($label) ?></option>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</select></label>
|
|
||||||
</div>
|
|
||||||
<label>标签<input name="tags" value="<?= $e(implode(',', $article['tags'])) ?>" placeholder="用逗号分隔"></label>
|
<label>标签<input name="tags" value="<?= $e(implode(',', $article['tags'])) ?>" placeholder="用逗号分隔"></label>
|
||||||
<label>摘要<textarea name="summary" rows="2" maxlength="250"><?= $e($article['summary']) ?></textarea><small>用于动态列表和搜索摘要。</small></label>
|
<label>摘要<textarea name="summary" rows="2" maxlength="250"><?= $e($article['summary']) ?></textarea><small>用于动态列表和搜索摘要。</small></label>
|
||||||
<?= View::fragment('admin-editor', ['format' => 'markdown', 'body' => $article['body']]) ?>
|
<div class="article-editor" data-article-editor>
|
||||||
|
<div class="article-editor-heading">
|
||||||
|
<label for="article-source" data-article-editor-label>正文</label>
|
||||||
|
<button type="button" class="button button-outline" data-insert-article-image hidden>从媒体库插入图片</button>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="body_format" value="<?= $e($article['body_format']) ?>">
|
||||||
|
<textarea id="article-source" name="body" rows="16" aria-label="文章正文"><?= $e($article['body']) ?></textarea>
|
||||||
|
<div data-editor-host hidden></div>
|
||||||
|
<p class="article-editor-help" data-article-editor-status role="status"></p>
|
||||||
|
</div>
|
||||||
|
<details class="admin-options" <?= array_intersect(array_keys($article['categories']), array_keys(Repository::DIRECTORIES)) ? 'open' : '' ?>>
|
||||||
|
<summary>目录卡片</summary>
|
||||||
|
<div class="form-grid">
|
||||||
|
<?= View::fragment('studio-asset-field', ['name' => 'card_image', 'label' => '封面或标志', 'value' => $article['card']['image'] ?? '']) ?>
|
||||||
|
<label>图片替代文字<input name="card_alt" value="<?= $e($article['card']['alt'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>主链接<input name="card_url" value="<?= $e($article['card']['url'] ?? '') ?>"></label>
|
||||||
|
<label>主链接文字<input name="card_label" value="<?= $e($article['card']['label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>附加链接<input name="card_extra_url" value="<?= $e($article['card']['extra_url'] ?? '') ?>"></label>
|
||||||
|
<label>附加链接文字<input name="card_extra_label" value="<?= $e($article['card']['extra_label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>类型说明<input name="card_category_label" value="<?= $e($article['card']['category_label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>目录排序(从小到大)<input name="card_position" type="number" min="0" max="9999" value="<?= $e($article['card']['position'] ?? 0) ?>"></label>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
<div class="form-submit">
|
<div class="form-submit">
|
||||||
<label>发布状态<select name="status">
|
<label>发布状态<select name="status">
|
||||||
<option value="draft" <?= $article['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
<option value="draft" <?= $article['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||||
@@ -35,3 +51,14 @@ $e = View::escape(...);
|
|||||||
<button class="button button-primary" type="submit">保存文章</button>
|
<button class="button button-primary" type="submit">保存文章</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<?php if ($articleId !== null): ?>
|
||||||
|
<details class="admin-panel admin-options">
|
||||||
|
<summary>删除文章</summary>
|
||||||
|
<form method="post" action="/admin/articles/<?= $e($articleId) ?>/delete">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
||||||
|
<p class="field-note">删除后,文章及其目录卡片会从网站移除,且无法恢复。</p>
|
||||||
|
<button class="button button-danger" type="submit">永久删除</button>
|
||||||
|
</form>
|
||||||
|
</details>
|
||||||
|
<?php endif ?>
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading">
|
||||||
<h1>文章与动态</h1>
|
<h1>文章与动态</h1>
|
||||||
<a class="button button-primary" href="/admin/articles/new">新建文章</a>
|
<div class="actions">
|
||||||
|
<a class="button button-outline" href="/admin/article-categories">管理分类</a>
|
||||||
|
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<?php if ($deleted): ?><p class="feedback success" role="status">文章已删除。</p><?php endif ?>
|
||||||
|
<nav class="filter-nav" aria-label="筛选文章">
|
||||||
|
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
|
<?php foreach ($categories as $key => $name): ?>
|
||||||
|
<a href="/admin/articles?category=<?= $e($key) ?>" <?= $category === (string) $key ? 'aria-current="page"' : '' ?>><?= $e($name) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</nav>
|
||||||
<div class="admin-panel">
|
<div class="admin-panel">
|
||||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||||
</div>
|
</div>
|
||||||
<?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="/admin/articles?page=<?= $pageNumber - 1 ?>">上一页</a><?php endif ?>
|
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="/admin/articles?<?= $e($filters) ?>page=<?= $pageNumber - 1 ?>">上一页</a><?php endif ?>
|
||||||
<span>第 <?= $pageNumber ?> 页</span>
|
<span>第 <?= $pageNumber ?> 页</span>
|
||||||
<?php if ($hasNext): ?><a class="button button-outline" href="/admin/articles?page=<?= $pageNumber + 1 ?>">下一页</a><?php endif ?>
|
<?php if ($hasNext): ?><a class="button button-outline" href="/admin/articles?<?= $e($filters) ?>page=<?= $pageNumber + 1 ?>">下一页</a><?php endif ?>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$checked = array_fill_keys($selected, true);
|
||||||
|
?>
|
||||||
|
<fieldset class="category-checks">
|
||||||
|
<legend><?= $e($legend) ?></legend>
|
||||||
|
<div>
|
||||||
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
|
<label><input type="checkbox" name="<?= $e($name) ?>[]" value="<?= $e($key) ?>" <?= isset($checked[$key]) ? 'checked' : '' ?>> <?= $e($label) ?></label>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</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">
|
||||||
|
<section class="admin-panel dashboard-pages" aria-labelledby="pages-title" data-page-list>
|
||||||
|
<div class="admin-heading compact">
|
||||||
<h2 id="pages-title">网站页面</h2>
|
<h2 id="pages-title">网站页面</h2>
|
||||||
<ul class="admin-list">
|
<p class="field-note"><?= $live ?> 个已发布 · <?= count($pages) - $live ?> 个草稿</p>
|
||||||
|
</div>
|
||||||
|
<div class="dashboard-filters" data-page-filters hidden>
|
||||||
|
<label>查找页面<input type="search" data-page-search placeholder="页面名称或地址"></label>
|
||||||
|
<label>发布状态<select data-page-status>
|
||||||
|
<option value="">全部状态</option>
|
||||||
|
<option value="published">已发布</option>
|
||||||
|
<option value="draft">草稿</option>
|
||||||
|
</select></label>
|
||||||
|
</div>
|
||||||
|
<p class="empty-state" data-page-empty role="status"<?= $pages ? ' hidden' : '' ?>><?= $pages ? '没有匹配的页面。' : '暂无页面。' ?></p>
|
||||||
|
<ul class="admin-list dashboard-page-list">
|
||||||
<?php foreach ($pages as $page): ?>
|
<?php foreach ($pages as $page): ?>
|
||||||
<li>
|
<?php $path = $page['slug'] === 'home' ? '/' : '/' . $page['slug']; $published = $page['status'] === 'published'; ?>
|
||||||
<div><strong><?= $e($page['name']) ?></strong><small><?= $e($page['slug'] === 'home' ? '/' : '/' . $page['slug']) ?> · <?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></small></div>
|
<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 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>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
<div class="dashboard-secondary">
|
||||||
<section class="admin-panel" aria-labelledby="recent-title">
|
<section class="admin-panel" aria-labelledby="recent-title">
|
||||||
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2><a href="/admin/articles">管理全部文章</a></div>
|
<div class="admin-heading compact"><h2 id="recent-title">最近编辑的文章</h2></div>
|
||||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||||
|
<a class="back-link" href="/admin/articles">管理全部文章</a>
|
||||||
</section>
|
</section>
|
||||||
|
<section class="admin-panel dashboard-settings" aria-labelledby="quick-title">
|
||||||
|
<h2 id="quick-title">站点编辑</h2>
|
||||||
|
<ul class="dashboard-setting-buttons">
|
||||||
|
<li><a class="button button-outline" href="/admin/settings/header">编辑页头</a></li>
|
||||||
|
<li><a class="button button-outline" href="/admin/settings/footer">编辑页脚</a></li>
|
||||||
|
<li><a class="button button-outline" href="/admin/settings/cdn">静态资源 CDN</a></li>
|
||||||
|
<li><a class="button button-outline" href="/admin/media">打开媒体库</a></li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<?php use App\Content\View; ?>
|
<?php use App\Content\View; ?>
|
||||||
<?php if ($error): ?><p class="feedback error" role="alert"><?= View::escape($error) ?></p><?php endif ?>
|
<?php if ($error): ?><p class="feedback error" role="alert"><?= View::escape($error) ?></p><?php endif ?>
|
||||||
<?php if ($saved && !$error): ?><p class="feedback success" role="status">已保存。</p><?php endif ?>
|
<?php if ($saved && !$error): ?><p class="feedback success" data-save-confirmation role="status">已保存。</p><?php endif ?>
|
||||||
|
|||||||
@@ -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">
|
||||||
@@ -16,6 +23,12 @@ $e = View::escape(...);
|
|||||||
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
||||||
<script src="/assets/admin.js" defer></script>
|
<script src="/assets/admin.js" defer></script>
|
||||||
<script src="/assets/studio.js" defer></script>
|
<script src="/assets/studio.js" defer></script>
|
||||||
|
<?php if (!empty($articleEditor)): ?>
|
||||||
|
<link rel="stylesheet" href="/assets/vendor/toastui/toastui-editor.min.css">
|
||||||
|
<script src="/assets/vendor/toastui/toastui-editor.min.js" defer></script>
|
||||||
|
<script src="/assets/vendor/toastui/zh-cn.js" defer></script>
|
||||||
|
<script src="/assets/article-editor.js" defer></script>
|
||||||
|
<?php endif ?>
|
||||||
</head>
|
</head>
|
||||||
<body class="admin-body">
|
<body class="admin-body">
|
||||||
<a class="skip-link" href="#admin-content">跳到内容</a>
|
<a class="skip-link" href="#admin-content">跳到内容</a>
|
||||||
@@ -23,25 +36,31 @@ $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/catalog">产品与服务</a>
|
<a href="/admin/settings/header"<?= $active === 'settings' ? ' aria-current="page"' : '' ?>>网站设置</a>
|
||||||
<a href="/admin/settings/header">网站设置</a>
|
</nav>
|
||||||
<a href="/admin/password">修改密码</a>
|
<div class="admin-utility">
|
||||||
<a href="/">访问网站</a>
|
<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">
|
<form method="post" action="/admin/logout">
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
<button class="button button-outline" type="submit">退出</button>
|
<button type="submit">退出登录</button>
|
||||||
</form>
|
</form>
|
||||||
</nav>
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<a class="back-link" href="/">返回网站</a>
|
<a class="back-link" href="/">返回网站</a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main class="admin-wrap admin-main" id="admin-content"><?= $content ?></main>
|
<main class="admin-wrap admin-main<?= !empty($wideAdmin) ? ' admin-wide' : '' ?>" id="admin-content"><?= $content ?></main>
|
||||||
<?php if ($user): ?>
|
<?php if ($user): ?>
|
||||||
<dialog class="media-picker" id="media-picker" aria-labelledby="picker-heading">
|
<dialog class="media-picker" id="media-picker" aria-labelledby="picker-heading">
|
||||||
<header class="admin-heading compact"><h2 id="picker-heading">从媒体库选择</h2><button class="button button-outline" type="button" data-close-picker>关闭</button></header>
|
<header class="admin-heading compact"><h2 id="picker-heading">从媒体库选择</h2><button class="button button-outline" type="button" data-close-picker>关闭</button></header>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use App\Content\Database;
|
||||||
use App\Content\SiteDesign;
|
use App\Content\SiteDesign;
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
@@ -9,81 +10,135 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
?>
|
?>
|
||||||
<a class="back-link" href="/admin">返回页面</a>
|
<a class="back-link" href="/admin">返回页面</a>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading">
|
||||||
<div><h1><?= $e($title) ?></h1><p><?= $e($path) ?> · <?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></p></div>
|
<div><h1><?= $e($title) ?></h1><p class="studio-page-meta"><code><?= $e($path) ?></code>
|
||||||
|
<span class="dashboard-page-state" data-published="<?= $page['status'] === 'published' ? 'true' : 'false' ?>"><?= $page['status'] === 'draft' ? '草稿' : '已发布' ?></span></p></div>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
<a class="button button-outline" href="#studio-page-settings">页面设置</a>
|
||||||
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
<?php if ($page['status'] === 'published'): ?><a class="button button-outline" href="<?= $e($path) ?>">公开页面</a><?php endif ?>
|
||||||
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
<a class="button button-outline" href="<?= $e($previewUrl) ?>" target="_blank" rel="noopener">打开预览</a>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||||
<div class="studio-layout">
|
<div class="studio-layout">
|
||||||
<div>
|
<aside class="admin-panel studio-library" aria-labelledby="studio-library-title">
|
||||||
|
<h2 id="studio-library-title">页面编辑</h2>
|
||||||
|
<?= View::fragment('studio-templates', [
|
||||||
|
'layers' => View::fragment('studio-layers', compact('page', 'slug', 'token')),
|
||||||
|
'anchorForm' => View::fragment('studio-anchor-form', compact('slug', 'token')),
|
||||||
|
]) ?>
|
||||||
|
</aside>
|
||||||
|
<div class="studio-workspace">
|
||||||
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
<section class="admin-panel studio-preview" data-preview-studio aria-labelledby="studio-preview-title">
|
||||||
<div class="admin-heading compact">
|
<div class="admin-heading compact">
|
||||||
<h2 id="studio-preview-title">页面预览</h2>
|
<h2 id="studio-preview-title">页面画布</h2>
|
||||||
<div class="preview-selector" aria-label="预览尺寸">
|
<div class="preview-selector" aria-label="预览尺寸">
|
||||||
<button type="button" class="button button-outline" data-preview-size="desktop" aria-pressed="true">桌面</button>
|
<button type="button" class="button button-outline" data-preview-size="desktop" aria-pressed="true">桌面</button>
|
||||||
<button type="button" class="button button-outline" data-preview-size="phone" aria-pressed="false">手机</button>
|
<button type="button" class="button button-outline" data-preview-size="phone" aria-pressed="false">手机</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="editor-toolbar studio-canvas-toolbar" data-canvas-toolbar hidden aria-label="正文工具">
|
||||||
|
<div>
|
||||||
|
<button type="button" data-canvas-command="heading">小标题</button>
|
||||||
|
<button type="button" data-canvas-command="bold">粗体</button>
|
||||||
|
<button type="button" data-canvas-command="list">列表</button>
|
||||||
|
<button type="button" data-canvas-command="link">插入链接</button>
|
||||||
|
<button type="button" data-canvas-command="media">插入媒体</button>
|
||||||
|
</div>
|
||||||
|
<button class="button button-primary" form="studio-page-settings" type="submit">保存页面</button>
|
||||||
|
</div>
|
||||||
<div class="studio-frame-window">
|
<div class="studio-frame-window">
|
||||||
<iframe title="当前保存的页面" src="<?= $e($previewUrl) ?>" sandbox="allow-same-origin" loading="lazy"></iframe>
|
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
||||||
</div>
|
<div class="studio-element-tools" data-element-tools role="group" aria-label="所选元素" hidden>
|
||||||
<p class="field-note">可在画布内直接编辑标题和简介。其他改动保存后刷新预览。</p>
|
<div class="studio-element-align" data-element-align role="group" aria-label="对齐">
|
||||||
</section>
|
<?php foreach (['left' => '居左', 'center' => '居中', 'right' => '居右'] as $value => $label): ?>
|
||||||
<section class="admin-panel" id="blocks">
|
<button type="button" data-align="<?= $value ?>" aria-pressed="false" aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', ['icon' => $value]) ?></button>
|
||||||
<h2>内容区块</h2>
|
|
||||||
<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">
|
|
||||||
<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="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 ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
|
||||||
<form class="admin-form studio-block-add" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<input type="hidden" name="operation" value="create">
|
|
||||||
<div class="form-grid">
|
|
||||||
<label>区块锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
|
||||||
<label>区块类型<select name="preset"><option value="text">正文</option><option value="image">图文</option><option value="cta">行动按钮</option><option value="faq">常见问题</option></select></label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-submit"><button type="submit" class="button button-primary">添加区块</button></div>
|
<?php foreach (['module-settings' => ['settings', '模块设置'], 'properties' => ['edit', '属性'], 'copy' => ['copy', '复制'], 'delete' => ['delete', '删除']] as $action => [$icon, $label]): ?>
|
||||||
|
<button type="button" data-element-<?= $action ?> aria-label="<?= $label ?>" title="<?= $label ?>"><?= View::fragment('studio-icon', compact('icon')) ?></button>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<button class="studio-media-handle" type="button" role="slider" aria-label="媒体宽度" aria-valuemin="10" aria-valuemax="100" aria-valuenow="100" data-media-handle hidden></button>
|
||||||
|
<div class="studio-media-sizing" data-media-sizing hidden>
|
||||||
|
<output data-media-size aria-hidden="true"></output>
|
||||||
|
<button class="button button-outline" type="button" data-reset-media>原始尺寸</button>
|
||||||
|
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="field-note studio-canvas-status" data-canvas-status role="status"></p>
|
||||||
|
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
|
||||||
|
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
|
||||||
|
<form class="admin-form" method="dialog">
|
||||||
|
<label data-property-row="label">文案<input name="label"></label>
|
||||||
|
<label data-property-row="note">副标题<input name="note" maxlength="200"></label>
|
||||||
|
<label data-property-row="url">地址<input name="url" maxlength="1000"></label>
|
||||||
|
<label data-property-row="alt">图片替代文本<input name="alt" maxlength="200"></label>
|
||||||
|
<label data-property-row="quicklinks">目录链接<textarea name="quicklinks" rows="5" placeholder="概览 | #overview"></textarea><small>每行填写「文案 | 链接」。</small></label>
|
||||||
|
<label data-property-row="value">当前值<input name="value" inputmode="numeric"></label>
|
||||||
|
<label data-property-row="max">最大值<input name="max" inputmode="numeric"></label>
|
||||||
|
<label data-property-row="poster">视频封面<input name="poster" maxlength="1000"></label>
|
||||||
|
<p class="feedback error" role="alert" data-property-error hidden></p>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="button" class="button button-outline" data-property-pick="url">从媒体库选择</button>
|
||||||
|
<button type="button" class="button button-outline" data-property-pick="poster">选择视频封面</button>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit" class="button button-primary">应用</button>
|
||||||
|
<button type="button" class="button button-outline" data-property-close>取消</button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
</dialog>
|
||||||
|
<dialog class="media-picker canvas-module-settings" data-module-dialog aria-labelledby="module-settings-title">
|
||||||
|
<div class="admin-heading compact"><h2 id="module-settings-title">模块设置</h2></div>
|
||||||
|
<form class="admin-form" method="dialog">
|
||||||
|
<label>模块标题<input name="module_title" maxlength="100" required></label>
|
||||||
|
<label>模块简介<textarea name="module_lead" rows="2" maxlength="500"></textarea></label>
|
||||||
|
<?= View::fragment('studio-feed-fields', ['categories' => $categories, 'feed' => [], 'allowOff' => false]) ?>
|
||||||
|
<p class="feedback error" role="alert" data-module-error hidden></p>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="button button-primary" type="submit">应用</button>
|
||||||
|
<button class="button button-outline" data-module-close type="button">取消</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<form class="admin-form admin-panel studio-inspector" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
<form id="studio-page-settings" class="admin-form admin-panel studio-inspector" method="post" action="/admin/pages/<?= $e($slug) ?>">
|
||||||
<h2>页面设置</h2>
|
<h2>页面设置</h2>
|
||||||
<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="alignments" value="<?= $e(Database::json($page['alignments'])) ?>">
|
||||||
|
<details class="studio-hero-settings">
|
||||||
|
<summary>首屏与目录</summary>
|
||||||
|
<div class="studio-hero-controls">
|
||||||
|
<button class="button button-outline" type="button" disabled data-hero-control="image">首屏图片</button>
|
||||||
|
<button class="button button-outline" type="button" disabled data-hero-control="1">首屏按钮 1</button>
|
||||||
|
<button class="button button-outline" type="button" disabled data-hero-control="2">首屏按钮 2</button>
|
||||||
|
<button class="button button-outline" type="button" disabled data-hero-control="navigation">本页目录</button>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
<label>页面名称<input name="name" value="<?= $e($page['name']) ?>" required maxlength="100"></label>
|
<label>页面名称<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>
|
||||||
<label>首屏标题<input name="heading" value="<?= $e($page['heading']) ?>" required maxlength="110"></label>
|
<?php
|
||||||
<label>标题第二行<input name="accent" value="<?= $e($page['accent']) ?>" maxlength="110"></label>
|
$contentFields = [
|
||||||
<label>首屏简介<textarea name="lead" rows="2" maxlength="600"><?= $e($page['lead']) ?></textarea></label>
|
'heading' => $page['heading'], 'accent' => $page['accent'], 'lead' => $page['lead'],
|
||||||
<?= View::fragment('studio-asset-field', ['label' => '首屏图片', 'name' => 'image', 'value' => $page['image']]) ?>
|
'image' => $page['image'], 'alt' => $page['alt'], 'image_scale' => $page['image_scale'],
|
||||||
<label>图片替代文本<input name="alt" value="<?= $e($page['alt']) ?>" maxlength="200"></label>
|
'quicklinks' => SiteDesign::linkText($page['quicklinks']),
|
||||||
<details>
|
];
|
||||||
<summary>首屏按钮和页面目录</summary>
|
foreach ([1, 2] as $index) {
|
||||||
<?php foreach ([1, 2] as $index): ?>
|
$contentFields['label' . $index] = $page['actions'][$index - 1][1] ?? '';
|
||||||
<label>按钮 <?= $index ?> 文案<input name="label<?= $index ?>" value="<?= $e($page['actions'][$index - 1][1] ?? '') ?>" maxlength="50"></label>
|
$contentFields['url' . $index] = $page['actions'][$index - 1][0] ?? '';
|
||||||
<label>按钮 <?= $index ?> 链接<input name="url<?= $index ?>" value="<?= $e($page['actions'][$index - 1][0] ?? '') ?>" maxlength="1000"></label>
|
}
|
||||||
|
?>
|
||||||
|
<?php foreach ($contentFields as $field => $value): ?>
|
||||||
|
<?php if ($field === 'quicklinks'): ?>
|
||||||
|
<textarea name="quicklinks" hidden><?= $e($value) ?></textarea>
|
||||||
|
<?php else: ?>
|
||||||
|
<input type="hidden" name="<?= $e($field) ?>" value="<?= $e($value) ?>">
|
||||||
|
<?php endif ?>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<label>本页目录<textarea name="quicklinks" rows="3" placeholder="概览 | #overview"><?= $e(SiteDesign::linkText($page['quicklinks'])) ?></textarea>
|
|
||||||
<small>每行填写「文案 | 链接」。</small>
|
|
||||||
</label>
|
|
||||||
</details>
|
|
||||||
<?php if ($slug !== 'home'): ?>
|
<?php if ($slug !== 'home'): ?>
|
||||||
<label>发布状态<select name="status"><option value="draft" <?= $page['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
<label>发布状态<select name="status"><option value="draft" <?= $page['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||||
<option value="published" <?= $page['status'] === 'published' ? 'selected' : '' ?>>已发布</option></select></label>
|
<option value="published" <?= $page['status'] === 'published' ? 'selected' : '' ?>>已发布</option></select></label>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use App\Content\View;
|
|||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
$slug = $section['page_slug'];
|
$slug = $section['page_slug'];
|
||||||
$key = $section['key'];
|
$key = $section['key'];
|
||||||
|
$feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||||
?>
|
?>
|
||||||
<a class="back-link" href="/admin/pages/<?= $e($slug) ?>">返回页面编辑</a>
|
<a class="back-link" href="/admin/pages/<?= $e($slug) ?>">返回页面编辑</a>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading">
|
||||||
@@ -16,11 +17,17 @@ $key = $section['key'];
|
|||||||
<input type="hidden" name="version" value="<?= $e($section['version']) ?>">
|
<input type="hidden" name="version" value="<?= $e($section['version']) ?>">
|
||||||
<label>区块标题<input name="title" value="<?= $e($section['title']) ?>" required maxlength="100"></label>
|
<label>区块标题<input name="title" value="<?= $e($section['title']) ?>" required maxlength="100"></label>
|
||||||
<label>区块简介<textarea name="lead" rows="2" maxlength="500"><?= $e($section['lead']) ?></textarea></label>
|
<label>区块简介<textarea name="lead" rows="2" maxlength="500"><?= $e($section['lead']) ?></textarea></label>
|
||||||
|
<?php if ($savedStyle !== 'hero-links'): ?>
|
||||||
<label>区块背景<select name="style">
|
<label>区块背景<select name="style">
|
||||||
<?php foreach (array_unique([$savedStyle, 'plain', 'tinted']) as $style): ?>
|
<?php foreach (array_unique([$savedStyle, 'plain', 'tinted']) as $style): ?>
|
||||||
<option value="<?= $e($style) ?>" <?= $style === $section['style'] ? 'selected' : '' ?>><?= $e(['plain' => '默认', 'tinted' => '浅色背景'][$style] ?? '保留原布局') ?></option>
|
<option value="<?= $e($style) ?>" <?= $style === $section['style'] ? 'selected' : '' ?>><?= $e(['plain' => '默认', 'tinted' => '浅色背景'][$style] ?? '保留原布局') ?></option>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</select></label>
|
</select></label>
|
||||||
|
<details class="admin-options" <?= $feed ? 'open' : '' ?>>
|
||||||
|
<summary>动态模块</summary>
|
||||||
|
<?= View::fragment('studio-feed-fields', ['categories' => $categories, 'feed' => $feed, 'allowOff' => true]) ?>
|
||||||
|
</details>
|
||||||
|
<?php endif ?>
|
||||||
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
|
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
|
||||||
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
|
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -7,22 +6,26 @@ $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 (Repository::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]) ?>
|
<?php if (!empty($catalog)): ?>
|
||||||
|
<?= View::fragment('service-cards', ['products' => $articles]) ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?= View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
|
||||||
|
<?php endif ?>
|
||||||
<?php if ($pageNumber > 1 || $hasNext): ?>
|
<?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>
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<div class="article-feed" <?= count($groups) > 1 ? 'data-article-tabs' : '' ?>>
|
||||||
|
<?php if (count($groups) > 1): ?>
|
||||||
|
<div class="filter-nav article-tabs" data-tab-list role="tablist" aria-labelledby="heading-<?= $e($sectionKey) ?>" hidden>
|
||||||
|
<?php foreach ($groups as $index => $group): ?>
|
||||||
|
<button type="button" role="tab" id="<?= $e($sectionKey) ?>-tab-<?= $index ?>" aria-controls="<?= $e($sectionKey) ?>-articles-<?= $index ?>"><?= $e($group['label']) ?></button>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php foreach ($groups as $index => $group): ?>
|
||||||
|
<div id="<?= $e($sectionKey) ?>-articles-<?= $index ?>" data-tab-panel>
|
||||||
|
<?php if ($group['label'] !== ''): ?><h3 data-tab-heading><?= $e($group['label']) ?></h3><?php endif ?>
|
||||||
|
<?= View::fragment('article-list', ['articles' => $group['articles'], 'categoryScope' => $group['categories']]) ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php if ($archivePath !== null): ?>
|
||||||
|
<p class="article-feed-archive"><a class="back-link" href="<?= $e($archivePath) ?>">查看全部动态</a></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
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(Repository::CATEGORIES[$item['category']]) ?></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>
|
||||||
<time datetime="<?= $e(View::date($item['published_at'], 'Y-m-d')) ?>"><?= $e(View::date($item['published_at'], 'Y.m.d')) ?></time>
|
<?php if ($item['published_at']): ?><time datetime="<?= $e(View::date($item['published_at'], 'Y-m-d')) ?>"><?= $e(View::date($item['published_at'], 'Y.m.d')) ?></time><?php endif ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|||||||
@@ -1,29 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<article class="section article-page" itemscope itemtype="https://schema.org/Article" data-enter>
|
<article class="section article-page" itemscope itemtype="https://schema.org/Article" data-enter>
|
||||||
|
<?php $card = $article['card']; ?>
|
||||||
<div class="wrap reading-wrap">
|
<div class="wrap reading-wrap">
|
||||||
<a class="back-link" href="/articles">全部动态</a>
|
<a class="back-link" href="/articles">全部动态</a>
|
||||||
<header class="section-heading">
|
<header class="section-heading">
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<a href="/articles/category/<?= $e($article['category']) ?>" itemprop="articleSection"><?= $e(Repository::CATEGORIES[$article['category']]) ?></a>
|
<?php foreach ($article['categories'] as $key => $name): ?>
|
||||||
<time itemprop="datePublished" datetime="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>"><?= $e(View::date($article['published_at'])) ?></time>
|
<a href="/articles/category/<?= $e($key) ?>" itemprop="articleSection"><?= $e($name) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php if ($article['published_at']): ?><time itemprop="datePublished" datetime="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>"><?= $e(View::date($article['published_at'])) ?></time><?php endif ?>
|
||||||
<meta itemprop="dateModified" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
|
<meta itemprop="dateModified" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
|
||||||
</div>
|
</div>
|
||||||
<h1 itemprop="headline"><?= $e($article['title']) ?></h1>
|
<h1 itemprop="headline"><?= $e($article['title']) ?></h1>
|
||||||
<?php if ($article['summary']): ?><p itemprop="description"><?= $e($article['summary']) ?></p><?php endif ?>
|
<?php if ($article['summary']): ?><p itemprop="description"><?= $e($article['summary']) ?></p><?php endif ?>
|
||||||
<span itemprop="author" itemscope itemtype="https://schema.org/Organization"><meta itemprop="name" content="<?= $e($site['name']) ?>"></span>
|
<span itemprop="author" itemscope itemtype="https://schema.org/Organization"><meta itemprop="name" content="<?= $e($site['name']) ?>"></span>
|
||||||
</header>
|
</header>
|
||||||
|
<?php if (!empty($card['image'])): ?>
|
||||||
|
<img class="article-cover" src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>">
|
||||||
|
<?php endif ?>
|
||||||
<div class="rich prose" itemprop="articleBody">
|
<div class="rich prose" itemprop="articleBody">
|
||||||
<?php if (trim($articleHtml) !== ''): ?>
|
<?php if (trim($articleHtml) !== ''): ?>
|
||||||
<?= $articleHtml ?>
|
<?= $articleHtml ?>
|
||||||
<?php else: ?>
|
<?php elseif (!$article['summary'] && empty($card['image']) && empty($card['url'])): ?>
|
||||||
<p class="empty-state">此公告的原文暂不可用。</p>
|
<p class="empty-state">此文章的原文暂不可用。</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (!empty($card['url']) || !empty($card['extra_url'])): ?>
|
||||||
|
<div class="actions">
|
||||||
|
<?php if (!empty($card['url'])): ?><a class="button button-primary" href="<?= $e($card['url']) ?>"><?= $e(($card['label'] ?? '') ?: '访问网站') ?></a><?php endif ?>
|
||||||
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
<?php if ($article['tags']): ?>
|
<?php if ($article['tags']): ?>
|
||||||
<nav class="filter-nav" aria-label="文章标签">
|
<nav class="filter-nav" aria-label="文章标签">
|
||||||
<?php foreach ($article['tags'] as $tag): ?>
|
<?php foreach ($article['tags'] as $tag): ?>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ $e = View::escape(...);
|
|||||||
<div class="footer-grid">
|
<div class="footer-grid">
|
||||||
<div class="footer-company" itemscope itemtype="https://schema.org/Organization">
|
<div class="footer-company" itemscope itemtype="https://schema.org/Organization">
|
||||||
<?php if ($footer['logo'] !== ''): ?>
|
<?php if ($footer['logo'] !== ''): ?>
|
||||||
<a href="/" itemprop="url" aria-label="来笙 Laysense 首页">
|
<a class="footer-logo" href="/" itemprop="url" aria-label="来笙 Laysense 首页">
|
||||||
<img src="<?= $e($footer['logo']) ?>" alt="<?= $e($footer['alt']) ?>" width="130" height="33" itemprop="logo" loading="lazy">
|
<img src="<?= $e($footer['logo']) ?>" alt="<?= $e($footer['alt']) ?>" width="130" height="33" itemprop="logo" loading="lazy">
|
||||||
</a>
|
</a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@@ -17,31 +17,41 @@ $e = View::escape(...);
|
|||||||
<?php if ($footer['email']): ?>
|
<?php if ($footer['email']): ?>
|
||||||
<a itemprop="email" href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a>
|
<a itemprop="email" href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
<p class="footer-payment-label">支持的付款方式</p>
|
||||||
<div class="payment-methods" aria-label="支持的付款方式">
|
<div class="payment-methods" aria-label="支持的付款方式">
|
||||||
<img src="/assets/original/payment-taobao.png" alt="淘宝" width="26" height="26" loading="lazy">
|
<img src="/assets/original/payment-taobao.png" alt="淘宝" width="26" height="26" loading="lazy">
|
||||||
<img src="/assets/original/payment-alipay.png" alt="支付宝" width="26" height="26" loading="lazy">
|
<img src="/assets/original/payment-alipay.png" alt="支付宝" width="26" height="26" loading="lazy">
|
||||||
<img src="/assets/original/payment-wechat.png" alt="微信支付" width="26" height="26" loading="lazy">
|
<img src="/assets/original/payment-wechat.png" alt="微信支付" width="26" height="26" loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php foreach (['products', 'company'] as $group): ?>
|
<nav class="footer-links" aria-label="页脚导航">
|
||||||
|
<?php foreach (['products', 'company', 'resources'] as $group): ?>
|
||||||
<?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?>
|
<?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?>
|
||||||
<div>
|
<div>
|
||||||
<?php if ($footer[$group . '_title'] !== ''): ?><p class="footer-label"><?= $e($footer[$group . '_title']) ?></p><?php endif ?>
|
<?php if ($footer[$group . '_title'] !== ''): ?><h2 class="footer-label"><?= $e($footer[$group . '_title']) ?></h2><?php endif ?>
|
||||||
<?php foreach ($footer[$group] as [$url, $label]): ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a><?php endforeach ?>
|
<?php if ($footer[$group]): ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach ($footer[$group] as [$url, $label]): ?><li><a href="<?= $e($url) ?>"><?= $e($label) ?></a></li><?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-meta">
|
<div class="footer-meta">
|
||||||
<?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?> 2024–<?= $e(date('Y')) ?></p><?php endif ?>
|
<?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?></p><?php endif ?>
|
||||||
<?php if ($footer['phones']): ?>
|
<?php if ($footer['email'] || $footer['phones']): ?>
|
||||||
<p>全球号码
|
<p>
|
||||||
|
<?php if ($footer['email']): ?><a href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a><?php endif ?>
|
||||||
|
<?php if ($footer['phones']): ?>全球号码:
|
||||||
<?php foreach ($footer['phones'] as $index => [$url, $label]): ?>
|
<?php foreach ($footer['phones'] as $index => [$url, $label]): ?>
|
||||||
<?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
|
<?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
<?php endif ?>
|
||||||
</p>
|
</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($footer['registration']): ?><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a><?php endif ?>
|
|
||||||
<?php if ($footer['terms']): ?><p class="footer-terms"><?= $e($footer['terms']) ?></p><?php endif ?>
|
<?php if ($footer['terms']): ?><p class="footer-terms"><?= $e($footer['terms']) ?></p><?php endif ?>
|
||||||
|
<?php if ($footer['registration']): ?><p><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a></p><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ if (str_starts_with($imageUrl, '/')) {
|
|||||||
$kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software';
|
$kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software';
|
||||||
$siteKind = $kind === 'service' ? 'other' : 'software';
|
$siteKind = $kind === 'service' ? 'other' : 'software';
|
||||||
$header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
|
$header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
|
||||||
$footer = ($site['footer'] ?? []) + SiteDesign::DEFAULT_FOOTER + $site;
|
$footer = SiteDesign::footer($site);
|
||||||
$nav = $header['links'];
|
$nav = $header['links'];
|
||||||
$contact = $header['button'];
|
$contact = $header['button'];
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<section class="section network" aria-label="支持项目与合作伙伴">
|
||||||
|
<div class="wrap">
|
||||||
|
<?php if (!$standalone): ?>
|
||||||
|
<div class="section-heading inline-heading">
|
||||||
|
<h2>支持项目与合作伙伴</h2>
|
||||||
|
<a class="button button-outline" href="/network">查看全部</a>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php foreach ($network as $slug => $group): ?>
|
||||||
|
<div class="network-group" id="<?= $e($slug) ?>">
|
||||||
|
<?php if ($standalone): ?><h2><?= $e($group['name']) ?></h2><?php else: ?><h3><?= $e($group['name']) ?></h3><?php endif ?>
|
||||||
|
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
|
||||||
|
<?= View::fragment('network-items', ['articles' => $group['articles'], 'standalone' => $standalone]) ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Content\DirectoryCard;
|
||||||
|
use App\Content\Html;
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<ul class="network-list">
|
||||||
|
<?php foreach ($articles as $item): ?>
|
||||||
|
<?php
|
||||||
|
$card = $item['card'];
|
||||||
|
['primary' => $target, 'detail' => $detail] = DirectoryCard::links($item, Html::articleBody($item));
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
|
||||||
|
<?php if (!empty($card['image'])): ?>
|
||||||
|
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
||||||
|
<?php endif ?>
|
||||||
|
<span><?= $e($item['title']) ?></span>
|
||||||
|
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
|
||||||
|
<?php if ($standalone && $detail !== ''): ?>
|
||||||
|
<a class="network-detail" href="<?= $e($detail) ?>">查看详情</a>
|
||||||
|
<?php endif ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
?>
|
||||||
|
<section class="section catalog-hero">
|
||||||
|
<div class="wrap">
|
||||||
|
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">支持项目与合作伙伴</span></nav>
|
||||||
|
<h1>支持项目与合作伙伴</h1>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?= View::fragment('network-groups', ['network' => $network, 'standalone' => true]) ?>
|
||||||
@@ -5,6 +5,9 @@ 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 . '"' : '';
|
||||||
?>
|
?>
|
||||||
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
|
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
|
||||||
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>">
|
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>">
|
||||||
@@ -17,39 +20,49 @@ $service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
|
|||||||
</span>
|
</span>
|
||||||
<span class="crumb-divider" aria-hidden="true">/</span>
|
<span class="crumb-divider" aria-hidden="true">/</span>
|
||||||
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
|
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
|
||||||
<a itemprop="item" href="/<?= $e($page['slug']) ?>" aria-current="page"><span itemprop="name"><?= $e($page['name']) ?></span></a>
|
<a itemprop="item" href="/<?= $e($page['slug']) ?>" aria-current="page"><span itemprop="name"<?= $field('name') ?>><?= $e($page['name']) ?></span></a>
|
||||||
<meta itemprop="position" content="2">
|
<meta itemprop="position" content="2">
|
||||||
</span>
|
</span>
|
||||||
</nav>
|
</nav>
|
||||||
<?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" data-studio-field="heading"><?= $e($page['heading']) ?></span><?php if ($page['accent'] !== ''): ?><br><span><?= $e($page['accent']) ?></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" data-studio-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 ($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($home && $url === '/#product' ? '/services' : $url) ?>"><?= $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 ($page['image'] !== ''): ?>
|
<?php if ($canvas || $page['image'] !== ''): ?>
|
||||||
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?>" data-visual>
|
<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 src="<?= $e($page['image']) ?>" alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high">
|
<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'): ?>
|
||||||
|
<svg class="home-pipe-flow" viewBox="0 0 640 480" aria-hidden="true" focusable="false">
|
||||||
|
<defs>
|
||||||
|
<path id="hero-pipe-tower" pathLength="100" d="M174 347 241 312 Q246 310 246 305 L246 299 Q246 295 252 293 L273 282"/>
|
||||||
|
<path id="hero-pipe-disk" pathLength="100" d="M409 282 428 293 Q433 296 433 300 L433 304 Q433 307 438 309 L500 337"/>
|
||||||
|
<path id="hero-pipe-node" pathLength="100" d="M119 201 125 205 Q129 207 129 212 L129 214 Q130 217 134 219 L190 243"/>
|
||||||
|
<path id="hero-pipe-chart" pathLength="100" d="M443 226 471 213 Q478 208 483 209 L488 207 Q492 205 492 200 L492 182"/>
|
||||||
|
</defs>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-tower"/><use href="#hero-pipe-tower"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-disk"/><use href="#hero-pipe-disk"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-node"/><use href="#hero-pipe-node"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-chart"/><use href="#hero-pipe-chart"/></g>
|
||||||
|
</svg>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($home): ?>
|
<?php foreach ($page['sections'] as $section): ?>
|
||||||
<div class="wrap hero-directory">
|
<?php if ($section['style'] === 'hero-links'): ?>
|
||||||
<a class="overline directory-label" href="/services">产品与服务</a>
|
<?= View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
|
||||||
<a href="/pagepan"><span>PAGEPAN</span><small>可视化建站</small></a>
|
|
||||||
<a href="/highspeaker"><span>HighSpeaker DNS</span><small>开源智能解析</small></a>
|
|
||||||
<a href="/sc"><span>软著代理</span><small>登记申请与材料服务</small></a>
|
|
||||||
<a href="/shnu-sc"><span>SHNU 学生</span><small>软著申请方案</small></a>
|
|
||||||
</div>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
<?php endforeach ?>
|
||||||
</section>
|
</section>
|
||||||
<?php if ($page['quicklinks']): ?>
|
<?php if ($canvas || $page['quicklinks']): ?>
|
||||||
<nav class="section-nav" aria-label="本页目录">
|
<nav class="section-nav" aria-label="本页目录"<?= $canvas ? ' data-studio-navigation' : '' ?><?= !$page['quicklinks'] ? ' hidden' : '' ?>>
|
||||||
<div class="wrap section-nav-inner">
|
<div class="wrap section-nav-inner">
|
||||||
<?php foreach ($page['quicklinks'] as [$url, $label]): ?>
|
<?php foreach ($page['quicklinks'] as [$url, $label]): ?>
|
||||||
<a href="<?= $e($url) ?>"><?= $e($label) ?></a>
|
<a href="<?= $e($url) ?>"><?= $e($label) ?></a>
|
||||||
@@ -58,41 +71,13 @@ $service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
|
|||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php foreach ($page['sections'] as $section): ?>
|
<?php foreach ($page['sections'] as $section): ?>
|
||||||
<?= View::fragment('section', ['section' => $section, 'moment' => $home && $section['key'] === 'about']) ?>
|
<?php if ($section['style'] !== 'hero-links'): ?>
|
||||||
<?php endforeach ?>
|
<?= View::fragment('section', ['section' => $section, 'moment' => $home && $section['key'] === 'about', 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
|
||||||
<?php if ($home): ?>
|
|
||||||
<section class="section home-news" id="blog" aria-labelledby="updates-heading">
|
|
||||||
<div class="wrap">
|
|
||||||
<div class="section-heading inline-heading">
|
|
||||||
<h2 id="updates-heading">来笙动态</h2>
|
|
||||||
<a class="button button-outline" href="/articles">查看全部动态</a>
|
|
||||||
</div>
|
|
||||||
<?= View::fragment('article-list', ['articles' => $articles]) ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<?php if ($page['partners']): ?>
|
|
||||||
<section class="section network" aria-labelledby="network-heading">
|
|
||||||
<div class="wrap">
|
|
||||||
<div class="section-heading"><h2 id="network-heading">支持项目与合作伙伴</h2></div>
|
|
||||||
<?php foreach (['来笙支持项目' => 'supported-projects', '来笙合作伙伴' => 'partners'] as $group => $id): ?>
|
|
||||||
<div class="network-group" id="<?= $e($id) ?>">
|
|
||||||
<h3><?= $e($group) ?></h3>
|
|
||||||
<ul class="network-list">
|
|
||||||
<?php foreach ($page['partners'] as $partner): ?>
|
|
||||||
<?php if ($partner['group'] !== $group) { continue; } ?>
|
|
||||||
<li>
|
|
||||||
<?php if ($partner['url']): ?><a href="<?= $e($partner['url']) ?>"><?php else: ?><div><?php endif ?>
|
|
||||||
<?php if ($partner['image']): ?>
|
|
||||||
<img src="<?= $e($partner['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<span><?= $e($partner['name']) ?></span>
|
|
||||||
<?php if ($partner['url']): ?></a><?php else: ?></div><?php endif ?>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</ul>
|
<?php if ($canvas): ?>
|
||||||
</div>
|
<template data-studio-section-end><?= View::fragment('section', [
|
||||||
<?php endforeach ?>
|
'section' => ['style' => 'plain', 'key' => 'new', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
|
||||||
</div>
|
'moment' => false, 'canvas' => true,
|
||||||
</section>
|
]) ?></template>
|
||||||
<?php endif ?>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -2,13 +2,53 @@
|
|||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
|
$canvas ??= false;
|
||||||
|
$body = $section['body'];
|
||||||
|
$dynamic = isset($section['feed']);
|
||||||
|
$studio = $canvas ? ' data-studio-section="' . $e($section['version']) . '" data-studio-source="' . $e(base64_encode($section['body'])) . '"' : '';
|
||||||
|
if ($canvas && $dynamic) {
|
||||||
|
$studio .= ' data-studio-dynamic data-studio-feed="' . $e($section['feed']) . '" tabindex="0"';
|
||||||
|
}
|
||||||
|
if ($section['style'] === 'hero-links'):
|
||||||
?>
|
?>
|
||||||
<section class="section section-<?= $e($section['style']) ?>" id="<?= $e($section['key']) ?>" aria-labelledby="heading-<?= $e($section['key']) ?>" <?= $moment ? 'data-moment="iris-opens"' : '' ?>>
|
<div class="wrap hero-directory-slot" id="<?= $e($section['key']) ?>"<?= $studio ?>>
|
||||||
|
<?php if ($canvas): ?><span data-studio-part="title" hidden><?= $e($section['title']) ?></span><span data-studio-part="lead" hidden><?= $e($section['lead']) ?></span><?php endif ?>
|
||||||
|
<div<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
return;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$alignments = json_decode($section['alignments'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
if ($dynamic && $body === '<p><a class="back-link" href="/articles">查看全部动态</a></p>') {
|
||||||
|
$body = '';
|
||||||
|
}
|
||||||
|
$network = $section['networkFeed'] ?? false;
|
||||||
|
$catalog = $section['catalogFeed'] ?? false;
|
||||||
|
?>
|
||||||
|
<section class="section section-<?= $e($section['style']) ?><?= $network ? ' network' : '' ?>" id="<?= $e($section['key']) ?>" aria-labelledby="heading-<?= $e($section['key']) ?>" <?= $moment ? 'data-moment="iris-opens"' : '' ?><?= $studio ?>>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div class="section-heading">
|
<div class="section-heading">
|
||||||
<h2 id="heading-<?= $e($section['key']) ?>"><?= $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 ($section['lead']): ?><p><?= $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>
|
||||||
<div class="rich"><?= $section['body'] ?></div>
|
<?php if ($network): ?>
|
||||||
|
<?php foreach ($section['articleFeed'] as $group): ?>
|
||||||
|
<?php $slug = $group['categories'][0]; $anchor = ($pageSlug ?? '') === 'home' && $section['key'] === 'network' ? $slug : $section['key'] . '-group-' . $slug; ?>
|
||||||
|
<div class="network-group" id="<?= $e($anchor) ?>">
|
||||||
|
<h3><?= $e($group['label']) ?></h3>
|
||||||
|
<?= View::fragment('network-items', ['articles' => $group['articles'], 'standalone' => false]) ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php if ($section['archivePath'] !== null): ?><p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p><?php endif ?>
|
||||||
|
<?php elseif ($catalog): ?>
|
||||||
|
<?= View::fragment('service-cards', ['products' => $section['articleFeed'][0]['articles']]) ?>
|
||||||
|
<?php if ($section['archivePath'] !== null && count($section['articleFeed'][0]['articles']) >= $section['feedLimit']): ?>
|
||||||
|
<p class="article-feed-archive"><a class="back-link" href="<?= $e($section['archivePath']) ?>">查看全部</a></p>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php elseif (!empty($section['articleFeed'])): ?>
|
||||||
|
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key'], 'archivePath' => $section['archivePath']]) ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($canvas || $body !== ''): ?><div class="rich<?= $dynamic ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $body ?></div><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\DirectoryCard;
|
||||||
|
use App\Content\Html;
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
||||||
|
<div class="catalog-grid">
|
||||||
|
<?php foreach ($products as $product): ?>
|
||||||
|
<?php
|
||||||
|
$card = $product['card'];
|
||||||
|
$body = Html::articleBody($product);
|
||||||
|
$target = DirectoryCard::links($product, $body)['primary'];
|
||||||
|
$extra = $card['extra_url'] ?? '';
|
||||||
|
?>
|
||||||
|
<article class="catalog-card">
|
||||||
|
<?php if (!empty($card['image'])): ?>
|
||||||
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
||||||
|
<?php endif ?>
|
||||||
|
<div class="catalog-content">
|
||||||
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
||||||
|
<h3><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h3>
|
||||||
|
<?php if ($product['summary']): ?>
|
||||||
|
<p><?= $e($product['summary']) ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="rich"><?= $body ?></div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($target !== '' || $extra !== ''): ?>
|
||||||
|
<div class="actions">
|
||||||
|
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
|
||||||
|
<?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
use App\Content\View;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
|
||||||
?>
|
|
||||||
<section class="section catalog-hero">
|
|
||||||
<div class="wrap">
|
|
||||||
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
|
||||||
<h1>产品与服务</h1>
|
|
||||||
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<section class="section catalog-listing" aria-label="产品与服务目录">
|
|
||||||
<div class="wrap">
|
|
||||||
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
|
||||||
<div class="catalog-grid">
|
|
||||||
<?php foreach ($products as $product): ?>
|
|
||||||
<article class="catalog-card">
|
|
||||||
<?php if ($product['image']): ?>
|
|
||||||
<div class="catalog-image"><img src="<?= $e($product['image']) ?>" alt="<?= $e($product['alt']) ?>" loading="lazy"></div>
|
|
||||||
<?php endif ?>
|
|
||||||
<div class="catalog-content">
|
|
||||||
<p class="overline"><?= $e($product['category']) ?></p>
|
|
||||||
<h2><?= $e($product['name']) ?></h2>
|
|
||||||
<div class="rich"><?= $product['body'] ?></div>
|
|
||||||
<div class="actions">
|
|
||||||
<a class="button button-primary" href="<?= $e($product['url']) ?>"><?= $e($product['label']) ?></a>
|
|
||||||
<?php if ($product['extra_url']): ?><a href="<?= $e($product['extra_url']) ?>"><?= $e($product['extra_label']) ?></a><?php endif ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\BlockTemplates;
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<details class="studio-anchor-create">
|
||||||
|
<summary>按锚点新建区块</summary>
|
||||||
|
<form class="admin-form" method="post" action="/admin/page-blocks/<?= $e($slug) ?>">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<input type="hidden" name="operation" value="create">
|
||||||
|
<label>锚点<input name="key" pattern="[a-z0-9]+(-[a-z0-9]+)*" maxlength="70" placeholder="overview" required></label>
|
||||||
|
<label>模板<select name="preset">
|
||||||
|
<?php foreach (BlockTemplates::groups() as [$category, $templates]): ?>
|
||||||
|
<optgroup label="<?= $e($category) ?>">
|
||||||
|
<?php foreach ($templates as $preset => [$label]): ?>
|
||||||
|
<option value="<?= $e($preset) ?>"><?= $e($label) ?></option>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</optgroup>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</select></label>
|
||||||
|
<button type="submit" class="button button-outline">新建</button>
|
||||||
|
</form>
|
||||||
|
</details>
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
use App\Content\View;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
|
||||||
?>
|
|
||||||
<header class="admin-heading">
|
|
||||||
<div><h1>产品与服务</h1><p>管理公开目录中的条目、分类和按钮链接。</p></div>
|
|
||||||
<div class="actions"><a class="button button-outline" href="/services">查看目录</a><a class="button button-primary" href="/admin/catalog/new">添加条目</a></div>
|
|
||||||
</header>
|
|
||||||
<section class="admin-panel">
|
|
||||||
<?php if (!$products): ?><p class="empty-state">暂无产品或服务。</p><?php endif ?>
|
|
||||||
<ul class="admin-list">
|
|
||||||
<?php foreach ($products as $item): ?>
|
|
||||||
<li><div><strong><?= $e($item['name']) ?></strong><small><?= $e($item['category']) ?> · <?= $e($item['url']) ?></small></div>
|
|
||||||
<a class="button button-outline" href="/admin/catalog/<?= $e($item['id']) ?>">编辑</a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$modes = ($allowOff ? ['off' => '不展示'] : []) + ['merged' => '合并列表', 'tabs' => '分类标签页', 'network' => '项目与伙伴卡片', 'catalog' => '产品与服务卡片'];
|
||||||
|
?>
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>展示方式<select name="feed_mode">
|
||||||
|
<?php foreach ($modes as $mode => $label): ?>
|
||||||
|
<option value="<?= $mode ?>" <?= ($feed['mode'] ?? 'off') === $mode ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</select></label>
|
||||||
|
<label>展示数量<input name="feed_limit" type="number" required min="1" max="30" value="<?= $e($feed['limit'] ?? 6) ?>"><small>分组时每个分类独立计数。</small></label>
|
||||||
|
</div>
|
||||||
|
<?= View::fragment('admin-category-checkboxes', ['name' => 'feed_categories', 'selected' => $feed['categories'] ?? [], 'categories' => $categories, 'legend' => '展示分类']) ?>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
$paths = [
|
||||||
|
'left' => '<path d="M3 6h18M3 10h12M3 14h18M3 18h12"/>',
|
||||||
|
'center' => '<path d="M3 6h18M6 10h12M3 14h18M6 18h12"/>',
|
||||||
|
'right' => '<path d="M3 6h18M9 10h12M3 14h18M9 18h12"/>',
|
||||||
|
'settings' => '<path d="M4 6h12m4 0h0M4 12h3m4 0h9M4 18h10m4 0h2"/><circle cx="17" cy="6" r="2"/><circle cx="9" cy="12" r="2"/><circle cx="16" cy="18" r="2"/>',
|
||||||
|
'edit' => '<path d="m14 5 5 5M5 19l4-.8L20 7.3 16.7 4 5.8 15z"/>',
|
||||||
|
'copy' => '<rect x="8" y="8" width="12" height="12" rx="2"/><path d="M16 4H6a2 2 0 0 0-2 2v10"/>',
|
||||||
|
'delete' => '<path d="M4 7h16M9 7V4h6v3m3 0-.8 13H6.8L6 7m4 4v5m4-5v5"/>',
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><?= $paths[$icon] ?></svg>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<details class="studio-layers" id="blocks">
|
||||||
|
<summary>区块顺序</summary>
|
||||||
|
<ul class="admin-list studio-blocks">
|
||||||
|
<?php foreach ($page['sections'] as $index => $item): ?>
|
||||||
|
<?php $fixedSlot = $item['style'] === 'hero-links'; ?>
|
||||||
|
<li>
|
||||||
|
<div><strong><?= $e($item['title']) ?></strong><small>#<?= $e($item['key']) ?></small></div>
|
||||||
|
<div class="actions studio-block-actions">
|
||||||
|
<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" <?= $fixedSlot || $index === 0 || $page['sections'][$index - 1]['style'] === 'hero-links' ? 'disabled' : '' ?>>上移</button>
|
||||||
|
<button class="button button-outline" name="operation" value="down" type="submit" <?= $fixedSlot || $index === count($page['sections']) - 1 ? 'disabled' : '' ?>>下移</button>
|
||||||
|
<button class="button button-outline" name="operation" value="delete" type="submit" data-confirm="删除这个区块?">删除</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?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>
|
||||||
|
<?php if ($modules): ?><?= $anchorForm ?><?php endif ?>
|
||||||
|
<div class="studio-library-content" data-library-content hidden>
|
||||||
|
<div class="studio-library-category-title">
|
||||||
|
<button type="button" data-library-back>返回分类</button>
|
||||||
|
<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, $option, $feed] = array_pad($item, 4, null); ?>
|
||||||
|
<?php if ($modules): ?>
|
||||||
|
<article class="studio-template-card" data-template-card data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
|
||||||
|
<button type="button" class="studio-template-image" data-template-preview="<?= $e($key) ?>" data-template-title="<?= $e($label) ?>"
|
||||||
|
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) ?>" data-template-lead="<?= $e($option) ?>" data-template-style="<?= $e($item[4] ?? 'plain') ?>"
|
||||||
|
<?= $feed !== null ? 'data-template-feed="' . $e($feed) . '"' : '' ?> aria-label="添加<?= $e($label) ?>组件">添加</button>
|
||||||
|
</div>
|
||||||
|
<template data-preset="<?= $e($key) ?>"><?= $markup ?></template>
|
||||||
|
</article>
|
||||||
|
<?php else: ?>
|
||||||
|
<div data-library-item data-template-search-text="<?= $e($label . ' ' . $key) ?>">
|
||||||
|
<button type="button" disabled data-canvas-element="<?= $e($key) ?>"
|
||||||
|
<?php if ($option): ?>data-element-mime="<?= $e($option) ?>"<?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>
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
use App\Content\View;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
|
||||||
?>
|
|
||||||
<a class="back-link" href="/admin/catalog">返回目录管理</a>
|
|
||||||
<header class="admin-heading"><h1><?= $e($title) ?></h1></header>
|
|
||||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
|
||||||
<form class="admin-form admin-panel" method="post" action="/admin/catalog/<?= $e($id ?? 'new') ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<input type="hidden" name="version" value="<?= $e($product['version']) ?>">
|
|
||||||
<div class="form-grid">
|
|
||||||
<label>名称<input name="name" value="<?= $e($product['name']) ?>" required maxlength="100"></label>
|
|
||||||
<label>分类<input name="category" value="<?= $e($product['category']) ?>" required maxlength="70"></label>
|
|
||||||
</div>
|
|
||||||
<div class="form-grid">
|
|
||||||
<?= View::fragment('studio-asset-field', ['label' => '封面', 'name' => 'image', 'value' => $product['image']]) ?>
|
|
||||||
<label>封面替代文本<input name="alt" value="<?= $e($product['alt']) ?>" maxlength="200"></label>
|
|
||||||
</div>
|
|
||||||
<div class="form-grid">
|
|
||||||
<label>按钮文案<input name="label" value="<?= $e($product['label']) ?>" required maxlength="70"></label>
|
|
||||||
<label>按钮链接<input name="url" value="<?= $e($product['url']) ?>" required maxlength="1000"></label>
|
|
||||||
<label>次要链接文案<input name="extra_label" value="<?= $e($product['extra_label']) ?>" maxlength="70"></label>
|
|
||||||
<label>次要链接<input name="extra_url" value="<?= $e($product['extra_url']) ?>" maxlength="1000"></label>
|
|
||||||
</div>
|
|
||||||
<label>排序<input type="number" name="position" min="-999999" max="999999" value="<?= $e($product['position'] === '' ? 100 : $product['position']) ?>" required><small>数值越小越靠前。</small></label>
|
|
||||||
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $product['body']]) ?>
|
|
||||||
<div class="form-submit"><button class="button button-primary" type="submit">保存条目</button></div>
|
|
||||||
</form>
|
|
||||||
<?php if ($id !== null): ?>
|
|
||||||
<form class="admin-form" method="post" action="/admin/catalog/<?= $e($id) ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<input type="hidden" name="version" value="<?= $e($product['version']) ?>">
|
|
||||||
<div class="form-submit"><button class="button button-outline" type="submit" name="operation" value="delete" data-confirm="从公开目录删除此条目?">删除条目</button></div>
|
|
||||||
</form>
|
|
||||||
<?php endif ?>
|
|
||||||
@@ -36,7 +36,7 @@ $e = View::escape(...);
|
|||||||
<small>每行填写「显示号码 | tel:号码」。</small>
|
<small>每行填写「显示号码 | tel:号码」。</small>
|
||||||
</label>
|
</label>
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
<?php foreach (['products' => '第一列', 'company' => '第二列'] as $key => $text): ?>
|
<?php foreach (['products' => '第一列', 'company' => '第二列', 'resources' => '第三列'] as $key => $text): ?>
|
||||||
<div class="admin-form">
|
<div class="admin-form">
|
||||||
<label><?= $text ?>标题<input name="<?= $key ?>_title" value="<?= $e($config[$key . '_title']) ?>"></label>
|
<label><?= $text ?>标题<input name="<?= $key ?>_title" value="<?= $e($config[$key . '_title']) ?>"></label>
|
||||||
<label><?= $text ?>链接<textarea name="<?= $key ?>" rows="6"><?= $e(SiteDesign::linkText($config[$key])) ?></textarea>
|
<label><?= $text ?>链接<textarea name="<?= $key ?>" rows="6"><?= $e(SiteDesign::linkText($config[$key])) ?></textarea>
|
||||||
@@ -50,3 +50,11 @@ $e = View::escape(...);
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<div class="form-submit"><button class="button button-primary" type="submit">保存设置</button></div>
|
<div class="form-submit"><button class="button button-primary" type="submit">保存设置</button></div>
|
||||||
</form>
|
</form>
|
||||||
|
<?php if ($part === 'footer'): ?>
|
||||||
|
<form method="post" action="/admin/settings/footer">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<input type="hidden" name="version" value="<?= $e($revision) ?>">
|
||||||
|
<input type="hidden" name="operation" value="restore-footer">
|
||||||
|
<button class="button button-outline" type="submit" data-confirm="用原站的页脚内容覆盖当前页脚设置?">恢复原站页脚</button>
|
||||||
|
</form>
|
||||||
|
<?php endif ?>
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Content\BlockTemplates;
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$labels = ['modules' => '组件', 'elements' => '元素', 'layers' => '图层'];
|
||||||
|
?>
|
||||||
|
<div class="studio-presets" data-canvas-presets>
|
||||||
|
<div class="studio-library-tabs" role="tablist" aria-label="页面编辑工具" data-library-tabs hidden>
|
||||||
|
<?php foreach ($labels as $kind => $label): ?>
|
||||||
|
<button type="button" role="tab" id="studio-tab-<?= $kind ?>" aria-controls="studio-panel-<?= $kind ?>"
|
||||||
|
aria-selected="false" tabindex="-1" data-library-tab="<?= $kind ?>"><?= $e($label) ?></button>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php foreach (['modules' => BlockTemplates::groups(), 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
|
||||||
|
<?= View::fragment('studio-library-panel', compact('kind', 'groups', 'anchorForm')) ?>
|
||||||
|
<?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>
|
||||||
|
<img alt="">
|
||||||
|
<p></p>
|
||||||
|
</div>
|
||||||
|
<dialog class="media-picker studio-template-dialog" data-template-dialog aria-labelledby="studio-template-preview-title">
|
||||||
|
<header class="admin-heading compact">
|
||||||
|
<h2 id="studio-template-preview-title"></h2>
|
||||||
|
<button type="button" class="button button-outline" data-template-close>关闭</button>
|
||||||
|
</header>
|
||||||
|
<img alt="" width="768" height="480">
|
||||||
|
<div class="actions"><button type="button" class="button button-primary" data-template-use>添加到画布</button></div>
|
||||||
|
</dialog>
|
||||||
|
</div>
|
||||||
@@ -10,11 +10,11 @@ use Webman\Route;
|
|||||||
|
|
||||||
Route::disableDefaultRoute();
|
Route::disableDefaultRoute();
|
||||||
Route::get('/', [SiteController::class, 'home']);
|
Route::get('/', [SiteController::class, 'home']);
|
||||||
Route::get('/services', [SiteController::class, 'services']);
|
Route::get('/network', [SiteController::class, 'network']);
|
||||||
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
|
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
|
||||||
Route::get('/articles', [SiteController::class, 'archive']);
|
Route::get('/articles/category/{category:[a-z0-9-]+}', [SiteController::class, 'archive']);
|
||||||
Route::get('/articles/category/{category:announcement|news|product}', [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']);
|
||||||
@@ -27,16 +27,15 @@ Route::add(['GET', 'POST'], '/admin/login', [AdminController::class, 'login']);
|
|||||||
Route::post('/admin/logout', [AdminController::class, 'logout']);
|
Route::post('/admin/logout', [AdminController::class, 'logout']);
|
||||||
Route::add(['GET', 'POST'], '/admin/password', [AdminController::class, 'password']);
|
Route::add(['GET', 'POST'], '/admin/password', [AdminController::class, 'password']);
|
||||||
Route::get('/admin', [AdminController::class, 'dashboard']);
|
Route::get('/admin', [AdminController::class, 'dashboard']);
|
||||||
|
Route::add(['GET', 'POST'], '/admin/article-categories', [AdminController::class, 'articleCategories']);
|
||||||
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
||||||
|
Route::post('/admin/articles/{id:[0-9]+}/delete', [AdminController::class, 'deleteArticle']);
|
||||||
Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPage']);
|
Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPage']);
|
||||||
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
||||||
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
||||||
Route::add(['GET', 'POST'], '/admin/settings/{part:header|footer|cdn}', [StudioController::class, 'settings']);
|
Route::add(['GET', 'POST'], '/admin/settings/{part:header|footer|cdn}', [StudioController::class, 'settings']);
|
||||||
Route::get('/admin/catalog', [StudioController::class, 'catalog']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/catalog/new', [StudioController::class, 'product']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/catalog/{id:[0-9]+}', [StudioController::class, 'product']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/media', [StudioController::class, 'media']);
|
Route::add(['GET', 'POST'], '/admin/media', [StudioController::class, 'media']);
|
||||||
Route::get('/admin/media/options', [StudioController::class, 'mediaOptions']);
|
Route::get('/admin/media/options', [StudioController::class, 'mediaOptions']);
|
||||||
Route::post('/admin/media/{name:[a-f0-9]{32}\.[a-z0-9]+}', [StudioController::class, 'mediaMeta']);
|
Route::post('/admin/media/{name:[a-f0-9]{32}\.[a-z0-9]+}', [StudioController::class, 'mediaMeta']);
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
.feedback { padding: .8rem 1rem; border-radius: .5rem; }
|
.feedback { padding: .8rem 1rem; border-radius: .5rem; }
|
||||||
.feedback.error { background: #feebeb; color: #9c252a; }
|
.feedback.error { background: #feebeb; color: #9c252a; }
|
||||||
.feedback.success { background: #e5f6ed; color: #126044; }
|
.feedback.success { background: #e5f6ed; color: #126044; }
|
||||||
|
.button-danger { color: #9c252a; background: transparent; border-color: #e6b6b9; }
|
||||||
|
.button-danger:hover { color: #9c252a; background: #feebeb; }
|
||||||
.editor { display: grid; gap: .45rem; }
|
.editor { display: grid; gap: .45rem; }
|
||||||
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
|
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
|
||||||
.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
|
.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
|
||||||
@@ -54,10 +56,11 @@
|
|||||||
.admin-form button:disabled, .admin-bar button:disabled { cursor: progress; opacity: .65; }
|
.admin-form button:disabled, .admin-bar button:disabled { cursor: progress; opacity: .65; }
|
||||||
.admin-form .ajax-feedback { margin: 0; }
|
.admin-form .ajax-feedback { margin: 0; }
|
||||||
|
|
||||||
.studio-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(16rem, 1fr); gap: 1rem; align-items: start; }
|
|
||||||
.studio-frame-window { position: relative; height: min(67vh, 39rem); overflow: hidden; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--paper); }
|
.studio-frame-window { position: relative; height: min(67vh, 39rem); overflow: hidden; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--paper); }
|
||||||
.studio-frame-window iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
|
.studio-frame-window iframe { display: block; width: 100%; height: 100%; border: 0; background: white; }
|
||||||
.studio-frame-window.has-scaled-preview iframe { position: absolute; top: 0; transform-origin: 0 0; }
|
.studio-frame-window.has-scaled-preview iframe { position: absolute; top: 0; transform-origin: 0 0; }
|
||||||
|
.studio-canvas-toolbar { margin-bottom: .55rem; }
|
||||||
|
.studio-canvas-toolbar button:disabled { opacity: .5; cursor: default; }
|
||||||
.preview-selector { display: flex; gap: .35rem; flex-wrap: wrap; }
|
.preview-selector { display: flex; gap: .35rem; flex-wrap: wrap; }
|
||||||
.preview-selector [aria-pressed="true"] { background: var(--accent-light); color: var(--accent-deep); }
|
.preview-selector [aria-pressed="true"] { background: var(--accent-light); color: var(--accent-deep); }
|
||||||
.studio-inspector details label { margin-top: .7rem; }
|
.studio-inspector details label { margin-top: .7rem; }
|
||||||
@@ -81,6 +84,7 @@
|
|||||||
.media-card .media-archive { display: flex; align-items: center; }
|
.media-card .media-archive { display: flex; align-items: center; }
|
||||||
.media-card .media-archive input { width: auto; min-height: 0; }
|
.media-card .media-archive input { width: auto; min-height: 0; }
|
||||||
.media-picker { max-width: min(92vw, 52rem); max-height: 86vh; width: 100%; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
|
.media-picker { max-width: min(92vw, 52rem); max-height: 86vh; width: 100%; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
|
||||||
|
.media-picker.canvas-properties { max-width: min(92vw, 32rem); }
|
||||||
.media-picker::backdrop { background: #101c3488; }
|
.media-picker::backdrop { background: #101c3488; }
|
||||||
.media-picker label { display: grid; gap: .35rem; }
|
.media-picker label { display: grid; gap: .35rem; }
|
||||||
.media-picker input { padding: .55rem .75rem; border: 1px solid var(--line); border-radius: .4rem; }
|
.media-picker input { padding: .55rem .75rem; border: 1px solid var(--line); border-radius: .4rem; }
|
||||||
@@ -88,5 +92,225 @@
|
|||||||
.picker-item { text-align: left; min-height: 44px; }
|
.picker-item { text-align: left; min-height: 44px; }
|
||||||
.picker-item:hover { border-color: var(--accent); }
|
.picker-item:hover { border-color: var(--accent); }
|
||||||
@media (max-width: 65rem) {
|
@media (max-width: 65rem) {
|
||||||
.studio-layout { grid-template-columns: minmax(0, 1fr); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.admin-wrap.admin-wide { width: calc(100% - clamp(1rem, 3vw, 3rem)); }
|
||||||
|
.studio-layout {
|
||||||
|
display: grid;
|
||||||
|
align-items: start;
|
||||||
|
grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
|
||||||
|
grid-template-areas: "library workspace" "library settings";
|
||||||
|
gap: .9rem;
|
||||||
|
}
|
||||||
|
.studio-library { grid-area: library; position: sticky; z-index: 3; top: .75rem; max-height: calc(100vh - 1.5rem); overflow: auto; }
|
||||||
|
.studio-library h2 { font-size: 1.05rem; margin-bottom: .7rem; }
|
||||||
|
.studio-workspace { grid-area: workspace; min-width: 0; }
|
||||||
|
.studio-inspector { grid-area: settings; }
|
||||||
|
.studio-workspace .studio-preview { padding: clamp(.55rem, 1.25vw, 1rem); }
|
||||||
|
.studio-workspace .studio-frame-window { height: max(34rem, calc(100dvh - 16rem)); }
|
||||||
|
.studio-workspace .studio-preview h2 { font-size: 1.2rem; }
|
||||||
|
.studio-presets { display: grid; gap: .4rem; }
|
||||||
|
.studio-library .studio-layers button:not(.button), .studio-pending button {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 2.75rem;
|
||||||
|
padding: .55rem .75rem;
|
||||||
|
margin: 0;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: .45rem;
|
||||||
|
background: var(--white);
|
||||||
|
color: var(--ink);
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.studio-library button:not(.button):hover { border-color: var(--accent); color: var(--accent); }
|
||||||
|
.studio-insert-mode { margin-block: .45rem .15rem; font-size: .875rem; }
|
||||||
|
.studio-pending { padding: 0; margin: 0; list-style: none; }
|
||||||
|
.studio-pending li + li { margin-top: .3rem; }
|
||||||
|
.studio-presets [role="status"]:empty { margin: 0; }
|
||||||
|
.studio-layers { border-top: 1px solid var(--line); margin-top: .85rem; padding-top: .55rem; }
|
||||||
|
.studio-layers summary { cursor: pointer; font-weight: 620; }
|
||||||
|
.studio-layers[open] > summary { margin-bottom: .55rem; }
|
||||||
|
.studio-library .studio-layers > button + button { margin-top: .3rem; }
|
||||||
|
.studio-layers .studio-blocks li { display: grid; gap: .4rem; }
|
||||||
|
.studio-layers .studio-block-actions .button { min-height: 2.25rem; padding: .25rem .5rem; font-size: .8rem; }
|
||||||
|
.studio-media-sizing { position: absolute; z-index: 1; inset: auto .6rem .6rem auto; display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .45rem .6rem; max-width: calc(100% - 1.2rem); background: var(--accent-light); border: 1px solid var(--line); border-radius: .45rem; }
|
||||||
|
.studio-element-tools {
|
||||||
|
position: absolute; z-index: 3; display: flex; align-items: center; gap: .12rem; padding: .18rem;
|
||||||
|
border: 1px solid #c7d6f3; border-radius: .52rem; background: var(--white);
|
||||||
|
box-shadow: 0 .22rem .85rem #16305230;
|
||||||
|
}
|
||||||
|
.studio-element-tools button {
|
||||||
|
display: grid; place-items: center; width: 2rem; height: 2rem; padding: 0;
|
||||||
|
border: 0; border-radius: .32rem; background: transparent; color: #35496d; cursor: pointer;
|
||||||
|
}
|
||||||
|
.studio-element-tools button svg { width: 1rem; height: 1rem; pointer-events: none; }
|
||||||
|
.studio-element-tools button:hover, .studio-element-tools button:focus-visible { background: var(--accent-light); color: var(--accent-deep); }
|
||||||
|
.studio-element-tools button:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }
|
||||||
|
.studio-element-tools button[data-element-delete]:hover { color: #a12727; background: #fceeee; }
|
||||||
|
.studio-element-tools.is-module [data-element-module-settings] { background: var(--accent-light); color: var(--accent-deep); }
|
||||||
|
.studio-media-handle {
|
||||||
|
position: absolute; z-index: 2; width: 1.4rem; height: 2.8rem; translate: -50% -50%;
|
||||||
|
display: grid; place-content: center; border: 2px solid white; border-radius: .42rem;
|
||||||
|
background: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: white; cursor: ew-resize;
|
||||||
|
touch-action: none; user-select: none;
|
||||||
|
}
|
||||||
|
.studio-media-handle::after { content: ''; width: .38rem; height: .9rem; border-inline: 1px solid currentColor; }
|
||||||
|
.studio-media-sizing output { font-size: .85rem; font-variant-numeric: tabular-nums; }
|
||||||
|
.studio-media-sizing .button { min-height: 2.2rem; padding: .25rem .7rem; }
|
||||||
|
@media (max-width: 54rem) {
|
||||||
|
.studio-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "library" "workspace" "settings"; }
|
||||||
|
.studio-library { position: static; max-height: none; }
|
||||||
|
.studio-workspace .studio-frame-window { height: max(25rem, 64dvh); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-template-search { display: grid; gap: .3rem; font-size: .9rem; font-weight: 600; }
|
||||||
|
.studio-template-search input {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 42px;
|
||||||
|
padding: .45rem .6rem;
|
||||||
|
color: var(--ink);
|
||||||
|
background: var(--white);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: .5rem;
|
||||||
|
}
|
||||||
|
.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-library-tabs button, .studio-library-categories button, .studio-library-category-title button, .studio-element-items button {
|
||||||
|
color: var(--ink); font-family: inherit; cursor: pointer;
|
||||||
|
}
|
||||||
|
.studio-library-tabs button { min-height: 2.4rem; padding: .3rem .18rem; border: 1px solid transparent; border-radius: .42rem; background: transparent; font-size: .84rem; }
|
||||||
|
.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-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-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-image {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 0;
|
||||||
|
border-radius: .5rem .5rem 0 0;
|
||||||
|
background: var(--paper);
|
||||||
|
}
|
||||||
|
.studio-template-image img { display: block; width: 100%; height: auto; aspect-ratio: 8 / 5; transition: transform .16s ease; }
|
||||||
|
.studio-template-image:hover img, .studio-template-image:focus-visible img { transform: scale(1.07); }
|
||||||
|
.studio-template-meta { display: flex; align-items: center; justify-content: space-between; gap: .3rem; padding: .3rem .38rem .3rem .55rem; font-size: .875rem; }
|
||||||
|
.studio-template-meta .button { min-height: 33px; font-size: .8rem; flex: 0 0 auto; padding: .2rem .45rem; }
|
||||||
|
.studio-template-peek {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 2;
|
||||||
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
background: var(--white);
|
||||||
|
border: 1px solid #adbfdf;
|
||||||
|
border-radius: .65rem;
|
||||||
|
box-shadow: 0 14px 35px #142e5626;
|
||||||
|
}
|
||||||
|
.studio-template-peek img, .studio-template-dialog img { width: 100%; height: auto; aspect-ratio: 8 / 5; display: block; }
|
||||||
|
.studio-template-peek p { padding: .5rem .8rem; margin: 0; font-size: .9rem; color: var(--ink); }
|
||||||
|
.studio-template-dialog { width: min(90vw, 49rem); }
|
||||||
|
.studio-template-dialog > img { border: 1px solid var(--line); border-radius: .55rem; }
|
||||||
|
.studio-template-dialog > .actions { justify-content: flex-end; margin-top: .75rem; }
|
||||||
|
|
||||||
|
@media (max-width: 54rem) {
|
||||||
|
.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-meta { flex-wrap: wrap; }
|
||||||
|
.studio-template-peek { display: none; }
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.studio-template-image img { transition: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.category-checks { min-width: 0; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: .5rem; }
|
||||||
|
.category-checks > div { display: flex; flex-wrap: wrap; gap: .45rem 1.25rem; }
|
||||||
|
.admin-form .category-checks label { display: inline-flex; align-items: center; gap: .35rem; }
|
||||||
|
.admin-form .category-checks input { min-height: 0; width: auto; }
|
||||||
|
.admin-options { padding: .7rem 1rem; border: 1px solid var(--line); border-radius: .5rem; }
|
||||||
|
.admin-options > summary { font-weight: 650; cursor: pointer; }
|
||||||
|
.admin-options[open] > summary { margin-bottom: .85rem; }
|
||||||
|
.admin-options .form-grid + .category-checks { margin-top: .8rem; }
|
||||||
|
.article-editor { min-width: 0; }
|
||||||
|
.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-help:empty { display: none; }
|
||||||
|
|
||||||
|
.studio-element-align { display: flex; gap: .05rem; padding-inline-end: .15rem; border-inline-end: 1px solid var(--line); }
|
||||||
|
.studio-element-align button[aria-pressed="true"] { background: var(--accent-light); color: var(--accent-deep); }
|
||||||
|
|
||||||
|
.admin-primary a { padding: .28rem .65rem; border-radius: .48rem; color: var(--muted); }
|
||||||
|
.admin-primary a[aria-current="page"] { background: var(--accent-light); color: var(--accent-deep); }
|
||||||
|
.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-setting-buttons { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; padding: 0; margin: 0; }
|
||||||
|
.dashboard-setting-buttons .button { min-height: 2.45rem; padding: .3rem .6rem; font-size: .85rem; }
|
||||||
|
|
||||||
|
@media (max-width: 51rem) {
|
||||||
|
.dashboard-grid { grid-template-columns: 1fr; gap: 0; }
|
||||||
|
.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; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
|
||||||
|
.studio-page-meta code { color: var(--muted); font-size: .86rem; }
|
||||||
|
.studio-anchor-create, .studio-hero-settings { padding: .55rem .65rem; border: 1px solid var(--line); border-radius: .45rem; }
|
||||||
|
.studio-anchor-create { margin-top: .55rem; font-size: .84rem; }
|
||||||
|
.studio-anchor-create summary, .studio-hero-settings summary { cursor: pointer; font-weight: 630; }
|
||||||
|
.studio-anchor-create[open] form, .studio-hero-controls { margin-top: .6rem; }
|
||||||
|
.studio-hero-controls { display: flex; flex-wrap: wrap; gap: .42rem; }
|
||||||
|
.studio-hero-controls .button { min-height: 2.35rem; padding: .3rem .62rem; font-size: .85rem; }
|
||||||
|
.studio-canvas-status:empty { display: none; }
|
||||||
|
.canvas-module-settings { max-width: min(92vw, 40rem); }
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
.studio-element-tools button { width: 2.5rem; height: 2.5rem; }
|
||||||
|
}
|
||||||
|
.canvas-module-settings .category-checks { max-height: min(15rem, 27dvh); overflow-y: auto; }
|
||||||
|
.canvas-module-settings .actions { position: sticky; bottom: 0; padding-block: .35rem; margin: 0; background: var(--white); }
|
||||||
|
|||||||
@@ -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: ['## ', '', '小标题'],
|
||||||
@@ -16,6 +35,18 @@ jQuery(function ($) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function clearSavedStatus() {
|
||||||
|
$('[data-save-confirmation]').prop('hidden', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector('[data-save-confirmation]')) {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
if (url.searchParams.get('saved') === '1') {
|
||||||
|
url.searchParams.delete('saved');
|
||||||
|
window.history.replaceState(window.history.state, '', url.href);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function refreshToken(response) {
|
function refreshToken(response) {
|
||||||
if (response?.csrf) {
|
if (response?.csrf) {
|
||||||
$('input[name="csrf"]').val(response.csrf);
|
$('input[name="csrf"]').val(response.csrf);
|
||||||
@@ -37,22 +68,29 @@ jQuery(function ($) {
|
|||||||
$feedback.prop('hidden', false).trigger('focus');
|
$feedback.prop('hidden', false).trigger('focus');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('invalid', (event) => {
|
||||||
|
if (event.target.form?.method.toLowerCase() === 'post') clearSavedStatus();
|
||||||
|
}, true);
|
||||||
|
|
||||||
$('form[method="post"]').on('submit', function (event) {
|
$('form[method="post"]').on('submit', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const $form = $(this);
|
const $form = $(this);
|
||||||
if ($form.attr('aria-busy') === 'true') return;
|
if ($form.attr('aria-busy') === 'true') return;
|
||||||
const submitter = event.originalEvent?.submitter;
|
const submitter = event.originalEvent?.submitter;
|
||||||
if (submitter?.dataset.confirm && !window.confirm(submitter.dataset.confirm)) return;
|
if (submitter?.dataset.confirm && !window.confirm(submitter.dataset.confirm)) return;
|
||||||
|
clearSavedStatus();
|
||||||
const action = $form.attr('action');
|
const action = $form.attr('action');
|
||||||
const isLogin = action === '/admin/login';
|
const isLogin = action === '/admin/login';
|
||||||
const $submit = $form.find(':submit:enabled');
|
const $submit = $form.find(':submit:enabled');
|
||||||
const multipart = $form.attr('enctype') === 'multipart/form-data';
|
const multipart = $form.attr('enctype') === 'multipart/form-data';
|
||||||
$form.attr('aria-busy', 'true').children('.ajax-feedback').prop('hidden', true);
|
$form.attr('aria-busy', 'true').children('.ajax-feedback').prop('hidden', true);
|
||||||
$submit.prop('disabled', true);
|
$submit.prop('disabled', true);
|
||||||
|
$form.triggerHandler('studio:busy', [true]);
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
$form.removeAttr('aria-busy');
|
$form.removeAttr('aria-busy');
|
||||||
$submit.prop('disabled', false);
|
$submit.prop('disabled', false);
|
||||||
|
$form.triggerHandler('studio:busy', [false]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit(canRetryLogin) {
|
function submit(canRetryLogin) {
|
||||||
@@ -71,11 +109,12 @@ jQuery(function ($) {
|
|||||||
dataType: 'json'
|
dataType: 'json'
|
||||||
}).done(function (response) {
|
}).done(function (response) {
|
||||||
if (response.redirect) {
|
if (response.redirect) {
|
||||||
|
$form.triggerHandler('studio:saved');
|
||||||
window.location.assign(response.redirect);
|
window.location.assign(response.redirect);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
formError($form, '未收到保存结果,请刷新页面确认。');
|
|
||||||
finish();
|
finish();
|
||||||
|
formError($form, '未收到保存结果,请刷新页面确认。');
|
||||||
}).fail(function (request) {
|
}).fail(function (request) {
|
||||||
const response = request.responseJSON;
|
const response = request.responseJSON;
|
||||||
refreshToken(response);
|
refreshToken(response);
|
||||||
@@ -83,8 +122,8 @@ jQuery(function ($) {
|
|||||||
submit(false);
|
submit(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
formError($form, response?.message || '请求未完成,请稍后重试。', request.status);
|
|
||||||
finish();
|
finish();
|
||||||
|
formError($form, response?.message || '请求未完成,请稍后重试。', request.status);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
jQuery(function ($) {
|
||||||
|
$('[data-article-editor]').each(function () {
|
||||||
|
const Editor = window.toastui?.Editor;
|
||||||
|
if (!Editor) return;
|
||||||
|
const $field = $(this);
|
||||||
|
const $source = $field.find('textarea');
|
||||||
|
const $format = $field.find('input[name="body_format"]');
|
||||||
|
const $host = $field.find('[data-editor-host]');
|
||||||
|
const $status = $field.find('[data-article-editor-status]');
|
||||||
|
const originalFormat = $format.val();
|
||||||
|
const original = $source.val();
|
||||||
|
$host.prop('hidden', false);
|
||||||
|
let editor;
|
||||||
|
try {
|
||||||
|
editor = new Editor({
|
||||||
|
el: $host.get(0),
|
||||||
|
height: '34rem',
|
||||||
|
initialEditType: originalFormat === 'html' ? 'wysiwyg' : 'markdown',
|
||||||
|
initialValue: originalFormat === 'markdown' ? original : '',
|
||||||
|
previewStyle: 'vertical',
|
||||||
|
language: 'zh-CN',
|
||||||
|
usageStatistics: false,
|
||||||
|
autofocus: false,
|
||||||
|
hooks: {
|
||||||
|
addImageBlobHook() {
|
||||||
|
$status.text('请先上传图片到媒体库,再从媒体库插入。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (originalFormat === 'html') editor.setHTML(original);
|
||||||
|
} catch (error) {
|
||||||
|
$host.prop('hidden', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const snapshot = originalFormat === 'html' ? editor.getHTML() : editor.getMarkdown();
|
||||||
|
$source.prop('hidden', true);
|
||||||
|
$field.find('[data-article-editor-label]').removeAttr('for');
|
||||||
|
$field.find('[data-insert-article-image]').prop('hidden', false).on('click', () => {
|
||||||
|
$('#media-picker').triggerHandler('studio:pick', ['image/', (file) => {
|
||||||
|
const alt = window.prompt('图片替代文本(装饰图可留空)', file.label);
|
||||||
|
if (alt === null) return;
|
||||||
|
$status.empty();
|
||||||
|
editor.focus();
|
||||||
|
editor.exec('addImage', {imageUrl: file.url, altText: alt});
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
$field.closest('form').on('studio:sync', function () {
|
||||||
|
const format = editor.isMarkdownMode() ? 'markdown' : 'html';
|
||||||
|
const content = format === 'html' ? editor.getHTML() : editor.getMarkdown();
|
||||||
|
$format.val(format);
|
||||||
|
$source.val(format === originalFormat && content === snapshot ? original : content);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
After Width: | Height: | Size: 12 KiB |
@@ -152,15 +152,14 @@ address { font-style: normal; }
|
|||||||
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
|
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }
|
||||||
.crumb-divider { color: #74859d; }
|
.crumb-divider { color: #74859d; }
|
||||||
.hero-directory {
|
.hero-directory {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: minmax(0, .9fr) repeat(4, minmax(0, 1fr));
|
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: .85rem .85rem 0 0;
|
border-radius: .85rem .85rem 0 0;
|
||||||
background: #ffffffb8;
|
background: #ffffffb8;
|
||||||
min-height: 7rem;
|
min-height: 7rem;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
.hero-directory > * { display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); }
|
.hero-directory > * { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .12rem; padding: .75rem clamp(.6rem, 2vw, 1.85rem); overflow-wrap: anywhere; }
|
||||||
.hero-directory a { color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); transition: background-color 160ms ease, color 160ms ease; }
|
.hero-directory a { color: var(--ink); text-decoration: none; border-inline-start: 1px solid var(--line); transition: background-color 160ms ease, color 160ms ease; }
|
||||||
.hero-directory a:hover { color: var(--accent); background: #fff; }
|
.hero-directory a:hover { color: var(--accent); background: #fff; }
|
||||||
.hero-directory a span { font-size: 1.12rem; font-weight: 670; }
|
.hero-directory a span { font-size: 1.12rem; font-weight: 670; }
|
||||||
@@ -282,7 +281,9 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.network-group + .network-group { margin-top: 2.2rem; }
|
.network-group + .network-group { margin-top: 2.2rem; }
|
||||||
.network-group h3 { margin-bottom: .8rem; }
|
.network-group h3 { margin-bottom: .8rem; }
|
||||||
.network-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .7rem; }
|
.network-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .7rem; }
|
||||||
.network-list li > * { display: flex; align-items: center; gap: .75rem; min-height: 4rem; height: 100%; border-radius: .65rem; background: var(--white); border: 1px solid var(--line); color: var(--ink); text-decoration: none; padding: .75rem; transition: transform 160ms ease, border-color 160ms ease; }
|
.network-list li { display: flex; flex-direction: column; gap: .35rem; }
|
||||||
|
.network-list li > * { display: flex; align-items: center; gap: .75rem; min-height: 4rem; border-radius: .65rem; background: var(--white); border: 1px solid var(--line); color: var(--ink); text-decoration: none; padding: .75rem; transition: transform 160ms ease, border-color 160ms ease; }
|
||||||
|
.network-list li > :first-child { flex: 1; }
|
||||||
.network-list a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
|
.network-list a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
|
||||||
.network-list img { max-width: 3rem; max-height: 1.8rem; object-fit: contain; object-position: left; }
|
.network-list img { max-width: 3rem; max-height: 1.8rem; object-fit: contain; object-position: left; }
|
||||||
.network-list img[src$="oneprovider_invert.svg"] { background: #29354a; border-radius: .25rem; padding: .21rem; }
|
.network-list img[src$="oneprovider_invert.svg"] { background: #29354a; border-radius: .25rem; padding: .21rem; }
|
||||||
@@ -301,18 +302,22 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
|
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
|
||||||
.empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; }
|
.empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; }
|
||||||
|
|
||||||
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #edf2fa; border-top: 1px solid var(--line); }
|
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #e4ecfc; border-top: 1px solid var(--line); }
|
||||||
.footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, .75fr)); gap: 1.5rem 3rem; }
|
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem clamp(2rem, 7vw, 7rem); }
|
||||||
.footer-grid > div { display: flex; flex-direction: column; align-items: flex-start; }
|
.footer-company { display: flex; flex-direction: column; align-items: flex-start; }
|
||||||
|
.footer-logo img { width: clamp(8.125rem, 13vw, 10rem); height: auto; }
|
||||||
|
.footer-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 1rem; }
|
||||||
|
.footer-links ul { padding: 0; margin: 0; list-style: none; }
|
||||||
.footer-grid a, .footer-meta a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
|
.footer-grid a, .footer-meta a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
|
||||||
.footer-grid a:hover, .footer-meta a:hover { color: var(--accent); text-decoration: underline; }
|
.footer-grid a:hover, .footer-meta a:hover { color: var(--accent); text-decoration: underline; }
|
||||||
.footer-grid a { min-height: 44px; display: inline-flex; align-items: center; }
|
.footer-grid a { min-height: 40px; display: inline-flex; align-items: center; }
|
||||||
.footer-company p, .footer-label { color: var(--ink); font-weight: 640; margin: .2rem 0 .35rem; }
|
.footer-company p, .footer-label { color: var(--ink); font-weight: 640; margin: .2rem 0 .35rem; }
|
||||||
|
.footer-label { font-size: 1.05rem; line-height: 1.35; }
|
||||||
.footer-company p { margin-top: .6rem; }
|
.footer-company p { margin-top: .6rem; }
|
||||||
|
.footer-company .footer-payment-label { margin: .25rem 0 0; color: var(--muted); font-size: .87rem; font-weight: 500; }
|
||||||
.footer-company address { color: var(--muted); max-width: 26rem; font-size: .95rem; }
|
.footer-company address { color: var(--muted); max-width: 26rem; font-size: .95rem; }
|
||||||
.footer-meta { display: flex; flex-wrap: wrap; gap: .6rem 1.8rem; padding-top: 1.2rem; margin-top: 1.25rem; border-top: 1px solid var(--line); font-size: .875rem; }
|
.footer-meta { display: grid; gap: .35rem; padding-top: 1.2rem; margin-top: 1.6rem; border-top: 1px solid var(--line); font-size: .875rem; }
|
||||||
.footer-meta p { margin: 0; }
|
.footer-meta p { margin: 0; }
|
||||||
.footer-terms { flex-basis: 100%; }
|
|
||||||
|
|
||||||
@media (max-width: 62rem) {
|
@media (max-width: 62rem) {
|
||||||
.masthead-inner { gap: .85rem; }
|
.masthead-inner { gap: .85rem; }
|
||||||
@@ -344,10 +349,11 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.hero-lead { margin-bottom: 1.3rem; }
|
.hero-lead { margin-bottom: 1.3rem; }
|
||||||
.hero-illustration { border-radius: 1.15rem; }
|
.hero-illustration { border-radius: 1.15rem; }
|
||||||
.hero-illustration img { border-radius: .8rem; }
|
.hero-illustration img { border-radius: .8rem; }
|
||||||
.hero-directory { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: .2rem; }
|
.hero-directory { flex-wrap: wrap; margin-top: .2rem; }
|
||||||
.hero-directory > .overline { grid-column: 1 / -1; }
|
.hero-directory > * { flex-basis: 50%; }
|
||||||
|
.hero-directory > .directory-label { flex-basis: 100%; border-top: 0; }
|
||||||
.hero-directory a { border-top: 1px solid var(--line); min-height: 4rem; padding-inline: .8rem; }
|
.hero-directory a { border-top: 1px solid var(--line); min-height: 4rem; padding-inline: .8rem; }
|
||||||
.hero-directory a:nth-child(even) { border-inline-start: 0; }
|
.hero-directory > a:nth-child(odd of :not(.directory-label)) { border-inline-start: 0; }
|
||||||
.section-nav-inner { column-gap: 1.1rem; }
|
.section-nav-inner { column-gap: 1.1rem; }
|
||||||
.section-nav a { font-size: .875rem; }
|
.section-nav a { font-size: .875rem; }
|
||||||
.project, .project:nth-child(even) { grid-template-columns: 1fr; gap: 1rem; }
|
.project, .project:nth-child(even) { grid-template-columns: 1fr; gap: 1rem; }
|
||||||
@@ -358,8 +364,9 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.article-category { grid-column: 1; grid-row: 1; }
|
.article-category { grid-column: 1; grid-row: 1; }
|
||||||
.article-row-title { grid-column: 1 / -1; grid-row: 2; }
|
.article-row-title { grid-column: 1 / -1; grid-row: 2; }
|
||||||
.article-row time { grid-column: 2; grid-row: 1; }
|
.article-row time { grid-column: 2; grid-row: 1; }
|
||||||
.footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
|
.footer-grid { grid-template-columns: 1fr; }
|
||||||
.footer-company { grid-column: 1 / -1; }
|
.footer-company { align-items: center; text-align: center; }
|
||||||
|
.footer-links, .footer-meta { text-align: center; }
|
||||||
}
|
}
|
||||||
@media (max-width: 23rem) {
|
@media (max-width: 23rem) {
|
||||||
.hero-actions .button { width: 100%; }
|
.hero-actions .button { width: 100%; }
|
||||||
@@ -377,13 +384,12 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.catalog-hero { background: var(--paper); padding-block: clamp(3rem, 6vw, 6rem); }
|
.catalog-hero { background: var(--paper); padding-block: clamp(3rem, 6vw, 6rem); }
|
||||||
.catalog-hero h1 { margin-bottom: .85rem; }
|
.catalog-hero h1 { margin-bottom: .85rem; }
|
||||||
.catalog-hero p { margin: 0; font-size: 1.15rem; }
|
.catalog-hero p { margin: 0; font-size: 1.15rem; }
|
||||||
.catalog-listing { padding-block: clamp(3rem, 6vw, 6rem); }
|
|
||||||
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2rem); }
|
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 3vw, 2rem); }
|
||||||
.catalog-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
|
.catalog-card { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
|
||||||
.catalog-image { aspect-ratio: 16 / 8; padding: clamp(.8rem, 3vw, 1.8rem); background: var(--paper); display: grid; place-items: center; }
|
.catalog-image { aspect-ratio: 16 / 8; padding: clamp(.8rem, 3vw, 1.8rem); background: var(--paper); display: grid; place-items: center; }
|
||||||
.catalog-image img { max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
|
.catalog-image img { max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
|
||||||
.catalog-content { padding: clamp(1.25rem, 3vw, 2rem); flex: 1; display: flex; flex-direction: column; }
|
.catalog-content { padding: clamp(1.25rem, 3vw, 2rem); flex: 1; display: flex; flex-direction: column; }
|
||||||
.catalog-content h2 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
|
.catalog-content h3 { font-size: clamp(1.45rem, 3vw, 2.6rem); margin-bottom: .7rem; }
|
||||||
.catalog-content .overline { margin-bottom: .4rem; }
|
.catalog-content .overline { margin-bottom: .4rem; }
|
||||||
.catalog-content .actions { margin-top: auto; padding-top: 1rem; }
|
.catalog-content .actions { margin-top: auto; padding-top: 1rem; }
|
||||||
|
|
||||||
@@ -395,7 +401,7 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.hero-shnu-sc ~ #benefits .rich > ul li + li { margin-top: .35rem; }
|
.hero-shnu-sc ~ #benefits .rich > ul li + li { margin-top: .35rem; }
|
||||||
.hero-shnu-sc ~ #benefits .rich > ul li::marker { color: var(--accent); }
|
.hero-shnu-sc ~ #benefits .rich > ul li::marker { color: var(--accent); }
|
||||||
.hero-shnu-sc ~ #benefits .rich > img {
|
.hero-shnu-sc ~ #benefits .rich > img {
|
||||||
width: 100%;
|
width: var(--studio-media-width, 100%);
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
box-shadow: 0 .75rem 2.25rem #101c341a;
|
box-shadow: 0 .75rem 2.25rem #101c341a;
|
||||||
@@ -467,10 +473,266 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
}
|
}
|
||||||
@media (max-width: 44rem) {
|
@media (max-width: 44rem) {
|
||||||
.catalog-grid, .copyright-service #materials .feature-grid { grid-template-columns: 1fr; }
|
.catalog-grid, .copyright-service #materials .feature-grid { grid-template-columns: 1fr; }
|
||||||
.hero-directory > .directory-label { grid-column: 1 / -1; border-top: 0; }
|
|
||||||
.copyright-service #go > .wrap { padding: 1.55rem; min-height: 0; }
|
.copyright-service #go > .wrap { padding: 1.55rem; min-height: 0; }
|
||||||
.copyright-service #go .contact-panel { display: flex; gap: 1rem; }
|
.copyright-service #go .contact-panel { display: flex; gap: 1rem; }
|
||||||
.copyright-service #go .contact-panel img { position: static; transform: none; width: 7rem; }
|
.copyright-service #go .contact-panel img { position: static; transform: none; width: 7rem; }
|
||||||
}
|
}
|
||||||
.hero h1 .hero-heading-primary { color: inherit; }
|
.hero h1 .hero-heading-primary { color: inherit; }
|
||||||
[data-studio-field][contenteditable] { min-height: 1em; outline: 1px dashed #7896d5; outline-offset: 3px; }
|
.studio-accent { display: block; }
|
||||||
|
[data-studio-editing] [contenteditable], [data-studio-editing] [data-studio-action],
|
||||||
|
[data-studio-editing] [data-studio-navigation] a, [data-studio-editing] [data-studio-hero-image] {
|
||||||
|
outline: 1px dashed #7896d5;
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
[data-studio-editing] [contenteditable]:focus { outline: 2px solid #4477f9; }
|
||||||
|
[data-studio-editing] :is([data-studio-action], [data-studio-navigation] a, [data-studio-hero-image], .rich :is(img, video, audio)) { cursor: pointer; }
|
||||||
|
[data-studio-editing] [data-studio-placeholder]:empty::before {
|
||||||
|
content: attr(data-studio-placeholder);
|
||||||
|
color: var(--muted);
|
||||||
|
font: 400 1rem / 1.5 var(--sans);
|
||||||
|
}
|
||||||
|
|
||||||
|
.home-cursor {
|
||||||
|
display: inline-block;
|
||||||
|
width: .52em;
|
||||||
|
margin-inline-start: .08em;
|
||||||
|
font-family: var(--mono);
|
||||||
|
font-size: .7em;
|
||||||
|
animation: home-cursor-blink 1.1s steps(1, end) 5;
|
||||||
|
}
|
||||||
|
@keyframes home-cursor-blink { 50% { opacity: 0; } }
|
||||||
|
|
||||||
|
.home-pipe-flow {
|
||||||
|
position: absolute;
|
||||||
|
inset: clamp(.45rem, 1.8vw, 1.7rem);
|
||||||
|
width: calc(100% - 2 * clamp(.45rem, 1.8vw, 1.7rem));
|
||||||
|
height: calc(100% - 2 * clamp(.45rem, 1.8vw, 1.7rem));
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
.home-pipe-route { opacity: 0; animation: pipe-visibility 7s linear 2 both; }
|
||||||
|
.home-pipe-route use {
|
||||||
|
fill: none;
|
||||||
|
stroke: #2985fa;
|
||||||
|
stroke-width: 3;
|
||||||
|
stroke-linecap: round;
|
||||||
|
stroke-dasharray: 17 110;
|
||||||
|
stroke-dashoffset: 19;
|
||||||
|
opacity: .48;
|
||||||
|
animation: pipe-travel 7s linear 2 both;
|
||||||
|
}
|
||||||
|
.home-pipe-route use + use { stroke: #ecffff; stroke-width: 1.3; stroke-dasharray: 11 116; opacity: .95; }
|
||||||
|
.home-pipe-route:nth-of-type(2) { --pipe-delay: .85s; }
|
||||||
|
.home-pipe-route:nth-of-type(3) { --pipe-delay: 2.35s; }
|
||||||
|
.home-pipe-route:nth-of-type(4) { --pipe-delay: 3.2s; }
|
||||||
|
.home-pipe-route, .home-pipe-route use { animation-delay: var(--pipe-delay, 0s); }
|
||||||
|
@keyframes pipe-travel { 0%, 6% { stroke-dashoffset: 19; } 45%, 100% { stroke-dashoffset: -104; } }
|
||||||
|
@keyframes pipe-visibility { 0%, 6%, 45%, 100% { opacity: 0; } 13%, 37% { opacity: 1; } }
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.home-cursor { animation: none; }
|
||||||
|
.home-pipe-flow { display: none; }
|
||||||
|
}
|
||||||
|
|
||||||
|
.studio-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; align-items: center; }
|
||||||
|
.studio-split > img { width: 100%; }
|
||||||
|
.studio-banner { padding: clamp(1.25rem, 4vw, 3.25rem); border-radius: var(--radius); background: var(--accent-light); }
|
||||||
|
@media (max-width: 44rem) { .studio-split { grid-template-columns: 1fr; } }
|
||||||
|
|
||||||
|
:where(img, video, audio, .hero-visual)[class*="studio-media-"] { max-width: 100%; }
|
||||||
|
:is(.rich, .hero-inner, .editor-preview) [class*="studio-media-"] { width: var(--studio-media-width, auto); }
|
||||||
|
.studio-media-10 { --studio-media-width: 10%; }
|
||||||
|
.studio-media-11 { --studio-media-width: 11%; }
|
||||||
|
.studio-media-12 { --studio-media-width: 12%; }
|
||||||
|
.studio-media-13 { --studio-media-width: 13%; }
|
||||||
|
.studio-media-14 { --studio-media-width: 14%; }
|
||||||
|
.studio-media-15 { --studio-media-width: 15%; }
|
||||||
|
.studio-media-16 { --studio-media-width: 16%; }
|
||||||
|
.studio-media-17 { --studio-media-width: 17%; }
|
||||||
|
.studio-media-18 { --studio-media-width: 18%; }
|
||||||
|
.studio-media-19 { --studio-media-width: 19%; }
|
||||||
|
.studio-media-20 { --studio-media-width: 20%; }
|
||||||
|
.studio-media-21 { --studio-media-width: 21%; }
|
||||||
|
.studio-media-22 { --studio-media-width: 22%; }
|
||||||
|
.studio-media-23 { --studio-media-width: 23%; }
|
||||||
|
.studio-media-24 { --studio-media-width: 24%; }
|
||||||
|
.studio-media-25 { --studio-media-width: 25%; }
|
||||||
|
.studio-media-26 { --studio-media-width: 26%; }
|
||||||
|
.studio-media-27 { --studio-media-width: 27%; }
|
||||||
|
.studio-media-28 { --studio-media-width: 28%; }
|
||||||
|
.studio-media-29 { --studio-media-width: 29%; }
|
||||||
|
.studio-media-30 { --studio-media-width: 30%; }
|
||||||
|
.studio-media-31 { --studio-media-width: 31%; }
|
||||||
|
.studio-media-32 { --studio-media-width: 32%; }
|
||||||
|
.studio-media-33 { --studio-media-width: 33%; }
|
||||||
|
.studio-media-34 { --studio-media-width: 34%; }
|
||||||
|
.studio-media-35 { --studio-media-width: 35%; }
|
||||||
|
.studio-media-36 { --studio-media-width: 36%; }
|
||||||
|
.studio-media-37 { --studio-media-width: 37%; }
|
||||||
|
.studio-media-38 { --studio-media-width: 38%; }
|
||||||
|
.studio-media-39 { --studio-media-width: 39%; }
|
||||||
|
.studio-media-40 { --studio-media-width: 40%; }
|
||||||
|
.studio-media-41 { --studio-media-width: 41%; }
|
||||||
|
.studio-media-42 { --studio-media-width: 42%; }
|
||||||
|
.studio-media-43 { --studio-media-width: 43%; }
|
||||||
|
.studio-media-44 { --studio-media-width: 44%; }
|
||||||
|
.studio-media-45 { --studio-media-width: 45%; }
|
||||||
|
.studio-media-46 { --studio-media-width: 46%; }
|
||||||
|
.studio-media-47 { --studio-media-width: 47%; }
|
||||||
|
.studio-media-48 { --studio-media-width: 48%; }
|
||||||
|
.studio-media-49 { --studio-media-width: 49%; }
|
||||||
|
.studio-media-50 { --studio-media-width: 50%; }
|
||||||
|
.studio-media-51 { --studio-media-width: 51%; }
|
||||||
|
.studio-media-52 { --studio-media-width: 52%; }
|
||||||
|
.studio-media-53 { --studio-media-width: 53%; }
|
||||||
|
.studio-media-54 { --studio-media-width: 54%; }
|
||||||
|
.studio-media-55 { --studio-media-width: 55%; }
|
||||||
|
.studio-media-56 { --studio-media-width: 56%; }
|
||||||
|
.studio-media-57 { --studio-media-width: 57%; }
|
||||||
|
.studio-media-58 { --studio-media-width: 58%; }
|
||||||
|
.studio-media-59 { --studio-media-width: 59%; }
|
||||||
|
.studio-media-60 { --studio-media-width: 60%; }
|
||||||
|
.studio-media-61 { --studio-media-width: 61%; }
|
||||||
|
.studio-media-62 { --studio-media-width: 62%; }
|
||||||
|
.studio-media-63 { --studio-media-width: 63%; }
|
||||||
|
.studio-media-64 { --studio-media-width: 64%; }
|
||||||
|
.studio-media-65 { --studio-media-width: 65%; }
|
||||||
|
.studio-media-66 { --studio-media-width: 66%; }
|
||||||
|
.studio-media-67 { --studio-media-width: 67%; }
|
||||||
|
.studio-media-68 { --studio-media-width: 68%; }
|
||||||
|
.studio-media-69 { --studio-media-width: 69%; }
|
||||||
|
.studio-media-70 { --studio-media-width: 70%; }
|
||||||
|
.studio-media-71 { --studio-media-width: 71%; }
|
||||||
|
.studio-media-72 { --studio-media-width: 72%; }
|
||||||
|
.studio-media-73 { --studio-media-width: 73%; }
|
||||||
|
.studio-media-74 { --studio-media-width: 74%; }
|
||||||
|
.studio-media-75 { --studio-media-width: 75%; }
|
||||||
|
.studio-media-76 { --studio-media-width: 76%; }
|
||||||
|
.studio-media-77 { --studio-media-width: 77%; }
|
||||||
|
.studio-media-78 { --studio-media-width: 78%; }
|
||||||
|
.studio-media-79 { --studio-media-width: 79%; }
|
||||||
|
.studio-media-80 { --studio-media-width: 80%; }
|
||||||
|
.studio-media-81 { --studio-media-width: 81%; }
|
||||||
|
.studio-media-82 { --studio-media-width: 82%; }
|
||||||
|
.studio-media-83 { --studio-media-width: 83%; }
|
||||||
|
.studio-media-84 { --studio-media-width: 84%; }
|
||||||
|
.studio-media-85 { --studio-media-width: 85%; }
|
||||||
|
.studio-media-86 { --studio-media-width: 86%; }
|
||||||
|
.studio-media-87 { --studio-media-width: 87%; }
|
||||||
|
.studio-media-88 { --studio-media-width: 88%; }
|
||||||
|
.studio-media-89 { --studio-media-width: 89%; }
|
||||||
|
.studio-media-90 { --studio-media-width: 90%; }
|
||||||
|
.studio-media-91 { --studio-media-width: 91%; }
|
||||||
|
.studio-media-92 { --studio-media-width: 92%; }
|
||||||
|
.studio-media-93 { --studio-media-width: 93%; }
|
||||||
|
.studio-media-94 { --studio-media-width: 94%; }
|
||||||
|
.studio-media-95 { --studio-media-width: 95%; }
|
||||||
|
.studio-media-96 { --studio-media-width: 96%; }
|
||||||
|
.studio-media-97 { --studio-media-width: 97%; }
|
||||||
|
.studio-media-98 { --studio-media-width: 98%; }
|
||||||
|
.studio-media-99 { --studio-media-width: 99%; }
|
||||||
|
.studio-media-100 { --studio-media-width: 100%; }
|
||||||
|
.rich :is(img, video)[class*="studio-media-"] { height: auto; max-width: 100%; }
|
||||||
|
.hero-visual[class*="studio-media-"] { justify-self: center; }
|
||||||
|
[data-studio-editing] [data-studio-selected] { outline: 1px dashed #315ef0; outline-offset: 3px; }
|
||||||
|
|
||||||
|
.rich .studio-intro { max-width: 47rem; }
|
||||||
|
.rich .studio-intro h3, .rich .studio-cover h3 { font-size: clamp(1.75rem, 4vw, 2.8rem); }
|
||||||
|
.rich .studio-cover { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: clamp(1rem, 4vw, 3rem); background: var(--paper); padding: clamp(.8rem, 3vw, 2rem); border-radius: var(--radius); }
|
||||||
|
.rich .studio-cover img { width: 100%; }
|
||||||
|
.rich .studio-cover p { margin-bottom: .85rem; }
|
||||||
|
.rich .studio-two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
|
||||||
|
.rich .studio-quick-nav { display: flex; flex-wrap: wrap; gap: .55rem 1rem; list-style: none; padding: .75rem; border: 1px solid var(--line); border-radius: .6rem; }
|
||||||
|
.rich .studio-quick-nav a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: .4rem; font-weight: 600; }
|
||||||
|
@media (max-width: 44rem) {
|
||||||
|
.rich .studio-cover, .rich .studio-two-column { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-feed-note { margin-top: 1.15rem; }
|
||||||
|
.article-cover { display: block; max-height: 28rem; width: auto; margin-bottom: 1.75rem; object-fit: contain; }
|
||||||
|
.article-tabs { margin-bottom: .85rem; }
|
||||||
|
.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); }
|
||||||
|
.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; } }
|
||||||
|
|
||||||
|
.hero-directory-slot > [data-studio-part="body"] { min-height: 2.2rem; }
|
||||||
|
[data-studio-editing] [data-studio-dynamic] { cursor: pointer; }
|
||||||
|
[data-studio-editing] [data-studio-dynamic]:focus-visible { outline: 1px solid var(--accent); }
|
||||||
|
.studio-module-note { margin: 1rem 0 0; color: var(--accent-deep); padding: .6rem .8rem; background: var(--accent-light); border-radius: .4rem; }
|
||||||
|
.studio-badge { display: inline-flex; padding: .13rem .63rem; border-radius: 999px; background: var(--accent-light); color: var(--accent-deep); font-size: .85rem; }
|
||||||
|
.studio-progress progress { width: min(100%, 28rem); accent-color: var(--accent); display: block; }
|
||||||
|
.studio-progress p { margin-bottom: .3rem; }
|
||||||
|
.studio-empty { text-align: center; border: 1px dashed var(--line); border-radius: .6rem; padding: clamp(1.25rem, 4vw, 2.7rem); }
|
||||||
|
.studio-success-note { border-inline-start-color: #257b50; background: #e7f6ed; }
|
||||||
|
.rich .hero-directory { border-bottom: 1px solid var(--line); border-radius: .85rem; }
|
||||||
|
|
||||||
|
.hero:is(.hero-services, .hero-articles, .hero-contact) .hero-text-only { min-height: auto; }
|
||||||
|
|||||||
@@ -22,6 +22,37 @@ jQuery(function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('[data-article-tabs]').each(function () {
|
||||||
|
const $feed = $(this);
|
||||||
|
const $list = $feed.children('[data-tab-list]');
|
||||||
|
const $panels = $feed.children('[data-tab-panel]');
|
||||||
|
const $tabs = $list.children('[role="tab"]');
|
||||||
|
|
||||||
|
function selectTab(index, focus = false) {
|
||||||
|
$tabs.each(function (number) {
|
||||||
|
$(this).attr({'aria-selected': String(index === number), tabindex: index === number ? '0' : '-1'});
|
||||||
|
});
|
||||||
|
$panels.prop('hidden', true).eq(index).prop('hidden', false);
|
||||||
|
if (focus) $tabs.eq(index).trigger('focus');
|
||||||
|
}
|
||||||
|
|
||||||
|
$panels.each(function (index) {
|
||||||
|
$(this).attr({role: 'tabpanel', 'aria-labelledby': $tabs.eq(index).attr('id'), tabindex: '0'});
|
||||||
|
}).children('[data-tab-heading]').prop('hidden', true);
|
||||||
|
$list.prop('hidden', false);
|
||||||
|
selectTab(0);
|
||||||
|
$tabs.on('click', function () {
|
||||||
|
selectTab($tabs.index(this));
|
||||||
|
}).on('keydown', function (event) {
|
||||||
|
const index = $tabs.index(this);
|
||||||
|
const last = $tabs.length - 1;
|
||||||
|
const destinations = {ArrowLeft: index === 0 ? last : index - 1, ArrowRight: index === last ? 0 : index + 1, Home: 0, End: last};
|
||||||
|
if (!Object.hasOwn(destinations, event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
selectTab(destinations[event.key], true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if ('IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
if ('IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||||
const observer = new IntersectionObserver((entries) => {
|
const observer = new IntersectionObserver((entries) => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
|||||||
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
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: 12 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 21 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 7.8 KiB |