Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77f9b09c58 | ||
|
|
b0d61806dc | ||
|
|
252e0c38cb | ||
|
|
ace6d74a18 | ||
|
|
5748124383 |
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 @@
|
||||
# 编辑文章 IndexNow
|
||||
|
||||
用户2026-10-31要求接入教程发布后的自动推送。新增或实际内容改变的编辑文章在发布事务写入IndexNow待处理状态,缓存刷新完成后提交当前有效URL。目标为IndexNow官方API,复用本站既有key及根目录验证文件,不生成/轮换密钥,不改旧资源接收器。
|
||||
|
||||
- `config/editorial.php` 的 `indexnow_enabled`:默认仅production开启,可用`EDITORIAL_INDEXNOW_ENABLED=false`关闭。local不会发出通知,测试使用Http fake。
|
||||
- `PublicationEffects`保存`effects.indexnow`,包括状态、次数、HTTP状态和下一次重试时间;不保存key、响应正文或异常消息。只有200/202记done;202表示收到并待验证key。提交被接收不等于搜索引擎已经抓取或收录,见[官方协议](https://www.indexnow.org/documentation)。
|
||||
- `editorial:indexnow-retry`挂接原Laravel调度,每5分钟检查一次,单次最多10个到期回执,防重叠;退避从5分钟递增,最大24小时。定时任务运行在FNA业务服务器,以原nginx身份执行,白色机仅SSH跳板。
|
||||
- 已done的通知不重复调用;同一发布UUID重放不重发文章。网络结果未知或提交后进程崩溃可能重复通知同一URL,按至少一次投递处理,不能承诺第三方只收到一次。每次重试都重新确认文章仍公开、栏目启用且可索引。
|
||||
- 内容未变、已撤下、不再允许索引时跳过;旧版本中没有IndexNow状态的历史发布回执不自动补推。暂时禁用不会丢弃已pending状态。
|
||||
- 仅推送同一站点的规范文章地址;app.url、editorial.base_url、app.site_code必须一致,不跟随重定向,不从文章输入指定外部推送目标。
|
||||
|
||||
## 2026-10-31已部署与验证
|
||||
|
||||
功能提交`574812438338755b160453c4a574557365903506`已Git推送并部署正式cfn,独立分支`codex/editorial-indexnow-publish-20261031`,基线`d981a2aa4fa21abe4512ddd287a2f51f87b11197`。同名旧候选分支另有包含sitemap改动的并行提交415b5f8,保留未覆盖;本任务只部署IndexNow范围,没有捆绑其他SEO工作。
|
||||
|
||||
专项4项测试/52断言通过:新增/更新通知、同UUID去重、无变化跳过、429退避后202成功、旧回执不补推、禁用环境/域名错配拒发、撤下后停止重试。本地相关业务回归合计36项/344断言通过;其中共享工作区的sitemap测试未作为本次部署范围。
|
||||
|
||||
正式站现有188篇文章的核心内容与日期、所有旧编辑发布回执保持;生成标签模板哈希和data.ms并行目录保留。新重试命令以nginx实际运行,空队列返回processed=0/pending=0,已登记每5分钟调度;未为演练制造失败队列,也未宣称已观察到一笔真实失败的自动恢复。公网编辑API仍关闭,首页HTTP200。
|
||||
|
||||
2026-10-31 14:20:55北京时间,通过本机SSH→白色机→业务服务器,由新组件对现有`/a/system-proxy-vs-tun.html`执行一次真实通知验收,HTTP200,密钥文件HTTP200且内容匹配;未改正文、未重新发布、未改旧回执、未批量补推。只证明通知被接收,不代表已收录。已完成服务器侧验收,未做线上页面验收。精确证据见[回执](EDITORIAL_INDEXNOW_2026-10-31.json)。
|
||||
|
||||
私有恢复点:VPS-003 `/root/backups/cfn-indexnow-20261031/`,包含Git bundle、原HEAD/工作区状态、标签模板、文章核心字段与旧回执快照、真实提交事件和部署记录。回滚可检出基线,保留已有effects状态和内容;单独停推可设`EDITORIAL_INDEXNOW_ENABLED=false`,不要删除pending回执。普通发布继续通过[白色机发布封装](EDITORIAL_RELEASE.md)。
|
||||
|
||||
|
||||
## 两个教程栏目sitemap已部署(2026-10-31)
|
||||
|
||||
基于并行IndexNow正式文档提交`ace6d74a18988697340ebcd15e2b79a4dee0e697`,只发布本批7个栏目/测试/文档文件,功能提交`252e0c38cb85d0c1331063b1019a2bb13c27ac8a`已推送`codex/tutorial-sitemap-20261031`并检出正式cfn。保留57481243的通知实现,不重复部署旧候选415b5f8,也不覆盖其并行验收记录。
|
||||
|
||||
本地34项/310断言通过。正式sitemap从25项变27项,精确增加`/client`与`/advanced`,旧集合无移除;首页、两栏目和system-proxy-vs-tun详情HTTP200,两栏目index/follow及自引用canonical通过。188篇正文核心、既有发布回执、生成标签模板哈希及data.ms并行目录保持。重试命令以nginx执行返回processed=0/pending=0,原项目调度存在,密钥文件HTTP200且内容匹配。
|
||||
|
||||
切换时曾因2秒PHP OPcache检查窗口出现新模板与旧控制器混用,验收脚本立即回滚。最终通过Unix FastCGI socket仅失效本批文件缓存,临时私有脚本用后删除;未重启共享PHP-FPM、未改其配置。原两次候选回滚后,接续并行IndexNow新基线完成本次限定发布。
|
||||
|
||||
本批未再次发送真实通知、不补交历史文章;上一节的真实HTTP200验收继续有效。已完成服务器侧验收,未做线上页面验收。脱敏验收见[栏目回执](TUTORIAL_SITEMAP_2026-10-31.json)。恢复点:VPS-003 `/root/backups/cfn-tutorial-sitemap-20261031/`,包含原HEAD/status、Git bundle、模板、前后运行摘要和opcode失效回执。仅回滚本批时检回ace6d74a并定点失效PHP缓存,保留新通知实现、内容及回执。
|
||||
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"base": "d981a2aa4fa21abe4512ddd287a2f51f87b11197",
|
||||
"commit": "574812438338755b160453c4a574557365903506",
|
||||
"branch": "codex/editorial-indexnow-publish-20261031",
|
||||
"files": [
|
||||
"app/Console/Commands/RetryEditorialIndexNow.php",
|
||||
"app/Services/Editorial/IndexNowNotification.php",
|
||||
"app/Services/Editorial/PublicationEffects.php",
|
||||
"app/Services/Editorial/Publisher.php",
|
||||
"app/Services/Editorial/ReleaseRunner.php",
|
||||
"config/editorial.php",
|
||||
"docs/maintenance/EDITORIAL_API.md",
|
||||
"docs/maintenance/EDITORIAL_INDEXNOW.md",
|
||||
"docs/maintenance/EDITORIAL_RELEASE.md",
|
||||
"routes/console.php",
|
||||
"tests/Feature/EditorialApiTest.php"
|
||||
],
|
||||
"checks": {
|
||||
"enabled": true,
|
||||
"public_api_enabled": false,
|
||||
"key_valid": true,
|
||||
"retry_scheduled": true,
|
||||
"retry_command": {
|
||||
"processed": 0,
|
||||
"pending": 0
|
||||
},
|
||||
"existing_articles_and_receipts_unchanged": true,
|
||||
"tags_preserved": true,
|
||||
"homepage_http": 200
|
||||
},
|
||||
"backup_directory": "/root/backups/cfn-indexnow-20261031",
|
||||
"status": "M resources/views/components/generated-tags-cloud.blade.php\n?? data.ms/",
|
||||
"live_verification": {
|
||||
"ok": true,
|
||||
"key_file_http_matches": true,
|
||||
"notification": {
|
||||
"status": "done",
|
||||
"attempts": 1,
|
||||
"http_status": 200,
|
||||
"urls": [
|
||||
"https://clashfreenode.com/a/system-proxy-vs-tun.html"
|
||||
],
|
||||
"submitted_at": "2026-10-31T06:20:55+00:00",
|
||||
"result": "received"
|
||||
},
|
||||
"verification_only": true,
|
||||
"article_modified": false
|
||||
},
|
||||
"tests": {
|
||||
"indexnow_tests": 4,
|
||||
"indexnow_assertions": 52,
|
||||
"local_regression_tests": 36,
|
||||
"local_regression_assertions": 344
|
||||
},
|
||||
"parallel_branch_preserved": "codex/editorial-indexnow-20261031 (415b5f8ab57432ff238b6d83b83d1bee75c95c7b); sitemap changes not deployed in this task"
|
||||
}
|
||||
@@ -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状态通过(无需通知的IndexNow skipped视为完成),且IndexNow通知为done或明确skipped;`published_pending`代表正文已提交但后续仍待处理,退出码2,不能据此另发正文。返回`published_at`来自服务器真实发布事务时间。
|
||||
|
||||
本机工具只输出结果文件路径及状态,不回显SSH认证、正文或预览。SSH断开、超时或非JSON输出都保存未知/失败状态,不自动重放写入;用原release_id查status。不存在草稿时沿原bundle恢复prepare。
|
||||
|
||||
@@ -41,3 +41,7 @@ ## 状态与恢复
|
||||
上线前仅执行`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只重试后处理,不再次发表正文。
|
||||
|
||||
2026-10-31编辑发布已接入[IndexNow通知与重试](EDITORIAL_INDEXNOW.md),复用发布回执effects;通知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 为主力站,尚未实际部署或迁移。
|
||||
|
||||
@@ -182,7 +182,7 @@ ## 5 执行总表
|
||||
| [ ] | SEO-010 | 分类、标签、搜索的标题与语义层级 | P1 | 001、004 | 已确认 |
|
||||
| [ ] | SEO-011 | 生成真实、干净的页面简介 | P1 | 010 | 已确认 |
|
||||
| [ ] | SEO-012 | 分离真实内容日期并统一时间基准 | P1 | 003 | 已确认/条件性风险 |
|
||||
| [ ] | SEO-013 | 统一 sitemap 的集合和 lastmod | P1 | 003、004、008、012 | 已确认 |
|
||||
| [ ] | SEO-013 | 统一 sitemap 的集合和 lastmod | P1 | 003、004、008、012 | 部分实施:教程栏目,见正文 |
|
||||
| [ ] | SEO-014 | 建立长期内链和内容导航 | P1 | 005、009、018 | 已确认/策略建议 |
|
||||
| [ ] | SEO-015 | 整理标签与重复主题页 | P1 | 002、003 | 策略建议 |
|
||||
| [ ] | SEO-016 | 隔离并同步本站搜索索引 | P1 | 008、032 | 已确认 |
|
||||
@@ -202,7 +202,7 @@ ## 5 执行总表
|
||||
| [ ] | SEO-030 | 文章接收、更新与删除的发布合同 | P0 发布前 | 003、008、017、029 | 已确认/条件性风险 |
|
||||
| [ ] | SEO-031 | 正式主机、HTTPS 与 HTTP 服务质量 | P0 发布前 | 001、004 | 待部署验证 |
|
||||
| [ ] | SEO-032 | 本地、预发布和生产资源隔离 | P0 发布前 | 001 | 已确认/条件性风险 |
|
||||
| [ ] | SEO-033 | 规范 IndexNow 及搜索提交 | P2 | 003、004、030、032 | 已确认/待部署验证 |
|
||||
| [ ] | SEO-033 | 规范 IndexNow 及搜索提交 | P2 | 003、004、030、032 | 部分实施:编辑发布通知,见正文 |
|
||||
| [ ] | SEO-034 | SEO 自动回归与数据样例 | P1 | 跟随各批次 | 当前测试缺口 |
|
||||
| [ ] | SEO-035 | 搜索平台与业务效果监测 | P1 上线后 | 001、002、036 | 待线上数据 |
|
||||
| [ ] | SEO-036 | 发布、迁移、回滚与复核 | P0 发布时 | 前述必需项 | 待发布授权 |
|
||||
@@ -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、索引和发布规则回退。本轮未执行这些与审计目标无关的示例测试,也没有新增业务测试或修改代码。
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"base": "ace6d74a18988697340ebcd15e2b79a4dee0e697",
|
||||
"commit": "252e0c38cb85d0c1331063b1019a2bb13c27ac8a",
|
||||
"files": [
|
||||
"AGENTS.md",
|
||||
"app/Http/Controllers/SitemapController.php",
|
||||
"docs/maintenance/EDITORIAL_INDEXNOW.md",
|
||||
"docs/maintenance/SEO_PLAN.md",
|
||||
"resources/views/sitemap.blade.php",
|
||||
"tests/Feature/EditorialApiTest.php",
|
||||
"tests/Feature/EditorialReleaseTest.php"
|
||||
],
|
||||
"branch": "codex/tutorial-sitemap-20261031",
|
||||
"backup_directory": "/root/backups/cfn-tutorial-sitemap-20261031",
|
||||
"pushed": true,
|
||||
"before_count": 25,
|
||||
"after_count": 27,
|
||||
"added": [
|
||||
"https://clashfreenode.com/advanced",
|
||||
"https://clashfreenode.com/client"
|
||||
],
|
||||
"checks": {
|
||||
"article_core_preserved": true,
|
||||
"publications_unchanged": true,
|
||||
"indexnow_enabled": true,
|
||||
"keyfile": {
|
||||
"http_status": 200,
|
||||
"body_matches_key": true
|
||||
},
|
||||
"retry_command": {
|
||||
"processed": 0,
|
||||
"pending": 0
|
||||
},
|
||||
"existing_business_scheduler": true,
|
||||
"opcode_invalidation": true,
|
||||
"generated_template_preserved": true,
|
||||
"pages": {
|
||||
"/": 200,
|
||||
"/client": 200,
|
||||
"/advanced": 200,
|
||||
"/a/system-proxy-vs-tun.html": 200
|
||||
}
|
||||
},
|
||||
"live_indexnow_notification_sent": false,
|
||||
"head": "252e0c38cb85d0c1331063b1019a2bb13c27ac8a",
|
||||
"status": "M resources/views/components/generated-tags-cloud.blade.php\n?? data.ms/"
|
||||
}
|
||||
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>
|
||||
|
||||
@@ -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