From 1bb05546080b69cd23d4c82fd77c62f086feab42 Mon Sep 17 00:00:00 2001
From: ChatGPT
Date: Sun, 22 Nov 2026 23:25:52 +0800
Subject: [PATCH] Launch LaySite visual editor and MCP workspace
---
.gitattributes | 1 +
.gitignore | 7 +
README.md | 154 ++
VERSION | 1 +
app/Content/Assets.php | 63 +
app/Content/BlockTemplates.php | 120 ++
app/Content/Buttons.php | 45 +
app/Content/Database.php | 93 +
app/Content/DesignLibrary.php | 208 ++
app/Content/DirectoryCard.php | 39 +
app/Content/Html.php | 160 ++
app/Content/IdentityProvider.php | 148 ++
app/Content/Media.php | 130 ++
app/Content/PageDraft.php | 109 +
app/Content/PageTemplates.php | 40 +
app/Content/Passwords.php | 20 +
app/Content/Repository.php | 403 ++++
app/Content/SiteBackup.php | 289 +++
app/Content/SiteDesign.php | 47 +
app/Content/View.php | 108 +
app/Controller/AccountController.php | 110 +
app/Controller/AdminController.php | 662 ++++++
app/Controller/BackupController.php | 78 +
app/Controller/DesignController.php | 149 ++
app/Controller/McpController.php | 216 ++
app/Controller/MediaController.php | 45 +
app/Controller/SiteController.php | 245 +++
app/Controller/StudioController.php | 171 ++
app/Http/Request.php | 29 +
app/Http/VisitorSession.php | 38 +
app/Middleware/PublicAssets.php | 26 +
app/view/account.php | 14 +
app/view/admin-article-categories.php | 21 +
app/view/admin-article-list.php | 19 +
app/view/admin-article.php | 64 +
app/view/admin-articles.php | 31 +
app/view/admin-backup.php | 15 +
app/view/admin-brand.php | 4 +
app/view/admin-category-checkboxes.php | 14 +
app/view/admin-dashboard.php | 61 +
app/view/admin-design-edit.php | 83 +
app/view/admin-design.php | 23 +
app/view/admin-editor.php | 32 +
app/view/admin-error.php | 2 +
app/view/admin-feedback.php | 3 +
app/view/admin-layout.php | 78 +
app/view/admin-login.php | 17 +
app/view/admin-page.php | 173 ++
app/view/admin-password.php | 14 +
app/view/admin-section.php | 33 +
app/view/archive.php | 32 +
app/view/article-feed.php | 23 +
app/view/article-list.php | 24 +
app/view/article.php | 46 +
app/view/footer.php | 26 +
app/view/header.php | 42 +
app/view/layout.php | 60 +
app/view/missing.php | 8 +
app/view/network-items.php | 27 +
app/view/page.php | 74 +
app/view/section.php | 54 +
app/view/service-cards.php | 38 +
app/view/studio-anchor-form.php | 24 +
app/view/studio-asset-field.php | 9 +
app/view/studio-feed-fields.php | 15 +
app/view/studio-icon.php | 12 +
app/view/studio-layers.php | 30 +
app/view/studio-library-panel.php | 63 +
app/view/studio-media.php | 50 +
app/view/studio-new-page.php | 20 +
app/view/studio-page-templates.php | 60 +
app/view/studio-settings.php | 15 +
app/view/studio-templates.php | 35 +
bin/admin.php | 52 +
bin/backup.php | 26 +
bin/install.php | 11 +
bin/update.sh | 41 +
composer.json | 28 +
composer.lock | 1836 +++++++++++++++++
config/app.php | 12 +
config/bootstrap.php | 3 +
config/container.php | 3 +
config/exception.php | 3 +
config/log.php | 12 +
config/process.php | 15 +
config/route.php | 58 +
config/server.php | 10 +
config/session.php | 14 +
config/static.php | 3 +
public/assets/admin.css | 324 +++
public/assets/admin.js | 197 ++
public/assets/article-editor.js | 56 +
public/assets/geist-OFL.txt | 93 +
public/assets/geist.woff2 | Bin 0 -> 29400 bytes
public/assets/jquery-4.0.0.min.js | 2 +
public/assets/jquery-LICENSE.txt | 20 +
public/assets/page-template-drawer.css | 64 +
public/assets/page-template-drawer.js | 51 +
.../assets/page-templates/cobalt-guide.webp | Bin 0 -> 29812 bytes
.../assets/page-templates/cobalt-product.webp | Bin 0 -> 29160 bytes
public/assets/page-templates/cobalt.webp | Bin 0 -> 23954 bytes
public/assets/page-templates/dusk-launch.webp | Bin 0 -> 11652 bytes
.../assets/page-templates/dusk-updates.webp | Bin 0 -> 11150 bytes
public/assets/page-templates/dusk.webp | Bin 0 -> 9524 bytes
.../page-templates/furrow-checklist.webp | Bin 0 -> 11482 bytes
.../assets/page-templates/furrow-service.webp | Bin 0 -> 12780 bytes
public/assets/page-templates/furrow.webp | Bin 0 -> 9798 bytes
public/assets/page-templates/ribbon-help.webp | Bin 0 -> 11768 bytes
.../page-templates/ribbon-onboarding.webp | Bin 0 -> 13088 bytes
public/assets/page-templates/ribbon.webp | Bin 0 -> 11558 bytes
public/assets/page-templates/studio-case.webp | Bin 0 -> 19400 bytes
.../page-templates/studio-portfolio.webp | Bin 0 -> 18356 bytes
public/assets/page-templates/studio.webp | Bin 0 -> 16584 bytes
.../vantage-infrastructure.webp | Bin 0 -> 17164 bytes
.../page-templates/vantage-runbook.webp | Bin 0 -> 16128 bytes
public/assets/page-templates/vantage.webp | Bin 0 -> 17264 bytes
public/assets/page-themes.css | 172 ++
public/assets/site.css | 641 ++++++
public/assets/site.js | 70 +
public/assets/studio.js | 1431 +++++++++++++
public/assets/system/laysite-mark.webp | Bin 0 -> 15652 bytes
public/assets/system/sample.webp | Bin 0 -> 4288 bytes
public/assets/template-previews/articles.webp | Bin 0 -> 3060 bytes
public/assets/template-previews/banner.webp | Bin 0 -> 5026 bytes
.../assets/template-previews/changelog.webp | Bin 0 -> 4796 bytes
.../assets/template-previews/checklist.webp | Bin 0 -> 3396 bytes
.../template-previews/contact-card.webp | Bin 0 -> 5914 bytes
public/assets/template-previews/cover.webp | Bin 0 -> 8212 bytes
public/assets/template-previews/cta.webp | Bin 0 -> 3206 bytes
public/assets/template-previews/faq.webp | Bin 0 -> 2796 bytes
public/assets/template-previews/features.webp | Bin 0 -> 5054 bytes
public/assets/template-previews/gallery.webp | Bin 0 -> 4668 bytes
public/assets/template-previews/grid.webp | Bin 0 -> 4286 bytes
public/assets/template-previews/headline.webp | Bin 0 -> 5380 bytes
public/assets/template-previews/image.webp | Bin 0 -> 4182 bytes
public/assets/template-previews/list.webp | Bin 0 -> 3600 bytes
public/assets/template-previews/metrics.webp | Bin 0 -> 5146 bytes
.../assets/template-previews/navigation.webp | Bin 0 -> 3964 bytes
public/assets/template-previews/network.webp | Bin 0 -> 3398 bytes
public/assets/template-previews/notice.webp | Bin 0 -> 4568 bytes
public/assets/template-previews/pricing.webp | Bin 0 -> 9654 bytes
public/assets/template-previews/quote.webp | Bin 0 -> 2516 bytes
.../assets/template-previews/resources.webp | Bin 0 -> 4270 bytes
.../template-previews/service-catalog.webp | Bin 0 -> 2760 bytes
public/assets/template-previews/table.webp | Bin 0 -> 3750 bytes
.../template-previews/testimonials.webp | Bin 0 -> 5076 bytes
public/assets/template-previews/text.webp | Bin 0 -> 2246 bytes
public/assets/template-previews/timeline.webp | Bin 0 -> 4836 bytes
.../assets/template-previews/two-actions.webp | Bin 0 -> 5190 bytes
.../assets/template-previews/video-demo.webp | Bin 0 -> 5320 bytes
public/assets/vendor/toastui/LICENSE | 21 +
.../vendor/toastui/toastui-editor.min.css | 6 +
.../vendor/toastui/toastui-editor.min.js | 24 +
public/assets/vendor/toastui/zh-cn.js | 162 ++
resources/page-templates.php | 81 +
resources/schema.sql | 101 +
start.php | 15 +
storage/.gitignore | 0
support/bootstrap.php | 3 +
159 files changed, 11103 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .gitignore
create mode 100644 README.md
create mode 100644 VERSION
create mode 100644 app/Content/Assets.php
create mode 100644 app/Content/BlockTemplates.php
create mode 100644 app/Content/Buttons.php
create mode 100644 app/Content/Database.php
create mode 100644 app/Content/DesignLibrary.php
create mode 100644 app/Content/DirectoryCard.php
create mode 100644 app/Content/Html.php
create mode 100644 app/Content/IdentityProvider.php
create mode 100644 app/Content/Media.php
create mode 100644 app/Content/PageDraft.php
create mode 100644 app/Content/PageTemplates.php
create mode 100644 app/Content/Passwords.php
create mode 100644 app/Content/Repository.php
create mode 100644 app/Content/SiteBackup.php
create mode 100644 app/Content/SiteDesign.php
create mode 100644 app/Content/View.php
create mode 100644 app/Controller/AccountController.php
create mode 100644 app/Controller/AdminController.php
create mode 100644 app/Controller/BackupController.php
create mode 100644 app/Controller/DesignController.php
create mode 100644 app/Controller/McpController.php
create mode 100644 app/Controller/MediaController.php
create mode 100644 app/Controller/SiteController.php
create mode 100644 app/Controller/StudioController.php
create mode 100644 app/Http/Request.php
create mode 100644 app/Http/VisitorSession.php
create mode 100644 app/Middleware/PublicAssets.php
create mode 100644 app/view/account.php
create mode 100644 app/view/admin-article-categories.php
create mode 100644 app/view/admin-article-list.php
create mode 100644 app/view/admin-article.php
create mode 100644 app/view/admin-articles.php
create mode 100644 app/view/admin-backup.php
create mode 100644 app/view/admin-brand.php
create mode 100644 app/view/admin-category-checkboxes.php
create mode 100644 app/view/admin-dashboard.php
create mode 100644 app/view/admin-design-edit.php
create mode 100644 app/view/admin-design.php
create mode 100644 app/view/admin-editor.php
create mode 100644 app/view/admin-error.php
create mode 100644 app/view/admin-feedback.php
create mode 100644 app/view/admin-layout.php
create mode 100644 app/view/admin-login.php
create mode 100644 app/view/admin-page.php
create mode 100644 app/view/admin-password.php
create mode 100644 app/view/admin-section.php
create mode 100644 app/view/archive.php
create mode 100644 app/view/article-feed.php
create mode 100644 app/view/article-list.php
create mode 100644 app/view/article.php
create mode 100644 app/view/footer.php
create mode 100644 app/view/header.php
create mode 100644 app/view/layout.php
create mode 100644 app/view/missing.php
create mode 100644 app/view/network-items.php
create mode 100644 app/view/page.php
create mode 100644 app/view/section.php
create mode 100644 app/view/service-cards.php
create mode 100644 app/view/studio-anchor-form.php
create mode 100644 app/view/studio-asset-field.php
create mode 100644 app/view/studio-feed-fields.php
create mode 100644 app/view/studio-icon.php
create mode 100644 app/view/studio-layers.php
create mode 100644 app/view/studio-library-panel.php
create mode 100644 app/view/studio-media.php
create mode 100644 app/view/studio-new-page.php
create mode 100644 app/view/studio-page-templates.php
create mode 100644 app/view/studio-settings.php
create mode 100644 app/view/studio-templates.php
create mode 100644 bin/admin.php
create mode 100644 bin/backup.php
create mode 100644 bin/install.php
create mode 100755 bin/update.sh
create mode 100644 composer.json
create mode 100644 composer.lock
create mode 100644 config/app.php
create mode 100644 config/bootstrap.php
create mode 100644 config/container.php
create mode 100644 config/exception.php
create mode 100644 config/log.php
create mode 100644 config/process.php
create mode 100644 config/route.php
create mode 100644 config/server.php
create mode 100644 config/session.php
create mode 100644 config/static.php
create mode 100644 public/assets/admin.css
create mode 100644 public/assets/admin.js
create mode 100644 public/assets/article-editor.js
create mode 100644 public/assets/geist-OFL.txt
create mode 100644 public/assets/geist.woff2
create mode 100644 public/assets/jquery-4.0.0.min.js
create mode 100644 public/assets/jquery-LICENSE.txt
create mode 100644 public/assets/page-template-drawer.css
create mode 100644 public/assets/page-template-drawer.js
create mode 100644 public/assets/page-templates/cobalt-guide.webp
create mode 100644 public/assets/page-templates/cobalt-product.webp
create mode 100644 public/assets/page-templates/cobalt.webp
create mode 100644 public/assets/page-templates/dusk-launch.webp
create mode 100644 public/assets/page-templates/dusk-updates.webp
create mode 100644 public/assets/page-templates/dusk.webp
create mode 100644 public/assets/page-templates/furrow-checklist.webp
create mode 100644 public/assets/page-templates/furrow-service.webp
create mode 100644 public/assets/page-templates/furrow.webp
create mode 100644 public/assets/page-templates/ribbon-help.webp
create mode 100644 public/assets/page-templates/ribbon-onboarding.webp
create mode 100644 public/assets/page-templates/ribbon.webp
create mode 100644 public/assets/page-templates/studio-case.webp
create mode 100644 public/assets/page-templates/studio-portfolio.webp
create mode 100644 public/assets/page-templates/studio.webp
create mode 100644 public/assets/page-templates/vantage-infrastructure.webp
create mode 100644 public/assets/page-templates/vantage-runbook.webp
create mode 100644 public/assets/page-templates/vantage.webp
create mode 100644 public/assets/page-themes.css
create mode 100644 public/assets/site.css
create mode 100644 public/assets/site.js
create mode 100644 public/assets/studio.js
create mode 100644 public/assets/system/laysite-mark.webp
create mode 100644 public/assets/system/sample.webp
create mode 100644 public/assets/template-previews/articles.webp
create mode 100644 public/assets/template-previews/banner.webp
create mode 100644 public/assets/template-previews/changelog.webp
create mode 100644 public/assets/template-previews/checklist.webp
create mode 100644 public/assets/template-previews/contact-card.webp
create mode 100644 public/assets/template-previews/cover.webp
create mode 100644 public/assets/template-previews/cta.webp
create mode 100644 public/assets/template-previews/faq.webp
create mode 100644 public/assets/template-previews/features.webp
create mode 100644 public/assets/template-previews/gallery.webp
create mode 100644 public/assets/template-previews/grid.webp
create mode 100644 public/assets/template-previews/headline.webp
create mode 100644 public/assets/template-previews/image.webp
create mode 100644 public/assets/template-previews/list.webp
create mode 100644 public/assets/template-previews/metrics.webp
create mode 100644 public/assets/template-previews/navigation.webp
create mode 100644 public/assets/template-previews/network.webp
create mode 100644 public/assets/template-previews/notice.webp
create mode 100644 public/assets/template-previews/pricing.webp
create mode 100644 public/assets/template-previews/quote.webp
create mode 100644 public/assets/template-previews/resources.webp
create mode 100644 public/assets/template-previews/service-catalog.webp
create mode 100644 public/assets/template-previews/table.webp
create mode 100644 public/assets/template-previews/testimonials.webp
create mode 100644 public/assets/template-previews/text.webp
create mode 100644 public/assets/template-previews/timeline.webp
create mode 100644 public/assets/template-previews/two-actions.webp
create mode 100644 public/assets/template-previews/video-demo.webp
create mode 100644 public/assets/vendor/toastui/LICENSE
create mode 100644 public/assets/vendor/toastui/toastui-editor.min.css
create mode 100644 public/assets/vendor/toastui/toastui-editor.min.js
create mode 100644 public/assets/vendor/toastui/zh-cn.js
create mode 100644 resources/page-templates.php
create mode 100644 resources/schema.sql
create mode 100755 start.php
create mode 100644 storage/.gitignore
create mode 100644 support/bootstrap.php
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62f9980
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+/vendor/
+/runtime/
+/storage/*
+!/storage/.gitignore
+/.env
+/.taste-skill/
+/shots/
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..be93832
--- /dev/null
+++ b/README.md
@@ -0,0 +1,154 @@
+# LaySite
+
+基于 PHP Webman、SQLite、原生 CSS 和 jQuery 的通用站点编辑器。页面由服务端渲染,公开页复用站点组件和配色。新装提供空白首页、可编辑的文章页,以及六套十二个整页模板。
+
+## 安装
+
+需要 PHP 8.2+ CLI、Composer 2,及 `curl`、`dom`、`fileinfo`、`mbstring`、`openssl`、`pdo_sqlite`、`pcntl`、`posix` 和 `Phar`。确保运行账户能写入 `runtime/`、SQLite 所在目录和上传目录。
+
+```sh
+composer install --no-dev
+php bin/install.php
+php bin/admin.php editor@example.com
+php start.php start
+```
+
+打开 `http://127.0.0.1:8787/admin`。重设管理员密码可用 `php bin/admin.php reset editor@example.com`。该操作会使该账户的旧会话失效。应用使用进程环境变量,可在 systemd 服务或启动脚本中设置。
+
+| 环境变量 | 用途 |
+| --- | --- |
+| `LAYSITE_SITE_URL` | 完整站点地址,默认 `http://127.0.0.1:8787`。用于 SEO URL、MCP 编辑链接和登录回调 |
+| `LAYSITE_LISTEN` | Webman 监听地址,默认 `http://127.0.0.1:8787` |
+| `LAYSITE_WORKERS` | Webman worker 数,默认 2 |
+| `LAYSITE_DB` | SQLite 文件,默认 `storage/laysite.sqlite` |
+| `LAYSITE_MEDIA_DIR` | 用户上传目录,默认 `storage/media` |
+| `LAYSITE_SECURE_COOKIES` | 生产 HTTPS 设为 `1`。本机 HTTP 留空 |
+| `LAYSITE_TRUSTED_PROXIES` | 信任的反代 IP,默认 `127.0.0.1,::1` |
+| `LAYSITE_MCP_TOKEN` | MCP Bearer 密钥,至少 32 字符。未设置时端点关闭 |
+| `LAYSITE_OAUTH_*` | 会员页头选用的客户端密钥,按新建配置时填写的名称设置 |
+
+## 页面与站点设计
+
+- 在「页面」新建空白草稿或从整页模板创建。画布支持编辑、媒体拖拽调整宽度、移动端预览、区块复制与删除。
+- 选中按钮后可复制。在「属性」中选择纯色填充、线框、下划线或无样式,并选择是否在新标签页打开。首屏支持最多八个按钮。
+- 「站点设计」中可以保存多套页头、页脚和配色。选择布局模板后,可以勾选并排序标识、导航、按钮、文字、版权或用户区组件,填入各组件内容。页头和页脚可以设为站点默认。每页可覆盖这两个默认项、选择配色,或独立隐藏页头和页脚。
+- 媒体库和媒体选择器只列出用户上传文件。编辑器图标、示例资产、字体、模板缩略图和产品标识随程序发布。
+- 发布后的站点具备独立标题、描述、canonical、Open Graph、站点地图和 robots.txt。可在「站点设置」配置站点名称和静态资源 CDN。
+
+### 会员页头
+
+在「站点设计 → 页头」选择「会员导航」,启用用户区,并选择认证方式。将已配置的页头用作默认、或应用于要开放登录的页面。
+
+| 模式 | 填写内容 |
+| --- | --- |
+| OpenID Connect | Issuer、客户端 ID 和客户端密钥环境变量。LaySite 通过发现文档获取端点和签名公钥,使用 `openid profile email` 及附加范围 |
+| OAuth 2.0 + 用户资料 | 授权、令牌和用户资料三个 HTTPS 地址、客户端 ID、客户端密钥环境变量、权限范围及稳定的用户 ID 字段。名称和头像字段默认使用 `name`、`picture` |
+
+在提供商中注册由站点域名拼接的回调 `https://example.com/account/callback`。密钥写入进程环境,配置页填写类似 `LAYSITE_OAUTH_MEMBER_SECRET` 的变量名。两个模式均使用授权码、state 和 PKCE S256,可按提供商要求选择 HTTP Basic 或表单客户端密钥。通过验证后,访客头像会链接到 `/account`。访客会话与管理员登录分开,退出用户中心时结束本地访客会话。
+
+## MCP
+
+`POST /mcp` 提供无状态 Streamable HTTP JSON-RPC。使用 `openssl rand -hex 32` 生成令牌,然后设置 `LAYSITE_MCP_TOKEN` 并重启 Webman。客户端使用 HTTPS 站点地址及 `Authorization: Bearer `。
+
+支持 MCP `2025-11-25`、`2025-06-18`、`2025-03-26`。客户端配置示例(字段名称按客户端调整):
+
+```json
+{
+ "mcpServers": {
+ "laysite": {
+ "type": "http",
+ "url": "https://example.com/mcp",
+ "headers": { "Authorization": "Bearer YOUR_TOKEN" }
+ }
+ }
+}
+```
+
+| 工具 | 功能 |
+| --- | --- |
+| `list_pages` / `get_page` | 读取页面、区块及当前修订号 |
+| `list_templates` / `list_designs` | 查阅整页模板、组件、页头、页脚和配色 |
+| `create_draft` | 按模板或传入内容创建草稿,返回编辑地址 |
+| `save_draft` | 用最新修订号更新草稿。传入 `sections` 时替换区块列表 |
+
+Agent 可以编辑草稿,管理员在画布里检查、细改及发布。草稿 HTML 使用与人工画布相同的 HTML 过滤器。按钮参数为 `[href, label, style, opensNewTab]`,样式可选 `solid`、`outline`、`underline`、`plain`。MCP 与站点发布共用 SQLite 和编辑器修订号。
+
+## 站点备份与更新
+
+「站点设计 → 站点备份」支持导出和确认后覆盖导入。备份包是包含版本化 JSON 清单和校验和的 TAR,包含页面、区块、文章、站点设置、布局、配色和媒体数据。管理员密码、运行环境密钥和登录会话由目标安装独立管理。备份存放在站点公开目录外。
+
+当前导出格式为 v2,导入兼容 v1 的基础内容备份并补齐空的设计库。未来格式会保留迁移入口,遇到较新的不兼容格式时提示升级。上传大小受 Webman 与外层代理限制,较大站点可使用 CLI。
+
+```sh
+php bin/backup.php export /srv/backups/laysite-2026-11.tar
+php bin/backup.php import /srv/backups/laysite-2026-11.tar --replace
+```
+
+使用 Git 标签选择更新版本。更新命令先备份,再检出所选版本、安装锁定依赖并运行 SQLite 初始化或迁移。更新时暂停 Webman,更新结束后用原进程环境重新启动。保持源代码工作区干净,并将备份放到部署路径之外。
+
+```sh
+bin/update.sh check
+bin/update.sh v1.0.0 /srv/backups/pre-update.tar
+```
+
+## 生产反代
+
+配置 `LAYSITE_SITE_URL=https://example.com` 和 `LAYSITE_SECURE_COOKIES=1`。下列示例假定代理和 Webman 在同一主机。代理应以实际访客来源覆盖 `X-Real-IP`,并将项目文件、数据库和媒体存储保持在公开根目录之外。
+
+### Nginx
+
+在现有 HTTPS 虚拟主机内加入:
+
+```nginx
+proxy_http_version 1.1;
+proxy_set_header Host $host;
+proxy_set_header X-Real-IP $remote_addr;
+
+location / {
+ proxy_pass http://127.0.0.1:8787;
+ client_max_body_size 2m;
+}
+location ~ ^/admin/(media|backup)$ {
+ proxy_pass http://127.0.0.1:8787;
+ client_max_body_size 66m;
+}
+```
+
+### Caddy v2
+
+以下 `request_body` 配置要求 Caddy v2.10+。
+
+```caddyfile
+example.com {
+ @uploads path /admin/media /admin/backup
+ @pages not path /admin/media /admin/backup
+ request_body @uploads {
+ max_size 66MiB
+ }
+ request_body @pages {
+ max_size 2MiB
+ }
+ reverse_proxy 127.0.0.1:8787 {
+ header_up X-Real-IP {remote_host}
+ }
+}
+```
+
+### Caddy v1
+
+```caddyfile
+example.com {
+ limits {
+ body /admin/media 66MB
+ body /admin/backup 66MB
+ body / 2MB
+ }
+ proxy / 127.0.0.1:8787 {
+ transparent
+ }
+}
+```
+
+Caddy v1 的路径限额按前缀匹配。CDN 应转发 `/assets/`,并保留静态资源 CORS 与音视频 Range 响应。使用会员页头时,站点会对个性化页面发送 `Cache-Control: private, no-store`,外层代理应保留此响应头。
+
+模板视觉参考 Hallmark。代码中的 jQuery、Geist 和 TOAST UI Editor 随各自的许可证分发。
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..3eefcb9
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+1.0.0
diff --git a/app/Content/Assets.php b/app/Content/Assets.php
new file mode 100644
index 0000000..6e49b49
--- /dev/null
+++ b/app/Content/Assets.php
@@ -0,0 +1,63 @@
+ 263 || !preg_match('~^https://(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?::[0-9]{1,5})?$~iD', $value))) {
+ throw new RuntimeException('请填写 HTTPS CDN 源站地址,例如 https://cdn.example.com。');
+ }
+ if (($port = parse_url($value, PHP_URL_PORT)) !== null && ($port === false || $port < 1)) {
+ throw new RuntimeException('CDN 端口无效。');
+ }
+
+ return $value;
+ }
+
+ public static function url(string $path, string $cdn): string
+ {
+ return str_starts_with($path, '/assets/') ? $cdn . $path : $path;
+ }
+
+ public static function rewrite(string $html, string $cdn): string
+ {
+ if ($cdn === '') {
+ return $html;
+ }
+
+ // Match opening tags separately from comments and text-only elements' contents.
+ $tags = <<<'REGEX'
+~|\z)|(?<(?:(?script|style|textarea|title)|[a-z][\w:-]*)(?=[\s/>])(?:[^<>"']++|"[^"]*"|'[^']*')*+>)(?(textTag)(?.*?(?:\k\s*>|\z)))~is
+REGEX;
+ $attributes = <<<'REGEX'
+~(\s+)([^\s/<>="']+)(?:(\s*=\s*)("[^"]*"|'[^']*'|[^\s<>"'=`]+))?~
+REGEX;
+
+ return preg_replace_callback($tags, static function (array $tag) use ($attributes, $cdn): string {
+ if (!isset($tag['opening'])) {
+ return $tag[0];
+ }
+
+ $opening = preg_replace_callback($attributes, static function (array $attribute) use ($cdn): string {
+ if (!isset($attribute[4]) || !in_array(strtolower($attribute[2]), ['src', 'href', 'poster'], true)) {
+ return $attribute[0];
+ }
+
+ $value = $attribute[4];
+ $quote = str_starts_with($value, '"') || str_starts_with($value, "'") ? $value[0] : '';
+ $path = $quote === '' ? $value : substr($value, 1, -1);
+
+ return $attribute[1] . $attribute[2] . $attribute[3] . $quote . self::url($path, $cdn) . $quote;
+ }, $tag['opening']) ?? $tag['opening'];
+
+ return $opening . ($tag['tail'] ?? '');
+ }, $html) ?? $html;
+ }
+}
diff --git a/app/Content/BlockTemplates.php b/app/Content/BlockTemplates.php
new file mode 100644
index 0000000..68dd5c9
--- /dev/null
+++ b/app/Content/BlockTemplates.php
@@ -0,0 +1,120 @@
+ ['文字与列表', [
+ 'paragraph' => ['段落', '填写正文。
'],
+ 'subheading' => ['小标题', '填写小标题
'],
+ 'lead' => ['导语', '填写本节的导语。
'],
+ 'blockquote' => ['引用', '填写需要引用的内容。
'],
+ 'bullet-list' => ['项目列表', ''],
+ 'ordered-list' => ['编号列表', '- 填写第一项
- 填写第二项
'],
+ 'heading-kicker' => ['标题眉标', '填写分类名称
'],
+ 'tag' => ['徽标', '填写标签
'],
+ 'large-number' => ['重点数字', '填写数字
'],
+ 'definition-list' => ['术语说明', '- 填写术语
- 填写术语说明。
'],
+ ]],
+ 'link-elements' => ['链接与按钮', [
+ 'button' => ['主按钮', '联系站点
'],
+ 'outline-button' => ['描边按钮', '查看服务
'],
+ 'text-link' => ['文字链接', '阅读文章
'],
+ 'button-group' => ['按钮组', ''],
+ 'breadcrumbs' => ['面包屑', '首页 / 当前页面
'],
+ 'download-link' => ['下载入口', '查看下载
'],
+ 'email-link' => ['邮件链接', '发送邮件
'],
+ ]],
+ 'media-elements' => ['图片与影音', [
+ 'image' => ['图片', '', 'image/'],
+ 'video' => ['视频', '', 'video/'],
+ 'audio' => ['音频', '', 'audio/'],
+ 'qr-image' => ['二维码', '', 'image/'],
+ 'image-link' => ['图片链接', '
'],
+ ]],
+ 'structure-elements' => ['版式与数据', [
+ 'separator' => ['分割线', '
'],
+ 'spacer' => ['留白', ''],
+ 'code' => ['代码块', '填写代码
'],
+ 'basic-table' => ['数据表格', ''],
+ 'progress' => ['进度条', ''],
+ 'alert' => ['提示卡', ''],
+ 'simple-card' => ['内容卡片', '填写卡片标题
填写卡片内容。
'],
+ 'link-card' => ['链接卡片', '查看资料
填写链接指向的资料说明。
打开资料'],
+ 'list-group' => ['列表组', ''],
+ 'empty-card' => ['空状态', ''],
+ 'status-note' => ['状态提示', ''],
+ 'disclosure' => ['折叠内容', ''],
+ ]],
+ ];
+
+ public const GROUPS = [
+ 'content' => ['标题与正文', [
+ 'headline' => ['标题与简介', ''],
+ 'text' => ['正文', '在这里输入区块内容。
'],
+ 'articles' => ['分类文章', '', '', self::ARTICLE_FEED],
+ 'network' => ['按分类分组', '', '', self::NETWORK_FEED],
+ 'list' => ['步骤列表', '- 填写第一步
- 填写第二步
- 填写第三步
'],
+ 'notice' => ['重点提示', ''],
+ ]],
+ 'cover' => ['封面与横幅', [
+ 'cover' => ['图文封面', '
用一句话介绍你的产品
在首段说明访客能获得什么。
查看服务 '],
+ 'banner' => ['横幅', '用一句话介绍你的项目
简要说明项目能为访客做什么。
了解更多 '],
+ 'two-actions' => ['双按钮横幅', ''],
+ ]],
+ 'layout' => ['图文与布局', [
+ 'image' => ['产品图文', ''],
+ 'grid' => ['双栏网格', ''],
+ ]],
+ 'media' => ['媒体', [
+ 'gallery' => ['三图画廊', ''],
+ 'video-demo' => ['视频演示', ''],
+ ]],
+ 'features' => ['特性与口碑', [
+ 'features' => ['特性卡片', '特点一
介绍这个特点。
特点二
介绍这个特点。
特点三
介绍这个特点。
'],
+ 'quote' => ['引文', '在这里填写引用或用户反馈。
'],
+ 'metrics' => ['关键数据', '- 累计项目
- 100
服务覆盖12合作伙伴8'],
+ 'testimonials' => ['用户评价', '填写用户的评价,并说明他们获得的结果。
用户姓名 · 公司或角色
填写另一条用户评价。
用户姓名 · 公司或角色
'],
+ ]],
+ 'details' => ['表格与问答', [
+ 'table' => ['对比表格', ''],
+ 'faq' => ['常见问题', ''],
+ 'timeline' => ['时间线', '确定目标
填写这一阶段需要完成的事项。
实施与验收
填写交付时间与验收标准。
'],
+ 'checklist' => ['清单', ''],
+ 'changelog' => ['更新记录', '版本 2.0
填写主要功能或改进。
版本 1.0
填写上一版本的更新内容。
'],
+ 'pricing' => ['双方案报价', ''],
+ ]],
+ 'actions' => ['导航与引导', [
+ 'service-catalog' => ['目录卡片', '', '', self::CATALOG_FEED],
+ 'navigation' => ['快速导航', ''],
+ 'cta' => ['行动按钮', '说明下一步。
联系站点
'],
+ 'resources' => ['资料与链接', ''],
+ 'contact-card' => ['联系方式', ''],
+ ]],
+ ];
+
+ public static function groups(): array
+ {
+ return self::GROUPS;
+ }
+
+ public static function find(string $key): ?array
+ {
+ foreach (self::groups() as [, $templates]) {
+ if (isset($templates[$key])) {
+ return $templates[$key];
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/app/Content/Buttons.php b/app/Content/Buttons.php
new file mode 100644
index 0000000..dba6f70
--- /dev/null
+++ b/app/Content/Buttons.php
@@ -0,0 +1,45 @@
+ '纯色填充', 'outline' => '线框', 'underline' => '下划线', 'plain' => '无样式'];
+ private const CLASSES = ['solid' => 'button-primary', 'outline' => 'button-outline', 'underline' => 'button-underline', 'plain' => 'button-plain'];
+
+ public static function validate(mixed $items, int $limit = 8): array
+ {
+ if (!is_array($items) || !array_is_list($items) || count($items) > $limit) {
+ throw new RuntimeException('按钮或链接数量超过限制。');
+ }
+ $buttons = [];
+ foreach ($items as $index => $item) {
+ $url = $item[0] ?? null;
+ $label = $item[1] ?? null;
+ $style = $item[2] ?? ($index === 0 ? 'solid' : 'outline');
+ $blank = $item[3] ?? false;
+ if (!is_string($url) || strlen($url) > 1000 || !Html::url($url) || !is_string($label)
+ || trim($label) === '' || mb_strlen($label) > 70 || !is_string($style) || !isset(self::STYLES[$style])
+ || !is_bool($blank)) {
+ throw new RuntimeException('请检查按钮文案、链接和样式。');
+ }
+ $buttons[] = [$url, $label, $style, $blank];
+ }
+
+ return $buttons;
+ }
+
+ public static function css(string $style): string
+ {
+ return 'button ' . (self::CLASSES[$style] ?? self::CLASSES['solid']);
+ }
+
+ public static function target(bool $blank): string
+ {
+ return $blank ? ' target="_blank" rel="noopener noreferrer"' : '';
+ }
+}
diff --git a/app/Content/Database.php b/app/Content/Database.php
new file mode 100644
index 0000000..6fb5843
--- /dev/null
+++ b/app/Content/Database.php
@@ -0,0 +1,93 @@
+ PDO::FETCH_ASSOC]);
+ $pdo->exec('PRAGMA busy_timeout = 5000');
+ $pdo->exec('PRAGMA foreign_keys = ON');
+ self::$connection = $pdo;
+
+ return $pdo;
+ }
+
+ public static function initialize(): void
+ {
+ $root = dirname(__DIR__, 2);
+ $pdo = self::connect();
+ $pdo->exec('PRAGMA journal_mode = WAL');
+
+ self::write(function (PDO $pdo) use ($root): void {
+ $version = (int) $pdo->query('PRAGMA user_version')->fetchColumn();
+ if ($version > self::SCHEMA_VERSION) {
+ throw new RuntimeException('当前 SQLite 数据库需要更新版本的 LaySite。');
+ }
+ $pdo->exec(file_get_contents($root . '/resources/schema.sql'));
+ $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)')->execute([self::json(['name' => '我的网站'])]);
+ $pdo->prepare("INSERT OR IGNORE INTO pages
+ (slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)
+ VALUES ('home', '首页', '我的网站', '欢迎访问我的网站。', '我的网站', '', '', '', '', '[]', '[]')")
+ ->execute();
+ $articles = $pdo->prepare("INSERT OR IGNORE INTO pages
+ (slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)
+ VALUES ('articles', '文章与动态', '文章与动态', '浏览站点发布的文章。', '文章与动态', '', '', '', '', '[]', '[]')");
+ $articles->execute();
+ if ($articles->rowCount() === 1) {
+ $pdo->prepare("INSERT INTO sections (page_slug, key, title, lead, body, feed, position)
+ VALUES ('articles', 'posts', '最新文章', '', '', ?, 0)")->execute([BlockTemplates::ARTICLE_FEED]);
+ }
+ $category = $pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
+ foreach (Repository::CATEGORIES as $slug => $name) {
+ $category->execute([$slug, $name]);
+ }
+ if ($version < self::SCHEMA_VERSION) {
+ $pdo->exec('PRAGMA user_version = ' . self::SCHEMA_VERSION);
+ }
+ });
+ }
+
+ public static function write(callable $operation): mixed
+ {
+ $pdo = self::connect();
+ $pdo->exec('BEGIN IMMEDIATE');
+ try {
+ $result = $operation($pdo);
+ $pdo->exec('COMMIT');
+
+ return $result;
+ } catch (Throwable $error) {
+ $pdo->exec('ROLLBACK');
+ throw $error;
+ }
+ }
+
+ public static function json(array $data): string
+ {
+ return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
+ }
+}
diff --git a/app/Content/DesignLibrary.php b/app/Content/DesignLibrary.php
new file mode 100644
index 0000000..5c885b9
--- /dev/null
+++ b/app/Content/DesignLibrary.php
@@ -0,0 +1,208 @@
+ ['inline' => '横排导航', 'center' => '居中品牌', 'member' => '会员导航'],
+ 'footer' => ['columns' => '多栏链接', 'compact' => '简约横栏', 'band' => '全宽深色'],
+ 'palette' => ['custom' => '自定义配色'],
+ ];
+
+ public const COMPONENTS = [
+ 'header' => ['brand' => '站点标识', 'links' => '导航链接', 'action' => '行动按钮', 'account' => '用户区'],
+ 'footer' => ['brand' => '站点标识', 'text' => '说明文字', 'links' => '页脚链接', 'legal' => '版权文字'],
+ ];
+
+ public const COLORS = [
+ 'white' => ['页面背景', '#ffffff'], 'paper' => ['区块背景', '#f5f7fb'],
+ 'ink' => ['正文', '#111a2e'], 'muted' => ['次要文字', '#505d73'],
+ 'accent' => ['强调色', '#214ed7'], 'accent-deep' => ['强调色悬停', '#173bae'],
+ 'accent-light' => ['强调色浅底', '#e8efff'], 'line' => ['边框', '#dbe3f0'],
+ 'button-ink' => ['填充按钮文字', '#ffffff'],
+ ];
+
+ public static function all(?string $kind = null): array
+ {
+ $query = Database::connect()->prepare('SELECT id, kind, name, preset, version FROM design_presets'
+ . ($kind === null ? '' : ' WHERE kind = ?') . ' ORDER BY kind, id');
+ $query->execute($kind === null ? [] : [$kind]);
+
+ return $query->fetchAll();
+ }
+
+ public static function find(int $id, string $kind): ?array
+ {
+ if ($id < 1) {
+ return null;
+ }
+ $query = Database::connect()->prepare('SELECT * FROM design_presets WHERE id = ? AND kind = ?');
+ $query->execute([$id, $kind]);
+ $row = $query->fetch();
+ if (!$row) {
+ return null;
+ }
+ $row['payload'] = self::normalize($kind, $row['preset'], json_decode($row['payload'], true, flags: JSON_THROW_ON_ERROR));
+
+ return $row;
+ }
+
+ public static function defaults(string $kind): array
+ {
+ if ($kind === 'palette') {
+ return array_map(static fn (array $color): string => $color[1], self::COLORS);
+ }
+
+ return [
+ 'components' => array_keys(self::COMPONENTS[$kind]), 'logo' => '', 'brand' => '', 'text' => '',
+ 'legal' => '', 'links' => $kind === 'header' ? [['/', '首页'], ['/articles', '文章']] : [],
+ 'action' => [], 'provider' => [],
+ ];
+ }
+
+ public static function layout(string $kind, array $site, array $page): array
+ {
+ $id = (int) ($page[$kind . '_id'] ?? 0) ?: (int) ($site[$kind . '_id'] ?? 0);
+
+ return self::find($id, $kind) ?? [
+ 'id' => 0, 'preset' => array_key_first(self::PRESETS[$kind]), 'payload' => self::defaults($kind),
+ ];
+ }
+
+ public static function selection(string $kind, mixed $value): ?int
+ {
+ if ($value === '' || $value === null || $value === 0) {
+ return null;
+ }
+ $id = filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1]]);
+ if ($id === false || !self::find($id, $kind)) {
+ throw new RuntimeException('所选页头、页脚或配色方案不存在。');
+ }
+
+ return $id;
+ }
+
+ public static function normalize(string $kind, string $preset, array $data): array
+ {
+ if (!isset(self::PRESETS[$kind][$preset])) {
+ throw new RuntimeException('请选择可用的组件模板。');
+ }
+ if ($kind === 'palette') {
+ $colors = [];
+ foreach (self::COLORS as $key => [, $default]) {
+ $color = $data[$key] ?? $default;
+ if (!is_string($color) || !preg_match('/^#[\da-f]{6}$/iD', $color)) {
+ throw new RuntimeException('颜色必须使用六位十六进制表示。');
+ }
+ $colors[$key] = strtolower($color);
+ }
+
+ return $colors;
+ }
+
+ $clean = self::defaults($kind);
+ foreach (['brand' => 100, 'text' => 1200, 'legal' => 300, 'logo' => 1000] as $field => $limit) {
+ $clean[$field] = self::string($data[$field] ?? '', $limit);
+ }
+ if ($clean['logo'] !== '' && !Html::url($clean['logo'], true)) {
+ throw new RuntimeException('请检查站点标识地址。');
+ }
+ $components = $data['components'] ?? $clean['components'];
+ if (!is_array($components) || !array_is_list($components)) {
+ throw new RuntimeException('组件顺序无效。');
+ }
+ foreach ($components as $component) {
+ if (!is_string($component) || !isset(self::COMPONENTS[$kind][$component])) {
+ throw new RuntimeException('布局包含未知组件。');
+ }
+ }
+ $clean['components'] = array_values(array_unique($components));
+ $clean['links'] = Buttons::validate($data['links'] ?? $clean['links'], 20);
+ $clean['action'] = Buttons::validate($data['action'] ?? []);
+ $clean['provider'] = $kind === 'header' && $preset === 'member'
+ ? self::provider($data['provider'] ?? []) : [];
+
+ return $clean;
+ }
+
+ public static function provider(array $data): array
+ {
+ $mode = $data['mode'] ?? '';
+ if ($mode === '') {
+ return [];
+ }
+ if (!in_array($mode, ['oidc', 'oauth2'], true)) {
+ throw new RuntimeException('请选择 OIDC 或 OAuth 2.0。');
+ }
+ $result = ['mode' => $mode];
+ foreach (['client_id', 'secret_env', 'scope', 'issuer', 'authorization', 'token', 'userinfo', 'subject_field', 'name_field', 'avatar_field', 'token_auth'] as $field) {
+ $result[$field] = self::string($data[$field] ?? '', 600);
+ }
+ if (!in_array($result['token_auth'], ['', 'client_secret_basic', 'client_secret_post'], true)) {
+ throw new RuntimeException('令牌端点认证方式无效。');
+ }
+ if ($result['client_id'] === '' || !preg_match('/^LAYSITE_OAUTH_[A-Z0-9_]{1,45}$/D', $result['secret_env'])) {
+ throw new RuntimeException('填写客户端 ID 和以 LAYSITE_OAUTH_ 开头的客户端密钥环境变量名。');
+ }
+ foreach ($mode === 'oidc' ? ['issuer'] : ['authorization', 'token', 'userinfo'] as $field) {
+ $url = parse_url($result[$field]);
+ if (!$url || ($url['scheme'] ?? '') !== 'https' || empty($url['host'])
+ || isset($url['user']) || isset($url['pass']) || isset($url['fragment']) || ($field === 'issuer' && isset($url['query'])) || !Html::url($result[$field], true)) {
+ throw new RuntimeException('认证端点必须使用完整的 HTTPS 地址。');
+ }
+ }
+ if ($mode === 'oauth2' && $result['subject_field'] === '') {
+ throw new RuntimeException('OAuth 2.0 用户资料需要指定稳定的用户 ID 字段。');
+ }
+
+ return $result;
+ }
+
+ public static function save(string $kind, ?int $id, string $name, string $preset, array $data, int $version, bool $default): int
+ {
+ $name = self::string($name, 100);
+ if ($name === '') {
+ throw new RuntimeException('请填写配置名称。');
+ }
+ $payload = Database::json(self::normalize($kind, $preset, $data));
+
+ return Database::write(function (PDO $pdo) use ($kind, $id, $name, $preset, $payload, $version, $default): int {
+ if ($id === null) {
+ $pdo->prepare('INSERT INTO design_presets (kind, name, preset, payload) VALUES (?, ?, ?, ?)')->execute([$kind, $name, $preset, $payload]);
+ $id = (int) $pdo->lastInsertId();
+ } else {
+ $query = $pdo->prepare('UPDATE design_presets SET name = ?, preset = ?, payload = ?, version = version + 1 WHERE id = ? AND kind = ? AND version = ?');
+ $query->execute([$name, $preset, $payload, $id, $kind, $version]);
+ if ($query->rowCount() !== 1) {
+ throw new RuntimeException('配置已更新,请重新打开后再保存。');
+ }
+ }
+ if ($kind !== 'palette') {
+ $site = json_decode($pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
+ if ($default) {
+ $site[$kind . '_id'] = $id;
+ } elseif (($site[$kind . '_id'] ?? null) === $id) {
+ unset($site[$kind . '_id']);
+ }
+ $pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
+ }
+
+ return $id;
+ });
+ }
+
+ private static function string(mixed $value, int $limit): string
+ {
+ if (!is_string($value) || !mb_check_encoding($value, 'UTF-8') || mb_strlen($value) > $limit) {
+ throw new RuntimeException('配置包含无效或过长的文字。');
+ }
+
+ return trim($value);
+ }
+}
diff --git a/app/Content/DirectoryCard.php b/app/Content/DirectoryCard.php
new file mode 100644
index 0000000..0219b7a
--- /dev/null
+++ b/app/Content/DirectoryCard.php
@@ -0,0 +1,39 @@
+ $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('' . $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])');
+ }
+}
diff --git a/app/Content/Html.php b/app/Content/Html.php
new file mode 100644
index 0000000..9706127
--- /dev/null
+++ b/app/Content/Html.php
@@ -0,0 +1,160 @@
+ ['href', 'target', 'rel'], 'article' => [], 'audio' => ['src', 'controls', 'preload'], 'b' => [], 'blockquote' => [], 'br' => [],
+ 'caption' => [], 'code' => [], 'dd' => [], 'details' => [], 'div' => ['role', 'aria-label', 'tabindex'],
+ 'dl' => [], 'dt' => [], 'em' => [], 'h1' => [], 'h2' => [], 'h3' => [], 'h4' => [], 'h5' => [], 'h6' => [], 'hr' => [], 'i' => [],
+ 'img' => ['src', 'alt', 'loading', 'width', 'height'], 'label' => ['for'],
+ 'li' => [], 'ol' => [], 'p' => [], 'pre' => [], 'progress' => ['max', 'value'], 's' => [],
+ 'small' => [], 'source' => ['src', 'type'], 'span' => [], 'strong' => [], 'summary' => [],
+ 'table' => [], 'tbody' => [], 'td' => ['colspan', 'rowspan'], 'tfoot' => [],
+ 'th' => ['scope', 'colspan', 'rowspan'], 'thead' => [], 'tr' => [], 'ul' => [],
+ 'video' => ['src', 'controls', 'muted', 'playsinline', 'poster', 'preload'],
+ ];
+
+ public static function url(string $value, bool $media = false): bool
+ {
+ if ($value === '' || preg_match('/[\x00-\x20\x7f\\\\]/', $value)) {
+ return false;
+ }
+ if (str_starts_with($value, '/')) {
+ return !str_starts_with($value, '//');
+ }
+ if (str_starts_with($value, '#')) {
+ return !$media && strlen($value) > 1;
+ }
+ $scheme = strtolower((string) parse_url($value, PHP_URL_SCHEME));
+
+ return in_array($scheme, $media ? ['https'] : ['https', 'http', 'mailto', 'tel'], true);
+ }
+
+ public static function markdown(string $text): string
+ {
+ static $converter;
+ $converter ??= new GithubFlavoredMarkdownConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]);
+
+ $html = $converter->convert($text)->getContent();
+
+ return str_replace(['', '
'], ['', '
'], $html);
+ }
+
+ 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->loadHTML('' . $html . '', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
+ $body = $document->getElementsByTagName('body')->item(0);
+ if (!$body) {
+ return '';
+ }
+ self::sanitizeChildren($body);
+ if ($anchorPrefix !== null) {
+ $ids = [];
+ foreach ($body->getElementsByTagName('*') as $element) {
+ $id = $element->getAttribute('id');
+ if ($id !== '') {
+ $ids[$id] = $anchorPrefix . '-' . $id;
+ $element->setAttribute('id', $ids[$id]);
+ }
+ }
+ foreach ($body->getElementsByTagName('a') as $link) {
+ $href = $link->getAttribute('href');
+ if (str_starts_with($href, '#') && isset($ids[substr($href, 1)])) {
+ $link->setAttribute('href', '#' . $ids[substr($href, 1)]);
+ }
+ }
+ }
+ $output = '';
+ foreach ($body->childNodes as $child) {
+ $output .= $document->saveHTML($child);
+ }
+
+ return trim($output);
+ }
+
+ private static function sanitizeChildren(DOMNode $parent): void
+ {
+ foreach (iterator_to_array($parent->childNodes) as $element) {
+ if ($element->nodeType === XML_COMMENT_NODE) {
+ $parent->removeChild($element);
+ continue;
+ }
+ if (!$element instanceof DOMElement) {
+ continue;
+ }
+ if (!array_key_exists($element->tagName, self::TAGS)) {
+ $parent->removeChild($element);
+ continue;
+ }
+ $allowed = [...self::TAGS[$element->tagName], 'class', 'id'];
+ foreach (iterator_to_array($element->attributes) as $attribute) {
+ $name = $attribute->name;
+ $value = $attribute->value;
+ if (!in_array($name, $allowed, true)
+ || ($name === 'href' && !self::url($value))
+ || (in_array($name, ['src', 'poster'], true) && !self::url($value, true))
+ || ($name === 'target' && $value !== '_blank')
+ || ($name === 'tabindex' && $value !== '0')) {
+ $element->removeAttribute($name);
+ }
+ }
+ if ($element->tagName === 'a') {
+ if ($element->getAttribute('target') === '_blank') {
+ $element->setAttribute('rel', 'noopener noreferrer');
+ } else {
+ $element->removeAttribute('rel');
+ }
+ }
+ self::sanitizeChildren($element);
+ }
+ }
+}
diff --git a/app/Content/IdentityProvider.php b/app/Content/IdentityProvider.php
new file mode 100644
index 0000000..c271d60
--- /dev/null
+++ b/app/Content/IdentityProvider.php
@@ -0,0 +1,148 @@
+http = new Client(['timeout' => 8, 'connect_timeout' => 4, 'allow_redirects' => false]);
+ $scope = preg_split('/\s+/', trim($config['scope']), -1, PREG_SPLIT_NO_EMPTY);
+ $authorization = $config['authorization'];
+ $token = $config['token'];
+ $userinfo = $config['userinfo'];
+ if ($config['mode'] === 'oidc') {
+ $this->oidc = $this->document(rtrim($config['issuer'], '/') . '/.well-known/openid-configuration');
+ if (($this->oidc['issuer'] ?? null) !== $config['issuer']) {
+ throw new RuntimeException('OIDC Issuer 与发现文档不一致。');
+ }
+ $authorization = $this->endpoint($this->oidc['authorization_endpoint'] ?? '');
+ $token = $this->endpoint($this->oidc['token_endpoint'] ?? '');
+ $userinfo = isset($this->oidc['userinfo_endpoint']) ? $this->endpoint($this->oidc['userinfo_endpoint']) : '';
+ $scope = array_values(array_unique(['openid', 'profile', 'email', ...$scope]));
+ }
+ $auth = $config['token_auth'];
+ if ($auth === '') {
+ $supported = $this->oidc['token_endpoint_auth_methods_supported'] ?? ['client_secret_basic'];
+ if ($this->oidc === [] || (!in_array('client_secret_basic', $supported, true) && in_array('client_secret_post', $supported, true))) {
+ $auth = 'client_secret_post';
+ } elseif (in_array('client_secret_basic', $supported, true)) {
+ $auth = 'client_secret_basic';
+ } else {
+ throw new RuntimeException('身份服务没有公布受支持的令牌端点认证方式。');
+ }
+ }
+ $this->client = new GenericProvider([
+ 'clientId' => $config['client_id'], 'clientSecret' => $secret,
+ 'redirectUri' => View::absolute('/account/callback'), 'urlAuthorize' => $authorization,
+ 'urlAccessToken' => $token, 'urlResourceOwnerDetails' => $userinfo,
+ 'pkceMethod' => GenericProvider::PKCE_METHOD_S256, 'scopes' => $scope, 'scopeSeparator' => ' ',
+ ], [
+ 'httpClient' => $this->http,
+ 'optionProvider' => $auth === 'client_secret_basic' ? new HttpBasicAuthOptionProvider() : new PostAuthOptionProvider(),
+ ]);
+ }
+
+ public function authorization(string $nonce): string
+ {
+ return $this->client->getAuthorizationUrl($this->oidc === [] ? [] : ['nonce' => $nonce]);
+ }
+
+ public function profile(string $code, string $proof, string $nonce): array
+ {
+ $this->client->setPkceCode($proof);
+ $token = $this->client->getAccessToken('authorization_code', ['code' => $code]);
+ if ($this->oidc === []) {
+ $claims = $this->client->getResourceOwner($token)->toArray();
+ } else {
+ $claims = $this->verifiedClaims($token->getValues()['id_token'] ?? '', $nonce);
+ if (isset($this->oidc['userinfo_endpoint'])) {
+ $more = $this->client->getResourceOwner($token)->toArray();
+ if (($more['sub'] ?? null) !== $claims['sub']) {
+ throw new RuntimeException('OIDC 用户资料的主体与 ID Token 不一致。');
+ }
+ $claims = $more + $claims;
+ }
+ }
+ $subject = $claims[$this->oidc !== [] ? 'sub' : $this->config['subject_field']] ?? null;
+ if ((!is_string($subject) && !is_int($subject)) || (string) $subject === '' || strlen((string) $subject) > 255) {
+ throw new RuntimeException('身份服务没有返回有效的用户标识。');
+ }
+ $name = $claims[$this->config['name_field'] ?: 'name'] ?? $claims['preferred_username'] ?? (string) $subject;
+ $avatar = $claims[$this->config['avatar_field'] ?: 'picture'] ?? '';
+ return [
+ 'subject' => (string) $subject,
+ 'name' => is_string($name) ? mb_substr($name, 0, 100) : (string) $subject,
+ 'avatar' => is_string($avatar) && strlen($avatar) <= 2048 && str_starts_with($avatar, 'https://') && Html::url($avatar, true) ? $avatar : '',
+ ];
+ }
+
+ private function verifiedClaims(mixed $encoded, string $nonce): array
+ {
+ if (!is_string($encoded) || strlen($encoded) > 16384 || substr_count($encoded, '.') !== 2) {
+ throw new RuntimeException('身份服务没有返回有效的 ID Token。');
+ }
+ $header = JWT::jsonDecode(JWT::urlsafeB64Decode(explode('.', $encoded, 2)[0]));
+ $algorithm = $header->alg ?? '';
+ if (!in_array($algorithm, ['RS256', 'RS384', 'RS512', 'ES256', 'ES384'], true)) {
+ throw new RuntimeException('身份服务使用了不支持的 ID Token 签名算法。');
+ }
+ $keys = $this->document($this->endpoint($this->oidc['jwks_uri'] ?? ''));
+ $claims = (array) JWT::decode($encoded, JWK::parseKeySet($keys, $algorithm));
+ $audience = (array) ($claims['aud'] ?? []);
+ $client = $this->config['client_id'];
+ if (($claims['iss'] ?? null) !== $this->config['issuer'] || !in_array($client, $audience, true)
+ || ((count($audience) > 1 || isset($claims['azp'])) && ($claims['azp'] ?? null) !== $client)
+ || ($claims['nonce'] ?? null) !== $nonce || !is_string($claims['sub'] ?? null) || $claims['sub'] === ''
+ || !is_int($claims['exp'] ?? null) || $claims['exp'] <= time()
+ || !is_int($claims['iat'] ?? null) || $claims['iat'] > time() + 60) {
+ throw new RuntimeException('OIDC ID Token 声明校验失败。');
+ }
+
+ return $claims;
+ }
+
+ private function document(string $endpoint): array
+ {
+ $response = $this->http->get($this->endpoint($endpoint), ['headers' => ['Accept' => 'application/json'], 'stream' => true]);
+ $body = Utils::copyToString($response->getBody(), 1048577);
+ if (strlen($body) > 1048576 || $response->getStatusCode() !== 200) {
+ throw new RuntimeException('身份服务文档超过大小限制。');
+ }
+ $data = json_decode($body, true, 32, JSON_THROW_ON_ERROR);
+ if (!is_array($data)) {
+ throw new RuntimeException('身份服务文档格式无效。');
+ }
+ return $data;
+ }
+
+ private function endpoint(mixed $endpoint): string
+ {
+ $url = is_string($endpoint) ? parse_url($endpoint) : false;
+ if (!$url || ($url['scheme'] ?? '') !== 'https' || empty($url['host'])
+ || isset($url['user']) || isset($url['pass']) || isset($url['fragment']) || !Html::url($endpoint, true)) {
+ throw new RuntimeException('身份服务端点必须使用 HTTPS。');
+ }
+
+ return $endpoint;
+ }
+}
diff --git a/app/Content/Media.php b/app/Content/Media.php
new file mode 100644
index 0000000..8b2e253
--- /dev/null
+++ b/app/Content/Media.php
@@ -0,0 +1,130 @@
+ 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/webp' => 'webp',
+ 'image/avif' => 'avif', 'image/x-icon' => 'ico', 'image/vnd.microsoft.icon' => 'ico', 'image/svg+xml' => 'svg',
+ 'video/mp4' => 'mp4', 'video/webm' => 'webm', 'video/quicktime' => 'mov',
+ 'audio/mpeg' => 'mp3', 'audio/ogg' => 'ogg', 'audio/wav' => 'wav',
+ 'application/pdf' => 'pdf', 'font/woff' => 'woff', 'font/woff2' => 'woff2',
+ ];
+
+ public static function all(bool $includeArchived = false): array
+ {
+ $query = 'SELECT name, label, mime, size, created_at, archived FROM media' . ($includeArchived ? '' : ' WHERE archived = 0');
+ $files = Database::connect()->query($query . ' ORDER BY created_at DESC, name')->fetchAll();
+ foreach ($files as &$file) {
+ $file['url'] = '/assets/uploads/' . $file['name'];
+ }
+ unset($file);
+
+ return $files;
+ }
+
+ public static function upload(UploadFile $file, string $label): void
+ {
+ if (!$file->isValid() || ($size = $file->getSize()) < 1 || $size > self::MAX_BYTES) {
+ throw new RuntimeException('请选择大小不超过 64 MB 的有效文件。');
+ }
+ $source = $file->getPathname();
+ $mime = (new \finfo(FILEINFO_MIME_TYPE))->file($source);
+ $extension = self::EXTENSIONS[$mime] ?? null;
+ if ($extension === null) {
+ throw new RuntimeException('文件类型不受支持。');
+ }
+ $content = $mime === 'image/svg+xml' ? self::safeSvg($source, $size) : null;
+ $name = bin2hex(random_bytes(16)) . '.' . $extension;
+ $directory = self::directory();
+ if (!is_dir($directory) && !mkdir($directory, 0750, true) && !is_dir($directory)) {
+ throw new RuntimeException('资源目录无法创建。');
+ }
+ $path = $directory . '/' . $name;
+ try {
+ $written = $content === null ? copy($source, $path) : file_put_contents($path, $content) === strlen($content);
+ if (!$written) {
+ throw new RuntimeException('文件写入失败。');
+ }
+ $query = Database::connect()->prepare('INSERT INTO media (name, label, mime, size, created_at) VALUES (?, ?, ?, ?, ?)');
+ $query->execute([$name, $label, $mime, $content === null ? $size : strlen($content), gmdate('c')]);
+ } catch (Throwable $error) {
+ if (is_file($path)) {
+ unlink($path);
+ }
+ throw $error;
+ }
+ }
+
+ public static function find(string $name): ?array
+ {
+ $query = Database::connect()->prepare('SELECT * FROM media WHERE name = ?');
+ $query->execute([$name]);
+
+ return $query->fetch() ?: null;
+ }
+
+ public static function update(string $name, string $label, bool $archived): void
+ {
+ Database::connect()->prepare('UPDATE media SET label = ?, archived = ? WHERE name = ?')
+ ->execute([$label, (int) $archived, $name]);
+ }
+
+ public static function directory(): string
+ {
+ return rtrim(getenv('LAYSITE_MEDIA_DIR') ?: dirname(__DIR__, 2) . '/storage/media', '/');
+ }
+
+ public static function validateBackup(string $path, string $name, string $mime, int $size): void
+ {
+ if ((new \finfo(FILEINFO_MIME_TYPE))->file($path) !== $mime
+ || !isset(self::EXTENSIONS[$mime]) || self::EXTENSIONS[$mime] !== pathinfo($name, PATHINFO_EXTENSION)) {
+ throw new RuntimeException('备份资源类型与清单不一致。');
+ }
+ if ($mime === 'image/svg+xml') {
+ self::safeSvg($path, $size);
+ }
+ }
+
+ private static function safeSvg(string $source, int $size): string
+ {
+ if ($size > 512 * 1024) {
+ throw new RuntimeException('SVG 图标最大支持 512 KB。');
+ }
+ $svg = new DOMDocument();
+ if (!$svg->loadXML(file_get_contents($source), LIBXML_NONET | LIBXML_NOERROR | LIBXML_NOWARNING) || $svg->doctype
+ || $svg->documentElement?->namespaceURI !== 'http://www.w3.org/2000/svg' || $svg->documentElement->localName !== 'svg') {
+ throw new RuntimeException('SVG 图标格式无效。');
+ }
+ $tags = ['svg', 'g', 'path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon', 'title', 'desc'];
+ $attributes = ['viewBox', 'width', 'height', 'fill', 'fill-rule', 'fill-opacity', 'stroke', 'stroke-width', 'stroke-linecap',
+ 'stroke-linejoin', 'stroke-dasharray', 'stroke-opacity', 'curve', 'clip-rule', 'opacity', 'd', 'x', 'y',
+ 'rx', 'ry', 'cx', 'cy', 'r', 'x1', 'x2', 'y1', 'y2', 'points', 'transform'];
+ foreach ((new DOMXPath($svg))->query('//*') as $element) {
+ if (!$element instanceof DOMElement || $element->namespaceURI !== 'http://www.w3.org/2000/svg'
+ || !in_array($element->localName, $tags, true)) {
+ throw new RuntimeException('SVG 仅支持基础矢量元素。');
+ }
+ foreach ($element->attributes as $attribute) {
+ if ($attribute->namespaceURI !== null || !in_array($attribute->localName, $attributes, true)
+ || !preg_match('/^[a-z0-9#.,%\s()+-]*$/iD', $attribute->value) || preg_match('/url\s*\(/i', $attribute->value)) {
+ throw new RuntimeException('SVG 包含不支持的属性或外部引用。');
+ }
+ }
+ }
+
+ return $svg->saveXML($svg->documentElement);
+ }
+}
diff --git a/app/Content/PageDraft.php b/app/Content/PageDraft.php
new file mode 100644
index 0000000..f8f01da
--- /dev/null
+++ b/app/Content/PageDraft.php
@@ -0,0 +1,109 @@
+ 70 || !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value)
+ || in_array($value, $reserved, true)) {
+ throw new RuntimeException('网址标识无效或已保留。');
+ }
+
+ return $value;
+ }
+
+ public static function content(array $input, array $page): array
+ {
+ $name = self::text($input['name'] ?? $page['name'] ?? '', 100, true);
+ $page += ['name' => $name, 'title' => $name, 'heading' => $name, 'description' => '', 'lead' => '',
+ 'accent' => '', 'image' => '', 'alt' => '', 'image_scale' => 0, 'alignments' => [], 'visibility' => [],
+ 'actions' => [], 'quicklinks' => [], 'theme' => '', 'sections' => []];
+ $page['name'] = $name;
+ foreach (['title' => 160, 'heading' => 110, 'description' => 300, 'lead' => 600, 'accent' => 110, 'image' => 1000, 'alt' => 200] as $field => $limit) {
+ $page[$field] = self::text($input[$field] ?? $page[$field], $limit, in_array($field, ['title', 'heading'], true));
+ }
+ if (mb_strlen($page['heading'] . $page['accent']) > 110 || ($page['image'] !== '' && !Html::url($page['image'], true))) {
+ throw new RuntimeException('首屏标题过长或图片地址不正确。');
+ }
+ foreach (['header', 'footer', 'palette'] as $kind) {
+ $key = $kind . '_id';
+ $page[$key] = array_key_exists($key, $input) ? DesignLibrary::selection($kind, $input[$key]) : ($page[$key] ?? null);
+ }
+ $page['actions'] = Buttons::validate($input['actions'] ?? $page['actions']);
+ if (array_key_exists('visibility', $input)) {
+ if (!is_array($input['visibility'])) {
+ throw new RuntimeException('页面显示选项无效。');
+ }
+ foreach ($input['visibility'] as $area => $visible) {
+ if (!in_array($area, ['hero', 'header', 'footer'], true) || !is_bool($visible)) {
+ throw new RuntimeException('页面显示选项无效。');
+ }
+ $page['visibility'][$area] = $visible;
+ }
+ }
+ $page['status'] = 'draft';
+ if (array_key_exists('sections', $input)) {
+ $oldKeys = array_column($page['sections'], 'key');
+ $page['sections'] = self::sections($input['sections']);
+ if (!array_key_exists('actions', $input)) {
+ $removed = array_map(static fn (string $key): string => '#' . $key, array_diff($oldKeys, array_column($page['sections'], 'key')));
+ $page['actions'] = array_values(array_filter($page['actions'], static fn (array $button): bool => !in_array($button[0], $removed, true)));
+ }
+ $page['quicklinks'] = array_map(static fn (array $section): array => ['#' . $section['key'], $section['title']], array_slice($page['sections'], 0, 20));
+ }
+
+ return $page;
+ }
+
+ private static function sections(mixed $items): array
+ {
+ if (!is_array($items) || !array_is_list($items) || count($items) > 50) {
+ throw new RuntimeException('每页最多可提交 50 个区块。');
+ }
+ $sections = [];
+ foreach ($items as $item) {
+ if (!is_array($item)) {
+ throw new RuntimeException('区块必须是对象。');
+ }
+ $key = self::slug($item['key'] ?? null, ['home', 'contact', 'main-content', 'primary-navigation', 'preview']);
+ if (isset($sections[$key])) {
+ throw new RuntimeException('区块锚点重复。');
+ }
+ $preset = null;
+ if (isset($item['preset'])) {
+ $preset = is_string($item['preset']) ? BlockTemplates::find($item['preset']) : null;
+ if (!$preset) {
+ throw new RuntimeException('区块模板不存在。');
+ }
+ }
+ $style = $item['style'] ?? $preset[4] ?? 'plain';
+ if (!in_array($style, ['plain', 'tinted'], true)) {
+ throw new RuntimeException('区块样式无效。');
+ }
+ $sections[$key] = [
+ 'key' => $key, 'title' => self::text($item['title'] ?? $preset[0] ?? '', 100, true),
+ 'lead' => self::text($item['lead'] ?? $preset[2] ?? '', 500),
+ 'body' => Html::sanitize(self::text($item['body'] ?? $preset[1] ?? '', 120000)),
+ 'style' => $style, 'feed' => $preset[3] ?? null, 'version' => null,
+ ];
+ }
+ return array_values($sections);
+ }
+
+ private static function text(mixed $value, int $limit, bool $required = false): string
+ {
+ if (!is_string($value) || !mb_check_encoding($value, 'UTF-8') || mb_strlen($value) > $limit || ($required && trim($value) === '')) {
+ throw new RuntimeException('请检查页面内容及字段长度。');
+ }
+
+ return trim($value);
+ }
+}
diff --git a/app/Content/PageTemplates.php b/app/Content/PageTemplates.php
new file mode 100644
index 0000000..b80d396
--- /dev/null
+++ b/app/Content/PageTemplates.php
@@ -0,0 +1,40 @@
+ $group) {
+ if (!isset($group['pages'][$key])) {
+ continue;
+ }
+ $template = $group['pages'][$key];
+ $sections = [];
+ $quicklinks = [];
+ foreach ($template['sections'] as [$anchor, $title, $style, $body, $feed]) {
+ $sections[] = ['key' => $anchor, 'title' => $title, 'style' => $style, 'body' => Html::sanitize($body, $anchor),
+ 'lead' => '', 'feed' => $feed, 'alignments' => '{}', 'version' => 0];
+ $quicklinks[] = ['#' . $anchor, $title];
+ }
+
+ return array_replace($template, [
+ 'slug' => $key, 'theme' => $theme, 'title' => $template['name'], 'accent' => '',
+ 'lead' => $template['description'], 'quicklinks' => $quicklinks, 'status' => 'draft',
+ 'alignments' => [], 'image_scale' => 0, 'sections' => $sections,
+ ]);
+ }
+
+ return null;
+ }
+}
diff --git a/app/Content/Passwords.php b/app/Content/Passwords.php
new file mode 100644
index 0000000..9d7a076
--- /dev/null
+++ b/app/Content/Passwords.php
@@ -0,0 +1,20 @@
+= self::MIN_LENGTH;
+ }
+}
diff --git a/app/Content/Repository.php b/app/Content/Repository.php
new file mode 100644
index 0000000..ed6227f
--- /dev/null
+++ b/app/Content/Repository.php
@@ -0,0 +1,403 @@
+ '目录', '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;
+
+ public function __construct()
+ {
+ $this->pdo = Database::connect();
+ }
+
+ public function site(): array
+ {
+ return json_decode((string) $this->pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
+ }
+
+ public function pages(bool $publishedOnly = false): array
+ {
+ $where = $publishedOnly ? " WHERE status = 'published'" : '';
+
+ return $this->pdo->query('SELECT slug, name, title, updated_at, status, version FROM pages' . $where . ' ORDER BY rowid')->fetchAll();
+ }
+
+ public function createPage(string $slug, string $name, array $template = []): void
+ {
+ Database::write(function (PDO $pdo) use ($slug, $name, $template): void {
+ $query = $pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
+ lead, image, alt, actions, quicklinks, theme, visibility, header_id, footer_id, palette_id, status, updated_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'draft', ?)");
+ $query->execute([
+ $slug, $name, $template['title'] ?? $name, $template['description'] ?? '', $template['heading'] ?? $name,
+ $template['accent'] ?? '', $template['lead'] ?? '', $template['image'] ?? '', $template['alt'] ?? '',
+ Database::json($template['actions'] ?? []), Database::json($template['quicklinks'] ?? []),
+ $template['theme'] ?? '', Database::json($template['visibility'] ?? []), $template['header_id'] ?? null, $template['footer_id'] ?? null, $template['palette_id'] ?? null, self::now(),
+ ]);
+ if ($query->rowCount() !== 1) {
+ throw new RuntimeException('此页面地址已存在。');
+ }
+ foreach ($template['sections'] ?? [] as $section) {
+ self::insertSection($pdo, $slug, $section['key'], $section);
+ }
+ });
+ }
+
+ public function page(string $slug): ?array
+ {
+ $page = $this->one('SELECT * FROM pages WHERE slug = ?', [$slug]);
+ if (!$page) {
+ return null;
+ }
+ foreach (['actions', 'quicklinks', 'alignments', 'visibility'] as $key) {
+ $page[$key] = json_decode($page[$key], true, flags: JSON_THROW_ON_ERROR);
+ }
+ $query = $this->pdo->prepare('SELECT * FROM sections WHERE page_slug = ? ORDER BY position, key');
+ $query->execute([$slug]);
+ $page['sections'] = $query->fetchAll();
+
+ return $page;
+ }
+
+ public function section(string $page, string $key): ?array
+ {
+ return $this->one('SELECT * FROM sections WHERE page_slug = ? AND key = ?', [$page, $key]);
+ }
+
+ public function publishedFeed(string $page, string $key): ?array
+ {
+ return $this->one("SELECT sections.title, sections.feed FROM sections
+ JOIN pages ON pages.slug = sections.page_slug
+ WHERE pages.slug = ? AND pages.status = 'published' AND sections.key = ? AND sections.feed IS NOT NULL", [$page, $key]);
+ }
+
+ public function savePage(string $slug, array $data, int $version, array $sections = [], bool $replaceDraftSections = false): void
+ {
+ Database::write(function (PDO $pdo) use ($slug, $data, $version, $sections, $replaceDraftSections): void {
+ $query = $pdo->prepare('UPDATE pages SET name = ?, title = ?, description = ?, heading = ?, accent = ?, lead = ?,
+ image = ?, alt = ?, image_scale = ?, alignments = ?, actions = ?, quicklinks = ?, visibility = ?, header_id = ?, footer_id = ?, palette_id = ?, status = ?, updated_at = ?, version = version + 1 WHERE slug = ? AND version = ?');
+ $query->execute([
+ $data['name'], $data['title'], $data['description'], $data['heading'], $data['accent'], $data['lead'],
+ $data['image'], $data['alt'], $data['image_scale'], Database::json($data['alignments']), Database::json($data['actions']), Database::json($data['quicklinks']),
+ Database::json($data['visibility']), $data['header_id'], $data['footer_id'], $data['palette_id'], $data['status'], self::now(), $slug, $version,
+ ]);
+ self::checkVersion($query->rowCount());
+ if ($replaceDraftSections) {
+ $pdo->prepare('DELETE FROM sections WHERE page_slug = ?')->execute([$slug]);
+ }
+ 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
+ {
+ Database::write(function (PDO $pdo) use ($page, $key, $data, $version): void {
+ self::updateSection($pdo, $page, $key, $data, $version);
+ self::touchPage($pdo, $page);
+ });
+ }
+
+ private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
+ {
+ $query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, feed = ?, alignments = COALESCE(?, alignments), version = version + 1
+ WHERE page_slug = ? AND key = ? AND version = ?');
+ $query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $data['feed'] ?? null, $data['alignments'] ?? null, $page, $key, $version]);
+ 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) {
+ throw new RuntimeException('此区块锚点已被使用。');
+ }
+ }
+
+ private static function deleteSection(PDO $pdo, string $page, string $key, int $version): void
+ {
+ $query = $pdo->prepare('DELETE FROM sections WHERE page_slug = ? AND key = ? AND version = ?');
+ $query->execute([$page, $key, $version]);
+ self::checkVersion($query->rowCount());
+ $pdo->prepare("UPDATE pages SET
+ quicklinks = (SELECT json_group_array(json(value)) FROM json_each(quicklinks) WHERE json_extract(value, '$[0]') <> :anchor),
+ actions = (SELECT json_group_array(json(value)) FROM json_each(actions) WHERE json_extract(value, '$[0]') <> :anchor)
+ WHERE slug = :slug")->execute(['anchor' => '#' . $key, 'slug' => $page]);
+ }
+
+ public function arrangeSection(string $page, string $key, string $operation, int $version, int $pageVersion): void
+ {
+ Database::write(function (PDO $pdo) use ($page, $key, $operation, $version, $pageVersion): void {
+ $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;
+ }
+ $query = $pdo->prepare("SELECT key, version FROM sections WHERE page_slug = ? AND style <> 'hero-links' ORDER BY position, key");
+ $query->execute([$page]);
+ $revisions = $query->fetchAll(PDO::FETCH_KEY_PAIR);
+ if (!array_key_exists($key, $revisions)) {
+ 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);
+ if (!isset($keys[$other])) {
+ return;
+ }
+ [$keys[$index], $keys[$other]] = [$keys[$other], $keys[$index]];
+ $query = $pdo->prepare('UPDATE sections SET position = ? WHERE page_slug = ? AND key = ?');
+ foreach ($keys as $position => $section) {
+ $query->execute([$position, $page, $section]);
+ }
+ self::touchPage($pdo, $page, structureChanged: true);
+ });
+ }
+
+ private static function touchPage(PDO $pdo, string $slug, bool $structureChanged = false): void
+ {
+ $revision = $structureChanged ? ', version = version + 1' : '';
+ $pdo->prepare('UPDATE pages SET updated_at = ?' . $revision . ' WHERE slug = ?')->execute([self::now(), $slug]);
+ }
+
+ public function categories(): array
+ {
+ 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 = [];
+ if ($public) {
+ $sql .= " AND status = 'published'";
+ }
+ if ($category !== null) {
+ $args = (array) $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) {
+ $sql .= ' AND EXISTS (SELECT 1 FROM json_each(articles.tags) WHERE value = ?)';
+ $args[] = $tag;
+ }
+ $order = $public ? 'published_at' : 'updated_at';
+ $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]);
+
+ return array_map(self::decodeArticle(...), $query->fetchAll());
+ }
+
+ public function articleById(int $id): ?array
+ {
+ return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . ' FROM articles WHERE id = ?', [$id]));
+ }
+
+ public function published(string $slug): ?array
+ {
+ return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . " FROM articles WHERE slug = ? AND status = 'published'", [$slug]));
+ }
+
+ public function articleRedirect(string $slug): ?array
+ {
+ return $this->one("SELECT articles.slug FROM article_redirects
+ JOIN articles ON articles.id = article_redirects.article_id
+ WHERE article_redirects.slug = ? AND articles.status = 'published'", [$slug]);
+ }
+
+ public function legacyArticle(string $path): ?array
+ {
+ return $this->one("SELECT slug FROM articles WHERE legacy_path = ? AND status = 'published'", [$path]);
+ }
+
+ public function saveArticle(?int $id, array $data, int $version): int
+ {
+ return Database::write(function (PDO $pdo) use ($id, $data, $version): int {
+ $old = $id !== null ? $this->articleById($id) : null;
+ if ($id !== null && (!$old || $old['version'] !== $version)) {
+ self::checkVersion(0);
+ }
+ $existing = $this->one('SELECT id FROM articles WHERE slug = ?', [$data['slug']]);
+ $redirect = $this->one('SELECT article_id FROM article_redirects WHERE slug = ?', [$data['slug']]);
+ if (($existing && $existing['id'] !== $id) || ($redirect && $redirect['article_id'] !== $id)) {
+ throw new RuntimeException('此网址标识已被使用。');
+ }
+ $publishedAt = $old['published_at'] ?? ($data['status'] === 'published' && ($old['status'] ?? '') !== 'published' ? self::now() : null);
+ $values = [
+ $data['slug'], $data['title'], $data['summary'], $data['body'],
+ $data['body_format'], Database::json($data['card']),
+ Database::json($data['tags']), $data['status'], $publishedAt, self::now(),
+ ];
+ if ($id === null) {
+ $query = $pdo->prepare('INSERT INTO articles
+ (id, slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
+ VALUES (' . Database::NEXT_ARTICLE_ID . ', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
+ $query->execute($values);
+ $id = (int) $pdo->lastInsertId();
+ } else {
+ if ($old['slug'] !== $data['slug']) {
+ $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]);
+ }
+ $query = $pdo->prepare('UPDATE articles SET slug = ?, title = ?, summary = ?, body = ?,
+ body_format = ?, card = ?, tags = ?, status = ?, published_at = ?, updated_at = ?, version = version + 1
+ WHERE id = ? AND version = ?');
+ $query->execute([...$values, $id, $version]);
+ 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;
+ });
+ }
+
+ public function deleteArticle(int $id, int $version): void
+ {
+ Database::write(function (PDO $pdo) use ($id, $version): void {
+ // Keep the original seed slug even if the article has been renamed.
+ $deletions = $pdo->prepare('INSERT INTO article_deletions (slug, article_id)
+ SELECT slug, id FROM articles WHERE id = :id
+ UNION ALL SELECT slug, article_id FROM article_redirects WHERE article_id = :id
+ ON CONFLICT (slug) DO UPDATE SET article_id = excluded.article_id');
+ $deletions->execute(['id' => $id]);
+
+ $delete = $pdo->prepare('DELETE FROM articles WHERE id = ? AND version = ?');
+ $delete->execute([$id, $version]);
+ self::checkVersion($delete->rowCount());
+ });
+ }
+
+ public function sitemapArticles(): iterable
+ {
+ $query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
+ AND (trim(body) <> '' OR trim(summary) <> '' OR json_extract(card, '$.image') <> '' OR json_extract(card, '$.url') <> '')
+ ORDER BY slug");
+ yield from $query;
+ }
+
+ public function administrator(string $email): ?array
+ {
+ return $this->one('SELECT id, email, password_hash FROM users WHERE email = ?', [$email]);
+ }
+
+ public function administratorById(int $id): ?array
+ {
+ return $this->one('SELECT id, email, password_hash FROM users WHERE id = ?', [$id]);
+ }
+
+ public function changePassword(array $user, string $newHash): bool
+ {
+ $query = $this->pdo->prepare('UPDATE users SET password_hash = ? WHERE id = ? AND password_hash = ?');
+ $query->execute([$newHash, $user['id'], $user['password_hash']]);
+
+ return $query->rowCount() === 1;
+ }
+
+ public function recordFailedLogin(string $address): int
+ {
+ $now = time();
+ $current = $this->one('SELECT attempts, expires_at FROM login_attempts WHERE address = ?', [$address]);
+ if ($current && $current['attempts'] >= 12 && $current['expires_at'] > $now) {
+ return $current['expires_at'] - $now;
+ }
+
+ return Database::write(function (PDO $pdo) use ($address, $now): int {
+ $pdo->prepare('DELETE FROM login_attempts WHERE expires_at <= ?')->execute([$now]);
+ $current = $this->one('SELECT attempts, expires_at FROM login_attempts WHERE address = ?', [$address]);
+ if ($current && $current['attempts'] >= 12) {
+ return $current['expires_at'] - $now;
+ }
+ $query = $pdo->prepare('INSERT INTO login_attempts (address, attempts, expires_at) VALUES (?, 1, ?)
+ ON CONFLICT (address) DO UPDATE SET attempts = attempts + 1');
+ $query->execute([$address, $now + 900]);
+
+ return 0;
+ });
+ }
+
+ private function one(string $sql, array $args): ?array
+ {
+ $query = $this->pdo->prepare($sql);
+ $query->execute($args);
+
+ return $query->fetch() ?: null;
+ }
+
+ private static function decodeArticle(?array $article): ?array
+ {
+ if ($article !== null) {
+ foreach (['tags', 'categories', 'card'] as $field) {
+ $article[$field] = json_decode($article[$field], true, flags: JSON_THROW_ON_ERROR);
+ }
+ }
+
+ return $article;
+ }
+
+ private static function now(): string
+ {
+ return date('Y-m-d H:i:s');
+ }
+
+ private static function checkVersion(int $count): void
+ {
+ if ($count !== 1) {
+ throw new RuntimeException('此内容已在其他窗口更新。请保留你的修改,重新打开后再合并。');
+ }
+ }
+}
diff --git a/app/Content/SiteBackup.php b/app/Content/SiteBackup.php
new file mode 100644
index 0000000..cd1ceb0
--- /dev/null
+++ b/app/Content/SiteBackup.php
@@ -0,0 +1,289 @@
+query('SELECT * FROM ' . $table)->fetchAll();
+ }
+ $files = [];
+ $archive = new PharData($path);
+ foreach ($tables['media'] as $asset) {
+ $name = self::mediaName($asset['name']);
+ $file = Media::directory() . '/' . $name;
+ if (!is_file($file) || is_link($file) || filesize($file) !== (int) $asset['size']) {
+ throw new RuntimeException('资源文件缺失或大小已变更:' . $name);
+ }
+ $files[$name] = hash_file('sha256', $file);
+ $archive->addFile($file, 'media/' . $name);
+ }
+ $manifest = Database::json(['format' => self::FORMAT, 'version' => self::VERSION, 'exported_at' => gmdate('c'), 'tables' => $tables, 'files' => $files]);
+ if (strlen($manifest) > self::MANIFEST_LIMIT) {
+ throw new RuntimeException('站点内容超过当前备份格式的大小上限。');
+ }
+ $archive->addFromString('site.json', $manifest);
+ });
+ } catch (Throwable $error) {
+ if (is_file($path)) {
+ unlink($path);
+ }
+ throw $error;
+ }
+ }
+
+ public static function import(string $path): void
+ {
+ $archive = new PharData($path);
+ if (!isset($archive['site.json']) || $archive['site.json']->isLink() || $archive['site.json']->getSize() > self::MANIFEST_LIMIT) {
+ throw new RuntimeException('备份清单缺失或过大。');
+ }
+ $manifest = json_decode($archive['site.json']->getContent(), true, 48, JSON_THROW_ON_ERROR);
+ $tables = self::prepare($manifest);
+ $files = $manifest['files'] ?? [];
+ if (!is_array($files) || count($files) !== count($tables['media'])) {
+ throw new RuntimeException('备份资源清单不完整。');
+ }
+ $directory = Media::directory();
+ if (!is_dir($directory) && !mkdir($directory, 0750, true) && !is_dir($directory)) {
+ throw new RuntimeException('不能写入资源目录。');
+ }
+ $stage = $directory . '/.restore-' . bin2hex(random_bytes(12));
+ if (!mkdir($stage, 0700)) {
+ throw new RuntimeException('不能创建临时资源目录。');
+ }
+ $staged = [];
+ $installed = [];
+ try {
+ foreach ($tables['media'] as $asset) {
+ $name = self::mediaName($asset['name'] ?? null);
+ $size = $asset['size'] ?? 0;
+ if (!is_int($size) || $size < 1 || $size > Media::MAX_BYTES || isset($staged[$name])
+ || !is_string($files[$name] ?? null) || !isset($archive['media/' . $name])
+ || $archive['media/' . $name]->isLink() || !$archive['media/' . $name]->isFile() || $archive['media/' . $name]->getSize() !== $size) {
+ throw new RuntimeException('备份资源不完整:' . $name);
+ }
+ $staged[$name] = $stage . '/' . $name;
+ $source = fopen('phar://' . $path . '/media/' . $name, 'rb');
+ if ($source === false) {
+ throw new RuntimeException('不能读取备份资源。');
+ }
+ try {
+ $destination = fopen($staged[$name], 'xb');
+ if ($destination === false) {
+ throw new RuntimeException('不能暂存备份资源。');
+ }
+ try {
+ $written = stream_copy_to_stream($source, $destination, $size + 1);
+ } finally {
+ fclose($destination);
+ }
+ } finally {
+ fclose($source);
+ }
+ if ($written !== $size || !hash_equals($files[$name], hash_file('sha256', $staged[$name]))) {
+ throw new RuntimeException('备份资源校验失败:' . $name);
+ }
+ Media::validateBackup($staged[$name], $name, $asset['mime'] ?? '', $size);
+ }
+ Database::write(function (PDO $pdo) use ($tables, $staged, $directory, &$installed): void {
+ self::replaceTables($pdo, $tables);
+ foreach ($staged as $name => $source) {
+ $target = $directory . '/' . $name;
+ if (is_file($target) && !is_link($target) && hash_file('sha256', $target) === hash_file('sha256', $source)) {
+ continue;
+ }
+ if (file_exists($target) || is_link($target) || !link($source, $target)) {
+ throw new RuntimeException('资源名称冲突:' . $name);
+ }
+ $installed[] = $target;
+ }
+ });
+ } catch (Throwable $error) {
+ foreach ($installed as $file) {
+ unlink($file);
+ }
+ throw $error;
+ } finally {
+ foreach ($staged as $file) {
+ if (is_file($file)) {
+ unlink($file);
+ }
+ }
+ rmdir($stage);
+ }
+ }
+
+ private static function prepare(mixed $manifest): array
+ {
+ if (!is_array($manifest) || ($manifest['format'] ?? '') !== self::FORMAT
+ || !in_array($manifest['version'] ?? null, [1, self::VERSION], true) || !is_array($manifest['tables'] ?? null)) {
+ throw new RuntimeException('备份格式不受支持,请使用相同或更新版本的 LaySite。');
+ }
+ $tables = $manifest['tables'];
+ if ($manifest['version'] === 1) {
+ $tables += ['design_presets' => [], 'article_deletions' => []];
+ }
+ foreach (self::TABLES as $table) {
+ if (!is_array($tables[$table] ?? null) || !array_is_list($tables[$table])) {
+ throw new RuntimeException('备份数据表不完整。');
+ }
+ foreach ($tables[$table] as $row) {
+ if (!is_array($row) || array_is_list($row)) {
+ throw new RuntimeException('备份数据行格式无效。');
+ }
+ }
+ }
+ if (count($tables['site_settings']) !== 1 || !in_array('home', array_column($tables['pages'], 'slug'), true)) {
+ throw new RuntimeException('备份缺少站点身份或首页。');
+ }
+ $designs = [];
+ foreach ($tables['design_presets'] as &$row) {
+ $payload = self::decode($row['payload'] ?? '');
+ $row['payload'] = Database::json(DesignLibrary::normalize($row['kind'] ?? '', $row['preset'] ?? '', $payload));
+ $designs[$row['id']] = $row['kind'];
+ }
+ unset($row);
+ $settings = self::decode($tables['site_settings'][0]['payload'] ?? '');
+ if (!is_string($settings['name'] ?? null) || trim($settings['name']) === '' || mb_strlen($settings['name']) > 100) {
+ throw new RuntimeException('备份的站点名称无效。');
+ }
+ $site = ['name' => $settings['name'], 'cdn' => ['origin' => Assets::cdn($settings['cdn']['origin'] ?? '')], 'revisions' => ['general' => time()]];
+ foreach (['header', 'footer'] as $kind) {
+ if (isset($settings[$kind . '_id'])) {
+ $site[$kind . '_id'] = self::selection($designs, $kind, $settings[$kind . '_id']);
+ }
+ }
+ $tables['site_settings'] = [['id' => 1, 'payload' => Database::json($site)]];
+ foreach ($tables['pages'] as &$row) {
+ PageDraft::slug($row['slug'] ?? null, ['admin', 'assets', 'account', 'mcp', 'palette', 'favicon']);
+ self::validateAssetUrl($row['image'] ?? '', true);
+ $row['actions'] = Database::json(Buttons::validate(self::decode($row['actions'] ?? '[]')));
+ $row['quicklinks'] = Database::json(Buttons::validate(self::decode($row['quicklinks'] ?? '[]'), 20));
+ $row['visibility'] = Database::json(array_intersect_key(self::decode($row['visibility'] ?? '{}'), array_flip(['header', 'hero', 'footer'])));
+ $row['alignments'] = Database::json(self::decode($row['alignments'] ?? '{}'));
+ if (($row['theme'] ?? '') !== '' && !isset(PageTemplates::groups()[$row['theme']])) {
+ $row['theme'] = '';
+ }
+ foreach (['header', 'footer', 'palette'] as $kind) {
+ $row[$kind . '_id'] = self::selection($designs, $kind, $row[$kind . '_id'] ?? null);
+ }
+ }
+ unset($row);
+ foreach ($tables['sections'] as &$row) {
+ PageDraft::slug($row['key'] ?? null, ['home', 'contact', 'main-content', 'primary-navigation', 'preview']);
+ if (!in_array($row['style'] ?? '', ['plain', 'tinted', 'hero-links'], true)) {
+ throw new RuntimeException('备份包含未知区块样式。');
+ }
+ $row['body'] = Html::sanitize($row['body'] ?? '');
+ if (isset($row['feed'])) {
+ $feed = self::decode($row['feed']);
+ if (!in_array($feed['mode'] ?? '', ['merged', 'tabs', 'network', 'catalog'], true)
+ || !is_array($feed['categories'] ?? null) || !array_is_list($feed['categories'])
+ || array_diff($feed['categories'], array_column($tables['article_categories'], 'slug'))
+ || !is_int($feed['limit'] ?? null) || $feed['limit'] < 1 || $feed['limit'] > 30) {
+ throw new RuntimeException('备份的动态区块配置无效。');
+ }
+ }
+ }
+ unset($row);
+ foreach ($tables['articles'] as &$row) {
+ if (($row['body_format'] ?? '') === 'html') {
+ $row['body'] = Html::sanitize($row['body'] ?? '');
+ }
+ $card = self::decode($row['card'] ?? '{}');
+ foreach (['url', 'extra_url', 'image'] as $field) {
+ self::validateAssetUrl($card[$field] ?? '', $field === 'image');
+ }
+ $row['tags'] = Database::json(self::decode($row['tags'] ?? '[]'));
+ }
+ unset($row);
+
+ return $tables;
+ }
+
+ private static function replaceTables(PDO $pdo, array $tables): void
+ {
+ $revisions = [];
+ foreach (self::TABLES as $table) {
+ $columns = array_column($pdo->query('PRAGMA table_info(' . $table . ')')->fetchAll(), 'name');
+ $revisions[$table] = in_array('version', $columns, true) ? max(1, (int) $pdo->query('SELECT MAX(version) FROM ' . $table)->fetchColumn() + 1) : 0;
+ }
+ foreach (array_reverse(self::TABLES) as $table) {
+ $pdo->exec('DELETE FROM ' . $table);
+ }
+ foreach (self::TABLES as $table) {
+ $columns = array_column($pdo->query('PRAGMA table_info(' . $table . ')')->fetchAll(), 'name');
+ foreach ($tables[$table] as $row) {
+ $row = array_intersect_key($row, array_flip($columns));
+ if ($revisions[$table]) {
+ $row['version'] = $revisions[$table];
+ }
+ if (!$row) {
+ throw new RuntimeException('备份缺少必要的数据列。');
+ }
+ $keys = array_keys($row);
+ $query = $pdo->prepare('INSERT INTO ' . $table . ' ("' . implode('","', $keys) . '") VALUES (' . implode(',', array_fill(0, count($row), '?')) . ')');
+ $query->execute(array_values($row));
+ }
+ }
+ }
+
+ private static function selection(array $designs, string $kind, mixed $id): ?int
+ {
+ if ($id === null) {
+ return null;
+ }
+ if (!is_int($id) || ($designs[$id] ?? '') !== $kind) {
+ throw new RuntimeException('备份引用了缺失的设计方案。');
+ }
+ return $id;
+ }
+
+ private static function decode(mixed $value): array
+ {
+ $data = is_string($value) ? json_decode($value, true, 32, JSON_THROW_ON_ERROR) : null;
+ if (!is_array($data)) {
+ throw new RuntimeException('备份中的配置格式无效。');
+ }
+ return $data;
+ }
+
+ private static function validateAssetUrl(mixed $url, bool $media): void
+ {
+ if (!is_string($url) || ($url !== '' && !Html::url($url, $media))) {
+ throw new RuntimeException('备份含有无效的资源地址。');
+ }
+ }
+
+ private static function mediaName(mixed $name): string
+ {
+ if (!is_string($name) || !preg_match('/^[a-f0-9]{32}\.[a-z0-9]+$/D', $name)) {
+ throw new RuntimeException('备份含有无效的资源名称。');
+ }
+ return $name;
+ }
+}
diff --git a/app/Content/SiteDesign.php b/app/Content/SiteDesign.php
new file mode 100644
index 0000000..c519090
--- /dev/null
+++ b/app/Content/SiteDesign.php
@@ -0,0 +1,47 @@
+ 70 || strlen($url) > 1000 || !Html::url($url) || count($links) >= 20) {
+ throw new RuntimeException('每行填写「文案 | 链接」,最多 20 条。');
+ }
+ $links[] = [$url, $label];
+ }
+
+ return $links;
+ }
+
+ public static function linkText(array $links): string
+ {
+ return implode("\n", array_map(static fn (array $link): string => $link[1] . ' | ' . $link[0], $links));
+ }
+
+ public static function saveGeneral(string $name, string $origin, int $version): void
+ {
+ Database::write(function (PDO $pdo) use ($name, $origin, $version): void {
+ $site = json_decode((string) $pdo->query('SELECT payload FROM site_settings WHERE id = 1')->fetchColumn(), true, flags: JSON_THROW_ON_ERROR);
+ if (($site['revisions']['general'] ?? 0) !== $version) {
+ throw new RuntimeException('站点设置已更新,请重新打开后再保存。');
+ }
+ $site['name'] = $name;
+ $site['cdn'] = ['origin' => $origin];
+ $site['revisions']['general'] = $version + 1;
+ $pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
+ });
+ }
+}
diff --git a/app/Content/View.php b/app/Content/View.php
new file mode 100644
index 0000000..90abdff
--- /dev/null
+++ b/app/Content/View.php
@@ -0,0 +1,108 @@
+ $html]), $cdn);
+ $assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
+ $articleEditor = $admin && !empty($data['articleEditor']);
+ $editorImages = $articleEditor ? ' data:' : '';
+ $editorStyles = $articleEditor ? "style-src-attr 'unsafe-inline'; " : '';
+ $headers = [
+ 'Content-Type' => 'text/html; charset=utf-8',
+ 'X-Content-Type-Options' => 'nosniff',
+ 'Referrer-Policy' => 'strict-origin-when-cross-origin',
+ 'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
+ 'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:$editorImages; media-src 'self' https:; "
+ . "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'",
+ ];
+ if ($admin || !empty($data['previewMode'])) {
+ $headers['Cache-Control'] = 'no-store';
+ $headers['X-Robots-Tag'] = 'noindex, nofollow';
+ } elseif (($data['noindex'] ?? false) || $status >= 400) {
+ $headers['X-Robots-Tag'] = 'noindex';
+ }
+
+ if ($personalized) {
+ $headers['Cache-Control'] = 'private, no-store';
+ $headers['Vary'] = 'Cookie';
+ }
+ return new Response($status, $headers, $page);
+ }
+
+ public static function fragment(string $template, array $data = []): string
+ {
+ extract($data, EXTR_SKIP);
+ ob_start();
+ try {
+ require dirname(__DIR__) . '/view/' . $template . '.php';
+
+ return (string) ob_get_contents();
+ } finally {
+ ob_end_clean();
+ }
+ }
+
+ public static function escape(string|int|null $value): string
+ {
+ return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
+ }
+
+ public static function absolute(string $path): string
+ {
+ return rtrim(getenv('LAYSITE_SITE_URL') ?: 'http://127.0.0.1:8787', '/') . $path;
+ }
+
+ public static function date(?string $value, string $format = 'Y年n月j日'): string
+ {
+ 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
+ {
+ return new Response($status, ['Location' => $path, 'Cache-Control' => $status === 301 ? 'public, max-age=300' : 'no-store'], '');
+ }
+}
diff --git a/app/Controller/AccountController.php b/app/Controller/AccountController.php
new file mode 100644
index 0000000..3db9d14
--- /dev/null
+++ b/app/Controller/AccountController.php
@@ -0,0 +1,110 @@
+provider((int) $id);
+ if ($config === []) {
+ return $this->page($request, '该用户区尚未配置登录。', 404);
+ }
+ try {
+ $provider = new IdentityProvider($config);
+ $nonce = bin2hex(random_bytes(32));
+ $url = $provider->authorization($nonce);
+ $session = VisitorSession::create();
+ $session->set('flow', [
+ 'layout' => (int) $id, 'config' => $this->fingerprint($config), 'nonce' => $nonce,
+ 'state' => $provider->client->getState(), 'proof' => $provider->client->getPkceCode(), 'expires' => time() + 600,
+ ]);
+ $session->save();
+ return VisitorSession::cookie(View::redirect($url), $session, 600);
+ } catch (Throwable $error) {
+ error_log('LaySite account login: ' . get_class($error));
+ return $this->page($request, '无法连接身份服务,请联系站点管理员。', 502);
+ }
+ }
+
+ public function callback(Request $request): Response
+ {
+ $session = VisitorSession::open($request);
+ $flow = $session?->get('flow');
+ $state = $request->get('state');
+ $code = $request->get('code');
+ if (!is_array($flow) || $flow['expires'] < time() || !is_string($state) || !hash_equals($flow['state'], $state)
+ || !is_string($code) || $code === '' || strlen($code) > 4096) {
+ return $this->page($request, '登录请求已过期或未完成,请重新登录。', 400);
+ }
+ $session->flush();
+ $session->save();
+ try {
+ $config = $this->provider($flow['layout']);
+ if (!$config || $this->fingerprint($config) !== $flow['config']) {
+ return $this->page($request, '登录配置已变更,请重新登录。', 409);
+ }
+ $profile = (new IdentityProvider($config))->profile($code, $flow['proof'], $flow['nonce']);
+ $current = VisitorSession::create();
+ $current->set('profile', $profile + [
+ 'layout' => $flow['layout'], 'config' => $flow['config'], 'expires' => time() + 28800, 'logout' => bin2hex(random_bytes(32)),
+ ]);
+ $current->save();
+ return VisitorSession::cookie(View::redirect('/account'), $current, 28800);
+ } catch (Throwable $error) {
+ error_log('LaySite account callback: ' . get_class($error));
+ return $this->page($request, '身份验证失败,请重新登录。', 502);
+ }
+ }
+
+ public function index(Request $request): Response
+ {
+ return $this->page($request);
+ }
+
+ public function logout(Request $request): Response
+ {
+ $profile = VisitorSession::profile($request);
+ $token = $request->post('token');
+ if (!$profile || !is_string($token) || !hash_equals($profile['logout'], $token)) {
+ return $this->page($request, '退出请求已过期。', 403);
+ }
+ $session = VisitorSession::open($request);
+ $session->flush();
+ $session->save();
+
+ return VisitorSession::cookie(View::redirect('/'), null, 0);
+ }
+
+ private function page(Request $request, string $error = '', int $status = 200): Response
+ {
+ return View::render('account', [
+ 'site' => (new Repository())->site(), 'title' => '用户中心', 'description' => '', 'path' => '/account',
+ 'error' => $error, 'profile' => VisitorSession::profile($request), 'noindex' => true,
+ ], $status)->withHeader('Cache-Control', 'private, no-store');
+ }
+
+ private function provider(int $id): array
+ {
+ $row = DesignLibrary::find($id, 'header');
+
+ return ($row['preset'] ?? '') === 'member' && in_array('account', $row['payload']['components'], true)
+ ? $row['payload']['provider'] : [];
+ }
+
+ private function fingerprint(array $config): string
+ {
+ return hash('sha256', json_encode($config, JSON_THROW_ON_ERROR));
+ }
+}
diff --git a/app/Controller/AdminController.php b/app/Controller/AdminController.php
new file mode 100644
index 0000000..3e1f7b7
--- /dev/null
+++ b/app/Controller/AdminController.php
@@ -0,0 +1,662 @@
+signedIn($request)) {
+ return $this->success($request, '/admin');
+ }
+
+ $data = ['title' => '登录内容管理', 'error' => '', 'email' => ''];
+ if ($request->method() !== 'POST') {
+ return $this->render($request, 'admin-login', $data);
+ }
+
+ $data['email'] = strtolower($this->input($request, 'email'));
+ if (!$this->validToken($request)) {
+ $data['error'] = '登录表单已更新,请重新提交。若反复出现此提示,请确认浏览器允许本站 Cookie。';
+
+ return $this->render($request, 'admin-login', $data, 403);
+ }
+
+ $password = $this->input($request, 'password', trimValue: false);
+ $repo = new Repository();
+ $user = strlen($data['email']) <= 254 ? $repo->administrator($data['email']) : null;
+ $hash = $user['password_hash'] ?? '$2y$12$XGNKW.dBbfpUrZT8MYvWquCW1dBN3fIlVb29tlaoFIge3YDWG0AzG';
+ if (Passwords::isSupported($password) && password_verify($password, $hash) && $user) {
+ $this->openSession($request, $user);
+
+ return $this->success($request, '/admin');
+ }
+
+ $retryAfter = $repo->recordFailedLogin($request->clientAddress());
+ if ($retryAfter > 0) {
+ $data['error'] = '当前来源的密码验证失败次数过多,请核对密码或稍后再试。';
+
+ return $this->render($request, 'admin-login', $data, 429)->withHeader('Retry-After', (string) $retryAfter);
+ }
+
+ $data['error'] = '邮箱或密码有误。';
+
+ return $this->render($request, 'admin-login', $data, 422);
+ }
+
+ public function logout(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $request->session()->flush();
+ $request->session()->save();
+ $request->sessionRegenerateId(true);
+
+ return $this->success($request, '/admin/login');
+ }
+
+ public function password(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+
+ $error = '';
+ if ($request->method() === 'POST') {
+ $current = $this->input($request, 'current_password', trimValue: false);
+ $password = $this->input($request, 'new_password', trimValue: false);
+ $confirmation = $this->input($request, 'confirm_password', trimValue: false);
+ if (!Passwords::isSupported($current) || !password_verify($current, $this->user['password_hash'])) {
+ $error = '当前密码有误。';
+ } elseif (!Passwords::isValidNew($password)) {
+ $error = '新密码至少 8 个字符,最多 72 字节。';
+ } elseif ($password !== $confirmation) {
+ $error = '两次输入的新密码不一致。';
+ } else {
+ try {
+ $newHash = password_hash($password, PASSWORD_DEFAULT);
+ if (!(new Repository())->changePassword($this->user, $newHash)) {
+ throw new RuntimeException('密码已在其他会话中更新,请重新登录。');
+ }
+ $this->openSession($request, array_replace($this->user, ['password_hash' => $newHash]));
+
+ return $this->success($request, '/admin/password?saved=1');
+ } catch (RuntimeException $exception) {
+ $error = $this->validationMessage($exception);
+ }
+ }
+ }
+
+ return $this->render($request, 'admin-password', [
+ 'title' => '修改密码', 'error' => $error, 'saved' => $request->get('saved') === '1',
+ ], $error !== '' ? 422 : 200);
+ }
+
+ public function dashboard(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $repo = new Repository();
+
+ return $this->render($request, 'admin-dashboard', [
+ 'title' => '内容管理', 'pages' => $repo->pages(), 'articles' => $repo->articles(public: false, limit: 5),
+ 'pageTemplateDrawer' => true,
+ ]);
+ }
+
+ public function articles(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $page = max(1, min(10000, (int) $request->get('page', 1)));
+ $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', [
+ '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
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $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) : [
+ 'title' => '', 'slug' => '', 'summary' => '', 'body' => '', 'body_format' => 'markdown',
+ 'categories' => [$preset => $categories[$preset]], 'card' => [], 'tags' => [], 'status' => 'draft', 'version' => 0,
+ ];
+ if (!$article) {
+ return $this->error($request, '找不到这篇文章。', 404);
+ }
+ $error = '';
+ if ($request->method() === 'POST') {
+ $data = $this->articleInput($request);
+ $article = array_replace($article, $data, [
+ 'categories' => array_intersect_key($categories, array_flip($data['categories'])),
+ 'version' => $this->version($request),
+ ]);
+ try {
+ 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
+ || mb_strlen($data['summary']) > 250 || strlen($data['body']) > 200000
+ || $data['categories'] === [] || array_diff($data['categories'], array_keys($categories))
+ || !in_array($data['body_format'], ['markdown', 'html'], true)
+ || !in_array($data['status'], ['draft', 'published'], true)) {
+ throw new RuntimeException('请检查标题、网址标识、分类、摘要和正文长度。');
+ }
+ $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('发布前请填写文章正文。');
+ }
+ $saved = $repo->saveArticle($id === null ? null : (int) $id, $data, $this->version($request));
+
+ return $this->success($request, '/admin/articles/' . $saved . '?saved=1');
+ } catch (RuntimeException $exception) {
+ $error = $this->validationMessage($exception);
+ }
+ }
+
+ return $this->render($request, 'admin-article', [
+ 'title' => $id === null ? '新建文章' : '编辑文章', 'article' => $article, 'error' => $error,
+ 'articleId' => $id, 'categories' => $categories, 'articleEditor' => true, 'saved' => $request->get('saved') === '1',
+ ], $error !== '' ? 422 : 200);
+ }
+
+ public function deleteArticle(Request $request, string $id): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+
+ try {
+ (new Repository())->deleteArticle((int) $id, $this->version($request));
+ } catch (RuntimeException $exception) {
+ return $this->error($request, $this->validationMessage($exception), $exception instanceof \PDOException ? 500 : 409);
+ }
+
+ return $this->success($request, '/admin/articles?deleted=1');
+ }
+
+ public function page(Request $request, string $slug): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $repo = new Repository();
+ $page = $repo->page($slug);
+ if (!$page) {
+ return $this->error($request, '找不到此页面。', 404);
+ }
+ $error = '';
+ if ($request->method() === 'POST') {
+ $data = [];
+ foreach (['title', 'description', 'heading', 'accent', 'lead', 'image', 'alt'] as $field) {
+ $data[$field] = $this->input($request, $field);
+ }
+ $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');
+ $scale = $this->input($request, 'image_scale');
+ $data['image_scale'] = $request->post('image_scale') === null ? (int) $page['image_scale']
+ : (ctype_digit($scale) ? (int) $scale : -1);
+ $page = array_replace($page, $data, ['version' => $this->version($request)]);
+ try {
+ $data['actions'] = $request->post('hero_actions') === null ? $page['actions']
+ : Buttons::validate(json_decode($this->input($request, 'hero_actions'), true));
+ foreach (['header', 'footer', 'palette'] as $kind) {
+ $key = $kind . '_id';
+ $data[$key] = $request->post($key) === null ? $page[$key] : DesignLibrary::selection($kind, $request->post($key));
+ }
+ $page = array_replace($page, $data);
+ $data['visibility'] = $page['visibility'];
+ foreach (['hero', 'header', 'footer'] as $area) {
+ $value = $request->post('show_' . $area);
+ if ($value === null) {
+ continue;
+ }
+ if (!in_array($value, ['0', '1'], true)) {
+ throw new RuntimeException('页面显示选项不正确。');
+ }
+ $data['visibility'][$area] = $value === '1';
+ }
+ $page['visibility'] = $data['visibility'];
+ $data['alignments'] = $request->post('alignments') === null ? $page['alignments']
+ : $this->alignmentMap(json_decode($this->input($request, 'alignments'), true), ['heading', 'lead', 'actions', 'image']);
+ $page['alignments'] = $data['alignments'];
+ $data['quicklinks'] = $request->post('quicklinks') === null ? $page['quicklinks'] : SiteDesign::parseLinks($this->input($request, 'quicklinks'));
+ if ($data['name'] === '' || mb_strlen($data['name']) > 100 || !in_array($data['status'], ['draft', 'published'], true)
+ || $data['title'] === '' || mb_strlen($data['title']) > 160 ||
+ ($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
+ (($data['visibility']['hero'] ?? true) && $data['heading'] === '') || mb_strlen($data['heading'] . $data['accent']) > 110 ||
+ mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
+ ($data['image_scale'] !== 0 && ($data['image_scale'] < 10 || $data['image_scale'] > 100)) ||
+ strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true))) {
+ throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
+ }
+ $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');
+ } catch (RuntimeException $exception) {
+ $error = $this->validationMessage($exception);
+ }
+ }
+
+ return $this->render($request, 'admin-page', [
+ 'title' => '编辑 ' . $page['name'], 'page' => $page, 'categories' => $repo->categories(), 'wideAdmin' => true, 'error' => $error, 'saved' => $request->get('saved') === '1',
+ 'pageTemplateDrawer' => true, 'designs' => DesignLibrary::all(),
+ ], $error !== '' ? 422 : 200);
+ }
+
+ public function section(Request $request, string $slug, string $key): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $repo = new Repository();
+ $section = $repo->section($slug, $key);
+ if (!$section) {
+ return $this->error($request, '找不到此区块。', 404);
+ }
+ $savedStyle = $section['style'];
+ $categories = $repo->categories();
+ $error = '';
+ if ($request->method() === 'POST') {
+ $data = [
+ 'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
+ 'body' => $this->input($request, 'body'),
+ 'style' => $savedStyle === 'hero-links' || $request->post('style') === null ? $savedStyle : $this->input($request, 'style'),
+ 'feed' => $section['feed'],
+ ];
+ $section = array_replace($section, $data, ['version' => $this->version($request)]);
+ try {
+ if ($savedStyle !== 'hero-links' && $request->post('feed_mode') !== null) {
+ $data['feed'] = $section['feed'] = $this->feedInput($request, $categories);
+ }
+ $this->checkSection($data, $savedStyle);
+ $data['body'] = Html::sanitize($data['body']);
+ $repo->saveSection($slug, $key, $data, $this->version($request));
+
+ return $this->success($request, '/admin/pages/' . $slug . '/' . $key . '?saved=1');
+ } catch (RuntimeException $exception) {
+ $error = $this->validationMessage($exception);
+ }
+ }
+
+ return $this->render($request, 'admin-section', [
+ 'title' => '编辑区块', 'section' => $section, 'categories' => $categories, 'savedStyle' => $savedStyle, 'error' => $error, 'saved' => $request->get('saved') === '1',
+ ], $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) {
+ 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
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $body = $this->input($request, 'body');
+ if (strlen($body) > 300000) {
+ return $this->error($request, '正文太长。', 413);
+ }
+ $html = $this->input($request, 'format') === 'html' ? Html::sanitize($body) : Html::markdown($body);
+
+ return new Response(200, [
+ 'Content-Type' => 'text/html; charset=utf-8', 'Cache-Control' => 'no-store', 'X-Robots-Tag' => 'noindex, nofollow',
+ 'Content-Security-Policy' => "default-src 'none'; frame-ancestors 'none'; sandbox",
+ ], $html);
+ }
+
+ protected function guard(Request $request): ?Response
+ {
+ if (!$this->signedIn($request)) {
+ return $request->isAjax()
+ ? $this->json(['message' => '登录已过期。请在新标签页重新登录,再返回继续编辑。'], 401)
+ : View::redirect('/admin/login');
+ }
+ if ($request->method() === 'POST' && !$this->validToken($request)) {
+ return $this->error($request, '表单凭证已更新,请重新提交。', 403);
+ }
+
+ return null;
+ }
+
+ private function signedIn(Request $request): bool
+ {
+ $session = $request->session();
+ $id = $session->get('admin_id');
+ if (!is_int($id) || (int) $session->get('admin_since') < time() - 8 * 60 * 60) {
+ return false;
+ }
+ $user = (new Repository())->administratorById($id);
+ if (!$user || !hash_equals(hash('sha256', $user['password_hash']), (string) $session->get('auth_version'))) {
+ $session->flush();
+ $session->save();
+
+ return false;
+ }
+ $this->user = $user;
+
+ return true;
+ }
+
+ private function openSession(Request $request, array $user): void
+ {
+ $request->sessionRegenerateId(true);
+ $session = $request->session();
+ $session->flush();
+ $session->put([
+ 'admin_id' => $user['id'],
+ 'auth_version' => hash('sha256', $user['password_hash']),
+ 'admin_since' => time(),
+ ]);
+ $this->token($request);
+ }
+
+ private function token(Request $request): string
+ {
+ $session = $request->session();
+ $token = $session->get('csrf');
+ if (!is_string($token)) {
+ $token = bin2hex(random_bytes(32));
+ $session->set('csrf', $token);
+ $session->save();
+ }
+
+ return $token;
+ }
+
+ private function validToken(Request $request): bool
+ {
+ $token = $request->session()->get('csrf');
+
+ return is_string($token) && hash_equals($token, $this->input($request, 'csrf'));
+ }
+
+ protected function input(Request $request, string $key, bool $trimValue = true): string
+ {
+ $value = $request->post($key, '');
+ if (!is_string($value) || !mb_check_encoding($value, 'UTF-8')) {
+ return '';
+ }
+
+ return $trimValue ? trim($value) : $value;
+ }
+
+ protected function version(Request $request): int
+ {
+ $version = $this->input($request, 'version');
+
+ return ctype_digit($version) ? (int) $version : -1;
+ }
+
+ private function articleInput(Request $request): array
+ {
+ $data = [];
+ foreach (['title', 'slug', 'summary', 'body', 'status'] as $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'));
+ $data['tags'] = array_values(array_unique(array_slice(array_filter(
+ array_map('trim', $tags),
+ static fn (string $tag): bool => $tag !== '' && mb_strlen($tag) <= 80 && !str_contains($tag, '/'),
+ ), 0, 12)));
+
+ 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
+ {
+ if ($exception instanceof \PDOException) {
+ error_log($exception->getMessage());
+
+ return '保存失败,请稍后重试。';
+ }
+
+ return $exception->getMessage();
+ }
+
+ protected function success(Request $request, string $path): Response
+ {
+ return $request->isAjax() ? $this->json(['redirect' => $path]) : View::redirect($path);
+ }
+
+ protected function json(array $payload, int $status = 200): Response
+ {
+ return new Response($status, [
+ 'Content-Type' => 'application/json; charset=utf-8',
+ 'Cache-Control' => 'no-store',
+ 'X-Content-Type-Options' => 'nosniff',
+ 'X-Robots-Tag' => 'noindex, nofollow',
+ ], Database::json($payload));
+ }
+
+ protected function render(Request $request, string $view, array $data, int $status = 200): Response
+ {
+ $token = $this->token($request);
+ if ($request->isAjax() && $status >= 400) {
+ return $this->json([
+ 'message' => $data['error'] ?? $data['title'],
+ ...($status === 403 ? ['csrf' => $token] : []),
+ ], $status);
+ }
+
+ 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
+ {
+ return $this->render($request, 'admin-error', ['title' => $message], $status);
+ }
+}
diff --git a/app/Controller/BackupController.php b/app/Controller/BackupController.php
new file mode 100644
index 0000000..6bd6444
--- /dev/null
+++ b/app/Controller/BackupController.php
@@ -0,0 +1,78 @@
+guard($request)) {
+ return $failure;
+ }
+ $error = '';
+ if ($request->method() === 'POST') {
+ $path = null;
+ try {
+ $file = $request->file('backup');
+ if ($request->post('replace') !== '1' || !$file instanceof \Webman\Http\UploadFile || !$file->isValid()) {
+ throw new RuntimeException('请选择备份文件并确认覆盖站点内容。');
+ }
+ $path = $this->temporary();
+ if (!copy($file->getPathname(), $path)) {
+ throw new RuntimeException('不能暂存备份文件。');
+ }
+ SiteBackup::import($path);
+ return $this->success($request, '/admin/backup?restored=1');
+ } catch (Throwable $ex) {
+ $error = $ex instanceof RuntimeException && !$ex instanceof \PDOException
+ ? $ex->getMessage() : '备份无法导入。请检查文件格式或服务器日志。';
+ } finally {
+ if ($path && is_file($path)) {
+ unlink($path);
+ }
+ }
+ }
+ return $this->render($request, 'admin-backup', [
+ 'title' => '站点备份', 'error' => $error, 'restored' => $request->get('restored') === '1',
+ ], $error === '' ? 200 : 422);
+ }
+
+ public function export(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ try {
+ $path = $this->temporary();
+ SiteBackup::export($path);
+ Timer::add(600, static function () use ($path): void {
+ if (is_file($path)) {
+ unlink($path);
+ }
+ }, [], false);
+ return (new Response(200, ['Content-Type' => 'application/x-tar', 'Cache-Control' => 'no-store',
+ 'X-Content-Type-Options' => 'nosniff', 'Content-Disposition' => 'attachment; filename="laysite-' . gmdate('Ymd-His') . '.tar"']))->withFile($path);
+ } catch (Throwable $ex) {
+ return $this->error($request, '无法创建站点备份,请检查文件权限和媒体文件。', 500);
+ }
+ }
+
+ private function temporary(): string
+ {
+ $directory = runtime_path('backups');
+ if (!is_dir($directory) && !mkdir($directory, 0700, true) && !is_dir($directory)) {
+ throw new RuntimeException('不能创建临时备份目录。');
+ }
+
+ return $directory . '/' . bin2hex(random_bytes(20)) . '.tar';
+ }
+}
diff --git a/app/Controller/DesignController.php b/app/Controller/DesignController.php
new file mode 100644
index 0000000..e58ffa3
--- /dev/null
+++ b/app/Controller/DesignController.php
@@ -0,0 +1,149 @@
+guard($request)) {
+ return $failure;
+ }
+
+ return $this->render($request, 'admin-design', [
+ 'title' => '站点设计', 'items' => DesignLibrary::all(), 'site' => (new Repository())->site(),
+ ]);
+ }
+
+ public function edit(Request $request, string $kind, string $key): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $id = $key === 'new' ? null : (int) $key;
+ $item = $id === null ? [
+ 'name' => '', 'preset' => array_key_first(DesignLibrary::PRESETS[$kind]),
+ 'payload' => DesignLibrary::defaults($kind), 'version' => 0,
+ ] : DesignLibrary::find($id, $kind);
+ if (!$item) {
+ return $this->error($request, '找不到这项设计配置。', 404);
+ }
+ $error = '';
+ $default = $id !== null && ((new Repository())->site()[$kind . '_id'] ?? null) === $id;
+ if ($request->method() === 'POST') {
+ try {
+ $item['name'] = $this->input($request, 'name');
+ $item['preset'] = $this->input($request, 'preset');
+ if ($kind === 'palette') {
+ foreach (DesignLibrary::COLORS as $color => $definition) {
+ $item['payload'][$color] = $this->input($request, $color);
+ }
+ } else {
+ $url = $this->input($request, 'action_url');
+ $label = $this->input($request, 'action_label');
+ $item['payload'] = [
+ 'components' => $request->post('components', []),
+ 'brand' => $this->input($request, 'brand'), 'logo' => $this->input($request, 'logo'),
+ 'text' => $this->input($request, 'text'), 'legal' => $this->input($request, 'legal'),
+ 'links' => SiteDesign::parseLinks($this->input($request, 'links')),
+ 'action' => $url === '' && $label === '' ? [] : [[$url, $label, $this->input($request, 'action_style'), $request->post('action_blank') === '1']],
+ 'provider' => [],
+ ];
+ foreach (['mode', 'issuer', 'authorization', 'token', 'userinfo', 'client_id', 'secret_env', 'scope', 'subject_field', 'name_field', 'avatar_field', 'token_auth'] as $field) {
+ $item['payload']['provider'][$field] = $this->input($request, 'provider_' . $field);
+ }
+ }
+ $default = $request->post('make_default') === '1';
+ $id = DesignLibrary::save($kind, $id, $item['name'], $item['preset'], $item['payload'], $this->version($request), $default);
+
+ return $this->success($request, "/admin/design/$kind/$id?saved=1");
+ } catch (RuntimeException $ex) {
+ $error = $this->validationMessage($ex);
+ $item['payload'] = DesignLibrary::defaults($kind);
+ }
+ }
+
+ return $this->render($request, 'admin-design-edit', [
+ 'title' => '设计配置', 'kind' => $kind, 'key' => $key, 'item' => $item, 'default' => $default,
+ 'error' => $error, 'saved' => $request->get('saved') === '1',
+ ], $error === '' ? 200 : 422);
+ }
+
+ public function site(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $site = (new Repository())->site();
+ $error = '';
+ $name = $site['name'];
+ $cdn = $site['cdn']['origin'] ?? '';
+ $version = (int) ($site['revisions']['general'] ?? 0);
+ if ($request->method() === 'POST') {
+ try {
+ $name = $this->input($request, 'name');
+ $cdn = Assets::cdn($this->input($request, 'cdn'));
+ if ($name === '' || mb_strlen($name) > 100) {
+ throw new RuntimeException('站点名称必须为 1 至 100 个字符。');
+ }
+ SiteDesign::saveGeneral($name, $cdn, $this->version($request));
+
+ return $this->success($request, '/admin/settings?saved=1');
+ } catch (RuntimeException $ex) {
+ $error = $this->validationMessage($ex);
+ }
+ }
+
+ return $this->render($request, 'studio-settings', [
+ 'title' => '站点设置', 'name' => $name, 'cdn' => $cdn, 'version' => $version, 'error' => $error,
+ 'saved' => $request->get('saved') === '1',
+ ], $error === '' ? 200 : 422);
+ }
+
+ public function preview(Request $request, string $kind, string $id): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ if (!DesignLibrary::find((int) $id, $kind)) {
+ return $this->error($request, '找不到这项设计配置。', 404);
+ }
+ $repo = new Repository();
+ $page = $repo->page('home');
+ $page[$kind . '_id'] = (int) $id;
+ if ($kind !== 'palette') {
+ $page['visibility'][$kind] = true;
+ }
+
+ return (new SiteController())->renderPage($repo, $page, true);
+ }
+
+ public function palette(Request $request, string $id): Response
+ {
+ $palette = DesignLibrary::find((int) $id, 'palette');
+ if (!$palette) {
+ return new Response(404);
+ }
+ $declarations = [];
+ foreach ($palette['payload'] as $variable => $value) {
+ $declarations[] = '--' . $variable . ':' . $value;
+ }
+
+ return new Response(200, [
+ 'Content-Type' => 'text/css; charset=utf-8', 'Cache-Control' => 'public, max-age=60',
+ 'X-Content-Type-Options' => 'nosniff',
+ ], ':root, #main-content.page-theme {' . implode(';', $declarations) . '} .page-theme .hero, .hero-home {background:var(--paper)}'
+ . ' #main-content .button-primary, #main-content .button-primary:hover {color:var(--button-ink);background:var(--accent)}');
+ }
+}
diff --git a/app/Controller/McpController.php b/app/Controller/McpController.php
new file mode 100644
index 0000000..927a02d
--- /dev/null
+++ b/app/Controller/McpController.php
@@ -0,0 +1,216 @@
+header('origin');
+ if ($origin !== null && $origin !== '' && $origin !== rtrim(View::absolute(''), '/')) {
+ return new Response(403, ['Cache-Control' => 'no-store']);
+ }
+ $secret = getenv('LAYSITE_MCP_TOKEN');
+ $header = $request->header('authorization', '');
+ if (!is_string($secret) || strlen($secret) < 32 || !is_string($header) || !hash_equals('Bearer ' . $secret, $header)) {
+ return new Response(401, ['WWW-Authenticate' => 'Bearer realm="LaySite MCP"', 'Cache-Control' => 'no-store']);
+ }
+ if ($request->method() !== 'POST') {
+ return new Response(405, ['Allow' => 'POST', 'Cache-Control' => 'no-store']);
+ }
+ if (!preg_match('~^application/json(?:\s*;|$)~i', $request->header('content-type', ''))) {
+ return new Response(415, ['Cache-Control' => 'no-store']);
+ }
+ $protocol = $request->header('mcp-protocol-version');
+ if ($protocol !== null && $protocol !== '' && !in_array($protocol, self::PROTOCOLS, true)) {
+ return new Response(400, ['Cache-Control' => 'no-store']);
+ }
+ $body = $request->rawBody();
+ if (strlen($body) > 1048576) {
+ return new Response(413, ['Cache-Control' => 'no-store']);
+ }
+ $message = json_decode($body, true, 48);
+ if (json_last_error() !== JSON_ERROR_NONE) {
+ return $this->error(null, -32700, 'Invalid JSON');
+ }
+ $id = $message['id'] ?? null;
+ $method = $message['method'] ?? null;
+ if (!is_array($message) || ($message['jsonrpc'] ?? '') !== '2.0' || !is_string($method)
+ || (array_key_exists('id', $message) && !is_int($id) && !is_string($id))) {
+ return $this->error(null, -32600, 'Invalid request');
+ }
+ if (!array_key_exists('id', $message)) {
+ return new Response(202, ['Cache-Control' => 'no-store']);
+ }
+ $params = $message['params'] ?? [];
+ if (!is_array($params)) {
+ return $this->error($id, -32602, 'Invalid params');
+ }
+
+ return match ($method) {
+ 'initialize' => $this->result($id, [
+ 'protocolVersion' => in_array($params['protocolVersion'] ?? null, self::PROTOCOLS, true) ? $params['protocolVersion'] : self::PROTOCOLS[0],
+ 'capabilities' => ['tools' => (object) []], 'serverInfo' => ['name' => 'laysite', 'version' => trim(file_get_contents(dirname(__DIR__, 2) . '/VERSION'))],
+ 'instructions' => 'Create or revise draft pages. A human can open the editor URL to review, refine and publish.',
+ ]),
+ 'ping' => $this->result($id, (object) []),
+ 'tools/list' => $this->result($id, ['tools' => $this->tools()]),
+ 'tools/call' => $this->invoke($id, $params),
+ default => $this->error($id, -32601, 'Method not found'),
+ };
+ }
+
+ private function tools(): array
+ {
+ $string = ['type' => 'string'];
+ $object = static fn (array $properties, array $required = []): array => [
+ 'type' => 'object', 'properties' => (object) $properties, 'required' => $required, 'additionalProperties' => false,
+ ];
+ $optional = [
+ 'name' => $string, 'title' => $string, 'heading' => $string, 'description' => $string, 'lead' => $string,
+ 'accent' => $string, 'image' => $string, 'alt' => $string,
+ 'header_id' => ['type' => ['integer', 'null']], 'footer_id' => ['type' => ['integer', 'null']], 'palette_id' => ['type' => ['integer', 'null']],
+ 'visibility' => $object(['hero' => ['type' => 'boolean'], 'header' => ['type' => 'boolean'], 'footer' => ['type' => 'boolean']]),
+ 'actions' => ['type' => 'array', 'maxItems' => 8, 'items' => ['type' => 'array', 'description' => '[URL, label, style, boolean opensNewTab]. Style: solid, outline, underline, plain.']],
+ 'sections' => ['type' => 'array', 'maxItems' => 50, 'items' => $object([
+ 'key' => $string, 'title' => $string, 'lead' => $string, 'body' => $string,
+ 'style' => ['enum' => ['plain', 'tinted']], 'preset' => $string,
+ ], ['key'])],
+ ];
+ $definitions = [
+ 'list_pages' => ['List pages and their current revisions.', $object([])],
+ 'get_page' => ['Read a page and its editable sections.', $object(['slug' => $string], ['slug'])],
+ 'list_templates' => ['List whole-page templates and reusable components.', $object([])],
+ 'list_designs' => ['List saved header, footer and palette IDs. Authentication settings are private.', $object([])],
+ 'create_draft' => ['Create a draft from content or a template. Returns the editor URL.', $object(['slug' => $string, 'template' => $string] + $optional, ['slug', 'name'])],
+ 'save_draft' => ['Save a draft at the supplied version. A supplied sections array replaces the section list. Omitted fields are preserved.',
+ $object(['slug' => $string, 'version' => ['type' => 'integer', 'minimum' => 0]] + $optional, ['slug', 'version'])],
+ ];
+
+ $tools = [];
+ foreach ($definitions as $name => [$description, $inputSchema]) {
+ $tools[] = compact('name', 'description', 'inputSchema');
+ }
+ return $tools;
+ }
+
+ private function invoke(int|string $id, array $params): Response
+ {
+ $name = $params['name'] ?? null;
+ $args = $params['arguments'] ?? [];
+ if (!is_string($name) || !is_array($args)) {
+ return $this->error($id, -32602, 'Invalid tool call');
+ }
+ $repo = new Repository();
+ try {
+ $data = match ($name) {
+ 'list_pages' => $repo->pages(),
+ 'get_page' => $this->read($repo, PageDraft::slug($args['slug'] ?? null, [])),
+ 'list_templates' => $this->templates(),
+ 'list_designs' => DesignLibrary::all(),
+ 'create_draft' => $this->create($repo, $args),
+ 'save_draft' => $this->save($repo, $args),
+ default => throw new RuntimeException('Unknown tool'),
+ };
+ return $this->result($id, ['content' => [['type' => 'text', 'text' => Database::json($data)]]]);
+ } catch (RuntimeException $error) {
+ $message = $error instanceof PDOException ? 'Could not save the requested change.' : $error->getMessage();
+ return $this->result($id, ['isError' => true, 'content' => [['type' => 'text', 'text' => $message]]]);
+ }
+ }
+
+ private function read(Repository $repo, string $slug): array
+ {
+ $page = $repo->page($slug);
+ if (!$page) {
+ throw new RuntimeException('页面不存在。');
+ }
+ return $page;
+ }
+
+ private function create(Repository $repo, array $args): array
+ {
+ $slug = PageDraft::slug($args['slug'] ?? null);
+ $key = $args['template'] ?? '';
+ $template = $key === '' ? [] : (is_string($key) ? PageTemplates::find($key) : null);
+ if ($template === null) {
+ throw new RuntimeException('整页模板不存在。');
+ }
+ if (!isset($args['name'])) {
+ throw new RuntimeException('请填写页面名称。');
+ }
+ $page = PageDraft::content($args, $template);
+ $repo->createPage($slug, $page['name'], $page);
+
+ return $this->summary($repo, $slug);
+ }
+
+ private function save(Repository $repo, array $args): array
+ {
+ $slug = PageDraft::slug($args['slug'] ?? null);
+ $page = $this->read($repo, $slug);
+ $version = $args['version'] ?? null;
+ if ($page['status'] !== 'draft' || !is_int($version) || $version !== $page['version']) {
+ throw new RuntimeException('只能编辑匹配当前版本的草稿。请重新读取页面。');
+ }
+ $page = PageDraft::content($args, $page);
+ $replace = array_key_exists('sections', $args);
+ $repo->savePage($slug, $page, $version, $replace ? $page['sections'] : [], replaceDraftSections: $replace);
+
+ return $this->summary($repo, $slug);
+ }
+
+ private function summary(Repository $repo, string $slug): array
+ {
+ return ['slug' => $slug, 'version' => $this->read($repo, $slug)['version'],
+ 'editor' => View::absolute('/admin/pages/' . $slug), 'preview' => View::absolute('/admin/pages/' . $slug . '/preview')];
+ }
+
+ private function templates(): array
+ {
+ $pages = [];
+ foreach (PageTemplates::groups() as $theme => $group) {
+ foreach ($group['pages'] as $key => $page) {
+ $pages[$key] = ['name' => $page['name'], 'theme' => $theme, 'description' => $page['description']];
+ }
+ }
+ $blocks = [];
+ foreach (BlockTemplates::groups() as [, $group]) {
+ foreach ($group as $key => $block) {
+ $blocks[$key] = $block[0];
+ }
+ }
+ return compact('pages', 'blocks');
+ }
+
+ private function error(int|string|null $id, int $code, string $message): Response
+ {
+ return $this->json(['jsonrpc' => '2.0', 'id' => $id, 'error' => compact('code', 'message')]);
+ }
+
+ private function result(int|string $id, array|object $result): Response
+ {
+ return $this->json(['jsonrpc' => '2.0', 'id' => $id, 'result' => $result]);
+ }
+
+ private function json(array $payload): Response
+ {
+ return new Response(200, ['Content-Type' => 'application/json', 'Cache-Control' => 'no-store', 'X-Content-Type-Options' => 'nosniff'], Database::json($payload));
+ }
+}
diff --git a/app/Controller/MediaController.php b/app/Controller/MediaController.php
new file mode 100644
index 0000000..0ebb7c4
--- /dev/null
+++ b/app/Controller/MediaController.php
@@ -0,0 +1,45 @@
+ $media['mime'], 'X-Content-Type-Options' => 'nosniff',
+ 'Content-Security-Policy' => "default-src 'none'; sandbox",
+ 'Cache-Control' => 'public, max-age=31536000, immutable',
+ 'Access-Control-Allow-Origin' => '*', 'Accept-Ranges' => 'bytes',
+ ];
+ $range = $request->header('range');
+ if ($range === null) {
+ return (new Response(200, $headers + ['Content-Length' => (string) $length]))->withFile($path);
+ }
+ if (!preg_match('/^bytes=(\d*)-(\d*)$/D', $range, $parts) || $parts[1] === '' && $parts[2] === '') {
+ return new Response(416, $headers + ['Content-Range' => "bytes */$length"]);
+ }
+ $start = $parts[1] === '' ? max(0, $length - (int) $parts[2]) : (int) $parts[1];
+ $end = $parts[1] === '' || $parts[2] === '' ? $length - 1 : min($length - 1, (int) $parts[2]);
+ if ($end < $start) {
+ return new Response(416, $headers + ['Content-Range' => "bytes */$length"]);
+ }
+ $count = $end - $start + 1;
+
+ return (new Response(206, $headers + ['Content-Length' => (string) $count, 'Content-Range' => "bytes $start-$end/$length"]))
+ ->withFile($path, $start, $count);
+ }
+}
diff --git a/app/Controller/SiteController.php b/app/Controller/SiteController.php
new file mode 100644
index 0000000..88f335e
--- /dev/null
+++ b/app/Controller/SiteController.php
@@ -0,0 +1,245 @@
+page($request, 'home');
+ }
+
+ public function page(Request $request, string $slug): Response
+ {
+ $repo = new Repository();
+ $page = $repo->page($slug);
+ if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') {
+ return $this->missing($request);
+ }
+ if ($slug === 'articles' && $request->get('page') !== null) {
+ foreach ($page['sections'] as $section) {
+ $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
+ if (in_array($feed['mode'] ?? null, ['merged', 'tabs'], true)) {
+ return $this->feedArchive($request, $slug, $section['key']);
+ }
+ }
+
+ return $this->missing($request);
+ }
+ return $this->renderPage($repo, $page);
+ }
+
+ public function renderPage(Repository $repo, array $page, bool $preview = false, bool $canvas = false): Response
+ {
+ $slug = $page['slug'];
+ $isHome = $slug === 'home';
+ $showHero = $page['visibility']['hero'] ?? true;
+ $categories = $repo->categories();
+ foreach ($page['sections'] as &$section) {
+ if (!$section['feed']) {
+ continue;
+ }
+ $feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
+ $network = $feed['mode'] === 'network';
+ $catalog = $feed['mode'] === 'catalog';
+ $grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1);
+ $archivePath = '/articles/feed/' . $slug . '/' . $section['key'];
+ $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', [
+ 'site' => $repo->site(),
+ 'page' => $page,
+ 'path' => $isHome ? '/' : '/' . $slug,
+ 'title' => $page['title'],
+ 'description' => $page['description'],
+ 'socialImage' => $showHero ? $page['image'] : '',
+ 'socialAlt' => $showHero ? $page['alt'] : '',
+ 'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
+ ]);
+ }
+
+ public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
+ {
+ $repo = new Repository();
+ $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) : ''));
+
+ $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');
+ if (!is_scalar($number) || !preg_match('/^[1-9][0-9]{0,4}$/D', (string) $number)) {
+ return $this->missing($request);
+ }
+ $page = (int) $number;
+ $articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20, directoryOrder: $view['catalog'] ?? false);
+ if ($page > 1 && $articles === []) {
+ return $this->missing($request);
+ }
+ $path = $view['archivePath'];
+
+ return View::render('archive', $view + [
+ 'site' => $repo->site(), 'title' => $view['headline'],
+ 'path' => $page > 1 ? View::archivePage($path, $page) : $path,
+ 'pageNumber' => $page, 'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
+ 'noindex' => $articles === [],
+ ]);
+ }
+
+ public function tagged(Request $request, string $tag): Response
+ {
+ $tag = rawurldecode($tag);
+ if (mb_strlen($tag) > 80 || $tag === '') {
+ return $this->missing($request);
+ }
+
+ return $this->archive($request, tag: $tag);
+ }
+
+ public function article(Request $request, string $slug): Response
+ {
+ $repo = new Repository();
+ $article = $repo->published($slug);
+ if (!$article) {
+ $redirect = $repo->articleRedirect($slug);
+
+ return $redirect ? View::redirect('/articles/' . $redirect['slug'], 301) : $this->missing($request);
+ }
+ $articleHtml = Html::articleBody($article);
+
+ return View::render('article', [
+ 'site' => $repo->site(), 'article' => $article, 'articleHtml' => $articleHtml,
+ 'title' => $article['title'],
+ 'description' => $article['summary'] ?: mb_substr(trim(strip_tags($articleHtml)), 0, 150) ?: $article['title'],
+ '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']),
+ ]);
+ }
+
+ public function sitemap(Request $request): Response
+ {
+ $repo = new Repository();
+ $xml = ['', ''];
+ $pages = $repo->pages(publishedOnly: true);
+ foreach ($pages as $page) {
+ $xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']);
+ }
+ foreach ($repo->sitemapArticles() as $article) {
+ $xml[] = $this->sitemapUrl('/articles/' . $article['slug'], $article['updated_at']);
+ }
+ $xml[] = '';
+
+ return new Response(200, ['Content-Type' => 'application/xml; charset=utf-8'], implode("\n", $xml) . "\n");
+ }
+
+ public function robots(Request $request): Response
+ {
+ return new Response(200, ['Content-Type' => 'text/plain; charset=utf-8'],
+ "User-agent: *\nAllow: /\nDisallow: /admin\nSitemap: " . View::absolute('/sitemap.xml') . "\n");
+ }
+
+ public function missing(Request $request): Response
+ {
+ $path = $request->path();
+ if ($request->method() === 'GET' && strlen($path) > 1 && str_ends_with($path, '/')) {
+ $normal = rtrim($path, '/');
+ $single = preg_match('~^/[a-z0-9-]+$~D', $normal);
+ $known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
+ if ($known || preg_match('~^/articles(?:/[a-z0-9-]+){1,2}$~D', $normal)) {
+ $query = $request->queryString();
+
+ return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
+ }
+ }
+
+ return View::render('missing', [
+ 'site' => (new Repository())->site(), 'title' => '页面未找到', 'description' => '',
+ 'path' => null, 'noindex' => true,
+ ], 404);
+ }
+
+ private function sitemapUrl(string $path, ?string $updated): string
+ {
+ $url = htmlspecialchars(View::absolute($path), ENT_XML1 | ENT_QUOTES, 'UTF-8');
+ $date = $updated ? '' . View::date($updated, 'Y-m-d') . '' : '';
+
+ return ' ' . $url . '' . $date . '';
+ }
+}
diff --git a/app/Controller/StudioController.php b/app/Controller/StudioController.php
new file mode 100644
index 0000000..0eebfd5
--- /dev/null
+++ b/app/Controller/StudioController.php
@@ -0,0 +1,171 @@
+guard($request)) {
+ return $failure;
+ }
+ $data = [
+ 'title' => '新建页面', 'name' => '', 'slug' => '', 'error' => '', 'pageTemplateDrawer' => true,
+ 'openTemplates' => $request->get('templates') === '1',
+ ];
+ if ($request->method() === 'POST') {
+ $data['name'] = $this->input($request, 'name');
+ $data['slug'] = $this->input($request, 'slug');
+ try {
+ if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'home', 'account', 'mcp', 'palette', 'favicon'], true)
+ || $data['name'] === '' || mb_strlen($data['name']) > 100) {
+ throw new RuntimeException('请填写页面名称及可用的网址标识。');
+ }
+ $key = $this->input($request, 'template');
+ $template = $key === '' ? [] : PageTemplates::find($key);
+ if ($template === null) {
+ throw new RuntimeException('找不到所选整页模板。');
+ }
+ $template['title'] = $data['name'];
+ (new Repository())->createPage($data['slug'], $data['name'], $template);
+
+ return $this->success($request, '/admin/pages/' . $data['slug']);
+ } catch (RuntimeException $error) {
+ $data['error'] = $this->validationMessage($error);
+ }
+ }
+
+ return $this->render($request, 'studio-new-page', $data, $data['error'] === '' ? 200 : 422);
+ }
+
+ public function previewTemplate(Request $request, string $key): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $template = PageTemplates::find($key);
+
+ return $template ? (new SiteController())->renderPage(new Repository(), $template, true)
+ : $this->error($request, '找不到所选整页模板。', 404);
+ }
+
+ public function previewPage(Request $request, string $slug): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $repo = new Repository();
+ $page = $repo->page($slug);
+
+ return $page ? (new SiteController())->renderPage($repo, $page, true, $request->get('canvas') === '1') : $this->error($request, '找不到此页面。', 404);
+ }
+
+ public function blocks(Request $request, string $slug): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $repo = new Repository();
+ if (!$repo->page($slug)) {
+ return $this->error($request, '找不到此页面。', 404);
+ }
+ $action = $this->input($request, 'operation');
+ $key = $this->input($request, 'key');
+ try {
+ if (!$this->slug($key) || in_array($key, ['preview', 'home', 'contact', 'main-content', 'partners', 'supported-projects'], true)) {
+ throw new RuntimeException('区块锚点不可用。');
+ }
+ if ($action === 'create') {
+ $type = $this->input($request, 'preset');
+ $preset = BlockTemplates::find($type);
+ if ($preset === null) {
+ throw new RuntimeException('请选择区块类型。');
+ }
+ $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");
+ }
+ if (!in_array($action, ['up', 'down', 'delete'], true)) {
+ throw new RuntimeException('操作不可用。');
+ }
+ $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");
+ } catch (RuntimeException $error) {
+ return $this->error($request, $this->validationMessage($error), 422);
+ }
+ }
+
+ public function media(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $error = '';
+ if ($request->method() === 'POST') {
+ try {
+ $file = $request->file('file');
+ if (!$file instanceof UploadFile || !$file->isValid()) {
+ throw new RuntimeException('请选择要上传的文件。');
+ }
+ $label = $this->input($request, 'label') ?: mb_substr((string) $file->getUploadName(), 0, 160);
+ if (mb_strlen($label) > 160) {
+ throw new RuntimeException('资源名称最多 160 个字符。');
+ }
+ Media::upload($file, $label);
+
+ return $this->success($request, '/admin/media?uploaded=1');
+ } catch (RuntimeException $exception) {
+ $error = $this->validationMessage($exception);
+ }
+ }
+
+ return $this->render($request, 'studio-media', [
+ 'title' => '媒体库', 'files' => Media::all(true), 'error' => $error, 'saved' => $request->get('uploaded') === '1',
+ ], $error === '' ? 200 : 422);
+ }
+
+ public function mediaOptions(Request $request): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+
+ return $this->json(['files' => Media::all()]);
+ }
+
+ public function mediaMeta(Request $request, string $name): Response
+ {
+ if ($failure = $this->guard($request)) {
+ return $failure;
+ }
+ $label = $this->input($request, 'label');
+ if (!Media::find($name)) {
+ return $this->error($request, '找不到此资源。', 404);
+ }
+ if ($label === '' || mb_strlen($label) > 160) {
+ return $this->error($request, '请输入资源名称,最多 160 个字符。', 422);
+ }
+ Media::update($name, $label, $this->input($request, 'archived') === '1');
+
+ return $this->success($request, '/admin/media');
+ }
+
+ private function slug(string $value): bool
+ {
+ return strlen($value) <= 70 && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value) === 1;
+ }
+}
diff --git a/app/Http/Request.php b/app/Http/Request.php
new file mode 100644
index 0000000..050decb
--- /dev/null
+++ b/app/Http/Request.php
@@ -0,0 +1,29 @@
+getRemoteIp();
+ $forwarded = $this->header('x-real-ip', '');
+ if (!$this->fromTrustedProxy() || !filter_var($forwarded, FILTER_VALIDATE_IP)) {
+ return $peer;
+ }
+
+ return inet_ntop(inet_pton($forwarded));
+ }
+
+ private function fromTrustedProxy(): bool
+ {
+ $configured = getenv('LAYSITE_TRUSTED_PROXIES');
+ $trusted = $configured === false ? self::LOOPBACK : array_map('trim', explode(',', $configured));
+
+ return in_array($this->getRemoteIp(), $trusted, true);
+ }
+}
diff --git a/app/Http/VisitorSession.php b/app/Http/VisitorSession.php
new file mode 100644
index 0000000..07222cc
--- /dev/null
+++ b/app/Http/VisitorSession.php
@@ -0,0 +1,38 @@
+cookie(self::COOKIE);
+ return is_string($id) && preg_match('/^visitor-[a-f0-9]{64}$/D', $id) ? new Session($id) : null;
+ }
+
+ public static function create(): Session
+ {
+ return new Session('visitor-' . bin2hex(random_bytes(32)));
+ }
+
+ public static function cookie(Response $response, ?Session $session, int $seconds): Response
+ {
+ return $response->cookie(self::COOKIE, $session?->getId() ?? '', $seconds, '/',
+ secure: getenv('LAYSITE_SECURE_COOKIES') === '1', httpOnly: true, sameSite: 'Lax');
+ }
+
+ public static function profile(?Request $request): ?array
+ {
+ $profile = self::open($request)?->get('profile');
+
+ return is_array($profile) && ($profile['expires'] ?? 0) > time() ? $profile : null;
+ }
+}
diff --git a/app/Middleware/PublicAssets.php b/app/Middleware/PublicAssets.php
new file mode 100644
index 0000000..5ea2d2d
--- /dev/null
+++ b/app/Middleware/PublicAssets.php
@@ -0,0 +1,26 @@
+path();
+ if (str_starts_with($path, '/assets/')) {
+ $response->withHeader('Access-Control-Allow-Origin', '*');
+ if ($path === '/assets/jquery-4.0.0.min.js') {
+ $response->withHeader('Cache-Control', 'public, max-age=31536000, immutable');
+ }
+ }
+
+ return $response;
+ }
+}
diff --git a/app/view/account.php b/app/view/account.php
new file mode 100644
index 0000000..5a68f45
--- /dev/null
+++ b/app/view/account.php
@@ -0,0 +1,14 @@
+
+
+
用户中心
+
= $e($error) ?>
+
+
 ?>)
+
= $e($profile['name']) ?>
+
+
请从站点页头登录。
+
返回首页
+
diff --git a/app/view/admin-article-categories.php b/app/view/admin-article-categories.php
new file mode 100644
index 0000000..fe11bb6
--- /dev/null
+++ b/app/view/admin-article-categories.php
@@ -0,0 +1,21 @@
+
+返回文章列表
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
+
diff --git a/app/view/admin-article-list.php b/app/view/admin-article-list.php
new file mode 100644
index 0000000..ea53853
--- /dev/null
+++ b/app/view/admin-article-list.php
@@ -0,0 +1,19 @@
+
+
+
+
+ 暂无文章。
+
diff --git a/app/view/admin-article.php b/app/view/admin-article.php
new file mode 100644
index 0000000..1d00a00
--- /dev/null
+++ b/app/view/admin-article.php
@@ -0,0 +1,64 @@
+
+返回文章列表
+
+ = $e($title) ?>
+
+ 查看公开页面
+
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
+
+
+ 删除文章
+
+
+
diff --git a/app/view/admin-articles.php b/app/view/admin-articles.php
new file mode 100644
index 0000000..f314cd7
--- /dev/null
+++ b/app/view/admin-articles.php
@@ -0,0 +1,31 @@
+
+
+文章已删除。
+
+
+ = View::fragment('admin-article-list', ['articles' => $articles]) ?>
+
+ 1 || $hasNext): ?>
+
+
diff --git a/app/view/admin-backup.php b/app/view/admin-backup.php
new file mode 100644
index 0000000..bb0b981
--- /dev/null
+++ b/app/view/admin-backup.php
@@ -0,0 +1,15 @@
+
+返回站点设计
+
+站点已还原。
+= View::fragment('admin-feedback', ['error' => $error, 'saved' => false]) ?>
+
diff --git a/app/view/admin-brand.php b/app/view/admin-brand.php
new file mode 100644
index 0000000..7718a61
--- /dev/null
+++ b/app/view/admin-brand.php
@@ -0,0 +1,4 @@
+
+
+
+LaySite
diff --git a/app/view/admin-category-checkboxes.php b/app/view/admin-category-checkboxes.php
new file mode 100644
index 0000000..208f97d
--- /dev/null
+++ b/app/view/admin-category-checkboxes.php
@@ -0,0 +1,14 @@
+
+
diff --git a/app/view/admin-dashboard.php b/app/view/admin-dashboard.php
new file mode 100644
index 0000000..cbc5f6c
--- /dev/null
+++ b/app/view/admin-dashboard.php
@@ -0,0 +1,61 @@
+ $page['status'] === 'published'));
+?>
+
+
+
+
+
网站页面
+
= $live ?> 个已发布 · = count($pages) - $live ?> 个草稿
+
+
+
+
+
+ >= $pages ? '没有匹配的页面。' : '暂无页面。' ?>
+
+
+
+ -
+
= $e($page['name']) ?>= $e($path) ?>
+ = $published ? '已发布' : '草稿' ?>
+
+
+
+
+
+
+
+ 最近编辑的文章
+ = View::fragment('admin-article-list', ['articles' => $articles]) ?>
+ 管理全部文章
+
+
+
+
+= View::fragment('studio-page-templates', compact('token')) ?>
diff --git a/app/view/admin-design-edit.php b/app/view/admin-design-edit.php
new file mode 100644
index 0000000..bfd100a
--- /dev/null
+++ b/app/view/admin-design-edit.php
@@ -0,0 +1,83 @@
+
+返回站点设计
+
+ = $e(['header' => '页头组件', 'footer' => '页脚组件', 'palette' => '配色方案'][$kind]) ?>
+ 预览已保存的配置
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
diff --git a/app/view/admin-design.php b/app/view/admin-design.php
new file mode 100644
index 0000000..966893b
--- /dev/null
+++ b/app/view/admin-design.php
@@ -0,0 +1,23 @@
+
+
+
+ '页头', 'footer' => '页脚', 'palette' => '配色方案'] as $kind => $label): ?>
+
+
+ $item['kind'] === $kind); ?>
+ 暂无自定义配置。
+
+
+ - = $e($item['name']) ?>
+ 站点默认
+ 编辑
+
+
+
+
+
+
diff --git a/app/view/admin-editor.php b/app/view/admin-editor.php
new file mode 100644
index 0000000..5e39b67
--- /dev/null
+++ b/app/view/admin-editor.php
@@ -0,0 +1,32 @@
+
+
+
+
+
+
= Html::sanitize($body) ?>
+
+
+
+
+
可以直接编辑文字,插入链接、图片、音视频。复杂区块可切换到 HTML 源码调整。
+
+
+
diff --git a/app/view/admin-error.php b/app/view/admin-error.php
new file mode 100644
index 0000000..7c12341
--- /dev/null
+++ b/app/view/admin-error.php
@@ -0,0 +1,2 @@
+= App\Content\View::escape($title) ?>
+返回内容管理
diff --git a/app/view/admin-feedback.php b/app/view/admin-feedback.php
new file mode 100644
index 0000000..62097b3
--- /dev/null
+++ b/app/view/admin-feedback.php
@@ -0,0 +1,3 @@
+
+= View::escape($error) ?>
+已保存。
diff --git a/app/view/admin-layout.php b/app/view/admin-layout.php
new file mode 100644
index 0000000..4c1ab63
--- /dev/null
+++ b/app/view/admin-layout.php
@@ -0,0 +1,78 @@
+ 'articles',
+ str_starts_with($adminPath, '/admin/media') => 'media',
+ str_starts_with($adminPath, '/admin/settings') || str_starts_with($adminPath, '/admin/design') || str_starts_with($adminPath, '/admin/backup') => 'settings',
+ $adminPath === '/admin/password' => '',
+ default => 'pages',
+};
+?>
+
+
+
+
+
+
+
+ = $e($title) ?> CMS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+跳到内容
+
+= $content ?>
+
+
+
+
+
diff --git a/app/view/admin-login.php b/app/view/admin-login.php
new file mode 100644
index 0000000..0b86101
--- /dev/null
+++ b/app/view/admin-login.php
@@ -0,0 +1,17 @@
+
+
+
登录内容管理
+
管理网站页面、媒体和文章。
+
= $e($error) ?>
+
+
忘记密码时,可请服务器管理员通过命令行重设。
+
diff --git a/app/view/admin-page.php b/app/view/admin-page.php
new file mode 100644
index 0000000..da3325b
--- /dev/null
+++ b/app/view/admin-page.php
@@ -0,0 +1,173 @@
+
+返回页面
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
+
+
+
+
+= View::fragment('studio-page-templates', compact('token')) ?>
diff --git a/app/view/admin-password.php b/app/view/admin-password.php
new file mode 100644
index 0000000..19d6ff0
--- /dev/null
+++ b/app/view/admin-password.php
@@ -0,0 +1,14 @@
+
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
diff --git a/app/view/admin-section.php b/app/view/admin-section.php
new file mode 100644
index 0000000..1bac8dd
--- /dev/null
+++ b/app/view/admin-section.php
@@ -0,0 +1,33 @@
+
+返回页面编辑
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
diff --git a/app/view/archive.php b/app/view/archive.php
new file mode 100644
index 0000000..4b26d72
--- /dev/null
+++ b/app/view/archive.php
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+ = View::fragment('service-cards', ['products' => $articles]) ?>
+
+ = View::fragment('article-list', ['articles' => $articles, 'categoryScope' => $categoryScope ?? null]) ?>
+
+ 1 || $hasNext): ?>
+
+
+
+
diff --git a/app/view/article-feed.php b/app/view/article-feed.php
new file mode 100644
index 0000000..f10942e
--- /dev/null
+++ b/app/view/article-feed.php
@@ -0,0 +1,23 @@
+
+ 1 ? 'data-article-tabs' : '' ?>>
+ 1): ?>
+
+ $group): ?>
+
+
+
+
+ $group): ?>
+
+
= $e($group['label']) ?>
+ = View::fragment('article-list', ['articles' => $group['articles'], 'categoryScope' => $group['categories']]) ?>
+
+
+
+
查看全部动态
+
+
diff --git a/app/view/article-list.php b/app/view/article-list.php
new file mode 100644
index 0000000..8bde699
--- /dev/null
+++ b/app/view/article-list.php
@@ -0,0 +1,24 @@
+
+
+
+
+ 暂无已发布的动态。
+
diff --git a/app/view/article.php b/app/view/article.php
new file mode 100644
index 0000000..096c667
--- /dev/null
+++ b/app/view/article.php
@@ -0,0 +1,46 @@
+
+
+
+
+
全部动态
+
+
+
![<?= $e($card['alt'] ?? '') ?>](<?= $e($card['image']) ?>)
+
+
+
+ = $articleHtml ?>
+
+
此文章的原文暂不可用。
+
+
+
+
+
+
+
+
+
+
diff --git a/app/view/footer.php b/app/view/footer.php
new file mode 100644
index 0000000..19832b5
--- /dev/null
+++ b/app/view/footer.php
@@ -0,0 +1,26 @@
+
+
diff --git a/app/view/header.php b/app/view/header.php
new file mode 100644
index 0000000..06134ba
--- /dev/null
+++ b/app/view/header.php
@@ -0,0 +1,42 @@
+
+
diff --git a/app/view/layout.php b/app/view/layout.php
new file mode 100644
index 0000000..fbae993
--- /dev/null
+++ b/app/view/layout.php
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+ = $e($title) ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+跳到内容
+
+ = View::fragment('header', compact('header', 'site', 'showHeader', 'visitor', 'path')) ?>
+
+ tabindex="-1">= $content ?>
+
+ = View::fragment('footer', compact('footer', 'site', 'showFooter')) ?>
+
+
+
diff --git a/app/view/missing.php b/app/view/missing.php
new file mode 100644
index 0000000..8bd5597
--- /dev/null
+++ b/app/view/missing.php
@@ -0,0 +1,8 @@
+
+
+
404
+
页面未找到
+
请检查网址,或回到首页浏览产品与服务。
+
返回首页
+
+
diff --git a/app/view/network-items.php b/app/view/network-items.php
new file mode 100644
index 0000000..a99ed32
--- /dev/null
+++ b/app/view/network-items.php
@@ -0,0 +1,27 @@
+
+
diff --git a/app/view/page.php b/app/view/page.php
new file mode 100644
index 0000000..78e00ba
--- /dev/null
+++ b/app/view/page.php
@@ -0,0 +1,74 @@
+ $section['style'] === 'hero-links');
+$alignments = $page['alignments'];
+$alignField = static fn (string $name): string => $canvas ? ' data-studio-align-field="' . $name . '"' : '';
+$field = static fn (string $name): string => $canvas ? ' data-studio-field="' . $name . '"' : '';
+?>
+= $e($page['name']) ?>
+
+
+
+ = $showHero ? '' : ' hidden' ?>>
+
+
+
+
+
= $e($site['name']) ?>
+
+
= $alignField('heading') ?>>>= $e($page['heading']) ?>>= $e($page['accent']) ?>
= $e($page['accent']) ?>
+
= $alignField('lead') ?>>= $e($page['lead']) ?>
+
+
+
+
= $page['image'] === '' ? ' hidden' : '' ?>>
+
 . ')
alt="= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"= $canvas ? ' data-studio-hero-image' : '' ?>>
+
+
+
+
+
+ = View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
+
+
+
+
+
+
+
+
+ = View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
+
+
+
+ = View::fragment('section', [
+ 'section' => ['style' => 'plain', 'key' => 'new', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
+ 'moment' => false, 'canvas' => true,
+ ]) ?>
+
diff --git a/app/view/section.php b/app/view/section.php
new file mode 100644
index 0000000..0c6a28e
--- /dev/null
+++ b/app/view/section.php
@@ -0,0 +1,54 @@
+
+ >
+
= $e($section['title']) ?>= $e($section['lead']) ?>
+
>= $body ?>
+
+查看全部动态') {
+ $body = '';
+}
+$network = $section['networkFeed'] ?? false;
+$catalog = $section['catalogFeed'] ?? false;
+?>
+= $studio ?>>
+
+
+
= $canvas ? ' data-studio-part="title"' : '' ?>>= $e($section['title']) ?>
+
= $canvas ? ' data-studio-part="lead"' : '' ?>>= $e($section['lead']) ?>
+
+
+
+
+
+
= $e($group['label']) ?>
+ = View::fragment('network-items', ['articles' => $group['articles'], 'standalone' => false]) ?>
+
+
+
查看全部
+
+ = View::fragment('service-cards', ['products' => $section['articleFeed'][0]['articles']]) ?>
+ = $section['feedLimit']): ?>
+
查看全部
+
+
+ = View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key'], 'archivePath' => $section['archivePath']]) ?>
+
+
>= $body ?>
+
+
diff --git a/app/view/service-cards.php b/app/view/service-cards.php
new file mode 100644
index 0000000..b0a7982
--- /dev/null
+++ b/app/view/service-cards.php
@@ -0,0 +1,38 @@
+
+暂无可查看的产品和服务。
+
+
+
+
+
+
+
+
+
= $e($card['category_label']) ?>
+
+
+
= $e($product['summary']) ?>
+
+
= $body ?>
+
+
+
+
+
+
+
+
diff --git a/app/view/studio-anchor-form.php b/app/view/studio-anchor-form.php
new file mode 100644
index 0000000..ca0395f
--- /dev/null
+++ b/app/view/studio-anchor-form.php
@@ -0,0 +1,24 @@
+
+
+ 按锚点新建区块
+
+
diff --git a/app/view/studio-asset-field.php b/app/view/studio-asset-field.php
new file mode 100644
index 0000000..bd6f12e
--- /dev/null
+++ b/app/view/studio-asset-field.php
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/app/view/studio-feed-fields.php b/app/view/studio-feed-fields.php
new file mode 100644
index 0000000..7e172af
--- /dev/null
+++ b/app/view/studio-feed-fields.php
@@ -0,0 +1,15 @@
+ '不展示'] : []) + ['merged' => '合并列表', 'tabs' => '分类标签页', 'network' => '项目与伙伴卡片', 'catalog' => '产品与服务卡片'];
+?>
+
+
+
+
+= View::fragment('admin-category-checkboxes', ['name' => 'feed_categories', 'selected' => $feed['categories'] ?? [], 'categories' => $categories, 'legend' => '展示分类']) ?>
diff --git a/app/view/studio-icon.php b/app/view/studio-icon.php
new file mode 100644
index 0000000..06e8b10
--- /dev/null
+++ b/app/view/studio-icon.php
@@ -0,0 +1,12 @@
+ '',
+ 'center' => '',
+ 'right' => '',
+ 'settings' => '',
+ 'edit' => '',
+ 'copy' => '',
+ 'delete' => '',
+];
+?>
+
diff --git a/app/view/studio-layers.php b/app/view/studio-layers.php
new file mode 100644
index 0000000..b09e05b
--- /dev/null
+++ b/app/view/studio-layers.php
@@ -0,0 +1,30 @@
+
+
+ 区块顺序
+
+
diff --git a/app/view/studio-library-panel.php b/app/view/studio-library-panel.php
new file mode 100644
index 0000000..43fac43
--- /dev/null
+++ b/app/view/studio-library-panel.php
@@ -0,0 +1,63 @@
+
+
+
+ [$category, $items]): ?>
+
+
+
+ = $anchorForm ?>
+
+
+
+
+
+
+
+
+
+
没有匹配的= $modules ? '组件' : '元素' ?>。
+ [$category, $items]): ?>
+
+ $item): ?>
+
+
+
+
+
+ = $e($label) ?>
+
+
+ = $markup ?>
+
+
+
+
+ = $markup ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/view/studio-media.php b/app/view/studio-media.php
new file mode 100644
index 0000000..3d0a78c
--- /dev/null
+++ b/app/view/studio-media.php
@@ -0,0 +1,50 @@
+
+媒体库
统一查找并引用静态文件、图片、图标和音视频。
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
+
diff --git a/app/view/studio-new-page.php b/app/view/studio-new-page.php
new file mode 100644
index 0000000..9121394
--- /dev/null
+++ b/app/view/studio-new-page.php
@@ -0,0 +1,20 @@
+
+返回页面
+
+= View::fragment('admin-feedback', ['error' => $error, 'saved' => false]) ?>
+
+= View::fragment('studio-page-templates', compact('token', 'openTemplates')) ?>
diff --git a/app/view/studio-page-templates.php b/app/view/studio-page-templates.php
new file mode 100644
index 0000000..8c99adf
--- /dev/null
+++ b/app/view/studio-page-templates.php
@@ -0,0 +1,60 @@
+
+
diff --git a/app/view/studio-settings.php b/app/view/studio-settings.php
new file mode 100644
index 0000000..f26b104
--- /dev/null
+++ b/app/view/studio-settings.php
@@ -0,0 +1,15 @@
+
+返回站点设计
+
+= View::fragment('admin-feedback', compact('error', 'saved')) ?>
+
diff --git a/app/view/studio-templates.php b/app/view/studio-templates.php
new file mode 100644
index 0000000..b8de3f2
--- /dev/null
+++ b/app/view/studio-templates.php
@@ -0,0 +1,35 @@
+ '组件', 'elements' => '元素', 'layers' => '图层'];
+?>
+
+
+ $label): ?>
+
+
+
+ BlockTemplates::groups(), 'elements' => BlockTemplates::ELEMENT_GROUPS] as $kind => $groups): ?>
+ = View::fragment('studio-library-panel', compact('kind', 'groups', 'anchorForm')) ?>
+
+
+
+
+
![]()
+
+
+
+
diff --git a/bin/admin.php b/bin/admin.php
new file mode 100644
index 0000000..ec88692
--- /dev/null
+++ b/bin/admin.php
@@ -0,0 +1,52 @@
+administrator($email);
+ if (!$user || !$repo->changePassword($user, $hash)) {
+ fwrite(STDERR, "未能重设密码。请确认邮箱对应的账户存在,且未被同时修改。\n");
+ exit(1);
+ }
+ fwrite(STDOUT, "密码已重设,旧会话将失效。\n");
+ exit(0);
+}
+
+$query = Database::connect()->prepare('INSERT INTO users (email, password_hash) VALUES (?, ?)
+ ON CONFLICT (email) DO UPDATE SET password_hash = excluded.password_hash');
+$query->execute([$email, $hash]);
+fwrite(STDOUT, "管理员账户已就绪。\n");
diff --git a/bin/backup.php b/bin/backup.php
new file mode 100644
index 0000000..f7dc3f1
--- /dev/null
+++ b/bin/backup.php
@@ -0,0 +1,26 @@
+#!/usr/bin/env php
+getMessage() . PHP_EOL);
+ exit(1);
+}
diff --git a/bin/install.php b/bin/install.php
new file mode 100644
index 0000000..15aee30
--- /dev/null
+++ b/bin/install.php
@@ -0,0 +1,11 @@
+&2
+ exit 2
+fi
+if [ -n "$(git status --porcelain)" ]; then
+ printf '%s\n' 'Commit or set aside local source changes before updating.' >&2
+ exit 1
+fi
+
+git fetch origin --tags
+current=$(git rev-parse HEAD)
+next=$(git rev-parse --verify "refs/tags/$target^{commit}")
+git merge-base --is-ancestor "$current" "$next"
+"$php_bin" bin/backup.php export "$2"
+
+if git switch --detach "$next" &&
+ "$composer_bin" install --no-dev --prefer-dist --no-interaction --no-scripts &&
+ "$php_bin" bin/install.php
+then
+ printf 'Updated to %s. Start Webman with the original site environment.\n' "$target"
+else
+ git switch --detach "$current"
+ "$composer_bin" install --no-dev --prefer-dist --no-interaction --no-scripts
+ printf 'Update failed. The prior source version is checked out and the backup is at %s.\n' "$2" >&2
+ exit 1
+fi
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..4eedc5d
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,28 @@
+{
+ "name": "laysense/laysite",
+ "description": "LaySite visual editor and content management system",
+ "type": "project",
+ "require": {
+ "ext-curl": "*",
+ "ext-dom": "*",
+ "ext-fileinfo": "*",
+ "ext-mbstring": "*",
+ "ext-openssl": "*",
+ "ext-pdo_sqlite": "*",
+ "ext-phar": "*",
+ "firebase/php-jwt": "^7.0",
+ "league/commonmark": "^2.8",
+ "league/oauth2-client": "^2.8",
+ "monolog/monolog": "^3.0",
+ "php": "^8.2",
+ "workerman/webman-framework": "^2.2"
+ },
+ "autoload": {
+ "psr-4": {
+ "App\\": "app/"
+ }
+ },
+ "config": {
+ "sort-packages": true
+ }
+}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 0000000..cbfce59
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,1836 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "45db06869e345d093c2aa4f7825b56c9",
+ "packages": [
+ {
+ "name": "dflydev/dot-access-data",
+ "version": "v3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/dflydev/dflydev-dot-access-data.git",
+ "reference": "a23a2bf4f31d3518f3ecb38660c95715dfead60f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/dflydev/dflydev-dot-access-data/zipball/a23a2bf4f31d3518f3ecb38660c95715dfead60f",
+ "reference": "a23a2bf4f31d3518f3ecb38660c95715dfead60f",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.1 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^0.12.42",
+ "phpunit/phpunit": "^7.5 || ^8.5 || ^9.3",
+ "scrutinizer/ocular": "1.6.0",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^4.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Dflydev\\DotAccessData\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Dragonfly Development Inc.",
+ "email": "info@dflydev.com",
+ "homepage": "http://dflydev.com"
+ },
+ {
+ "name": "Beau Simensen",
+ "email": "beau@dflydev.com",
+ "homepage": "http://beausimensen.com"
+ },
+ {
+ "name": "Carlos Frutos",
+ "email": "carlos@kiwing.it",
+ "homepage": "https://github.com/cfrutos"
+ },
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com"
+ }
+ ],
+ "description": "Given a deep data structure, access data by dot notation.",
+ "homepage": "https://github.com/dflydev/dflydev-dot-access-data",
+ "keywords": [
+ "access",
+ "data",
+ "dot",
+ "notation"
+ ],
+ "support": {
+ "issues": "https://github.com/dflydev/dflydev-dot-access-data/issues",
+ "source": "https://github.com/dflydev/dflydev-dot-access-data/tree/v3.0.3"
+ },
+ "time": "2024-07-08T12:26:09+00:00",
+ "published-time": "2024-07-08T12:27:13+00:00"
+ },
+ {
+ "name": "firebase/php-jwt",
+ "version": "v7.2.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/googleapis/php-jwt.git",
+ "reference": "99efeb17d6def8c0295777f2d45b07ff4fdb4e40"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/googleapis/php-jwt/zipball/99efeb17d6def8c0295777f2d45b07ff4fdb4e40",
+ "reference": "99efeb17d6def8c0295777f2d45b07ff4fdb4e40",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^8.0"
+ },
+ "require-dev": {
+ "guzzlehttp/guzzle": "^7.4||^8.0",
+ "phpfastcache/phpfastcache": "^9.2",
+ "phpseclib/phpseclib": "~3.0",
+ "phpspec/prophecy-phpunit": "^2.2",
+ "phpunit/phpunit": "^9.5",
+ "psr/cache": "^2.0||^3.0",
+ "psr/http-client": "^1.0",
+ "psr/http-factory": "^1.0"
+ },
+ "suggest": {
+ "ext-sodium": "Support EdDSA (Ed25519) signatures",
+ "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present",
+ "phpseclib/phpseclib": "Support PS256 (RSASSA-PSS) signatures"
+ },
+ "type": "library",
+ "extra": {
+ "component": {
+ "id": "jwt",
+ "path": "Jwt",
+ "entry": "README.md",
+ "target": "googleapis/php-jwt.git"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Firebase\\JWT\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Neuman Vong",
+ "email": "neuman+pear@twilio.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Anant Narayanan",
+ "email": "anant@php.net",
+ "role": "Developer"
+ }
+ ],
+ "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
+ "homepage": "https://github.com/googleapis/php-jwt",
+ "keywords": [
+ "jwt",
+ "php"
+ ],
+ "support": {
+ "issues": "https://github.com/googleapis/php-jwt/issues",
+ "source": "https://github.com/googleapis/php-jwt/tree/v7.2.2"
+ },
+ "time": "2026-11-17T00:25:19+00:00",
+ "published-time": "2026-11-17T19:16:00+00:00"
+ },
+ {
+ "name": "guzzlehttp/guzzle",
+ "version": "8.5.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/guzzle.git",
+ "reference": "d1a26e6ce24268e740af501de8748d1c945e6f4b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d1a26e6ce24268e740af501de8748d1c945e6f4b",
+ "reference": "d1a26e6ce24268e740af501de8748d1c945e6f4b",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "guzzlehttp/promises": "^3.1.1",
+ "guzzlehttp/psr7": "^3.5.1",
+ "php": "^7.4 || ^8.0",
+ "psr/http-client": "^1.0",
+ "psr/http-factory": "^1.0",
+ "symfony/deprecation-contracts": "^2.5 || ^3.0",
+ "symfony/polyfill-php80": "^1.25",
+ "symfony/polyfill-php82": "^1.27"
+ },
+ "provide": {
+ "psr/http-client-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "ext-curl": "*",
+ "guzzle/client-integration-tests": "4.0.1",
+ "guzzlehttp/test-server": "^1.1",
+ "php-http/message-factory": "^1.1",
+ "phpunit/phpunit": "^9.6.34",
+ "psr/log": "^1.1 || ^2.0 || ^3.0"
+ },
+ "suggest": {
+ "ext-curl": "Required for CURL handler support",
+ "ext-intl": "Required for Internationalized Domain Name (IDN) support",
+ "psr/log": "Required for using the Log middleware"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Jeremy Lindblom",
+ "email": "jeremeamia@gmail.com",
+ "homepage": "https://github.com/jeremeamia"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle is a PHP HTTP client library",
+ "keywords": [
+ "client",
+ "curl",
+ "framework",
+ "http",
+ "http client",
+ "psr-18",
+ "psr-7",
+ "rest",
+ "web service"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/guzzle/issues",
+ "source": "https://github.com/guzzle/guzzle/tree/8.5.5"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-11-21T21:14:02+00:00",
+ "published-time": "2026-11-21T21:14:44+00:00"
+ },
+ {
+ "name": "guzzlehttp/promises",
+ "version": "3.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/promises.git",
+ "reference": "a201cc78db93065f891278f86eaeaa1c97c5a158"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/promises/zipball/a201cc78db93065f891278f86eaeaa1c97c5a158",
+ "reference": "a201cc78db93065f891278f86eaeaa1c97c5a158",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0",
+ "symfony/deprecation-contracts": "^2.5 || ^3.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "phpunit/phpunit": "^9.6.34"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Promise\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ }
+ ],
+ "description": "Guzzle promises library",
+ "keywords": [
+ "promise"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/promises/issues",
+ "source": "https://github.com/guzzle/promises/tree/3.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-11-21T03:48:02+00:00",
+ "published-time": "2026-11-21T03:48:27+00:00"
+ },
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "3.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "1fa0f8319c046b7dec80030460254283d851388e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/1fa0f8319c046b7dec80030460254283d851388e",
+ "reference": "1fa0f8319c046b7dec80030460254283d851388e",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0",
+ "psr/http-factory": "^1.1",
+ "psr/http-message": "^2.0",
+ "symfony/deprecation-contracts": "^2.5 || ^3.0",
+ "symfony/polyfill-php80": "^1.25",
+ "symfony/polyfill-php82": "^1.27"
+ },
+ "provide": {
+ "psr/http-factory-implementation": "1.1",
+ "psr/http-message-implementation": "2.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.2",
+ "http-interop/http-factory-tests": "1.1.0",
+ "jshttp/mime-db": "1.54.0.1",
+ "php-http/psr7-integration-tests": "^1.5.1",
+ "phpunit/phpunit": "^9.6.34"
+ },
+ "suggest": {
+ "ext-intl": "Convert internationalized hosts with Idna",
+ "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://sagikazarmark.hu"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/psr7/issues",
+ "source": "https://github.com/guzzle/psr7/tree/3.6.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-11-22T00:00:35+00:00",
+ "published-time": "2026-11-22T00:01:04+00:00"
+ },
+ {
+ "name": "league/commonmark",
+ "version": "2.10.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/commonmark.git",
+ "reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/8eb53e906fd60c67038d22f1f1cab420ed58b8be",
+ "reference": "8eb53e906fd60c67038d22f1f1cab420ed58b8be",
+ "shasum": ""
+ },
+ "require": {
+ "ext-mbstring": "*",
+ "league/config": "^1.1.1",
+ "php": "^7.4 || ^8.0",
+ "psr/event-dispatcher": "^1.0",
+ "symfony/deprecation-contracts": "^2.1 || ^3.0",
+ "symfony/polyfill-php80": "^1.16"
+ },
+ "require-dev": {
+ "cebe/markdown": "^1.0",
+ "commonmark/cmark": "0.31.1",
+ "commonmark/commonmark.js": "0.31.1",
+ "composer/package-versions-deprecated": "^1.8",
+ "embed/embed": "^4.4",
+ "erusev/parsedown": "^1.0",
+ "ext-json": "*",
+ "github/gfm": "0.29.0",
+ "michelf/php-markdown": "^1.4 || ^2.0",
+ "nyholm/psr7": "^1.5",
+ "phpstan/phpstan": "^2.0.0",
+ "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0 || ^12.0.0 || ^13.0.0",
+ "scrutinizer/ocular": "^1.8.1",
+ "symfony/finder": "^5.3 | ^6.0 | ^7.0 || ^8.0",
+ "symfony/process": "^5.4 | ^6.0 | ^7.0 || ^8.0",
+ "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0 || ^8.0",
+ "unleashedtech/php-coding-standard": "^3.1.1",
+ "vimeo/psalm": "^4.24.0 || ^5.0.0 || ^6.0.0"
+ },
+ "suggest": {
+ "symfony/yaml": "v2.3+ required if using the Front Matter extension"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "2.11-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\CommonMark\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com",
+ "role": "Lead Developer"
+ }
+ ],
+ "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)",
+ "homepage": "https://commonmark.thephpleague.com",
+ "keywords": [
+ "commonmark",
+ "flavored",
+ "gfm",
+ "github",
+ "github-flavored",
+ "markdown",
+ "md",
+ "parser"
+ ],
+ "support": {
+ "docs": "https://commonmark.thephpleague.com/",
+ "forum": "https://github.com/thephpleague/commonmark/discussions",
+ "issues": "https://github.com/thephpleague/commonmark/issues",
+ "rss": "https://github.com/thephpleague/commonmark/releases.atom",
+ "source": "https://github.com/thephpleague/commonmark"
+ },
+ "funding": [
+ {
+ "url": "https://www.colinodell.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.paypal.me/colinpodell/10.00",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/colinodell",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/league/commonmark",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-10-31T13:35:37+00:00",
+ "published-time": "2026-10-31T13:35:57+00:00"
+ },
+ {
+ "name": "league/config",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/config.git",
+ "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/config/zipball/754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
+ "reference": "754b3604fb2984c71f4af4a9cbe7b57f346ec1f3",
+ "shasum": ""
+ },
+ "require": {
+ "dflydev/dot-access-data": "^3.0.1",
+ "nette/schema": "^1.2",
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "phpstan/phpstan": "^1.8.2",
+ "phpunit/phpunit": "^9.5.5",
+ "scrutinizer/ocular": "^1.8.1",
+ "unleashedtech/php-coding-standard": "^3.1",
+ "vimeo/psalm": "^4.7.3"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "League\\Config\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Colin O'Dell",
+ "email": "colinodell@gmail.com",
+ "homepage": "https://www.colinodell.com",
+ "role": "Lead Developer"
+ }
+ ],
+ "description": "Define configuration arrays with strict schemas and access values with dot notation",
+ "homepage": "https://config.thephpleague.com",
+ "keywords": [
+ "array",
+ "config",
+ "configuration",
+ "dot",
+ "dot-access",
+ "nested",
+ "schema"
+ ],
+ "support": {
+ "docs": "https://config.thephpleague.com/",
+ "issues": "https://github.com/thephpleague/config/issues",
+ "rss": "https://github.com/thephpleague/config/releases.atom",
+ "source": "https://github.com/thephpleague/config"
+ },
+ "funding": [
+ {
+ "url": "https://www.colinodell.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://www.paypal.me/colinpodell/10.00",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/colinodell",
+ "type": "github"
+ }
+ ],
+ "time": "2022-12-11T20:36:23+00:00",
+ "published-time": "2022-12-11T20:36:45+00:00"
+ },
+ {
+ "name": "league/oauth2-client",
+ "version": "2.10.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/thephpleague/oauth2-client.git",
+ "reference": "25d240c6804f975909f8cdd131345949d8642535"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/25d240c6804f975909f8cdd131345949d8642535",
+ "reference": "25d240c6804f975909f8cdd131345949d8642535",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "guzzlehttp/guzzle": "^8.5.2",
+ "guzzlehttp/psr7": "^3.5.1",
+ "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "^1.6.15",
+ "php-parallel-lint/php-parallel-lint": "^1.4.0",
+ "phpunit/phpunit": "^11.5.58",
+ "squizlabs/php_codesniffer": "^4.0.4"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "League\\OAuth2\\Client\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Alex Bilbie",
+ "email": "hello@alexbilbie.com",
+ "homepage": "http://www.alexbilbie.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Woody Gilk",
+ "homepage": "https://github.com/shadowhand",
+ "role": "Contributor"
+ },
+ {
+ "name": "Andrew Millington",
+ "homepage": "https://github.com/sephster",
+ "role": "Developer"
+ }
+ ],
+ "description": "OAuth 2.0 Client Library",
+ "keywords": [
+ "Authentication",
+ "SSO",
+ "authorization",
+ "identity",
+ "idp",
+ "oauth",
+ "oauth2",
+ "single sign on"
+ ],
+ "support": {
+ "issues": "https://github.com/thephpleague/oauth2-client/issues",
+ "source": "https://github.com/thephpleague/oauth2-client/tree/2.10.0"
+ },
+ "time": "2026-11-20T19:11:07+00:00",
+ "published-time": "2026-11-20T19:16:43+00:00"
+ },
+ {
+ "name": "monolog/monolog",
+ "version": "3.13.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Seldaek/monolog.git",
+ "reference": "1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac",
+ "reference": "1f5f55bb4a9a230ff6d8a4ceccea31d10b0142ac",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "psr/log": "^2.0 || ^3.0"
+ },
+ "provide": {
+ "psr/log-implementation": "3.0.0"
+ },
+ "require-dev": {
+ "aws/aws-sdk-php": "^3.0",
+ "doctrine/couchdb": "~1.0@dev",
+ "elasticsearch/elasticsearch": "^7 || ^8",
+ "ext-json": "*",
+ "graylog2/gelf-php": "^1.4.2 || ^2.0",
+ "guzzlehttp/guzzle": "^7.4.5",
+ "guzzlehttp/psr7": "^2.2",
+ "mongodb/mongodb": "^1.8 || ^2.0",
+ "php-amqplib/php-amqplib": "~2.4 || ^3",
+ "php-console/php-console": "^3.1.8",
+ "phpstan/phpstan": "^2",
+ "phpstan/phpstan-deprecation-rules": "^2",
+ "phpstan/phpstan-strict-rules": "^2",
+ "phpunit/phpunit": "^10.5.17 || ^11.0.7",
+ "predis/predis": "^1.1 || ^2",
+ "psr/clock": "^1.0",
+ "rollbar/rollbar": "^4.0",
+ "ruflin/elastica": "^7 || ^8",
+ "symfony/mailer": "^5.4 || ^6",
+ "symfony/mime": "^5.4 || ^6"
+ },
+ "suggest": {
+ "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
+ "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
+ "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
+ "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+ "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
+ "ext-mbstring": "Allow to work properly with unicode symbols",
+ "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
+ "ext-openssl": "Required to send log messages using SSL",
+ "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
+ "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
+ "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
+ "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
+ "psr/clock": "Required to pass a clock to the Logger and control the timestamp of log records",
+ "rollbar/rollbar": "Allow sending log messages to Rollbar",
+ "ruflin/elastica": "Allow sending log messages to an Elastic Search server"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Monolog\\": "src/Monolog"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jordi Boggiano",
+ "email": "j.boggiano@seld.be",
+ "homepage": "https://seld.be"
+ }
+ ],
+ "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
+ "homepage": "https://github.com/Seldaek/monolog",
+ "keywords": [
+ "log",
+ "logging",
+ "psr-3"
+ ],
+ "support": {
+ "issues": "https://github.com/Seldaek/monolog/issues",
+ "source": "https://github.com/Seldaek/monolog/tree/3.13.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/Seldaek",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-11-16T10:43:05+00:00",
+ "published-time": "2026-11-16T10:45:37+00:00"
+ },
+ {
+ "name": "nette/schema",
+ "version": "v1.4.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/schema.git",
+ "reference": "af9fa8a86bfca9b02b10346220db26e62ef942ec"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/schema/zipball/af9fa8a86bfca9b02b10346220db26e62ef942ec",
+ "reference": "af9fa8a86bfca9b02b10346220db26e62ef942ec",
+ "shasum": ""
+ },
+ "require": {
+ "nette/utils": "^4.0",
+ "php": "8.1 - 8.6"
+ },
+ "require-dev": {
+ "nette/phpstan-rules": "^1.0.7",
+ "nette/tester": "^2.6",
+ "phpstan/extension-installer": "^1.4@stable",
+ "phpstan/phpstan": "^2.3@stable",
+ "tracy/tracy": "^2.8"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Nette\\": "src"
+ },
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0-only",
+ "GPL-3.0-only"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ }
+ ],
+ "description": "📐 Nette Schema: validates and normalizes data such as configuration or API input against a schema described in a few readable lines of PHP, with precise error messages.",
+ "homepage": "https://doc.nette.org/schema",
+ "keywords": [
+ "configuration",
+ "data validation",
+ "nette",
+ "normalization",
+ "schema",
+ "validation"
+ ],
+ "support": {
+ "issues": "https://github.com/nette/schema/issues",
+ "source": "https://github.com/nette/schema/tree/v1.4.0"
+ },
+ "time": "2026-10-22T02:12:50+00:00",
+ "published-time": "2026-10-22T02:14:45+00:00"
+ },
+ {
+ "name": "nette/utils",
+ "version": "v4.1.6",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nette/utils.git",
+ "reference": "6bf24518accf32cf845bca305e0b92078700fd01"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nette/utils/zipball/6bf24518accf32cf845bca305e0b92078700fd01",
+ "reference": "6bf24518accf32cf845bca305e0b92078700fd01",
+ "shasum": ""
+ },
+ "require": {
+ "php": "8.2 - 8.6"
+ },
+ "conflict": {
+ "nette/finder": "<3",
+ "nette/schema": "<1.2.2"
+ },
+ "require-dev": {
+ "jetbrains/phpstorm-attributes": "^1.2",
+ "nette/phpstan-rules": "^1.0",
+ "nette/tester": "^2.5",
+ "phpstan/extension-installer": "^1.4@stable",
+ "phpstan/phpstan": "^2.1@stable",
+ "tracy/tracy": "^2.9"
+ },
+ "suggest": {
+ "ext-gd": "to use Image",
+ "ext-iconv": "to use Strings::chr(), ord() and reverse()",
+ "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()",
+ "ext-json": "to use Nette\\Utils\\Json",
+ "ext-mbstring": "to use Strings::lower() etc...",
+ "ext-tokenizer": "to use Nette\\Utils\\Reflection::getUseStatements()"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.1-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Nette\\": "src"
+ },
+ "classmap": [
+ "src/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause",
+ "GPL-2.0-only",
+ "GPL-3.0-only"
+ ],
+ "authors": [
+ {
+ "name": "David Grudl",
+ "homepage": "https://davidgrudl.com"
+ },
+ {
+ "name": "Nette Community",
+ "homepage": "https://nette.org/contributors"
+ }
+ ],
+ "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.",
+ "homepage": "https://nette.org",
+ "keywords": [
+ "array",
+ "core",
+ "datetime",
+ "images",
+ "json",
+ "nette",
+ "paginator",
+ "password",
+ "slugify",
+ "string",
+ "unicode",
+ "utf-8",
+ "utility",
+ "validation"
+ ],
+ "support": {
+ "issues": "https://github.com/nette/utils/issues",
+ "source": "https://github.com/nette/utils/tree/v4.1.6"
+ },
+ "time": "2026-10-20T17:07:56+00:00",
+ "published-time": "2026-10-20T17:48:30+00:00"
+ },
+ {
+ "name": "nikic/fast-route",
+ "version": "1.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nikic/FastRoute.git",
+ "reference": "7476684f39bb9124b3be69ed3d84b66723920298"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/nikic/FastRoute/zipball/7476684f39bb9124b3be69ed3d84b66723920298",
+ "reference": "7476684f39bb9124b3be69ed3d84b66723920298",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8.35|~5.7"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/functions.php"
+ ],
+ "psr-4": {
+ "FastRoute\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Nikita Popov",
+ "email": "nikic@php.net"
+ }
+ ],
+ "description": "Fast request router for PHP",
+ "keywords": [
+ "router",
+ "routing"
+ ],
+ "support": {
+ "issues": "https://github.com/nikic/FastRoute/issues",
+ "source": "https://github.com/nikic/FastRoute/tree/1.3.1"
+ },
+ "time": "2026-07-09T19:38:47+00:00",
+ "published-time": "2026-07-09T19:39:54+00:00"
+ },
+ {
+ "name": "psr/container",
+ "version": "2.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/container.git",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.4.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Container\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common Container Interface (PHP FIG PSR-11)",
+ "homepage": "https://github.com/php-fig/container",
+ "keywords": [
+ "PSR-11",
+ "container",
+ "container-interface",
+ "container-interop",
+ "psr"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/container/issues",
+ "source": "https://github.com/php-fig/container/tree/2.0.2"
+ },
+ "time": "2021-11-05T16:47:00+00:00",
+ "published-time": "2021-11-05T16:53:27+00:00"
+ },
+ {
+ "name": "psr/event-dispatcher",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/event-dispatcher.git",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\EventDispatcher\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Standard interfaces for event handling.",
+ "keywords": [
+ "events",
+ "psr",
+ "psr-14"
+ ],
+ "support": {
+ "issues": "https://github.com/php-fig/event-dispatcher/issues",
+ "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0"
+ },
+ "time": "2019-01-08T18:20:26+00:00",
+ "published-time": "2019-03-25T15:31:44+00:00"
+ },
+ {
+ "name": "psr/http-client",
+ "version": "1.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-client.git",
+ "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
+ "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.0 || ^8.0",
+ "psr/http-message": "^1.0 || ^2.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Client\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP clients",
+ "homepage": "https://github.com/php-fig/http-client",
+ "keywords": [
+ "http",
+ "http-client",
+ "psr",
+ "psr-18"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-client"
+ },
+ "time": "2023-09-23T14:17:50+00:00",
+ "published-time": "2023-09-23T14:18:12+00:00"
+ },
+ {
+ "name": "psr/http-factory",
+ "version": "1.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-factory.git",
+ "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
+ "reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1",
+ "psr/http-message": "^1.0 || ^2.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
+ "keywords": [
+ "factory",
+ "http",
+ "message",
+ "psr",
+ "psr-17",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory"
+ },
+ "time": "2024-04-15T12:06:14+00:00",
+ "published-time": "2024-05-10T07:32:19+00:00"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2 || ^8.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/2.0"
+ },
+ "time": "2023-04-04T09:54:51+00:00",
+ "published-time": "2023-04-04T09:55:35+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
+ "reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/3.0.2"
+ },
+ "time": "2024-09-11T13:17:53+00:00",
+ "published-time": "2024-09-11T13:21:14+00:00"
+ },
+ {
+ "name": "symfony/deprecation-contracts",
+ "version": "v3.8.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/deprecation-contracts.git",
+ "reference": "feb1edf4e546af3b85c5caebe8359a20db230ca3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/feb1edf4e546af3b85c5caebe8359a20db230ca3",
+ "reference": "feb1edf4e546af3b85c5caebe8359a20db230ca3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/contracts",
+ "name": "symfony/contracts"
+ },
+ "branch-alias": {
+ "dev-main": "3.8-dev"
+ }
+ },
+ "autoload": {
+ "files": [
+ "function.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A generic function and convention to trigger deprecation notices",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.8.1"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/nicolas-grekas",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-09-16T14:15:10+00:00",
+ "published-time": "2026-11-04T11:25:34+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php80",
+ "version": "v1.43.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php80.git",
+ "reference": "9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74",
+ "reference": "9c6a5d6b01ca51d486c813e9a9c0ed55f208bb74",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/polyfill",
+ "name": "symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php80\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ion Bazan",
+ "email": "ion.bazan@gmail.com"
+ },
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php80/tree/v1.43.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/nicolas-grekas",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-09-25T15:50:05+00:00",
+ "published-time": "2026-09-30T10:23:35+00:00"
+ },
+ {
+ "name": "symfony/polyfill-php82",
+ "version": "v1.43.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-php82.git",
+ "reference": "843bbe8b2a7934307b749751eede0f111f5d1cfc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/843bbe8b2a7934307b749751eede0f111f5d1cfc",
+ "reference": "843bbe8b2a7934307b749751eede0f111f5d1cfc",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2"
+ },
+ "type": "library",
+ "extra": {
+ "thanks": {
+ "url": "https://github.com/symfony/polyfill",
+ "name": "symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Php82\\": ""
+ },
+ "classmap": [
+ "Resources/stubs"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-php82/tree/v1.43.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/nicolas-grekas",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-09-25T15:50:05+00:00",
+ "published-time": "2026-09-30T10:23:32+00:00"
+ },
+ {
+ "name": "workerman/coroutine",
+ "version": "v1.1.7",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/workerman-php/coroutine.git",
+ "reference": "68a905d50f7ec1efcedc1ec317a75dcc3dea3f0f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/workerman-php/coroutine/zipball/68a905d50f7ec1efcedc1ec317a75dcc3dea3f0f",
+ "reference": "68a905d50f7ec1efcedc1ec317a75dcc3dea3f0f",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.1",
+ "workerman/workerman": "^5.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^11.0",
+ "psr/log": "*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Workerman\\": "src",
+ "Workerman\\Coroutine\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Workerman coroutine",
+ "support": {
+ "issues": "https://github.com/workerman-php/coroutine/issues",
+ "source": "https://github.com/workerman-php/coroutine/tree/v1.1.7"
+ },
+ "time": "2026-10-24T05:06:43+00:00",
+ "published-time": "2026-10-25T02:55:21+00:00"
+ },
+ {
+ "name": "workerman/webman-framework",
+ "version": "v2.2.5",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/walkor/webman-framework.git",
+ "reference": "263ef955d8ba6a0cb6fbc1bd0912589ed67c0c8d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/walkor/webman-framework/zipball/263ef955d8ba6a0cb6fbc1bd0912589ed67c0c8d",
+ "reference": "263ef955d8ba6a0cb6fbc1bd0912589ed67c0c8d",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "nikic/fast-route": "^1.3",
+ "php": ">=8.1",
+ "psr/container": ">=1.0",
+ "psr/log": "^2.0 || ^3.0",
+ "workerman/workerman": "^5.1 || dev-master"
+ },
+ "suggest": {
+ "ext-event": "For better performance. "
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "./src/support/helpers.php"
+ ],
+ "psr-4": {
+ "Webman\\": "./src",
+ "Support\\": "./src/support",
+ "support\\": "./src/support",
+ "Support\\View\\": "./src/support/view",
+ "Support\\Bootstrap\\": "./src/support/bootstrap",
+ "Support\\Exception\\": "./src/support/exception"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "walkor",
+ "email": "walkor@workerman.net",
+ "homepage": "https://www.workerman.net",
+ "role": "Developer"
+ }
+ ],
+ "description": "High performance HTTP Service Framework.",
+ "homepage": "https://www.workerman.net",
+ "keywords": [
+ "High Performance",
+ "http service"
+ ],
+ "support": {
+ "email": "walkor@workerman.net",
+ "forum": "https://wenda.workerman.net/",
+ "issues": "https://github.com/walkor/webman/issues",
+ "source": "https://github.com/walkor/webman-framework",
+ "wiki": "https://doc.workerman.net/"
+ },
+ "time": "2026-10-25T09:46:46+00:00",
+ "published-time": "2026-10-25T09:47:02+00:00"
+ },
+ {
+ "name": "workerman/workerman",
+ "version": "v5.2.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/walkor/workerman.git",
+ "reference": "4c817dec82c9ea223879b019600db58f62199abc"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/walkor/workerman/zipball/4c817dec82c9ea223879b019600db58f62199abc",
+ "reference": "4c817dec82c9ea223879b019600db58f62199abc",
+ "shasum": ""
+ },
+ "require": {
+ "ext-json": "*",
+ "php": ">=8.1",
+ "workerman/coroutine": "^1.1 || dev-main"
+ },
+ "conflict": {
+ "ext-swow": " false,
+ 'error_reporting' => E_ALL,
+ 'default_timezone' => 'Asia/Shanghai',
+ 'request_class' => App\Http\Request::class,
+ 'public_path' => base_path() . '/public',
+ 'runtime_path' => base_path() . '/runtime',
+ 'controller_suffix' => 'Controller',
+ 'controller_reuse' => false,
+];
diff --git a/config/bootstrap.php b/config/bootstrap.php
new file mode 100644
index 0000000..23cde40
--- /dev/null
+++ b/config/bootstrap.php
@@ -0,0 +1,3 @@
+ support\exception\Handler::class];
diff --git a/config/log.php b/config/log.php
new file mode 100644
index 0000000..aa4eb27
--- /dev/null
+++ b/config/log.php
@@ -0,0 +1,12 @@
+ [
+ 'handlers' => [
+ [
+ 'class' => Monolog\Handler\RotatingFileHandler::class,
+ 'constructor' => [runtime_path() . '/logs/webman.log', 14, Monolog\Level::Info],
+ ],
+ ],
+ ],
+];
diff --git a/config/process.php b/config/process.php
new file mode 100644
index 0000000..15b0a7b
--- /dev/null
+++ b/config/process.php
@@ -0,0 +1,15 @@
+ [
+ 'handler' => Webman\App::class,
+ 'listen' => getenv('LAYSITE_LISTEN') ?: 'http://127.0.0.1:8787',
+ 'count' => max(1, (int) (getenv('LAYSITE_WORKERS') ?: 2)),
+ 'constructor' => [
+ 'requestClass' => App\Http\Request::class,
+ 'logger' => support\Log::channel('default'),
+ 'appPath' => app_path(),
+ 'publicPath' => public_path(),
+ ],
+ ],
+];
diff --git a/config/route.php b/config/route.php
new file mode 100644
index 0000000..f6e43b5
--- /dev/null
+++ b/config/route.php
@@ -0,0 +1,58 @@
+ (new SiteController())->missing($request));
diff --git a/config/server.php b/config/server.php
new file mode 100644
index 0000000..4d2d9f6
--- /dev/null
+++ b/config/server.php
@@ -0,0 +1,10 @@
+ runtime_path() . '/webman.pid',
+ 'status_file' => runtime_path() . '/webman.status',
+ 'stdout_file' => runtime_path() . '/logs/stdout.log',
+ 'log_file' => runtime_path() . '/logs/workerman.log',
+ 'stop_timeout' => 4,
+ 'max_package_size' => 66 * 1024 * 1024,
+];
diff --git a/config/session.php b/config/session.php
new file mode 100644
index 0000000..0719b87
--- /dev/null
+++ b/config/session.php
@@ -0,0 +1,14 @@
+ 'file',
+ 'handler' => Webman\Session\FileSessionHandler::class,
+ 'config' => ['file' => ['save_path' => runtime_path() . '/sessions']],
+ 'session_name' => 'LAYSITE_CMS',
+ 'lifetime' => 8 * 60 * 60,
+ 'cookie_lifetime' => 0,
+ 'cookie_path' => '/admin',
+ 'http_only' => true,
+ 'secure' => getenv('LAYSITE_SECURE_COOKIES') === '1',
+ 'same_site' => 'Lax',
+];
diff --git a/config/static.php b/config/static.php
new file mode 100644
index 0000000..8b1fb0d
--- /dev/null
+++ b/config/static.php
@@ -0,0 +1,3 @@
+ true, 'middleware' => [App\Middleware\PublicAssets::class]];
diff --git a/public/assets/admin.css b/public/assets/admin.css
new file mode 100644
index 0000000..19f5d5f
--- /dev/null
+++ b/public/assets/admin.css
@@ -0,0 +1,324 @@
+.admin-body { background: var(--paper); min-height: 100vh; }
+.admin-wrap { width: min(calc(100% - 2rem), 67rem); margin-inline: auto; }
+.admin-bar { background: var(--white); border-bottom: 1px solid var(--line); }
+.admin-bar-inner, .admin-bar nav { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem 1.15rem; }
+.admin-bar-inner { justify-content: space-between; min-height: 4.5rem; padding-block: .45rem; }
+.admin-bar nav > a { display: inline-flex; min-height: 44px; align-items: center; text-decoration: none; font-weight: 550; }
+.admin-main { padding-block: clamp(1.65rem, 4vw, 3.25rem); }
+.admin-main h1 { font-size: clamp(2rem, 4vw, 3.1rem); margin: 0; }
+.admin-main h2 { font-size: 1.38rem; margin-bottom: 1rem; }
+.admin-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.25rem; margin: 0 0 1.2rem; }
+.admin-heading.compact h2, .admin-heading p { margin: 0; }
+.admin-heading p { margin-top: .4rem; }
+.admin-panel, .login-box { border: 1px solid var(--line); padding: clamp(1rem, 3vw, 2rem); background: var(--white); border-radius: var(--radius); margin-bottom: 1.15rem; }
+.login-box { max-width: 27rem; margin: clamp(1.5rem, 6vw, 5rem) auto; }
+.login-box p { margin-block: .6rem 1.25rem; }
+.admin-form { display: grid; gap: 1rem; }
+.admin-form label { display: grid; gap: .4rem; font-weight: 570; color: var(--ink); }
+.admin-form :where(input:not([type=hidden]), select, textarea) {
+ background: white;
+ color: var(--ink);
+ width: 100%;
+ border: 1px solid #b9c7dd;
+ border-radius: .5rem;
+ padding: .6rem .75rem;
+ font-size: 1rem;
+ font-weight: 400;
+ min-height: 44px;
+}
+.admin-form textarea { resize: vertical; }
+.admin-form small, .field-note { color: var(--muted); font-size: .875rem; font-weight: 400; }
+.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
+.form-submit { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
+.form-submit label { min-width: 10rem; }
+.admin-list { margin: 0; padding: 0; list-style: none; }
+.admin-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .65rem; padding-block: .7rem; border-top: 1px solid var(--line); }
+.admin-list small { display: block; color: var(--muted); font-size: .875rem; }
+.feedback { padding: .8rem 1rem; border-radius: .5rem; }
+.feedback.error { background: #feebeb; color: #9c252a; }
+.feedback.success { background: #e5f6ed; color: #126044; }
+.button-danger { color: #9c252a; background: transparent; border-color: #e6b6b9; }
+.button-danger:hover { color: #9c252a; background: #feebeb; }
+.editor { display: grid; gap: .45rem; }
+.editor-toolbar { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: space-between; padding: .45rem; border: 1px solid var(--line); background: var(--paper); border-radius: .5rem; }
+.editor-toolbar > div { display: flex; flex-wrap: wrap; gap: .25rem; }
+.editor-toolbar button { border: 1px solid var(--line); background: var(--white); border-radius: .35rem; min-height: 44px; padding: .45rem .7rem; color: var(--ink); }
+.editor-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
+.editor textarea { font-family: var(--mono); font-size: .95rem; line-height: 1.55; }
+.editor-preview { padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; }
+.field-note { margin: 0; }
+@media (max-width: 38rem) {
+ .form-grid { grid-template-columns: 1fr; }
+ .admin-bar nav { gap: .3rem .85rem; }
+}
+
+.password-form { max-width: 37rem; }
+.admin-form button:disabled, .admin-bar button:disabled { cursor: progress; opacity: .65; }
+.admin-form .ajax-feedback { margin: 0; }
+
+.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.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 [aria-pressed="true"] { background: var(--accent-light); color: var(--accent-deep); }
+.studio-inspector details label { margin-top: .7rem; }
+.studio-blocks form, .studio-block-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .32rem; }
+.studio-blocks .button { padding-inline: .65rem; }
+.studio-block-add { margin-top: 1.25rem; }
+.studio-rich { min-height: 15rem; max-width: 100%; overflow-x: auto; padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: .55rem; }
+.studio-rich:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
+.studio-rich details { margin-bottom: .5rem; }
+.studio-rich img, .studio-rich video { max-width: 100%; height: auto; }
+.asset-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .55rem; }
+.settings-form { max-width: 54rem; }
+.media-grid, .picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .8rem; }
+.media-card, .picker-item { min-width: 0; border: 1px solid var(--line); border-radius: .65rem; background: white; padding: .75rem; overflow-wrap: anywhere; }
+.media-card > img, .picker-item img, .media-file-type { height: 6rem; width: 100%; object-fit: contain; background: var(--paper); border-radius: .45rem; margin-bottom: .7rem; }
+.media-card .media-file-type { display: grid; place-items: center; font-size: 1.1rem; text-transform: uppercase; }
+.media-card h3 { font-size: 1rem; margin-bottom: 0; }
+.media-card small { color: var(--muted); }
+.media-card .actions { margin: .45rem 0; }
+.media-card .button { padding-inline: .55rem; }
+.media-card .media-archive { display: flex; align-items: center; }
+.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.canvas-properties { max-width: min(92vw, 32rem); }
+.media-picker::backdrop { background: #101c3488; }
+.media-picker label { display: grid; gap: .35rem; }
+.media-picker input { padding: .55rem .75rem; border: 1px solid var(--line); border-radius: .4rem; }
+.picker-grid { max-height: 50vh; overflow: auto; padding: .25rem; }
+.picker-item { text-align: left; min-height: 44px; }
+.picker-item:hover { border-color: var(--accent); }
+@media (max-width: 65rem) {
+}
+
+.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); }
+
+.design-overview, .palette-fields { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); }
+.palette-fields input[type=color] { padding: .25rem; }
+.layout-components input[type=checkbox] { width: auto; min-height: auto; }
+.layout-components label { display: flex; align-items: center; }
+
+.admin-bar .wordmark { display: inline-flex; gap: .5rem; align-items: center; font-size: 1.26rem; font-weight: 700; color: var(--ink); text-decoration: none; }
+.admin-bar .laysite-mark { width: 2.6rem; height: 2.6rem; max-width: 2.6rem; max-height: 2.6rem; object-fit: contain; }
diff --git a/public/assets/admin.js b/public/assets/admin.js
new file mode 100644
index 0000000..38dce7d
--- /dev/null
+++ b/public/assets/admin.js
@@ -0,0 +1,197 @@
+'use strict';
+
+jQuery(function ($) {
+ $('[data-layout-components]').on('click', '[data-component-move]', function () {
+ const $item = $(this).closest('li');
+ if (this.dataset.componentMove === '-1') $item.prev().before($item);
+ else $item.next().after($item);
+ $(this).trigger('focus');
+ });
+ $('[data-provider-settings]').each(function () {
+ const $settings = $(this);
+ const $preset = $settings.closest('form').find('[data-layout-preset]');
+ const $mode = $settings.find('[name=provider_mode]');
+ const sync = () => {
+ $settings.prop('hidden', $preset.val() !== 'member');
+ $settings.find('[data-provider-mode]').each(function () {
+ $(this).prop('hidden', this.dataset.providerMode !== $mode.val());
+ });
+ };
+ $preset.add($mode).on('change', sync);
+ sync();
+ });
+
+ $('[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 = {
+ markdown: {
+ heading: ['## ', '', '小标题'],
+ bold: ['**', '**', '粗体文字'],
+ list: ['- ', '', '列表项'],
+ link: ['[', '](https://)', '链接文字']
+ },
+ html: {
+ heading: ['', '
', '小标题'],
+ bold: ['', '', '粗体文字'],
+ list: ['', '列表项'],
+ link: ['', '', '链接文字']
+ }
+ };
+
+ 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) {
+ if (response?.csrf) {
+ $('input[name="csrf"]').val(response.csrf);
+ }
+ }
+
+ function formError($form, message, status) {
+ let $feedback = $form.children('.ajax-feedback');
+ if (!$feedback.length) {
+ $feedback = $('', {class: 'ajax-feedback feedback error', role: 'alert', tabindex: -1})
+ .prependTo($form);
+ }
+ $feedback.text(message);
+ if (status === 401) {
+ $feedback.append(' ', $('', {
+ href: '/admin/login', target: '_blank', rel: 'noopener', text: '打开登录页'
+ }));
+ }
+ $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) {
+ event.preventDefault();
+ const $form = $(this);
+ if ($form.attr('aria-busy') === 'true') return;
+ const submitter = event.originalEvent?.submitter;
+ if (submitter?.dataset.confirm && !window.confirm(submitter.dataset.confirm)) return;
+ clearSavedStatus();
+ const action = $form.attr('action');
+ const isLogin = action === '/admin/login';
+ const $submit = $form.find(':submit:enabled');
+ const multipart = $form.attr('enctype') === 'multipart/form-data';
+ $form.attr('aria-busy', 'true').children('.ajax-feedback').prop('hidden', true);
+ $submit.prop('disabled', true);
+ $form.triggerHandler('studio:busy', [true]);
+
+ function finish() {
+ $form.removeAttr('aria-busy');
+ $submit.prop('disabled', false);
+ $form.triggerHandler('studio:busy', [false]);
+ }
+
+ function submit(canRetryLogin) {
+ $form.triggerHandler('studio:sync');
+ const fields = multipart ? new FormData($form.get(0)) : $form.serializeArray();
+ if (submitter?.name) {
+ if (multipart) fields.append(submitter.name, submitter.value);
+ else fields.push({name: submitter.name, value: submitter.value});
+ }
+ $.ajax({
+ url: action,
+ method: 'POST',
+ data: fields,
+ processData: !multipart,
+ contentType: multipart ? false : 'application/x-www-form-urlencoded; charset=UTF-8',
+ dataType: 'json'
+ }).done(function (response) {
+ if (response.redirect) {
+ $form.triggerHandler('studio:saved');
+ window.location.assign(response.redirect);
+ return;
+ }
+ finish();
+ formError($form, '未收到保存结果,请刷新页面确认。');
+ }).fail(function (request) {
+ const response = request.responseJSON;
+ refreshToken(response);
+ if (canRetryLogin && request.status === 403 && response?.csrf) {
+ submit(false);
+ return;
+ }
+ finish();
+ formError($form, response?.message || '请求未完成,请稍后重试。', request.status);
+ });
+ }
+
+ submit(isLogin);
+ });
+
+ $('[data-editor]').each(function () {
+ const $editor = $(this);
+ if ($editor.find('[data-rich-canvas]').length) return;
+ const area = $editor.find('textarea').get(0);
+ const format = $editor.data('format');
+ const $preview = $editor.find('.editor-preview');
+ const $form = $editor.closest('form');
+ let pendingPreview;
+
+ $editor.on('click', '[data-insert]', function () {
+ const [before, after, example] = formats[format][$(this).data('insert')];
+ const start = area.selectionStart;
+ const end = area.selectionEnd;
+ const selection = area.value.slice(start, end) || example;
+ area.setRangeText(before + selection + after, start, end, 'end');
+ area.focus();
+ area.setSelectionRange(start + before.length, start + before.length + selection.length);
+ });
+
+ $editor.on('click', '[data-preview-button]', function () {
+ const $button = $(this);
+ const show = $preview.prop('hidden');
+ $preview.prop('hidden', !show);
+ $button.text(show ? '收起预览' : '预览正文').attr('aria-expanded', String(show));
+ pendingPreview?.abort();
+ if (!show) return;
+
+ $preview.text('正在加载预览…');
+ pendingPreview = $.ajax({
+ url: '/admin/preview',
+ method: 'POST',
+ data: {body: area.value, format, csrf: $form.find('input[name="csrf"]').val()},
+ dataType: 'text'
+ }).done((markup) => $preview.html(markup)).fail((request, status) => {
+ if (status === 'abort') return;
+ let feedback = request.responseJSON;
+ if (!feedback && request.getResponseHeader('Content-Type')?.startsWith('application/json')) {
+ try { feedback = JSON.parse(request.responseText); } catch { /* Use the fallback feedback. */ }
+ }
+ refreshToken(feedback);
+ $preview.text(feedback?.message || '预览无法加载,请重试。');
+ });
+ });
+ });
+});
diff --git a/public/assets/article-editor.js b/public/assets/article-editor.js
new file mode 100644
index 0000000..bde229a
--- /dev/null
+++ b/public/assets/article-editor.js
@@ -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);
+ });
+ });
+});
diff --git a/public/assets/geist-OFL.txt b/public/assets/geist-OFL.txt
new file mode 100644
index 0000000..5e83a47
--- /dev/null
+++ b/public/assets/geist-OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2026 The Geist Project Authors (https://github.com/vercel/geist-font)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/public/assets/geist.woff2 b/public/assets/geist.woff2
new file mode 100644
index 0000000000000000000000000000000000000000..991445d78ae619a7378ff219385588c7811c88ab
GIT binary patch
literal 29400
zcmV)2K+L~)Pew8T0RR910CLy>6aWAK0RadA0CHjg0RR9100000000000000000000
z0000Qh6NjepB@~COg~6gK~jfXKTTFaQalD=KT}jeRDn1Eg%B@(5eN$QXx<|WghBu?
zfv9K!HUcCAi2wv31&A64i%ARz8zS))Y*%BTp1|g%HJ8sbD%h@O+zv$4`n_s4!iJ3l
zAl@7k{eMzY8AB7;lNO*l-R=*yWFwRsIf8~9GL0FjwPHg^@2WWFJlFf012?ihsP#qZ
z`;kyPGs$e>Hzyupcl@oUYGa#9SVz!vuHm}znb*V>SP;aAF)%QlYFJI3FdKLK;o9Vm
zL%sj3B9mWq;uIuOmskyHi7k;>(vv|E#`_|7Mc32Pk68q`P5g+29AAWr)~F(~disD-
z5k1a6Is!+ekc4EGfX3YEm(Rih&k@b}KYJIwgd~IzLI~mT03n#AG?)b~MN(7(MZA6yP-h*_Um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-*?veMgljFnlBlb6#z3`q8
ztFf$V{;?vDU&sz5JgHPZ?hZnm^XlpSqh%UX&Xe>f23XkYfu|Lt}eKTy0&&t-1 in e)}var y=e.document,m={type:!0,src:!0,nonce:!0,noModule:!0};function x(e,t,n){var r,i=(n=n||y).createElement("script");for(r in i.text=e,m)t&&t[r]&&(i[r]=t[r]);n.head.appendChild(i).parentNode&&i.parentNode.removeChild(i)}var b="4.0.0",w=/HTML$/i,T=function(e,t){return new T.fn.init(e,t)};function C(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()}T.fn=T.prototype={jquery:b,constructor:T,length:0,toArray:function(){return i.call(this)},get:function(e){return null==e?i.call(this):e<0?this[e+this.length]:this[e]},pushStack:function(e){var t=T.merge(this.constructor(),e);return t.prevObject=this,t},each:function(e){return T.each(this,e)},map:function(e){return this.pushStack(T.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return this.pushStack(i.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},even:function(){return this.pushStack(T.grep(this,function(e,t){return(t+1)%2}))},odd:function(){return this.pushStack(T.grep(this,function(e,t){return t%2}))},eq:function(e){var t=this.length,n=+e+(e<0?t:0);return this.pushStack(n>=0&&n+~]|"+E+")"+E+"*"),q=RegExp(E+"|>"),O=/[+~]/,L=y.documentElement,H=L.matches||L.msMatchesSelector;function P(){var e=[];function t(n,r){return e.push(n+" ")>T.expr.cacheLength&&delete t[e.shift()],t[n+" "]=r}return t}function R(e){return e&&void 0!==e.getElementsByTagName&&e}var M="\\["+E+"*("+A+")(?:"+E+"*([*^$|!~]?=)"+E+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+A+"))|)"+E+"*\\]",W=":("+A+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+M+")*)|.*)\\)|)",$={ID:RegExp("^#("+A+")"),CLASS:RegExp("^\\.("+A+")"),TAG:RegExp("^("+A+"|[*])"),ATTR:RegExp("^"+M),PSEUDO:RegExp("^"+W),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+E+"*(even|odd|(([+-]|)(\\d*)n|)"+E+"*(?:([+-]|)"+E+"*(\\d+)|))"+E+"*\\)|)","i")},I=new RegExp(W),F=RegExp("\\\\[\\da-fA-F]{1,6}"+E+"?|\\\\([^\\r\\n\\f])","g"),B=function(e,t){var n="0x"+e.slice(1)-65536;return t||(n<0?String.fromCharCode(n+65536):String.fromCharCode(n>>10|55296,1023&n|56320))};function _(e){return e.replace(F,B)}function U(e){T.error("Syntax error, unrecognized expression: "+e)}var X=RegExp("^"+E+"*,"+E+"*"),z=P();function Y(e,t){var n,r,i,o,a,s,u,l=z[e+" "];if(l)return t?0:l.slice(0);a=e,s=[],u=T.expr.preFilter;while(a){for(o in(!n||(r=X.exec(a)))&&(r&&(a=a.slice(r[0].length)||a),s.push(i=[])),n=!1,(r=N.exec(a))&&(n=r.shift(),i.push({value:n,type:r[0].replace(D," ")}),a=a.slice(n.length)),$)(r=T.expr.match[o].exec(a))&&(!u[o]||(r=u[o](r)))&&(n=r.shift(),i.push({value:n,type:o,matches:r}),a=a.slice(n.length));if(!n)break}return t?a.length:a?U(e):z(e,s).slice(0)}function G(e){for(var t=0,n=e.length,r="";t1)},removeAttr:function(e){return this.each(function(){T.removeAttr(this,e)})}}),T.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?T.prop(e,t,n):(1===o&&T.isXMLDoc(e)||(i=T.attrHooks[t.toLowerCase()]),void 0!==n)?null===n||!1===n&&0!==t.toLowerCase().indexOf("aria-")?void T.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=e.getAttribute(t))?void 0:r},attrHooks:{},removeAttr:function(e,t){var n,r=0,i=t&&t.match(Q);if(i&&1===e.nodeType)while(n=i[r++])e.removeAttribute(n)}}),k&&(T.attrHooks.type={set:function(e,t){if("radio"===t&&C(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}});var J=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;function K(e,t){return t?"\0"===e?"\uFFFD":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e}T.escapeSelector=function(e){return(e+"").replace(J,K)};var Z=n.sort,ee=n.splice;function et(e,t){if(e===t)return en=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n?n:1&(n=(e.ownerDocument||e)==(t.ownerDocument||t)?e.compareDocumentPosition(t):1)?e==y||e.ownerDocument==y&&T.contains(y,e)?-1:t==y||t.ownerDocument==y&&T.contains(y,t)?1:0:4&n?-1:1}T.uniqueSort=function(e){var t,n=[],r=0,i=0;if(en=!1,Z.call(e,et),en){while(t=e[i++])t===e[i]&&(r=n.push(i));while(r--)ee.call(e,n[r],1)}return e},T.fn.uniqueSort=function(){return this.pushStack(T.uniqueSort(i.apply(this)))};var en,er,ei,eo,ea,es,eu=0,el=0,ec=P(),ef=P(),ep=P(),ed=RegExp(E+"+","g"),eh=RegExp("^"+A+"$"),eg=T.extend({needsContext:RegExp("^"+E+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+E+"*((?:-\\d)?\\d*)"+E+"*\\)|)(?=[^-]|$)","i")},$),ev=/^(?:input|select|textarea|button)$/i,ey=/^h\d$/i,em=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ex=function(){eE()},eb=eS(function(e){return!0===e.disabled&&C(e,"fieldset")},{dir:"parentNode",next:"legend"});function ew(e,t,n,r){var i,o,s,u,l,c,f,p=t&&t.ownerDocument,d=t?t.nodeType:9;if(n=n||[],"string"!=typeof e||!e||1!==d&&9!==d&&11!==d)return n;if(!r&&(eE(t),t=t||eo,es)){if(11!==d&&(l=em.exec(e))){if(i=l[1]){if(9===d)return(s=t.getElementById(i))&&a.call(n,s),n;else if(p&&(s=p.getElementById(i))&&T.contains(t,s))return a.call(n,s),n}else if(l[2])return a.apply(n,t.getElementsByTagName(e)),n;else if((i=l[3])&&t.getElementsByClassName)return a.apply(n,t.getElementsByClassName(i)),n}if(!ep[e+" "]&&(!S||!S.test(e))){if(f=e,p=t,1===d&&(q.test(e)||N.test(e))){((p=O.test(e)&&R(t.parentNode)||t)!=t||k)&&((u=t.getAttribute("id"))?u=T.escapeSelector(u):t.setAttribute("id",u=T.expando)),o=(c=Y(e)).length;while(o--)c[o]=(u?"#"+u:":scope")+" "+G(c[o]);f=c.join(",")}try{return a.apply(n,p.querySelectorAll(f)),n}catch(t){ep(e,!0)}finally{u===T.expando&&t.removeAttribute("id")}}}return eq(e.replace(D,"$1"),t,n,r)}function eT(e){return e[T.expando]=!0,e}function eC(e){return function(t){if("form"in t){if(t.parentNode&&!1===t.disabled){if("label"in t)if("label"in t.parentNode)return t.parentNode.disabled===e;else return t.disabled===e;return t.isDisabled===e||!e!==t.isDisabled&&eb(t)===e}return t.disabled===e}return"label"in t&&t.disabled===e}}function ej(e){return eT(function(t){return t*=1,eT(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function eE(e){var t,n=e?e.ownerDocument||e:y;n!=eo&&9===n.nodeType&&(ea=(eo=n).documentElement,es=!T.isXMLDoc(eo),k&&y!=eo&&(t=eo.defaultView)&&t.top!==t&&t.addEventListener("unload",ex))}for(er in ew.matches=function(e,t){return ew(e,null,null,t)},ew.matchesSelector=function(e,t){if(eE(e),es&&!ep[t+" "]&&(!S||!S.test(t)))try{return H.call(e,t)}catch(e){ep(t,!0)}return ew(t,eo,null,[e]).length>0},T.expr={cacheLength:50,createPseudo:eT,match:eg,find:{ID:function(e,t){if(void 0!==t.getElementById&&es){var n=t.getElementById(e);return n?[n]:[]}},TAG:function(e,t){return void 0!==t.getElementsByTagName?t.getElementsByTagName(e):t.querySelectorAll(e)},CLASS:function(e,t){if(void 0!==t.getElementsByClassName&&es)return t.getElementsByClassName(e)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=_(e[1]),e[3]=_(e[3]||e[4]||e[5]||""),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||U(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&U(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return $.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&I.test(n)&&(t=Y(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{ID:function(e){var t=_(e);return function(e){return e.getAttribute("id")===t}},TAG:function(e){var t=_(e).toLowerCase();return"*"===e?function(){return!0}:function(e){return C(e,t)}},CLASS:function(e){var t=ec[e+" "];return t||(t=RegExp("(^|"+E+")"+e+"("+E+"|$)"))&&ec(e,function(e){return t.test("string"==typeof e.className&&e.className||void 0!==e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=T.attr(r,e);return null==i?"!="===t:!t||((i+="","="===t)?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i.replace(ed," ")+" ").indexOf(n)>-1:"|="===t&&(i===n||i.slice(0,n.length+1)===n+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h=o!==a?"nextSibling":"previousSibling",g=t.parentNode,v=s&&t.nodeName.toLowerCase(),y=!u&&!s,m=!1;if(g){if(o){while(h){f=t;while(f=f[h])if(s?C(f,v):1===f.nodeType)return!1;d=h="only"===e&&!d&&"nextSibling"}return!0}if(d=[a?g.firstChild:g.lastChild],a&&y){m=(p=(l=(c=g[T.expando]||(g[T.expando]={}))[e]||[])[0]===eu&&l[1])&&l[2],f=p&&g.childNodes[p];while(f=++p&&f&&f[h]||(m=p=0)||d.pop())if(1===f.nodeType&&++m&&f===t){c[e]=[eu,p,m];break}}else if(y&&(m=p=(l=(c=t[T.expando]||(t[T.expando]={}))[e]||[])[0]===eu&&l[1]),!1===m){while(f=++p&&f&&f[h]||(m=p=0)||d.pop())if((s?C(f,v):1===f.nodeType)&&++m&&(y&&((c=f[T.expando]||(f[T.expando]={}))[e]=[eu,m]),f===t))break}return(m-=i)===r||m%r==0&&m/r>=0}}},PSEUDO:function(e,t){var n=T.expr.pseudos[e]||T.expr.setFilters[e.toLowerCase()]||U("unsupported pseudo: "+e);return n[T.expando]?n(t):n}},pseudos:{not:eT(function(e){var t=[],n=[],r=eN(e.replace(D,"$1"));return r[T.expando]?eT(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),t[0]=null,!n.pop()}}),has:eT(function(e){return function(t){return ew(e,t).length>0}}),contains:eT(function(e){return e=_(e),function(t){return(t.textContent||T.text(t)).indexOf(e)>-1}}),lang:eT(function(e){return eh.test(e||"")||U("unsupported lang: "+e),e=_(e).toLowerCase(),function(t){var n;do if(n=es?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return(n=n.toLowerCase())===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===ea},focus:function(e){return e===eo.activeElement&&eo.hasFocus()&&!!(e.type||e.href||~e.tabIndex)},enabled:eC(!1),disabled:eC(!0),checked:function(e){return C(e,"input")&&!!e.checked||C(e,"option")&&!!e.selected},selected:function(e){return k&&e.parentNode&&e.parentNode.selectedIndex,!0===e.selected},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!T.expr.pseudos.empty(e)},header:function(e){return ey.test(e.nodeName)},input:function(e){return ev.test(e.nodeName)},button:function(e){return C(e,"input")&&"button"===e.type||C(e,"button")},text:function(e){return C(e,"input")&&"text"===e.type},first:ej(function(){return[0]}),last:ej(function(e,t){return[t-1]}),eq:ej(function(e,t,n){return[n<0?n+t:n]}),even:ej(function(e,t){for(var n=0;nt?t:n;--r>=0;)e.push(r);return e}),gt:ej(function(e,t,n){for(var r=n<0?n+t:n;++r1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function eA(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;s-1},l,!0),d=[function(e,t,r){var i=!u&&(r||t!=ei)||((n=t).nodeType?f(e,t,r):p(e,t,r));return n=null,i}];c-1&&(e[f]=!(u[f]=d))}}else h=eA(h===u?h.splice(y,h.length):h),o?o(null,u,h,c):a.apply(u,h)})}(c>1&&eD(d),c>1&&G(t.slice(0,c-1).concat({value:" "===t[c-2].type?"*":""})).replace(D,"$1"),r,c0,r=l.length>0,i=function(e,t,i,o,s){var c,f,p,d=0,h="0",g=e&&[],v=[],y=ei,m=e||r&&T.expr.find.TAG("*",s),x=eu+=null==y?1:Math.random()||.1;for(s&&(ei=t==eo||t||s);null!=(c=m[h]);h++){if(r&&c){f=0,t||c.ownerDocument==eo||(eE(c),i=!es);while(p=l[f++])if(p(c,t||eo,i)){a.call(o,c);break}s&&(eu=x)}n&&((c=!p&&c)&&d--,e&&g.push(c))}if(d+=h,n&&h!==d){f=0;while(p=u[f++])p(g,v,t,i);if(e){if(d>0)while(h--)g[h]||v[h]||(v[h]=j.call(o));v=eA(v)}a.apply(o,v),s&&!e&&v.length>0&&d+u.length>1&&T.uniqueSort(o)}return s&&(eu=x,ei=y),g},n?eT(i):i))).selector=e}return c}function eq(e,t,n,r){var i,o,s,u,l,c="function"==typeof e&&e,f=!r&&Y(e=c.selector||e);if(n=n||[],1===f.length){if((o=f[0]=f[0].slice(0)).length>2&&"ID"===(s=o[0]).type&&9===t.nodeType&&es&&T.expr.relative[o[1].type]){if(!(t=(T.expr.find.ID(_(s.matches[0]),t)||[])[0]))return n;c&&(t=t.parentNode),e=e.slice(o.shift().value.length)}i=eg.needsContext.test(e)?0:o.length;while(i--){if(s=o[i],T.expr.relative[u=s.type])break;if((l=T.expr.find[u])&&(r=l(_(s.matches[0]),O.test(o[0].type)&&R(t.parentNode)||t))){if(o.splice(i,1),!(e=r.length&&G(o)))return a.apply(n,r),n;break}}}return(c||eN(e,f))(r,t,!es,n,!t||O.test(e)&&R(t.parentNode)||t),n}function eO(e,t,n){var r=[],i=void 0!==n;while((e=e[t])&&9!==e.nodeType)if(1===e.nodeType){if(i&&T(e).is(n))break;r.push(e)}return r}function eL(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}ek.prototype=T.expr.pseudos,T.expr.setFilters=new ek,eE(),T.find=ew,ew.compile=eN,ew.select=eq,ew.setDocument=eE,ew.tokenize=Y;var eH=T.expr.match.needsContext,eP=/^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function eR(e){return"<"===e[0]&&">"===e[e.length-1]&&e.length>=3}function eM(e,t,n){return"function"==typeof t?T.grep(e,function(e,r){return!!t.call(e,r,e)!==n}):t.nodeType?T.grep(e,function(e){return e===t!==n}):"string"!=typeof t?T.grep(e,function(e){return s.call(t,e)>-1!==n}):T.filter(t,e,n)}T.filter=function(e,t,n){var r=t[0];return(n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType)?T.find.matchesSelector(r,e)?[r]:[]:T.find.matches(e,T.grep(t,function(e){return 1===e.nodeType}))},T.fn.extend({find:function(e){var t,n,r=this.length,i=this;if("string"!=typeof e)return this.pushStack(T(e).filter(function(){for(t=0;t1?T.uniqueSort(n):n},filter:function(e){return this.pushStack(eM(this,e||[],!1))},not:function(e){return this.pushStack(eM(this,e||[],!0))},is:function(e){return!!eM(this,"string"==typeof e&&eH.test(e)?T(e):e||[],!1).length}});var eW,e$=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/;(T.fn.init=function(e,t){var n,r;if(!e)return this;if(e.nodeType)return this[0]=e,this.length=1,this;if("function"==typeof e)return void 0!==eW.ready?eW.ready(e):e(T);if(eR(n=e+""))n=[null,e,null];else{if("string"!=typeof e)return T.makeArray(e,this);n=e$.exec(e)}if(n&&(n[1]||!t))if(!n[1])return(r=y.getElementById(n[2]))&&(this[0]=r,this.length=1),this;else{if(t=t instanceof T?t[0]:t,T.merge(this,T.parseHTML(n[1],t&&t.nodeType?t.ownerDocument||t:y,!0)),eP.test(n[1])&&T.isPlainObject(t))for(n in t)"function"==typeof this[n]?this[n](t[n]):this.attr(n,t[n]);return this}return!t||t.jquery?(t||eW).find(e):this.constructor(t).find(e)}).prototype=T.fn,eW=T(y);var eI=/^(?:parents|prev(?:Until|All))/,eF={children:!0,contents:!0,next:!0,prev:!0};function eB(e,t){while((e=e[t])&&1!==e.nodeType);return e}function e_(e){return e}function eU(e){throw e}function eX(e,t,n,r){var i;try{e&&"function"==typeof(i=e.promise)?i.call(e).done(t).fail(n):e&&"function"==typeof(i=e.then)?i.call(e,t,n):t.apply(void 0,[e].slice(r))}catch(e){n(e)}}T.fn.extend({has:function(e){var t=T(e,this),n=t.length;return this.filter(function(){for(var e=0;e-1:1===n.nodeType&&T.find.matchesSelector(n,e))){o.push(n);break}}return this.pushStack(o.length>1?T.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?s.call(T(e),this[0]):s.call(this,e.jquery?e[0]:e):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(T.uniqueSort(T.merge(this.get(),T(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),T.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return eO(e,"parentNode")},parentsUntil:function(e,t,n){return eO(e,"parentNode",n)},next:function(e){return eB(e,"nextSibling")},prev:function(e){return eB(e,"previousSibling")},nextAll:function(e){return eO(e,"nextSibling")},prevAll:function(e){return eO(e,"previousSibling")},nextUntil:function(e,t,n){return eO(e,"nextSibling",n)},prevUntil:function(e,t,n){return eO(e,"previousSibling",n)},siblings:function(e){return eL((e.parentNode||{}).firstChild,e)},children:function(e){return eL(e.firstChild)},contents:function(e){return null!=e.contentDocument&&r(e.contentDocument)?e.contentDocument:(C(e,"template")&&(e=e.content||e),T.merge([],e.childNodes))}},function(e,t){T.fn[e]=function(n,r){var i=T.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=T.filter(r,i)),this.length>1&&(eF[e]||T.uniqueSort(i),eI.test(e)&&i.reverse()),this.pushStack(i)}}),T.Callbacks=function(e){e="string"==typeof e?(t=e,n={},T.each(t.match(Q)||[],function(e,t){n[t]=!0}),n):T.extend({},e);var t,n,r,i,o,a,s=[],u=[],l=-1,c=function(){for(a=a||e.once,o=r=!0;u.length;l=-1){i=u.shift();while(++l-1)s.splice(n,1),n<=l&&l--}),this},has:function(e){return e?T.inArray(e,s)>-1:s.length>0},empty:function(){return s&&(s=[]),this},disable:function(){return a=u=[],s=i="",this},disabled:function(){return!s},lock:function(){return a=u=[],i||r||(s=i=""),this},locked:function(){return!!a},fireWith:function(e,t){return!a&&(t=[e,(t=t||[]).slice?t.slice():t],u.push(t),r||c()),this},fire:function(){return f.fireWith(this,arguments),this},fired:function(){return!!o}};return f},T.extend({Deferred:function(t){var n=[["notify","progress",T.Callbacks("memory"),T.Callbacks("memory"),2],["resolve","done",T.Callbacks("once memory"),T.Callbacks("once memory"),0,"resolved"],["reject","fail",T.Callbacks("once memory"),T.Callbacks("once memory"),1,"rejected"]],r="pending",i={state:function(){return r},always:function(){return o.done(arguments).fail(arguments),this},catch:function(e){return i.then(null,e)},pipe:function(){var e=arguments;return T.Deferred(function(t){T.each(n,function(n,r){var i="function"==typeof e[r[4]]&&e[r[4]];o[r[1]](function(){var e=i&&i.apply(this,arguments);e&&"function"==typeof e.promise?e.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this,i?[e]:arguments)})}),e=null}).promise()},then:function(t,r,i){var o=0;function a(t,n,r,i){return function(){var s=this,u=arguments,l=function(){var e,l;if(!(t=o&&(r!==eU&&(s=void 0,u=[e]),n.rejectWith(s,u))}};t?c():(T.Deferred.getErrorHook&&(c.error=T.Deferred.getErrorHook()),e.setTimeout(c))}}return T.Deferred(function(e){n[0][3].add(a(0,e,"function"==typeof i?i:e_,e.notifyWith)),n[1][3].add(a(0,e,"function"==typeof t?t:e_)),n[2][3].add(a(0,e,"function"==typeof r?r:eU))}).promise()},promise:function(e){return null!=e?T.extend(e,i):i}},o={};return T.each(n,function(e,t){var a=t[2],s=t[5];i[t[1]]=a.add,s&&a.add(function(){r=s},n[3-e][2].disable,n[3-e][3].disable,n[0][2].lock,n[0][3].lock),a.add(t[3].fire),o[t[0]]=function(){return o[t[0]+"With"](this===o?void 0:this,arguments),this},o[t[0]+"With"]=a.fireWith}),i.promise(o),t&&t.call(o,o),o},when:function(e){var t=arguments.length,n=t,r=Array(n),o=i.call(arguments),a=T.Deferred(),s=function(e){return function(n){r[e]=this,o[e]=arguments.length>1?i.call(arguments):n,--t||a.resolveWith(r,o)}};if(t<=1&&(eX(e,a.done(s(n)).resolve,a.reject,!t),"pending"===a.state()||"function"==typeof(o[n]&&o[n].then)))return a.then();while(n--)eX(o[n],s(n),a.reject);return a.promise()}});var ez=/^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;T.Deferred.exceptionHook=function(t,n){t&&ez.test(t.name)&&e.console.warn("jQuery.Deferred exception",t,n)},T.readyException=function(t){e.setTimeout(function(){throw t})};var eY=T.Deferred();function eG(){y.removeEventListener("DOMContentLoaded",eG),e.removeEventListener("load",eG),T.ready()}T.fn.ready=function(e){return eY.then(e).catch(function(e){T.readyException(e)}),this},T.extend({isReady:!1,readyWait:1,ready:function(e){(!0===e?--T.readyWait:T.isReady)||(T.isReady=!0,!0!==e&&--T.readyWait>0||eY.resolveWith(y,[T]))}}),T.ready.then=eY.then,"loading"!==y.readyState?e.setTimeout(T.ready):(y.addEventListener("DOMContentLoaded",eG),e.addEventListener("load",eG));var eV=/-([a-z])/g;function eQ(e,t){return t.toUpperCase()}function eJ(e){return e.replace(eV,eQ)}function eK(e){return 1===e.nodeType||9===e.nodeType||!+e.nodeType}function eZ(){this.expando=T.expando+eZ.uid++}eZ.uid=1,eZ.prototype={cache:function(e){var t=e[this.expando];return!t&&(t=Object.create(null),eK(e)&&(e.nodeType?e[this.expando]=t:Object.defineProperty(e,this.expando,{value:t,configurable:!0}))),t},set:function(e,t,n){var r,i=this.cache(e);if("string"==typeof t)i[eJ(t)]=n;else for(r in t)i[eJ(r)]=t[r];return n},get:function(e,t){return void 0===t?this.cache(e):e[this.expando]&&e[this.expando][eJ(t)]},access:function(e,t,n){return void 0===t||t&&"string"==typeof t&&void 0===n?this.get(e,t):(this.set(e,t,n),void 0!==n?n:t)},remove:function(e,t){var n,r=e[this.expando];if(void 0!==r){if(void 0!==t){n=(t=Array.isArray(t)?t.map(eJ):(t=eJ(t))in r?[t]:t.match(Q)||[]).length;while(n--)delete r[t[n]]}(void 0===t||T.isEmptyObject(r))&&(e.nodeType?e[this.expando]=void 0:delete e[this.expando])}},hasData:function(e){var t=e[this.expando];return void 0!==t&&!T.isEmptyObject(t)}};var e0=new eZ,e1=new eZ,e2=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,e3=/[A-Z]/g;function e4(e,t,n){var r,i;if(void 0===n&&1===e.nodeType)if(r="data-"+t.replace(e3,"-$&").toLowerCase(),"string"==typeof(n=e.getAttribute(r))){try{i=n,n="true"===i||"false"!==i&&("null"===i?null:i===+i+""?+i:e2.test(i)?JSON.parse(i):i)}catch(e){}e1.set(e,t,n)}else n=void 0;return n}T.extend({hasData:function(e){return e1.hasData(e)||e0.hasData(e)},data:function(e,t,n){return e1.access(e,t,n)},removeData:function(e,t){e1.remove(e,t)},_data:function(e,t,n){return e0.access(e,t,n)},_removeData:function(e,t){e0.remove(e,t)}}),T.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=e1.get(o),1===o.nodeType&&!e0.get(o,"hasDataAttrs"))){n=a.length;while(n--)a[n]&&0===(r=a[n].name).indexOf("data-")&&e4(o,r=eJ(r.slice(5)),i[r]);e0.set(o,"hasDataAttrs",!0)}return i}return"object"==typeof e?this.each(function(){e1.set(this,e)}):V(this,function(t){var n;if(o&&void 0===t)return void 0!==(n=e1.get(o,e))||void 0!==(n=e4(o,e))?n:void 0;this.each(function(){e1.set(this,e,t)})},null,t,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){e1.remove(this,e)})}}),T.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=e0.get(e,t),n&&(!r||Array.isArray(n)?r=e0.set(e,t,T.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=T.queue(e,t),r=n.length,i=n.shift(),o=T._queueHooks(e,t);"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,function(){T.dequeue(e,t)},o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return e0.get(e,n)||e0.set(e,n,{empty:T.Callbacks("once memory").add(function(){e0.remove(e,[t+"queue",n])})})}}),T.fn.extend({queue:function(e,t){var n=2;return("string"!=typeof e&&(t=e,e="fx",n--),arguments.length\x20\t\r\n\f]*)/i,tc={thead:["table"],col:["colgroup","table"],tr:["tbody","table"],td:["tr","tbody","table"]};function tf(e,t){var r;return(r=void 0!==e.getElementsByTagName?n.slice.call(e.getElementsByTagName(t||"*")):void 0!==e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&C(e,t))?T.merge([e],r):r}tc.tbody=tc.tfoot=tc.colgroup=tc.caption=tc.thead,tc.th=tc.td;var tp=/^$|^module$|\/(?:java|ecma)script/i;function td(e,t){for(var n=0,r=e.length;n-1)s=s.appendChild(t.createElement(u[c]));s.innerHTML=T.htmlPrefilter(a),T.merge(p,s.childNodes),(s=f.firstChild).textContent=""}else p.push(t.createTextNode(a));f.textContent="",d=0;while(a=p[d++]){if(i&&T.inArray(a,i)>-1){o&&o.push(a);continue}if(l=ts(a),s=tf(f.appendChild(a),"script"),l&&td(s),r){c=0;while(a=s[c++])tp.test(a.type||"")&&r.push(a)}}return f}function tv(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function ty(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function tm(e,t,n,r){t=o(t);var i,a,s,u,l,c,f=0,p=e.length,d=p-1,h=t[0];if("function"==typeof h)return e.each(function(i){var o=e.eq(i);t[0]=h.call(this,i,o.html()),tm(o,t,n,r)});if(p&&(a=(i=tg(t,e[0].ownerDocument,!1,e,r)).firstChild,1===i.childNodes.length&&(i=a),a||r)){for(u=(s=T.map(tf(i,"script"),tv)).length;f=1)){for(;l!==this;l=l.parentNode||this)if(1===l.nodeType&&("click"!==e.type||!0!==l.disabled)){for(n=0,o=[],a={};n-1:T.find(i,this,null,[l]).length),a[i]&&o.push(r);o.length&&s.push({elem:l,handlers:o})}}return l=this,u0&&td(a,!u&&tf(e,"script")),s},cleanData:function(e){for(var t,n,r,i=T.event.special,o=0;void 0!==(n=e[o]);o++)if(eK(n)){if(t=n[e0.expando]){if(t.events)for(r in t.events)i[r]?T.event.remove(n,r):T.removeEvent(n,r,t.handle);n[e0.expando]=void 0}n[e1.expando]&&(n[e1.expando]=void 0)}}}),T.fn.extend({detach:function(e){return tD(this,e,!0)},remove:function(e){return tD(this,e)},text:function(e){return V(this,function(e){return void 0===e?T.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=e)})},null,e,arguments.length)},append:function(){return tm(this,arguments,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&tk(this,e).appendChild(e)})},prepend:function(){return tm(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=tk(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return tm(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return tm(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(T.cleanData(tf(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return T.clone(this,e,t)})},html:function(e){return V(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!tE.test(e)&&!tc[(tl.exec(e)||["",""])[1].toLowerCase()]){e=T.htmlPrefilter(e);try{for(;nT.inArray(this,e)&&(T.cleanData(tf(this)),n&&n.replaceChild(t,this))},e)}}),T.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){T.fn[e]=function(e){for(var n,r=[],i=T(e),o=i.length-1,s=0;s<=o;s++)n=s===o?this:this.clone(!0),T(i[s])[t](n),a.apply(r,n);return this.pushStack(r)}});var tA=RegExp("^("+e5+")(?!px)[a-z%]+$","i"),tN=/^--/;function tq(t){var n=t.ownerDocument.defaultView;return n||(n=e),n.getComputedStyle(t)}function tO(e,t,n){var r,i=tN.test(t);return(n=n||tq(e))&&(r=n.getPropertyValue(t)||n[t],i&&r&&(r=r.replace(D,"$1")||void 0),""!==r||ts(e)||(r=T.style(e,t))),void 0!==r?r+"":r}var tL=["Webkit","Moz","ms"],tH=y.createElement("div").style;function tP(e){return e in tH?e:function(e){var t=e[0].toUpperCase()+e.slice(1),n=tL.length;while(n--)if((e=tL[n]+t)in tH)return e}(e)||e}var tR,tM,tW=y.createElement("table");function t$(){if(tW&&tW.style){var t,n=y.createElement("col"),r=y.createElement("tr"),i=y.createElement("td");if(tW.style.cssText="position:absolute;left:-11111px;border-collapse:separate;border-spacing:0",r.style.cssText="box-sizing:content-box;border:1px solid;height:1px",i.style.cssText="height:9px;width:9px;padding:0",n.span=2,L.appendChild(tW).appendChild(n).parentNode.appendChild(r).appendChild(i).parentNode.appendChild(i.cloneNode(!0)),0===tW.offsetWidth)return void L.removeChild(tW);t=e.getComputedStyle(r),tM=k||18===Math.round(parseFloat(e.getComputedStyle(n).width)),tR=Math.round(parseFloat(t.height)+parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth))===r.offsetHeight,L.removeChild(tW),tW=null}}T.extend(d,{reliableTrDimensions:function(){return t$(),tR},reliableColDimensions:function(){return t$(),tM}});var tI={position:"absolute",visibility:"hidden",display:"block"},tF={letterSpacing:"0",fontWeight:"400"};function tB(e,t,n){var r=e9.exec(t);return r?Math.max(0,r[2]-(n||0))+(r[3]||"px"):t}function t_(e,t,n,r,i,o){var a=+("width"===t),s=0,u=0,l=0;if(n===(r?"border":"content"))return 0;for(;a<4;a+=2)"margin"===n&&(l+=T.css(e,n+e6[a],!0,i)),r?("content"===n&&(u-=T.css(e,"padding"+e6[a],!0,i)),"margin"!==n&&(u-=T.css(e,"border"+e6[a]+"Width",!0,i))):(u+=T.css(e,"padding"+e6[a],!0,i),"padding"!==n?u+=T.css(e,"border"+e6[a]+"Width",!0,i):s+=T.css(e,"border"+e6[a]+"Width",!0,i));return!r&&o>=0&&(u+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-u-s-.5))||0),u+l}function tU(e,t,n){var r=tq(e),i=(k||n)&&"border-box"===T.css(e,"boxSizing",!1,r),o=i,a=tO(e,t,r),s="offset"+t[0].toUpperCase()+t.slice(1);if(tA.test(a)){if(!n)return a;a="auto"}return("auto"===a||k&&i||!d.reliableColDimensions()&&C(e,"col")||!d.reliableTrDimensions()&&C(e,"tr"))&&e.getClientRects().length&&(i="border-box"===T.css(e,"boxSizing",!1,r),(o=s in e)&&(a=e[s])),(a=parseFloat(a)||0)+t_(e,t,n||(i?"border":"content"),o,r,a)+"px"}function tX(e,t,n,r,i){return new tX.prototype.init(e,t,n,r,i)}T.extend({cssHooks:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=ti(t),u=tN.test(t),l=e.style;if(u||(t=tP(s)),a=T.cssHooks[t]||T.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:l[t];if("string"==(o=typeof n)&&(i=e9.exec(n))&&i[1]&&(n=tn(e,t,i),o="number"),null!=n&&n==n)"number"===o&&(n+=i&&i[3]||(tt(s)?"px":"")),k&&""===n&&0===t.indexOf("background")&&(l[t]="inherit"),a&&"set"in a&&void 0===(n=a.set(e,n,r))||(u?l.setProperty(t,n):l[t]=n)}},css:function(e,t,n,r){var i,o,a,s=ti(t);return(tN.test(t)||(t=tP(s)),(a=T.cssHooks[t]||T.cssHooks[s])&&"get"in a&&(i=a.get(e,!0,n)),void 0===i&&(i=tO(e,t,r)),"normal"===i&&t in tF&&(i=tF[t]),""===n||n)?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),T.each(["height","width"],function(e,t){T.cssHooks[t]={get:function(e,n,r){if(n)return"none"===T.css(e,"display")?function(e,t,n){var r,i,o={};for(i in t)o[i]=e.style[i],e.style[i]=t[i];for(i in r=n.call(e),t)e.style[i]=o[i];return r}(e,tI,function(){return tU(e,t,r)}):tU(e,t,r)},set:function(e,n,r){var i,o=tq(e),a=r&&"border-box"===T.css(e,"boxSizing",!1,o),s=r?t_(e,t,r,a,o):0;return s&&(i=e9.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=T.css(e,t)),tB(e,n,s)}}}),T.each({margin:"",padding:"",border:"Width"},function(e,t){T.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+e6[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(T.cssHooks[e+t].set=tB)}),T.fn.extend({css:function(e,t){return V(this,function(e,t,n){var r,i,o={},a=0;if(Array.isArray(t)){for(r=tq(e),i=t.length;a1)}}),T.Tween=tX,tX.prototype={constructor:tX,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||T.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(tt(n)?"px":"")},cur:function(){var e=tX.propHooks[this.prop];return e&&e.get?e.get(this):tX.propHooks._default.get(this)},run:function(e){var t,n=tX.propHooks[this.prop];return this.options.duration?this.pos=t=T.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):tX.propHooks._default.set(this),this}},tX.prototype.init.prototype=tX.prototype,tX.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=T.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){T.fx.step[e.prop]?T.fx.step[e.prop](e):1===e.elem.nodeType&&(T.cssHooks[e.prop]||null!=e.elem.style[tP(e.prop)])?T.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},T.easing={linear:function(e){return e},swing:function(e){return .5-Math.cos(e*Math.PI)/2},_default:"swing"},T.fx=tX.prototype.init,T.fx.step={};var tz,tY,tG=/^(?:toggle|show|hide)$/,tV=/queueHooks$/;function tQ(){return e.setTimeout(function(){tz=void 0}),tz=Date.now()}function tJ(e,t){var n,r=0,i={height:e};for(t=+!!t;r<4;r+=2-t)i["margin"+(n=e6[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function tK(e,t,n){for(var r,i=(tZ.tweeners[t]||[]).concat(tZ.tweeners["*"]),o=0,a=i.length;o1)},removeProp:function(e){return this.each(function(){delete this[T.propFix[e]||e]})}}),T.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return(1===o&&T.isXMLDoc(e)||(t=T.propFix[t]||t,i=T.propHooks[t]),void 0!==n)?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=e.getAttribute("tabindex");return t?parseInt(t,10):t0.test(e.nodeName)||t1.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),k&&(T.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),T.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){T.propFix[this.toLowerCase()]=this}),T.fn.extend({addClass:function(e){var t,n,r,i,o,a;return"function"==typeof e?this.each(function(t){T(this).addClass(e.call(this,t,t3(this)))}):(t=t4(e)).length?this.each(function(){if(r=t3(this),n=1===this.nodeType&&" "+t2(r)+" "){for(o=0;on.indexOf(" "+i+" ")&&(n+=i+" ");r!==(a=t2(n))&&this.setAttribute("class",a)}}):this},removeClass:function(e){var t,n,r,i,o,a;return"function"==typeof e?this.each(function(t){T(this).removeClass(e.call(this,t,t3(this)))}):arguments.length?(t=t4(e)).length?this.each(function(){if(r=t3(this),n=1===this.nodeType&&" "+t2(r)+" "){for(o=0;o-1)n=n.replace(" "+i+" "," ")}r!==(a=t2(n))&&this.setAttribute("class",a)}}):this:this.attr("class","")},toggleClass:function(e,t){var n,r,i,o;return"function"==typeof e?this.each(function(n){T(this).toggleClass(e.call(this,n,t3(this),t),t)}):"boolean"==typeof t?t?this.addClass(e):this.removeClass(e):(n=t4(e)).length?this.each(function(){for(i=0,o=T(this);i-1)return!0;return!1}}),T.fn.extend({val:function(e){var t,n,r,i=this[0];if(!arguments.length)return i?(t=T.valHooks[i.type]||T.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:null==(n=i.value)?"":n:void 0;return r="function"==typeof e,this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,T(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=T.map(i,function(e){return null==e?"":e+""})),(t=T.valHooks[this.type]||T.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))})}}),T.extend({valHooks:{select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,a="select-one"===e.type,s=a?null:[],u=a?o+1:i.length;for(r=o<0?u:a?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),k&&(T.valHooks.option={get:function(e){var t=e.getAttribute("value");return null!=t?t:t2(T.text(e))}}),T.each(["radio","checkbox"],function(){T.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=T.inArray(T(e).val(),t)>-1}}});var t5=/^(?:focusinfocus|focusoutblur)$/,t9=function(e){e.stopPropagation()};T.extend(T.event,{trigger:function(t,n,r,i){var o,a,s,u,l,f,p,d,h=[r||y],v=c.call(t,"type")?t.type:t,m=c.call(t,"namespace")?t.namespace.split("."):[];if((a=d=s=r=r||y,!(3===r.nodeType||8===r.nodeType||t5.test(v+T.event.triggered)))&&(v.indexOf(".")>-1&&(v=(m=v.split(".")).shift(),m.sort()),l=0>v.indexOf(":")&&"on"+v,(t=t[T.expando]?t:new T.Event(v,"object"==typeof t&&t)).isTrigger=i?2:3,t.namespace=m.join("."),t.rnamespace=t.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:T.makeArray(n,[t]),p=T.event.special[v]||{},i||!p.trigger||!1!==p.trigger.apply(r,n))){if(!i&&!p.noBubble&&!g(r)){for(u=p.delegateType||v,!t5.test(u+v)&&(a=a.parentNode);a;a=a.parentNode)h.push(a),s=a;s===(r.ownerDocument||y)&&h.push(s.defaultView||s.parentWindow||e)}o=0;while((a=h[o++])&&!t.isPropagationStopped())d=a,t.type=o>1?u:p.bindType||v,(f=(e0.get(a,"events")||Object.create(null))[t.type]&&e0.get(a,"handle"))&&f.apply(a,n),(f=l&&a[l])&&f.apply&&eK(a)&&(t.result=f.apply(a,n),!1===t.result&&t.preventDefault());return t.type=v,!i&&!t.isDefaultPrevented()&&(!p._default||!1===p._default.apply(h.pop(),n))&&eK(r)&&l&&"function"==typeof r[v]&&!g(r)&&((s=r[l])&&(r[l]=null),T.event.triggered=v,t.isPropagationStopped()&&d.addEventListener(v,t9),r[v](),t.isPropagationStopped()&&d.removeEventListener(v,t9),T.event.triggered=void 0,s&&(r[l]=s)),t.result}},simulate:function(e,t,n){var r=T.extend(new T.Event,n,{type:e,isSimulated:!0});T.event.trigger(r,null,t)}}),T.fn.extend({trigger:function(e,t){return this.each(function(){T.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return T.event.trigger(e,t,n,!0)}});var t6=e.location,t8={guid:Date.now()},t7=/\?/;T.parseXML=function(t){var n,r;if(!t||"string"!=typeof t)return null;try{n=new e.DOMParser().parseFromString(t,"text/xml")}catch(e){}return r=n&&n.getElementsByTagName("parsererror")[0],(!n||r)&&T.error("Invalid XML: "+(r?T.map(r.childNodes,function(e){return e.textContent}).join("\n"):t)),n};var ne=/\[\]$/,nt=/\r?\n/g,nn=/^(?:submit|button|image|reset|file)$/i,nr=/^(?:input|select|textarea|keygen)/i;T.param=function(e,t){var n,r=[],i=function(e,t){var n="function"==typeof t?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(null==e)return"";if(Array.isArray(e)||e.jquery&&!T.isPlainObject(e))T.each(e,function(){i(this.name,this.value)});else for(n in e)!function e(t,n,r,i){var o;if(Array.isArray(n))T.each(n,function(n,o){r||ne.test(t)?i(t,o):e(t+"["+("object"==typeof o&&null!=o?n:"")+"]",o,r,i)});else if(r||"object"!==h(n))i(t,n);else for(o in n)e(t+"["+o+"]",n[o],r,i)}(n,e[n],t,i);return r.join("&")},T.fn.extend({serialize:function(){return T.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=T.prop(this,"elements");return e?T.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!T(this).is(":disabled")&&nr.test(this.nodeName)&&!nn.test(e)&&(this.checked||!tx.test(e))}).map(function(e,t){var n=T(this).val();return null==n?null:Array.isArray(n)?T.map(n,function(e){return{name:t.name,value:e.replace(nt,"\r\n")}}):{name:t.name,value:n.replace(nt,"\r\n")}}).get()}});var ni=/%20/g,no=/#.*$/,na=/([?&])_=[^&]*/,ns=/^(.*?):[ \t]*([^\r\n]*)$/mg,nu=/^(?:GET|HEAD)$/,nl=/^\/\//,nc={},nf={},np="*/".concat("*"),nd=y.createElement("a");function nh(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(Q)||[];if("function"==typeof n)while(r=o[i++])"+"===r[0]?(e[r=r.slice(1)||"*"]=e[r]||[]).unshift(n):(e[r]=e[r]||[]).push(n)}}function ng(e,t,n,r){var i={},o=e===nf;function a(s){var u;return i[s]=!0,T.each(e[s]||[],function(e,s){var l=s(t,n,r);return"string"!=typeof l||o||i[l]?o?!(u=l):void 0:(t.dataTypes.unshift(l),a(l),!1)}),u}return a(t.dataTypes[0])||!i["*"]&&a("*")}function nv(e,t){var n,r,i=T.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&T.extend(!0,e,r),e}nd.href=t6.href,T.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:t6.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(t6.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":np,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":T.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?nv(nv(e,T.ajaxSettings),t):nv(T.ajaxSettings,e)},ajaxPrefilter:nh(nc),ajaxTransport:nh(nf),ajax:function(t,n){"object"==typeof t&&(n=t,t=void 0),n=n||{};var r,i,o,a,s,u,l,c,f,p,d=T.ajaxSetup({},n),h=d.context||d,g=d.context&&(h.nodeType||h.jquery)?T(h):T.event,v=T.Deferred(),m=T.Callbacks("once memory"),x=d.statusCode||{},b={},w={},C="canceled",j={readyState:0,getResponseHeader:function(e){var t;if(l){if(!a){a={};while(t=ns.exec(o))a[t[1].toLowerCase()+" "]=(a[t[1].toLowerCase()+" "]||[]).concat(t[2])}t=a[e.toLowerCase()+" "]}return null==t?null:t.join(", ")},getAllResponseHeaders:function(){return l?o:null},setRequestHeader:function(e,t){return null==l&&(b[e=w[e.toLowerCase()]=w[e.toLowerCase()]||e]=t),this},overrideMimeType:function(e){return null==l&&(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(l)j.always(e[j.status]);else for(t in e)x[t]=[x[t],e[t]];return this},abort:function(e){var t=e||C;return r&&r.abort(t),E(0,t),this}};if(v.promise(j),d.url=((t||d.url||t6.href)+"").replace(nl,t6.protocol+"//"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=(d.dataType||"*").toLowerCase().match(Q)||[""],null==d.crossDomain){u=y.createElement("a");try{u.href=d.url,u.href=u.href,d.crossDomain=nd.protocol+"//"+nd.host!=u.protocol+"//"+u.host}catch(e){d.crossDomain=!0}}if(ng(nc,d,n,j),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=T.param(d.data,d.traditional)),l)return j;for(f in(c=T.event&&d.global)&&0==T.active++&&T.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!nu.test(d.type),i=d.url.replace(no,""),d.hasContent?d.data&&d.processData&&0===(d.contentType||"").indexOf("application/x-www-form-urlencoded")&&(d.data=d.data.replace(ni,"+")):(p=d.url.slice(i.length),d.data&&(d.processData||"string"==typeof d.data)&&(i+=(t7.test(i)?"&":"?")+d.data,delete d.data),!1===d.cache&&(i=i.replace(na,"$1"),p=(t7.test(i)?"&":"?")+"_="+t8.guid+++p),d.url=i+p),d.ifModified&&(T.lastModified[i]&&j.setRequestHeader("If-Modified-Since",T.lastModified[i]),T.etag[i]&&j.setRequestHeader("If-None-Match",T.etag[i])),(d.data&&d.hasContent&&!1!==d.contentType||n.contentType)&&j.setRequestHeader("Content-Type",d.contentType),j.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+np+"; q=0.01":""):d.accepts["*"]),d.headers)j.setRequestHeader(f,d.headers[f]);if(d.beforeSend&&(!1===d.beforeSend.call(h,j,d)||l))return j.abort();if(C="abort",m.add(d.complete),j.done(d.success),j.fail(d.error),r=ng(nf,d,n,j)){if(j.readyState=1,c&&g.trigger("ajaxSend",[j,d]),l)return j;d.async&&d.timeout>0&&(s=e.setTimeout(function(){j.abort("timeout")},d.timeout));try{l=!1,r.send(b,E)}catch(e){if(l)throw e;E(-1,e)}}else E(-1,"No Transport");function E(t,n,a,u){var f,p,y,b,w,C=n;!l&&(l=!0,s&&e.clearTimeout(s),r=void 0,o=u||"",j.readyState=4*(t>0),f=t>=200&&t<300||304===t,a&&(b=function(e,t,n){var r,i,o,a,s=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r){for(i in s)if(s[i]&&s[i].test(r)){u.unshift(i);break}}if(u[0]in n)o=u[0];else{for(i in n){if(!u[0]||e.converters[i+" "+u[0]]){o=i;break}a||(a=i)}o=o||a}if(o)return o!==u[0]&&u.unshift(o),n[o]}(d,j,a)),!f&&T.inArray("script",d.dataTypes)>-1&&0>T.inArray("json",d.dataTypes)&&(d.converters["text script"]=function(){}),b=function(e,t,n,r){var i,o,a,s,u,l={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)l[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!u&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u=o,o=c.shift()){if("*"===o)o=u;else if("*"!==u&&u!==o){if(!(a=l[u+" "+o]||l["* "+o])){for(i in l)if((s=i.split(" "))[1]===o&&(a=l[u+" "+s[0]]||l["* "+s[0]])){!0===a?a=l[i]:!0!==l[i]&&(o=s[0],c.unshift(s[1]));break}}if(!0!==a)if(a&&e.throws)t=a(t);else try{t=a(t)}catch(e){return{state:"parsererror",error:a?e:"No conversion from "+u+" to "+o}}}}return{state:"success",data:t}}(d,b,j,f),f?(d.ifModified&&((w=j.getResponseHeader("Last-Modified"))&&(T.lastModified[i]=w),(w=j.getResponseHeader("etag"))&&(T.etag[i]=w)),204===t||"HEAD"===d.type?C="nocontent":304===t?C="notmodified":(C=b.state,p=b.data,f=!(y=b.error))):(y=C,(t||!C)&&(C="error",t<0&&(t=0))),j.status=t,j.statusText=(n||C)+"",f?v.resolveWith(h,[p,C,j]):v.rejectWith(h,[j,C,y]),j.statusCode(x),x=void 0,c&&g.trigger(f?"ajaxSuccess":"ajaxError",[j,d,f?p:y]),m.fireWith(h,[j,C]),c&&(g.trigger("ajaxComplete",[j,d]),--T.active||T.event.trigger("ajaxStop")))}return j},getJSON:function(e,t,n){return T.get(e,t,n,"json")},getScript:function(e,t){return T.get(e,void 0,t,"script")}}),T.each(["get","post"],function(e,t){T[t]=function(e,n,r,i){return("function"==typeof n||null===n)&&(i=i||r,r=n,n=void 0),T.ajax(T.extend({url:e,type:t,dataType:i,data:n,success:r},T.isPlainObject(e)&&e))}}),T.ajaxPrefilter(function(e){var t;for(t in e.headers)"content-type"===t.toLowerCase()&&(e.contentType=e.headers[t]||"")}),T._evalUrl=function(e,t,n){return T.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,scriptAttrs:t.crossOrigin?{crossOrigin:t.crossOrigin}:void 0,converters:{"text script":function(){}},dataFilter:function(e){T.globalEval(e,t,n)}})},T.fn.extend({wrapAll:function(e){var t;return this[0]&&("function"==typeof e&&(e=e.call(this[0])),t=T(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstElementChild)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return"function"==typeof e?this.each(function(t){T(this).wrapInner(e.call(this,t))}):this.each(function(){var t=T(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t="function"==typeof e;return this.each(function(n){T(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){T(this).replaceWith(this.childNodes)}),this}}),T.expr.pseudos.hidden=function(e){return!T.expr.pseudos.visible(e)},T.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},T.ajaxSettings.xhr=function(){return new e.XMLHttpRequest};var ny={0:200};function nm(e){return e.scriptAttrs||!e.headers&&(e.crossDomain||e.async&&0>T.inArray("json",e.dataTypes))}T.ajaxTransport(function(e){var t;return{send:function(n,r){var i,o=e.xhr();if(o.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(i in e.xhrFields)o[i]=e.xhrFields[i];for(i in e.mimeType&&o.overrideMimeType&&o.overrideMimeType(e.mimeType),e.crossDomain||n["X-Requested-With"]||(n["X-Requested-With"]="XMLHttpRequest"),n)o.setRequestHeader(i,n[i]);t=function(e){return function(){t&&(t=o.onload=o.onerror=o.onabort=o.ontimeout=null,"abort"===e?o.abort():"error"===e?r(o.status,o.statusText):r(ny[o.status]||o.status,o.statusText,"text"===(o.responseType||"text")?{text:o.responseText}:{binary:o.response},o.getAllResponseHeaders()))}},o.onload=t(),o.onabort=o.onerror=o.ontimeout=t("error"),t=t("abort");try{o.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),T.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},converters:{"text script":function(e){return T.globalEval(e),e}}}),T.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),nm(e)&&(e.type="GET")}),T.ajaxTransport("script",function(e){if(nm(e)){var t,n;return{send:function(r,i){t=T("