画布元素工具条、媒体拖拽和多分类文章 #5
@@ -27,11 +27,13 @@ php bin/admin.php reset admin@example.com
|
|||||||
|
|
||||||
## 后台编辑
|
## 后台编辑
|
||||||
|
|
||||||
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。编辑器左侧可按分类和名称查找模板。悬停或键盘聚焦缩略图可放大,点击可打开预览。
|
- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。编辑器左侧可按分类和名称查找模板。悬停或键盘聚焦缩略图可放大,点击可打开预览。
|
||||||
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
- **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。
|
||||||
- **产品与服务**在 `/services` 显示独立的服务端 HTML 目录。后台支持添加、排序、修改和移除条目,并设置分类、封面、简介和按钮链接。
|
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
|
||||||
|
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。
|
||||||
|
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
|
||||||
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
|
||||||
- **文章与动态**使用 Markdown,支持正文预览、摘要、标签和公告、新闻、产品分类。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
|
||||||
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
|
||||||
|
|
||||||
## 生产运行
|
## 生产运行
|
||||||
@@ -68,7 +70,7 @@ location = /admin/media {
|
|||||||
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
|
| `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 |
|
||||||
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
|
| `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 |
|
||||||
|
|
||||||
SQLite 已启用 WAL。迁移服务器或做线上备份时,可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"` 取得一致备份。更新代码时保留数据库文件及其存放目录,以同一 `LAYSENSE_DB` 执行 `php bin/install.php` 应用迁移,然后重启服务。已有数据库会补回 PAGEPAN 原始功能图标,保留已编辑的文案和已有图像。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份站点时一并保存 SQLite 和媒体目录。
|
SQLite 已启用 WAL。本版需要新的 SQLite 文件。将 `LAYSENSE_DB` 指向新文件,执行 `php bin/install.php`,再按上面的步骤创建管理员并重启 Webman。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。
|
||||||
|
|
||||||
### CDN
|
### CDN
|
||||||
|
|
||||||
@@ -84,7 +86,7 @@ SQLite 已启用 WAL。迁移服务器或做线上备份时,可用 `sqlite3 st
|
|||||||
|
|
||||||
## 画布浏览器回归
|
## 画布浏览器回归
|
||||||
|
|
||||||
`tests/studio-browser.cjs` 用 Playwright 在真实 Chromium 内检查媒体及链接编辑、模板分类、搜索、预览、触屏操作和保存。使用已启动的测试实例、独立的 SQLite 数据库和管理员账户。测试会在该库创建一个草稿页面。
|
`tests/studio-browser.cjs` 用 Playwright 在真实 Chromium 内检查媒体拖拽、链接、模板预览、编辑器、文章分类和公开页面。使用已启动的测试实例、独立的 SQLite 数据库和管理员账户。测试会在该库创建页面、分类和测试文章。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
LAYSENSE_TEST_URL=http://127.0.0.1:8787 \
|
LAYSENSE_TEST_URL=http://127.0.0.1:8787 \
|
||||||
|
|||||||
@@ -6,10 +6,13 @@ namespace App\Content;
|
|||||||
|
|
||||||
final class BlockTemplates
|
final class BlockTemplates
|
||||||
{
|
{
|
||||||
|
public const ARTICLE_FEED = '{"categories":["announcement","news","product"],"mode":"merged","limit":6}';
|
||||||
|
|
||||||
public const GROUPS = [
|
public const GROUPS = [
|
||||||
'content' => ['标题与正文', [
|
'content' => ['标题与正文', [
|
||||||
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
|
'headline' => ['标题与简介', '<div class="studio-intro"><h3>填写区块标题</h3><p>用一句话补充背景或说明。</p></div>'],
|
||||||
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
'text' => ['正文', '<p>在这里输入区块内容。</p>'],
|
||||||
|
'articles' => ['分类文章', ''],
|
||||||
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
|
'list' => ['步骤列表', '<ol><li>填写第一步</li><li>填写第二步</li><li>填写第三步</li></ol>'],
|
||||||
]],
|
]],
|
||||||
'cover' => ['封面与横幅', [
|
'cover' => ['封面与横幅', [
|
||||||
|
|||||||
+27
-34
@@ -39,27 +39,24 @@ final class Database
|
|||||||
$pdo->exec('PRAGMA journal_mode = WAL');
|
$pdo->exec('PRAGMA journal_mode = WAL');
|
||||||
|
|
||||||
self::write(function (PDO $pdo) use ($root, $seed): void {
|
self::write(function (PDO $pdo) use ($root, $seed): void {
|
||||||
|
$articleColumns = array_column($pdo->query('PRAGMA table_info(articles)')->fetchAll(), 'name');
|
||||||
|
if (in_array('category', $articleColumns, true)) {
|
||||||
|
throw new RuntimeException('请将 LAYSENSE_DB 指向一个新的 SQLite 文件,再运行安装命令。');
|
||||||
|
}
|
||||||
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
$pdo->exec(file_get_contents($root . '/resources/schema.sql'));
|
||||||
$pageColumns = array_column($pdo->query('PRAGMA table_info(pages)')->fetchAll(), 'name');
|
|
||||||
if (!in_array('status', $pageColumns, true)) {
|
|
||||||
$pdo->exec("ALTER TABLE pages ADD COLUMN status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published'))");
|
|
||||||
}
|
|
||||||
if (!in_array('image_scale', $pageColumns, true)) {
|
|
||||||
$pdo->exec('ALTER TABLE pages ADD COLUMN image_scale INTEGER NOT NULL DEFAULT 0');
|
|
||||||
}
|
|
||||||
$site = $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)');
|
$site = $pdo->prepare('INSERT OR IGNORE INTO site_settings (id, payload) VALUES (1, ?)');
|
||||||
$site->execute([self::json($seed['site'])]);
|
$site->execute([self::json($seed['site'])]);
|
||||||
|
|
||||||
$pageQuery = $pdo->prepare('INSERT OR IGNORE INTO pages
|
$pageQuery = $pdo->prepare('INSERT OR IGNORE INTO pages
|
||||||
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks, partners)
|
(slug, name, title, description, heading, accent, lead, image, alt, actions, quicklinks)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
$sectionQuery = $pdo->prepare('INSERT OR IGNORE INTO sections
|
$sectionQuery = $pdo->prepare('INSERT OR IGNORE INTO sections
|
||||||
(page_slug, key, title, lead, style, body, position) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
(page_slug, key, title, lead, style, body, feed, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
foreach ($seed['pages'] as $page) {
|
foreach ($seed['pages'] as $page) {
|
||||||
$pageQuery->execute([
|
$pageQuery->execute([
|
||||||
$page['slug'], $page['name'], $page['title'], $page['description'], $page['heading'],
|
$page['slug'], $page['name'], $page['title'], $page['description'], $page['heading'],
|
||||||
$page['accent'], $page['lead'], $page['image'], $page['alt'],
|
$page['accent'], $page['lead'], $page['image'], $page['alt'],
|
||||||
self::json($page['actions']), self::json($page['quicklinks']), self::json($page['partners'] ?? []),
|
self::json($page['actions']), self::json($page['quicklinks']),
|
||||||
]);
|
]);
|
||||||
if ($pageQuery->rowCount() !== 1) {
|
if ($pageQuery->rowCount() !== 1) {
|
||||||
continue;
|
continue;
|
||||||
@@ -67,38 +64,34 @@ final class Database
|
|||||||
foreach ($page['sections'] as $index => $section) {
|
foreach ($page['sections'] as $index => $section) {
|
||||||
$sectionQuery->execute([
|
$sectionQuery->execute([
|
||||||
$page['slug'], $section['key'], $section['title'], $section['lead'],
|
$page['slug'], $section['key'], $section['title'], $section['lead'],
|
||||||
$section['style'], Html::sanitize($section['body']), $index,
|
$section['style'], Html::sanitize($section['body']), isset($section['feed']) ? self::json($section['feed']) : null, $index,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$article = $pdo->prepare('INSERT OR IGNORE INTO articles
|
$category = $pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
|
||||||
(slug, title, category, summary, body, tags, status, published_at, updated_at, legacy_path)
|
foreach (Repository::CATEGORIES as $slug => $name) {
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
$category->execute([$slug, $name]);
|
||||||
|
}
|
||||||
|
$article = $pdo->prepare("INSERT OR IGNORE INTO articles
|
||||||
|
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at, legacy_path)
|
||||||
|
SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? WHERE NOT EXISTS (SELECT 1 FROM article_redirects WHERE slug = ?)");
|
||||||
|
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
||||||
foreach ($seed['articles'] as $item) {
|
foreach ($seed['articles'] as $item) {
|
||||||
$exists = $pdo->prepare('SELECT 1 FROM article_redirects WHERE slug = ?');
|
$format = $item['body_format'] ?? 'markdown';
|
||||||
$exists->execute([$item['slug']]);
|
$date = $item['date'] ?? null;
|
||||||
if ($exists->fetchColumn()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$article->execute([
|
$article->execute([
|
||||||
$item['slug'], $item['title'], $item['category'], $item['summary'], $item['body'],
|
$item['slug'], $item['title'], $item['summary'] ?? '',
|
||||||
self::json($item['tags']), $item['status'], $item['date'], $item['date'], $item['legacy'],
|
$format === 'html' ? Html::sanitize($item['body']) : $item['body'], $format,
|
||||||
|
self::json($item['card'] ?? []), self::json($item['tags'] ?? []),
|
||||||
|
$item['status'] ?? 'published', $date, $date ?? gmdate(DATE_ATOM), $item['legacy'] ?? null, $item['slug'],
|
||||||
]);
|
]);
|
||||||
|
if ($article->rowCount() === 1) {
|
||||||
|
$id = $pdo->lastInsertId();
|
||||||
|
foreach ($item['categories'] as $slug) {
|
||||||
|
$link->execute([$id, $slug]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$migration = $pdo->prepare('INSERT OR IGNORE INTO schema_migrations (name) VALUES (?)');
|
|
||||||
$migration->execute(['restore_pagepan_feature_icons']);
|
|
||||||
if ($migration->rowCount() === 1) {
|
|
||||||
PagepanFeatureIcons::migrate($pdo);
|
|
||||||
}
|
}
|
||||||
$migration->execute(['product_directory_and_service_icons']);
|
|
||||||
if ($migration->rowCount() === 1) {
|
|
||||||
DesignMigration::apply($pdo);
|
|
||||||
}
|
|
||||||
$migration->execute(['restore_home_featured_products']);
|
|
||||||
if ($migration->rowCount() === 1) {
|
|
||||||
DesignMigration::restoreFeaturedProducts($pdo, $seed);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,83 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Content;
|
|
||||||
|
|
||||||
use DOMDocument;
|
|
||||||
use DOMElement;
|
|
||||||
use DOMXPath;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
final class DesignMigration
|
|
||||||
{
|
|
||||||
private const DIRECTORY_SUMMARY = '<p>浏览来笙的建站工具、智能 DNS 和软件著作权服务。</p><a class="button button-primary" href="/services">查看产品与服务</a>';
|
|
||||||
|
|
||||||
public static function apply(PDO $pdo): void
|
|
||||||
{
|
|
||||||
$stock = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR);
|
|
||||||
$home = array_column($stock['pages'], null, 'slug')['home'];
|
|
||||||
$stockBody = Html::sanitize(array_column($home['sections'], 'body', 'key')['product']);
|
|
||||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$doc->loadHTML('<meta charset="UTF-8">' . $stockBody, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
|
||||||
$xpath = new DOMXPath($doc);
|
|
||||||
$insert = $pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, extra_url, extra_label, position)
|
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
|
||||||
foreach ($xpath->query('//article[contains(concat(" ", @class, " "), " project ")]') as $position => $card) {
|
|
||||||
$image = $xpath->query('.//img', $card)->item(0);
|
|
||||||
$links = $xpath->query('.//a', $card);
|
|
||||||
$body = '';
|
|
||||||
foreach ($xpath->query('.//p', $card) as $paragraph) {
|
|
||||||
$body .= $doc->saveHTML($paragraph);
|
|
||||||
}
|
|
||||||
$insert->execute([
|
|
||||||
trim($xpath->evaluate('string(.//h3)', $card)), trim($xpath->evaluate('string(.//span)', $card)),
|
|
||||||
Html::sanitize($body), $image->getAttribute('src'), $image->getAttribute('alt'),
|
|
||||||
$links->item(0)->getAttribute('href'), trim($links->item(0)->textContent),
|
|
||||||
$links->item(1)?->getAttribute('href') ?? '', trim($links->item(1)?->textContent ?? ''), $position * 10,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
$pdo->prepare('INSERT INTO catalog (name, category, body, image, alt, url, label, position) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')
|
|
||||||
->execute(['SHNU 学生软著服务', '校园服务', '<p>面向 SHNU 学生的软件著作权申请服务。</p>',
|
|
||||||
'/assets/original/shnu-hero.webp', '', '/shnu-sc', '查看学生方案', 30]);
|
|
||||||
$pdo->prepare("UPDATE sections SET body = ?, version = version + 1
|
|
||||||
WHERE page_slug = 'home' AND key = 'product' AND version = 0 AND body = ?")
|
|
||||||
->execute([self::DIRECTORY_SUMMARY, $stockBody]);
|
|
||||||
|
|
||||||
$choices = $pdo->query("SELECT page_slug, body FROM sections WHERE key = 'why' AND page_slug IN ('sc', 'shnu-sc')");
|
|
||||||
$updateChoice = $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = ? AND key = 'why'");
|
|
||||||
foreach ($choices->fetchAll() as $section) {
|
|
||||||
$body = preg_replace('~(<article\b[^>]*class="[^"]*\bfeature-card)("(?:[^>]*>)\s*<h[2-4]>选择来笙</h[2-4]>)~u',
|
|
||||||
'$1 choice-card$2', $section['body']);
|
|
||||||
if ($body !== null && $body !== $section['body']) {
|
|
||||||
$updateChoice->execute([$body, $section['page_slug']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$icons = ['/assets/original/10-1.png' => '/assets/service/project.svg',
|
|
||||||
'/assets/original/10-2.png' => '/assets/service/code.svg', '/assets/original/10-3.png' => '/assets/service/support.svg'];
|
|
||||||
$sections = $pdo->query("SELECT page_slug, body FROM sections WHERE key = 'options' AND page_slug IN ('sc', 'shnu-sc')");
|
|
||||||
$update = $pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = ? AND key = 'options'");
|
|
||||||
foreach ($sections->fetchAll() as $section) {
|
|
||||||
$body = strtr($section['body'], $icons);
|
|
||||||
$body = preg_replace('/(<article\b[^>]*>)\s*<li\b[^>]*>(.*?)<\/li>\s*(<\/article>)/s', '$1$2$3', $body);
|
|
||||||
if ($body !== $section['body']) {
|
|
||||||
$update->execute([$body, $section['page_slug']]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function restoreFeaturedProducts(PDO $pdo, array $seed): void
|
|
||||||
{
|
|
||||||
$home = array_column($seed['pages'], null, 'slug')['home'];
|
|
||||||
$stockBody = Html::sanitize(array_column($home['sections'], 'body', 'key')['product']);
|
|
||||||
$doc = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$doc->loadHTML('<meta charset="UTF-8">' . $stockBody, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
|
||||||
$projects = $doc->getElementsByTagName('article');
|
|
||||||
$body = '<div class="project-stack">' . $doc->saveHTML($projects->item(0))
|
|
||||||
. $doc->saveHTML($projects->item(1)) . '</div>';
|
|
||||||
$pdo->prepare("UPDATE sections SET body = ?, version = version + 1
|
|
||||||
WHERE page_slug = 'home' AND key = 'product' AND body = ?")
|
|
||||||
->execute([Html::sanitize($body), self::DIRECTORY_SUMMARY]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,7 @@ namespace App\Content;
|
|||||||
use DOMDocument;
|
use DOMDocument;
|
||||||
use DOMElement;
|
use DOMElement;
|
||||||
use DOMNode;
|
use DOMNode;
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\GithubFlavoredMarkdownConverter;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
final class Html
|
final class Html
|
||||||
@@ -43,13 +43,18 @@ final class Html
|
|||||||
public static function markdown(string $text): string
|
public static function markdown(string $text): string
|
||||||
{
|
{
|
||||||
static $converter;
|
static $converter;
|
||||||
$converter ??= new CommonMarkConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]);
|
$converter ??= new GithubFlavoredMarkdownConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]);
|
||||||
|
|
||||||
$html = $converter->convert($text)->getContent();
|
$html = $converter->convert($text)->getContent();
|
||||||
|
|
||||||
return str_replace(['<h1>', '</h1>'], ['<h2>', '</h2>'], $html);
|
return str_replace(['<h1>', '</h1>'], ['<h2>', '</h2>'], $html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function 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
|
public static function applyCanvasEdits(string $body, array $edits): string
|
||||||
{
|
{
|
||||||
if (!array_is_list($edits) || count($edits) > 512) {
|
if (!array_is_list($edits) || count($edits) > 512) {
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace App\Content;
|
|
||||||
|
|
||||||
use DOMDocument;
|
|
||||||
use DOMElement;
|
|
||||||
use DOMXPath;
|
|
||||||
use PDO;
|
|
||||||
|
|
||||||
final class PagepanFeatureIcons
|
|
||||||
{
|
|
||||||
public static function migrate(PDO $pdo): void
|
|
||||||
{
|
|
||||||
$query = $pdo->query("SELECT body FROM sections WHERE page_slug = 'pagepan' AND key = 'features'");
|
|
||||||
$body = $query->fetchColumn();
|
|
||||||
if (!is_string($body) || $body === '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$paths = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/pagepan-feature-icons.json'), true, flags: JSON_THROW_ON_ERROR);
|
|
||||||
$document = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$document->loadHTML('<!DOCTYPE html><html><head><meta charset="UTF-8"></head><body>' . $body . '</body></html>', LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
|
|
||||||
$xpath = new DOMXPath($document);
|
|
||||||
|
|
||||||
$changed = false;
|
|
||||||
foreach ($xpath->query('//article[contains(concat(" ", normalize-space(@class), " "), " feature-card ")]') as $card) {
|
|
||||||
$heading = $xpath->query('(./h2 | ./h3 | ./h4)[1]', $card)->item(0);
|
|
||||||
if (!$heading instanceof DOMElement || $card->getElementsByTagName('img')->length > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$title = trim($heading->textContent);
|
|
||||||
if (!isset($paths[$title])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$icon = $document->createElement('img');
|
|
||||||
foreach (['src' => $paths[$title], 'alt' => '', 'width' => '50', 'height' => '50', 'loading' => 'lazy'] as $key => $value) {
|
|
||||||
$icon->setAttribute($key, $value);
|
|
||||||
}
|
|
||||||
$card->insertBefore($icon, $card->firstChild);
|
|
||||||
$changed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($changed) {
|
|
||||||
$updated = '';
|
|
||||||
foreach ($document->getElementsByTagName('body')->item(0)->childNodes as $child) {
|
|
||||||
$updated .= $document->saveHTML($child);
|
|
||||||
}
|
|
||||||
$pdo->prepare("UPDATE sections SET body = ?, version = version + 1 WHERE page_slug = 'pagepan' AND key = 'features'")
|
|
||||||
->execute([trim($updated)]);
|
|
||||||
$pdo->prepare("UPDATE pages SET updated_at = ? WHERE slug = 'pagepan'")
|
|
||||||
->execute([(new \DateTimeImmutable('now', new \DateTimeZone('Asia/Shanghai')))->format('Y-m-d H:i:s')]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+69
-30
@@ -9,7 +9,13 @@ use RuntimeException;
|
|||||||
|
|
||||||
final class Repository
|
final class Repository
|
||||||
{
|
{
|
||||||
public const CATEGORIES = ['announcement' => '公告', 'news' => '新闻', 'product' => '产品'];
|
public const DIRECTORIES = [
|
||||||
|
'services' => '产品与服务', 'supported-projects' => '来笙支持项目', 'partners' => '来笙合作伙伴',
|
||||||
|
];
|
||||||
|
public const CATEGORIES = ['announcement' => '公告', 'news' => '新闻', 'product' => '产品'] + self::DIRECTORIES;
|
||||||
|
private const ARTICLE_FIELDS = 'articles.*, (SELECT json_group_object(c.slug, c.name)
|
||||||
|
FROM article_category_links l JOIN article_categories c ON c.slug = l.category_slug
|
||||||
|
WHERE l.article_id = articles.id) AS categories';
|
||||||
private PDO $pdo;
|
private PDO $pdo;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -32,8 +38,8 @@ final class Repository
|
|||||||
public function createPage(string $slug, string $name): void
|
public function createPage(string $slug, string $name): void
|
||||||
{
|
{
|
||||||
$query = $this->pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
|
$query = $this->pdo->prepare("INSERT OR IGNORE INTO pages (slug, name, title, description, heading, accent,
|
||||||
lead, image, alt, actions, quicklinks, partners, status, updated_at)
|
lead, image, alt, actions, quicklinks, status, updated_at)
|
||||||
VALUES (?, ?, ?, '', ?, '', '', '', '', '[]', '[]', '[]', 'draft', ?)");
|
VALUES (?, ?, ?, '', ?, '', '', '', '', '[]', '[]', 'draft', ?)");
|
||||||
$query->execute([$slug, $name, $name . ' · 来笙', $name, self::now()]);
|
$query->execute([$slug, $name, $name . ' · 来笙', $name, self::now()]);
|
||||||
if ($query->rowCount() !== 1) {
|
if ($query->rowCount() !== 1) {
|
||||||
throw new RuntimeException('此页面地址已存在。');
|
throw new RuntimeException('此页面地址已存在。');
|
||||||
@@ -46,7 +52,7 @@ final class Repository
|
|||||||
if (!$page) {
|
if (!$page) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
foreach (['actions', 'quicklinks', 'partners'] as $key) {
|
foreach (['actions', 'quicklinks'] as $key) {
|
||||||
$page[$key] = json_decode($page[$key], true, flags: JSON_THROW_ON_ERROR);
|
$page[$key] = json_decode($page[$key], true, flags: JSON_THROW_ON_ERROR);
|
||||||
}
|
}
|
||||||
$query = $this->pdo->prepare('SELECT * FROM sections WHERE page_slug = ? ORDER BY position, key');
|
$query = $this->pdo->prepare('SELECT * FROM sections WHERE page_slug = ? ORDER BY position, key');
|
||||||
@@ -92,25 +98,25 @@ final class Repository
|
|||||||
|
|
||||||
private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
|
private static function updateSection(PDO $pdo, string $page, string $key, array $data, int $version): void
|
||||||
{
|
{
|
||||||
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, version = version + 1
|
$query = $pdo->prepare('UPDATE sections SET title = ?, lead = ?, body = ?, style = ?, feed = ?, version = version + 1
|
||||||
WHERE page_slug = ? AND key = ? AND version = ?');
|
WHERE page_slug = ? AND key = ? AND version = ?');
|
||||||
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $page, $key, $version]);
|
$query->execute([$data['title'], $data['lead'], $data['body'], $data['style'], $data['feed'] ?? null, $page, $key, $version]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSection(string $page, string $key, string $title, string $style, string $body): void
|
public function createSection(string $page, string $key, string $title, string $style, string $body, ?string $feed = null): void
|
||||||
{
|
{
|
||||||
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body): void {
|
Database::write(function (PDO $pdo) use ($page, $key, $title, $style, $body, $feed): void {
|
||||||
self::insertSection($pdo, $page, $key, compact('title', 'style', 'body') + ['lead' => '']);
|
self::insertSection($pdo, $page, $key, compact('title', 'style', 'body', 'feed') + ['lead' => '']);
|
||||||
self::touchPage($pdo, $page, structureChanged: true);
|
self::touchPage($pdo, $page, structureChanged: true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function insertSection(PDO $pdo, string $page, string $key, array $data): void
|
private static function insertSection(PDO $pdo, string $page, string $key, array $data): void
|
||||||
{
|
{
|
||||||
$query = $pdo->prepare('INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, position)
|
$query = $pdo->prepare('INSERT OR IGNORE INTO sections (page_slug, key, title, lead, style, body, feed, position)
|
||||||
SELECT ?, ?, ?, ?, ?, ?, COALESCE(MAX(position), -1) + 1 FROM sections WHERE page_slug = ?');
|
SELECT ?, ?, ?, ?, ?, ?, ?, COALESCE(MAX(position), -1) + 1 FROM sections WHERE page_slug = ?');
|
||||||
$query->execute([$page, $key, $data['title'], $data['lead'], $data['style'], $data['body'], $page]);
|
$query->execute([$page, $key, $data['title'], $data['lead'], $data['style'], $data['body'], $data['feed'] ?? null, $page]);
|
||||||
if ($query->rowCount() !== 1) {
|
if ($query->rowCount() !== 1) {
|
||||||
throw new RuntimeException('此区块锚点已被使用。');
|
throw new RuntimeException('此区块锚点已被使用。');
|
||||||
}
|
}
|
||||||
@@ -159,23 +165,44 @@ final class Repository
|
|||||||
$pdo->prepare('UPDATE pages SET updated_at = ?' . $revision . ' WHERE slug = ?')->execute([self::now(), $slug]);
|
$pdo->prepare('UPDATE pages SET updated_at = ?' . $revision . ' WHERE slug = ?')->execute([self::now(), $slug]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articles(?string $category = null, ?string $tag = null, bool $public = true, int $limit = 30, int $offset = 0): array
|
public function categories(): array
|
||||||
{
|
{
|
||||||
$sql = 'SELECT * FROM articles WHERE 1 = 1';
|
return $this->pdo->query('SELECT slug, name FROM article_categories ORDER BY rowid')->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createCategory(string $slug, string $name): void
|
||||||
|
{
|
||||||
|
$query = $this->pdo->prepare('INSERT OR IGNORE INTO article_categories (slug, name) VALUES (?, ?)');
|
||||||
|
$query->execute([$slug, $name]);
|
||||||
|
if ($query->rowCount() !== 1) {
|
||||||
|
throw new RuntimeException('此分类网址标识已被使用。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function articles(string|array|null $category = null, ?string $tag = null, bool $public = true,
|
||||||
|
int $limit = 30, int $offset = 0, bool $directoryOrder = false): array
|
||||||
|
{
|
||||||
|
if ($category === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
$sql = 'SELECT ' . self::ARTICLE_FIELDS . ' FROM articles WHERE 1 = 1';
|
||||||
$args = [];
|
$args = [];
|
||||||
if ($public) {
|
if ($public) {
|
||||||
$sql .= " AND status = 'published' AND published_at IS NOT NULL";
|
$sql .= " AND status = 'published'";
|
||||||
}
|
}
|
||||||
if ($category !== null) {
|
if ($category !== null) {
|
||||||
$sql .= ' AND category = ?';
|
$args = (array) $category;
|
||||||
$args[] = $category;
|
$marks = implode(', ', array_fill(0, count($args), '?'));
|
||||||
|
$sql .= " AND EXISTS (SELECT 1 FROM article_category_links
|
||||||
|
WHERE article_id = articles.id AND category_slug IN ($marks))";
|
||||||
}
|
}
|
||||||
if ($tag !== null) {
|
if ($tag !== null) {
|
||||||
$sql .= ' AND EXISTS (SELECT 1 FROM json_each(articles.tags) WHERE value = ?)';
|
$sql .= ' AND EXISTS (SELECT 1 FROM json_each(articles.tags) WHERE value = ?)';
|
||||||
$args[] = $tag;
|
$args[] = $tag;
|
||||||
}
|
}
|
||||||
$order = $public ? 'published_at' : 'updated_at';
|
$order = $public ? 'published_at' : 'updated_at';
|
||||||
$query = $this->pdo->prepare($sql . ' ORDER BY ' . $order . ' DESC, id DESC LIMIT ? OFFSET ?');
|
$order = $directoryOrder ? "COALESCE(json_extract(card, '$.position'), 0), id" : "$order DESC, id DESC";
|
||||||
|
$query = $this->pdo->prepare($sql . ' ORDER BY ' . $order . ' LIMIT ? OFFSET ?');
|
||||||
$query->execute([...$args, $limit, $offset]);
|
$query->execute([...$args, $limit, $offset]);
|
||||||
|
|
||||||
return array_map(self::decodeArticle(...), $query->fetchAll());
|
return array_map(self::decodeArticle(...), $query->fetchAll());
|
||||||
@@ -183,12 +210,12 @@ final class Repository
|
|||||||
|
|
||||||
public function articleById(int $id): ?array
|
public function articleById(int $id): ?array
|
||||||
{
|
{
|
||||||
return self::decodeArticle($this->one('SELECT * FROM articles WHERE id = ?', [$id]));
|
return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . ' FROM articles WHERE id = ?', [$id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function published(string $slug): ?array
|
public function published(string $slug): ?array
|
||||||
{
|
{
|
||||||
return self::decodeArticle($this->one("SELECT * FROM articles WHERE slug = ? AND status = 'published'", [$slug]));
|
return self::decodeArticle($this->one('SELECT ' . self::ARTICLE_FIELDS . " FROM articles WHERE slug = ? AND status = 'published'", [$slug]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function articleRedirect(string $slug): ?array
|
public function articleRedirect(string $slug): ?array
|
||||||
@@ -215,26 +242,34 @@ final class Repository
|
|||||||
if (($existing && $existing['id'] !== $id) || ($redirect && $redirect['article_id'] !== $id)) {
|
if (($existing && $existing['id'] !== $id) || ($redirect && $redirect['article_id'] !== $id)) {
|
||||||
throw new RuntimeException('此网址标识已被使用。');
|
throw new RuntimeException('此网址标识已被使用。');
|
||||||
}
|
}
|
||||||
$publishedAt = $old['published_at'] ?? ($data['status'] === 'published' ? self::now() : null);
|
$publishedAt = $old['published_at'] ?? ($data['status'] === 'published' && ($old['status'] ?? '') !== 'published' ? self::now() : null);
|
||||||
$values = [
|
$values = [
|
||||||
$data['slug'], $data['title'], $data['category'], $data['summary'], $data['body'],
|
$data['slug'], $data['title'], $data['summary'], $data['body'],
|
||||||
|
$data['body_format'], Database::json($data['card']),
|
||||||
Database::json($data['tags']), $data['status'], $publishedAt, self::now(),
|
Database::json($data['tags']), $data['status'], $publishedAt, self::now(),
|
||||||
];
|
];
|
||||||
if ($id === null) {
|
if ($id === null) {
|
||||||
$query = $pdo->prepare('INSERT INTO articles
|
$query = $pdo->prepare('INSERT INTO articles
|
||||||
(slug, title, category, summary, body, tags, status, published_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
(slug, title, summary, body, body_format, card, tags, status, published_at, updated_at)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
|
||||||
$query->execute($values);
|
$query->execute($values);
|
||||||
|
$id = (int) $pdo->lastInsertId();
|
||||||
return (int) $pdo->lastInsertId();
|
} else {
|
||||||
}
|
|
||||||
if ($old['slug'] !== $data['slug']) {
|
if ($old['slug'] !== $data['slug']) {
|
||||||
$pdo->prepare('DELETE FROM article_redirects WHERE slug = ? AND article_id = ?')->execute([$data['slug'], $id]);
|
$pdo->prepare('DELETE FROM article_redirects WHERE slug = ? AND article_id = ?')->execute([$data['slug'], $id]);
|
||||||
$pdo->prepare('INSERT INTO article_redirects (slug, article_id) VALUES (?, ?)')->execute([$old['slug'], $id]);
|
$pdo->prepare('INSERT INTO article_redirects (slug, article_id) VALUES (?, ?)')->execute([$old['slug'], $id]);
|
||||||
}
|
}
|
||||||
$query = $pdo->prepare('UPDATE articles SET slug = ?, title = ?, category = ?, summary = ?, body = ?, tags = ?,
|
$query = $pdo->prepare('UPDATE articles SET slug = ?, title = ?, summary = ?, body = ?,
|
||||||
status = ?, published_at = ?, updated_at = ?, version = version + 1 WHERE id = ? AND version = ?');
|
body_format = ?, card = ?, tags = ?, status = ?, published_at = ?, updated_at = ?, version = version + 1
|
||||||
|
WHERE id = ? AND version = ?');
|
||||||
$query->execute([...$values, $id, $version]);
|
$query->execute([...$values, $id, $version]);
|
||||||
self::checkVersion($query->rowCount());
|
self::checkVersion($query->rowCount());
|
||||||
|
$pdo->prepare('DELETE FROM article_category_links WHERE article_id = ?')->execute([$id]);
|
||||||
|
}
|
||||||
|
$link = $pdo->prepare('INSERT INTO article_category_links (article_id, category_slug) VALUES (?, ?)');
|
||||||
|
foreach ($data['categories'] as $category) {
|
||||||
|
$link->execute([$id, $category]);
|
||||||
|
}
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
});
|
});
|
||||||
@@ -242,7 +277,9 @@ final class Repository
|
|||||||
|
|
||||||
public function sitemapArticles(): iterable
|
public function sitemapArticles(): iterable
|
||||||
{
|
{
|
||||||
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published' AND trim(body) <> '' ORDER BY slug");
|
$query = $this->pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'
|
||||||
|
AND (trim(body) <> '' OR trim(summary) <> '' OR json_extract(card, '$.image') <> '' OR json_extract(card, '$.url') <> '')
|
||||||
|
ORDER BY slug");
|
||||||
yield from $query;
|
yield from $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,7 +334,9 @@ final class Repository
|
|||||||
private static function decodeArticle(?array $article): ?array
|
private static function decodeArticle(?array $article): ?array
|
||||||
{
|
{
|
||||||
if ($article !== null) {
|
if ($article !== null) {
|
||||||
$article['tags'] = json_decode($article['tags'], true, flags: JSON_THROW_ON_ERROR);
|
foreach (['tags', 'categories', 'card'] as $field) {
|
||||||
|
$article[$field] = json_decode($article[$field], true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $article;
|
return $article;
|
||||||
|
|||||||
@@ -58,50 +58,4 @@ final class SiteDesign
|
|||||||
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
$pdo->prepare('UPDATE site_settings SET payload = ? WHERE id = 1')->execute([Database::json($site)]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function catalog(): array
|
|
||||||
{
|
|
||||||
return Database::connect()->query('SELECT * FROM catalog ORDER BY position, id')->fetchAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function product(int $id): ?array
|
|
||||||
{
|
|
||||||
$query = Database::connect()->prepare('SELECT * FROM catalog WHERE id = ?');
|
|
||||||
$query->execute([$id]);
|
|
||||||
|
|
||||||
return $query->fetch() ?: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function saveProduct(?int $id, array $product, int $version): int
|
|
||||||
{
|
|
||||||
$pdo = Database::connect();
|
|
||||||
$fields = ['name', 'category', 'body', 'image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'position'];
|
|
||||||
$values = array_map(static fn (string $field) => $product[$field], $fields);
|
|
||||||
if ($id === null) {
|
|
||||||
$pdo->prepare('INSERT INTO catalog (' . implode(', ', $fields) . ') VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')
|
|
||||||
->execute($values);
|
|
||||||
|
|
||||||
return (int) $pdo->lastInsertId();
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $pdo->prepare('UPDATE catalog SET ' . implode(' = ?, ', $fields) . ' = ?, version = version + 1 WHERE id = ? AND version = ?');
|
|
||||||
$query->execute([...$values, $id, $version]);
|
|
||||||
self::checkProduct($query->rowCount());
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function deleteProduct(int $id, int $version): void
|
|
||||||
{
|
|
||||||
$query = Database::connect()->prepare('DELETE FROM catalog WHERE id = ? AND version = ?');
|
|
||||||
$query->execute([$id, $version]);
|
|
||||||
self::checkProduct($query->rowCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static function checkProduct(int $count): void
|
|
||||||
{
|
|
||||||
if ($count !== 1) {
|
|
||||||
throw new RuntimeException('此项目已在另一页面更新,请重新打开。');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,16 @@ final class View
|
|||||||
$html = self::fragment($template, $data);
|
$html = self::fragment($template, $data);
|
||||||
$page = Assets::rewrite(self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]), $cdn);
|
$page = Assets::rewrite(self::fragment($admin ? 'admin-layout' : 'layout', $data + ['content' => $html]), $cdn);
|
||||||
$assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
|
$assetSources = $cdn === '' ? "'self'" : "'self' " . $cdn;
|
||||||
|
$articleEditor = $admin && !empty($data['articleEditor']);
|
||||||
|
$editorImages = $articleEditor ? ' data:' : '';
|
||||||
|
$editorStyles = $articleEditor ? "style-src-attr 'unsafe-inline'; " : '';
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Type' => 'text/html; charset=utf-8',
|
'Content-Type' => 'text/html; charset=utf-8',
|
||||||
'X-Content-Type-Options' => 'nosniff',
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
'Referrer-Policy' => 'strict-origin-when-cross-origin',
|
'Referrer-Policy' => 'strict-origin-when-cross-origin',
|
||||||
'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
|
'X-Frame-Options' => !empty($data['previewMode']) ? 'SAMEORIGIN' : 'DENY',
|
||||||
'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:; media-src 'self' https:; "
|
'Content-Security-Policy' => "default-src 'self'; img-src 'self' https:$editorImages; media-src 'self' https:; "
|
||||||
. "style-src $assetSources; script-src $assetSources; font-src $assetSources; frame-src 'self'; frame-ancestors "
|
. "style-src $assetSources; {$editorStyles}script-src $assetSources; font-src $assetSources; frame-src 'self'; frame-ancestors "
|
||||||
. (!empty($data['previewMode']) ? "'self'" : "'none'") . "; form-action 'self'; base-uri 'none'; object-src 'none'",
|
. (!empty($data['previewMode']) ? "'self'" : "'none'") . "; form-action 'self'; base-uri 'none'; object-src 'none'",
|
||||||
];
|
];
|
||||||
if ($admin || !empty($data['previewMode'])) {
|
if ($admin || !empty($data['previewMode'])) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Content\BlockTemplates;
|
||||||
use App\Content\Database;
|
use App\Content\Database;
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\Passwords;
|
use App\Content\Passwords;
|
||||||
@@ -125,22 +126,58 @@ class AdminController
|
|||||||
return $failure;
|
return $failure;
|
||||||
}
|
}
|
||||||
$page = max(1, min(10000, (int) $request->get('page', 1)));
|
$page = max(1, min(10000, (int) $request->get('page', 1)));
|
||||||
$articles = (new Repository())->articles(public: false, limit: 31, offset: ($page - 1) * 30);
|
$repo = new Repository();
|
||||||
|
$categories = $repo->categories();
|
||||||
|
$category = $request->get('category');
|
||||||
|
$category = is_string($category) && isset($categories[$category]) ? $category : null;
|
||||||
|
$articles = $repo->articles($category, public: false, limit: 31, offset: ($page - 1) * 30);
|
||||||
|
|
||||||
return $this->render($request, 'admin-articles', [
|
return $this->render($request, 'admin-articles', [
|
||||||
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page, 'hasNext' => count($articles) > 30,
|
'title' => '文章与动态', 'articles' => array_slice($articles, 0, 30), 'pageNumber' => $page,
|
||||||
|
'hasNext' => count($articles) > 30, 'categories' => $categories, 'category' => $category,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function articleCategories(Request $request): Response
|
||||||
|
{
|
||||||
|
if ($failure = $this->guard($request)) {
|
||||||
|
return $failure;
|
||||||
|
}
|
||||||
|
$repo = new Repository();
|
||||||
|
$name = $slug = $error = '';
|
||||||
|
if ($request->method() === 'POST') {
|
||||||
|
$slug = $this->input($request, 'slug');
|
||||||
|
$name = $this->input($request, 'name');
|
||||||
|
try {
|
||||||
|
if (!preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $slug) || strlen($slug) > 60 || $name === '' || mb_strlen($name) > 60) {
|
||||||
|
throw new RuntimeException('请填写分类名称及网址标识。');
|
||||||
|
}
|
||||||
|
$repo->createCategory($slug, $name);
|
||||||
|
|
||||||
|
return $this->success($request, '/admin/article-categories?saved=1');
|
||||||
|
} catch (RuntimeException $exception) {
|
||||||
|
$error = $this->validationMessage($exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render($request, 'admin-article-categories', [
|
||||||
|
'title' => '文章分类', 'categories' => $repo->categories(), 'name' => $name, 'slug' => $slug,
|
||||||
|
'error' => $error, 'saved' => $request->get('saved') === '1',
|
||||||
|
], $error === '' ? 200 : 422);
|
||||||
|
}
|
||||||
|
|
||||||
public function article(Request $request, ?string $id = null): Response
|
public function article(Request $request, ?string $id = null): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
return $failure;
|
return $failure;
|
||||||
}
|
}
|
||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
|
$categories = $repo->categories();
|
||||||
|
$preset = $request->get('category');
|
||||||
|
$preset = is_string($preset) && isset($categories[$preset]) ? $preset : 'news';
|
||||||
$article = $id !== null ? $repo->articleById((int) $id) : [
|
$article = $id !== null ? $repo->articleById((int) $id) : [
|
||||||
'title' => '', 'slug' => '', 'summary' => '', 'category' => 'news', 'body' => '',
|
'title' => '', 'slug' => '', 'summary' => '', 'body' => '', 'body_format' => 'markdown',
|
||||||
'tags' => [], 'status' => 'draft', 'version' => 0,
|
'categories' => [$preset => $categories[$preset]], 'card' => [], 'tags' => [], 'status' => 'draft', 'version' => 0,
|
||||||
];
|
];
|
||||||
if (!$article) {
|
if (!$article) {
|
||||||
return $this->error($request, '找不到这篇文章。', 404);
|
return $this->error($request, '找不到这篇文章。', 404);
|
||||||
@@ -148,16 +185,26 @@ class AdminController
|
|||||||
$error = '';
|
$error = '';
|
||||||
if ($request->method() === 'POST') {
|
if ($request->method() === 'POST') {
|
||||||
$data = $this->articleInput($request);
|
$data = $this->articleInput($request);
|
||||||
$article = array_replace($article, $data, ['version' => $this->version($request)]);
|
$article = array_replace($article, $data, [
|
||||||
|
'categories' => array_intersect_key($categories, array_flip($data['categories'])),
|
||||||
|
'version' => $this->version($request),
|
||||||
|
]);
|
||||||
try {
|
try {
|
||||||
if (mb_strlen($data['title']) < 1 || mb_strlen($data['title']) > 120
|
if (mb_strlen($data['title']) < 1 || mb_strlen($data['title']) > 120
|
||||||
|| !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $data['slug']) || strlen($data['slug']) > 100
|
|| !preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $data['slug']) || strlen($data['slug']) > 100
|
||||||
|| mb_strlen($data['summary']) > 250 || strlen($data['body']) > 200000
|
|| mb_strlen($data['summary']) > 250 || strlen($data['body']) > 200000
|
||||||
|| !isset(Repository::CATEGORIES[$data['category']])
|
|| $data['categories'] === [] || array_diff($data['categories'], array_keys($categories))
|
||||||
|
|| !in_array($data['body_format'], ['markdown', 'html'], true)
|
||||||
|| !in_array($data['status'], ['draft', 'published'], true)) {
|
|| !in_array($data['status'], ['draft', 'published'], true)) {
|
||||||
throw new RuntimeException('请检查标题、网址标识、分类、摘要和正文长度。');
|
throw new RuntimeException('请检查标题、网址标识、分类、摘要和正文长度。');
|
||||||
}
|
}
|
||||||
if ($data['status'] === 'published' && trim(Html::markdown($data['body'])) === '') {
|
$this->checkArticleCard($data['card']);
|
||||||
|
if ($data['body_format'] === 'html') {
|
||||||
|
$data['body'] = Html::sanitize($data['body']);
|
||||||
|
}
|
||||||
|
if ($data['status'] === 'published' && trim(Html::articleBody($data)) === ''
|
||||||
|
&& (!array_intersect($data['categories'], array_keys(Repository::DIRECTORIES))
|
||||||
|
|| ($data['summary'] === '' && empty($data['card']['url']) && empty($data['card']['image'])))) {
|
||||||
throw new RuntimeException('发布前请填写文章正文。');
|
throw new RuntimeException('发布前请填写文章正文。');
|
||||||
}
|
}
|
||||||
$saved = $repo->saveArticle($id === null ? null : (int) $id, $data, $this->version($request));
|
$saved = $repo->saveArticle($id === null ? null : (int) $id, $data, $this->version($request));
|
||||||
@@ -170,7 +217,7 @@ class AdminController
|
|||||||
|
|
||||||
return $this->render($request, 'admin-article', [
|
return $this->render($request, 'admin-article', [
|
||||||
'title' => $id === null ? '新建文章' : '编辑文章', 'article' => $article, 'error' => $error,
|
'title' => $id === null ? '新建文章' : '编辑文章', 'article' => $article, 'error' => $error,
|
||||||
'articleId' => $id, 'saved' => $request->get('saved') === '1',
|
'articleId' => $id, 'categories' => $categories, 'articleEditor' => true, 'saved' => $request->get('saved') === '1',
|
||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,7 +261,7 @@ class AdminController
|
|||||||
($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
|
($data['status'] === 'published' && $data['description'] === '') || mb_strlen($data['description']) > 300 ||
|
||||||
$data['heading'] === '' || mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
$data['heading'] === '' || mb_strlen($data['heading'] . $data['accent']) > 110 ||
|
||||||
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
|
mb_strlen($data['lead']) > 600 || mb_strlen($data['alt']) > 200 ||
|
||||||
!in_array($data['image_scale'], [0, 25, 40, 50, 60, 75, 85, 100], true) ||
|
($data['image_scale'] !== 0 && ($data['image_scale'] < 10 || $data['image_scale'] > 100)) ||
|
||||||
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true)) || !$validButtons) {
|
strlen($data['image']) > 1000 || ($data['image'] !== '' && !Html::url($data['image'], true)) || !$validButtons) {
|
||||||
throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
|
throw new RuntimeException('请检查页面标题、说明、图片地址和按钮链接。');
|
||||||
}
|
}
|
||||||
@@ -243,15 +290,20 @@ class AdminController
|
|||||||
return $this->error($request, '找不到此区块。', 404);
|
return $this->error($request, '找不到此区块。', 404);
|
||||||
}
|
}
|
||||||
$savedStyle = $section['style'];
|
$savedStyle = $section['style'];
|
||||||
|
$categories = $repo->categories();
|
||||||
$error = '';
|
$error = '';
|
||||||
if ($request->method() === 'POST') {
|
if ($request->method() === 'POST') {
|
||||||
$data = [
|
$data = [
|
||||||
'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
|
'title' => $this->input($request, 'title'), 'lead' => $this->input($request, 'lead'),
|
||||||
'body' => $this->input($request, 'body'),
|
'body' => $this->input($request, 'body'),
|
||||||
'style' => $request->post('style') === null ? $section['style'] : $this->input($request, 'style'),
|
'style' => $request->post('style') === null ? $section['style'] : $this->input($request, 'style'),
|
||||||
|
'feed' => $section['feed'],
|
||||||
];
|
];
|
||||||
$section = array_replace($section, $data, ['version' => $this->version($request)]);
|
$section = array_replace($section, $data, ['version' => $this->version($request)]);
|
||||||
try {
|
try {
|
||||||
|
if ($request->post('feed_mode') !== null) {
|
||||||
|
$data['feed'] = $section['feed'] = $this->feedInput($request, $categories);
|
||||||
|
}
|
||||||
$this->checkSection($data, $savedStyle);
|
$this->checkSection($data, $savedStyle);
|
||||||
$data['body'] = Html::sanitize($data['body']);
|
$data['body'] = Html::sanitize($data['body']);
|
||||||
$repo->saveSection($slug, $key, $data, $this->version($request));
|
$repo->saveSection($slug, $key, $data, $this->version($request));
|
||||||
@@ -263,7 +315,7 @@ class AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($request, 'admin-section', [
|
return $this->render($request, 'admin-section', [
|
||||||
'title' => '编辑区块', 'section' => $section, 'savedStyle' => $savedStyle, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
'title' => '编辑区块', 'section' => $section, 'categories' => $categories, 'savedStyle' => $savedStyle, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
||||||
], $error !== '' ? 422 : 200);
|
], $error !== '' ? 422 : 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,6 +357,9 @@ class AdminController
|
|||||||
if (isset($fields['body'])) {
|
if (isset($fields['body'])) {
|
||||||
$section['body'] = Html::sanitize($section['body']);
|
$section['body'] = Html::sanitize($section['body']);
|
||||||
}
|
}
|
||||||
|
if ($isNew && ($change['template'] ?? null) === 'articles') {
|
||||||
|
$section['feed'] = BlockTemplates::ARTICLE_FEED;
|
||||||
|
}
|
||||||
$section['version'] = $version;
|
$section['version'] = $version;
|
||||||
$updates[$key] = $section;
|
$updates[$key] = $section;
|
||||||
}
|
}
|
||||||
@@ -423,9 +478,14 @@ class AdminController
|
|||||||
private function articleInput(Request $request): array
|
private function articleInput(Request $request): array
|
||||||
{
|
{
|
||||||
$data = [];
|
$data = [];
|
||||||
foreach (['title', 'slug', 'category', 'summary', 'body', 'status'] as $key) {
|
foreach (['title', 'slug', 'summary', 'body', 'status'] as $key) {
|
||||||
$data[$key] = $this->input($request, $key);
|
$data[$key] = $this->input($request, $key);
|
||||||
}
|
}
|
||||||
|
$data['body_format'] = $this->input($request, 'body_format');
|
||||||
|
$data['categories'] = $this->selectedCategories($request->post('categories'));
|
||||||
|
foreach (['image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'category_label', 'position'] as $field) {
|
||||||
|
$data['card'][$field] = $this->input($request, 'card_' . $field);
|
||||||
|
}
|
||||||
$tags = preg_split('/[,,\r\n]+/u', $this->input($request, 'tags'));
|
$tags = preg_split('/[,,\r\n]+/u', $this->input($request, 'tags'));
|
||||||
$data['tags'] = array_values(array_unique(array_slice(array_filter(
|
$data['tags'] = array_values(array_unique(array_slice(array_filter(
|
||||||
array_map('trim', $tags),
|
array_map('trim', $tags),
|
||||||
@@ -435,6 +495,45 @@ class AdminController
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkArticleCard(array &$card): void
|
||||||
|
{
|
||||||
|
foreach (['image', 'url', 'extra_url'] as $field) {
|
||||||
|
if (!empty($card[$field]) && (strlen($card[$field]) > 2000 || !Html::url($card[$field], $field === 'image'))) {
|
||||||
|
throw new RuntimeException('请检查目录卡片的媒体地址和链接。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (['alt', 'label', 'extra_label', 'category_label'] as $field) {
|
||||||
|
if (mb_strlen($card[$field] ?? '') > 120) {
|
||||||
|
throw new RuntimeException('目录卡片的文字不得超过 120 字。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$position = filter_var(($card['position'] ?? '') === '' ? 0 : $card['position'], FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 9999]]);
|
||||||
|
if ($position === false) {
|
||||||
|
throw new RuntimeException('目录排序应为 0 到 9999 的整数。');
|
||||||
|
}
|
||||||
|
$card['position'] = $position;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectedCategories(mixed $input): array
|
||||||
|
{
|
||||||
|
return is_array($input) ? array_values(array_unique(array_filter($input, 'is_string'))) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function feedInput(Request $request, array $available): ?string
|
||||||
|
{
|
||||||
|
$mode = $this->input($request, 'feed_mode');
|
||||||
|
if ($mode === 'off') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$categories = $this->selectedCategories($request->post('feed_categories'));
|
||||||
|
$limit = filter_var($this->input($request, 'feed_limit'), FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]);
|
||||||
|
if (!in_array($mode, ['merged', 'tabs'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) {
|
||||||
|
throw new RuntimeException('请选择文章分类,并将展示数量设为 1 至 30。');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Database::json(compact('categories', 'mode', 'limit'));
|
||||||
|
}
|
||||||
|
|
||||||
protected function validationMessage(RuntimeException $exception): string
|
protected function validationMessage(RuntimeException $exception): string
|
||||||
{
|
{
|
||||||
if ($exception instanceof \PDOException) {
|
if ($exception instanceof \PDOException) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ namespace App\Controller;
|
|||||||
|
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\Repository;
|
use App\Content\Repository;
|
||||||
use App\Content\SiteDesign;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
@@ -32,6 +31,22 @@ final class SiteController
|
|||||||
{
|
{
|
||||||
$slug = $page['slug'];
|
$slug = $page['slug'];
|
||||||
$isHome = $slug === 'home';
|
$isHome = $slug === 'home';
|
||||||
|
$categories = $repo->categories();
|
||||||
|
foreach ($page['sections'] as &$section) {
|
||||||
|
if (!$section['feed']) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR);
|
||||||
|
$tabs = $feed['mode'] === 'tabs' && count($feed['categories']) > 1;
|
||||||
|
$section['articleFeed'] = [];
|
||||||
|
foreach ($tabs ? $feed['categories'] : [''] as $category) {
|
||||||
|
$section['articleFeed'][] = [
|
||||||
|
'label' => $categories[$category] ?? '',
|
||||||
|
'articles' => $repo->articles($category === '' ? $feed['categories'] : $category, limit: $feed['limit']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($section);
|
||||||
|
|
||||||
return View::render('page', [
|
return View::render('page', [
|
||||||
'site' => $repo->site(),
|
'site' => $repo->site(),
|
||||||
@@ -41,25 +56,51 @@ final class SiteController
|
|||||||
'description' => $page['description'],
|
'description' => $page['description'],
|
||||||
'socialImage' => $page['image'],
|
'socialImage' => $page['image'],
|
||||||
'socialAlt' => $page['alt'],
|
'socialAlt' => $page['alt'],
|
||||||
'articles' => $isHome ? $repo->articles(limit: 3) : [],
|
'network' => $isHome ? $this->networkGroups($repo) : [],
|
||||||
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
|
'previewMode' => $preview, 'canvas' => $preview && $canvas, 'noindex' => $preview,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function services(Request $request): Response
|
public function services(Request $request): Response
|
||||||
{
|
{
|
||||||
|
$repo = new Repository();
|
||||||
|
|
||||||
return View::render('services', [
|
return View::render('services', [
|
||||||
'site' => (new Repository())->site(), 'path' => '/services',
|
'site' => $repo->site(), 'path' => '/services',
|
||||||
'title' => '产品与服务 · 来笙 Laysense',
|
'title' => '产品与服务 · 来笙 Laysense',
|
||||||
'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。',
|
'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。',
|
||||||
'products' => SiteDesign::catalog(),
|
'products' => $repo->articles('services', limit: -1, directoryOrder: true),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function network(Request $request): Response
|
||||||
|
{
|
||||||
|
$repo = new Repository();
|
||||||
|
|
||||||
|
return View::render('network', [
|
||||||
|
'site' => $repo->site(), 'path' => '/network', 'title' => '支持项目与合作伙伴 · 来笙',
|
||||||
|
'description' => '浏览来笙支持的开源项目和合作伙伴。', 'network' => $this->networkGroups($repo),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function networkGroups(Repository $repo): array
|
||||||
|
{
|
||||||
|
$groups = [];
|
||||||
|
foreach (array_diff_key(Repository::DIRECTORIES, ['services' => true]) as $slug => $name) {
|
||||||
|
$groups[$slug] = ['name' => $name, 'articles' => $repo->articles($slug, limit: -1, directoryOrder: true)];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
|
public function archive(Request $request, ?string $category = null, ?string $tag = null): Response
|
||||||
{
|
{
|
||||||
$repo = new Repository();
|
$repo = new Repository();
|
||||||
$title = $category ? Repository::CATEGORIES[$category] : ($tag ?: '来笙动态');
|
$categories = $repo->categories();
|
||||||
|
if ($category !== null && !isset($categories[$category])) {
|
||||||
|
return $this->missing($request);
|
||||||
|
}
|
||||||
|
$title = $category ? $categories[$category] : ($tag ?: '来笙动态');
|
||||||
$path = '/articles' . ($category ? '/category/' . $category : ($tag ? '/tag/' . rawurlencode($tag) : ''));
|
$path = '/articles' . ($category ? '/category/' . $category : ($tag ? '/tag/' . rawurlencode($tag) : ''));
|
||||||
$number = $request->get('page', '1');
|
$number = $request->get('page', '1');
|
||||||
if (!is_scalar($number) || !preg_match('/^[1-9][0-9]{0,4}$/D', (string) $number)) {
|
if (!is_scalar($number) || !preg_match('/^[1-9][0-9]{0,4}$/D', (string) $number)) {
|
||||||
@@ -75,7 +116,7 @@ final class SiteController
|
|||||||
'site' => $repo->site(), 'title' => $title . ' · 来笙', 'headline' => $title,
|
'site' => $repo->site(), 'title' => $title . ' · 来笙', 'headline' => $title,
|
||||||
'description' => '查看来笙的公告、新闻和产品动态。',
|
'description' => '查看来笙的公告、新闻和产品动态。',
|
||||||
'path' => $path . ($page > 1 ? '?page=' . $page : ''), 'archivePath' => $path,
|
'path' => $path . ($page > 1 ? '?page=' . $page : ''), 'archivePath' => $path,
|
||||||
'category' => $category, 'tag' => $tag, 'pageNumber' => $page,
|
'categories' => $categories, 'category' => $category, 'tag' => $tag, 'pageNumber' => $page,
|
||||||
'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
|
'hasNext' => count($articles) > 20, 'articles' => array_slice($articles, 0, 20),
|
||||||
'noindex' => $articles === [],
|
'noindex' => $articles === [],
|
||||||
]);
|
]);
|
||||||
@@ -100,13 +141,15 @@ final class SiteController
|
|||||||
|
|
||||||
return $redirect ? View::redirect('/articles/' . $redirect['slug'], 301) : $this->missing($request);
|
return $redirect ? View::redirect('/articles/' . $redirect['slug'], 301) : $this->missing($request);
|
||||||
}
|
}
|
||||||
$articleHtml = Html::markdown($article['body']);
|
$articleHtml = Html::articleBody($article);
|
||||||
|
|
||||||
return View::render('article', [
|
return View::render('article', [
|
||||||
'site' => $repo->site(), 'article' => $article, 'articleHtml' => $articleHtml,
|
'site' => $repo->site(), 'article' => $article, 'articleHtml' => $articleHtml,
|
||||||
'title' => $article['title'] . ' · 来笙',
|
'title' => $article['title'] . ' · 来笙',
|
||||||
'description' => $article['summary'] ?: mb_substr(trim(strip_tags($articleHtml)), 0, 150) ?: $article['title'],
|
'description' => $article['summary'] ?: mb_substr(trim(strip_tags($articleHtml)), 0, 150) ?: $article['title'],
|
||||||
'path' => '/articles/' . $article['slug'], 'noindex' => trim($articleHtml) === '',
|
'path' => '/articles/' . $article['slug'],
|
||||||
|
'socialImage' => $article['card']['image'] ?? '', 'socialAlt' => $article['card']['alt'] ?? '',
|
||||||
|
'noindex' => trim($articleHtml) === '' && !$article['summary'] && empty($article['card']['url']) && empty($article['card']['image']),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +181,7 @@ final class SiteController
|
|||||||
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
|
$xml = ['<?xml version="1.0" encoding="UTF-8"?>', '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
|
||||||
$pages = $repo->pages(publishedOnly: true);
|
$pages = $repo->pages(publishedOnly: true);
|
||||||
$pages[] = ['slug' => 'services', 'updated_at' => null];
|
$pages[] = ['slug' => 'services', 'updated_at' => null];
|
||||||
|
$pages[] = ['slug' => 'network', 'updated_at' => null];
|
||||||
if ($repo->articles(limit: 1)) {
|
if ($repo->articles(limit: 1)) {
|
||||||
$pages[] = ['slug' => 'articles', 'updated_at' => null];
|
$pages[] = ['slug' => 'articles', 'updated_at' => null];
|
||||||
}
|
}
|
||||||
@@ -165,7 +209,7 @@ final class SiteController
|
|||||||
$normal = rtrim($path, '/');
|
$normal = rtrim($path, '/');
|
||||||
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
|
$single = preg_match('~^/[a-z0-9-]+$~D', $normal);
|
||||||
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
|
$known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home';
|
||||||
if ($known || $normal === '/services' || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) {
|
if ($known || in_array($normal, ['/services', '/network'], true) || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) {
|
||||||
$query = $request->queryString();
|
$query = $request->queryString();
|
||||||
|
|
||||||
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
|
return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ final class StudioController extends AdminController
|
|||||||
$data['name'] = $this->input($request, 'name');
|
$data['name'] = $this->input($request, 'name');
|
||||||
$data['slug'] = $this->input($request, 'slug');
|
$data['slug'] = $this->input($request, 'slug');
|
||||||
try {
|
try {
|
||||||
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'news', 'main', 'favicon'], true)
|
if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'network', 'news', 'main', 'favicon'], true)
|
||||||
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
|
|| $data['name'] === '' || mb_strlen($data['name']) > 100) {
|
||||||
throw new RuntimeException('请填写页面名称及可用的网址标识。');
|
throw new RuntimeException('请填写页面名称及可用的网址标识。');
|
||||||
}
|
}
|
||||||
@@ -65,15 +65,16 @@ final class StudioController extends AdminController
|
|||||||
$action = $this->input($request, 'operation');
|
$action = $this->input($request, 'operation');
|
||||||
$key = $this->input($request, 'key');
|
$key = $this->input($request, 'key');
|
||||||
try {
|
try {
|
||||||
if (!$this->slug($key) || in_array($key, ['preview', 'home', 'contact', 'main-content', 'blog', 'partners', 'supported-projects'], true)) {
|
if (!$this->slug($key) || in_array($key, ['preview', 'home', 'contact', 'main-content', 'partners', 'supported-projects'], true)) {
|
||||||
throw new RuntimeException('区块锚点不可用。');
|
throw new RuntimeException('区块锚点不可用。');
|
||||||
}
|
}
|
||||||
if ($action === 'create') {
|
if ($action === 'create') {
|
||||||
$preset = BlockTemplates::find($this->input($request, 'preset'));
|
$type = $this->input($request, 'preset');
|
||||||
|
$preset = BlockTemplates::find($type);
|
||||||
if ($preset === null) {
|
if ($preset === null) {
|
||||||
throw new RuntimeException('请选择区块类型。');
|
throw new RuntimeException('请选择区块类型。');
|
||||||
}
|
}
|
||||||
$repo->createSection($slug, $key, $preset[0], 'plain', $preset[1]);
|
$repo->createSection($slug, $key, $preset[0], 'plain', $preset[1], $type === 'articles' ? BlockTemplates::ARTICLE_FEED : null);
|
||||||
|
|
||||||
return $this->success($request, "/admin/pages/$slug/$key");
|
return $this->success($request, "/admin/pages/$slug/$key");
|
||||||
}
|
}
|
||||||
@@ -121,53 +122,6 @@ final class StudioController extends AdminController
|
|||||||
], $error === '' ? 200 : 422);
|
], $error === '' ? 200 : 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function catalog(Request $request): Response
|
|
||||||
{
|
|
||||||
if ($failure = $this->guard($request)) {
|
|
||||||
return $failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render($request, 'studio-catalog', ['title' => '产品与服务', 'products' => SiteDesign::catalog()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function product(Request $request, ?string $id = null): Response
|
|
||||||
{
|
|
||||||
if ($failure = $this->guard($request)) {
|
|
||||||
return $failure;
|
|
||||||
}
|
|
||||||
$fields = ['name', 'category', 'body', 'image', 'alt', 'url', 'label', 'extra_url', 'extra_label', 'position'];
|
|
||||||
$product = $id !== null ? SiteDesign::product((int) $id) : array_fill_keys($fields, '') + ['version' => 0];
|
|
||||||
if (!$product) {
|
|
||||||
return $this->error($request, '找不到此产品或服务。', 404);
|
|
||||||
}
|
|
||||||
$error = '';
|
|
||||||
if ($request->method() === 'POST') {
|
|
||||||
try {
|
|
||||||
if ($id !== null && $this->input($request, 'operation') === 'delete') {
|
|
||||||
SiteDesign::deleteProduct((int) $id, $this->version($request));
|
|
||||||
|
|
||||||
return $this->success($request, '/admin/catalog');
|
|
||||||
}
|
|
||||||
foreach ($fields as $field) {
|
|
||||||
$product[$field] = $this->input($request, $field);
|
|
||||||
}
|
|
||||||
$product['version'] = $this->version($request);
|
|
||||||
$this->checkProduct($product);
|
|
||||||
$product['body'] = Html::sanitize($product['body']);
|
|
||||||
$savedId = SiteDesign::saveProduct($id === null ? null : (int) $id, $product, $product['version']);
|
|
||||||
|
|
||||||
return $this->success($request, '/admin/catalog/' . $savedId . '?saved=1');
|
|
||||||
} catch (RuntimeException $exception) {
|
|
||||||
$error = $this->validationMessage($exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->render($request, 'studio-product', [
|
|
||||||
'title' => $id === null ? '添加产品或服务' : '编辑产品或服务', 'product' => $product,
|
|
||||||
'id' => $id, 'error' => $error, 'saved' => $request->get('saved') === '1',
|
|
||||||
], $error === '' ? 200 : 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function media(Request $request): Response
|
public function media(Request $request): Response
|
||||||
{
|
{
|
||||||
if ($failure = $this->guard($request)) {
|
if ($failure = $this->guard($request)) {
|
||||||
@@ -256,23 +210,6 @@ final class StudioController extends AdminController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkProduct(array $item): void
|
|
||||||
{
|
|
||||||
if ($item['name'] === '' || mb_strlen($item['name']) > 100 || $item['category'] === '' || mb_strlen($item['category']) > 70
|
|
||||||
|| strlen($item['body']) > 300000 || strlen($item['image']) > 1000 || mb_strlen($item['alt']) > 200
|
|
||||||
|| ($item['image'] !== '' && !Html::url($item['image'], true)) || !preg_match('/^-?\d{1,6}$/D', $item['position'])) {
|
|
||||||
throw new RuntimeException('请检查名称、分类、简介、封面及排序字段。');
|
|
||||||
}
|
|
||||||
foreach ([['url', 'label'], ['extra_url', 'extra_label']] as [$href, $label]) {
|
|
||||||
if ($href === 'extra_url' && $item[$href] === '' && $item[$label] === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (strlen($item[$href]) > 1000 || !Html::url($item[$href]) || $item[$label] === '' || mb_strlen($item[$label]) > 70) {
|
|
||||||
throw new RuntimeException('请填写按钮文案和有效链接。');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function slug(string $value): bool
|
private function slug(string $value): bool
|
||||||
{
|
{
|
||||||
return strlen($value) <= 70 && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value) === 1;
|
return strlen($value) <= 70 && preg_match('/^[a-z0-9]+(?:-[a-z0-9]+)*$/D', $value) === 1;
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<a class="back-link" href="/admin/articles">返回文章列表</a>
|
||||||
|
<header class="admin-heading"><h1>文章分类</h1></header>
|
||||||
|
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
||||||
|
<form class="admin-form admin-panel" method="post" action="/admin/article-categories">
|
||||||
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>分类名称<input name="name" value="<?= $e($name) ?>" required maxlength="60"></label>
|
||||||
|
<label>网址标识<input name="slug" value="<?= $e($slug) ?>" required maxlength="60" pattern="[a-z0-9]+(-[a-z0-9]+)*"></label>
|
||||||
|
</div>
|
||||||
|
<div class="form-submit"><button class="button button-primary" type="submit">创建分类</button></div>
|
||||||
|
</form>
|
||||||
|
<nav class="filter-nav" aria-label="查看分类">
|
||||||
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
|
<a href="/admin/articles?category=<?= $e($key) ?>"><?= $e($label) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</nav>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -9,7 +8,7 @@ $e = View::escape(...);
|
|||||||
<?php foreach ($articles as $item): ?>
|
<?php foreach ($articles as $item): ?>
|
||||||
<li>
|
<li>
|
||||||
<div><strong><?= $e($item['title']) ?></strong>
|
<div><strong><?= $e($item['title']) ?></strong>
|
||||||
<small><?= $e(Repository::CATEGORIES[$item['category']]) ?> · <?= $item['status'] === 'published' ? '已发布' : '草稿' ?> · <?= $e(View::date($item['updated_at'])) ?></small>
|
<small><?= $e(implode('、', $item['categories'])) ?> · <?= $item['status'] === 'published' ? '已发布' : '草稿' ?> · <?= $e(View::date($item['updated_at'])) ?></small>
|
||||||
</div>
|
</div>
|
||||||
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>">编辑文章</a>
|
<a class="button button-outline" href="/admin/articles/<?= $e($item['id']) ?>">编辑文章</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -16,17 +16,33 @@ $e = View::escape(...);
|
|||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
||||||
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
<input type="hidden" name="version" value="<?= $e($article['version']) ?>">
|
||||||
<label>文章标题<input name="title" value="<?= $e($article['title']) ?>" required maxlength="120"></label>
|
<label>文章标题<input name="title" value="<?= $e($article['title']) ?>" required maxlength="120"></label>
|
||||||
<div class="form-grid">
|
|
||||||
<label>网址标识<input name="slug" value="<?= $e($article['slug']) ?>" required maxlength="100" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="product-update"><small>使用小写英文字母、数字和连字符。</small></label>
|
<label>网址标识<input name="slug" value="<?= $e($article['slug']) ?>" required maxlength="100" pattern="[a-z0-9]+(-[a-z0-9]+)*" placeholder="product-update"><small>使用小写英文字母、数字和连字符。</small></label>
|
||||||
<label>分类<select name="category">
|
<?= View::fragment('admin-category-checkboxes', ['name' => 'categories', 'selected' => array_keys($article['categories']), 'categories' => $categories, 'legend' => '文章分类(可多选)']) ?>
|
||||||
<?php foreach (Repository::CATEGORIES as $key => $label): ?>
|
|
||||||
<option value="<?= $e($key) ?>" <?= $article['category'] === $key ? 'selected' : '' ?>><?= $e($label) ?></option>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</select></label>
|
|
||||||
</div>
|
|
||||||
<label>标签<input name="tags" value="<?= $e(implode(',', $article['tags'])) ?>" placeholder="用逗号分隔"></label>
|
<label>标签<input name="tags" value="<?= $e(implode(',', $article['tags'])) ?>" placeholder="用逗号分隔"></label>
|
||||||
<label>摘要<textarea name="summary" rows="2" maxlength="250"><?= $e($article['summary']) ?></textarea><small>用于动态列表和搜索摘要。</small></label>
|
<label>摘要<textarea name="summary" rows="2" maxlength="250"><?= $e($article['summary']) ?></textarea><small>用于动态列表和搜索摘要。</small></label>
|
||||||
<?= View::fragment('admin-editor', ['format' => 'markdown', 'body' => $article['body']]) ?>
|
<div class="article-editor" data-article-editor>
|
||||||
|
<div class="article-editor-heading">
|
||||||
|
<label for="article-source" data-article-editor-label>正文</label>
|
||||||
|
<button type="button" class="button button-outline" data-insert-article-image hidden>从媒体库插入图片</button>
|
||||||
|
</div>
|
||||||
|
<input type="hidden" name="body_format" value="<?= $e($article['body_format']) ?>">
|
||||||
|
<textarea id="article-source" name="body" rows="16" aria-label="文章正文"><?= $e($article['body']) ?></textarea>
|
||||||
|
<div data-editor-host hidden></div>
|
||||||
|
<p class="article-editor-help" data-article-editor-status role="status"></p>
|
||||||
|
</div>
|
||||||
|
<details class="admin-options" <?= array_intersect(array_keys($article['categories']), array_keys(Repository::DIRECTORIES)) ? 'open' : '' ?>>
|
||||||
|
<summary>目录卡片</summary>
|
||||||
|
<div class="form-grid">
|
||||||
|
<?= View::fragment('studio-asset-field', ['name' => 'card_image', 'label' => '封面或标志', 'value' => $article['card']['image'] ?? '']) ?>
|
||||||
|
<label>图片替代文字<input name="card_alt" value="<?= $e($article['card']['alt'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>主链接<input name="card_url" value="<?= $e($article['card']['url'] ?? '') ?>"></label>
|
||||||
|
<label>主链接文字<input name="card_label" value="<?= $e($article['card']['label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>附加链接<input name="card_extra_url" value="<?= $e($article['card']['extra_url'] ?? '') ?>"></label>
|
||||||
|
<label>附加链接文字<input name="card_extra_label" value="<?= $e($article['card']['extra_label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>类型说明<input name="card_category_label" value="<?= $e($article['card']['category_label'] ?? '') ?>" maxlength="120"></label>
|
||||||
|
<label>目录排序(从小到大)<input name="card_position" type="number" min="0" max="9999" value="<?= $e($article['card']['position'] ?? 0) ?>"></label>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
<div class="form-submit">
|
<div class="form-submit">
|
||||||
<label>发布状态<select name="status">
|
<label>发布状态<select name="status">
|
||||||
<option value="draft" <?= $article['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
<option value="draft" <?= $article['status'] === 'draft' ? 'selected' : '' ?>>草稿</option>
|
||||||
|
|||||||
@@ -1,17 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
$filters = $category ? 'category=' . rawurlencode($category) . '&' : '';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading">
|
||||||
<h1>文章与动态</h1>
|
<h1>文章与动态</h1>
|
||||||
<a class="button button-primary" href="/admin/articles/new">新建文章</a>
|
<div class="actions">
|
||||||
|
<a class="button button-outline" href="/admin/article-categories">管理分类</a>
|
||||||
|
<a class="button button-primary" href="/admin/articles/new<?= $category ? '?category=' . $e($category) : '' ?>">新建文章</a>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
<nav class="filter-nav" aria-label="筛选文章">
|
||||||
|
<a href="/admin/articles" <?= $category === null ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
|
<?php foreach ($categories as $key => $name): ?>
|
||||||
|
<a href="/admin/articles?category=<?= $e($key) ?>" <?= $category === $key ? 'aria-current="page"' : '' ?>><?= $e($name) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</nav>
|
||||||
<div class="admin-panel">
|
<div class="admin-panel">
|
||||||
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
<?= View::fragment('admin-article-list', ['articles' => $articles]) ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($pageNumber > 1 || $hasNext): ?>
|
<?php if ($pageNumber > 1 || $hasNext): ?>
|
||||||
<nav class="pagination" aria-label="文章分页">
|
<nav class="pagination" aria-label="文章分页">
|
||||||
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="/admin/articles?page=<?= $pageNumber - 1 ?>">上一页</a><?php endif ?>
|
<?php if ($pageNumber > 1): ?><a class="button button-outline" href="/admin/articles?<?= $e($filters) ?>page=<?= $pageNumber - 1 ?>">上一页</a><?php endif ?>
|
||||||
<span>第 <?= $pageNumber ?> 页</span>
|
<span>第 <?= $pageNumber ?> 页</span>
|
||||||
<?php if ($hasNext): ?><a class="button button-outline" href="/admin/articles?page=<?= $pageNumber + 1 ?>">下一页</a><?php endif ?>
|
<?php if ($hasNext): ?><a class="button button-outline" href="/admin/articles?<?= $e($filters) ?>page=<?= $pageNumber + 1 ?>">下一页</a><?php endif ?>
|
||||||
</nav>
|
</nav>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<fieldset class="category-checks">
|
||||||
|
<legend><?= $e($legend) ?></legend>
|
||||||
|
<div>
|
||||||
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
|
<label><input type="checkbox" name="<?= $e($name) ?>[]" value="<?= $e($key) ?>" <?= in_array($key, $selected, true) ? 'checked' : '' ?>> <?= $e($label) ?></label>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
@@ -16,6 +16,12 @@ $e = View::escape(...);
|
|||||||
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
||||||
<script src="/assets/admin.js" defer></script>
|
<script src="/assets/admin.js" defer></script>
|
||||||
<script src="/assets/studio.js" defer></script>
|
<script src="/assets/studio.js" defer></script>
|
||||||
|
<?php if (!empty($articleEditor)): ?>
|
||||||
|
<link rel="stylesheet" href="/assets/vendor/toastui/toastui-editor.min.css">
|
||||||
|
<script src="/assets/vendor/toastui/toastui-editor.min.js" defer></script>
|
||||||
|
<script src="/assets/vendor/toastui/zh-cn.js" defer></script>
|
||||||
|
<script src="/assets/article-editor.js" defer></script>
|
||||||
|
<?php endif ?>
|
||||||
</head>
|
</head>
|
||||||
<body class="admin-body">
|
<body class="admin-body">
|
||||||
<a class="skip-link" href="#admin-content">跳到内容</a>
|
<a class="skip-link" href="#admin-content">跳到内容</a>
|
||||||
@@ -27,7 +33,6 @@ $e = View::escape(...);
|
|||||||
<a href="/admin">页面</a>
|
<a href="/admin">页面</a>
|
||||||
<a href="/admin/articles">文章</a>
|
<a href="/admin/articles">文章</a>
|
||||||
<a href="/admin/media">媒体库</a>
|
<a href="/admin/media">媒体库</a>
|
||||||
<a href="/admin/catalog">产品与服务</a>
|
|
||||||
<a href="/admin/settings/header">网站设置</a>
|
<a href="/admin/settings/header">网站设置</a>
|
||||||
<a href="/admin/password">修改密码</a>
|
<a href="/admin/password">修改密码</a>
|
||||||
<a href="/">访问网站</a>
|
<a href="/">访问网站</a>
|
||||||
|
|||||||
@@ -91,19 +91,19 @@ $previewUrl = '/admin/pages/' . $slug . '/preview';
|
|||||||
</div>
|
</div>
|
||||||
<div class="studio-frame-window">
|
<div class="studio-frame-window">
|
||||||
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
<iframe title="可编辑页面画布" src="<?= $e($previewUrl) ?>?canvas=1" sandbox="allow-same-origin"></iframe>
|
||||||
|
<div class="studio-element-tools" data-element-tools role="group" aria-label="所选元素" hidden>
|
||||||
|
<button type="button" data-element-properties>属性</button>
|
||||||
|
<button type="button" data-element-copy>复制</button>
|
||||||
|
<button type="button" data-element-delete>删除</button>
|
||||||
|
</div>
|
||||||
|
<button class="studio-media-handle" type="button" role="slider" aria-label="媒体宽度" aria-valuemin="10" aria-valuemax="100" aria-valuenow="100" data-media-handle hidden></button>
|
||||||
<div class="studio-media-sizing" data-media-sizing hidden>
|
<div class="studio-media-sizing" data-media-sizing hidden>
|
||||||
<label>媒体宽度
|
<output data-media-size aria-hidden="true"></output>
|
||||||
<select data-media-width>
|
<button class="button button-outline" type="button" data-reset-media>原始尺寸</button>
|
||||||
<option value="0">原始尺寸</option>
|
|
||||||
<?php foreach ([25, 40, 50, 60, 75, 85, 100] as $scale): ?>
|
|
||||||
<option value="<?= $scale ?>"><?= $scale ?>%</option>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
<button class="button button-outline" type="button" data-replace-media>替换媒体</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p class="field-note">直接编辑画布文字。单击媒体调整宽度,双击替换。</p>
|
<p class="field-note">单击画布中的元素可打开浮动工具条。选中媒体后可拖动边缘手柄调整宽度。</p>
|
||||||
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
|
<dialog class="media-picker canvas-properties" data-canvas-properties aria-labelledby="canvas-properties-heading">
|
||||||
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
|
<div class="admin-heading compact"><h2 id="canvas-properties-heading" data-property-heading>编辑属性</h2></div>
|
||||||
<form class="admin-form" method="dialog">
|
<form class="admin-form" method="dialog">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use App\Content\View;
|
|||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
$slug = $section['page_slug'];
|
$slug = $section['page_slug'];
|
||||||
$key = $section['key'];
|
$key = $section['key'];
|
||||||
|
$feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR);
|
||||||
?>
|
?>
|
||||||
<a class="back-link" href="/admin/pages/<?= $e($slug) ?>">返回页面编辑</a>
|
<a class="back-link" href="/admin/pages/<?= $e($slug) ?>">返回页面编辑</a>
|
||||||
<header class="admin-heading">
|
<header class="admin-heading">
|
||||||
@@ -21,6 +22,18 @@ $key = $section['key'];
|
|||||||
<option value="<?= $e($style) ?>" <?= $style === $section['style'] ? 'selected' : '' ?>><?= $e(['plain' => '默认', 'tinted' => '浅色背景'][$style] ?? '保留原布局') ?></option>
|
<option value="<?= $e($style) ?>" <?= $style === $section['style'] ? 'selected' : '' ?>><?= $e(['plain' => '默认', 'tinted' => '浅色背景'][$style] ?? '保留原布局') ?></option>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</select></label>
|
</select></label>
|
||||||
|
<details class="admin-options" <?= $feed ? 'open' : '' ?>>
|
||||||
|
<summary>文章组件</summary>
|
||||||
|
<div class="form-grid">
|
||||||
|
<label>展示方式<select name="feed_mode">
|
||||||
|
<?php foreach (['off' => '不展示', 'merged' => '合并为一个列表', 'tabs' => '按分类分标签页'] as $mode => $label): ?>
|
||||||
|
<option value="<?= $mode ?>" <?= ($feed['mode'] ?? 'off') === $mode ? 'selected' : '' ?>><?= $e($label) ?></option>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</select></label>
|
||||||
|
<label>展示数量<input name="feed_limit" type="number" min="1" max="30" value="<?= $e($feed['limit'] ?? 6) ?>"><small>分标签页时,每个分类独立计数。</small></label>
|
||||||
|
</div>
|
||||||
|
<?= View::fragment('admin-category-checkboxes', ['name' => 'feed_categories', 'selected' => $feed['categories'] ?? [], 'categories' => $categories, 'legend' => '展示哪些分类(可多选)']) ?>
|
||||||
|
</details>
|
||||||
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
|
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $section['body']]) ?>
|
||||||
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
|
<div class="form-submit"><button class="button button-primary" type="submit">保存区块</button></div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -13,7 +12,7 @@ $e = View::escape(...);
|
|||||||
</div>
|
</div>
|
||||||
<nav class="filter-nav" aria-label="动态分类">
|
<nav class="filter-nav" aria-label="动态分类">
|
||||||
<a href="/articles" <?= !$category && !$tag ? 'aria-current="page"' : '' ?>>全部</a>
|
<a href="/articles" <?= !$category && !$tag ? 'aria-current="page"' : '' ?>>全部</a>
|
||||||
<?php foreach (Repository::CATEGORIES as $key => $label): ?>
|
<?php foreach ($categories as $key => $label): ?>
|
||||||
<a href="/articles/category/<?= $e($key) ?>" <?= $category === $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
<a href="/articles/category/<?= $e($key) ?>" <?= $category === $key ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<div class="article-feed" <?= count($groups) > 1 ? 'data-article-tabs' : '' ?>>
|
||||||
|
<?php if (count($groups) > 1): ?>
|
||||||
|
<div class="filter-nav article-tabs" data-tab-list role="tablist" aria-labelledby="heading-<?= $e($sectionKey) ?>" hidden>
|
||||||
|
<?php foreach ($groups as $index => $group): ?>
|
||||||
|
<button type="button" role="tab" id="<?= $e($sectionKey) ?>-tab-<?= $index ?>" aria-controls="<?= $e($sectionKey) ?>-articles-<?= $index ?>"><?= $e($group['label']) ?></button>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php foreach ($groups as $index => $group): ?>
|
||||||
|
<div id="<?= $e($sectionKey) ?>-articles-<?= $index ?>" data-tab-panel>
|
||||||
|
<?php if ($group['label'] !== ''): ?><h3 data-tab-heading><?= $e($group['label']) ?></h3><?php endif ?>
|
||||||
|
<?= View::fragment('article-list', ['articles' => $group['articles']]) ?>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -9,11 +8,11 @@ $e = View::escape(...);
|
|||||||
<?php foreach ($articles as $item): ?>
|
<?php foreach ($articles as $item): ?>
|
||||||
<li>
|
<li>
|
||||||
<a class="article-row" href="/articles/<?= $e($item['slug']) ?>">
|
<a class="article-row" href="/articles/<?= $e($item['slug']) ?>">
|
||||||
<span class="article-category"><?= $e(Repository::CATEGORIES[$item['category']]) ?></span>
|
<span class="article-category"><?= $e(implode('、', $item['categories'])) ?></span>
|
||||||
<span class="article-row-title"><?= $e($item['title']) ?>
|
<span class="article-row-title"><?= $e($item['title']) ?>
|
||||||
<?php if ($item['summary']): ?><small><?= $e($item['summary']) ?></small><?php endif ?>
|
<?php if ($item['summary']): ?><small><?= $e($item['summary']) ?></small><?php endif ?>
|
||||||
</span>
|
</span>
|
||||||
<time datetime="<?= $e(View::date($item['published_at'], 'Y-m-d')) ?>"><?= $e(View::date($item['published_at'], 'Y.m.d')) ?></time>
|
<?php if ($item['published_at']): ?><time datetime="<?= $e(View::date($item['published_at'], 'Y-m-d')) ?>"><?= $e(View::date($item['published_at'], 'Y.m.d')) ?></time><?php endif ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
|||||||
+16
-5
@@ -1,29 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Repository;
|
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<article class="section article-page" itemscope itemtype="https://schema.org/Article" data-enter>
|
<article class="section article-page" itemscope itemtype="https://schema.org/Article" data-enter>
|
||||||
|
<?php $card = $article['card']; ?>
|
||||||
<div class="wrap reading-wrap">
|
<div class="wrap reading-wrap">
|
||||||
<a class="back-link" href="/articles">全部动态</a>
|
<a class="back-link" href="/articles">全部动态</a>
|
||||||
<header class="section-heading">
|
<header class="section-heading">
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<a href="/articles/category/<?= $e($article['category']) ?>" itemprop="articleSection"><?= $e(Repository::CATEGORIES[$article['category']]) ?></a>
|
<?php foreach ($article['categories'] as $key => $name): ?>
|
||||||
<time itemprop="datePublished" datetime="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>"><?= $e(View::date($article['published_at'])) ?></time>
|
<a href="/articles/category/<?= $e($key) ?>" itemprop="articleSection"><?= $e($name) ?></a>
|
||||||
|
<?php endforeach ?>
|
||||||
|
<?php if ($article['published_at']): ?><time itemprop="datePublished" datetime="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>"><?= $e(View::date($article['published_at'])) ?></time><?php endif ?>
|
||||||
<meta itemprop="dateModified" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
|
<meta itemprop="dateModified" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
|
||||||
</div>
|
</div>
|
||||||
<h1 itemprop="headline"><?= $e($article['title']) ?></h1>
|
<h1 itemprop="headline"><?= $e($article['title']) ?></h1>
|
||||||
<?php if ($article['summary']): ?><p itemprop="description"><?= $e($article['summary']) ?></p><?php endif ?>
|
<?php if ($article['summary']): ?><p itemprop="description"><?= $e($article['summary']) ?></p><?php endif ?>
|
||||||
<span itemprop="author" itemscope itemtype="https://schema.org/Organization"><meta itemprop="name" content="<?= $e($site['name']) ?>"></span>
|
<span itemprop="author" itemscope itemtype="https://schema.org/Organization"><meta itemprop="name" content="<?= $e($site['name']) ?>"></span>
|
||||||
</header>
|
</header>
|
||||||
|
<?php if (!empty($card['image'])): ?>
|
||||||
|
<img class="article-cover" src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>">
|
||||||
|
<?php endif ?>
|
||||||
<div class="rich prose" itemprop="articleBody">
|
<div class="rich prose" itemprop="articleBody">
|
||||||
<?php if (trim($articleHtml) !== ''): ?>
|
<?php if (trim($articleHtml) !== ''): ?>
|
||||||
<?= $articleHtml ?>
|
<?= $articleHtml ?>
|
||||||
<?php else: ?>
|
<?php elseif (!$article['summary'] && empty($card['image']) && empty($card['url'])): ?>
|
||||||
<p class="empty-state">此公告的原文暂不可用。</p>
|
<p class="empty-state">此文章的原文暂不可用。</p>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if (!empty($card['url']) || !empty($card['extra_url'])): ?>
|
||||||
|
<div class="actions">
|
||||||
|
<?php if (!empty($card['url'])): ?><a class="button button-primary" href="<?= $e($card['url']) ?>"><?= $e(($card['label'] ?? '') ?: '访问网站') ?></a><?php endif ?>
|
||||||
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
<?php if ($article['tags']): ?>
|
<?php if ($article['tags']): ?>
|
||||||
<nav class="filter-nav" aria-label="文章标签">
|
<nav class="filter-nav" aria-label="文章标签">
|
||||||
<?php foreach ($article['tags'] as $tag): ?>
|
<?php foreach ($article['tags'] as $tag): ?>
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
|
||||||
|
$e = View::escape(...);
|
||||||
|
?>
|
||||||
|
<section class="section network" aria-label="支持项目与合作伙伴">
|
||||||
|
<div class="wrap">
|
||||||
|
<?php if (!$standalone): ?>
|
||||||
|
<div class="section-heading inline-heading">
|
||||||
|
<h2>支持项目与合作伙伴</h2>
|
||||||
|
<a class="button button-outline" href="/network">查看全部</a>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php foreach ($network as $slug => $group): ?>
|
||||||
|
<div class="network-group" id="<?= $e($slug) ?>">
|
||||||
|
<?php if ($standalone): ?><h2><?= $e($group['name']) ?></h2><?php else: ?><h3><?= $e($group['name']) ?></h3><?php endif ?>
|
||||||
|
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
|
||||||
|
<ul class="network-list">
|
||||||
|
<?php foreach ($group['articles'] as $item): ?>
|
||||||
|
<?php $card = $item['card']; $articlePath = '/articles/' . $item['slug']; ?>
|
||||||
|
<li>
|
||||||
|
<a href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>">
|
||||||
|
<?php if (!empty($card['image'])): ?>
|
||||||
|
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
||||||
|
<?php endif ?>
|
||||||
|
<span><?= $e($item['title']) ?></span>
|
||||||
|
</a>
|
||||||
|
<?php if ($standalone && !empty($card['url']) && ($item['body'] !== '' || $item['summary'] !== '')): ?>
|
||||||
|
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
||||||
|
<?php endif ?>
|
||||||
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
use App\Content\View;
|
||||||
|
?>
|
||||||
|
<section class="section catalog-hero">
|
||||||
|
<div class="wrap">
|
||||||
|
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">支持项目与合作伙伴</span></nav>
|
||||||
|
<h1>支持项目与合作伙伴</h1>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<?= View::fragment('network-groups', ['network' => $network, 'standalone' => true]) ?>
|
||||||
+14
-36
@@ -36,8 +36,19 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
|
|||||||
<?php if ($canvas || $page['image'] !== ''): ?>
|
<?php if ($canvas || $page['image'] !== ''): ?>
|
||||||
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?><?= $page['image_scale'] ? ' studio-media-' . $e($page['image_scale']) : '' ?>" data-visual<?= $page['image'] === '' ? ' hidden' : '' ?>>
|
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?><?= $page['image_scale'] ? ' studio-media-' . $e($page['image_scale']) : '' ?>" data-visual<?= $page['image'] === '' ? ' hidden' : '' ?>>
|
||||||
<img<?= $page['image'] === '' ? '' : ' src="' . $e($page['image']) . '"' ?> alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"<?= $canvas ? ' data-studio-hero-image' : '' ?>>
|
<img<?= $page['image'] === '' ? '' : ' src="' . $e($page['image']) . '"' ?> alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"<?= $canvas ? ' data-studio-hero-image' : '' ?>>
|
||||||
<?php if ($home && !$canvas && $page['image'] === '/assets/original/home-hero.webp' && !$page['image_scale']): ?>
|
<?php if ($home && !$canvas && $page['image'] === '/assets/original/home-hero.webp'): ?>
|
||||||
<div class="home-pipe-flow" aria-hidden="true"><span></span><span></span><span></span><span></span></div>
|
<svg class="home-pipe-flow" viewBox="0 0 640 480" aria-hidden="true" focusable="false">
|
||||||
|
<defs>
|
||||||
|
<path id="hero-pipe-tower" pathLength="100" d="M174 347 241 312 Q246 310 246 305 L246 299 Q246 295 252 293 L273 282"/>
|
||||||
|
<path id="hero-pipe-disk" pathLength="100" d="M409 282 428 293 Q433 296 433 300 L433 304 Q433 307 438 309 L500 337"/>
|
||||||
|
<path id="hero-pipe-node" pathLength="100" d="M119 201 125 205 Q129 207 129 212 L129 214 Q130 217 134 219 L190 243"/>
|
||||||
|
<path id="hero-pipe-chart" pathLength="100" d="M443 226 471 213 Q478 208 483 209 L488 207 Q492 205 492 200 L492 182"/>
|
||||||
|
</defs>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-tower"/><use href="#hero-pipe-tower"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-disk"/><use href="#hero-pipe-disk"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-node"/><use href="#hero-pipe-node"/></g>
|
||||||
|
<g class="home-pipe-route"><use href="#hero-pipe-chart"/><use href="#hero-pipe-chart"/></g>
|
||||||
|
</svg>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@@ -71,38 +82,5 @@ $field = static fn (string $name): string => $canvas ? ' data-studio-field="' .
|
|||||||
]) ?></template>
|
]) ?></template>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php if ($home): ?>
|
<?php if ($home): ?>
|
||||||
<section class="section home-news" id="blog" aria-labelledby="updates-heading">
|
<?= View::fragment('network-groups', ['network' => $network, 'standalone' => false]) ?>
|
||||||
<div class="wrap">
|
|
||||||
<div class="section-heading inline-heading">
|
|
||||||
<h2 id="updates-heading">来笙动态</h2>
|
|
||||||
<a class="button button-outline" href="/articles">查看全部动态</a>
|
|
||||||
</div>
|
|
||||||
<?= View::fragment('article-list', ['articles' => $articles]) ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<?php if ($page['partners']): ?>
|
|
||||||
<section class="section network" aria-labelledby="network-heading">
|
|
||||||
<div class="wrap">
|
|
||||||
<div class="section-heading"><h2 id="network-heading">支持项目与合作伙伴</h2></div>
|
|
||||||
<?php foreach (['来笙支持项目' => 'supported-projects', '来笙合作伙伴' => 'partners'] as $group => $id): ?>
|
|
||||||
<div class="network-group" id="<?= $e($id) ?>">
|
|
||||||
<h3><?= $e($group) ?></h3>
|
|
||||||
<ul class="network-list">
|
|
||||||
<?php foreach ($page['partners'] as $partner): ?>
|
|
||||||
<?php if ($partner['group'] !== $group) { continue; } ?>
|
|
||||||
<li>
|
|
||||||
<?php if ($partner['url']): ?><a href="<?= $e($partner['url']) ?>"><?php else: ?><div><?php endif ?>
|
|
||||||
<?php if ($partner['image']): ?>
|
|
||||||
<img src="<?= $e($partner['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
|
||||||
<?php endif ?>
|
|
||||||
<span><?= $e($partner['name']) ?></span>
|
|
||||||
<?php if ($partner['url']): ?></a><?php else: ?></div><?php endif ?>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
<?php endif ?>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ $canvas ??= false;
|
|||||||
<h2 id="heading-<?= $e($section['key']) ?>"<?= $canvas ? ' data-studio-part="title"' : '' ?>><?= $e($section['title']) ?></h2>
|
<h2 id="heading-<?= $e($section['key']) ?>"<?= $canvas ? ' data-studio-part="title"' : '' ?>><?= $e($section['title']) ?></h2>
|
||||||
<?php if ($canvas || $section['lead']): ?><p<?= $canvas ? ' data-studio-part="lead"' : '' ?>><?= $e($section['lead']) ?></p><?php endif ?>
|
<?php if ($canvas || $section['lead']): ?><p<?= $canvas ? ' data-studio-part="lead"' : '' ?>><?= $e($section['lead']) ?></p><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="rich"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $section['body'] ?></div>
|
<?php if (!empty($section['articleFeed'])): ?>
|
||||||
|
<?= View::fragment('article-feed', ['groups' => $section['articleFeed'], 'sectionKey' => $section['key']]) ?>
|
||||||
|
<?php endif ?>
|
||||||
|
<?php if ($canvas || $section['body'] !== ''): ?><div class="rich<?= !empty($section['articleFeed']) ? ' article-feed-note' : '' ?>"<?= $canvas ? ' data-studio-part="body"' : '' ?>><?= $section['body'] ?></div><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
+13
-7
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use App\Content\Html;
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
@@ -15,17 +16,22 @@ $e = View::escape(...);
|
|||||||
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
||||||
<div class="catalog-grid">
|
<div class="catalog-grid">
|
||||||
<?php foreach ($products as $product): ?>
|
<?php foreach ($products as $product): ?>
|
||||||
|
<?php $card = $product['card']; $articlePath = '/articles/' . $product['slug']; ?>
|
||||||
<article class="catalog-card">
|
<article class="catalog-card">
|
||||||
<?php if ($product['image']): ?>
|
<?php if (!empty($card['image'])): ?>
|
||||||
<div class="catalog-image"><img src="<?= $e($product['image']) ?>" alt="<?= $e($product['alt']) ?>" loading="lazy"></div>
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<div class="catalog-content">
|
<div class="catalog-content">
|
||||||
<p class="overline"><?= $e($product['category']) ?></p>
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
||||||
<h2><?= $e($product['name']) ?></h2>
|
<h2><a href="<?= $e($articlePath) ?>"><?= $e($product['title']) ?></a></h2>
|
||||||
<div class="rich"><?= $product['body'] ?></div>
|
<?php if ($product['summary']): ?>
|
||||||
|
<p><?= $e($product['summary']) ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="rich"><?= Html::articleBody($product) ?></div>
|
||||||
|
<?php endif ?>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<a class="button button-primary" href="<?= $e($product['url']) ?>"><?= $e($product['label']) ?></a>
|
<a class="button button-primary" href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a>
|
||||||
<?php if ($product['extra_url']): ?><a href="<?= $e($product['extra_url']) ?>"><?= $e($product['extra_label']) ?></a><?php endif ?>
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
use App\Content\View;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
|
||||||
?>
|
|
||||||
<header class="admin-heading">
|
|
||||||
<div><h1>产品与服务</h1><p>管理公开目录中的条目、分类和按钮链接。</p></div>
|
|
||||||
<div class="actions"><a class="button button-outline" href="/services">查看目录</a><a class="button button-primary" href="/admin/catalog/new">添加条目</a></div>
|
|
||||||
</header>
|
|
||||||
<section class="admin-panel">
|
|
||||||
<?php if (!$products): ?><p class="empty-state">暂无产品或服务。</p><?php endif ?>
|
|
||||||
<ul class="admin-list">
|
|
||||||
<?php foreach ($products as $item): ?>
|
|
||||||
<li><div><strong><?= $e($item['name']) ?></strong><small><?= $e($item['category']) ?> · <?= $e($item['url']) ?></small></div>
|
|
||||||
<a class="button button-outline" href="/admin/catalog/<?= $e($item['id']) ?>">编辑</a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach ?>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
use App\Content\View;
|
|
||||||
|
|
||||||
$e = View::escape(...);
|
|
||||||
?>
|
|
||||||
<a class="back-link" href="/admin/catalog">返回目录管理</a>
|
|
||||||
<header class="admin-heading"><h1><?= $e($title) ?></h1></header>
|
|
||||||
<?= View::fragment('admin-feedback', compact('error', 'saved')) ?>
|
|
||||||
<form class="admin-form admin-panel" method="post" action="/admin/catalog/<?= $e($id ?? 'new') ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<input type="hidden" name="version" value="<?= $e($product['version']) ?>">
|
|
||||||
<div class="form-grid">
|
|
||||||
<label>名称<input name="name" value="<?= $e($product['name']) ?>" required maxlength="100"></label>
|
|
||||||
<label>分类<input name="category" value="<?= $e($product['category']) ?>" required maxlength="70"></label>
|
|
||||||
</div>
|
|
||||||
<div class="form-grid">
|
|
||||||
<?= View::fragment('studio-asset-field', ['label' => '封面', 'name' => 'image', 'value' => $product['image']]) ?>
|
|
||||||
<label>封面替代文本<input name="alt" value="<?= $e($product['alt']) ?>" maxlength="200"></label>
|
|
||||||
</div>
|
|
||||||
<div class="form-grid">
|
|
||||||
<label>按钮文案<input name="label" value="<?= $e($product['label']) ?>" required maxlength="70"></label>
|
|
||||||
<label>按钮链接<input name="url" value="<?= $e($product['url']) ?>" required maxlength="1000"></label>
|
|
||||||
<label>次要链接文案<input name="extra_label" value="<?= $e($product['extra_label']) ?>" maxlength="70"></label>
|
|
||||||
<label>次要链接<input name="extra_url" value="<?= $e($product['extra_url']) ?>" maxlength="1000"></label>
|
|
||||||
</div>
|
|
||||||
<label>排序<input type="number" name="position" min="-999999" max="999999" value="<?= $e($product['position'] === '' ? 100 : $product['position']) ?>" required><small>数值越小越靠前。</small></label>
|
|
||||||
<?= View::fragment('admin-editor', ['format' => 'html', 'body' => $product['body']]) ?>
|
|
||||||
<div class="form-submit"><button class="button button-primary" type="submit">保存条目</button></div>
|
|
||||||
</form>
|
|
||||||
<?php if ($id !== null): ?>
|
|
||||||
<form class="admin-form" method="post" action="/admin/catalog/<?= $e($id) ?>">
|
|
||||||
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
|
|
||||||
<input type="hidden" name="version" value="<?= $e($product['version']) ?>">
|
|
||||||
<div class="form-submit"><button class="button button-outline" type="submit" name="operation" value="delete" data-confirm="从公开目录删除此条目?">删除条目</button></div>
|
|
||||||
</form>
|
|
||||||
<?php endif ?>
|
|
||||||
+3
-4
@@ -11,9 +11,10 @@ use Webman\Route;
|
|||||||
Route::disableDefaultRoute();
|
Route::disableDefaultRoute();
|
||||||
Route::get('/', [SiteController::class, 'home']);
|
Route::get('/', [SiteController::class, 'home']);
|
||||||
Route::get('/services', [SiteController::class, 'services']);
|
Route::get('/services', [SiteController::class, 'services']);
|
||||||
|
Route::get('/network', [SiteController::class, 'network']);
|
||||||
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
|
Route::get('/assets/uploads/{name:[a-f0-9]{32}\.[a-z0-9]+}', [MediaController::class, 'file']);
|
||||||
Route::get('/articles', [SiteController::class, 'archive']);
|
Route::get('/articles', [SiteController::class, 'archive']);
|
||||||
Route::get('/articles/category/{category:announcement|news|product}', [SiteController::class, 'archive']);
|
Route::get('/articles/category/{category:[a-z0-9-]+}', [SiteController::class, 'archive']);
|
||||||
Route::get('/articles/tag/{tag:[^/]+}', [SiteController::class, 'tagged']);
|
Route::get('/articles/tag/{tag:[^/]+}', [SiteController::class, 'tagged']);
|
||||||
Route::get('/articles/{slug:[a-z0-9-]+}', [SiteController::class, 'article']);
|
Route::get('/articles/{slug:[a-z0-9-]+}', [SiteController::class, 'article']);
|
||||||
Route::get('/main', static fn () => View::redirect('/articles', 301));
|
Route::get('/main', static fn () => View::redirect('/articles', 301));
|
||||||
@@ -27,6 +28,7 @@ Route::add(['GET', 'POST'], '/admin/login', [AdminController::class, 'login']);
|
|||||||
Route::post('/admin/logout', [AdminController::class, 'logout']);
|
Route::post('/admin/logout', [AdminController::class, 'logout']);
|
||||||
Route::add(['GET', 'POST'], '/admin/password', [AdminController::class, 'password']);
|
Route::add(['GET', 'POST'], '/admin/password', [AdminController::class, 'password']);
|
||||||
Route::get('/admin', [AdminController::class, 'dashboard']);
|
Route::get('/admin', [AdminController::class, 'dashboard']);
|
||||||
|
Route::add(['GET', 'POST'], '/admin/article-categories', [AdminController::class, 'articleCategories']);
|
||||||
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
Route::get('/admin/articles', [AdminController::class, 'articles']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/new', [AdminController::class, 'article']);
|
||||||
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
Route::add(['GET', 'POST'], '/admin/articles/{id:[0-9]+}', [AdminController::class, 'article']);
|
||||||
@@ -34,9 +36,6 @@ Route::add(['GET', 'POST'], '/admin/new-page', [StudioController::class, 'newPag
|
|||||||
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
Route::get('/admin/pages/{slug:[a-z0-9-]+}/preview', [StudioController::class, 'previewPage']);
|
||||||
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
Route::post('/admin/page-blocks/{slug:[a-z0-9-]+}', [StudioController::class, 'blocks']);
|
||||||
Route::add(['GET', 'POST'], '/admin/settings/{part:header|footer|cdn}', [StudioController::class, 'settings']);
|
Route::add(['GET', 'POST'], '/admin/settings/{part:header|footer|cdn}', [StudioController::class, 'settings']);
|
||||||
Route::get('/admin/catalog', [StudioController::class, 'catalog']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/catalog/new', [StudioController::class, 'product']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/catalog/{id:[0-9]+}', [StudioController::class, 'product']);
|
|
||||||
Route::add(['GET', 'POST'], '/admin/media', [StudioController::class, 'media']);
|
Route::add(['GET', 'POST'], '/admin/media', [StudioController::class, 'media']);
|
||||||
Route::get('/admin/media/options', [StudioController::class, 'mediaOptions']);
|
Route::get('/admin/media/options', [StudioController::class, 'mediaOptions']);
|
||||||
Route::post('/admin/media/{name:[a-f0-9]{32}\.[a-z0-9]+}', [StudioController::class, 'mediaMeta']);
|
Route::post('/admin/media/{name:[a-f0-9]{32}\.[a-z0-9]+}', [StudioController::class, 'mediaMeta']);
|
||||||
|
|||||||
+32
-1
@@ -131,7 +131,25 @@
|
|||||||
.studio-layers .studio-blocks li { display: grid; gap: .4rem; }
|
.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-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-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-media-sizing select { margin-inline-start: .3rem; }
|
.studio-element-tools {
|
||||||
|
position: absolute; z-index: 3; display: flex; align-items: center; gap: .15rem; padding: .2rem;
|
||||||
|
border: 1px solid #3f62e0; border-radius: .65rem; background: #244bc8;
|
||||||
|
box-shadow: 0 .22rem .7rem #13297538;
|
||||||
|
}
|
||||||
|
.studio-element-tools button {
|
||||||
|
min-height: 2rem; padding: .22rem .6rem; border: 0; border-radius: .42rem;
|
||||||
|
background: transparent; color: white; font-size: .84rem; white-space: nowrap; cursor: pointer;
|
||||||
|
}
|
||||||
|
.studio-element-tools button:hover, .studio-element-tools button:focus-visible { background: #ffffff32; }
|
||||||
|
.studio-element-tools button:focus-visible { outline: 1px solid white; outline-offset: -2px; }
|
||||||
|
.studio-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; }
|
.studio-media-sizing .button { min-height: 2.2rem; padding: .25rem .7rem; }
|
||||||
@media (max-width: 54rem) {
|
@media (max-width: 54rem) {
|
||||||
.studio-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "library" "workspace" "settings"; }
|
.studio-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "library" "workspace" "settings"; }
|
||||||
@@ -203,3 +221,16 @@
|
|||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.studio-template-image img { transition: none; }
|
.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; }
|
||||||
|
|||||||
@@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
+119
-38
@@ -500,39 +500,28 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
.home-pipe-flow {
|
.home-pipe-flow {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: clamp(.45rem, 1.8vw, 1.7rem);
|
inset: clamp(.45rem, 1.8vw, 1.7rem);
|
||||||
|
width: calc(100% - 2 * clamp(.45rem, 1.8vw, 1.7rem));
|
||||||
|
height: calc(100% - 2 * clamp(.45rem, 1.8vw, 1.7rem));
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
.home-pipe-flow span {
|
.home-pipe-route { opacity: 0; animation: pipe-visibility 7s linear 2 both; }
|
||||||
position: absolute;
|
.home-pipe-route use {
|
||||||
width: clamp(.3rem, .68vw, .63rem);
|
fill: none;
|
||||||
aspect-ratio: 1;
|
stroke: #2985fa;
|
||||||
border-radius: 50%;
|
stroke-width: 3;
|
||||||
background: #e3fbff;
|
stroke-linecap: round;
|
||||||
box-shadow: 0 0 .4rem .1rem #78d7ff, 0 0 .8rem .16rem #3882ff;
|
stroke-dasharray: 17 110;
|
||||||
translate: -50% -50%;
|
stroke-dashoffset: 19;
|
||||||
animation: home-pipe-pulse 2.8s linear 2 both;
|
opacity: .48;
|
||||||
}
|
animation: pipe-travel 7s linear 2 both;
|
||||||
.home-pipe-flow span:nth-child(1) {
|
|
||||||
--pipe-start: 72% auto auto 27.4%; --pipe-turn: 64% auto auto 38.3%; --pipe-end: 59.1% auto auto 42.1%;
|
|
||||||
}
|
|
||||||
.home-pipe-flow span:nth-child(2) {
|
|
||||||
--pipe-start: 59.2% auto auto 64%; --pipe-turn: 64.2% auto auto 67.1%; --pipe-end: 70% auto auto 78.2%;
|
|
||||||
animation-delay: .35s;
|
|
||||||
}
|
|
||||||
.home-pipe-flow span:nth-child(3) {
|
|
||||||
--pipe-start: 42% auto auto 18.7%; --pipe-turn: 46.9% auto auto 23.4%; --pipe-end: 51% auto auto 29.8%;
|
|
||||||
animation-delay: .65s;
|
|
||||||
}
|
|
||||||
.home-pipe-flow span:nth-child(4) {
|
|
||||||
--pipe-start: 37% auto auto 77%; --pipe-turn: 42.5% auto auto 77%; --pipe-end: 47.7% auto auto 68.3%;
|
|
||||||
animation-delay: .9s;
|
|
||||||
}
|
|
||||||
@keyframes home-pipe-pulse {
|
|
||||||
0%, 16% { inset: var(--pipe-start); opacity: 0; }
|
|
||||||
21%, 67% { opacity: 1; }
|
|
||||||
40% { inset: var(--pipe-turn); }
|
|
||||||
72%, 100% { inset: var(--pipe-end); opacity: 0; }
|
|
||||||
}
|
}
|
||||||
|
.home-pipe-route use + use { stroke: #ecffff; stroke-width: 1.3; stroke-dasharray: 11 116; opacity: .95; }
|
||||||
|
.home-pipe-route:nth-of-type(2) { --pipe-delay: .85s; }
|
||||||
|
.home-pipe-route:nth-of-type(3) { --pipe-delay: 2.35s; }
|
||||||
|
.home-pipe-route:nth-of-type(4) { --pipe-delay: 3.2s; }
|
||||||
|
.home-pipe-route, .home-pipe-route use { animation-delay: var(--pipe-delay, 0s); }
|
||||||
|
@keyframes pipe-travel { 0%, 6% { stroke-dashoffset: 19; } 45%, 100% { stroke-dashoffset: -104; } }
|
||||||
|
@keyframes pipe-visibility { 0%, 6%, 45%, 100% { opacity: 0; } 13%, 37% { opacity: 1; } }
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.home-cursor { animation: none; }
|
.home-cursor { animation: none; }
|
||||||
.home-pipe-flow { display: none; }
|
.home-pipe-flow { display: none; }
|
||||||
@@ -544,16 +533,101 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
@media (max-width: 44rem) { .studio-split { grid-template-columns: 1fr; } }
|
@media (max-width: 44rem) { .studio-split { grid-template-columns: 1fr; } }
|
||||||
|
|
||||||
:where(img, video, audio, .hero-visual)[class*="studio-media-"] { max-width: 100%; }
|
:where(img, video, audio, .hero-visual)[class*="studio-media-"] { max-width: 100%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-25 { --studio-media-width: 25%; width: var(--studio-media-width); }
|
:is(.rich, .hero-inner, .editor-preview) [class*="studio-media-"] { width: var(--studio-media-width, auto); }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-40 { --studio-media-width: 40%; width: var(--studio-media-width); }
|
.studio-media-10 { --studio-media-width: 10%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-50 { --studio-media-width: 50%; width: var(--studio-media-width); }
|
.studio-media-11 { --studio-media-width: 11%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-60 { --studio-media-width: 60%; width: var(--studio-media-width); }
|
.studio-media-12 { --studio-media-width: 12%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-75 { --studio-media-width: 75%; width: var(--studio-media-width); }
|
.studio-media-13 { --studio-media-width: 13%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-85 { --studio-media-width: 85%; width: var(--studio-media-width); }
|
.studio-media-14 { --studio-media-width: 14%; }
|
||||||
:is(.rich, .hero-inner, .editor-preview) .studio-media-100 { --studio-media-width: 100%; width: var(--studio-media-width); }
|
.studio-media-15 { --studio-media-width: 15%; }
|
||||||
|
.studio-media-16 { --studio-media-width: 16%; }
|
||||||
|
.studio-media-17 { --studio-media-width: 17%; }
|
||||||
|
.studio-media-18 { --studio-media-width: 18%; }
|
||||||
|
.studio-media-19 { --studio-media-width: 19%; }
|
||||||
|
.studio-media-20 { --studio-media-width: 20%; }
|
||||||
|
.studio-media-21 { --studio-media-width: 21%; }
|
||||||
|
.studio-media-22 { --studio-media-width: 22%; }
|
||||||
|
.studio-media-23 { --studio-media-width: 23%; }
|
||||||
|
.studio-media-24 { --studio-media-width: 24%; }
|
||||||
|
.studio-media-25 { --studio-media-width: 25%; }
|
||||||
|
.studio-media-26 { --studio-media-width: 26%; }
|
||||||
|
.studio-media-27 { --studio-media-width: 27%; }
|
||||||
|
.studio-media-28 { --studio-media-width: 28%; }
|
||||||
|
.studio-media-29 { --studio-media-width: 29%; }
|
||||||
|
.studio-media-30 { --studio-media-width: 30%; }
|
||||||
|
.studio-media-31 { --studio-media-width: 31%; }
|
||||||
|
.studio-media-32 { --studio-media-width: 32%; }
|
||||||
|
.studio-media-33 { --studio-media-width: 33%; }
|
||||||
|
.studio-media-34 { --studio-media-width: 34%; }
|
||||||
|
.studio-media-35 { --studio-media-width: 35%; }
|
||||||
|
.studio-media-36 { --studio-media-width: 36%; }
|
||||||
|
.studio-media-37 { --studio-media-width: 37%; }
|
||||||
|
.studio-media-38 { --studio-media-width: 38%; }
|
||||||
|
.studio-media-39 { --studio-media-width: 39%; }
|
||||||
|
.studio-media-40 { --studio-media-width: 40%; }
|
||||||
|
.studio-media-41 { --studio-media-width: 41%; }
|
||||||
|
.studio-media-42 { --studio-media-width: 42%; }
|
||||||
|
.studio-media-43 { --studio-media-width: 43%; }
|
||||||
|
.studio-media-44 { --studio-media-width: 44%; }
|
||||||
|
.studio-media-45 { --studio-media-width: 45%; }
|
||||||
|
.studio-media-46 { --studio-media-width: 46%; }
|
||||||
|
.studio-media-47 { --studio-media-width: 47%; }
|
||||||
|
.studio-media-48 { --studio-media-width: 48%; }
|
||||||
|
.studio-media-49 { --studio-media-width: 49%; }
|
||||||
|
.studio-media-50 { --studio-media-width: 50%; }
|
||||||
|
.studio-media-51 { --studio-media-width: 51%; }
|
||||||
|
.studio-media-52 { --studio-media-width: 52%; }
|
||||||
|
.studio-media-53 { --studio-media-width: 53%; }
|
||||||
|
.studio-media-54 { --studio-media-width: 54%; }
|
||||||
|
.studio-media-55 { --studio-media-width: 55%; }
|
||||||
|
.studio-media-56 { --studio-media-width: 56%; }
|
||||||
|
.studio-media-57 { --studio-media-width: 57%; }
|
||||||
|
.studio-media-58 { --studio-media-width: 58%; }
|
||||||
|
.studio-media-59 { --studio-media-width: 59%; }
|
||||||
|
.studio-media-60 { --studio-media-width: 60%; }
|
||||||
|
.studio-media-61 { --studio-media-width: 61%; }
|
||||||
|
.studio-media-62 { --studio-media-width: 62%; }
|
||||||
|
.studio-media-63 { --studio-media-width: 63%; }
|
||||||
|
.studio-media-64 { --studio-media-width: 64%; }
|
||||||
|
.studio-media-65 { --studio-media-width: 65%; }
|
||||||
|
.studio-media-66 { --studio-media-width: 66%; }
|
||||||
|
.studio-media-67 { --studio-media-width: 67%; }
|
||||||
|
.studio-media-68 { --studio-media-width: 68%; }
|
||||||
|
.studio-media-69 { --studio-media-width: 69%; }
|
||||||
|
.studio-media-70 { --studio-media-width: 70%; }
|
||||||
|
.studio-media-71 { --studio-media-width: 71%; }
|
||||||
|
.studio-media-72 { --studio-media-width: 72%; }
|
||||||
|
.studio-media-73 { --studio-media-width: 73%; }
|
||||||
|
.studio-media-74 { --studio-media-width: 74%; }
|
||||||
|
.studio-media-75 { --studio-media-width: 75%; }
|
||||||
|
.studio-media-76 { --studio-media-width: 76%; }
|
||||||
|
.studio-media-77 { --studio-media-width: 77%; }
|
||||||
|
.studio-media-78 { --studio-media-width: 78%; }
|
||||||
|
.studio-media-79 { --studio-media-width: 79%; }
|
||||||
|
.studio-media-80 { --studio-media-width: 80%; }
|
||||||
|
.studio-media-81 { --studio-media-width: 81%; }
|
||||||
|
.studio-media-82 { --studio-media-width: 82%; }
|
||||||
|
.studio-media-83 { --studio-media-width: 83%; }
|
||||||
|
.studio-media-84 { --studio-media-width: 84%; }
|
||||||
|
.studio-media-85 { --studio-media-width: 85%; }
|
||||||
|
.studio-media-86 { --studio-media-width: 86%; }
|
||||||
|
.studio-media-87 { --studio-media-width: 87%; }
|
||||||
|
.studio-media-88 { --studio-media-width: 88%; }
|
||||||
|
.studio-media-89 { --studio-media-width: 89%; }
|
||||||
|
.studio-media-90 { --studio-media-width: 90%; }
|
||||||
|
.studio-media-91 { --studio-media-width: 91%; }
|
||||||
|
.studio-media-92 { --studio-media-width: 92%; }
|
||||||
|
.studio-media-93 { --studio-media-width: 93%; }
|
||||||
|
.studio-media-94 { --studio-media-width: 94%; }
|
||||||
|
.studio-media-95 { --studio-media-width: 95%; }
|
||||||
|
.studio-media-96 { --studio-media-width: 96%; }
|
||||||
|
.studio-media-97 { --studio-media-width: 97%; }
|
||||||
|
.studio-media-98 { --studio-media-width: 98%; }
|
||||||
|
.studio-media-99 { --studio-media-width: 99%; }
|
||||||
|
.studio-media-100 { --studio-media-width: 100%; }
|
||||||
.rich :is(img, video)[class*="studio-media-"] { height: auto; max-width: 100%; }
|
.rich :is(img, video)[class*="studio-media-"] { height: auto; max-width: 100%; }
|
||||||
.hero-visual[class*="studio-media-"] { justify-self: center; }
|
.hero-visual[class*="studio-media-"] { justify-self: center; }
|
||||||
[data-studio-editing] [data-studio-selected] { outline: 2px solid #4477f9; outline-offset: 3px; }
|
[data-studio-editing] [data-studio-selected] { outline: 1px dashed #315ef0; outline-offset: 3px; }
|
||||||
|
|
||||||
.rich .studio-intro { max-width: 47rem; }
|
.rich .studio-intro { max-width: 47rem; }
|
||||||
.rich .studio-intro h3, .rich .studio-cover h3 { font-size: clamp(1.75rem, 4vw, 2.8rem); }
|
.rich .studio-intro h3, .rich .studio-cover h3 { font-size: clamp(1.75rem, 4vw, 2.8rem); }
|
||||||
@@ -566,3 +640,10 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
|
|||||||
@media (max-width: 44rem) {
|
@media (max-width: 44rem) {
|
||||||
.rich .studio-cover, .rich .studio-two-column { grid-template-columns: minmax(0, 1fr); }
|
.rich .studio-cover, .rich .studio-two-column { grid-template-columns: minmax(0, 1fr); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.article-feed-note { margin-top: 1.15rem; }
|
||||||
|
.article-cover { display: block; max-height: 28rem; width: auto; margin-bottom: 1.75rem; object-fit: contain; }
|
||||||
|
.article-tabs { margin-bottom: .85rem; }
|
||||||
|
.article-tabs button { padding: .38rem .8rem; background: white; border: 1px solid var(--line); border-radius: .45rem; color: inherit; cursor: pointer; }
|
||||||
|
.article-tabs button[aria-selected="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
|
||||||
|
.network-list .network-detail { min-height: 0; padding-block: .2rem; font-size: .85rem; }
|
||||||
|
|||||||
@@ -22,6 +22,37 @@ jQuery(function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('[data-article-tabs]').each(function () {
|
||||||
|
const $feed = $(this);
|
||||||
|
const $list = $feed.children('[data-tab-list]');
|
||||||
|
const $panels = $feed.children('[data-tab-panel]');
|
||||||
|
const $tabs = $list.children('[role="tab"]');
|
||||||
|
|
||||||
|
function selectTab(index, focus = false) {
|
||||||
|
$tabs.each(function (number) {
|
||||||
|
$(this).attr({'aria-selected': String(index === number), tabindex: index === number ? '0' : '-1'});
|
||||||
|
});
|
||||||
|
$panels.prop('hidden', true).eq(index).prop('hidden', false);
|
||||||
|
if (focus) $tabs.eq(index).trigger('focus');
|
||||||
|
}
|
||||||
|
|
||||||
|
$panels.each(function (index) {
|
||||||
|
$(this).attr({role: 'tabpanel', 'aria-labelledby': $tabs.eq(index).attr('id'), tabindex: '0'});
|
||||||
|
}).children('[data-tab-heading]').prop('hidden', true);
|
||||||
|
$list.prop('hidden', false);
|
||||||
|
selectTab(0);
|
||||||
|
$tabs.on('click', function () {
|
||||||
|
selectTab($tabs.index(this));
|
||||||
|
}).on('keydown', function (event) {
|
||||||
|
const index = $tabs.index(this);
|
||||||
|
const last = $tabs.length - 1;
|
||||||
|
const destinations = {ArrowLeft: index === 0 ? last : index - 1, ArrowRight: index === last ? 0 : index + 1, Home: 0, End: last};
|
||||||
|
if (!Object.hasOwn(destinations, event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
selectTab(destinations[event.key], true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if ('IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
if ('IntersectionObserver' in window && !matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||||
const observer = new IntersectionObserver((entries) => {
|
const observer = new IntersectionObserver((entries) => {
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
|
|||||||
+267
-49
@@ -62,6 +62,7 @@ jQuery(function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$picker.on('studio:pick', (_event, type, callback) => openPicker(type, callback));
|
||||||
$picker.on('input', '[data-media-query]', renderPicker);
|
$picker.on('input', '[data-media-query]', renderPicker);
|
||||||
$picker.on('click', '[data-close-picker]', () => $picker.get(0).close());
|
$picker.on('click', '[data-close-picker]', () => $picker.get(0).close());
|
||||||
$picker.on('click', '.picker-item', function () {
|
$picker.on('click', '.picker-item', function () {
|
||||||
@@ -260,6 +261,17 @@ jQuery(function ($) {
|
|||||||
const $studio = $(this);
|
const $studio = $(this);
|
||||||
const $frame = $studio.find('iframe');
|
const $frame = $studio.find('iframe');
|
||||||
const $window = $studio.find('.studio-frame-window');
|
const $window = $studio.find('.studio-frame-window');
|
||||||
|
const $layout = $studio.closest('.studio-layout');
|
||||||
|
const $settings = $layout.find('.studio-inspector');
|
||||||
|
const $sizing = $studio.find('[data-media-sizing]');
|
||||||
|
const $elementTools = $studio.find('[data-element-tools]');
|
||||||
|
const heroOrOptional = '[data-studio-field="accent"], [data-studio-field="lead"], [data-studio-part="lead"], [data-studio-action], [data-studio-nav-index]';
|
||||||
|
const bodyElements = 'a, article, blockquote, details, div, dl, dt, dd, figure, h1, h2, h3, h4, h5, h6, hr, li, ol, p, pre, table, ul';
|
||||||
|
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] img, [data-studio-part="body"] audio, [data-studio-part="body"] video';
|
||||||
|
const $handle = $studio.find('[data-media-handle]');
|
||||||
|
const $mediaSize = $sizing.find('[data-media-size]');
|
||||||
|
const mediaWidthClass = /^studio-media-\d+$/;
|
||||||
|
|
||||||
function fitPreview() {
|
function fitPreview() {
|
||||||
const width = $window.width();
|
const width = $window.width();
|
||||||
const height = $window.height();
|
const height = $window.height();
|
||||||
@@ -273,24 +285,22 @@ jQuery(function ($) {
|
|||||||
left: (width - viewport * scale) / 2,
|
left: (width - viewport * scale) / 2,
|
||||||
transform: 'scale(' + scale + ')'
|
transform: 'scale(' + scale + ')'
|
||||||
});
|
});
|
||||||
|
positionSelection();
|
||||||
}
|
}
|
||||||
|
const $presets = $layout.find('[data-canvas-presets]');
|
||||||
|
const $templateStatus = $presets.find('[data-template-status]');
|
||||||
|
const $pending = $presets.find('[data-template-pending]');
|
||||||
|
const heroControls = new Map();
|
||||||
|
let selectedElement;
|
||||||
|
let selectedMedia;
|
||||||
|
let mediaDrag;
|
||||||
|
const selectionObserver = 'ResizeObserver' in window ? new ResizeObserver(positionSelection) : null;
|
||||||
if ('ResizeObserver' in window) {
|
if ('ResizeObserver' in window) {
|
||||||
new ResizeObserver(fitPreview).observe($window.get(0));
|
new ResizeObserver(fitPreview).observe($window.get(0));
|
||||||
} else {
|
} else {
|
||||||
$(window).on('resize', fitPreview);
|
$(window).on('resize', fitPreview);
|
||||||
}
|
}
|
||||||
fitPreview();
|
fitPreview();
|
||||||
const $layout = $studio.closest('.studio-layout');
|
|
||||||
const $settings = $layout.find('.studio-inspector');
|
|
||||||
const $sizing = $studio.find('[data-media-sizing]');
|
|
||||||
const $width = $sizing.find('[data-media-width]');
|
|
||||||
const availableWidths = Array.from($width.get(0).options, ({value}) => value).filter((value) => value !== '0');
|
|
||||||
const sizeClasses = availableWidths.map((value) => 'studio-media-' + value);
|
|
||||||
const $presets = $layout.find('[data-canvas-presets]');
|
|
||||||
const $templateStatus = $presets.find('[data-template-status]');
|
|
||||||
const $pending = $presets.find('[data-template-pending]');
|
|
||||||
const heroControls = new Map();
|
|
||||||
let selectedMedia;
|
|
||||||
$studio.on('click', '[data-preview-size]', function () {
|
$studio.on('click', '[data-preview-size]', function () {
|
||||||
const $button = $(this);
|
const $button = $(this);
|
||||||
$studio.toggleClass('studio-phone', $button.data('preview-size') === 'phone');
|
$studio.toggleClass('studio-phone', $button.data('preview-size') === 'phone');
|
||||||
@@ -316,15 +326,20 @@ jQuery(function ($) {
|
|||||||
let saveComplete = false;
|
let saveComplete = false;
|
||||||
|
|
||||||
function sectionChanges(withEdits = true) {
|
function sectionChanges(withEdits = true) {
|
||||||
return sections.flatMap(({key, version, fields, source}) => {
|
return sections.flatMap(({key, version, fields, source, template}) => {
|
||||||
const changes = {};
|
const changes = {};
|
||||||
for (const [field, {node, initial}] of Object.entries(fields)) {
|
for (const [field, {node, initial}] of Object.entries(fields)) {
|
||||||
const value = field === 'body' ? node.innerHTML : node.textContent;
|
let value = field === 'body' ? node.innerHTML : node.textContent;
|
||||||
|
if (field === 'body' && node.contains(selectedElement)) {
|
||||||
|
const copy = node.cloneNode(true);
|
||||||
|
$(copy).find('[data-studio-selected]').removeAttr('data-studio-selected');
|
||||||
|
value = copy.innerHTML;
|
||||||
|
}
|
||||||
if (version === null || value !== initial) {
|
if (version === null || value !== initial) {
|
||||||
changes[field] = withEdits && field === 'body' && version !== null ? bodyEdits(source, value) : value;
|
changes[field] = withEdits && field === 'body' && version !== null ? bodyEdits(source, value) : value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Object.keys(changes).length ? [{key, version, fields: changes}] : [];
|
return Object.keys(changes).length ? [{key, version, fields: changes, ...(template ? {template} : {})}] : [];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,6 +474,11 @@ jQuery(function ($) {
|
|||||||
$image.attr('alt', pageInput('alt').val());
|
$image.attr('alt', pageInput('alt').val());
|
||||||
}
|
}
|
||||||
$settings.find('[name="image"], [name="alt"]').on('input.canvas', syncImage);
|
$settings.find('[name="image"], [name="alt"]').on('input.canvas', syncImage);
|
||||||
|
heroControls.set('remove-image', () => {
|
||||||
|
pageInput('alt').val('');
|
||||||
|
pageInput('image_scale').val(0);
|
||||||
|
pageInput('image').val('').trigger('input');
|
||||||
|
});
|
||||||
syncImage();
|
syncImage();
|
||||||
$image.attr({tabindex: '0', role: 'button', 'aria-label': '编辑首屏图片'});
|
$image.attr({tabindex: '0', role: 'button', 'aria-label': '编辑首屏图片'});
|
||||||
heroControls.set('image', () => {
|
heroControls.set('image', () => {
|
||||||
@@ -491,7 +511,7 @@ jQuery(function ($) {
|
|||||||
}, null, true);
|
}, null, true);
|
||||||
};
|
};
|
||||||
heroControls.set(index, editButton);
|
heroControls.set(index, editButton);
|
||||||
$button.on('click', (event) => {
|
$button.on('dblclick studio:properties', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
editButton();
|
editButton();
|
||||||
});
|
});
|
||||||
@@ -513,7 +533,8 @@ jQuery(function ($) {
|
|||||||
const link = doc.createElement('a');
|
const link = doc.createElement('a');
|
||||||
link.href = safeLink(url) ? url : '#';
|
link.href = safeLink(url) ? url : '#';
|
||||||
link.textContent = label || url;
|
link.textContent = label || url;
|
||||||
link.addEventListener('click', (event) => {
|
link.dataset.studioNavIndex = index;
|
||||||
|
$(link).on('dblclick studio:properties', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
openProperties('本页目录链接', {label, url}, (next) => {
|
openProperties('本页目录链接', {label, url}, (next) => {
|
||||||
if (!next.label || /[|\r\n]/.test(next.label)) {
|
if (!next.label || /[|\r\n]/.test(next.label)) {
|
||||||
@@ -530,6 +551,14 @@ jQuery(function ($) {
|
|||||||
}
|
}
|
||||||
$navigation.prop('hidden', !$navContent.children().length);
|
$navigation.prop('hidden', !$navContent.children().length);
|
||||||
}
|
}
|
||||||
|
heroControls.set('change-nav', (index, copy) => {
|
||||||
|
const lines = navLines();
|
||||||
|
if (copy && $navContent.children().length >= 20) return null;
|
||||||
|
lines.splice(index + (copy ? 1 : 0), copy ? 0 : 1, ...(copy ? [lines[index]] : []));
|
||||||
|
$navInput.val(lines.join('\n'));
|
||||||
|
syncNavigation();
|
||||||
|
return $navContent.find('[data-studio-nav-index="' + (index + 1) + '"]').get(0);
|
||||||
|
});
|
||||||
$navInput.on('input.canvas', syncNavigation);
|
$navInput.on('input.canvas', syncNavigation);
|
||||||
heroControls.set('navigation', () => {
|
heroControls.set('navigation', () => {
|
||||||
openProperties('本页目录', {quicklinks: $navInput.val()}, ({quicklinks}) => {
|
openProperties('本页目录', {quicklinks: $navInput.val()}, ({quicklinks}) => {
|
||||||
@@ -592,48 +621,230 @@ jQuery(function ($) {
|
|||||||
const source = new TextDecoder('utf-8', {ignoreBOM: true}).decode(Uint8Array.from(
|
const source = new TextDecoder('utf-8', {ignoreBOM: true}).decode(Uint8Array.from(
|
||||||
atob(section.dataset.studioSource || ''), (byte) => byte.charCodeAt(0)
|
atob(section.dataset.studioSource || ''), (byte) => byte.charCodeAt(0)
|
||||||
));
|
));
|
||||||
sections.push({key: section.id, version, fields, source});
|
sections.push({key: section.id, version, fields, source, template: section.dataset.studioTemplate});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMediaWidth(node, width) {
|
function setMediaWidth(node, width) {
|
||||||
node.classList.remove(...sizeClasses);
|
for (const token of Array.from(node.classList).filter((name) => mediaWidthClass.test(name))) {
|
||||||
if (availableWidths.includes(width)) node.classList.add('studio-media-' + width);
|
node.classList.remove(token);
|
||||||
|
}
|
||||||
|
if (Number(width)) node.classList.add('studio-media-' + width);
|
||||||
|
else if (!node.classList.length) node.removeAttribute('class');
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectMedia(node) {
|
function sizingTarget() {
|
||||||
selectedMedia?.removeAttribute('data-studio-selected');
|
if (!selectedMedia?.isConnected) return null;
|
||||||
selectedMedia = node;
|
return selectedMedia.hasAttribute('data-studio-hero-image') ? selectedMedia.parentElement : selectedMedia;
|
||||||
if (!node) {
|
}
|
||||||
$sizing.prop('hidden', true);
|
|
||||||
|
function frameScale() {
|
||||||
|
const frame = $frame.get(0);
|
||||||
|
return frame.getBoundingClientRect().width / frame.offsetWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
function previewBounds(node) {
|
||||||
|
const frame = $frame.get(0).getBoundingClientRect();
|
||||||
|
const container = $window.get(0);
|
||||||
|
const origin = container.getBoundingClientRect();
|
||||||
|
const bounds = node.getBoundingClientRect();
|
||||||
|
const scale = frameScale();
|
||||||
|
const x = frame.left - origin.left - container.clientLeft;
|
||||||
|
const y = frame.top - origin.top - container.clientTop;
|
||||||
|
return {
|
||||||
|
left: x + bounds.left * scale, right: x + bounds.right * scale,
|
||||||
|
top: y + bounds.top * scale, bottom: y + bounds.bottom * scale,
|
||||||
|
width: bounds.width * scale, height: bounds.height * scale,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionSelection() {
|
||||||
|
const container = $window.get(0);
|
||||||
|
const node = sizingTarget();
|
||||||
|
if (node) {
|
||||||
|
const bounds = previewBounds(node);
|
||||||
|
const y = (bounds.top + bounds.bottom) / 2;
|
||||||
|
const visible = bounds.width > 0 && y >= 0 && y <= container.clientHeight
|
||||||
|
&& bounds.right > 0 && bounds.right <= container.clientWidth + 1;
|
||||||
|
$handle.prop('hidden', !mediaDrag && !visible);
|
||||||
|
$handle.css({left: Math.min(bounds.right, container.clientWidth - 11), top: y});
|
||||||
|
} else {
|
||||||
|
$handle.prop('hidden', true);
|
||||||
|
}
|
||||||
|
if (!selectedElement?.isConnected) {
|
||||||
|
$elementTools.prop('hidden', true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
node.setAttribute('data-studio-selected', '');
|
const bounds = previewBounds(selectedElement);
|
||||||
const width = node.hasAttribute('data-studio-hero-image') ? pageInput('image_scale').val()
|
const visible = bounds.width > 0 && bounds.height > 0 && bounds.right > 0
|
||||||
: availableWidths.find((value) => node.classList.contains('studio-media-' + value)) || '0';
|
&& bounds.left < container.clientWidth && bounds.bottom > 0 && bounds.top < container.clientHeight;
|
||||||
$width.val(width);
|
$elementTools.prop('hidden', !visible);
|
||||||
$sizing.prop('hidden', false);
|
if (!visible) return;
|
||||||
|
const maxX = container.clientWidth - $elementTools.outerWidth() - 5;
|
||||||
|
const height = $elementTools.outerHeight();
|
||||||
|
const above = bounds.top - height - 5;
|
||||||
|
const below = bounds.bottom + 5;
|
||||||
|
const y = above >= 5 || below + height > container.clientHeight ? above : below;
|
||||||
|
$elementTools.css({
|
||||||
|
left: Math.max(5, Math.min(bounds.left, maxX)),
|
||||||
|
top: Math.max(5, Math.min(y, container.clientHeight - height - 5)),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function currentMediaWidth(node) {
|
||||||
|
return Number(Array.from(node.classList).find((name) => mediaWidthClass.test(name))?.slice('studio-media-'.length)) || 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMediaWidth(width) {
|
||||||
|
$mediaSize.text(width ? width + '%' : '原始尺寸');
|
||||||
|
$handle.attr({'aria-valuenow': width || 100, 'aria-valuetext': width ? width + '%' : '原始尺寸'});
|
||||||
|
}
|
||||||
|
|
||||||
|
function editableBodyElement(node) {
|
||||||
|
const body = node.closest('[data-studio-part="body"]');
|
||||||
|
if (!body) return null;
|
||||||
|
const element = node.closest(bodyElements);
|
||||||
|
return element !== body && body.contains(element) ? element : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectElement(node) {
|
||||||
|
selectionObserver?.disconnect();
|
||||||
|
selectedElement?.removeAttribute('data-studio-selected');
|
||||||
|
selectedElement = node;
|
||||||
|
selectedMedia = node?.matches(mediaTargets) ? node : null;
|
||||||
|
$sizing.prop('hidden', !selectedMedia);
|
||||||
|
if (node) {
|
||||||
|
node.setAttribute('data-studio-selected', '');
|
||||||
|
const target = sizingTarget();
|
||||||
|
const nav = node.hasAttribute('data-studio-nav-index');
|
||||||
|
const inBody = node.closest('[data-studio-part="body"]') !== null;
|
||||||
|
const canCopy = inBody || (nav && $(node).siblings().length < 19);
|
||||||
|
const hasProperties = selectedMedia || node.matches('a');
|
||||||
|
$elementTools.find('[data-element-copy]').prop('hidden', !canCopy);
|
||||||
|
$elementTools.find('[data-element-properties]').prop('hidden', !hasProperties);
|
||||||
|
if (target) showMediaWidth(currentMediaWidth(target));
|
||||||
|
selectionObserver?.observe(target || node);
|
||||||
|
}
|
||||||
|
positionSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeElement(copy) {
|
||||||
|
const node = selectedElement;
|
||||||
|
if (!node?.isConnected) return;
|
||||||
|
const {studioField, studioAction, studioNavIndex} = node.dataset;
|
||||||
|
const inBody = node.closest('[data-studio-part="body"]') !== null;
|
||||||
|
selectElement(null);
|
||||||
|
if (inBody) {
|
||||||
|
if (copy) {
|
||||||
|
const $clone = $(node.cloneNode(true));
|
||||||
|
$clone.find('[id]').addBack('[id]').removeAttr('id');
|
||||||
|
$(node).after($clone);
|
||||||
|
selectElement($clone.get(0));
|
||||||
|
} else {
|
||||||
|
$(node).remove();
|
||||||
|
savedRange = null;
|
||||||
|
}
|
||||||
|
} else if (studioNavIndex !== undefined) {
|
||||||
|
const next = heroControls.get('change-nav')(Number(studioNavIndex), copy);
|
||||||
|
if (copy && next) selectElement(next);
|
||||||
|
} else if (!copy) {
|
||||||
|
if (node.hasAttribute('data-studio-hero-image')) {
|
||||||
|
heroControls.get('remove-image')();
|
||||||
|
} else if (studioAction) {
|
||||||
|
pageInput('label' + studioAction).val('');
|
||||||
|
pageInput('url' + studioAction).val('').trigger('input');
|
||||||
|
} else if (studioField) {
|
||||||
|
pageInput(studioField).val('').trigger('input');
|
||||||
|
} else {
|
||||||
|
$(node).text('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$elementTools.on('click', '[data-element-copy]', () => changeElement(true))
|
||||||
|
.on('click', '[data-element-delete]', () => changeElement(false))
|
||||||
|
.on('click', '[data-element-properties]', () => {
|
||||||
|
if (selectedMedia) replaceMedia();
|
||||||
|
else if (selectedElement?.matches('[data-studio-action], [data-studio-nav-index]')) {
|
||||||
|
$(selectedElement).triggerHandler('studio:properties');
|
||||||
|
} else if (selectedElement?.matches('a')) {
|
||||||
|
editResource(selectedElement);
|
||||||
|
}
|
||||||
|
}).on('keydown', (event) => {
|
||||||
|
if (event.key === 'Escape') selectElement(null);
|
||||||
|
});
|
||||||
|
|
||||||
function replaceMedia() {
|
function replaceMedia() {
|
||||||
if (!selectedMedia?.isConnected) return;
|
if (!selectedMedia?.isConnected) return;
|
||||||
if (selectedMedia.hasAttribute('data-studio-hero-image')) heroControls.get('image')();
|
if (selectedMedia.hasAttribute('data-studio-hero-image')) heroControls.get('image')();
|
||||||
else editResource(selectedMedia);
|
else editResource(selectedMedia);
|
||||||
}
|
}
|
||||||
|
|
||||||
$width.on('change', function () {
|
function measureMedia() {
|
||||||
if (!selectedMedia?.isConnected) return;
|
const node = sizingTarget();
|
||||||
const hero = selectedMedia.hasAttribute('data-studio-hero-image');
|
const width = currentMediaWidth(node);
|
||||||
if (hero) pageInput('image_scale').val(this.value);
|
const natural = node.getBoundingClientRect().width;
|
||||||
setMediaWidth(hero ? selectedMedia.parentElement : selectedMedia, this.value);
|
const classes = node.getAttribute('class');
|
||||||
|
setMediaWidth(node, 100);
|
||||||
|
const full = node.getBoundingClientRect();
|
||||||
|
setMediaWidth(node, 10);
|
||||||
|
const narrow = node.getBoundingClientRect();
|
||||||
|
if (classes === null) node.removeAttribute('class');
|
||||||
|
else node.setAttribute('class', classes);
|
||||||
|
const rightEdgeTravel = (full.right - narrow.right) / .9;
|
||||||
|
const available = rightEdgeTravel > full.width * .15 ? rightEdgeTravel : full.width;
|
||||||
|
return {available, initialWidth: width || Math.round(100 * natural / (full.width || natural || 1))};
|
||||||
|
}
|
||||||
|
|
||||||
|
function resizeMedia(width) {
|
||||||
|
const node = sizingTarget();
|
||||||
|
if (!node) return;
|
||||||
|
const next = width === null ? 0 : Math.round(Math.max(10, Math.min(100, width)));
|
||||||
|
if (selectedMedia.hasAttribute('data-studio-hero-image')) pageInput('image_scale').val(next);
|
||||||
|
if (next !== currentMediaWidth(node)) setMediaWidth(node, next);
|
||||||
|
showMediaWidth(next);
|
||||||
|
positionSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
$handle.on('pointerdown', function (event) {
|
||||||
|
const pointer = event.originalEvent;
|
||||||
|
if (pointer.button !== 0 || !sizingTarget()) return;
|
||||||
|
event.preventDefault();
|
||||||
|
this.focus({preventScroll: true});
|
||||||
|
mediaDrag = {...measureMedia(), x: pointer.clientX, scale: frameScale(), id: pointer.pointerId};
|
||||||
|
this.setPointerCapture(pointer.pointerId);
|
||||||
|
}).on('pointermove', (event) => {
|
||||||
|
const pointer = event.originalEvent;
|
||||||
|
if (!mediaDrag || mediaDrag.id !== pointer.pointerId || !mediaDrag.available) return;
|
||||||
|
if (pointer.clientX !== mediaDrag.x || mediaDrag.moved) {
|
||||||
|
mediaDrag.moved = true;
|
||||||
|
resizeMedia(mediaDrag.initialWidth + 100 * (pointer.clientX - mediaDrag.x) / (mediaDrag.available * mediaDrag.scale));
|
||||||
|
}
|
||||||
|
}).on('lostpointercapture', () => {
|
||||||
|
mediaDrag = null;
|
||||||
|
positionSelection();
|
||||||
|
}).on('keydown', (event) => {
|
||||||
|
if (!sizingTarget() || !['ArrowLeft', 'ArrowDown', 'ArrowRight', 'ArrowUp', 'Home', 'End'].includes(event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
const step = event.shiftKey ? 10 : 1;
|
||||||
|
const {initialWidth} = measureMedia();
|
||||||
|
const increase = ['ArrowRight', 'ArrowUp'].includes(event.key);
|
||||||
|
const next = {Home: 10, End: 100}[event.key] ?? initialWidth + (increase ? step : -step);
|
||||||
|
resizeMedia(next);
|
||||||
});
|
});
|
||||||
$sizing.on('click', '[data-replace-media]', replaceMedia);
|
$sizing.on('click', '[data-replace-media]', replaceMedia)
|
||||||
|
.on('click', '[data-reset-media]', () => resizeMedia(null));
|
||||||
$layout.on('click', '[data-hero-control]', function () {
|
$layout.on('click', '[data-hero-control]', function () {
|
||||||
heroControls.get(this.dataset.heroControl)?.();
|
heroControls.get(this.dataset.heroControl)?.();
|
||||||
});
|
});
|
||||||
$presets.on('mousedown', '[data-canvas-template]', (event) => event.preventDefault());
|
$presets.on('mousedown', '[data-canvas-template]', (event) => event.preventDefault());
|
||||||
$presets.on('click', '[data-canvas-template]', function () {
|
$presets.on('click', '[data-canvas-template]', function () {
|
||||||
const markup = $presets.find('template[data-preset="' + this.dataset.canvasTemplate + '"]').get(0).innerHTML;
|
const markup = $presets.find('template[data-preset="' + this.dataset.canvasTemplate + '"]').get(0).innerHTML;
|
||||||
|
const template = this.dataset.canvasTemplate;
|
||||||
if ($presets.find('[data-template-inline]').prop('checked')) {
|
if ($presets.find('[data-template-inline]').prop('checked')) {
|
||||||
|
if (template === 'articles') {
|
||||||
|
$templateStatus.text('分类文章需要作为独立区块添加。');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!activeBody) {
|
if (!activeBody) {
|
||||||
$templateStatus.text('先在画布中选择要插入的区块正文。');
|
$templateStatus.text('先在画布中选择要插入的区块正文。');
|
||||||
return;
|
return;
|
||||||
@@ -658,6 +869,11 @@ jQuery(function ($) {
|
|||||||
title.textContent = this.dataset.templateTitle;
|
title.textContent = this.dataset.templateTitle;
|
||||||
section.setAttribute('aria-labelledby', title.id);
|
section.setAttribute('aria-labelledby', title.id);
|
||||||
section.querySelector('[data-studio-part="body"]').innerHTML = markup;
|
section.querySelector('[data-studio-part="body"]').innerHTML = markup;
|
||||||
|
if (template === 'articles') {
|
||||||
|
section.dataset.studioTemplate = template;
|
||||||
|
$('<p>', {class: 'empty-state', text: '保存页面后可在图层的区块设置中选择分类和展示方式。'})
|
||||||
|
.insertBefore($(section).find('[data-studio-part="body"]'));
|
||||||
|
}
|
||||||
end.before(section);
|
end.before(section);
|
||||||
registerSection(section, null);
|
registerSection(section, null);
|
||||||
section.scrollIntoView({block: 'start'});
|
section.scrollIntoView({block: 'start'});
|
||||||
@@ -667,7 +883,7 @@ jQuery(function ($) {
|
|||||||
$pending.prop('hidden', false);
|
$pending.prop('hidden', false);
|
||||||
$cancel.on('click', () => {
|
$cancel.on('click', () => {
|
||||||
if (section.contains(activeBody)) selectBody(null);
|
if (section.contains(activeBody)) selectBody(null);
|
||||||
if (section.contains(selectedMedia)) selectMedia(null);
|
if (section.contains(selectedElement)) selectElement(null);
|
||||||
section.remove();
|
section.remove();
|
||||||
sections = sections.filter(({key}) => key !== id);
|
sections = sections.filter(({key}) => key !== id);
|
||||||
$item.remove();
|
$item.remove();
|
||||||
@@ -685,7 +901,7 @@ jQuery(function ($) {
|
|||||||
$settings.find(':input').off('.canvas');
|
$settings.find(':input').off('.canvas');
|
||||||
bindPage($doc);
|
bindPage($doc);
|
||||||
selectBody(null);
|
selectBody(null);
|
||||||
selectMedia(null);
|
selectElement(null);
|
||||||
$pending.empty().prop('hidden', true);
|
$pending.empty().prop('hidden', true);
|
||||||
sections = [];
|
sections = [];
|
||||||
$doc.find('[data-studio-section]').each((_, section) => registerSection(section));
|
$doc.find('[data-studio-section]').each((_, section) => registerSection(section));
|
||||||
@@ -693,30 +909,32 @@ jQuery(function ($) {
|
|||||||
$doc.on('focusin.canvas', '[contenteditable]', function () {
|
$doc.on('focusin.canvas', '[contenteditable]', function () {
|
||||||
selectBody(this.dataset.studioPart === 'body' ? this : null);
|
selectBody(this.dataset.studioPart === 'body' ? this : null);
|
||||||
});
|
});
|
||||||
$doc.on('selectionchange.canvas', rememberSelection);
|
$doc.on('selectionchange.canvas', rememberSelection).on('scroll.canvas', positionSelection);
|
||||||
$doc.on('click.canvas', (event) => {
|
|
||||||
if (!event.target.closest?.('[data-studio-selected]')) selectMedia(null);
|
|
||||||
});
|
|
||||||
$doc.on('click.canvas auxclick.canvas', 'a', (event) => event.preventDefault());
|
$doc.on('click.canvas auxclick.canvas', 'a', (event) => event.preventDefault());
|
||||||
const mediaTargets = '[data-studio-hero-image], [data-studio-part="body"] img, [data-studio-part="body"] audio, [data-studio-part="body"] video';
|
|
||||||
$doc.on('click.canvas dblclick.canvas', mediaTargets, function (event) {
|
$doc.on('click.canvas dblclick.canvas', mediaTargets, function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
selectBody(this.closest('[data-studio-part="body"]'));
|
selectBody(this.closest('[data-studio-part="body"]'));
|
||||||
selectMedia(this);
|
selectElement(this);
|
||||||
if (event.type === 'dblclick') replaceMedia();
|
if (event.type === 'dblclick') replaceMedia();
|
||||||
});
|
});
|
||||||
$doc.on('click.canvas', '[data-studio-part="body"] a', function (event) {
|
$doc.on('click.canvas', (event) => {
|
||||||
|
const node = event.target;
|
||||||
|
const optional = node.closest?.(heroOrOptional);
|
||||||
|
selectElement(doc.getSelection()?.isCollapsed ? optional || editableBodyElement(node) : null);
|
||||||
|
});
|
||||||
|
$doc.on('dblclick.canvas', '[data-studio-part="body"] a', function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if ($(this).find('img, audio, video').length && event.target.closest('img, audio, video')) return;
|
if (!event.target.closest(mediaTargets)) editResource(this);
|
||||||
selectBody(this.closest('[data-studio-part="body"]'));
|
});
|
||||||
editResource(this);
|
$doc.on('keydown.canvas', (event) => {
|
||||||
|
if (event.key === 'Escape') selectElement(null);
|
||||||
});
|
});
|
||||||
$doc.on('keydown.canvas', '[data-studio-hero-image]', function (event) {
|
$doc.on('keydown.canvas', '[data-studio-hero-image]', function (event) {
|
||||||
if (event.key === 'Enter' || event.key === ' ') {
|
if (event.key === 'Enter' || event.key === ' ') {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
selectMedia(this);
|
selectElement(this);
|
||||||
$width.trigger('focus');
|
$handle.trigger('focus');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$doc.on('beforeinput.canvas', '[contenteditable="plaintext-only"]', (event) => {
|
$doc.on('beforeinput.canvas', '[contenteditable="plaintext-only"]', (event) => {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 7.4 KiB |
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 NHN Cloud Corp.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+162
@@ -0,0 +1,162 @@
|
|||||||
|
/*!
|
||||||
|
* TOAST UI Editor : i18n
|
||||||
|
* @version 3.2.2
|
||||||
|
* @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
(function webpackUniversalModuleDefinition(root, factory) {
|
||||||
|
if(typeof exports === 'object' && typeof module === 'object')
|
||||||
|
module.exports = factory(require("@toast-ui/editor"));
|
||||||
|
else if(typeof define === 'function' && define.amd)
|
||||||
|
define(["@toast-ui/editor"], factory);
|
||||||
|
else {
|
||||||
|
var a = typeof exports === 'object' ? factory(require("@toast-ui/editor")) : factory(root["toastui"]["Editor"]);
|
||||||
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
||||||
|
}
|
||||||
|
})(self, function(__WEBPACK_EXTERNAL_MODULE__213__) {
|
||||||
|
return /******/ (function() { // webpackBootstrap
|
||||||
|
/******/ "use strict";
|
||||||
|
/******/ var __webpack_modules__ = ({
|
||||||
|
|
||||||
|
/***/ 213:
|
||||||
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
module.exports = __WEBPACK_EXTERNAL_MODULE__213__;
|
||||||
|
|
||||||
|
/***/ })
|
||||||
|
|
||||||
|
/******/ });
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ // The module cache
|
||||||
|
/******/ var __webpack_module_cache__ = {};
|
||||||
|
/******/
|
||||||
|
/******/ // The require function
|
||||||
|
/******/ function __webpack_require__(moduleId) {
|
||||||
|
/******/ // Check if module is in cache
|
||||||
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||||
|
/******/ if (cachedModule !== undefined) {
|
||||||
|
/******/ return cachedModule.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/ // Create a new module (and put it into the cache)
|
||||||
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||||
|
/******/ // no module.id needed
|
||||||
|
/******/ // no module.loaded needed
|
||||||
|
/******/ exports: {}
|
||||||
|
/******/ };
|
||||||
|
/******/
|
||||||
|
/******/ // Execute the module function
|
||||||
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||||
|
/******/
|
||||||
|
/******/ // Return the exports of the module
|
||||||
|
/******/ return module.exports;
|
||||||
|
/******/ }
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/compat get default export */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||||
|
/******/ __webpack_require__.n = function(module) {
|
||||||
|
/******/ var getter = module && module.__esModule ?
|
||||||
|
/******/ function() { return module['default']; } :
|
||||||
|
/******/ function() { return module; };
|
||||||
|
/******/ __webpack_require__.d(getter, { a: getter });
|
||||||
|
/******/ return getter;
|
||||||
|
/******/ };
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __webpack_require__.d = function(exports, definition) {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ !function() {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __webpack_require__.r = function(exports) {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ }();
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
|
!function() {
|
||||||
|
__webpack_require__.r(__webpack_exports__);
|
||||||
|
/* harmony import */ var _editorCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(213);
|
||||||
|
/* harmony import */ var _editorCore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_editorCore__WEBPACK_IMPORTED_MODULE_0__);
|
||||||
|
/**
|
||||||
|
* @fileoverview I18N for Chinese
|
||||||
|
* @author NHN Cloud FE Development Lab <dl_javascript@nhn.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
_editorCore__WEBPACK_IMPORTED_MODULE_0___default().setLanguage('zh-CN', {
|
||||||
|
Markdown: 'Markdown',
|
||||||
|
WYSIWYG: '所见即所得',
|
||||||
|
Write: '编辑',
|
||||||
|
Preview: '预览',
|
||||||
|
Headings: '标题',
|
||||||
|
Paragraph: '文本',
|
||||||
|
Bold: '加粗',
|
||||||
|
Italic: '斜体字',
|
||||||
|
Strike: '删除线',
|
||||||
|
Code: '内嵌代码',
|
||||||
|
Line: '水平线',
|
||||||
|
Blockquote: '引用块',
|
||||||
|
'Unordered list': '无序列表',
|
||||||
|
'Ordered list': '有序列表',
|
||||||
|
Task: '任务',
|
||||||
|
Indent: '缩进',
|
||||||
|
Outdent: '减少缩进',
|
||||||
|
'Insert link': '插入链接',
|
||||||
|
'Insert CodeBlock': '插入代码块',
|
||||||
|
'Insert table': '插入表格',
|
||||||
|
'Insert image': '插入图片',
|
||||||
|
Heading: '标题',
|
||||||
|
'Image URL': '图片网址',
|
||||||
|
'Select image file': '选择图片文件',
|
||||||
|
'Choose a file': '选择一个文件',
|
||||||
|
'No file': '没有文件',
|
||||||
|
Description: '说明',
|
||||||
|
OK: '确认',
|
||||||
|
More: '更多',
|
||||||
|
Cancel: '取消',
|
||||||
|
File: '文件',
|
||||||
|
URL: 'URL',
|
||||||
|
'Link text': '链接文本',
|
||||||
|
'Add row to up': '向上添加行',
|
||||||
|
'Add row to down': '在下方添加行',
|
||||||
|
'Add column to left': '在左侧添加列',
|
||||||
|
'Add column to right': '在右侧添加列',
|
||||||
|
'Remove row': '删除行',
|
||||||
|
'Remove column': '删除列',
|
||||||
|
'Align column to left': '左对齐',
|
||||||
|
'Align column to center': '居中对齐',
|
||||||
|
'Align column to right': '右对齐',
|
||||||
|
'Remove table': '删除表格',
|
||||||
|
'Would you like to paste as table?': '需要粘贴为表格吗?',
|
||||||
|
'Text color': '文字颜色',
|
||||||
|
'Auto scroll enabled': '自动滚动已启用',
|
||||||
|
'Auto scroll disabled': '自动滚动已禁用',
|
||||||
|
'Choose language': '选择语言',
|
||||||
|
});
|
||||||
|
|
||||||
|
}();
|
||||||
|
/******/ return __webpack_exports__;
|
||||||
|
/******/ })()
|
||||||
|
;
|
||||||
|
});
|
||||||
+13
-22
@@ -15,7 +15,6 @@ CREATE TABLE IF NOT EXISTS pages (
|
|||||||
image_scale INTEGER NOT NULL DEFAULT 0,
|
image_scale INTEGER NOT NULL DEFAULT 0,
|
||||||
actions TEXT NOT NULL,
|
actions TEXT NOT NULL,
|
||||||
quicklinks TEXT NOT NULL,
|
quicklinks TEXT NOT NULL,
|
||||||
partners TEXT NOT NULL,
|
|
||||||
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
|
status TEXT NOT NULL DEFAULT 'published' CHECK (status IN ('draft', 'published')),
|
||||||
updated_at TEXT,
|
updated_at TEXT,
|
||||||
version INTEGER NOT NULL DEFAULT 0
|
version INTEGER NOT NULL DEFAULT 0
|
||||||
@@ -26,6 +25,7 @@ CREATE TABLE IF NOT EXISTS sections (
|
|||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
lead TEXT NOT NULL,
|
lead TEXT NOT NULL,
|
||||||
style TEXT NOT NULL DEFAULT 'plain',
|
style TEXT NOT NULL DEFAULT 'plain',
|
||||||
|
feed TEXT,
|
||||||
body TEXT NOT NULL,
|
body TEXT NOT NULL,
|
||||||
position INTEGER NOT NULL,
|
position INTEGER NOT NULL,
|
||||||
version INTEGER NOT NULL DEFAULT 0,
|
version INTEGER NOT NULL DEFAULT 0,
|
||||||
@@ -35,9 +35,10 @@ CREATE TABLE IF NOT EXISTS articles (
|
|||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
slug TEXT NOT NULL UNIQUE,
|
slug TEXT NOT NULL UNIQUE,
|
||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
category TEXT NOT NULL CHECK (category IN ('announcement','news','product')),
|
|
||||||
summary TEXT NOT NULL,
|
summary TEXT NOT NULL,
|
||||||
body TEXT NOT NULL,
|
body TEXT NOT NULL,
|
||||||
|
body_format TEXT NOT NULL DEFAULT 'markdown' CHECK (body_format IN ('markdown', 'html')),
|
||||||
|
card TEXT NOT NULL DEFAULT '{}',
|
||||||
tags TEXT NOT NULL,
|
tags TEXT NOT NULL,
|
||||||
status TEXT NOT NULL CHECK (status IN ('draft','published')),
|
status TEXT NOT NULL CHECK (status IN ('draft','published')),
|
||||||
published_at TEXT,
|
published_at TEXT,
|
||||||
@@ -46,6 +47,16 @@ CREATE TABLE IF NOT EXISTS articles (
|
|||||||
version INTEGER NOT NULL DEFAULT 0
|
version INTEGER NOT NULL DEFAULT 0
|
||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS articles_public ON articles (status, published_at DESC, id DESC);
|
CREATE INDEX IF NOT EXISTS articles_public ON articles (status, published_at DESC, id DESC);
|
||||||
|
CREATE TABLE IF NOT EXISTS article_categories (
|
||||||
|
slug TEXT PRIMARY KEY,
|
||||||
|
name TEXT NOT NULL
|
||||||
|
);
|
||||||
|
CREATE TABLE IF NOT EXISTS article_category_links (
|
||||||
|
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE,
|
||||||
|
category_slug TEXT NOT NULL REFERENCES article_categories(slug),
|
||||||
|
PRIMARY KEY (article_id, category_slug)
|
||||||
|
);
|
||||||
|
CREATE INDEX IF NOT EXISTS article_categories_lookup ON article_category_links (category_slug, article_id);
|
||||||
CREATE TABLE IF NOT EXISTS article_redirects (
|
CREATE TABLE IF NOT EXISTS article_redirects (
|
||||||
slug TEXT PRIMARY KEY,
|
slug TEXT PRIMARY KEY,
|
||||||
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE
|
article_id INTEGER NOT NULL REFERENCES articles(id) ON DELETE CASCADE
|
||||||
@@ -60,26 +71,6 @@ CREATE TABLE IF NOT EXISTS login_attempts (
|
|||||||
attempts INTEGER NOT NULL,
|
attempts INTEGER NOT NULL,
|
||||||
expires_at INTEGER NOT NULL
|
expires_at INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
||||||
name TEXT PRIMARY KEY
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS catalog (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
name TEXT NOT NULL,
|
|
||||||
category TEXT NOT NULL,
|
|
||||||
body TEXT NOT NULL,
|
|
||||||
image TEXT NOT NULL,
|
|
||||||
alt TEXT NOT NULL,
|
|
||||||
url TEXT NOT NULL,
|
|
||||||
label TEXT NOT NULL,
|
|
||||||
extra_url TEXT NOT NULL DEFAULT '',
|
|
||||||
extra_label TEXT NOT NULL DEFAULT '',
|
|
||||||
position INTEGER NOT NULL DEFAULT 0,
|
|
||||||
version INTEGER NOT NULL DEFAULT 0
|
|
||||||
);
|
|
||||||
CREATE INDEX IF NOT EXISTS catalog_order ON catalog (position, id);
|
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS media (
|
CREATE TABLE IF NOT EXISTS media (
|
||||||
name TEXT PRIMARY KEY,
|
name TEXT PRIMARY KEY,
|
||||||
label TEXT NOT NULL,
|
label TEXT NOT NULL,
|
||||||
|
|||||||
+229
-57
@@ -34,7 +34,7 @@
|
|||||||
"key": "product",
|
"key": "product",
|
||||||
"title": "产品与服务",
|
"title": "产品与服务",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<div class=\"project-stack\"><article class=\"project\"><div><img src=\"/assets/original/pagepan-editor-optimized.webp\" alt=\"PAGEPAN 可视化网页编辑器\" loading=\"lazy\"></div><div><span class=\"overline\">可视化建站</span><h3>PAGEPAN 小飞页</h3><p>自托管拖拽建站工具。由 UI 中国签约的飞屋设计团队打造,可在自己的服务器上运行。</p><p>无需代码,五分钟 DIY 网站,每一处细节都可定制。提供永久免费版本,VIP 版本最低 ¥79/年。</p><div class=\"actions\"><a class=\"button button-primary\" href=\"/pagepan\">探索 PAGEPAN</a><a href=\"/pagepan#download\">免费体验</a></div></div></article><article class=\"project\"><div><img src=\"/assets/original/highspeaker-ui-optimized.webp\" alt=\"HighSpeaker DNS 管理界面\" loading=\"lazy\"></div><div><span class=\"overline\">开源基础软件</span><h3>HighSpeaker DNS</h3><p>新一代智能 DNS 系统。企业和云服务商可以私有化或内网部署,也可二次开发,提供多租户、可分销的 SaaS 服务。</p><p>100% 开源免费。</p><a class=\"button button-primary\" href=\"/highspeaker\">探索 HighSpeaker</a></div></article><article class=\"project\"><div><img src=\"/assets/original/copyright.webp\" alt=\"软件著作权服务插图\" loading=\"lazy\"></div><div><span class=\"overline\">软件著作权</span><h3>来笙软著代理</h3><p>提供申请代理、材料审核与优化、合作开发合同模板。</p><div class=\"actions\"><a class=\"button button-primary\" href=\"/sc\">查看软著服务</a><a href=\"/shnu-sc\">查看 SHNU 学生方案</a></div></div></article></div>",
|
"body": "<div class=\"project-stack\"><article class=\"project\"><div><img src=\"/assets/original/pagepan-editor-optimized.webp\" alt=\"PAGEPAN 可视化网页编辑器\" loading=\"lazy\"></div><div><span class=\"overline\">可视化建站</span><h3>PAGEPAN 小飞页</h3><p>自托管拖拽建站工具。由 UI 中国签约的飞屋设计团队打造,可在自己的服务器上运行。</p><p>无需代码,五分钟 DIY 网站,每一处细节都可定制。提供永久免费版本,VIP 版本最低 ¥79/年。</p><div class=\"actions\"><a class=\"button button-primary\" href=\"/pagepan\">探索 PAGEPAN</a><a href=\"/pagepan#download\">免费体验</a></div></div></article><article class=\"project\"><div><img src=\"/assets/original/highspeaker-ui-optimized.webp\" alt=\"HighSpeaker DNS 管理界面\" loading=\"lazy\"></div><div><span class=\"overline\">开源基础软件</span><h3>HighSpeaker DNS</h3><p>新一代智能 DNS 系统。企业和云服务商可以私有化或内网部署,也可二次开发,提供多租户、可分销的 SaaS 服务。</p><p>100% 开源免费。</p><a class=\"button button-primary\" href=\"/highspeaker\">探索 HighSpeaker</a></div></article></div>",
|
||||||
"style": "projects"
|
"style": "projects"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -43,56 +43,22 @@
|
|||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<p>来笙是由上海师范大学、华东理工大学、沈阳建筑大学、华南师范大学等多所高校学生发起的合作跨校的自主创业项目。致力于提供独特、优质的企行业软件和面向开发者的个人工具软件。</p><p>来笙致力于通过研发互联网基础软件和产品,解决互联网基础产品痛点痒点,为构建更好互联网持续做出努力。</p>",
|
"body": "<p>来笙是由上海师范大学、华东理工大学、沈阳建筑大学、华南师范大学等多所高校学生发起的合作跨校的自主创业项目。致力于提供独特、优质的企行业软件和面向开发者的个人工具软件。</p><p>来笙致力于通过研发互联网基础软件和产品,解决互联网基础产品痛点痒点,为构建更好互联网持续做出努力。</p>",
|
||||||
"style": "about"
|
"style": "about"
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"key": "blog",
|
||||||
|
"title": "来笙动态",
|
||||||
|
"lead": "",
|
||||||
|
"style": "plain",
|
||||||
|
"body": "<p><a class=\"back-link\" href=\"/articles\">查看全部动态</a></p>",
|
||||||
|
"feed": {
|
||||||
|
"categories": [
|
||||||
|
"announcement",
|
||||||
|
"news",
|
||||||
|
"product"
|
||||||
],
|
],
|
||||||
"partners": [
|
"mode": "merged",
|
||||||
{
|
"limit": 3
|
||||||
"name": "HighSpeaker DNS",
|
}
|
||||||
"image": "/assets/original/highspeaker-logo-optimized.webp",
|
|
||||||
"url": "/highspeaker",
|
|
||||||
"group": "来笙支持项目"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "FW Network",
|
|
||||||
"image": "/assets/original/fw-banner.svg",
|
|
||||||
"url": "https://fw.ac.cn/",
|
|
||||||
"group": "来笙合作伙伴"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "IdealShark",
|
|
||||||
"image": "/assets/original/IdealShark_B.png",
|
|
||||||
"url": "",
|
|
||||||
"group": "来笙支持项目"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "MimirLib",
|
|
||||||
"image": "/assets/original/mimirlib.png",
|
|
||||||
"url": "",
|
|
||||||
"group": "来笙支持项目"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "NoNat",
|
|
||||||
"image": "/assets/original/nonat-optimized.webp",
|
|
||||||
"url": "https://nonat.eu.org/",
|
|
||||||
"group": "来笙支持项目"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "PAGEPAN",
|
|
||||||
"image": "/assets/original/papepan-logo.svg",
|
|
||||||
"url": "https://pagepan.com/",
|
|
||||||
"group": "来笙合作伙伴"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "LayFi",
|
|
||||||
"image": "",
|
|
||||||
"url": "https://www.layfi.de",
|
|
||||||
"group": "来笙支持项目"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "OneProvider",
|
|
||||||
"image": "/assets/original/oneprovider_invert.svg",
|
|
||||||
"url": "https://oneprovider.com/",
|
|
||||||
"group": "来笙合作伙伴"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -146,7 +112,7 @@
|
|||||||
"key": "features",
|
"key": "features",
|
||||||
"title": "建站工具与功能",
|
"title": "建站工具与功能",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<img src=\"/assets/original/pagepan-example.webp\" alt=\"用 PAGEPAN 搭建的响应式网站在电脑和手机上的效果\" loading=\"lazy\" width=\"1366\" height=\"768\"><div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><h3>字体管理器</h3>\n<p>几千种开源字体随意添加选用。附带字体压缩功能和缓存器功能,再也不用为加载字体付出高额流量费!</p></article><article class=\"content-card feature-card\"><h3>文件管理器</h3>\n<p>什么年代了还需要FTP?不存在的。图片、文档、视频、压缩包,全都由可视化的文件管理器来管理,随时取用~</p></article><article class=\"content-card feature-card\"><h3>代码编辑器</h3>\n<p>PAGEPAN已经不能满足你了?没关系。每一个组件,包括公共页头页脚你都可以打开Html编辑器修改其代码,依旧所见即所得。你甚至可以编写PHP脚本。</p></article><article class=\"content-card feature-card\"><h3>COS、CDN</h3>\n<p>可以将所有静态内容传入腾讯云COS,或接入任意CDN。让你的网站快如闪电!</p></article><article class=\"content-card feature-card\"><h3>Sitemap一键生成</h3>\n<p>自动挖掘Sitemap,一键即可生成!</p></article><article class=\"content-card feature-card\"><h3>All for SEO</h3>\n<p>SEO优化友好,加快网站收录速度。</p></article><article class=\"content-card feature-card\"><h3>动态组件(CMS)</h3>\n<p>无论是新闻、列表、博客、文章、产品,都可以通过动态内容来实现类似于CMS的体验。支持Html和Markdown双编辑器自由切换。不是CMS,但是超越CMS!</p></article><article class=\"content-card feature-card\"><h3>渐变色调色器</h3>\n<p>自带渐变调色器。任何组件任何文字都可以设置为魅力十足的渐变色。</p></article><article class=\"content-card feature-card\"><h3>多语言支持</h3>\n<p>一个站点,多种语言,任意切换,实现面向全球!</p></article></div><p><a href=\"https://pagepan.com/home\">访问 PAGEPAN 官网</a></p>",
|
"body": "<img src=\"/assets/original/pagepan-example.webp\" alt=\"用 PAGEPAN 搭建的响应式网站在电脑和手机上的效果\" loading=\"lazy\" width=\"1366\" height=\"768\"><div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/fonts.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>字体管理器</h3>\n<p>几千种开源字体随意添加选用。附带字体压缩功能和缓存器功能,再也不用为加载字体付出高额流量费!</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/files.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>文件管理器</h3>\n<p>什么年代了还需要FTP?不存在的。图片、文档、视频、压缩包,全都由可视化的文件管理器来管理,随时取用~</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/code.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>代码编辑器</h3>\n<p>PAGEPAN已经不能满足你了?没关系。每一个组件,包括公共页头页脚你都可以打开Html编辑器修改其代码,依旧所见即所得。你甚至可以编写PHP脚本。</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/cdn.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>COS、CDN</h3>\n<p>可以将所有静态内容传入腾讯云COS,或接入任意CDN。让你的网站快如闪电!</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/sitemap.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>Sitemap一键生成</h3>\n<p>自动挖掘Sitemap,一键即可生成!</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/seo.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>All for SEO</h3>\n<p>SEO优化友好,加快网站收录速度。</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/cms.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>动态组件(CMS)</h3>\n<p>无论是新闻、列表、博客、文章、产品,都可以通过动态内容来实现类似于CMS的体验。支持Html和Markdown双编辑器自由切换。不是CMS,但是超越CMS!</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/gradient.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>渐变色调色器</h3>\n<p>自带渐变调色器。任何组件任何文字都可以设置为魅力十足的渐变色。</p></article><article class=\"content-card feature-card\"><img src=\"/assets/original/pagepan/languages.svg\" alt=\"\" width=\"50\" height=\"50\" loading=\"lazy\"><h3>多语言支持</h3>\n<p>一个站点,多种语言,任意切换,实现面向全球!</p></article></div><p><a href=\"https://pagepan.com/home\">访问 PAGEPAN 官网</a></p>",
|
||||||
"style": "plain"
|
"style": "plain"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -305,14 +271,14 @@
|
|||||||
"key": "why",
|
"key": "why",
|
||||||
"title": "为什么选择来笙",
|
"title": "为什么选择来笙",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><h3>手工DIY</h3>\n<p>申请需要繁琐的材料。<br/>一旦有所错漏哪怕格式不对、甚至点错了按钮,都会造成补正。<br/>一次补正就要重新排队,至少延迟两周时间。</p></article><article class=\"content-card feature-card\"><h3>其他著作权代理商</h3>\n<p>经常收取高额费用,声称提供所谓“加急”服务<br/>实则经常盗用各种开源软件、AI代码。<br/>一旦被版权中心查实,面临终生黑名单,得不偿失!部分黑心商家还收合作申请费!</p></article><article class=\"content-card feature-card\"><h3>选择来笙</h3>\n<p>最低仅需¥120元起,替您处理和审查、优化材料。不收取任何加急费,所有申请均最快60日内下证。<br/>不收取合作申请费,可多人一起申请。</p></article></div>",
|
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><h3>手工DIY</h3>\n<p>申请需要繁琐的材料。<br>一旦有所错漏哪怕格式不对、甚至点错了按钮,都会造成补正。<br>一次补正就要重新排队,至少延迟两周时间。</p></article><article class=\"content-card feature-card\"><h3>其他著作权代理商</h3>\n<p>经常收取高额费用,声称提供所谓“加急”服务<br>实则经常盗用各种开源软件、AI代码。<br>一旦被版权中心查实,面临终生黑名单,得不偿失!部分黑心商家还收合作申请费!</p></article><article class=\"content-card feature-card choice-card\"><h3>选择来笙</h3>\n<p>最低仅需¥120元起,替您处理和审查、优化材料。不收取任何加急费,所有申请均最快60日内下证。<br>不收取合作申请费,可多人一起申请。</p></article></div>",
|
||||||
"style": "tinted"
|
"style": "tinted"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "options",
|
"key": "options",
|
||||||
"title": "按准备进度选择服务",
|
"title": "按准备进度选择服务",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-1.png\"/>\n<h3>我已经有项目了!</h3>\n<p>仅需一本书的价格,来笙直接帮您搞定软著!为您全程提供申请代理+材料指导+审核优化,最快60天拿证书!</p>\n<a href=\"#price1\"><span>代理申请服务</span></a>\n\n</li></article><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-2.png\"/>\n<h3>我会写代码!</h3>\n<p>无需头疼各种麻烦的材料和手续,来笙为您一次性做齐所有材料,包您下证!</p>\n<a href=\"#price2\"><span>无忧申请</span></a>\n\n</li></article><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-3.png\"/>\n<h3>啥也不会也没事!</h3>\n<p>从代码到材料,来笙替您一站式解决。即使不会写代码也能拿到软著!</p>\n<a href=\"#price3\"><span>一价全包</span></a>\n\n</li></article></div>",
|
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/project.svg\">\n<h3>我已经有项目了!</h3>\n<p>仅需一本书的价格,来笙直接帮您搞定软著!为您全程提供申请代理+材料指导+审核优化,最快60天拿证书!</p>\n<a href=\"#price1\"><span>代理申请服务</span></a>\n\n</article><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/code.svg\">\n<h3>我会写代码!</h3>\n<p>无需头疼各种麻烦的材料和手续,来笙为您一次性做齐所有材料,包您下证!</p>\n<a href=\"#price2\"><span>无忧申请</span></a>\n\n</article><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/support.svg\">\n<h3>啥也不会也没事!</h3>\n<p>从代码到材料,来笙替您一站式解决。即使不会写代码也能拿到软著!</p>\n<a href=\"#price3\"><span>一价全包</span></a>\n\n</article></div>",
|
||||||
"style": "plain"
|
"style": "plain"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -409,14 +375,14 @@
|
|||||||
"key": "why",
|
"key": "why",
|
||||||
"title": "为什么选择来笙",
|
"title": "为什么选择来笙",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><h3>手工DIY</h3>\n<p>申请需要繁琐的材料。<br/>一旦有所错漏哪怕格式不对、甚至点错了按钮,都会造成补正。<br/>一次补正就要重新排队,至少延迟两周时间。</p></article><article class=\"content-card feature-card\"><h3>其他著作权代理商</h3>\n<p>经常收取高额费用,声称提供所谓“加急”服务<br/>实则经常盗用各种开源软件、AI代码。<br/>一旦被版权中心查实,面临终生黑名单,得不偿失!部分黑心商家还收合作申请费!</p></article><article class=\"content-card feature-card\"><h3>选择来笙</h3>\n<p>最低仅需¥66元起,替您处理和审查、优化材料。不收取任何加急费,所有申请均最快60日内下证。<br/>不收取合作申请费,可多人一起申请。</p></article></div>",
|
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><h3>手工DIY</h3>\n<p>申请需要繁琐的材料。<br>一旦有所错漏哪怕格式不对、甚至点错了按钮,都会造成补正。<br>一次补正就要重新排队,至少延迟两周时间。</p></article><article class=\"content-card feature-card\"><h3>其他著作权代理商</h3>\n<p>经常收取高额费用,声称提供所谓“加急”服务<br>实则经常盗用各种开源软件、AI代码。<br>一旦被版权中心查实,面临终生黑名单,得不偿失!部分黑心商家还收合作申请费!</p></article><article class=\"content-card feature-card choice-card\"><h3>选择来笙</h3>\n<p>最低仅需¥66元起,替您处理和审查、优化材料。不收取任何加急费,所有申请均最快60日内下证。<br>不收取合作申请费,可多人一起申请。</p></article></div>",
|
||||||
"style": "tinted"
|
"style": "tinted"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"key": "options",
|
"key": "options",
|
||||||
"title": "按准备进度选择服务",
|
"title": "按准备进度选择服务",
|
||||||
"lead": "",
|
"lead": "",
|
||||||
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-1.png\"/>\n<h3>我已经有项目了!</h3>\n<p>仅需一本书的价格,来笙直接帮您搞定软著!为您全程提供申请代理+材料指导+审核优化,最快60天拿证书!</p>\n<a href=\"/shnu-sc#price1\"><span>代理申请服务</span></a>\n\n</li></article><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-2.png\"/>\n<h3>我会写代码!</h3>\n<p>无需头疼各种麻烦的材料和手续,来笙为您一次性做齐所有材料,包您下证!</p>\n<a href=\"/shnu-sc#price2\"><span>无忧申请</span></a>\n\n</li></article><article class=\"content-card feature-card\"><li>\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/original/10-3.png\"/>\n<h3>啥也不会也没事!</h3>\n<p>从代码到材料,来笙替您一站式解决。即使不会写代码也能拿到软著!</p>\n<a href=\"/shnu-sc#price3\"><span>一价全包</span></a>\n\n</li></article></div>",
|
"body": "<div class=\"card-grid feature-grid\"><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/project.svg\">\n<h3>我已经有项目了!</h3>\n<p>仅需一本书的价格,来笙直接帮您搞定软著!为您全程提供申请代理+材料指导+审核优化,最快60天拿证书!</p>\n<a href=\"/shnu-sc#price1\"><span>代理申请服务</span></a>\n\n</article><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/code.svg\">\n<h3>我会写代码!</h3>\n<p>无需头疼各种麻烦的材料和手续,来笙为您一次性做齐所有材料,包您下证!</p>\n<a href=\"/shnu-sc#price2\"><span>无忧申请</span></a>\n\n</article><article class=\"content-card feature-card\">\n\n<img alt=\"\" loading=\"lazy\" src=\"/assets/service/support.svg\">\n<h3>啥也不会也没事!</h3>\n<p>从代码到材料,来笙替您一站式解决。即使不会写代码也能拿到软著!</p>\n<a href=\"/shnu-sc#price3\"><span>一价全包</span></a>\n\n</article></div>",
|
||||||
"style": "plain"
|
"style": "plain"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -468,7 +434,6 @@
|
|||||||
{
|
{
|
||||||
"slug": "global-server-deployment",
|
"slug": "global-server-deployment",
|
||||||
"title": "来笙关于即将减少全球服务器部署的公告",
|
"title": "来笙关于即将减少全球服务器部署的公告",
|
||||||
"category": "announcement",
|
|
||||||
"summary": "",
|
"summary": "",
|
||||||
"body": "",
|
"body": "",
|
||||||
"tags": [
|
"tags": [
|
||||||
@@ -477,7 +442,214 @@
|
|||||||
],
|
],
|
||||||
"date": "2024-11-10 14:39:31",
|
"date": "2024-11-10 14:39:31",
|
||||||
"status": "published",
|
"status": "published",
|
||||||
"legacy": "/news/id/4.html"
|
"legacy": "/news/id/4.html",
|
||||||
|
"categories": [
|
||||||
|
"announcement"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "service-1",
|
||||||
|
"title": "PAGEPAN 小飞页",
|
||||||
|
"body": "<p>自托管拖拽建站工具。由 UI 中国签约的飞屋设计团队打造,可在自己的服务器上运行。</p><p>无需代码,五分钟 DIY 网站,每一处细节都可定制。提供永久免费版本,VIP 版本最低 ¥79/年。</p>",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/pagepan-editor-optimized.webp",
|
||||||
|
"alt": "PAGEPAN 可视化网页编辑器",
|
||||||
|
"url": "/pagepan",
|
||||||
|
"label": "探索 PAGEPAN",
|
||||||
|
"extra_url": "/pagepan#download",
|
||||||
|
"extra_label": "免费体验",
|
||||||
|
"position": 0,
|
||||||
|
"category_label": "可视化建站"
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"services"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "service-2",
|
||||||
|
"title": "HighSpeaker DNS",
|
||||||
|
"body": "<p>新一代智能 DNS 系统。企业和云服务商可以私有化或内网部署,也可二次开发,提供多租户、可分销的 SaaS 服务。</p><p>100% 开源免费。</p>",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/highspeaker-ui-optimized.webp",
|
||||||
|
"alt": "HighSpeaker DNS 管理界面",
|
||||||
|
"url": "/highspeaker",
|
||||||
|
"label": "探索 HighSpeaker",
|
||||||
|
"extra_url": "",
|
||||||
|
"extra_label": "",
|
||||||
|
"position": 10,
|
||||||
|
"category_label": "开源基础软件"
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"services"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "service-3",
|
||||||
|
"title": "来笙软著代理",
|
||||||
|
"body": "<p>提供申请代理、材料审核与优化、合作开发合同模板。</p>",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/copyright.webp",
|
||||||
|
"alt": "软件著作权服务插图",
|
||||||
|
"url": "/sc",
|
||||||
|
"label": "查看软著服务",
|
||||||
|
"extra_url": "/shnu-sc",
|
||||||
|
"extra_label": "查看 SHNU 学生方案",
|
||||||
|
"position": 20,
|
||||||
|
"category_label": "软件著作权"
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"services"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "service-4",
|
||||||
|
"title": "SHNU 学生软著服务",
|
||||||
|
"body": "<p>面向 SHNU 学生的软件著作权申请服务。</p>",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/shnu-hero.webp",
|
||||||
|
"alt": "",
|
||||||
|
"url": "/shnu-sc",
|
||||||
|
"label": "查看学生方案",
|
||||||
|
"extra_url": "",
|
||||||
|
"extra_label": "",
|
||||||
|
"position": 30,
|
||||||
|
"category_label": "校园服务"
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"services"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-1",
|
||||||
|
"title": "HighSpeaker DNS",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/highspeaker-logo-optimized.webp",
|
||||||
|
"alt": "",
|
||||||
|
"url": "/highspeaker",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 0
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"supported-projects"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-2",
|
||||||
|
"title": "FW Network",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/fw-banner.svg",
|
||||||
|
"alt": "",
|
||||||
|
"url": "https://fw.ac.cn/",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 1
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"partners"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-3",
|
||||||
|
"title": "IdealShark",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/IdealShark_B.png",
|
||||||
|
"alt": "",
|
||||||
|
"url": "",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 2
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"supported-projects"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-4",
|
||||||
|
"title": "MimirLib",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/mimirlib.png",
|
||||||
|
"alt": "",
|
||||||
|
"url": "",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 3
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"supported-projects"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-5",
|
||||||
|
"title": "NoNat",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/nonat-optimized.webp",
|
||||||
|
"alt": "",
|
||||||
|
"url": "https://nonat.eu.org/",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 4
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"supported-projects"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-6",
|
||||||
|
"title": "PAGEPAN",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/papepan-logo.svg",
|
||||||
|
"alt": "",
|
||||||
|
"url": "https://pagepan.com/",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 5
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"partners"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-7",
|
||||||
|
"title": "LayFi",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "",
|
||||||
|
"alt": "",
|
||||||
|
"url": "https://www.layfi.de",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 6
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"supported-projects"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "network-8",
|
||||||
|
"title": "OneProvider",
|
||||||
|
"body": "",
|
||||||
|
"card": {
|
||||||
|
"image": "/assets/original/oneprovider_invert.svg",
|
||||||
|
"alt": "",
|
||||||
|
"url": "https://oneprovider.com/",
|
||||||
|
"label": "访问网站",
|
||||||
|
"position": 7
|
||||||
|
},
|
||||||
|
"body_format": "html",
|
||||||
|
"categories": [
|
||||||
|
"partners"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+132
-6
@@ -38,6 +38,7 @@ async function run(browser) {
|
|||||||
version: '0', title: '媒体和链接', lead: '', style: 'plain',
|
version: '0', title: '媒体和链接', lead: '', style: 'plain',
|
||||||
body: '<p><img src="/assets/favicon.png" alt="示例图片" width="96"></p>'
|
body: '<p><img src="/assets/favicon.png" alt="示例图片" width="96"></p>'
|
||||||
+ '<p><a href="/services">示例链接</a></p>'
|
+ '<p><a href="/services">示例链接</a></p>'
|
||||||
|
+ '<p id="copy-fixture">待复制段落</p><p>待删除段落</p>'
|
||||||
+ '<video controls width="260" preload="none"><source src="/assets/original/drag-in-components.mp4"></video>'
|
+ '<video controls width="260" preload="none"><source src="/assets/original/drag-in-components.mp4"></video>'
|
||||||
+ '<audio controls src="/assets/original/drag-in-components.mp4" preload="none"></audio>',
|
+ '<audio controls src="/assets/original/drag-in-components.mp4" preload="none"></audio>',
|
||||||
});
|
});
|
||||||
@@ -46,7 +47,7 @@ async function run(browser) {
|
|||||||
const version = await page.locator('#studio-page-settings [name=version]').inputValue();
|
const version = await page.locator('#studio-page-settings [name=version]').inputValue();
|
||||||
await post(editorPath, {
|
await post(editorPath, {
|
||||||
version, name: '画布测试页', status: 'draft', title: '画布测试页',
|
version, name: '画布测试页', status: 'draft', title: '画布测试页',
|
||||||
description: '', heading: '画布测试页', accent: '', lead: '',
|
description: '', heading: '画布测试页', accent: '', lead: '待删除的首屏简介',
|
||||||
image: '/assets/original/home-hero.webp', alt: '首屏示例', image_scale: '0',
|
image: '/assets/original/home-hero.webp', alt: '首屏示例', image_scale: '0',
|
||||||
});
|
});
|
||||||
await page.reload();
|
await page.reload();
|
||||||
@@ -59,8 +60,17 @@ async function run(browser) {
|
|||||||
await image.click();
|
await image.click();
|
||||||
await sizing.waitFor({state: 'visible'});
|
await sizing.waitFor({state: 'visible'});
|
||||||
assert.equal(await image.getAttribute('data-studio-selected'), '');
|
assert.equal(await image.getAttribute('data-studio-selected'), '');
|
||||||
await sizing.locator('[data-media-width]').selectOption('50');
|
const handle = page.getByRole('slider', {name: '媒体宽度'});
|
||||||
assert.match(await image.getAttribute('class'), /studio-media-50/);
|
const initial = await image.boundingBox();
|
||||||
|
const grip = await handle.boundingBox();
|
||||||
|
await page.mouse.move(grip.x + grip.width / 2, grip.y + grip.height / 2);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(grip.x + grip.width / 2 + 145, grip.y + grip.height / 2, {steps: 8});
|
||||||
|
assert((await image.boundingBox()).width > initial.width + 100);
|
||||||
|
await page.mouse.up();
|
||||||
|
const imageSize = await image.getAttribute('class');
|
||||||
|
assert.match(imageSize, /studio-media-\d+/);
|
||||||
|
assert.notEqual(imageSize, 'studio-media-100');
|
||||||
await image.dblclick();
|
await image.dblclick();
|
||||||
await properties.waitFor({state: 'visible'});
|
await properties.waitFor({state: 'visible'});
|
||||||
assert.equal(await properties.locator('h2').textContent(), '正文图片');
|
assert.equal(await properties.locator('h2').textContent(), '正文图片');
|
||||||
@@ -73,11 +83,15 @@ async function run(browser) {
|
|||||||
await hero.click();
|
await hero.click();
|
||||||
await sizing.waitFor({state: 'visible'});
|
await sizing.waitFor({state: 'visible'});
|
||||||
assert.equal(await hero.getAttribute('data-studio-selected'), '');
|
assert.equal(await hero.getAttribute('data-studio-selected'), '');
|
||||||
|
await handle.press('ArrowLeft');
|
||||||
|
assert.equal(await page.locator('[name=image_scale]').inputValue(), '99');
|
||||||
await sizing.locator('[data-replace-media]').click();
|
await sizing.locator('[data-replace-media]').click();
|
||||||
assert.equal(await properties.locator('h2').textContent(), '首屏图片');
|
assert.equal(await properties.locator('h2').textContent(), '首屏图片');
|
||||||
await closeProperties();
|
await closeProperties();
|
||||||
|
|
||||||
|
const tools = page.getByRole('group', {name: '所选元素'});
|
||||||
await frame.locator('#fixtures a').click();
|
await frame.locator('#fixtures a').click();
|
||||||
|
await tools.getByRole('button', {name: '属性'}).click();
|
||||||
await properties.waitFor({state: 'visible'});
|
await properties.waitFor({state: 'visible'});
|
||||||
assert.equal(await properties.locator('h2').textContent(), '正文链接');
|
assert.equal(await properties.locator('h2').textContent(), '正文链接');
|
||||||
await properties.locator('[name=url]').fill('/articles');
|
await properties.locator('[name=url]').fill('/articles');
|
||||||
@@ -92,9 +106,22 @@ async function run(browser) {
|
|||||||
await closeProperties();
|
await closeProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const copyText = frame.locator('#fixtures').getByText('待复制段落', {exact: true});
|
||||||
|
await copyText.click();
|
||||||
|
await tools.getByRole('button', {name: '复制'}).click();
|
||||||
|
assert.equal(await copyText.count(), 2);
|
||||||
|
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
||||||
|
const oldParagraph = frame.getByText('待删除段落', {exact: true});
|
||||||
|
await oldParagraph.click();
|
||||||
|
await tools.getByRole('button', {name: '删除'}).click();
|
||||||
|
assert.equal(await oldParagraph.count(), 0);
|
||||||
|
await frame.getByText('待删除的首屏简介', {exact: true}).click();
|
||||||
|
await tools.getByRole('button', {name: '删除'}).click();
|
||||||
|
assert.equal(await page.locator('[name=lead]').inputValue(), '');
|
||||||
|
|
||||||
const gallery = page.locator('[data-canvas-presets]');
|
const gallery = page.locator('[data-canvas-presets]');
|
||||||
assert.equal(await gallery.locator('[data-template-group]').count(), 6);
|
assert.equal(await gallery.locator('[data-template-group]').count(), 6);
|
||||||
assert.equal(await gallery.locator('[data-template-card]').count(), 13);
|
assert.equal(await gallery.locator('[data-template-card]').count(), 14);
|
||||||
const brokenPreviews = await gallery.locator('[data-template-card] img').evaluateAll(async (images) => {
|
const brokenPreviews = await gallery.locator('[data-template-card] img').evaluateAll(async (images) => {
|
||||||
for (const image of images) image.loading = 'eager';
|
for (const image of images) image.loading = 'eager';
|
||||||
await Promise.all(images.map((image) => image.decode()));
|
await Promise.all(images.map((image) => image.decode()));
|
||||||
@@ -122,6 +149,9 @@ async function run(browser) {
|
|||||||
await gallery.locator('[data-template-empty]').waitFor({state: 'visible'});
|
await gallery.locator('[data-template-empty]').waitFor({state: 'visible'});
|
||||||
await search.fill('双栏');
|
await search.fill('双栏');
|
||||||
assert.equal(await gallery.locator('[data-template-card]:visible').count(), 1);
|
assert.equal(await gallery.locator('[data-template-card]:visible').count(), 1);
|
||||||
|
await search.fill('分类文章');
|
||||||
|
await gallery.locator('[data-canvas-template=articles]').click();
|
||||||
|
await frame.locator('section[id^=block-] h2').filter({hasText: '分类文章'}).waitFor();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
page.waitForResponse((response) => response.url().endsWith(editorPath) && response.request().method() === 'POST' && response.ok()),
|
page.waitForResponse((response) => response.url().endsWith(editorPath) && response.request().method() === 'POST' && response.ok()),
|
||||||
@@ -131,6 +161,15 @@ async function run(browser) {
|
|||||||
await frame.locator('section[id^=block-] .studio-cover').waitFor();
|
await frame.locator('section[id^=block-] .studio-cover').waitFor();
|
||||||
assert.equal(await frame.locator('#fixtures a').getAttribute('href'), '/articles');
|
assert.equal(await frame.locator('#fixtures a').getAttribute('href'), '/articles');
|
||||||
assert.equal(await frame.locator('#fixtures img').getAttribute('src'), '/assets/original/home-hero.webp');
|
assert.equal(await frame.locator('#fixtures img').getAttribute('src'), '/assets/original/home-hero.webp');
|
||||||
|
assert.equal(await frame.locator('#fixtures img').getAttribute('class'), imageSize);
|
||||||
|
assert.match(await frame.locator('[data-visual]').getAttribute('class'), /studio-media-99/);
|
||||||
|
assert.equal(await copyText.count(), 2);
|
||||||
|
assert.equal(await frame.locator('#copy-fixture').count(), 1);
|
||||||
|
assert.equal(await oldParagraph.count(), 0);
|
||||||
|
assert.equal(await page.locator('[name=lead]').inputValue(), '');
|
||||||
|
const feedSection = frame.locator('section[id^=block-]').filter({hasText: '分类文章'});
|
||||||
|
const feedId = await feedSection.getAttribute('id');
|
||||||
|
await feedSection.locator('.article-list').waitFor();
|
||||||
|
|
||||||
const phone = await browser.newContext({
|
const phone = await browser.newContext({
|
||||||
baseURL, viewport: {width: 390, height: 844}, isMobile: true, hasTouch: true,
|
baseURL, viewport: {width: 390, height: 844}, isMobile: true, hasTouch: true,
|
||||||
@@ -144,16 +183,103 @@ async function run(browser) {
|
|||||||
await phoneGallery.locator('[data-template-preview=banner]').tap();
|
await phoneGallery.locator('[data-template-preview=banner]').tap();
|
||||||
await phoneGallery.locator('[data-template-dialog]').waitFor({state: 'visible'});
|
await phoneGallery.locator('[data-template-dialog]').waitFor({state: 'visible'});
|
||||||
assert.equal(await phoneGallery.locator('[data-template-dialog] h2').textContent(), '横幅');
|
assert.equal(await phoneGallery.locator('[data-template-dialog] h2').textContent(), '横幅');
|
||||||
assert.deepEqual(errors, []);
|
|
||||||
await phone.close();
|
await phone.close();
|
||||||
|
await verifyArticleLibrary(browser, context, page, post, slug, feedId);
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
await context.close();
|
await context.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function verifyArticleLibrary(browser, context, page, post, slug, feedId) {
|
||||||
|
const category = slug + '-category';
|
||||||
|
await post('/admin/article-categories', {slug: category, name: '自定义测试分类'});
|
||||||
|
const articleSlug = slug + '-article';
|
||||||
|
await page.goto('/admin/articles/new');
|
||||||
|
const editor = page.locator('[data-editor-host]');
|
||||||
|
const markdown = editor.locator('.toastui-editor-md-container .ProseMirror');
|
||||||
|
const preview = editor.locator('.toastui-editor-md-preview');
|
||||||
|
await markdown.waitFor();
|
||||||
|
await preview.waitFor();
|
||||||
|
await page.locator('[name=title]').fill('测试 Markdown 和富文本');
|
||||||
|
await page.locator('[name=slug]').fill(articleSlug);
|
||||||
|
await page.locator('[name="categories[]"][value="' + category + '"]').check();
|
||||||
|
await page.locator('[name=status]').selectOption('published');
|
||||||
|
await markdown.fill('**Markdown 分屏**');
|
||||||
|
await preview.locator('strong').getByText('Markdown 分屏').waitFor();
|
||||||
|
await page.getByRole('button', {name: '保存文章'}).click();
|
||||||
|
await page.waitForURL(/\/admin\/articles\/\d+/);
|
||||||
|
const articleAdmin = new URL(page.url()).pathname;
|
||||||
|
const publishedPath = '/articles/' + articleSlug;
|
||||||
|
const sourcePage = await context.newPage();
|
||||||
|
await sourcePage.goto(publishedPath);
|
||||||
|
assert.equal(await sourcePage.locator('[itemprop=articleSection]').count(), 2);
|
||||||
|
await sourcePage.locator('[itemprop=articleBody] strong').getByText('Markdown 分屏').waitFor();
|
||||||
|
await page.goto(articleAdmin);
|
||||||
|
await editor.locator('.toastui-editor-mode-switch').getByText('所见即所得', {exact: true}).click();
|
||||||
|
const rich = editor.locator('.toastui-editor-ww-container .ProseMirror');
|
||||||
|
await rich.waitFor();
|
||||||
|
await rich.press('End');
|
||||||
|
await page.keyboard.insertText(' 富文本');
|
||||||
|
await page.getByRole('button', {name: '从媒体库插入图片'}).click();
|
||||||
|
await page.locator('[data-media-query]').fill('favicon.png');
|
||||||
|
page.once('dialog', (dialog) => dialog.accept('媒体库图片'));
|
||||||
|
await page.locator('.picker-item', {hasText: 'favicon.png'}).click();
|
||||||
|
await rich.locator('img[alt="媒体库图片"]').waitFor();
|
||||||
|
await page.getByRole('button', {name: '保存文章'}).click();
|
||||||
|
await page.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
||||||
|
await page.reload();
|
||||||
|
await rich.waitFor();
|
||||||
|
assert.equal(await page.locator('[name=body_format]').inputValue(), 'html');
|
||||||
|
await sourcePage.reload();
|
||||||
|
assert.match(await sourcePage.locator('[itemprop=articleBody]').textContent(), /Markdown 分屏 富文本/);
|
||||||
|
await sourcePage.locator('[itemprop=articleBody] img[alt="媒体库图片"]').waitFor();
|
||||||
|
|
||||||
|
const sectionPath = '/admin/pages/' + slug + '/' + feedId;
|
||||||
|
await page.goto(sectionPath);
|
||||||
|
await page.locator('[name=feed_mode]').selectOption('merged');
|
||||||
|
await page.locator('[name="feed_categories[]"][value=announcement]').uncheck();
|
||||||
|
await page.locator('[name="feed_categories[]"][value=product]').uncheck();
|
||||||
|
await page.locator('[name="feed_categories[]"][value="' + category + '"]').check();
|
||||||
|
await page.getByRole('button', {name: '保存区块'}).click();
|
||||||
|
await page.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
||||||
|
let contentVersion = await page.locator('[name=version]').inputValue();
|
||||||
|
assert.equal(contentVersion, '1');
|
||||||
|
const canvasPath = '/admin/pages/' + slug + '/preview';
|
||||||
|
await sourcePage.goto(canvasPath);
|
||||||
|
const feed = sourcePage.locator('#' + feedId + ' .article-feed');
|
||||||
|
assert.equal(await feed.locator('a[href="' + publishedPath + '"]').count(), 1);
|
||||||
|
assert.equal(await feed.getByRole('tab').count(), 0);
|
||||||
|
|
||||||
|
await page.locator('[name=feed_mode]').selectOption('tabs');
|
||||||
|
await page.getByRole('button', {name: '保存区块'}).click();
|
||||||
|
await page.locator('[data-save-confirmation]').waitFor({state: 'visible'});
|
||||||
|
contentVersion = await page.locator('[name=version]').inputValue();
|
||||||
|
assert.equal(contentVersion, '2');
|
||||||
|
await sourcePage.reload();
|
||||||
|
const customTab = feed.getByRole('tab', {name: '自定义测试分类'});
|
||||||
|
await customTab.waitFor();
|
||||||
|
await feed.getByRole('tab', {name: '新闻'}).press('ArrowRight');
|
||||||
|
assert.equal(await customTab.getAttribute('aria-selected'), 'true');
|
||||||
|
assert.equal(await feed.getByRole('tabpanel').count(), 1);
|
||||||
|
assert.equal(await feed.locator('a[href="' + publishedPath + '"]:visible').count(), 1);
|
||||||
|
|
||||||
|
const noJS = await browser.newContext({baseURL, javaScriptEnabled: false, storageState: await context.storageState()});
|
||||||
|
const noJSPage = await noJS.newPage();
|
||||||
|
await noJSPage.goto(canvasPath);
|
||||||
|
assert.equal(await noJSPage.locator('#' + feedId + ' a[href="' + publishedPath + '"]:visible').count(), 2);
|
||||||
|
await noJS.close();
|
||||||
|
assert((await context.request.get('/articles/category/' + category)).ok());
|
||||||
|
await sourcePage.goto('/services');
|
||||||
|
await sourcePage.locator('.catalog-card').first().waitFor();
|
||||||
|
await sourcePage.goto('/network');
|
||||||
|
assert.equal(await sourcePage.locator('.network-group').count(), 2);
|
||||||
|
await sourcePage.close();
|
||||||
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
const browser = await chromium.launch({executablePath: process.env.CHROMIUM_EXECUTABLE || undefined});
|
||||||
try {
|
try {
|
||||||
await run(browser);
|
await run(browser);
|
||||||
console.log('Passed Chromium canvas media/link interactions, template gallery, and persistence.');
|
console.log('Passed Chromium canvas media/link interactions, template gallery, persistence, and the article library.');
|
||||||
} finally {
|
} finally {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user