Author SHA1 Message Date
DeepSeek 62c10b09bc Skip links to empty directory articles 2026-11-21 23:26:15 +08:00
DeepSeek 935bc7f071 Skip links to empty directory articles 2026-11-21 23:26:14 +08:00
DeepSeek 1a025353b2 Merge pull request #7: 修复产品目录卡片标题指向文章页
标题与主按钮统一使用卡片配置的网址,未配置时回退文章页。21 项链接断言通过。
2026-11-21 23:23:56 +08:00
DeepSeek ef1ff93904 Point product cards at their configured URL
The services directory built each card title from the backing article, so
/services linked to /articles/service-1..4 instead of the product pages the
card already carries (PAGEPAN, HighSpeaker, /sc, /shnu-sc). Only the primary
button used card.url, which made the title and the button disagree.

Use the card URL for both, keeping the article page as fallback for entries
without a configured URL, and add a dependency-free regression test.
2026-11-21 23:23:23 +08:00
DeepSeek 74e0de84a6 Merge pull request #6: 限制文章区块归档范围,扩展编辑组件与对齐工具
审计通过(405 项断言 + 浏览器实测对齐链路),合并。合并后需对现有 LAYSENSE_DB 运行 php bin/install.php 补 alignments 列并重启 Webman。
2026-11-21 23:16:53 +08:00
4 changed files with 176 additions and 78 deletions
+10 -4
View File
@@ -17,15 +17,21 @@ $e = View::escape(...);
<?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?> <?php if (!$group['articles']): ?><p class="empty-state">暂无已发布条目。</p><?php endif ?>
<ul class="network-list"> <ul class="network-list">
<?php foreach ($group['articles'] as $item): ?> <?php foreach ($group['articles'] as $item): ?>
<?php $card = $item['card']; $articlePath = '/articles/' . $item['slug']; ?> <?php
// 优先跳卡片配置的网址;没有网址时,只有文章本身有内容才回退到文章页,否则不渲染链接。
$card = $item['card'];
$articlePath = '/articles/' . $item['slug'];
$hasDetail = $item['body'] !== '' || $item['summary'] !== '';
$target = ($card['url'] ?? '') ?: ($hasDetail ? $articlePath : '');
?>
<li> <li>
<a href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>"> <?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>
</a> <?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
<?php if ($standalone && !empty($card['url']) && ($item['body'] !== '' || $item['summary'] !== '')): ?> <?php if ($standalone && !empty($card['url']) && $hasDetail): ?>
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a> <a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
<?php endif ?> <?php endif ?>
</li> </li>
+10 -3
View File
@@ -16,23 +16,30 @@ $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']; ?> <?php
// 目录卡片指向卡片自己配置的网址;没有网址时,只有文章本身有内容才回退到文章页。
$card = $product['card'];
$hasDetail = $product['body'] !== '' || $product['summary'] !== '';
$target = ($card['url'] ?? '') ?: ($hasDetail ? '/articles/' . $product['slug'] : '');
?>
<article class="catalog-card"> <article class="catalog-card">
<?php if (!empty($card['image'])): ?> <?php if (!empty($card['image'])): ?>
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['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">
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?> <?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
<h2><a href="<?= $e($articlePath) ?>"><?= $e($product['title']) ?></a></h2> <h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
<?php if ($product['summary']): ?> <?php if ($product['summary']): ?>
<p><?= $e($product['summary']) ?></p> <p><?= $e($product['summary']) ?></p>
<?php else: ?> <?php else: ?>
<div class="rich"><?= Html::articleBody($product) ?></div> <div class="rich"><?= Html::articleBody($product) ?></div>
<?php endif ?> <?php endif ?>
<?php if ($target !== '' || !empty($card['extra_url'])): ?>
<div class="actions"> <div class="actions">
<a class="button button-primary" href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a> <?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $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 ?> <?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
</div> </div>
<?php endif ?>
</div> </div>
</article> </article>
<?php endforeach ?> <?php endforeach ?>
+18
View File
@@ -0,0 +1,18 @@
<?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";
}
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# 目录页(/services、/network)的卡片链接必须指向卡片配置的网址,而不是 /articles/<slug>
set -u
cd "$(dirname "$0")/.." || exit 1
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