diff --git a/README.md b/README.md index 8709710..45013f5 100644 --- a/README.md +++ b/README.md @@ -28,10 +28,11 @@ php bin/admin.php reset admin@example.com ## 后台编辑 - **网站后台**可按名称、地址或发布状态查找页面,从列表打开画布、公开页或草稿预览。 -- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。已有五个内置页面的首屏图文和正文区块都可复用,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。 +- **页面设计**支持新建草稿、发布和撤回。首屏标题与简介可在桌面或手机画布中直接编辑。区块支持新增、排序、删除、可视化编辑、媒体插入和 HTML 源码。单击画布元素可用浮动工具条复制或删除。选中媒体后,可拖动边缘手柄调整宽度。浮动工具条可将正文元素、区块标题和首屏元素对齐到左侧、中央或右侧。编辑器左侧分为「组件」「元素」「图层」。先进入分类,再查找并插入模板或基础元素。可在功能分类中复用产品图文、特性组、服务报价等内置模板,徽标、按钮组、面包屑、进度、通知和折叠等元素参考 [Preline UI 免费组件文档](https://preline.co/docs/index.html),用本站样式实现。悬停或键盘聚焦缩略图可放大,点击可打开预览。 - **媒体库**集中列出项目静态文件及上传文件,支持查找、选取、复制路径、改名和归档。归档资源的已有 URL 保持可访问。上传文件放在 `LAYSENSE_MEDIA_DIR`,由 `/assets/uploads/` 提供。 - **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。 -- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表和项目与伙伴卡片共用分类设置。「查看全部动态」和翻页只列出该区块所选的分类。 +- **普通页面**包括 `/services`、`/articles` 和 `/contact`。产品目录和分类文章模块的设置可在画布编辑。动态页默认显示公告、新闻和产品动态。 +- **分类文章**支持在任意页面添加,选中动态模块后可用浮动工具条打开设置、复制或删除,随页面一起保存。文章列表、产品目录和项目与伙伴卡片共用分类设置。「查看全部」和翻页只列出该区块所选的分类。 - **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。 - **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。 - 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。 @@ -71,7 +72,7 @@ location = /admin/media { | `LAYSENSE_SECURE_COOKIES` | 默认关闭 · 本地 HTTP 使用默认值。生产 HTTPS 设置为 `1`。 | | `LAYSENSE_TRUSTED_PROXIES` | 默认 `127.0.0.1,::1` · 逗号分隔的受信反代 IP,设为空字符串可关闭信任 | -SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。首页五联导航和伙伴动态模块会作为可管理区块导入一次。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。 +SQLite 已启用 WAL。使用上一版多分类文章结构的站点,可用当前 `LAYSENSE_DB` 运行 `php bin/install.php` 增量安装,之后重启 Webman。安装会补齐 `/services`、`/articles` 和 `/contact` 的页面记录,并一次性导入首页五联导航和伙伴动态模块。全新安装时,将 `LAYSENSE_DB` 指向新文件并按上面的步骤初始化和创建管理员。安装会预载网站自带页面、文章、产品和伙伴目录。服务用户需要对 SQLite 目录、媒体目录和 `runtime/` 有写权限。备份可用 `sqlite3 storage/laysense.sqlite ".backup 'laysense-backup.sqlite'"`,媒体目录单独保存。 ### CDN diff --git a/app/Content/BlockTemplates.php b/app/Content/BlockTemplates.php index 50a30b2..a1968d7 100644 --- a/app/Content/BlockTemplates.php +++ b/app/Content/BlockTemplates.php @@ -10,6 +10,8 @@ final class BlockTemplates public const NETWORK_FEED = '{"categories":["supported-projects","partners"],"mode":"network","limit":30}'; + public const CATALOG_FEED = '{"categories":["services"],"mode":"catalog","limit":30}'; + public const PRODUCT_LINKS = '
产品与服务PAGEPAN可视化建站HighSpeaker DNS开源智能解析软著代理登记申请与材料服务SHNU 学生软著申请方案
'; public const ELEMENT_GROUPS = [ @@ -72,7 +74,7 @@ final class BlockTemplates 'two-actions' => ['双按钮横幅', '

选择下一步

介绍访客可以立即做什么。

查看服务联系我们
'], ]], 'layout' => ['图文与布局', [ - 'image' => ['图文', '

介绍主题

在这里说明图片或产品。

'], + 'image' => ['产品图文', '

介绍主题

在这里说明图片或产品。

'], 'grid' => ['双栏网格', '

第一栏

填写主要内容。

第二栏

补充相关信息。

'], ]], 'media' => ['媒体', [ @@ -94,6 +96,7 @@ final class BlockTemplates 'pricing' => ['双方案报价', '

基础方案

填写价格

填写方案包含的服务。

咨询基础方案

进阶方案

填写价格

填写扩展服务或权益。

咨询进阶方案
'], ]], 'actions' => ['导航与引导', [ + 'service-catalog' => ['产品与服务目录', '', '', self::CATALOG_FEED], 'product-links' => ['产品与服务五联导航', self::PRODUCT_LINKS], 'navigation' => ['快速导航', ''], 'cta' => ['行动按钮', '

说明下一步。

联系来笙

'], @@ -111,7 +114,17 @@ final class BlockTemplates $groups = self::GROUPS; $seed = json_decode(file_get_contents(dirname(__DIR__, 2) . '/resources/seed.json'), true, flags: JSON_THROW_ON_ERROR); + $sectionGroups = [ + 'product' => 'layout', 'about' => 'content', 'blog' => 'content', + 'features' => 'features', 'support' => 'features', 'why' => 'features', 'stories' => 'features', + 'pricing' => 'details', 'comparison' => 'details', 'materials' => 'details', 'fees' => 'details', + 'faq' => 'details', 'terms' => 'details', + 'get' => 'actions', 'options' => 'actions', 'go' => 'actions', 'benefits' => 'layout', + ]; foreach ($seed['pages'] as $page) { + if (!in_array($page['slug'], ['home', 'highspeaker', 'sc', 'shnu-sc'], true)) { + continue; + } $links = ''; foreach ($page['actions'] as [$url, $label]) { $links .= '' . View::escape($label) . ''; @@ -119,15 +132,20 @@ final class BlockTemplates $hero = '
' . View::escape($page['alt']) . '' . '

' . View::escape(trim($page['heading'] . ' ' . $page['accent'])) . '

' . View::escape($page['lead']) . '

' . $links . '
'; - $items = ['existing-' . $page['slug'] . '-hero' => ['首屏图文', $hero]]; + $prefix = 'existing-' . $page['slug'] . '-'; + $groups['cover'][1][$prefix . 'hero'] = ['产品图文 · ' . $page['name'], $hero]; foreach ($page['sections'] as $section) { - $items['existing-' . $page['slug'] . '-' . $section['key']] = [ - $section['title'], Html::sanitize($section['body']), $section['lead'], + $group = $sectionGroups[$section['key']] ?? null; + if ($group === null) { + continue; + } + $groups[$group][1][$prefix . $section['key']] = [ + $section['key'] === 'features' ? '特性组' : $section['title'], + Html::sanitize($section['body']), $section['lead'], isset($section['feed']) ? Database::json($section['feed']) : null, $section['style'], ]; } - $groups['existing-' . $page['slug']] = ['现有页面 · ' . $page['name'], $items]; } return $groups; diff --git a/app/Content/SiteDesign.php b/app/Content/SiteDesign.php index 224edc9..1e6d061 100644 --- a/app/Content/SiteDesign.php +++ b/app/Content/SiteDesign.php @@ -12,7 +12,7 @@ final class SiteDesign public const DEFAULT_HEADER = [ 'logo' => '/assets/wordmark.webp', 'alt' => 'Laysense 来笙', 'links' => [['/', '首页'], ['/services', '产品与服务'], ['/articles', '动态'], ['/#about', '关于来笙']], - 'button' => ['#contact', '联系来笙'], + 'button' => ['/contact', '联系来笙'], ]; public const DEFAULT_FOOTER = [ @@ -23,7 +23,7 @@ final class SiteDesign 'products_title' => '产品与服务', 'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']], 'company_title' => '公司', - 'company' => [['/#about', '关于来笙'], ['#contact', '联系来笙']], + 'company' => [['/#about', '关于来笙'], ['/contact', '联系来笙']], 'resources_title' => '资源', 'resources' => [['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']], 'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']], diff --git a/app/Controller/AdminController.php b/app/Controller/AdminController.php index 1aa1386..128b17f 100644 --- a/app/Controller/AdminController.php +++ b/app/Controller/AdminController.php @@ -581,7 +581,7 @@ class AdminController { $categories = $this->selectedCategories($selected); $limit = filter_var($value, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'max_range' => 30]]); - if (!in_array($mode, ['merged', 'tabs', 'network'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) { + if (!in_array($mode, ['merged', 'tabs', 'network', 'catalog'], true) || !$categories || array_diff($categories, array_keys($available)) || $limit === false) { throw new RuntimeException('请选择文章分类,并将展示数量设为 1 至 30。'); } diff --git a/app/Controller/SiteController.php b/app/Controller/SiteController.php index 43a8968..3737909 100644 --- a/app/Controller/SiteController.php +++ b/app/Controller/SiteController.php @@ -24,6 +24,16 @@ final class SiteController if (!$page || $page['status'] !== 'published' || $slug === 'home' && $request->path() !== '/') { return $this->missing($request); } + if ($slug === 'articles' && $request->get('page') !== null) { + foreach ($page['sections'] as $section) { + $feed = json_decode($section['feed'] ?? '{}', true, flags: JSON_THROW_ON_ERROR); + if (in_array($feed['mode'] ?? null, ['merged', 'tabs'], true)) { + return $this->feedArchive($request, $slug, $section['key']); + } + } + + return $this->missing($request); + } return $this->renderPage($repo, $page); } @@ -38,6 +48,7 @@ final class SiteController } $feed = json_decode($section['feed'], true, flags: JSON_THROW_ON_ERROR); $network = $feed['mode'] === 'network'; + $catalog = $feed['mode'] === 'catalog'; $grouped = $network || ($feed['mode'] === 'tabs' && count($feed['categories']) > 1); $archivePath = '/articles/feed/' . $slug . '/' . $section['key']; if ($network && count($feed['categories']) === 2 && !array_diff($feed['categories'], ['supported-projects', 'partners'])) { @@ -46,11 +57,13 @@ final class SiteController $section['archivePath'] = $page['status'] === 'published' ? $archivePath : null; $section['articleFeed'] = []; $section['networkFeed'] = $network; + $section['catalogFeed'] = $catalog; + $section['feedLimit'] = $feed['limit']; foreach ($grouped ? $feed['categories'] : [''] as $category) { $selected = $category === '' ? $feed['categories'] : [$category]; $section['articleFeed'][] = [ 'categories' => $selected, 'label' => $categories[$category] ?? '', - 'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network), + 'articles' => $repo->articles($selected, limit: $feed['limit'], directoryOrder: $network || $catalog), ]; } } @@ -68,18 +81,6 @@ final class SiteController ]); } - public function services(Request $request): Response - { - $repo = new Repository(); - - return View::render('services', [ - 'site' => $repo->site(), 'path' => '/services', - 'title' => '产品与服务 · 来笙 Laysense', - 'description' => '浏览来笙的建站工具、智能 DNS 和软件著作权服务。', - 'products' => $repo->articles('services', limit: -1, directoryOrder: true), - ]); - } - public function network(Request $request): Response { $repo = new Repository(); @@ -157,6 +158,7 @@ final class SiteController 'archivePath' => $category === null ? $allPath : $categoryLinks[$category], 'allPath' => $allPath, 'categoryLinks' => $categoryLinks, 'categories' => $categories, 'category' => $category, 'tag' => null, 'categoryScope' => $category === null ? array_keys($categories) : [$category], + 'catalog' => $feed['mode'] === 'catalog', 'backPath' => $returnPath, 'backLabel' => '返回原页面', 'noindex' => true, ]); } @@ -168,7 +170,7 @@ final class SiteController return $this->missing($request); } $page = (int) $number; - $articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20); + $articles = $repo->articles($category, $tag, limit: 21, offset: ($page - 1) * 20, directoryOrder: $view['catalog'] ?? false); if ($page > 1 && $articles === []) { return $this->missing($request); } @@ -240,11 +242,7 @@ final class SiteController $repo = new Repository(); $xml = ['', '']; $pages = $repo->pages(publishedOnly: true); - $pages[] = ['slug' => 'services', 'updated_at' => null]; $pages[] = ['slug' => 'network', 'updated_at' => null]; - if ($repo->articles(limit: 1)) { - $pages[] = ['slug' => 'articles', 'updated_at' => null]; - } foreach ($pages as $page) { $xml[] = $this->sitemapUrl($page['slug'] === 'home' ? '/' : '/' . $page['slug'], $page['updated_at']); } @@ -269,7 +267,7 @@ final class SiteController $normal = rtrim($path, '/'); $single = preg_match('~^/[a-z0-9-]+$~D', $normal); $known = $single && ((new Repository())->page(substr($normal, 1))['status'] ?? null) === 'published' && $normal !== '/home'; - if ($known || in_array($normal, ['/services', '/network'], true) || preg_match('~^/articles(?:/[a-z0-9-]+){0,2}$~D', $normal)) { + if ($known || $normal === '/network' || preg_match('~^/articles(?:/[a-z0-9-]+){1,2}$~D', $normal)) { $query = $request->queryString(); return View::redirect($normal . ($query !== '' ? '?' . $query : ''), 301); diff --git a/app/Controller/StudioController.php b/app/Controller/StudioController.php index a4a92eb..bae5cb6 100644 --- a/app/Controller/StudioController.php +++ b/app/Controller/StudioController.php @@ -27,7 +27,7 @@ final class StudioController extends AdminController $data['name'] = $this->input($request, 'name'); $data['slug'] = $this->input($request, 'slug'); try { - if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'articles', 'home', 'services', 'network', 'news', 'main', 'favicon'], true) + if (!$this->slug($data['slug']) || in_array($data['slug'], ['admin', 'assets', 'home', 'network', 'news', 'main', 'favicon'], true) || $data['name'] === '' || mb_strlen($data['name']) > 100) { throw new RuntimeException('请填写页面名称及可用的网址标识。'); } diff --git a/app/view/admin-dashboard.php b/app/view/admin-dashboard.php index 75a25b8..05fb8dc 100644 --- a/app/view/admin-dashboard.php +++ b/app/view/admin-dashboard.php @@ -48,11 +48,11 @@ $live = count(array_filter($pages, static fn (array $page): bool => $page['statu

站点编辑

-
diff --git a/app/view/archive.php b/app/view/archive.php index e08f665..4b26d72 100644 --- a/app/view/archive.php +++ b/app/view/archive.php @@ -16,7 +16,11 @@ $e = View::escape(...); > - $articles, 'categoryScope' => $categoryScope ?? null]) ?> + + $articles]) ?> + + $articles, 'categoryScope' => $categoryScope ?? null]) ?> + 1 || $hasNext): ?>