Author SHA1 Message Date
ChatGPT 2b01537cf3 Audit merged directory links and test rendered fallbacks 2026-11-21 23:36:20 +08:00
14 changed files with 226 additions and 264 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ php bin/admin.php reset admin@example.com
- **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。 - **文章**使用自托管的 TOAST UI Editor 3.2.2(MIT)。Markdown 左侧源码、右侧实时预览,富文本使用所见即所得模式。文章可以加入多个分类,可在「管理分类」创建新分类。
- **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。「查看全部动态」和翻页只列出该区块所选的分类。 - **分类文章**支持在任意页面添加,保存区块后在「图层」中编辑分类、展示数量和合并或标签页模式。「查看全部动态」和翻页只列出该区块所选的分类。
- **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。 - **产品与服务**(`/services`)和**支持项目与合作伙伴**(`/network`)由文章分类生成。通过文章的目录卡片设置图片、链接和排序,使用草稿状态可从目录撤下。
- **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、产品、公司及资源链接和备注。页脚设置可恢复原站内容。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。 - **网站设置**分别编辑页头标志、导航及按钮,和页脚的公司信息、链接与备注。CDN 设置接受 HTTPS 源站地址。浏览器看到的公开 `/assets/…` 路径使用该源站。
- 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。 - 文章支持摘要和标签。状态选「草稿」可撤回公开文章。已发布文章改网址标识后,旧标识会自动跳转。
- 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。 - 首页动态、分类列表和站点地图随发布状态更新。源代码和 SQLite 数据分开管理。安装命令可重复执行,已编辑的内容会保留。
+39
View File
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace App\Content;
use DOMDocument;
use DOMXPath;
final class DirectoryCard
{
public static function links(array $article, string $body): array
{
$detail = self::hasText($article['summary']) || self::hasBody($body) ? '/articles/' . $article['slug'] : '';
$primary = ($article['card']['url'] ?? '') ?: $detail;
return ['primary' => $primary, 'detail' => $primary === $detail ? '' : $detail];
}
private static function hasText(string $text): bool
{
return preg_match('/[^\s\p{Z}\p{Cf}]/u', $text) === 1;
}
private static function hasBody(string $html): bool
{
if (self::hasText(html_entity_decode(strip_tags($html), ENT_QUOTES | ENT_HTML5, 'UTF-8'))) {
return true;
}
if (!str_contains($html, 'src=')) {
return false;
}
$document = new DOMDocument();
$document->loadHTML('<meta charset="utf-8">' . $html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
$xpath = new DOMXPath($document);
return (bool) $xpath->evaluate('boolean(//img[@src] | //audio[@src] | //video[@src] | //audio/source[@src] | //video/source[@src])');
}
}
+3 -29
View File
@@ -16,40 +16,14 @@ final class SiteDesign
]; ];
public const DEFAULT_FOOTER = [ public const DEFAULT_FOOTER = [
'logo' => '/assets/original/footer-wordmark.webp', 'alt' => '来笙 Laysense', 'logo' => '/assets/wordmark.webp', 'alt' => '来笙 Laysense',
'name' => '上海来笙信息科技有限公司',
'address' => '中国(上海)自由贸易试验区世博村路231号2单元3层328室',
'email' => 'public@laysense.cn',
'products_title' => '产品与服务', 'products_title' => '产品与服务',
'products' => [['/highspeaker', 'HighSpeaker DNS'], ['/pagepan', 'PAGEPAN'], ['/sc', '软著代理服务']], 'products' => [['/pagepan', 'PAGEPAN 小飞页'], ['/highspeaker', 'HighSpeaker DNS'], ['/sc', '软著代理服务'], ['/shnu-sc', 'SHNU 学生软著服务']],
'company_title' => '公司', 'company_title' => '公司',
'company' => [['/#about', '关于来笙'], ['#contact', '联系来笙']], 'company' => [['/#about', '关于来笙'], ['/articles', '来笙动态'], ['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
'resources_title' => '资源',
'resources' => [['https://git.laysense.com', 'Laysense Git'], ['https://www.layso.de', 'LaySo']],
'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']], 'phones' => [['tel:+16699004532', '+1 (669) 900 4532'], ['tel:+85257012856', '+852 5701 2856']],
'copyright' => '© Shanghai Laysense Information Technology Co. Ltd. 2024',
'terms' => '本网站中产品价格仅作展示,不作为订立合同、邀约或要约邀请的有效因素。',
'registration' => '沪ICP备2024051698号-1',
]; ];
public static function footer(array $site): array
{
$saved = $site['footer'] ?? null;
if ($saved === null) {
return self::DEFAULT_FOOTER;
}
// Older configurations store the entire footer navigation in two columns.
if (!array_key_exists('resources', $saved)) {
$saved += ['resources' => [], 'resources_title' => ''];
if (!empty($saved['copyright'])) {
$saved['copyright'] .= ' 2024–' . date('Y');
}
}
return $saved + self::DEFAULT_FOOTER;
}
public static function parseLinks(string $value): array public static function parseLinks(string $value): array
{ {
$links = []; $links = [];
+4 -10
View File
@@ -98,16 +98,15 @@ final class StudioController extends AdminController
$site = (new Repository())->site(); $site = (new Repository())->site();
$defaults = match ($part) { $defaults = match ($part) {
'header' => SiteDesign::DEFAULT_HEADER, 'header' => SiteDesign::DEFAULT_HEADER,
'footer' => SiteDesign::DEFAULT_FOOTER, 'footer' => SiteDesign::DEFAULT_FOOTER + array_intersect_key($site, array_flip(['name', 'address', 'email', 'copyright', 'registration', 'terms'])),
'cdn' => ['origin' => ''], 'cdn' => ['origin' => ''],
}; };
$config = $part === 'footer' ? SiteDesign::footer($site) : ($site[$part] ?? []) + $defaults; $config = ($site[$part] ?? []) + $defaults;
$version = $site['revisions'][$part] ?? 0; $version = $site['revisions'][$part] ?? 0;
$error = ''; $error = '';
if ($request->method() === 'POST') { if ($request->method() === 'POST') {
try { try {
$config = $part === 'footer' && $request->post('operation') === 'restore-footer' $config = $this->settingsInput($request, $part, $defaults);
? $defaults : $this->settingsInput($request, $part, $defaults, $config);
SiteDesign::saveSettings($part, $config, $this->version($request)); SiteDesign::saveSettings($part, $config, $this->version($request));
return $this->success($request, '/admin/settings/' . $part . '?saved=1'); return $this->success($request, '/admin/settings/' . $part . '?saved=1');
@@ -178,18 +177,13 @@ final class StudioController extends AdminController
return $this->success($request, '/admin/media'); return $this->success($request, '/admin/media');
} }
private function settingsInput(Request $request, string $part, array $defaults, array $current): array private function settingsInput(Request $request, string $part, array $defaults): array
{ {
if ($part === 'cdn') { if ($part === 'cdn') {
return ['origin' => Assets::cdn($this->input($request, 'origin'))]; return ['origin' => Assets::cdn($this->input($request, 'origin'))];
} }
$result = []; $result = [];
$hasResources = $request->post('resources') !== null;
foreach ($defaults as $key => $default) { foreach ($defaults as $key => $default) {
if ($part === 'footer' && !$hasResources && in_array($key, ['resources', 'resources_title'], true)) {
$result[$key] = $current[$key];
continue;
}
$input = $this->input($request, $key); $input = $this->input($request, $key);
if (is_array($default)) { if (is_array($default)) {
$result[$key] = SiteDesign::parseLinks($input); $result[$key] = SiteDesign::parseLinks($input);
+15 -25
View File
@@ -8,7 +8,7 @@ $e = View::escape(...);
<div class="footer-grid"> <div class="footer-grid">
<div class="footer-company" itemscope itemtype="https://schema.org/Organization"> <div class="footer-company" itemscope itemtype="https://schema.org/Organization">
<?php if ($footer['logo'] !== ''): ?> <?php if ($footer['logo'] !== ''): ?>
<a class="footer-logo" href="/" itemprop="url" aria-label="来笙 Laysense 首页"> <a href="/" itemprop="url" aria-label="来笙 Laysense 首页">
<img src="<?= $e($footer['logo']) ?>" alt="<?= $e($footer['alt']) ?>" width="130" height="33" itemprop="logo" loading="lazy"> <img src="<?= $e($footer['logo']) ?>" alt="<?= $e($footer['alt']) ?>" width="130" height="33" itemprop="logo" loading="lazy">
</a> </a>
<?php endif ?> <?php endif ?>
@@ -17,41 +17,31 @@ $e = View::escape(...);
<?php if ($footer['email']): ?> <?php if ($footer['email']): ?>
<a itemprop="email" href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a> <a itemprop="email" href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a>
<?php endif ?> <?php endif ?>
<p class="footer-payment-label">支持的付款方式</p>
<div class="payment-methods" aria-label="支持的付款方式"> <div class="payment-methods" aria-label="支持的付款方式">
<img src="/assets/original/payment-taobao.png" alt="淘宝" width="26" height="26" loading="lazy"> <img src="/assets/original/payment-taobao.png" alt="淘宝" width="26" height="26" loading="lazy">
<img src="/assets/original/payment-alipay.png" alt="支付宝" width="26" height="26" loading="lazy"> <img src="/assets/original/payment-alipay.png" alt="支付宝" width="26" height="26" loading="lazy">
<img src="/assets/original/payment-wechat.png" alt="微信支付" width="26" height="26" loading="lazy"> <img src="/assets/original/payment-wechat.png" alt="微信支付" width="26" height="26" loading="lazy">
</div> </div>
</div> </div>
<nav class="footer-links" aria-label="页脚导航"> <?php foreach (['products', 'company'] as $group): ?>
<?php foreach (['products', 'company', 'resources'] as $group): ?> <?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?>
<?php if (!$footer[$group] && $footer[$group . '_title'] === '') { continue; } ?> <div>
<div> <?php if ($footer[$group . '_title'] !== ''): ?><p class="footer-label"><?= $e($footer[$group . '_title']) ?></p><?php endif ?>
<?php if ($footer[$group . '_title'] !== ''): ?><h2 class="footer-label"><?= $e($footer[$group . '_title']) ?></h2><?php endif ?> <?php foreach ($footer[$group] as [$url, $label]): ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a><?php endforeach ?>
<?php if ($footer[$group]): ?> </div>
<ul> <?php endforeach ?>
<?php foreach ($footer[$group] as [$url, $label]): ?><li><a href="<?= $e($url) ?>"><?= $e($label) ?></a></li><?php endforeach ?>
</ul>
<?php endif ?>
</div>
<?php endforeach ?>
</nav>
</div> </div>
<div class="footer-meta"> <div class="footer-meta">
<?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?></p><?php endif ?> <?php if ($footer['copyright']): ?><p><?= $e($footer['copyright']) ?> 2024–<?= $e(date('Y')) ?></p><?php endif ?>
<?php if ($footer['email'] || $footer['phones']): ?> <?php if ($footer['phones']): ?>
<p> <p>全球号码
<?php if ($footer['email']): ?><a href="mailto:<?= $e($footer['email']) ?>"><?= $e($footer['email']) ?></a><?php endif ?> <?php foreach ($footer['phones'] as $index => [$url, $label]): ?>
<?php if ($footer['phones']): ?>全球号码: <?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
<?php foreach ($footer['phones'] as $index => [$url, $label]): ?> <?php endforeach ?>
<?= $index ? ' / ' : '' ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a>
<?php endforeach ?>
<?php endif ?>
</p> </p>
<?php endif ?> <?php endif ?>
<?php if ($footer['registration']): ?><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a><?php endif ?>
<?php if ($footer['terms']): ?><p class="footer-terms"><?= $e($footer['terms']) ?></p><?php endif ?> <?php if ($footer['terms']): ?><p class="footer-terms"><?= $e($footer['terms']) ?></p><?php endif ?>
<?php if ($footer['registration']): ?><p><a href="https://beian.miit.gov.cn/"><?= $e($footer['registration']) ?></a></p><?php endif ?>
</div> </div>
</div> </div>
</footer> </footer>
+1 -1
View File
@@ -13,7 +13,7 @@ if (str_starts_with($imageUrl, '/')) {
$kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software'; $kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software';
$siteKind = $kind === 'service' ? 'other' : 'software'; $siteKind = $kind === 'service' ? 'other' : 'software';
$header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER; $header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
$footer = SiteDesign::footer($site); $footer = ($site['footer'] ?? []) + SiteDesign::DEFAULT_FOOTER + $site;
$nav = $header['links']; $nav = $header['links'];
$contact = $header['button']; $contact = $header['button'];
?> ?>
+42 -43
View File
@@ -1,43 +1,42 @@
<?php <?php
use App\Content\View; use App\Content\DirectoryCard;
use App\Content\Html;
$e = View::escape(...); use App\Content\View;
?>
<section class="section network" aria-label="支持项目与合作伙伴"> $e = View::escape(...);
<div class="wrap"> ?>
<?php if (!$standalone): ?> <section class="section network" aria-label="支持项目与合作伙伴">
<div class="section-heading inline-heading"> <div class="wrap">
<h2>支持项目与合作伙伴</h2> <?php if (!$standalone): ?>
<a class="button button-outline" href="/network">查看全部</a> <div class="section-heading inline-heading">
</div> <h2>支持项目与合作伙伴</h2>
<?php endif ?> <a class="button button-outline" href="/network">查看全部</a>
<?php foreach ($network as $slug => $group): ?> </div>
<div class="network-group" id="<?= $e($slug) ?>"> <?php endif ?>
<?php if ($standalone): ?><h2><?= $e($group['name']) ?></h2><?php else: ?><h3><?= $e($group['name']) ?></h3><?php endif ?> <?php foreach ($network as $slug => $group): ?>
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?> <div class="network-group" id="<?= $e($slug) ?>">
<ul class="network-list"> <?php if ($standalone): ?><h2><?= $e($group['name']) ?></h2><?php else: ?><h3><?= $e($group['name']) ?></h3><?php endif ?>
<?php foreach ($group['articles'] as $item): ?> <?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
<?php <ul class="network-list">
// 优先跳卡片配置的网址;没有网址时,只有文章本身有内容才回退到文章页,否则不渲染链接。 <?php foreach ($group['articles'] as $item): ?>
$card = $item['card']; <?php
$articlePath = '/articles/' . $item['slug']; $card = $item['card'];
$hasDetail = $item['body'] !== '' || $item['summary'] !== ''; ['primary' => $target, 'detail' => $detail] = DirectoryCard::links($item, Html::articleBody($item));
$target = ($card['url'] ?? '') ?: ($hasDetail ? $articlePath : ''); ?>
?> <li>
<li> <?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?> <?php if (!empty($card['image'])): ?>
<?php if (!empty($card['image'])): ?> <img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28"> <?php endif ?>
<?php endif ?> <span><?= $e($item['title']) ?></span>
<span><?= $e($item['title']) ?></span> <?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?> <?php if ($standalone && $detail !== ''): ?>
<?php if ($standalone && !empty($card['url']) && $hasDetail): ?> <a class="network-detail" href="<?= $e($detail) ?>">查看详情</a>
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a> <?php endif ?>
<?php endif ?> </li>
</li> <?php endforeach ?>
<?php endforeach ?> </ul>
</ul> </div>
</div> <?php endforeach ?>
<?php endforeach ?> </div>
</div> </section>
</section>
+50 -48
View File
@@ -1,48 +1,50 @@
<?php <?php
use App\Content\Html; use App\Content\DirectoryCard;
use App\Content\View; use App\Content\Html;
use App\Content\View;
$e = View::escape(...);
?> $e = View::escape(...);
<section class="section catalog-hero"> ?>
<div class="wrap"> <section class="section catalog-hero">
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav> <div class="wrap">
<h1>产品与服务</h1> <nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p> <h1>产品与服务</h1>
</div> <p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
</section> </div>
<section class="section catalog-listing" aria-label="产品与服务目录"> </section>
<div class="wrap"> <section class="section catalog-listing" aria-label="产品与服务目录">
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?> <div class="wrap">
<div class="catalog-grid"> <?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
<?php foreach ($products as $product): ?> <div class="catalog-grid">
<?php <?php foreach ($products as $product): ?>
// 目录卡片指向卡片自己配置的网址;没有网址时,只有文章本身有内容才回退到文章页。 <?php
$card = $product['card']; $card = $product['card'];
$hasDetail = $product['body'] !== '' || $product['summary'] !== ''; $body = Html::articleBody($product);
$target = ($card['url'] ?? '') ?: ($hasDetail ? '/articles/' . $product['slug'] : ''); ['primary' => $target, 'detail' => $detail] = DirectoryCard::links($product, $body);
?> $extra = $card['extra_url'] ?? '';
<article class="catalog-card"> ?>
<?php if (!empty($card['image'])): ?> <article class="catalog-card">
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div> <?php if (!empty($card['image'])): ?>
<?php endif ?> <div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
<div class="catalog-content"> <?php endif ?>
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?> <div class="catalog-content">
<h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2> <?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<?php if ($product['summary']): ?> <h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
<p><?= $e($product['summary']) ?></p> <?php if ($product['summary']): ?>
<?php else: ?> <p><?= $e($product['summary']) ?></p>
<div class="rich"><?= Html::articleBody($product) ?></div> <?php else: ?>
<?php endif ?> <div class="rich"><?= $body ?></div>
<?php if ($target !== '' || !empty($card['extra_url'])): ?> <?php endif ?>
<div class="actions"> <?php if ($target !== '' || $extra !== ''): ?>
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?> <div class="actions">
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?> <?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
</div> <?php if ($extra !== '' && $extra !== $target): ?><a href="<?= $e($extra) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
<?php endif ?> <?php if ($detail !== '' && $detail !== $extra): ?><a class="catalog-detail" href="<?= $e($detail) ?>">查看详情</a><?php endif ?>
</div> </div>
</article> <?php endif ?>
<?php endforeach ?> </div>
</div> </article>
</div> <?php endforeach ?>
</section> </div>
</div>
</section>
+1 -9
View File
@@ -36,7 +36,7 @@ $e = View::escape(...);
<small>每行填写「显示号码 | tel:号码」。</small> <small>每行填写「显示号码 | tel:号码」。</small>
</label> </label>
<div class="form-grid"> <div class="form-grid">
<?php foreach (['products' => '第一列', 'company' => '第二列', 'resources' => '第三列'] as $key => $text): ?> <?php foreach (['products' => '第一列', 'company' => '第二列'] as $key => $text): ?>
<div class="admin-form"> <div class="admin-form">
<label><?= $text ?>标题<input name="<?= $key ?>_title" value="<?= $e($config[$key . '_title']) ?>"></label> <label><?= $text ?>标题<input name="<?= $key ?>_title" value="<?= $e($config[$key . '_title']) ?>"></label>
<label><?= $text ?>链接<textarea name="<?= $key ?>" rows="6"><?= $e(SiteDesign::linkText($config[$key])) ?></textarea> <label><?= $text ?>链接<textarea name="<?= $key ?>" rows="6"><?= $e(SiteDesign::linkText($config[$key])) ?></textarea>
@@ -50,11 +50,3 @@ $e = View::escape(...);
<?php endif ?> <?php endif ?>
<div class="form-submit"><button class="button button-primary" type="submit">保存设置</button></div> <div class="form-submit"><button class="button button-primary" type="submit">保存设置</button></div>
</form> </form>
<?php if ($part === 'footer'): ?>
<form method="post" action="/admin/settings/footer">
<input type="hidden" name="csrf" value="<?= $e($token) ?>">
<input type="hidden" name="version" value="<?= $e($revision) ?>">
<input type="hidden" name="operation" value="restore-footer">
<button class="button button-outline" type="submit" data-confirm="用原站的页脚内容覆盖当前页脚设置?">恢复原站页脚</button>
</form>
<?php endif ?>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

+11 -14
View File
@@ -282,7 +282,9 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.network-group + .network-group { margin-top: 2.2rem; } .network-group + .network-group { margin-top: 2.2rem; }
.network-group h3 { margin-bottom: .8rem; } .network-group h3 { margin-bottom: .8rem; }
.network-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .7rem; } .network-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: .7rem; }
.network-list li > * { display: flex; align-items: center; gap: .75rem; min-height: 4rem; height: 100%; border-radius: .65rem; background: var(--white); border: 1px solid var(--line); color: var(--ink); text-decoration: none; padding: .75rem; transition: transform 160ms ease, border-color 160ms ease; } .network-list li { display: flex; flex-direction: column; gap: .35rem; }
.network-list li > * { display: flex; align-items: center; gap: .75rem; min-height: 4rem; border-radius: .65rem; background: var(--white); border: 1px solid var(--line); color: var(--ink); text-decoration: none; padding: .75rem; transition: transform 160ms ease, border-color 160ms ease; }
.network-list li > :first-child { flex: 1; }
.network-list a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); } .network-list a:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
.network-list img { max-width: 3rem; max-height: 1.8rem; object-fit: contain; object-position: left; } .network-list img { max-width: 3rem; max-height: 1.8rem; object-fit: contain; object-position: left; }
.network-list img[src$="oneprovider_invert.svg"] { background: #29354a; border-radius: .25rem; padding: .21rem; } .network-list img[src$="oneprovider_invert.svg"] { background: #29354a; border-radius: .25rem; padding: .21rem; }
@@ -301,22 +303,18 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; } .pagination { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; } .empty-state { background: var(--paper); padding: 1rem; border-radius: .6rem; }
.site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #e4ecfc; border-top: 1px solid var(--line); } .site-footer { padding: clamp(2.5rem, 5.8vw, 5.5rem) 0 2rem; background: #edf2fa; border-top: 1px solid var(--line); }
.footer-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.6rem clamp(2rem, 7vw, 7rem); } .footer-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, .75fr)); gap: 1.5rem 3rem; }
.footer-company { display: flex; flex-direction: column; align-items: flex-start; } .footer-grid > div { display: flex; flex-direction: column; align-items: flex-start; }
.footer-logo img { width: clamp(8.125rem, 13vw, 10rem); height: auto; }
.footer-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 1rem; }
.footer-links ul { padding: 0; margin: 0; list-style: none; }
.footer-grid a, .footer-meta a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; } .footer-grid a, .footer-meta a { color: var(--muted); text-decoration: none; overflow-wrap: anywhere; }
.footer-grid a:hover, .footer-meta a:hover { color: var(--accent); text-decoration: underline; } .footer-grid a:hover, .footer-meta a:hover { color: var(--accent); text-decoration: underline; }
.footer-grid a { min-height: 40px; display: inline-flex; align-items: center; } .footer-grid a { min-height: 44px; display: inline-flex; align-items: center; }
.footer-company p, .footer-label { color: var(--ink); font-weight: 640; margin: .2rem 0 .35rem; } .footer-company p, .footer-label { color: var(--ink); font-weight: 640; margin: .2rem 0 .35rem; }
.footer-label { font-size: 1.05rem; line-height: 1.35; }
.footer-company p { margin-top: .6rem; } .footer-company p { margin-top: .6rem; }
.footer-company .footer-payment-label { margin: .25rem 0 0; color: var(--muted); font-size: .87rem; font-weight: 500; }
.footer-company address { color: var(--muted); max-width: 26rem; font-size: .95rem; } .footer-company address { color: var(--muted); max-width: 26rem; font-size: .95rem; }
.footer-meta { display: grid; gap: .35rem; padding-top: 1.2rem; margin-top: 1.6rem; border-top: 1px solid var(--line); font-size: .875rem; } .footer-meta { display: flex; flex-wrap: wrap; gap: .6rem 1.8rem; padding-top: 1.2rem; margin-top: 1.25rem; border-top: 1px solid var(--line); font-size: .875rem; }
.footer-meta p { margin: 0; } .footer-meta p { margin: 0; }
.footer-terms { flex-basis: 100%; }
@media (max-width: 62rem) { @media (max-width: 62rem) {
.masthead-inner { gap: .85rem; } .masthead-inner { gap: .85rem; }
@@ -362,9 +360,8 @@ progress { width: 100%; height: .8rem; accent-color: var(--accent); }
.article-category { grid-column: 1; grid-row: 1; } .article-category { grid-column: 1; grid-row: 1; }
.article-row-title { grid-column: 1 / -1; grid-row: 2; } .article-row-title { grid-column: 1 / -1; grid-row: 2; }
.article-row time { grid-column: 2; grid-row: 1; } .article-row time { grid-column: 2; grid-row: 1; }
.footer-grid { grid-template-columns: 1fr; } .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
.footer-company { align-items: center; text-align: center; } .footer-company { grid-column: 1 / -1; }
.footer-links, .footer-meta { text-align: center; }
} }
@media (max-width: 23rem) { @media (max-width: 23rem) {
.hero-actions .button { width: 100%; } .hero-actions .button { width: 100%; }
-18
View File
@@ -1,18 +0,0 @@
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
use App\Content\Database;
// 输出目录类文章:slug<TAB>卡片网址<TAB>是否已发布
$pdo = Database::connect();
$query = $pdo->query("SELECT a.slug, a.card, a.status FROM articles a
WHERE EXISTS (SELECT 1 FROM article_category_links l WHERE l.article_id = a.id
AND l.category_slug IN ('services', 'supported-projects', 'partners'))
ORDER BY a.id");
foreach ($query as $row) {
$card = json_decode($row['card'], true) ?: [];
echo $row['slug'], '|', $card['url'] ?? '', '|', $row['status'], "\n";
}
+56
View File
@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
require dirname(__DIR__) . '/vendor/autoload.php';
use App\Content\View;
$primary = 'https://example.com/product?a=1&b=2';
$cases = [
'configured-with-detail' => [['card' => ['url' => $primary], 'body' => '<p>有正文</p>'], $primary, true],
'configured-only' => [['card' => ['url' => '/pagepan']], '/pagepan', false],
'summary-only' => [['summary' => '仅摘要'], '/articles/summary-only', false],
'editor-placeholder' => [['body' => '<p><br></p><p>&nbsp;&#8203;</p>'], '', false],
'markdown-comment' => [['body' => '<!-- 草稿注释 -->', 'body_format' => 'markdown'], '', false],
'media-body' => [['body' => '<video controls><source src="/assets/demo.mp4"></video>'], '/articles/media-body', false],
'unconfigured' => [[], '', false],
];
$items = [];
foreach ($cases as $slug => [$fields]) {
$items[] = $fields + ['slug' => $slug, 'title' => $slug, 'card' => [], 'summary' => '', 'body' => '', 'body_format' => 'html'];
}
function parseFragment(string $html): DOMXPath
{
$document = new DOMDocument();
$document->loadHTML('<meta charset="utf-8">' . $html, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET);
return new DOMXPath($document);
}
function equal(mixed $actual, mixed $expected, string $message): void
{
if ($actual !== $expected) {
throw new RuntimeException($message . ' ' . json_encode([$expected, $actual], JSON_UNESCAPED_UNICODE));
}
}
$services = parseFragment(View::fragment('services', ['products' => $items]));
$network = parseFragment(View::fragment('network-groups', [
'network' => ['partners' => ['name' => '合作伙伴', 'articles' => $items]], 'standalone' => true,
]));
foreach ($cases as $slug => [, $target, $detail]) {
$card = "//article[h2='$slug' or div/h2='$slug']";
equal($services->evaluate("count($card)"), 1.0, "$slug 服务卡片存在");
equal($services->evaluate("string($card/div/h2/a/@href)"), $target, "$slug 服务标题目标");
equal($services->evaluate("string($card/div/div/a[contains(@class, 'button-primary')]/@href)"), $target, "$slug 服务按钮目标");
equal($services->evaluate("boolean($card/div/div/a[@class='catalog-detail'][@href='/articles/$slug'])"), $detail, "$slug 服务独立详情");
$item = "//li[*[1]/span='$slug']";
equal($network->evaluate("count($item)"), 1.0, "$slug 伙伴卡片存在");
equal($network->evaluate("string($item/*[1]/@href)"), $target, "$slug 伙伴卡片目标");
equal($network->evaluate("boolean($item/a[@class='network-detail'][@href='/articles/$slug'])"), $detail, "$slug 伙伴独立详情");
}
printf("通过 %d 组目录卡片测试。\n", count($cases));
+3 -66
View File
@@ -1,67 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# 目录页(/services、/network)的卡片链接必须指向卡片配置的网址,而不是 /articles/<slug> set -euo pipefail
set -u cd "$(dirname "$0")/.."
cd "$(dirname "$0")/.." || exit 1 exec "${PHP_BIN:-php}" tests/directory-links.php
BASE=http://127.0.0.1:8787
PASS=0; FAIL=0
ok(){ PASS=$((PASS+1)); printf ' ok %s\n' "$1"; }
no(){ FAIL=$((FAIL+1)); printf ' FAIL %s -> %s\n' "$1" "${2:-}"; }
SERVICES=$(curl -s "$BASE/services")
NETWORK=$(curl -s "$BASE/network")
ROWS=$(php tests/dircheck.php)
echo "== /services 卡片链接 =="
while IFS='|' read -r slug url status; do
[ -z "$slug" ] && continue
[ -z "$url" ] && continue
if echo "$SERVICES" | grep -q "href=\"$url\""; then ok "$slug 标题/按钮指向 $url"; else no "$slug 未指向 $url"; fi
if echo "$SERVICES" | grep -q "href=\"/articles/$slug\""; then no "$slug 仍出现 /articles/$slug"; else ok "$slug 不再指向文章页"; fi
done <<< "$(echo "$ROWS" | grep -E '^service-')"
echo "== /network 卡片链接 =="
while IFS='|' read -r slug url status; do
[ -z "$slug" ] && continue
[ -z "$url" ] && continue
if echo "$NETWORK" | grep -q "href=\"$url\""; then ok "$slug 指向 $url"; else no "$slug 未指向 $url"; fi
if echo "$NETWORK" | grep -q "href=\"/articles/$slug\""; then no "$slug 仍出现 /articles/$slug"; else ok "$slug 不再指向文章页"; fi
done <<< "$(echo "$ROWS" | grep -E '^network-')"
echo "== 标题链接与按钮链接一致性 =="
python3 - "$BASE" <<'PY'
import re, sys, html, urllib.request
base = sys.argv[1]
def get(path):
return urllib.request.urlopen(base + path, timeout=10).read().decode()
page = get('/services')
cards = re.findall(r'<article class="catalog-card">.*?</article>', page, re.S)
bad = 0
for card in cards:
links = re.findall(r'<a[^>]*href="([^"]+)"', card)
title = re.search(r'<h2><a href="([^"]+)"', card)
if not title:
print(' FAIL 卡片缺标题链接'); bad += 1; continue
primary = [l for l in links if not l.startswith('/articles/')]
if primary and title.group(1) != primary[0]:
print(' FAIL 标题 href=%s 与主按钮 href=%s 不一致' % (title.group(1), primary[0])); bad += 1
print(' ok %d 张卡片标题与主按钮一致' % (len(cards) - bad) if bad == 0 else ' 共 %d 张卡片,%d 张不一致' % (len(cards), bad))
sys.exit(0 if bad == 0 else 1)
PY
[ $? -eq 0 ] && ok "标题与按钮目标一致" || no "标题与主按钮目标不一致"
echo "== 参考信息:目录条目在文章流中的可见性(不判定) =="
PUB=$(echo "$ROWS" | awk -F'|' '$3 == "published" {print $1}')
N=0
for slug in $PUB; do
if curl -s "$BASE/articles" | grep -q "href=\"/articles/$slug\""; then N=$((N+1)); fi
done
echo " /articles 列表中出现的目录条目: $N / $(echo "$PUB" | wc -l)"
M=0
for slug in $PUB; do
if curl -s "$BASE/sitemap.xml" | grep -q "/articles/$slug"; then M=$((M+1)); fi
done
echo " sitemap 中的目录条目: $M / $(echo "$PUB" | wc -l)"
echo ""
echo "== 结果: $PASS 通过, $FAIL 失败 =="
[ $FAIL -eq 0 ] || exit 1