Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
415b5f8ab5 |
No files matched your search
@@ -11,3 +11,5 @@ ## AI 文章写作(必读)
|
||||
插画完成后按[自动交付](docs/maintenance/ILLUSTRATION_DELIVERY.md)提交批准批次;不要再手工上传发布/编辑图池或把保存草稿当作上线完成。
|
||||
|
||||
周期文章按[固定发布封装](docs/maintenance/EDITORIAL_RELEASE.md)执行:本机SSH必须经白色机到正式业务服务器,使用服务器进程内API,不临时开放公网接口。每周三篇、每天15:00检查、错过窗口回补及文章随机展示时间见[周期写作](docs/maintenance/WEEKLY_TUTORIALS.md);这一流程替代周期写作中的手动开关API步骤,不扩大其他实例或全站改版权限。
|
||||
|
||||
教程SEO、编辑API的IndexNow结果与重试、栏目sitemap的唯一维护说明见[教程SEO通知](docs/maintenance/EDITORIAL_INDEXNOW.md)。`sitemap: done`不代表搜索引擎已收到通知或已收录。
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Editorial\PublicationEffects;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
final class RetryEditorialIndexNow extends Command
|
||||
{
|
||||
protected $signature = 'editorial:indexnow-retry';
|
||||
|
||||
protected $description = 'Retry due editorial IndexNow notifications without republishing content';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (! app()->environment(['production', 'testing']) || ! config('editorial.indexnow_enabled', app()->environment('production'))) {
|
||||
$this->line('IndexNow retry disabled in this environment.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
$ids = DB::table('editorial_publications')->where('effects->indexnow->status', 'pending')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('effects->indexnow->next_attempt_at')
|
||||
->orWhere('effects->indexnow->next_attempt_at', '<=', now()->timestamp);
|
||||
})->orderBy('updated_at')->limit(10)->pluck('id');
|
||||
$pending = 0;
|
||||
foreach ($ids as $id) {
|
||||
try {
|
||||
$receipt = app(PublicationEffects::class)->synchronize($id);
|
||||
$pending += ($receipt['effects']['indexnow']['status'] ?? '') === 'pending' ? 1 : 0;
|
||||
} catch (\Throwable) {
|
||||
$pending++;
|
||||
}
|
||||
}
|
||||
$this->line(json_encode(['processed' => count($ids), 'pending' => $pending]));
|
||||
|
||||
return $pending ? self::FAILURE : self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -3,29 +3,33 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Models\Categories;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
// 连表查询分类:按 aOpt['noindexday'] 动态过滤过期文章
|
||||
// Use the same expiry rule as article metadata, including on SQLite in isolated tests.
|
||||
$cArticles = Articles::where('iStatus', 1)
|
||||
->whereHas('oCategory', function ($q) {
|
||||
$q->where(function ($query) {
|
||||
// 1. 没有配置 noindexday,或者 noindexday = 0 的文章,一直保留
|
||||
$query->whereNull('aOpt')
|
||||
->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) IS NULL")
|
||||
->orWhereRaw("JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) = '0'")
|
||||
// 2. 配置了天数的,只取 N 天内创建的新文章
|
||||
->orWhereRaw("articles.created_at >= NOW() - INTERVAL CAST(JSON_UNQUOTE(JSON_EXTRACT(aOpt, '$.noindexday')) AS UNSIGNED) DAY");
|
||||
});
|
||||
})
|
||||
->where('created_at', '<=', now())
|
||||
->whereHas('oCategory', fn ($q) => $q->where('iStatus', 1))
|
||||
->with('oCategory')
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
->get()->reject(fn ($article) => $article->bIsSeoExpired());
|
||||
|
||||
$visible = fn ($q) => $q->where('iStatus', 1)->where('created_at', '<=', now());
|
||||
$cCategories = Categories::whereIn('sSlug', ['client', 'advanced'])
|
||||
->where('iParentId', 0)->where('iStatus', 1)
|
||||
->where(function ($q) use ($visible) {
|
||||
$q->whereHas('aArticles', $visible)->orWhereHas('aChildren', function ($children) use ($visible) {
|
||||
$children->where('iStatus', 1)->whereHas('aArticles', $visible);
|
||||
});
|
||||
})->orderBy('sSlug')->get();
|
||||
|
||||
$sXmlContent = view('sitemap', [
|
||||
'cArticles' => $cArticles
|
||||
'cArticles' => $cArticles,
|
||||
'cCategories' => $cCategories,
|
||||
])->render();
|
||||
|
||||
return response($sXmlContent, 200)->header('Content-Type', 'text/xml');
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Editorial;
|
||||
|
||||
use App\Models\Articles;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
/** Durable notification state lives in the publication receipt, alongside cache/search effects. */
|
||||
final class IndexNowNotification
|
||||
{
|
||||
public function initial(array $articles): array
|
||||
{
|
||||
if (! $this->enabled()) {
|
||||
return ['status' => 'skipped', 'reason' => 'disabled-environment'];
|
||||
}
|
||||
if (! collect($articles)->contains(fn ($a) => $a['content_changed'] ?? false)) {
|
||||
return ['status' => 'skipped', 'reason' => 'no-content-change'];
|
||||
}
|
||||
|
||||
return ['status' => 'pending', 'attempts' => 0];
|
||||
}
|
||||
|
||||
public function synchronize(array $state, array $published): array
|
||||
{
|
||||
if (($state['status'] ?? '') !== 'pending' || ! $this->enabled()
|
||||
|| ($state['next_attempt_at'] ?? 0) > now()->timestamp) {
|
||||
return $state;
|
||||
}
|
||||
|
||||
$base = rtrim((string) config('editorial.base_url'), '/');
|
||||
$host = parse_url($base, PHP_URL_HOST);
|
||||
// No per-article target, redirect, or credentials in URLs. Never probe public pages from local.
|
||||
if (! $host || ! preg_match('~\Ahttps://[a-z0-9.-]+\z~i', $base)
|
||||
|| $base !== rtrim((string) config('app.url'), '/')
|
||||
|| $host !== config('app.site_code')) {
|
||||
return $this->pending($state, 'site-binding-mismatch');
|
||||
}
|
||||
$key = config('key.indexnow');
|
||||
if (! is_string($key) || ! preg_match('/\A[a-zA-Z0-9-]{8,128}\z/', $key)) {
|
||||
return $this->pending($state, 'key-missing-or-invalid');
|
||||
}
|
||||
|
||||
$urls = [];
|
||||
foreach ($published as $item) {
|
||||
if (! ($item['content_changed'] ?? false)) {
|
||||
continue;
|
||||
}
|
||||
$article = Articles::with('oCategory')->find($item['article_id']);
|
||||
if (! $article || (int) $article->iStatus !== 1 || ! $article->oCategory
|
||||
|| (int) $article->oCategory->iStatus !== 1 || $article->created_at->isFuture()
|
||||
|| $article->bIsSeoExpired()) {
|
||||
continue;
|
||||
}
|
||||
$url = $base.'/a/'.$article->sSlug.'.html';
|
||||
if ($url === $item['url'] && preg_match('/\A[a-z0-9_-]+\z/', $article->sSlug)) {
|
||||
$urls[] = $url;
|
||||
}
|
||||
}
|
||||
$urls = array_values(array_unique($urls));
|
||||
if (! $urls) {
|
||||
return array_replace($state, ['status' => 'skipped', 'reason' => 'no-current-indexable-url']);
|
||||
}
|
||||
|
||||
try {
|
||||
$response = Http::connectTimeout(5)->timeout(15)->withoutRedirecting()->acceptJson()
|
||||
->post('https://api.indexnow.org/indexnow', [
|
||||
'host' => $host, 'key' => $key, 'keyLocation' => $base.'/'.$key.'.txt', 'urlList' => $urls,
|
||||
]);
|
||||
$code = $response->status();
|
||||
if (in_array($code, [200, 202], true)) {
|
||||
return ['status' => 'done', 'attempts' => ($state['attempts'] ?? 0) + 1,
|
||||
'http_status' => $code, 'urls' => $urls, 'submitted_at' => now()->toIso8601String(),
|
||||
'result' => $code === 202 ? 'received-key-validation-pending' : 'received'];
|
||||
}
|
||||
|
||||
return $this->pending($state, 'http-error', $code);
|
||||
} catch (\Throwable) {
|
||||
// Response bodies and exception messages may contain the key. Persist only safe diagnostics.
|
||||
return $this->pending($state, 'transport-error');
|
||||
}
|
||||
}
|
||||
|
||||
private function enabled(): bool
|
||||
{
|
||||
return app()->environment(['production', 'testing'])
|
||||
&& (bool) config('editorial.indexnow_enabled', app()->environment('production'));
|
||||
}
|
||||
|
||||
private function pending(array $state, string $reason, ?int $code = null): array
|
||||
{
|
||||
$attempts = ($state['attempts'] ?? 0) + 1;
|
||||
|
||||
return ['status' => 'pending', 'attempts' => $attempts, 'reason' => $reason, 'http_status' => $code,
|
||||
'last_attempt_at' => now()->toIso8601String(),
|
||||
'next_attempt_at' => now()->timestamp + min(86400, 300 * 2 ** min(9, $attempts - 1))];
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,12 @@ public function synchronize(string $id): array
|
||||
}
|
||||
// Sitemap is generated from current DB rows, no external submission is performed.
|
||||
$effects['sitemap'] = ['status' => ($effects['cache']['status'] ?? '') === 'done' ? 'done' : 'pending', 'method' => 'database-driven'];
|
||||
// Legacy receipts were not queued for notification; never backfill them implicitly.
|
||||
$notification = $effects['indexnow'] ?? ['status' => 'skipped', 'reason' => 'legacy-publication'];
|
||||
if (($effects['cache']['status'] ?? '') === 'done') {
|
||||
$notification = app(IndexNowNotification::class)->synchronize($notification, $receipt['articles']);
|
||||
}
|
||||
$effects['indexnow'] = $notification;
|
||||
DB::table('editorial_publications')->where('id', $id)->update(['effects' => json_encode($effects), 'updated_at' => now()]);
|
||||
});
|
||||
|
||||
|
||||
@@ -206,10 +206,13 @@ public function publish(string $id, array $input): array
|
||||
DB::table('editorial_documents')->where('content_key', $item['content_key'])->update(['article_id' => $articleId, 'published_revision' => $item['revision'], 'updated_at' => now()]);
|
||||
DB::table('editorial_versions')->insert(['content_key' => $item['content_key'], 'revision' => $item['revision'], 'snapshot' => json_encode($item, JSON_UNESCAPED_UNICODE), 'created_at' => now()]);
|
||||
$published[] = ['content_key' => $item['content_key'], 'article_id' => $articleId, 'revision' => $item['revision'],
|
||||
'content_changed' => $item['base_article_hash'] !== $this->articleHash(DB::table('articles')->where('id', $articleId)->first()),
|
||||
'url' => rtrim(config('editorial.base_url'), '/').'/a/'.$item['slug'].'.html'];
|
||||
}
|
||||
DB::table('editorial_publications')->insert(['id' => $data['request_id'], 'draft_id' => $id, 'payload_hash' => $opHash,
|
||||
'receipt' => json_encode(['publication_id' => $data['request_id'], 'status' => 'published', 'articles' => $published], JSON_UNESCAPED_UNICODE), 'created_at' => now(), 'updated_at' => now()]);
|
||||
'receipt' => json_encode(['publication_id' => $data['request_id'], 'status' => 'published', 'articles' => $published], JSON_UNESCAPED_UNICODE),
|
||||
'effects' => json_encode(['indexnow' => app(IndexNowNotification::class)->initial($published)]),
|
||||
'created_at' => now(), 'updated_at' => now()]);
|
||||
DB::table('editorial_drafts')->where('id', $id)->update(['status' => 'published', 'publication_id' => $data['request_id'], 'updated_at' => now()]);
|
||||
|
||||
return $data['request_id'];
|
||||
|
||||
@@ -141,7 +141,8 @@ private function verify(string $file, array $state): array
|
||||
'body_sha256' => hash('sha256', $source['body_html']), 'like_growth' => $source['like_growth']];
|
||||
}
|
||||
$state['readback'] = $readback;
|
||||
$done = collect($state['receipt']['effects'])->every(fn ($e) => ($e['status'] ?? '') === 'done');
|
||||
$done = collect($state['receipt']['effects'])->every(fn ($e, $name) => ($e['status'] ?? '') === 'done'
|
||||
|| ($name === 'indexnow' && ($e['status'] ?? '') === 'skipped'));
|
||||
$state['phase'] = $done && collect($readback)->every(fn ($r) => $r['revision_matches'] && $r['content_matches']) ? 'complete' : 'published_pending';
|
||||
$this->save($file, $state);
|
||||
|
||||
|
||||
@@ -7,4 +7,5 @@
|
||||
'preview_minutes' => 30,
|
||||
'max_batch' => 10,
|
||||
'search_index' => env('EDITORIAL_SEARCH_INDEX', env('APP_ENV') === 'local' ? 'fna_v3_articles' : null),
|
||||
'indexnow_enabled' => env('EDITORIAL_INDEXNOW_ENABLED', env('APP_ENV') === 'production'),
|
||||
];
|
||||
@@ -10,7 +10,7 @@ ## 职责与数据
|
||||
|
||||
项目正文源保留可编辑稿;`editorial_drafts`保存收到并渲染后的冻结版本,发布读取该快照,不临时重新读取文件。`articles`为公开显示数据,草稿不写入它。`editorial_documents`按稳定`content_key`绑定本站文章;`editorial_versions`保留已发布版本和首次接管旧文的基线版本0;`editorial_publications`保存独立发布回执及后续处理状态。图片元信息在`editorial_assets`。
|
||||
|
||||
新API不调用旧接收器,不发送旧Telegram通知、IndexNow提交或ATOM请求。旧资源接收接口继续沿用原流程,不在本次改造范围;普通编辑API拒绝免费节点与小火箭ID两个自动资源栏目。旧接口/人工直接编辑同一文章会造成草稿基线变化,新API发布时返回409,不能静默覆盖并行修改。
|
||||
新API不调用旧接收器,不发送旧Telegram通知或ATOM请求。2026-10-31起编辑文章新增/实质修改后具有独立IndexNow回执与失败重试,见[教程SEO通知](EDITORIAL_INDEXNOW.md);本地和测试不真实外发。旧资源接收接口继续沿用原流程,不在本次改造范围;普通编辑API拒绝免费节点与小火箭ID两个自动资源栏目。旧接口/人工直接编辑同一文章会造成草稿基线变化,新API发布时返回409,不能静默覆盖并行修改。
|
||||
|
||||
## 凭据与环境
|
||||
|
||||
@@ -116,9 +116,9 @@ ### 3 发布确认过的版本
|
||||
|
||||
- `status: published`:本次内容已写入本站公开文章表;这是所调用环境的状态,本地成功不代表生产成功。
|
||||
- `articles`:各文章的`content_key`、`article_id`、`revision`和URL。
|
||||
- `effects.cache/search/sitemap`:各后续处理的独立结果。搜索暂时失败不撤销已提交正文,返回`pending`,不能重发正文来弥补搜索失败。
|
||||
- `effects.cache/search/sitemap/indexnow`:各后续处理的独立结果。搜索暂时失败不撤销已提交正文,返回`pending`,不能重发正文来弥补搜索失败。
|
||||
|
||||
后续处理为刷新本站响应缓存与热门数据缓存、同步本站搜索,以及使用数据库驱动的sitemap。缓存未刷新时sitemap也标记pending。不调用搜索引擎主动提交。
|
||||
后续处理为刷新本站响应缓存与热门数据缓存、同步本站搜索,以及使用数据库驱动的sitemap。缓存未刷新时sitemap也标记pending。IndexNow以独立`effects.indexnow`记录,不与sitemap结果混用,见[教程SEO通知](EDITORIAL_INDEXNOW.md)。
|
||||
|
||||
### 4 查询、重试与回退
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# 教程SEO通知与栏目Sitemap
|
||||
|
||||
2026-10-31用户授权补齐教程发布后的IndexNow,并确认将两个教程栏目加入sitemap。当前:34项隔离测试/310断言通过,正式发布准备中。最终Git与服务器验收在下方记录。
|
||||
|
||||
## 发布与通知
|
||||
|
||||
沿本站草稿→预览→hash发布的既有流程,不经ATOM。正文事务内初始化`effects.indexnow`,新增文章和标题/摘要/正文/封面/栏目/标签等公开字段实质变更才排队;不变稿、点赞变化不发通知。正文提交后,在缓存刷新成功后尝试发送。复用`key.indexnow`,目标固定`https://api.indexnow.org/indexnow`;base_url必须与APP_URL及site_code一致且HTTPS,不跟随重定向,不拼接其他主机,不探测文章页面。
|
||||
|
||||
- `done`:HTTP200表示已接收;HTTP202另标记`received-key-validation-pending`。均不等于已抓取、已收录或排名提升。
|
||||
- `pending`:持久化安全原因、尝试次数、HTTP码和下一次时间。正文已发表,不回滚、不重发文章;缺key、主机绑定错误、网络异常、429/5xx等沿同一回执重试。不保存响应正文/异常文本,避免泄露key。
|
||||
- `skipped`:本地/测试/禁用环境、无内容变化、历史未排队回执,或重试时已无当前可索引URL。回执说明原因,不能把skipped写成提交成功。
|
||||
|
||||
`EDITORIAL_INDEXNOW_ENABLED`默认仅production启用;local/staging即使误设true仍不发送。测试只用Http替身,不向线上发请求。使用原生产key,不创建或轮换凭据。
|
||||
|
||||
重试命令`php artisan editorial:indexnow-retry`由业务服务器原Laravel调度每5分钟运行,非白色机任务;一次最多处理10批,沿发布行锁串行防并发。退避5分钟起翻倍,最多24小时;原发布请求或`synchronize`也遵守同一退避。done/skipped不重发,不自动补交历史教程。服务器在远端已收到但本地回执尚未提交时崩溃,恢复可能再次通知同一URL;不能保证跨网络恰好一次。
|
||||
|
||||
提交前重读文章:已发布、分类启用、非未来且未过期;只提交仍匹配回执的本站文章URL。不支持用本流程进行撤稿/删除通知,旧日更接收器保留原实现。ReleaseRunner的complete要求IndexNow为done或明确skipped,pending反映published_pending;读status不发送。
|
||||
|
||||
没有新增运行消息,内部重试留本站回执;按TeleHub规范无需制造通知。地址身份沿既有本站配置,不新增DomainHub配置或第二个发布平台。
|
||||
|
||||
## 栏目sitemap
|
||||
|
||||
仅加入`/client`与`/advanced`两个根栏目。栏目启用且自己或启用的直接子栏目有已发布非未来文章时进入;不加入其他分类/标签/搜索、错误别名、空栏目或分页参数。根栏目没有可靠内容修改时间,因此不输出伪造lastmod。
|
||||
|
||||
文章沿模型的同一`noindexday`判断过滤过期,并排除草稿、未来文和停用分类;保留原文章URL。当前sitemap仍取文章updated_at为lastmod,点赞耦合、分页robots/canonical、摘要当天日期属于原SEO计划剩余项,不在本批完成。不存在“sitemap done=主动推送”的等式。
|
||||
|
||||
## 验证与恢复
|
||||
|
||||
隔离测试覆盖新文、实质修改、不变稿、重复发布、失败退避与定时恢复、HTTP202、主机错误、历史回执不补发、撤下文章不发送,以及非空/空/停用/子类教程栏目和发布封装pending→complete。全部HTTP使用替身,独立SQLite,不改本地业务库。
|
||||
|
||||
正式发布只涉及本文关联代码/测试/文档,无schema迁移,不改业务正文、已有IndexNow密钥、旧日更接口、Nginx、域名或原任务。发布前保存Git基线、生成模板哈希、sitemap集合及脱敏配置检查;经白色机在业务机Git临时worktree提交推送,正式检出明确SHA。若有并行改动或HEAD漂移,停止并重做基线。回滚检回本批基线SHA,保留后续产生的发布回执与内容,不恢复整库;也可显式关闭开关暂停新通知与重试。
|
||||
|
||||
已完成服务器侧验收后不另做线上页面验收。不创建演练文章;下一次真实发布前不声称通知已真实送达。
|
||||
@@ -28,7 +28,7 @@ ## 调用
|
||||
- id.json仅`{"release_id":"原UUID"}`。服务器先保存稳定草稿ID/发布UUID,再调用API;相同bundle重复prepare不新建版本或重新抽取参数,相同release_id改正文拒绝409。改稿应显式创建新release并使用当前版本。
|
||||
- review.json的`data.previews`含原模板渲染的HTML,`data.review`含hash和digest。先阅读及检查冻结版本;程序渲染通过不等于人类/浏览器视觉验收。正式HTML内含线上资源链接,禁止直接在本机浏览器打开加载;视觉检查在本地对应稿件完成。必须线上页面验收时仍按项目访问批准规则到Windows,不以取预览为由越界。
|
||||
- publish.json为`{"release_id":"原UUID","expected_hash":"review中hash","review_digest":"review中digest"}`,不得盲填或以另一份稿件替换。程序先查回执;已发表则只重试后处理,草稿版本冲突返回失败。
|
||||
- status会从API重新查询并核对公开正文,不只读本地台账。`phase=complete`要求内容/版本/上传图哈希和缓存/搜索/sitemap状态通过;`published_pending`代表正文已提交但后续仍待处理,退出码2,不能据此另发正文。返回`published_at`来自服务器真实发布事务时间。
|
||||
- status会从API重新查询并核对公开正文,不只读本地台账。`phase=complete`要求内容/版本/上传图哈希和缓存/搜索/sitemap状态通过,且IndexNow通知为done或明确skipped;`published_pending`代表正文已提交但后续仍待处理,退出码2,不能据此另发正文。返回`published_at`来自服务器真实发布事务时间。
|
||||
|
||||
本机工具只输出结果文件路径及状态,不回显SSH认证、正文或预览。SSH断开、超时或非JSON输出都保存未知/失败状态,不自动重放写入;用原release_id查status。不存在草稿时沿原bundle恢复prepare。
|
||||
|
||||
@@ -41,3 +41,5 @@ ## 状态与恢复
|
||||
上线前仅执行`2026_10_31_150000_add_article_display_timestamp.php`迁移(新增可空`sDisplayPublishedAt`);旧文显示回退原时间。新文草稿冻结0~21600秒偏移,首次发布计算展示时间;保留created_at、实际回执、点赞起点,旧文改稿不改展示日期。回滚程序保留新增可空列和历史发布记录,不删业务数据。
|
||||
|
||||
验证与当前部署状态见[2026-10-31发布记录](EDITORIAL_RELEASE_2026-10-31.md)。周期调度和额度唯一见[WEEKLY_TUTORIALS.md](WEEKLY_TUTORIALS.md)。
|
||||
|
||||
IndexNow的结果、环境开关及服务器延时重试见[教程SEO通知](EDITORIAL_INDEXNOW.md)。通知pending只重试后处理,不再次发表正文。
|
||||
@@ -1,6 +1,6 @@
|
||||
# FNA_V3 SEO 优化建议与执行清单
|
||||
|
||||
评估日期:2026-10-22,Asia/Shanghai。状态:**分析与建议文档已完成;SEO-001 的部署定位已由用户确认,配置改造尚未实施;SEO-020 于2026-10-27完成本地教程正文更新,设备实测及生产验收未做,D02首页最新免费节点全文展示于2026-10-27本地完成,其余项目尚未实施**。本文件是后续 SEO 工作的唯一执行清单;按 `SEO-001` 至 `SEO-036` 跟踪,实施后在本文件更新结果,不另建重复的“最新版计划”。
|
||||
评估日期:2026-10-22,Asia/Shanghai。状态:**分析与建议文档已完成;SEO-001 的部署定位已由用户确认,配置改造尚未实施;SEO-020 于2026-10-27完成本地教程正文更新,设备实测及生产验收未做,D02首页最新免费节点全文展示于2026-10-27本地完成,其余项目按分项记录;2026-10-31正在实施编辑文章IndexNow通知与两个教程栏目sitemap(见SEO-013/033)**。本文件是后续 SEO 工作的唯一执行清单;按 `SEO-001` 至 `SEO-036` 跟踪,实施后在本文件更新结果,不另建重复的“最新版计划”。
|
||||
|
||||
本轮依据当前代码、当前本地数据库、重新取得的 HTTP 响应及受限浏览器检查形成结论。网站源码、样式和业务数据未作修改。当前三款 DPL 广告属于已存在的实现,纳入分析基准并保留。网站仍在独立本地副本中开发;用户随后确认未来替换现有 cfn,并支持同一套代码部署多个同类站点,ClashFreeNode 为主力站,尚未实际部署或迁移。
|
||||
|
||||
@@ -352,6 +352,8 @@ ### SEO-013 统一 sitemap 的集合和 lastmod
|
||||
|
||||
**验收:** XML 解析、URL 编码、正式 host、状态、canonical、robots、noindex 做交叉校验;新增/撤稿/到期后集合及时变化;集合差异有可解释原因。Google 忽略 priority 与 changefreq,不应将调大这些数字作为优化工作。[Google sitemap 指南](https://developers.google.com/search/docs/crawling-indexing/sitemaps/build-sitemap)
|
||||
|
||||
**2026-10-31定点实施:** 见[教程SEO通知](EDITORIAL_INDEXNOW.md)。仅编辑API新增/实质更新通知、独立回执/退避重试,以及client/advanced非空栏目进入sitemap;未完成本项所有全站建议,发布/验收以该正文为准。
|
||||
|
||||
### SEO-014 建立长期内链和内容导航
|
||||
|
||||
**优先级:P1。证据:E03。** 当前资源发现主要依赖列表首屏和“点赞活跃”;动态热门榜并不保证重要教程或可索引资源长期获得入口。
|
||||
@@ -539,6 +541,8 @@ ### SEO-033 规范 IndexNow 及搜索提交
|
||||
|
||||
**验收:** 本地使用替身验证,不实际发送;正式获准后单条核验目标主机、验证文件和返回结果;删除事件不因目标已 404 而被本地逻辑永远过滤掉。IndexNow 表示通知采用该协议的搜索引擎,不能当成 Google 通用收录接口。Google Indexing API 仅支持其指定的招聘及直播事件页面,不适用于普通节点文章。[IndexNow 协议](https://www.indexnow.org/documentation)、[Google Indexing API 适用范围](https://developers.google.com/search/apis/indexing-api/v3/using-api)
|
||||
|
||||
**2026-10-31定点实施:** 见[教程SEO通知](EDITORIAL_INDEXNOW.md)。仅编辑API新增/实质更新通知、独立回执/退避重试,以及client/advanced非空栏目进入sitemap;未完成本项所有全站建议,发布/验收以该正文为准。
|
||||
|
||||
### SEO-034 SEO 自动回归与数据样例
|
||||
|
||||
**优先级:P1,随每批实现。** 当前仓库测试只有首页 200 示例和恒真示例,不能防止 URL、索引和发布规则回退。本轮未执行这些与审计目标无关的示例测试,也没有新增业务测试或修改代码。
|
||||
|
||||
Executable → Regular
+7
@@ -7,6 +7,13 @@
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
{{-- Only established tutorial landing pages; omit lastmod until a reliable content clock exists. --}}
|
||||
@foreach($cCategories as $oCategory)
|
||||
<url>
|
||||
<loc>{{ rtrim(config('app.url'), '/') }}/{{ $oCategory->sSlug }}</loc>
|
||||
</url>
|
||||
@endforeach
|
||||
|
||||
{{-- 未过期的文章 --}}
|
||||
@foreach($cArticles as $oArticles)
|
||||
<url>
|
||||
|
||||
Executable → Regular
+2
@@ -19,6 +19,8 @@
|
||||
|
||||
Schedule::command('article:sync-likes')->everyFiveMinutes();
|
||||
|
||||
Schedule::command('editorial:indexnow-retry')->everyFiveMinutes()->environments(['production'])->withoutOverlapping(10);
|
||||
|
||||
|
||||
//Artisan::command('db:reCreate {sTableName?}', function ($sTableName = null) {
|
||||
// // 1. 没传参数?直接亮红牌!
|
||||
|
||||
@@ -389,4 +389,116 @@ public function test_raw_script_markup_is_escaped_and_publish_request_id_cannot_
|
||||
$this->publish($next, $request)->assertConflict();
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
}
|
||||
private function enableEditorialIndexNow(): void
|
||||
{
|
||||
config(['editorial.indexnow_enabled' => true, 'editorial.base_url' => 'https://example.org',
|
||||
'app.url' => 'https://example.org', 'app.site_code' => 'example.org',
|
||||
'key.indexnow' => 'test-key-12345678']);
|
||||
// API authentication in these tests is bound to the same origin.
|
||||
file_put_contents($this->credential, json_encode(['project' => 'fna-v3', 'environment' => 'testing',
|
||||
'base_url' => 'https://example.org', 'schema' => 'gemdocs.credential.v1', 'fields' => ['api_key' => $this->token]]));
|
||||
}
|
||||
|
||||
public function test_editorial_indexnow_notifies_new_and_changed_content_once_but_not_noop(): void
|
||||
{
|
||||
$this->enableEditorialIndexNow();
|
||||
Http::fake(['api.indexnow.org/*' => Http::response('', 200)]);
|
||||
$item = $this->item();
|
||||
$item['category_slug'] = 'advanced';
|
||||
$draft = $this->draft([$item]);
|
||||
$id = (string) Str::uuid();
|
||||
$first = $this->publish($draft, $id)->assertOk()->assertJsonPath('effects.indexnow.status', 'done');
|
||||
$this->assertTrue($first->json('articles.0.content_changed'));
|
||||
$this->publish($draft, $id)->assertOk();
|
||||
$this->postJson('/api/editorial/v1/publications/'.$id.'/synchronize')->assertOk();
|
||||
Http::assertSentCount(1);
|
||||
Http::assertSent(fn ($r) => $r->url() === 'https://api.indexnow.org/indexnow'
|
||||
&& $r['host'] === 'example.org' && $r['urlList'] === ['https://example.org/a/example.html']);
|
||||
$noop = $this->draft([$this->item('example', 1)]);
|
||||
// The category change in this revision is itself meaningful.
|
||||
$this->publish($noop)->assertOk()->assertJsonPath('effects.indexnow.status', 'done');
|
||||
$same = $this->draft([$this->item('example', 2)]);
|
||||
$this->publish($same)->assertOk()->assertJsonPath('effects.indexnow.reason', 'no-content-change');
|
||||
Http::assertSentCount(2);
|
||||
$changed = $this->item('example', 3);
|
||||
$changed['body'] .= '<p>新的说明。</p>';
|
||||
$this->publish($this->draft([$changed]))->assertOk()->assertJsonPath('effects.indexnow.status', 'done');
|
||||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
public function test_editorial_indexnow_failure_retries_with_backoff_without_republishing(): void
|
||||
{
|
||||
$this->enableEditorialIndexNow();
|
||||
Http::fake(['api.indexnow.org/*' => Http::sequence()->push('do not persist response secrets', 429)->push('', 202)]);
|
||||
$draft = $this->draft([$this->item()]);
|
||||
$result = $this->publish($draft)->assertOk()->assertJsonPath('status', 'published')
|
||||
->assertJsonPath('effects.indexnow.status', 'pending')->assertJsonPath('effects.indexnow.http_status', 429);
|
||||
$this->assertStringNotContainsString('do not persist', json_encode($result->json()));
|
||||
$this->artisan('editorial:indexnow-retry')->assertExitCode(0);
|
||||
Http::assertSentCount(1);
|
||||
$this->travel(6)->minutes();
|
||||
$this->artisan('editorial:indexnow-retry')->assertExitCode(0);
|
||||
$this->getJson('/api/editorial/v1/publications/'.$result->json('publication_id'))->assertOk()
|
||||
->assertJsonPath('effects.indexnow.status', 'done')->assertJsonPath('effects.indexnow.http_status', 202)
|
||||
->assertJsonPath('effects.indexnow.attempts', 2);
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
$this->assertSame(1, DB::table('editorial_versions')->count());
|
||||
$this->assertSame(1, DB::table('editorial_publications')->count());
|
||||
$this->artisan('editorial:indexnow-retry')->assertExitCode(0);
|
||||
Http::assertSentCount(2);
|
||||
}
|
||||
|
||||
public function test_editorial_indexnow_does_not_send_disabled_or_mismatched_hosts_or_legacy_receipts(): void
|
||||
{
|
||||
Http::fake();
|
||||
$draft = $this->draft([$this->item()]);
|
||||
$result = $this->publish($draft)->assertOk()->assertJsonPath('effects.indexnow.status', 'skipped');
|
||||
$this->enableEditorialIndexNow();
|
||||
$legacy = $result->json('publication_id');
|
||||
DB::table('editorial_publications')->where('id', $legacy)->update(['effects' => null]);
|
||||
$this->postJson('/api/editorial/v1/publications/'.$legacy.'/synchronize')->assertOk()
|
||||
->assertJsonPath('effects.indexnow.reason', 'legacy-publication');
|
||||
config(['app.site_code' => 'wrong.example']);
|
||||
$new = $this->draft([$this->item('another')]);
|
||||
$this->publish($new)->assertOk()->assertJsonPath('effects.indexnow.reason', 'site-binding-mismatch');
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_editorial_indexnow_retries_skip_withdrawn_or_expired_articles(): void
|
||||
{
|
||||
$this->enableEditorialIndexNow();
|
||||
Http::fake(['api.indexnow.org/*' => Http::response('', 503)]);
|
||||
$result = $this->publish($this->draft([$this->item()]))->assertOk();
|
||||
DB::table('articles')->update(['iStatus' => 0]);
|
||||
$this->travel(6)->minutes();
|
||||
$this->artisan('editorial:indexnow-retry')->assertExitCode(0);
|
||||
$this->getJson('/api/editorial/v1/publications/'.$result->json('publication_id'))->assertOk()
|
||||
->assertJsonPath('effects.indexnow.reason', 'no-current-indexable-url');
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
public function test_sitemap_contains_only_active_nonempty_tutorial_roots_and_indexable_articles(): void
|
||||
{
|
||||
config(['app.url' => 'http://localhost']);
|
||||
$this->publish($this->draft([$this->item()]))->assertOk();
|
||||
DB::table('categories')->where('id', 3)->update(['iParentId' => 2]);
|
||||
DB::table('categories')->insert(['id' => 2, 'sSlug' => 'client', 'sName' => '入门教程', 'iStatus' => 1]);
|
||||
$xml = $this->get('/sitemap.xml')->assertOk()->getContent();
|
||||
$this->assertStringContainsString('<loc>http://localhost/client</loc>', $xml);
|
||||
$this->assertStringNotContainsString('<loc>http://localhost/advanced</loc>', $xml);
|
||||
$advanced = $this->item('advanced-test');
|
||||
$advanced['category_slug'] = 'advanced';
|
||||
$this->publish($this->draft([$advanced]))->assertOk();
|
||||
$xml = $this->get('/sitemap.xml')->assertOk()->getContent();
|
||||
$this->assertSame(1, substr_count($xml, '<loc>http://localhost/advanced</loc>'));
|
||||
$this->assertStringContainsString('/a/advanced-test.html</loc>', $xml);
|
||||
$this->assertStringNotContainsString('<loc>http://localhost/windows</loc>', $xml);
|
||||
DB::table('categories')->where('id', 10)->update(['iStatus' => 0]);
|
||||
DB::table('articles')->where('iCategoryId', 3)->update(['iStatus' => 0]);
|
||||
$xml = $this->get('/sitemap.xml')->assertOk()->getContent();
|
||||
$this->assertStringNotContainsString('/advanced</loc>', $xml);
|
||||
$this->assertStringNotContainsString('/client</loc>', $xml);
|
||||
$this->assertStringNotContainsString('/a/advanced-test.html</loc>', $xml);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -262,4 +262,29 @@ public function test_release_display_time_is_frozen_and_real_publish_time_is_pre
|
||||
$this->assertSame($article->sDisplayPublishedAt, DB::table('articles')->value('sDisplayPublishedAt'));
|
||||
$this->travelBack();
|
||||
}
|
||||
public function test_release_tracks_indexnow_pending_and_recovers_without_a_new_publication(): void
|
||||
{
|
||||
config(['editorial.indexnow_enabled' => true, 'editorial.base_url' => 'https://example.org',
|
||||
'app.url' => 'https://example.org', 'app.site_code' => 'example.org', 'key.indexnow' => 'test-key-12345678']);
|
||||
Http::fake(['api.indexnow.org/*' => Http::sequence()->push('', 503)->push('', 200)]);
|
||||
$runner = app(ReleaseRunner::class);
|
||||
$bundle = $this->bundle();
|
||||
$runner->run($bundle);
|
||||
$review = $runner->run(['operation' => 'review', 'release_id' => $bundle['release_id']]);
|
||||
$publish = ['operation' => 'publish', 'release_id' => $bundle['release_id'],
|
||||
'expected_hash' => $review['review']['hash'], 'review_digest' => $review['review']['digest']];
|
||||
$pending = $runner->run($publish);
|
||||
$this->assertSame('published_pending', $pending['phase']);
|
||||
$this->assertSame('pending', $pending['receipt']['effects']['indexnow']['status']);
|
||||
Http::assertSentCount(1);
|
||||
$this->travel(6)->minutes();
|
||||
$this->artisan('editorial:indexnow-retry')->assertExitCode(0);
|
||||
$done = $runner->run(['operation' => 'status', 'release_id' => $bundle['release_id']]);
|
||||
$this->assertSame('complete', $done['phase']);
|
||||
$this->assertSame('done', $done['receipt']['effects']['indexnow']['status']);
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
$this->assertSame(1, DB::table('editorial_publications')->count());
|
||||
Http::assertSentCount(2);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user