Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62c10b09bc | ||
|
|
935bc7f071 | ||
|
|
1a025353b2 | ||
|
|
ef1ff93904 |
+43
-37
@@ -1,37 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<section class="section network" aria-label="支持项目与合作伙伴">
|
<section class="section network" aria-label="支持项目与合作伙伴">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?php if (!$standalone): ?>
|
<?php if (!$standalone): ?>
|
||||||
<div class="section-heading inline-heading">
|
<div class="section-heading inline-heading">
|
||||||
<h2>支持项目与合作伙伴</h2>
|
<h2>支持项目与合作伙伴</h2>
|
||||||
<a class="button button-outline" href="/network">查看全部</a>
|
<a class="button button-outline" href="/network">查看全部</a>
|
||||||
</div>
|
</div>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php foreach ($network as $slug => $group): ?>
|
<?php foreach ($network as $slug => $group): ?>
|
||||||
<div class="network-group" id="<?= $e($slug) ?>">
|
<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 ($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 ?>
|
<?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
|
||||||
<li>
|
// 优先跳卡片配置的网址;没有网址时,只有文章本身有内容才回退到文章页,否则不渲染链接。
|
||||||
<a href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>">
|
$card = $item['card'];
|
||||||
<?php if (!empty($card['image'])): ?>
|
$articlePath = '/articles/' . $item['slug'];
|
||||||
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
$hasDetail = $item['body'] !== '' || $item['summary'] !== '';
|
||||||
<?php endif ?>
|
$target = ($card['url'] ?? '') ?: ($hasDetail ? $articlePath : '');
|
||||||
<span><?= $e($item['title']) ?></span>
|
?>
|
||||||
</a>
|
<li>
|
||||||
<?php if ($standalone && !empty($card['url']) && ($item['body'] !== '' || $item['summary'] !== '')): ?>
|
<?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?php else: ?><span class="network-static"><?php endif ?>
|
||||||
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
<?php if (!empty($card['image'])): ?>
|
||||||
<?php endif ?>
|
<img src="<?= $e($card['image']) ?>" alt="" loading="lazy" width="76" height="28">
|
||||||
</li>
|
<?php endif ?>
|
||||||
<?php endforeach ?>
|
<span><?= $e($item['title']) ?></span>
|
||||||
</ul>
|
<?php if ($target !== ''): ?></a><?php else: ?></span><?php endif ?>
|
||||||
</div>
|
<?php if ($standalone && !empty($card['url']) && $hasDetail): ?>
|
||||||
<?php endforeach ?>
|
<a class="network-detail" href="<?= $e($articlePath) ?>">查看详情</a>
|
||||||
</div>
|
<?php endif ?>
|
||||||
</section>
|
</li>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|||||||
+48
-41
@@ -1,41 +1,48 @@
|
|||||||
<?php
|
<?php
|
||||||
use App\Content\Html;
|
use App\Content\Html;
|
||||||
use App\Content\View;
|
use App\Content\View;
|
||||||
|
|
||||||
$e = View::escape(...);
|
$e = View::escape(...);
|
||||||
?>
|
?>
|
||||||
<section class="section catalog-hero">
|
<section class="section catalog-hero">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
||||||
<h1>产品与服务</h1>
|
<h1>产品与服务</h1>
|
||||||
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="section catalog-listing" aria-label="产品与服务目录">
|
<section class="section catalog-listing" aria-label="产品与服务目录">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<?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
|
||||||
<article class="catalog-card">
|
// 目录卡片指向卡片自己配置的网址;没有网址时,只有文章本身有内容才回退到文章页。
|
||||||
<?php if (!empty($card['image'])): ?>
|
$card = $product['card'];
|
||||||
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
$hasDetail = $product['body'] !== '' || $product['summary'] !== '';
|
||||||
<?php endif ?>
|
$target = ($card['url'] ?? '') ?: ($hasDetail ? '/articles/' . $product['slug'] : '');
|
||||||
<div class="catalog-content">
|
?>
|
||||||
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
<article class="catalog-card">
|
||||||
<h2><a href="<?= $e($articlePath) ?>"><?= $e($product['title']) ?></a></h2>
|
<?php if (!empty($card['image'])): ?>
|
||||||
<?php if ($product['summary']): ?>
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
||||||
<p><?= $e($product['summary']) ?></p>
|
<?php endif ?>
|
||||||
<?php else: ?>
|
<div class="catalog-content">
|
||||||
<div class="rich"><?= Html::articleBody($product) ?></div>
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
||||||
<?php endif ?>
|
<h2><?php if ($target !== ''): ?><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a><?php else: ?><?= $e($product['title']) ?><?php endif ?></h2>
|
||||||
<div class="actions">
|
<?php if ($product['summary']): ?>
|
||||||
<a class="button button-primary" href="<?= $e(($card['url'] ?? '') ?: $articlePath) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a>
|
<p><?= $e($product['summary']) ?></p>
|
||||||
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
<?php else: ?>
|
||||||
</div>
|
<div class="rich"><?= Html::articleBody($product) ?></div>
|
||||||
</div>
|
<?php endif ?>
|
||||||
</article>
|
<?php if ($target !== '' || !empty($card['extra_url'])): ?>
|
||||||
<?php endforeach ?>
|
<div class="actions">
|
||||||
</div>
|
<?php if ($target !== ''): ?><a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a><?php endif ?>
|
||||||
</div>
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
||||||
</section>
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|||||||
@@ -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";
|
||||||
|
}
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user