Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
437bea7d17 |
No files matched your search
@@ -63,6 +63,3 @@ AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
# Approved illustration delivery (independent per environment)
|
||||
ILLUSTRATION_DELIVERY_ENABLED=false
|
||||
@@ -7,16 +7,3 @@ ## FNA 静态配图副本
|
||||
## AI 文章写作(必读)
|
||||
|
||||
文章写作和发布先读docs/content/WRITING.md及docs/maintenance/EDITORIAL_API.md。项目身份和访问边界先读GemDocs AI版项目总览、维护协议及10-项目/fna_v3.md。
|
||||
|
||||
插画完成后按[自动交付](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`不代表搜索引擎已收到通知或已收录。
|
||||
|
||||
## SEO统一合同(2026-10-31)
|
||||
|
||||
首页、归档、教程、分页、索引、sitemap、内容更新时间和IndexNow统一按[SEO实施维护](docs/maintenance/SEO_IMPLEMENTATION_2026-10-31.md)。禁止恢复全query robots屏蔽、分页canonical第一页、按180天批量删正文、用点赞updated_at作为lastmod,或让源图删除影响本站独立副本。当前状态和未取得的搜索平台证据见该文档;实施不等于收录/排名已验证。
|
||||
|
||||
|
||||
2026-10-31用户纠正:SEO只做内部优化,用户看到的布局、样式、可见标题/说明、图片呈现、导航和广告位置必须保持原界面;不因SEO增加说明块、分页条或改版。后续可见改动须用户另行明确要求。恢复基线与验证见[界面保留修复](docs/maintenance/SEO_UI_RESTORE_2026-10-31.md)。
|
||||
Regular → Executable
+13
-2
@@ -25,9 +25,20 @@ public function handle(): void
|
||||
|
||||
private function article()
|
||||
{
|
||||
$this->info('正文按内容保留策略维护,不再按180天自动删除。');
|
||||
}
|
||||
$aCateId = Categories::whereIn("sSlug", ["freenode", "shadowrocketids"])->pluck("id")->toArray();
|
||||
|
||||
if (empty($aCateId)) {
|
||||
$this->info("没有匹配的分类,跳过清理");
|
||||
return;
|
||||
}
|
||||
|
||||
$sDate = date('Y-m-d', strtotime('-180 days'));
|
||||
|
||||
$i = Articles::whereIn("iCategoryId", $aCateId)->whereDate("created_at", "<", $sDate)->delete();
|
||||
|
||||
$this->info("清理 {$i} 条数据");
|
||||
}
|
||||
|
||||
private function articleLikes()
|
||||
{
|
||||
// 1. 确定 30 天前的时间点
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\Editorial\ReleaseRunner;
|
||||
use Illuminate\Console\Command;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
final class EditorialRelease extends Command
|
||||
{
|
||||
protected $signature = 'editorial:release';
|
||||
|
||||
protected $description = 'Run a resumable editorial API operation from JSON on stdin, on this application server';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
try {
|
||||
abort_unless(PHP_SAPI === 'cli', 403);
|
||||
if (! app()->environment('testing')) {
|
||||
abort_unless(app()->environment('production')
|
||||
&& realpath(base_path()) === '/www/wwwroot/clashfreenode-new.com'
|
||||
&& rtrim(config('editorial.base_url'), '/') === 'https://clashfreenode.com'
|
||||
&& function_exists('posix_geteuid') && posix_getpwuid(posix_geteuid())['name'] === 'nginx', 403, 'Server binding mismatch');
|
||||
}
|
||||
$raw = stream_get_contents(STDIN, 48 * 1024 * 1024 + 1);
|
||||
abort_unless(strlen($raw) <= 48 * 1024 * 1024, 413);
|
||||
$input = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
|
||||
abort_unless(is_array($input), 422);
|
||||
$result = app(ReleaseRunner::class)->run($input);
|
||||
$this->line(json_encode(['ok' => true, 'data' => $result], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR));
|
||||
|
||||
return ($result['phase'] ?? '') === 'published_pending' ? 2 : 0;
|
||||
} catch (\Throwable $e) {
|
||||
$status = $e instanceof HttpExceptionInterface ? $e->getStatusCode() : 500;
|
||||
$this->line(json_encode(['ok' => false, 'status' => $status, 'error' => 'Release operation failed; use the same release_id to inspect or resume. No credential details are exposed.']));
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace App\Console\Commands;
|
||||
use Illuminate\Console\Command;
|
||||
class RetrySeoNotifications extends Command
|
||||
{
|
||||
protected $signature = 'seo:indexnow-retry';
|
||||
protected $description = 'Retry durable resource, collection and deletion notifications';
|
||||
public function handle(): int
|
||||
{
|
||||
$this->line(json_encode(['processed'=>app(\App\Services\SeoNotifications::class)->retry()]));
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Services\IllustrationPool;
|
||||
use App\Services\LocalIllustrations;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
final class SyncIllustrationDeliveries extends Command
|
||||
{
|
||||
protected $signature = 'illustrations:sync-deliveries';
|
||||
|
||||
protected $description = 'Synchronize pending illustration deliveries and acknowledge verified static copies';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (! config('illustrations.delivery_enabled') || ! IllustrationPool::enabled() || ! LocalIllustrations::enabled()) {
|
||||
$this->error('Illustration delivery is disabled');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
$dir = dirname(config('illustrations.local_manifest'));
|
||||
if (! is_dir($dir)) {
|
||||
mkdir($dir, 0700, true);
|
||||
}
|
||||
$lock = fopen($dir.'/delivery.lock', 'c');
|
||||
if (! $lock) {
|
||||
return self::FAILURE;
|
||||
}
|
||||
if (! flock($lock, LOCK_EX | LOCK_NB)) {
|
||||
fclose($lock);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
try {
|
||||
$pending = array_slice(IllustrationPool::pendingDeliveries(), 0, 3); // Bound metadata calls below the consumer rate limit.
|
||||
if (! $pending) {
|
||||
$this->line('No pending illustration deliveries');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
$snapshots = [];
|
||||
$images = [];
|
||||
foreach ($pending as $batch) {
|
||||
foreach ($batch['assets'] ?? [] as $asset) {
|
||||
$pool = $asset['pool'] ?? '';
|
||||
if (! in_array($pool, config('illustrations.categories'), true)) {
|
||||
throw new \RuntimeException('invalid_pool');
|
||||
}
|
||||
if (! isset($snapshots[$pool])) {
|
||||
$snapshots[$pool] = IllustrationPool::sourceSnapshot($pool);
|
||||
}
|
||||
$match = null;
|
||||
foreach ($snapshots[$pool]['items'] as $image) {
|
||||
if (($image['asset_id'] ?? '') === ($asset['asset_id'] ?? null)) {
|
||||
$match = $image;
|
||||
}
|
||||
}
|
||||
if (! $match) {
|
||||
throw new \RuntimeException('delivery_asset_unavailable');
|
||||
}
|
||||
$images[$asset['asset_id']] = $match;
|
||||
}
|
||||
}
|
||||
app(LocalIllustrations::class)->cacheDeliveryAssets(array_values($images));
|
||||
$bytes = file_get_contents(config('illustrations.local_manifest'));
|
||||
$manifest = json_decode($bytes, true, 512, JSON_THROW_ON_ERROR);
|
||||
foreach ($pending as $batch) {
|
||||
if (($batch['state'] ?? '') !== 'awaiting_sync' || empty($batch['assets'])) {
|
||||
throw new \RuntimeException('invalid_delivery');
|
||||
}
|
||||
foreach ($batch['assets'] as $asset) {
|
||||
$local = $manifest['assets'][$asset['asset_id']] ?? null;
|
||||
$sha = $asset['sha256'] ?? '';
|
||||
if (! preg_match('/\A[a-f0-9]{64}\z/D', $sha) || ! $local || ($local['sha256'] ?? '') !== $sha || ($local['mime'] ?? '') !== 'image/webp') {
|
||||
throw new \RuntimeException('missing_copy');
|
||||
}
|
||||
$path = rtrim(config('illustrations.local_directory'), '/').'/'.$sha.'.webp';
|
||||
if (! is_file($path) || is_link($path) || hash_file('sha256', $path) !== $sha) {
|
||||
throw new \RuntimeException('invalid_copy');
|
||||
}
|
||||
}
|
||||
$ack = IllustrationPool::acknowledgeDelivery($batch['id'], ['fingerprint' => $batch['fingerprint'], 'manifest_sha256' => hash('sha256', $bytes)]);
|
||||
if (($ack['state'] ?? '') !== 'completed') {
|
||||
throw new \RuntimeException('ack_failed');
|
||||
}
|
||||
$this->line('Completed illustration delivery '.$batch['id']);
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
} catch (\Throwable) {
|
||||
$this->error('Illustration delivery sync incomplete; will retry without a completion ACK.');
|
||||
|
||||
return self::FAILURE;
|
||||
} finally {
|
||||
flock($lock, LOCK_UN);
|
||||
fclose($lock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ public function source(int $article)
|
||||
return response()->json(['article_id' => $a->id, 'title' => $a->sTitle, 'summary' => $a->sTitleSub,
|
||||
'slug' => $a->sSlug, 'body_html' => $a->sContent, 'category_slug' => $category->sSlug,
|
||||
'tag_ids' => DB::table('article_tag')->where('iArticleId', $a->id)->pluck('iTagId'),
|
||||
'created_at' => $a->created_at, 'display_published_at' => $a->sDisplayPublishedAt,
|
||||
'cover' => $a->sThumb, 'show_cover' => (bool) $a->bPageThumb,
|
||||
'like_growth' => ['seven_day_remaining' => (int) $a->i7like, 'yearly' => (int) $a->i365like,
|
||||
'one_year_target' => (int) $a->iYearLikeTarget, 'one_year_added' => (int) $a->iYearLikeAdded,
|
||||
@@ -141,7 +140,7 @@ public function preview(string $draft, string $key, Publisher $p)
|
||||
}
|
||||
$a = new Articles;
|
||||
$a->forceFill(['id' => 0, 'sTitle' => $item['title'], 'sTitleSub' => $item['summary'], 'sSlug' => $item['slug'], 'sContent' => $html,
|
||||
'created_at' => now(), 'sDisplayPublishedAt' => now()->subSeconds($item['display_offset_seconds'] ?? 0), 'iLikeCount' => 0, 'bPageThumb' => $item['show_cover'] ?? false, 'sThumb' => $cover]);
|
||||
'created_at' => now(), 'iLikeCount' => 0, 'bPageThumb' => $item['show_cover'] ?? false, 'sThumb' => $cover]);
|
||||
$category = Categories::where('sSlug', $item['category_slug'])->with('oParent')->firstOrFail();
|
||||
$a->setRelation('oCategory', $category);
|
||||
$a->setRelation('oTags', collect());
|
||||
|
||||
Regular → Executable
+7
-9
@@ -66,9 +66,6 @@ public function receive(Request $oRequest)
|
||||
|
||||
$oArticle = Articles::where("sSlug", $sSlug)->first();
|
||||
|
||||
if ($oArticle && \Illuminate\Support\Facades\DB::table('editorial_documents')->where('article_id',$oArticle->id)->exists()) {
|
||||
abort(409, 'This article is managed by the editorial API');
|
||||
}
|
||||
if (!$oArticle) {
|
||||
$oArticle = new Articles();
|
||||
$oArticle->sSlug = $sSlug;
|
||||
@@ -170,7 +167,8 @@ public function receiveShadowrocketids(Request $oRequest)
|
||||
|
||||
$sArticleUrl = config("app.url")."/a/".$sSlug;
|
||||
|
||||
$bIndexR = '待服务器队列处理';
|
||||
$oIndexNow = new IndexNowService();
|
||||
$bIndexR = $oIndexNow->pushUrls([$sArticleUrl.".html"]);
|
||||
|
||||
TeleSlave::notify()->send($sArticleUrl." 发布成功 | "."indexNow推送:".$bIndexR);
|
||||
|
||||
@@ -184,7 +182,6 @@ public function receiveFreenode(Request $oRequest)
|
||||
|
||||
$aData = $oRequest->all();
|
||||
$aArticle = $aData["article"];
|
||||
$resourceState = \App\Services\ResourcePublication::validate($aArticle);
|
||||
$sArticleTitle = $aArticle["title"];
|
||||
$sArticleTitleSub = $aArticle["title_sub"];
|
||||
$sArticleContent = $aArticle["content"];
|
||||
@@ -192,7 +189,7 @@ public function receiveFreenode(Request $oRequest)
|
||||
$sSlug = 'fn'.date("Ymd");
|
||||
// $sImgAuthor = "tg_xiuren_a";
|
||||
$sSubKey = $_ENV['site_code_short'].'::fn';
|
||||
$i7like = $aArticle["7like"] ?? 0;
|
||||
$i7like = $aArticle["7like"];
|
||||
|
||||
$oThumbNum = ArticleFreenodeThumbNum::firstOrCreate(["author_code" => $sSubKey]);
|
||||
$iThumbNum = $oThumbNum->num;
|
||||
@@ -240,7 +237,7 @@ public function receiveFreenode(Request $oRequest)
|
||||
|
||||
$oArticle = Articles::updateOrCreate(
|
||||
['sSlug' => $sSlug],
|
||||
$aAttributes + $resourceState
|
||||
$aAttributes
|
||||
);
|
||||
|
||||
(new TagService())->syncArticleTagsByName($oArticle, $aArticleTags);
|
||||
@@ -249,7 +246,8 @@ public function receiveFreenode(Request $oRequest)
|
||||
|
||||
$sArticleUrl = config("app.url")."/a/".$sSlug;
|
||||
|
||||
$bIndexR = '待服务器队列处理';
|
||||
$oIndexNow = new IndexNowService();
|
||||
$bIndexR = $oIndexNow->pushUrls([$sArticleUrl.".html"]);
|
||||
|
||||
TeleSlave::notify()->send($sArticleUrl.".html"." 发布成功 | "."indexNow推送:".$bIndexR); // indexR是true或false,发送到tg什么都没有?
|
||||
|
||||
@@ -269,7 +267,7 @@ public function receiveFreenode_laji(Request $oRequest)
|
||||
$aArticleTags = $aArticle["tags"];
|
||||
$sSlug = 'fn'.date("Ymd");
|
||||
$sImgAuthor = "tg_xiuren_a";
|
||||
$i7like = $aArticle["7like"] ?? 0;
|
||||
$i7like = $aArticle["7like"];
|
||||
|
||||
$oThumbNum = ArticleFreenodeThumbNum::firstOrCreate(["author_code" => $sImgAuthor]);
|
||||
$iThumbNum = $oThumbNum->num;
|
||||
|
||||
@@ -12,10 +12,10 @@ public function index(): Response
|
||||
$sContent .= "Allow: /\n";
|
||||
$sContent .= "Disallow: /admin/\n";
|
||||
$sContent .= "Disallow: /api/\n";
|
||||
$sContent .= "\n";
|
||||
$sContent .= "Disallow: /storage/\n";
|
||||
$sContent .= "Disallow: /vendor/\n";
|
||||
$sContent .= "Disallow: /test/\n";
|
||||
$sContent .= "Disallow: /like/\n\n";
|
||||
$sContent .= "Disallow: /*?*\n\n";
|
||||
$sContent .= "Sitemap: " . config('app.url') . "/sitemap.xml\n";
|
||||
|
||||
// 核心修复:强制指定 text/plain 响应头
|
||||
|
||||
@@ -1,24 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Models\Categories;
|
||||
use App\Services\Seo;
|
||||
use App\Services\ArticlesService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class SitemapController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
$articles = Articles::publicVisible()->with('oCategory.oParent')->orderByDesc('created_at')->orderByDesc('id')->get();
|
||||
$latest = app(ArticlesService::class)->getLatestFreeNodeSlug();
|
||||
$home = $latest ? $articles->firstWhere('sSlug',$latest) : null;
|
||||
$entries = $home ? [['url'=>Seo::url(),'modified'=>Seo::modified($home)]] : [];
|
||||
foreach (Categories::where('iStatus',1)->with('oParent')->orderBy('id')->get() as $category) {
|
||||
if ($category->iParentId && (!$category->oParent || !$category->oParent->iStatus)) continue;
|
||||
$members = $articles->filter(fn($a)=>$a->iCategoryId === $category->id || ($category->iShowChildren && $a->oCategory->iParentId === $category->id));
|
||||
if ($members->isNotEmpty()) $entries[] = ['url'=>Seo::url(Seo::categoryPath($category)),'modified'=>null];
|
||||
}
|
||||
foreach ($articles->filter(fn($a)=>Seo::indexable($a)) as $a) $entries[] = ['url'=>Seo::articleUrl($a),'modified'=>Seo::modified($a)];
|
||||
return response()->view('sitemap',['entries'=>$entries])->header('Content-Type','application/xml; charset=UTF-8');
|
||||
// 连表查询分类:按 aOpt['noindexday'] 动态过滤过期文章
|
||||
$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");
|
||||
});
|
||||
})
|
||||
->orderBy('created_at', 'desc')
|
||||
->get();
|
||||
|
||||
$sXmlContent = view('sitemap', [
|
||||
'cArticles' => $cArticles
|
||||
])->render();
|
||||
|
||||
return response($sXmlContent, 200)->header('Content-Type', 'text/xml');
|
||||
}
|
||||
}
|
||||
Regular → Executable
+33
-46
@@ -19,12 +19,10 @@ public function __construct(ArticlesService $oService)
|
||||
|
||||
public function search(Request $oRequest, string $sKeyword)
|
||||
{
|
||||
$page = \App\Services\Seo::page($oRequest);
|
||||
$data = $this->oArticlesService->search($sKeyword, 'view');
|
||||
$data['seo'] = \App\Services\Seo::listMeta('搜索:'.$data['sKeywords'], '本站文章搜索结果', '/search/'.rawurlencode($data['sKeywords']), $page, false);
|
||||
return $this->listing($oRequest, $data);
|
||||
$xData = $this->oArticlesService->search($sKeyword, 'view');
|
||||
return view('pages.articles.default.index', $xData);
|
||||
}
|
||||
|
||||
|
||||
public function like(int $iArticleId, Request $oRequest)
|
||||
{
|
||||
// 1. 获取/生成指纹
|
||||
@@ -45,55 +43,44 @@ public function like(int $iArticleId, Request $oRequest)
|
||||
|
||||
public function listByTag(Request $oRequest, string $sSlug)
|
||||
{
|
||||
$page = \App\Services\Seo::page($oRequest);
|
||||
$data = $this->oArticlesService->getTagArticles($sSlug, 'view');
|
||||
$data['seo'] = \App\Services\Seo::listMeta($data['oTag']->sName.'相关文章', '按标签浏览本站内容', '/tag/'.$sSlug, $page, false);
|
||||
return $this->listing($oRequest, $data);
|
||||
$xData = $this->oArticlesService->getTagArticles($sSlug, 'view');
|
||||
return view('pages.articles.default.index', $xData);
|
||||
}
|
||||
|
||||
public function home(Request $oRequest)
|
||||
{
|
||||
if ($oRequest->filled('s')) {
|
||||
abort_unless(is_string($oRequest->query('s')),404);
|
||||
return redirect(\App\Services\Seo::url('/search/'.rawurlencode(trim($oRequest->query('s')))),301);
|
||||
$sSlug = $this->oArticlesService->getLatestFreeNodeSlug();
|
||||
|
||||
if ($sSlug === null) {
|
||||
return view('pages.articles.default.index', ['oArticles' => collect()]);
|
||||
}
|
||||
$page = \App\Services\Seo::page($oRequest);
|
||||
if ($oRequest->has('page')) return redirect(\App\Services\Seo::url($page>1?'/freenode':'/', $page),301);
|
||||
$slug = $this->oArticlesService->getLatestFreeNodeSlug();
|
||||
if (!$slug) return response()->view('pages.articles.default.unavailable', [], 503)->header('Retry-After','3600');
|
||||
$data = $this->articleData($slug, $oRequest);
|
||||
$data['bIsHome'] = true;
|
||||
$data['seo'] = \App\Services\Seo::articleMeta($data['oArticle'], true);
|
||||
return view('pages.articles.default.show', $data);
|
||||
|
||||
return $this->show($sSlug, $oRequest);
|
||||
}
|
||||
public function list(Request $oRequest, string $sSlug1, ?string $sSlug2 = null)
|
||||
|
||||
public function list(Request $oRequest, string $sSlug1, string $sSlug2 = null)
|
||||
{
|
||||
$page = \App\Services\Seo::page($oRequest);
|
||||
$data = $this->oArticlesService->getCategoryArticles($sSlug2 ?? $sSlug1, 'view');
|
||||
$category = $data['oCategory'];
|
||||
$path = \App\Services\Seo::categoryPath($category);
|
||||
if ($sSlug2) abort_unless($path === '/'.$sSlug1.'/'.$sSlug2, 404);
|
||||
$heading = $category->sSlug === 'freenode' ? '免费节点更新记录' : \App\Services\Seo::categoryName($category);
|
||||
$desc = $category->sSlug === 'freenode' ? '按发布时间查看免费节点历史记录;获取当前订阅请访问首页。' : ($category->sDescription ?: $heading.'相关文章与使用说明');
|
||||
$data['seo'] = \App\Services\Seo::listMeta($heading, $desc, $path, $page, $data['oArticles']->total()>0);
|
||||
if ('/'.$sSlug1 !== $path && !$sSlug2) return redirect(\App\Services\Seo::url($path,$page),301);
|
||||
return $this->listing($oRequest, $data);
|
||||
}
|
||||
private function listing(Request $request, array $data)
|
||||
{
|
||||
$page = \App\Services\Seo::page($request);
|
||||
abort_if($page > $data['oArticles']->lastPage(),404);
|
||||
if ($request->has('page') && $page === 1) return redirect($data['seo']['canonical'],301);
|
||||
$data['oArticles']->withPath(strtok($data['seo']['canonical'],'?'));
|
||||
return view('pages.articles.default.index', $data);
|
||||
}
|
||||
private function articleData(string $slug, Request $request): array
|
||||
{
|
||||
return $this->oArticlesService->getArticle($slug, $request->ip(), $request->cookie('visitor_token') ?? md5($request->ip().$request->userAgent()));
|
||||
$sSlug = $sSlug2 ?? $sSlug1;
|
||||
$xData = $this->oArticlesService->getCategoryArticles($sSlug, 'view');
|
||||
return view('pages.articles.default.index', $xData);
|
||||
}
|
||||
|
||||
public function show(string $sArticleSlug, Request $oRequest)
|
||||
{
|
||||
$data = $this->articleData($sArticleSlug,$oRequest);
|
||||
$data['seo'] = \App\Services\Seo::articleMeta($data['oArticle']);
|
||||
return view('pages.articles.default.show',$data);
|
||||
$sFingerprint = $oRequest->cookie('visitor_token')
|
||||
?? md5($oRequest->ip() . $oRequest->userAgent());
|
||||
|
||||
$xData = $this->oArticlesService->getArticle($sArticleSlug, $oRequest->ip(), $sFingerprint);
|
||||
|
||||
// $xData["siteUrl"] = config("app.url");
|
||||
|
||||
$sViewPath = 'pages.articles.default.show';
|
||||
//
|
||||
// if ($xData["oArticle"]->oCategory->sSlug == "freenode") {
|
||||
// $sViewPath = 'pages.articles.freenode.show';
|
||||
// }
|
||||
|
||||
return view($sViewPath, $xData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,7 @@ public function handle(Request $request, Closure $next)
|
||||
abort_unless(($db['database'] ?? '') === 'fna_v3' && in_array($db['host'] ?? '', ['localhost', '127.0.0.1']) && empty($db['url']), 503, 'Local editorial database binding mismatch');
|
||||
}
|
||||
$path = config('editorial.credential_file');
|
||||
$process = PHP_SAPI === 'cli' ? config('editorial.process_credential') : null;
|
||||
$credential = $process ?? (is_file($path) ? json_decode(file_get_contents($path), true) : null);
|
||||
abort_if($process && (! is_int($process['expires_at'] ?? null) || $process['expires_at'] <= time()), 401, 'Process session expired');
|
||||
$credential = is_file($path) ? json_decode(file_get_contents($path), true) : null;
|
||||
abort_unless(is_array($credential)
|
||||
&& ($credential['environment'] ?? null) === app()->environment()
|
||||
&& ($credential['project'] ?? null) === 'fna-v3'
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
final class SeoHeaders
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
if ($response->getStatusCode() >= 400 || $request->is('api/*','like/*','up','test/*')) $response->headers->set('X-Robots-Tag','noindex, nofollow');
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
Regular → Executable
+23
-23
@@ -38,7 +38,7 @@ protected function sCreatedAtDiff(): Attribute
|
||||
{
|
||||
return Attribute::get(function () {
|
||||
// 1. 别直接用 $this->created_at,防止它还没被实例化成 Carbon 对象
|
||||
$oDate = \Carbon\Carbon::parse($this->attributes['sDisplayPublishedAt'] ?? $this->created_at);
|
||||
$oDate = \Carbon\Carbon::parse($this->created_at);
|
||||
$oNow = \Carbon\Carbon::now();
|
||||
|
||||
// 2. 计算小时差(强制转整数)
|
||||
@@ -67,7 +67,7 @@ protected function sCreatedAtDiff(): Attribute
|
||||
|
||||
public function shouldBeSearchable(): bool
|
||||
{
|
||||
return \App\Services\Seo::public($this);
|
||||
return (int)$this->iStatus === 1;
|
||||
}
|
||||
|
||||
public function searchableAs(): string
|
||||
@@ -97,34 +97,34 @@ public function toSearchableArray(): array
|
||||
* 判断当前文章是否超过分类设置的 SEO 暴露天数
|
||||
* @return bool
|
||||
*/
|
||||
public function bIsSeoExpired(): bool { return !\App\Services\Seo::indexable($this); }
|
||||
|
||||
public function scopePublicVisible($query)
|
||||
public function bIsSeoExpired(): bool
|
||||
{
|
||||
return $query->where('articles.iStatus', 1)->where('articles.created_at', '<=', now())
|
||||
->whereHas('oCategory', fn($c) => $c->where('iStatus', 1)->where(fn($p) => $p
|
||||
->where('iParentId', 0)->orWhereHas('oParent', fn($parent) => $parent->where('iStatus', 1))));
|
||||
}
|
||||
$oCategory = $this->oCategory;
|
||||
|
||||
// 未关联分类,或分类下的 aOpt 没设置,默认不处理(不过期)
|
||||
if (!$oCategory || empty($oCategory->aOpt) || !isset($oCategory->aOpt['noindexday'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$iNoindexDay = (int) $oCategory->aOpt['noindexday'];
|
||||
|
||||
// 0 或负数代表不限制,一直暴露给搜索引擎
|
||||
if ($iNoindexDay <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 判断文章创建时间是否早于 N 天前
|
||||
$oCreateDate = \Carbon\Carbon::parse($this->created_at);
|
||||
return $oCreateDate->lt(\Carbon\Carbon::now()->subDays($iNoindexDay));
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::saving(function ($article) {
|
||||
// Historical test fixtures and migration tooling may use the pre-SEO schema.
|
||||
if (!\Illuminate\Support\Facades\Schema::hasColumn('articles', 'sContentUpdatedAt')) return;
|
||||
if (!$article->exists || $article->isDirty(['sTitle','sTitleSub','sContent','sThumb','iCategoryId','iStatus','bPageThumb'])) {
|
||||
$article->sContentUpdatedAt = now();
|
||||
}
|
||||
if (!$article->exists && $article->oCategory?->sSlug === 'freenode') $article->sSeoPolicy = 'archive';
|
||||
});
|
||||
static::saved(function ($article) {
|
||||
if ($article->wasRecentlyCreated || $article->wasChanged(['sTitle','sTitleSub','sContent','sThumb','iCategoryId','iStatus'])) {
|
||||
app(\App\Services\SeoNotifications::class)->changed($article);
|
||||
}
|
||||
static::saved(function () {
|
||||
ResponseCache::forget('/'); // 要改成具体文章
|
||||
});
|
||||
|
||||
static::deleted(function ($article) {
|
||||
app(\App\Services\SeoNotifications::class)->changed($article,true);
|
||||
static::deleted(function () {
|
||||
ResponseCache::forget('/'); // 要改成具体文章
|
||||
});
|
||||
}
|
||||
|
||||
Regular → Executable
+1
-3
@@ -21,9 +21,7 @@ public function boot(): void
|
||||
$aHotArticles = CacheService::updateOrderLikes();
|
||||
}
|
||||
|
||||
$ids = collect($aHotArticles)->pluck('oArticle.id');
|
||||
$visible = \App\Models\Articles::publicVisible()->whereIn('id',$ids)->pluck('id')->all();
|
||||
$oView->with('oOrderLikes', array_values(array_filter($aHotArticles, fn($item)=>in_array($item['oArticle']['id'],$visible))));
|
||||
$oView->with('oOrderLikes', $aHotArticles);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ class ArticleResponseCacheProfile extends CacheAllSuccessfulGetRequests
|
||||
public function enabled(Request $request): bool
|
||||
{
|
||||
// 首页跟随最新免费节点文章,不能沿用整页的七天缓存。
|
||||
return false; // Public HTML contains session/like state and time-dependent visibility; static assets remain cacheable.
|
||||
return ! $request->is('/', 'api/editorial/*') && parent::enabled($request);
|
||||
}
|
||||
}
|
||||
Regular → Executable
+137
-32
@@ -143,46 +143,151 @@ public function like(int $iArticleId, string $sIp, string $sFingerprint): array
|
||||
}
|
||||
}
|
||||
|
||||
public function search(string $keywords, string $resultType = 'view')
|
||||
public function search(string $sKeywords, string $sResultType)
|
||||
{
|
||||
$term = trim(strip_tags($keywords));
|
||||
abort_if($term === '' || mb_strlen($term) > 100, 404);
|
||||
// Live DB authorization avoids stale external-index documents and cross-site results.
|
||||
$literal = '%'.str_replace(['!','%','_'], ['!!','!%','!_'], $term).'%';
|
||||
$articles = Articles::publicVisible()->with('oCategory.oParent')
|
||||
->where(fn($q) => $q->whereRaw("sTitle LIKE ? ESCAPE '!'", [$literal])->orWhereRaw("sContent LIKE ? ESCAPE '!'", [$literal]))
|
||||
->orderByDesc('iIsTop')->orderByDesc('created_at')->orderByDesc('id')->paginate(config('seo.page_size'));
|
||||
return ['oArticles'=>$articles, 'sKeywords'=>$term];
|
||||
if (empty($sKeywords)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sKeywords = strip_tags(trim($sKeywords));
|
||||
|
||||
$oArticles = Articles::search($sKeywords)
|
||||
->options([
|
||||
'attributesToHighlight' => ['sTitle', 'sContent', 'sCategoryName'],
|
||||
// 1. 把 attributesToSnippet 改成 attributesToCrop
|
||||
'attributesToCrop' => ['sContent'],
|
||||
// 2. 设置裁剪后的长度(单位是字符,按需调整)
|
||||
'cropLength' => 100,
|
||||
'highlightPreTag' => '<mark class="highlight">',
|
||||
'highlightPostTag' => '</mark>',
|
||||
])
|
||||
->orderByDesc('iIsTop')
|
||||
->paginate(config('app.page_limit'));
|
||||
|
||||
$oArticles->getCollection()->transform(function ($oArticle) {
|
||||
|
||||
$aMeta = $oArticle->scoutMetadata();
|
||||
$aFormatted = $aMeta['_formatted'] ?? [];
|
||||
|
||||
if (!empty($aFormatted)) {
|
||||
$oArticle->sTitle = $aFormatted['sTitle'] ?? $oArticle->sTitle;
|
||||
$oArticle->sContent = $aFormatted['sContent'] ?? $oArticle->sContent;
|
||||
|
||||
if (isset($aFormatted['sCategoryName'])) {
|
||||
$oArticle->sCategoryName = $aFormatted['sCategoryName'];
|
||||
$oArticle->setRelation('oCategory', (object)[
|
||||
'sName' => $aFormatted['sCategoryName'],
|
||||
'sSlug' => $oArticle->sCategorySlug ?? ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $oArticle;
|
||||
});
|
||||
|
||||
if ($sResultType === "ajax") {
|
||||
$sHtml = '';
|
||||
foreach ($oArticles as $oArticle) {
|
||||
$sHtml .= view('components.article-item', ['oArticle' => $oArticle])->render();
|
||||
}
|
||||
$xResult = $sHtml;
|
||||
} else {
|
||||
$xResult = [
|
||||
'oArticles' => $oArticles,
|
||||
];
|
||||
}
|
||||
|
||||
return $xResult;
|
||||
}
|
||||
public function getTagArticles(string $slug, string $resultType = 'view')
|
||||
|
||||
public function getTagArticles(string $sSlug, string $sResultType)
|
||||
{
|
||||
$tag = Tags::where('sSlug', $slug)->firstOrFail();
|
||||
return ['oTag'=>$tag, 'oArticles'=>$tag->oArticles()->publicVisible()->with('oCategory.oParent')
|
||||
->orderByDesc('iIsTop')->orderByDesc('created_at')->orderByDesc('id')->paginate(config('seo.page_size'))];
|
||||
$oTags = Tags::where('sSlug', $sSlug)->firstOrFail();
|
||||
|
||||
$oArticles = $oTags->oArticles()
|
||||
->where('iStatus', 1) // 只拿已发布的
|
||||
->with(['oCategory']) // 预加载关联,拒绝 N+1
|
||||
->orderByDesc('iIsTop') // 置顶优先
|
||||
->orderByDesc('created_at') // 最新优先
|
||||
->paginate(config('app.page_limit')); // 必须分页,否则数据多了会爆内存
|
||||
|
||||
if ($sResultType === "ajax") {
|
||||
$sHtml = '';
|
||||
foreach ($oArticles as $oArticle) {
|
||||
$sHtml .= view('components.article-item', ['oArticle' => $oArticle])->render();
|
||||
}
|
||||
$xResult = $sHtml;
|
||||
} else {
|
||||
$xResult = [
|
||||
'oArticles' => $oArticles,
|
||||
];
|
||||
}
|
||||
|
||||
return $xResult;
|
||||
}
|
||||
|
||||
public function getLatestFreeNodeSlug(): ?string
|
||||
{
|
||||
foreach (Articles::publicVisible()->whereHas('oCategory', fn($q)=>$q->where('sSlug','freenode'))
|
||||
->orderByDesc('created_at')->orderByDesc('id')->cursor() as $article) {
|
||||
if (ResourcePublication::usable($article)) return $article->sSlug;
|
||||
return Articles::where('iStatus', 1)
|
||||
->whereHas('oCategory', fn ($query) => $query->where('sSlug', 'freenode'))
|
||||
->where('created_at', '<=', now())
|
||||
->orderByDesc('created_at')
|
||||
->orderByDesc('id')
|
||||
->value('sSlug');
|
||||
}
|
||||
|
||||
public function getCategoryArticles(string $sSlug, string $sResultType)
|
||||
{
|
||||
$oCategory = Categories::where('sSlug', $sSlug)->firstOrFail();
|
||||
|
||||
if ($oCategory->iShowChildren) {
|
||||
$aCategoryIds = Categories::where('iParentId', $oCategory->id)
|
||||
->pluck('id')
|
||||
->push($oCategory->id)
|
||||
->toArray();
|
||||
} else {
|
||||
$aCategoryIds = [$oCategory->id];
|
||||
}
|
||||
return null;
|
||||
|
||||
$oArticles = Articles::whereIn('iCategoryId', $aCategoryIds)
|
||||
->with(['oUser', 'oCategory'])
|
||||
->orderBy('iIsTop', 'desc')
|
||||
->orderBy('created_at', 'desc')
|
||||
->simplePaginate(config('app.page_limit'));
|
||||
|
||||
if ($sResultType === "ajax") {
|
||||
$sHtml = '';
|
||||
foreach ($oArticles as $oArticle) {
|
||||
$sHtml .= view('components.article-item', ['oArticle' => $oArticle])->render();
|
||||
}
|
||||
$aResult = $sHtml;
|
||||
} else {
|
||||
$aResult = [
|
||||
'oCategory' => $oCategory,
|
||||
'iArticleCount' => isset($oCategory->aBanner) ? Articles::whereIn('iCategoryId', $aCategoryIds)->count() : null,
|
||||
'oArticles' => $oArticles,
|
||||
];
|
||||
}
|
||||
|
||||
return $aResult;
|
||||
}
|
||||
public function getCategoryArticles(string $slug, string $resultType = 'view')
|
||||
|
||||
public function getArticle(string $sArticleSlug, string $sIp, string $sFingerprint)
|
||||
{
|
||||
$category = Categories::where('sSlug', $slug)->where('iStatus',1)->with('oParent')->firstOrFail();
|
||||
abort_if($category->iParentId && (!$category->oParent || !$category->oParent->iStatus),404);
|
||||
$ids = [$category->id];
|
||||
if ($category->iShowChildren) $ids = array_merge($ids, Categories::where('iParentId',$category->id)->where('iStatus',1)->pluck('id')->all());
|
||||
$articles = Articles::publicVisible()->whereIn('iCategoryId',$ids)->with('oCategory.oParent')
|
||||
->orderByDesc('iIsTop')->orderByDesc('created_at')->orderByDesc('id')->paginate(config('seo.page_size'));
|
||||
return ['oCategory'=>$category,'oArticles'=>$articles,'iArticleCount'=>$articles->total()];
|
||||
}
|
||||
public function getArticle(string $slug, string $ip, string $fingerprint)
|
||||
{
|
||||
$article = Articles::publicVisible()->where('sSlug',$slug)->with(['oCategory.oParent','oTags'])->firstOrFail();
|
||||
$article->bIsLiked = ArticleLikes::where('iArticleId',$article->id)
|
||||
->where(fn($q)=>$q->where('sIp',$ip)->orWhere('sFingerprint',$fingerprint))->exists();
|
||||
return ['oArticle'=>$article];
|
||||
$oArticle = Articles::where('sSlug', $sArticleSlug)
|
||||
->where('iStatus', 1)
|
||||
->with(['oCategory.oParent', 'oTags'])
|
||||
->firstOrFail();
|
||||
|
||||
$oArticle->bIsLiked = ArticleLikes::where('iArticleId', $oArticle->id)
|
||||
->where(function($q) use ($sIp, $sFingerprint) {
|
||||
$q->where('sIp', $sIp)
|
||||
->orWhere('sFingerprint', $sFingerprint);
|
||||
})->exists();
|
||||
|
||||
// return $oArticle;
|
||||
return [
|
||||
'oArticle' => $oArticle
|
||||
];
|
||||
}
|
||||
}
|
||||
Regular → Executable
+1
-1
@@ -68,7 +68,7 @@ class CacheService
|
||||
public static function updateOrderLikes(): array
|
||||
{
|
||||
// 1. 基于 Articles 表按最后点赞时间倒序,涵盖真实赞与算法注入赞
|
||||
$cArticles = Articles::publicVisible()
|
||||
$cArticles = Articles::where('iStatus', 1)
|
||||
->whereNotNull('sLastLikedAt')
|
||||
->orderBy('sLastLikedAt', 'desc')
|
||||
->limit(5)
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
<?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'), '/');
|
||||
$urls = [];
|
||||
foreach ($published as $item) {
|
||||
if (! ($item['content_changed'] ?? false)) {
|
||||
continue;
|
||||
}
|
||||
$article = Articles::with('oCategory')->find($item['article_id']);
|
||||
if (! $article || !\App\Services\Seo::indexable($article)) {
|
||||
continue;
|
||||
}
|
||||
$url = $base.'/a/'.$article->sSlug.'.html';
|
||||
if ($url === $item['url'] && preg_match('/\A[a-z0-9_-]+\z/', $article->sSlug)) {
|
||||
$urls[] = $url;
|
||||
$urls[] = \App\Services\Seo::url(\App\Services\Seo::categoryPath($article->oCategory));
|
||||
if ($article->oCategory->oParent) $urls[] = \App\Services\Seo::url(\App\Services\Seo::categoryPath($article->oCategory->oParent));
|
||||
}
|
||||
}
|
||||
$urls = array_values(array_unique($urls));
|
||||
if (! $urls) {
|
||||
return array_replace($state, ['status' => 'skipped', 'reason' => 'no-current-indexable-url']);
|
||||
}
|
||||
|
||||
return $this->submit($state, $urls);
|
||||
}
|
||||
|
||||
public function submit(array $state, array $urls): array
|
||||
{
|
||||
if (!$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');
|
||||
}
|
||||
|
||||
foreach ($urls as $url) {
|
||||
if (!str_starts_with($url, $base.'/') || parse_url($url, PHP_URL_HOST) !== $host || parse_url($url, PHP_URL_QUERY) || parse_url($url, PHP_URL_FRAGMENT)) return $this->pending($state,'invalid-target');
|
||||
}
|
||||
if (!$urls) return ['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))];
|
||||
}
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Editorial;
|
||||
|
||||
use Illuminate\Contracts\Http\Kernel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
/** Calls the existing HTTP routes on the application server, without opening its public API. */
|
||||
final class ProcessApi
|
||||
{
|
||||
private array $credential;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
abort_unless(PHP_SAPI === 'cli', 403);
|
||||
$this->credential = ['schema' => 'gemdocs.credential.v1', 'project' => 'fna-v3',
|
||||
'environment' => app()->environment(), 'base_url' => config('editorial.base_url'),
|
||||
'expires_at' => time() + 600, 'fields' => ['api_key' => 'fna_ed_'.bin2hex(random_bytes(32))]];
|
||||
}
|
||||
|
||||
public function call(string $method, string $path, array $data = [], ?UploadedFile $image = null): array
|
||||
{
|
||||
abort_unless(in_array($method, ['GET', 'POST']) && preg_match('~\A[a-zA-Z0-9_/-]+\z~', $path), 422);
|
||||
$response = $this->dispatch($method, '/api/editorial/v1/'.$path, $data, $image);
|
||||
$body = json_decode($response->getContent(), true);
|
||||
abort_unless($response->isSuccessful(), $response->getStatusCode(), 'Editorial API rejected operation; inspect state before retry');
|
||||
abort_unless(is_array($body), 502, 'Unexpected API response');
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
public function preview(string $url): string
|
||||
{
|
||||
$base = rtrim(config('editorial.base_url'), '/');
|
||||
abort_unless(str_starts_with($url, $base.'/api/editorial/v1/preview/'), 422, 'Preview origin mismatch');
|
||||
$response = $this->dispatch('GET', substr($url, strlen($base)));
|
||||
abort_unless($response->isSuccessful() && str_contains($response->headers->get('Content-Type', ''), 'text/html')
|
||||
&& str_contains($response->headers->get('X-Robots-Tag', ''), 'noindex'), 502, 'Preview render failed');
|
||||
|
||||
return $response->getContent();
|
||||
}
|
||||
|
||||
private function dispatch(string $method, string $path, array $data = [], ?UploadedFile $image = null)
|
||||
{
|
||||
abort_unless(time() < $this->credential['expires_at'], 401, 'Process session expired');
|
||||
$before = ['editorial.enabled' => config('editorial.enabled'),
|
||||
'editorial.process_credential' => config('editorial.process_credential')];
|
||||
$originalRequest = app('request');
|
||||
config(['editorial.enabled' => true, 'editorial.process_credential' => $this->credential]);
|
||||
try {
|
||||
$server = ['HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => 'Bearer '.$this->credential['fields']['api_key'],
|
||||
'CONTENT_TYPE' => 'application/json', 'REMOTE_ADDR' => '127.0.0.1'];
|
||||
$request = Request::create(rtrim(config('editorial.base_url'), '/').$path, $method, [], [],
|
||||
$image ? ['image' => $image] : [], $server, $image ? null : json_encode($data));
|
||||
$kernel = app(Kernel::class);
|
||||
$response = $kernel->handle($request);
|
||||
$kernel->terminate($request, $response);
|
||||
|
||||
return $response;
|
||||
} finally {
|
||||
config($before);
|
||||
app()->instance('request', $originalRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,12 +36,6 @@ 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()]);
|
||||
});
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ public function draft(array $input): array
|
||||
'articles.*.tag_ids' => 'sometimes|array|max:20', 'articles.*.tag_ids.*' => 'integer|min:1',
|
||||
'articles.*.cover' => 'sometimes|nullable|string|max:255',
|
||||
'articles.*.show_cover' => 'sometimes|boolean',
|
||||
'articles.*.display_time_randomize' => 'sometimes|boolean',
|
||||
'articles.*.adopt_article_id' => 'sometimes|integer|min:1',
|
||||
'articles.*.like_settings' => 'sometimes|array:seven_day,yearly,one_year',
|
||||
'articles.*.like_settings.seven_day' => 'sometimes|integer|min:0|max:1000000',
|
||||
@@ -65,7 +64,6 @@ public function draft(array $input): array
|
||||
abort_if($doc->article_id && ! $article, 409, 'Managed article was removed');
|
||||
if ($article) {
|
||||
abort_if(array_key_exists('like_settings', $row), 422, 'Like settings are only accepted for new articles');
|
||||
abort_if(array_key_exists('display_time_randomize', $row), 422, 'Display time settings are only accepted for new articles');
|
||||
abort_unless($article->sSlug === $row['slug'], 409, 'Stable article URL cannot change');
|
||||
$sourceCategory = DB::table('categories')->where('id', $article->iCategoryId)->value('sSlug');
|
||||
abort_if(in_array($sourceCategory, ['freenode', 'shadowrocketids']), 422, 'Resource articles cannot be adopted by the editorial API');
|
||||
@@ -86,8 +84,7 @@ public function draft(array $input): array
|
||||
'base_article_hash' => $article ? $this->articleHash($article) : null,
|
||||
];
|
||||
if (! $article) {
|
||||
// Freeze display offset and like defaults once; retries cannot redraw them.
|
||||
$item['display_offset_seconds'] = ($row['display_time_randomize'] ?? true) ? random_int(0, 21600) : 0;
|
||||
// Freeze the random defaults once per draft, so a retry/publication cannot redraw them.
|
||||
$item['like_settings'] = [
|
||||
'seven_day' => $row['like_settings']['seven_day'] ?? random_int(5, 35),
|
||||
'yearly' => $row['like_settings']['yearly'] ?? 50,
|
||||
@@ -117,7 +114,7 @@ public function getDraft(string $id): array
|
||||
|
||||
return ['draft_id' => $id, 'hash' => $d->payload_hash, 'status' => $d->status, 'publication_id' => $d->publication_id,
|
||||
'articles' => array_map(fn ($i) => ['content_key' => $i['content_key'], 'revision' => $i['revision'], 'title' => $i['title'],
|
||||
'path' => '/a/'.$i['slug'].'.html', 'display_offset_seconds' => $i['display_offset_seconds'] ?? 0, 'like_settings' => $i['like_settings'] ?? null,
|
||||
'path' => '/a/'.$i['slug'].'.html', 'like_settings' => $i['like_settings'] ?? null,
|
||||
'preview_url' => $base.URL::temporarySignedRoute('editorial.preview', now()->addMinutes(config('editorial.preview_minutes')), ['draft' => $id, 'key' => $i['content_key']], absolute: false)], $items)];
|
||||
}
|
||||
|
||||
@@ -192,8 +189,7 @@ public function publish(string $id, array $input): array
|
||||
'i7like' => $likes['seven_day'], 'i365like' => $likes['yearly'],
|
||||
'iYearLikeTarget' => $likes['one_year'], 'iYearLikeAdded' => 0,
|
||||
'sYearLikeStartedAt' => $likes['one_year'] > 0 ? now() : null,
|
||||
'iIsTop' => 0, 'created_at' => now(),
|
||||
'sDisplayPublishedAt' => now()->subSeconds($item['display_offset_seconds'] ?? 0)]);
|
||||
'iIsTop' => 0, 'created_at' => now()]);
|
||||
}
|
||||
$oldTags = $this->tags($articleId);
|
||||
DB::table('article_tag')->where('iArticleId', $articleId)->delete();
|
||||
@@ -203,20 +199,13 @@ public function publish(string $id, array $input): array
|
||||
foreach (array_unique(array_merge($oldTags, $item['tag_ids'])) as $tag) {
|
||||
DB::table('tags')->where('id', $tag)->update(['iArticleCount' => DB::table('article_tag')->where('iTagId', $tag)->count()]);
|
||||
}
|
||||
$contentChanged = $item['base_article_hash'] !== $this->articleHash(DB::table('articles')->where('id', $articleId)->first());
|
||||
if ($contentChanged && \Illuminate\Support\Facades\Schema::hasColumn('articles','sContentUpdatedAt')) {
|
||||
DB::table('articles')->where('id',$articleId)->update(['sContentUpdatedAt'=>now()]);
|
||||
}
|
||||
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),
|
||||
'effects' => json_encode(['indexnow' => app(IndexNowNotification::class)->initial($published)]),
|
||||
'created_at' => now(), 'updated_at' => now()]);
|
||||
'receipt' => json_encode(['publication_id' => $data['request_id'], 'status' => 'published', 'articles' => $published], JSON_UNESCAPED_UNICODE), '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'];
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Editorial;
|
||||
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
final class ReleaseRunner
|
||||
{
|
||||
public function __construct(private ProcessApi $api) {}
|
||||
|
||||
public function run(array $input): array
|
||||
{
|
||||
$op = $input['operation'] ?? '';
|
||||
abort_unless(in_array($op, ['catalog', 'source', 'prepare', 'review', 'publish', 'status']), 422, 'Unknown operation');
|
||||
if ($op === 'catalog') {
|
||||
return $this->api->call('GET', 'catalog');
|
||||
}
|
||||
if ($op === 'source') {
|
||||
abort_unless(is_int($input['article_id'] ?? null) && $input['article_id'] > 0, 422);
|
||||
|
||||
return $this->api->call('GET', 'source-articles/'.$input['article_id']);
|
||||
}
|
||||
$id = $input['release_id'] ?? '';
|
||||
abort_unless(is_string($id) && Str::isUuid($id), 422, 'release_id must be a UUID');
|
||||
$root = config('editorial.release_directory', storage_path('app/private/editorial-releases'));
|
||||
if (! is_dir($root)) {
|
||||
mkdir($root, 0700, true);
|
||||
}
|
||||
$lock = fopen($root.'/runner.lock', 'c');
|
||||
abort_unless($lock && flock($lock, LOCK_EX | LOCK_NB), 409, 'Another release operation is running');
|
||||
try {
|
||||
$file = $root.'/'.$id.'.json';
|
||||
$state = is_file($file) ? json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR) : null;
|
||||
if ($op === 'prepare') {
|
||||
$bundle = ['articles' => $input['articles'] ?? [], 'assets' => $input['assets'] ?? []];
|
||||
$bundleHash = app(Publisher::class)->hash($bundle);
|
||||
abort_if($state && $state['bundle_hash'] !== $bundleHash, 409, 'Release ID reused with changed bundle');
|
||||
if (! $state) {
|
||||
$state = ['release_id' => $id, 'bundle_hash' => $bundleHash, 'draft_id' => $id,
|
||||
'publication_request_id' => (string) Str::uuid(), 'phase' => 'preparing'];
|
||||
$this->save($file, $state); // Persist IDs before any API mutation.
|
||||
}
|
||||
$articles = $this->assets($bundle);
|
||||
$draft = $this->api->call('POST', 'drafts', ['request_id' => $id, 'articles' => $articles]);
|
||||
$state['draft'] = $draft;
|
||||
if ($state['phase'] === 'preparing') {
|
||||
$state['phase'] = 'prepared';
|
||||
}
|
||||
$this->save($file, $state);
|
||||
|
||||
return $state;
|
||||
}
|
||||
abort_unless($state, 404, 'Release not found; retry prepare using the original bundle');
|
||||
if ($op === 'status') {
|
||||
return $this->receipt($file, $state);
|
||||
}
|
||||
$draft = $this->api->call('GET', 'drafts/'.$state['draft_id']);
|
||||
if ($op === 'review') {
|
||||
$previews = [];
|
||||
foreach ($draft['articles'] as $article) {
|
||||
$previews[$article['content_key']] = $this->api->preview($article['preview_url']);
|
||||
}
|
||||
$state['review'] = ['hash' => $draft['hash'], 'digest' => app(Publisher::class)->hash($previews), 'rendered_at' => gmdate('c')];
|
||||
$state['phase'] = $draft['status'] === 'published' ? 'published' : 'reviewed';
|
||||
$this->save($file, $state);
|
||||
|
||||
return $state + ['previews' => $previews];
|
||||
}
|
||||
abort_unless(isset($state['review'])
|
||||
&& hash_equals($state['review']['hash'], $input['expected_hash'] ?? '')
|
||||
&& hash_equals($state['review']['digest'], $input['review_digest'] ?? '')
|
||||
&& hash_equals($draft['hash'], $state['review']['hash']), 409, 'Review the frozen draft before publishing');
|
||||
// Query first even after a lost response or interrupted local state update.
|
||||
$state = $this->receipt($file, $state);
|
||||
if (! isset($state['receipt'])) {
|
||||
$state['phase'] = 'publishing';
|
||||
$this->save($file, $state);
|
||||
$state['receipt'] = $this->api->call('POST', 'drafts/'.$state['draft_id'].'/publish',
|
||||
['request_id' => $state['publication_request_id'], 'expected_hash' => $state['review']['hash']]);
|
||||
$this->save($file, $state);
|
||||
}
|
||||
$receiptId = $state['receipt']['publication_id'];
|
||||
$state['receipt'] = $this->api->call('POST', 'publications/'.$receiptId.'/synchronize');
|
||||
|
||||
return $this->verify($file, $state);
|
||||
} finally {
|
||||
flock($lock, LOCK_UN);
|
||||
fclose($lock);
|
||||
}
|
||||
}
|
||||
|
||||
private function receipt(string $file, array $state): array
|
||||
{
|
||||
try {
|
||||
$state['receipt'] = $this->api->call('GET', 'publications/'.$state['publication_request_id']);
|
||||
} catch (\Symfony\Component\HttpKernel\Exception\HttpException $e) {
|
||||
if ($e->getStatusCode() !== 404) {
|
||||
throw $e;
|
||||
}
|
||||
// Another publisher may have completed this same draft with its own UUID.
|
||||
$draft = $this->api->call('GET', 'drafts/'.$state['draft_id']);
|
||||
if ($draft['publication_id']) {
|
||||
$state['receipt'] = $this->api->call('GET', 'publications/'.$draft['publication_id']);
|
||||
} else {
|
||||
return $state;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->verify($file, $state);
|
||||
}
|
||||
|
||||
private function verify(string $file, array $state): array
|
||||
{
|
||||
$timestamp = \Illuminate\Support\Facades\DB::table('editorial_publications')->where('id', $state['receipt']['publication_id'])->value('created_at');
|
||||
$state['published_at'] = \Carbon\CarbonImmutable::parse($timestamp, config('app.timezone'))->toIso8601String();
|
||||
$readback = [];
|
||||
foreach ($state['receipt']['articles'] as $article) {
|
||||
$source = $this->api->call('GET', 'source-articles/'.$article['article_id']);
|
||||
$version = $this->api->call('GET', 'articles/'.$article['content_key'].'/versions/'.$article['revision'])['content'];
|
||||
$imagesValid = true;
|
||||
$resolve = function (string $html) use (&$imagesValid) {
|
||||
return preg_replace_callback('/asset:([a-f0-9]{64})/', function ($m) use (&$imagesValid) {
|
||||
$extension = \Illuminate\Support\Facades\DB::table('editorial_assets')->where('sha256', $m[1])->value('extension');
|
||||
$url = '/images/editorial/'.$m[1].'.'.$extension;
|
||||
$path = public_path(ltrim($url, '/'));
|
||||
$imagesValid = $imagesValid && is_file($path) && hash_file('sha256', $path) === $m[1];
|
||||
|
||||
return $url;
|
||||
}, $html);
|
||||
};
|
||||
$expectedHtml = $resolve($version['html']);
|
||||
$expectedCover = $version['cover'] ? $resolve($version['cover']) : $version['cover'];
|
||||
$matches = $source['body_html'] === $expectedHtml && $source['title'] === $version['title']
|
||||
&& $source['summary'] === $version['summary'] && $source['slug'] === $version['slug']
|
||||
&& $source['category_slug'] === $version['category_slug'] && $source['cover'] === $expectedCover
|
||||
&& $source['show_cover'] === $version['show_cover'] && $imagesValid;
|
||||
$readback[] = ['content_key' => $article['content_key'], 'article_id' => $article['article_id'],
|
||||
'revision_matches' => (int) $source['management']['published_revision'] === (int) $article['revision'],
|
||||
'content_matches' => $matches,
|
||||
'body_sha256' => hash('sha256', $source['body_html']), 'like_growth' => $source['like_growth']];
|
||||
}
|
||||
$state['readback'] = $readback;
|
||||
$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);
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
private function assets(array $bundle): array
|
||||
{
|
||||
abort_unless(is_array($bundle['assets']) && count($bundle['assets']) <= 10, 422);
|
||||
$replacements = [];
|
||||
foreach ($bundle['assets'] as $asset) {
|
||||
abort_unless(preg_match('/\A[a-z0-9_-]{1,80}\z/', $asset['name'] ?? '') && ! isset($replacements['file:'.$asset['name']]), 422, 'Invalid or duplicate asset name');
|
||||
$bytes = base64_decode($asset['base64'] ?? '', true);
|
||||
abort_unless($bytes !== false && strlen($bytes) <= 8 * 1024 * 1024, 422, 'Invalid asset');
|
||||
$temp = tempnam(sys_get_temp_dir(), 'editorial-upload-');
|
||||
try {
|
||||
file_put_contents($temp, $bytes);
|
||||
chmod($temp, 0600);
|
||||
$result = $this->api->call('POST', 'assets', [], new UploadedFile($temp, $asset['name'], null, null, true));
|
||||
$replacements['file:'.$asset['name']] = $result['reference'];
|
||||
} finally {
|
||||
@unlink($temp);
|
||||
}
|
||||
}
|
||||
$articles = $bundle['articles'];
|
||||
abort_unless(is_array($articles) && count($articles) >= 1 && count($articles) <= 10, 422);
|
||||
foreach ($articles as &$article) {
|
||||
foreach (['body', 'cover'] as $field) {
|
||||
if (isset($article[$field])) {
|
||||
$article[$field] = preg_replace_callback('/file:([a-z0-9_-]+)/', function ($m) use ($replacements) {
|
||||
abort_unless(isset($replacements[$m[0]]), 422, 'Missing bundled asset');
|
||||
|
||||
return $replacements[$m[0]];
|
||||
}, $article[$field]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $articles;
|
||||
}
|
||||
|
||||
private function save(string $file, array $state): void
|
||||
{
|
||||
$temp = $file.'.'.bin2hex(random_bytes(8));
|
||||
try {
|
||||
$handle = fopen($temp, 'x');
|
||||
chmod($temp, 0600);
|
||||
$bytes = json_encode($state, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR);
|
||||
if (fwrite($handle, $bytes) !== strlen($bytes) || ! fflush($handle) || ! fsync($handle)) {
|
||||
throw new \RuntimeException('Release state write failed');
|
||||
}
|
||||
fclose($handle);
|
||||
if (! rename($temp, $file)) {
|
||||
throw new \RuntimeException('Release state replacement failed');
|
||||
}
|
||||
} finally {
|
||||
@unlink($temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,17 +41,6 @@ private static function request(string $method, string $path, array $body = []):
|
||||
}
|
||||
}
|
||||
|
||||
public static function pendingDeliveries(): array
|
||||
{
|
||||
return self::request('GET', 'illustration-deliveries');
|
||||
}
|
||||
|
||||
public static function acknowledgeDelivery(string $id, array $receipt): array
|
||||
{
|
||||
if (! preg_match('/\A[a-f0-9-]{36}\z/D', $id)) throw new \RuntimeException('Invalid delivery');
|
||||
return self::request('POST', 'illustration-deliveries/'.$id.'/ack', $receipt);
|
||||
}
|
||||
|
||||
public static function snapshot(string $pool): array
|
||||
{
|
||||
return Cache::store('file')->remember('illustrations.v2.'.$pool, 60, function () use ($pool) {
|
||||
|
||||
@@ -115,18 +115,6 @@ private function copy(array $image, array $assets): array
|
||||
'url' => config('illustrations.local_url_prefix').'/'.$sha.'.'.$ext, 'source_url' => $source];
|
||||
}
|
||||
|
||||
/** Delivery intake copies only approved batch assets; it does not reconcile existing articles. */
|
||||
public function cacheDeliveryAssets(array $images): void
|
||||
{
|
||||
$this->locked(function () use ($images) {
|
||||
$state = $this->read();
|
||||
foreach ($images as $image) {
|
||||
$state['assets'][$image['asset_id']] = $this->copy($image, $state['assets']);
|
||||
}
|
||||
$this->save($state);
|
||||
});
|
||||
}
|
||||
|
||||
public function storeSelection(string $pool, string $slug, array $image): string
|
||||
{
|
||||
return $this->locked(function () use ($pool, $slug, $image) {
|
||||
@@ -160,20 +148,17 @@ public function synchronize(array $snapshots, ?array $baseline = null): array
|
||||
$state['assets'][$id] = $this->copy($image, $state['assets']);
|
||||
$available[$id] = true;
|
||||
}
|
||||
// Published FNA copies are independent of the source lifecycle.
|
||||
// A deleted source reference must not silently remove a local assignment.
|
||||
$selections = $state['selections'][$pool] ?? [];
|
||||
$selections = [];
|
||||
foreach ($snapshot['selections'] as $slug => $image) $selections[$slug] = $image['asset_id'];
|
||||
foreach ($snapshot['unavailable'] ?? [] as $slug => $reason) {
|
||||
$id = $state['selections'][$pool][$slug] ?? null;
|
||||
$old = $id ? ($state['assets'][$id] ?? null) : null;
|
||||
$local = $old ? config('illustrations.local_directory').'/'.basename($old['url']) : null;
|
||||
// Source deletion, disabling or withdrawal never revokes an FNA copy.
|
||||
if ($local && is_file($local) && ! is_link($local) && hash_equals($old['sha256'], hash_file('sha256', $local))) {
|
||||
// A healthy independent display copy survives physical loss at the source.
|
||||
if (in_array($reason, ['file_missing', 'file_corrupt', 'file_symlink']) && $local && is_file($local) && ! is_link($local) && hash_equals($old['sha256'], hash_file('sha256', $local))) {
|
||||
$selections[$slug] = $id;
|
||||
} else {
|
||||
// Report missing/corrupt local bytes without destroying recovery metadata.
|
||||
$selections[$slug] = $id;
|
||||
$selections[$slug] = null;
|
||||
$pending[$pool.':'.$slug] = $reason;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
final class ResourceArticlePresentation
|
||||
{
|
||||
/** Remove legacy follow prompts only from the two daily resource columns. */
|
||||
public static function body(string $html, ?string $category): string
|
||||
{
|
||||
if (! in_array($category, ['freenode', 'shadowrocketids'], true)) return $html;
|
||||
|
||||
return preg_replace_callback('~<p\b[^>]*>.*?</p>(?:\s*<p\b[^>]*>\s*</p>)*~si', static function (array $match): string {
|
||||
$text = html_entity_decode(strip_tags($match[0]), ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
$text = preg_replace('/\s+/u', '', $text);
|
||||
if (preg_match('/点击加入我们的(?:tg|telegram)频道|点击关注我们的github仓库/iu', $text)) return '';
|
||||
return $match[0];
|
||||
}, $html);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
use App\Models\Articles;
|
||||
final class ResourcePublication
|
||||
{
|
||||
public static function usable(Articles $article): bool
|
||||
{
|
||||
if (in_array($article->sResourceStatus, ['failed','empty'], true)) return false;
|
||||
// Legacy explicit zero is evidence of no result, not a successful refresh.
|
||||
return !preg_match('/(?:共|更新)\s*0\s*个可用节点/u', Seo::text($article->sTitleSub));
|
||||
}
|
||||
public static function validate(array $article): array
|
||||
{
|
||||
validator($article, ['title'=>'required|string|max:250','title_sub'=>'present|string|max:4000',
|
||||
'content'=>'required|string|max:2000000','tags'=>'present|array','7like'=>'nullable|integer|min:0',
|
||||
'check_status'=>'nullable|in:success,failed,unknown','valid_count'=>'nullable|integer|min:0'])->validate();
|
||||
$count = isset($article['valid_count']) ? (int)$article['valid_count'] : null;
|
||||
$state = $article['check_status'] ?? 'unknown';
|
||||
// Compatibility for the current upstream; a reported count is not a new live check.
|
||||
if ($count === null && preg_match('/(?:共|更新)\s*(\d+)\s*个可用节点/u', Seo::text($article['title_sub']), $m)) $count = (int)$m[1];
|
||||
abort_if($state === 'failed' || $count === 0 || trim(Seo::text($article['content'])) === '', 422, 'Resource update has no usable result; previous publication retained');
|
||||
return ['sResourceStatus'=>$state === 'success' && $count > 0 ? 'success' : 'unknown','iResourceCount'=>$count];
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Articles;
|
||||
use App\Models\Categories;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/** One URL, visibility and indexing contract for HTML, sitemap and notifications. */
|
||||
final class Seo
|
||||
{
|
||||
public static function url(string $path = '/', int $page = 1): string
|
||||
{
|
||||
return rtrim(config('app.url'), '/').'/'.ltrim($path, '/').($page > 1 ? '?page='.$page : '');
|
||||
}
|
||||
public static function articleUrl(Articles $article): string { return self::url('/a/'.$article->sSlug.'.html'); }
|
||||
public static function categoryPath(Categories $category): string
|
||||
{
|
||||
return ($category->oParent ? '/'.$category->oParent->sSlug : '').'/'.$category->sSlug;
|
||||
}
|
||||
public static function categoryName(Categories $category): string
|
||||
{
|
||||
return match ($category->sSlug) { 'andorid' => 'Android', 'ios' => 'iOS', default => $category->sName };
|
||||
}
|
||||
public static function text(?string $html, int $limit = 200): string
|
||||
{
|
||||
$text = html_entity_decode(strip_tags($html ?? ''), ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
return mb_substr(trim(preg_replace('/\s+/u', ' ', $text)), 0, $limit);
|
||||
}
|
||||
public static function imageSize(?string $url): array
|
||||
{
|
||||
$path = parse_url($url ?? '', PHP_URL_PATH);
|
||||
if (!$path || str_contains($path,'..') || !str_starts_with($path,'/')) return [];
|
||||
if (parse_url($url,PHP_URL_HOST) && parse_url($url,PHP_URL_HOST) !== parse_url(config('app.url'),PHP_URL_HOST)) return [];
|
||||
$file = public_path(ltrim($path,'/'));
|
||||
if (!is_file($file)) return [];
|
||||
$size = @getimagesize($file);
|
||||
return $size ? ['width'=>$size[0],'height'=>$size[1]] : [];
|
||||
}
|
||||
public static function body(string $html): string
|
||||
{
|
||||
// Preserve editorial HTML byte-for-byte except confirmed commercial links.
|
||||
return preg_replace_callback('~<a\b[^>]*>~i', function($match) {
|
||||
$tag = $match[0];
|
||||
if (!preg_match('~\bhref\s*=\s*([\x22\x27])(.*?)\1~i',$tag,$href)) return $tag;
|
||||
$host = parse_url(html_entity_decode($href[2],ENT_QUOTES),PHP_URL_HOST);
|
||||
if (!in_array($host,['fuuu.cloud','xn--123-9i9dj97q.com','hardnerd.net'],true)) return $tag;
|
||||
$tokens = ['sponsored','noopener'];
|
||||
if (preg_match('~\brel\s*=\s*([\x22\x27])(.*?)\1~i',$tag,$rel)) {
|
||||
$tokens = array_unique(array_merge(preg_split('/\s+/',trim($rel[2])),$tokens));
|
||||
return str_replace($rel[0],'rel="'.implode(' ',$tokens).'"',$tag);
|
||||
}
|
||||
return substr($tag,0,-1).' rel="'.implode(' ',$tokens).'">';
|
||||
}, $html);
|
||||
}
|
||||
public static function public(Articles $a): bool
|
||||
{
|
||||
return (int)$a->iStatus === 1 && $a->created_at && !$a->created_at->isFuture()
|
||||
&& $a->oCategory && (int)$a->oCategory->iStatus === 1
|
||||
&& (!$a->oCategory->iParentId || ($a->oCategory->oParent && (int)$a->oCategory->oParent->iStatus === 1));
|
||||
}
|
||||
public static function indexable(Articles $a): bool
|
||||
{
|
||||
if (!self::public($a) || in_array($a->sSeoPolicy, ['archive','noindex'], true)) return false;
|
||||
if ($a->sSeoPolicy === 'index') return true;
|
||||
// Legacy records retain their existing age policy; tutorials never inherit it.
|
||||
if (!in_array($a->oCategory->sSlug, ['freenode','shadowrocketids'])) return true;
|
||||
$days = (int)($a->oCategory->aOpt['noindexday'] ?? 0);
|
||||
return $days <= 0 || !$a->created_at->copy()->addDays($days)->isPast();
|
||||
}
|
||||
public static function modified(Articles $a): ?string
|
||||
{
|
||||
return $a->sContentUpdatedAt ? Carbon::parse($a->sContentUpdatedAt)->toAtomString() : null;
|
||||
}
|
||||
public static function page(Request $r): int
|
||||
{
|
||||
$raw = $r->query('page', '1');
|
||||
$keys = array_filter(explode('&', $r->server('QUERY_STRING', '')), fn($p) => urldecode(explode('=', $p, 2)[0]) === 'page');
|
||||
abort_if(count($keys) > 1 || !is_scalar($raw) || !preg_match('/\A[1-9][0-9]{0,5}\z/', (string)$raw), 404);
|
||||
return (int)$raw;
|
||||
}
|
||||
public static function articleMeta(Articles $a, bool $home = false): array
|
||||
{
|
||||
$canonical = $home ? self::url() : self::articleUrl($a);
|
||||
$title = $home ? config('seo.home_title') : self::text($a->sTitle, 250);
|
||||
$description = $home ? config('seo.home_description') : self::text($a->sTitleSub ?: $a->sContent);
|
||||
$schema = [['@context'=>'https://schema.org', '@type'=>$home ? 'WebSite' : 'Article',
|
||||
'name'=>$home ? config('seo.brand') : $title, 'url'=>$canonical]];
|
||||
if (!$home) {
|
||||
$schema[0] += ['headline'=>$title,'mainEntityOfPage'=>$canonical,'datePublished'=>$a->created_at->toAtomString(),
|
||||
'author'=>['@type'=>'Organization','name'=>config('seo.brand'),'url'=>self::url()]];
|
||||
if ($modified = self::modified($a)) $schema[0]['dateModified'] = $modified;
|
||||
if ($a->sThumb) $schema[0]['image'] = str_starts_with($a->sThumb, '/') ? self::url($a->sThumb) : $a->sThumb;
|
||||
$crumbs = [['name'=>'首页','item'=>self::url()]];
|
||||
if ($a->oCategory->oParent) $crumbs[] = ['name'=>self::categoryName($a->oCategory->oParent),'item'=>self::url(self::categoryPath($a->oCategory->oParent))];
|
||||
$crumbs[] = ['name'=>self::categoryName($a->oCategory),'item'=>self::url(self::categoryPath($a->oCategory))];
|
||||
$crumbs[] = ['name'=>$title,'item'=>$canonical];
|
||||
$schema[] = ['@context'=>'https://schema.org','@type'=>'BreadcrumbList','itemListElement'=>array_map(fn($c,$i)=>['@type'=>'ListItem','position'=>$i+1]+$c,$crumbs,array_keys($crumbs))];
|
||||
}
|
||||
return ['title'=>$title.' - '.config('seo.brand'),'heading'=>$title,'description'=>$description,'canonical'=>$canonical,
|
||||
'robots'=>$home || self::indexable($a) ? 'index, follow' : 'noindex, follow','type'=>$home ? 'website' : 'article','schema'=>$schema];
|
||||
}
|
||||
public static function listMeta(string $heading, string $description, string $path, int $page, bool $index = true): array
|
||||
{
|
||||
$url = self::url($path, $page);
|
||||
return ['heading'=>$heading, 'title'=>$heading.($page>1?' · 第'.$page.'页':'').' - '.config('seo.brand'),
|
||||
'description'=>self::text($description), 'canonical'=>$url, 'robots'=>$index?'index, follow':'noindex, follow',
|
||||
'schema'=>[['@context'=>'https://schema.org','@type'=>'CollectionPage','name'=>$heading,'url'=>$url]]];
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
use App\Models\Articles;
|
||||
use App\Services\Editorial\IndexNowNotification;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
final class SeoNotifications
|
||||
{
|
||||
public function changed(Articles $a, bool $deleted = false): void
|
||||
{
|
||||
if (!Schema::hasTable('seo_notifications')) return;
|
||||
$urls = [];
|
||||
if ($deleted || !Seo::public($a)) $urls[] = Seo::articleUrl($a);
|
||||
elseif (Seo::indexable($a)) $urls[] = Seo::articleUrl($a);
|
||||
if ($a->oCategory?->sSlug === 'freenode') $urls[] = Seo::url();
|
||||
if ($a->oCategory) $urls[] = Seo::url(Seo::categoryPath($a->oCategory));
|
||||
$event = $deleted || !Seo::public($a) ? 'delete' : 'update';
|
||||
$key = hash('sha256',json_encode([$a->id,$event,$a->sContentUpdatedAt,$a->sTitle,$a->sContent,$a->sThumb,$a->iStatus]));
|
||||
$this->enqueue($key,$urls,$event);
|
||||
}
|
||||
public function enqueue(string $key, array $urls, string $event = 'update'): void
|
||||
{
|
||||
if (!app()->environment(['production','testing']) || !config('editorial.indexnow_enabled',app()->environment('production'))) return;
|
||||
DB::table('seo_notifications')->insertOrIgnore(['event_key'=>$key,'urls'=>json_encode(array_values(array_unique($urls))),
|
||||
'event'=>$event,'state'=>json_encode(['status'=>'pending','attempts'=>0]),'created_at'=>now(),'updated_at'=>now()]);
|
||||
}
|
||||
public function retry(int $limit = 10): int
|
||||
{
|
||||
$processed = 0;
|
||||
foreach (DB::table('seo_notifications')->orderBy('id')->cursor() as $candidate) {
|
||||
$s = json_decode($candidate->state,true);
|
||||
if (($s['status'] ?? '') !== 'pending' || ($s['next_attempt_at'] ?? 0) > now()->timestamp) continue;
|
||||
DB::transaction(function () use ($candidate,&$processed) {
|
||||
$row = DB::table('seo_notifications')->where('id',$candidate->id)->lockForUpdate()->first();
|
||||
$state = json_decode($row->state,true);
|
||||
if (($state['status'] ?? '') !== 'pending' || ($state['next_attempt_at'] ?? 0) > now()->timestamp) return;
|
||||
$urls = json_decode($row->urls,true);
|
||||
if ($row->event !== 'delete') $urls = array_values(array_filter($urls,function($url) {
|
||||
$path = parse_url($url,PHP_URL_PATH);
|
||||
if (preg_match('~^/a/([a-zA-Z0-9_-]+)\.html$~',$path,$m)) {
|
||||
$a = Articles::where('sSlug',$m[1])->first(); return $a && Seo::indexable($a);
|
||||
}
|
||||
if ($path === '/') return app(ArticlesService::class)->getLatestFreeNodeSlug() !== null;
|
||||
return true;
|
||||
}));
|
||||
$state = app(IndexNowNotification::class)->submit($state,$urls);
|
||||
DB::table('seo_notifications')->where('id',$row->id)->update(['state'=>json_encode($state),'updated_at'=>now()]);
|
||||
$processed++;
|
||||
});
|
||||
if ($processed >= $limit) break;
|
||||
}
|
||||
return $processed;
|
||||
}
|
||||
}
|
||||
Regular → Executable
-1
@@ -12,7 +12,6 @@
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware) {
|
||||
$middleware->append(\App\Http\Middleware\SeoHeaders::class);
|
||||
$middleware->prepend(\Spatie\ResponseCache\Middlewares\CacheResponse::class);
|
||||
$middleware->alias([
|
||||
'doCache' => \Spatie\ResponseCache\Middlewares\CacheResponse::class,
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'dpl' => ['enabled' => env('DPL_AD_ENABLED', true), 'url' => env('DPL_AD_URL', 'https://dp-link.net/')],
|
||||
'fuc' => ['enabled' => env('FUC_AD_ENABLED', true), 'url' => env('FUC_AD_URL', 'https://xn--123-9i9dj97q.com/')],
|
||||
'hn' => [
|
||||
'enabled' => env('HN_AD_ENABLED', true),
|
||||
'url' => env('HN_AD_URL', 'https://hardnerd.net/'),
|
||||
],
|
||||
];
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'telegram_url' => env('COMMUNITY_TELEGRAM_URL', 'https://t.me/clashfreenode'),
|
||||
];
|
||||
@@ -7,5 +7,4 @@
|
||||
'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'),
|
||||
];
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'delivery_enabled' => (bool) env('ILLUSTRATION_DELIVERY_ENABLED', false),
|
||||
'enabled' => (bool) env('RESOURCE_V2_ILLUSTRATIONS_ENABLED', env('LOCAL_ILLUSTRATIONS_ENABLED', env('APP_ENV') === 'local')),
|
||||
'base_url' => env('RESOURCE_V2_URL', 'http://resource.loc:8612'),
|
||||
'credential_file' => env('RESOURCE_V2_CREDENTIAL_FILE'),
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?php
|
||||
return [
|
||||
'brand' => env('SEO_BRAND', env('site_code_short') === 'cfn' ? 'ClashFreeNode' : env('APP_NAME', '网站')),
|
||||
'home_title' => env('SEO_HOME_TITLE', '免费节点与订阅使用指南'),
|
||||
'home_description' => '获取最近更新的免费节点与订阅,查看 Clash、V2ray 客户端入门教程和连接排错指南。资源状态随时间和网络环境变化。',
|
||||
'page_size' => env('page_limit', 10),
|
||||
];
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('articles', fn (Blueprint $table) => $table->timestamp('sDisplayPublishedAt')->nullable());
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('articles', fn (Blueprint $table) => $table->dropColumn('sDisplayPublishedAt'));
|
||||
}
|
||||
};
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::table('articles', function (Blueprint $t) {
|
||||
$t->timestamp('sContentUpdatedAt')->nullable();
|
||||
$t->string('sSeoPolicy', 24)->nullable();
|
||||
$t->string('sResourceStatus', 24)->nullable();
|
||||
$t->unsignedInteger('iResourceCount')->nullable();
|
||||
});
|
||||
Schema::create('seo_notifications', function (Blueprint $t) {
|
||||
$t->id(); $t->string('event_key', 64)->unique(); $t->text('urls');
|
||||
$t->string('event', 16); $t->text('state'); $t->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('seo_notifications');
|
||||
Schema::table('articles', fn (Blueprint $t) => $t->dropColumn(['sContentUpdatedAt','sSeoPolicy','sResourceStatus','iResourceCount']));
|
||||
}
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
[Unit]
|
||||
Description=Process approved illustration deliveries (fna)
|
||||
After=network-online.target
|
||||
[Service]
|
||||
Type=oneshot
|
||||
User=nginx
|
||||
Group=nginx
|
||||
WorkingDirectory=/www/wwwroot/clashfreenode-new.com
|
||||
ExecStart=/usr/bin/php -d memory_limit=512M artisan illustrations:sync-deliveries --no-interaction
|
||||
TimeoutStartSec=300
|
||||
UMask=0022
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
@@ -1,8 +0,0 @@
|
||||
[Unit]
|
||||
Description=Poll approved illustration deliveries (fna)
|
||||
[Timer]
|
||||
OnBootSec=60
|
||||
OnUnitInactiveSec=60
|
||||
Persistent=true
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -4,8 +4,6 @@ # AI 写作与文章关联索引
|
||||
|
||||
发布已采用本站[独立文章 API](../maintenance/EDITORIAL_API.md),不经过ATOM。AI保留项目正文源,通过API保存冻结草稿、取得签名预览、发布确认的hash并核对回执;本索引仍由写作AI同任务维护,API不会自动改写它。
|
||||
|
||||
2026-10-31用户另行授权综合教程每周随机三篇的周期写作与发布,Codex任务已建立,自2026-11-02当周开始。随机计划、额度、幂等台账与执行状态唯一见[周期写作](../maintenance/WEEKLY_TUTORIALS.md);这一授权不扩大为全站重写或其他实例发布。
|
||||
|
||||
本文是写作流程、文章用途及文章关系的唯一维护入口。文章正文保存在各自源文件,数据库是页面实际读取的内容;栏目实现、渲染与备份方法见[教程维护](../maintenance/TUTORIALS.md),SEO项目状态见[SEO清单](../maintenance/SEO_PLAN.md)。不要在这些文档中再复制一份持续更新的文章关系表。
|
||||
|
||||
## 1 写作前先确定读者要完成的任务
|
||||
@@ -27,10 +25,6 @@ ## 1 写作前先确定读者要完成的任务
|
||||
|
||||
自然、准确地表达;必要时用真实操作图、流程图、配置示例。软件版本、下载入口与兼容要求使用当次核对的官方来源;来源核验、页面检查和设备实测分别记录,未做实测不写“实测”。
|
||||
|
||||
### 周期文章的展示时间(2026-10-31)
|
||||
|
||||
用户要求每天北京时间15:00检查周期计划,新文章展示日期从实际发布时间随机向前偏移0~21600秒(含端点)。API在新文草稿中冻结`display_offset_seconds`,首次发布计算独立的`sDisplayPublishedAt`;列表和详情沿原有日期显示样式使用该字段,未设置时使用真实创建时间。实际`created_at`、发布回执及点赞起点不改;重试、旧文编辑和回退不重抽、不改旧文展示时间。`display_time_randomize`只允许新建时设置,默认true,显式false为零偏移。不要把随机时间或内部执行过程写进公开正文。
|
||||
|
||||
### AI 新文章的点赞参数(2026-10-29)
|
||||
|
||||
后续AI通过本站独立文章API**新建文章**时使用以下默认设置,由API在保存草稿时为每篇独立取值并冻结;相同请求重试、查询预览及发布不重新抽取。重写、接管、回退已有文章不重置原参数、点赞数或已完成进度,不自动给现有文章批量补额度。
|
||||
@@ -66,12 +60,10 @@ ## 2 当前文章登记
|
||||
| cfw-linux-legacy | 211 / Linux | Clash Verge Rev 使用教程:Linux 安装、订阅与代理设置 | `/a/m174.html` | [verge-linux.md](tutorials/verge-linux.md);本地API版本5 | Linux桌面入门;#install 包格式与架构,#import 订阅,#terminal 单条curl代理验证;不适用于无桌面的服务器 |
|
||||
| system-proxy-vs-tun | 365 / 综合教程 | 系统代理和 TUN 有什么区别?接管范围、使用选择与排错 | `/a/system-proxy-vs-tun.html` | [system-proxy-tun.md](tutorials/system-proxy-tun.md);本地API版本1 | 桌面代理接管与出口选择;`#choose` 场景选择、`#switch` 切换检查、`#troubleshoot` 排错;三张流程图 |
|
||||
|
||||
这里只登记长期编辑内容及值得复用的稳定资源说明,不逐条收录日更节点或账号文章。稳定入口为 `/`(当前免费节点)、`/freenode`(历史分享归档)、`/client`(入门)、`/advanced`(综合教程);平台入口和名称修改另按项目路由核对,不从名称自行拼接。
|
||||
这里只登记长期编辑内容及值得复用的稳定资源说明,不逐条收录日更节点或账号文章。稳定入口为 `/freenode`(公开免费节点)、`/client`(入门)、`/advanced`(综合教程);平台入口和名称修改另按项目路由核对,不从名称自行拼接。
|
||||
|
||||
2026-10-29部署边界更新:上表10篇已通过本站API迁移到独立test并经用户确认后切到正式cfn,旧URL保留;生产发布以预览实际正文冻结再发布,未用test整库覆盖。test和生产的临时编辑密钥均在迁移后删除,接口默认关闭;后续本地写作继续使用本地API,正式编辑按明确任务与生产绑定启用。实际部署及验收统一见[发布记录](../maintenance/RELEASE_PREFLIGHT_2026-10-28.md#正式切换2026-10-29),上表ID仍为本地ID。
|
||||
|
||||
2026-10-31 SEO发布后,新稿获取当前免费资源优先链接 `/`;需要历史记录时链接 `/freenode`。下表保留旧文实际内链事实,旧栏目仍正常可用,不因入口规则变化虚报旧文正文已改;后续相关编辑时按内容用途维护。
|
||||
|
||||
## 3 已有文章关系
|
||||
|
||||
以下为2026-10-28从本地数据库正文提取并核对源文件的**实际内链**,不是建议列表。箭头表示正文中有从来源到目标的链接;入向关系从本表反查,不另存一份容易失步的反向清单。
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
# FNA_V3 文章推荐广告
|
||||
|
||||
## 当前实现
|
||||
|
||||
2026-10-31按用户新要求新增统一机场推荐表/手机卡片,本地覆盖资源正文旧福云推荐区及所有教程末尾。价格、网址、优惠码的唯一配置与验收见[统一机场推荐](AIRPORT_RECOMMENDATIONS.md)。未部署线上;下列整图广告保持原行为。
|
||||
|
||||
2026-10-31当前正式广告区已改为单张随机展示:DPL、HN、福云三张每次打开/刷新独立等概率选一张,允许连续重复。保留HN新版白字、旧福云侧栏撤除和TG图标。页面缓存保持原逻辑,随机在浏览器执行,不新增接口请求;三张候选存放原生template中,仅选中图片进入活动DOM并加载。详情及回退见本文“单张随机广告”。此前“DPL/FUC未发布”和多图堆叠仅描述历史状态。
|
||||
|
||||
2026-10-28新增FUC(福云)整图广告,顺序DPL→HN→FUC,三张上下各占一整行。FUC参考当前新版 `fuc-new.loc` 的静态源码:HomeController→index.tpl访客转auth/login;登录和用户区使用 `public/fucai192.png` 渐变紫色福字、Cool/Vuexy浅色界面及 `#7367f0` 紫色按钮。旧营销模板仅作“全球网络中继服务,随时随处尽情使用”文案来源。自动审批依据FUC AGENTS禁止运行真实配置Web入口而拒绝直接打开首页,本次未运行该入口或访问FUC线上;实际设计依据为只读模板/CSS/原始Logo。
|
||||
|
||||
图片 `public/images/ads/fuc-ad-site-style-20261028.png`(1962×801),内置image_gen生成;提示词 `codex/output/fuc-ad-site-style-20261028-prompt.txt`,Logo参考归档 `codex/output/fuc-logo-reference-20261028.png`。新增组件 `fuc-article-ad.blade.php`,汇总组件增加FUC显示判断;配置 `advertising.fuc.enabled/url`,支持 `FUC_AD_URL` 覆盖,默认采用GemDocs当前主站 `https://xn--123-9i9dj97q.com/`(福云123.com),不使用旧fuuu.cloud。无外部资源加载、无扫光,整图链接带sponsored/noopener/noreferrer和键盘焦点轮廓。
|
||||
|
||||
FNA_V3本地页面已验收三图加载、顺序和href;桌面各624×255、390px视口各322×131,无横向溢出。截图 `codex/output/fuc-site-style-preview-20261028.png`。未点击落地页,未改文章内旧福云文字、FUC源码/业务数据或线上配置,未提交、推送或部署。
|
||||
|
||||
2026-10-28用户认可DPL网站风格版,并要求HN同样参考网站重设计。本次只读查看 `http://hn.loc/` 当前EZ首页:深炭灰背景、柔和绿紫光晕、渐变品牌字及简洁居中构图。新版 `public/images/ads/hn-ad-site-style-20261028.png`(1962×802)通过内置image_gen参考首页截图和原广告图生成,保留无方框的眼镜H图形及Hardnerd首字母大写,采用首页文案“探索全球网络无限可能”和“了解 HN”。提示词 `codex/output/hn-ad-site-style-20261028-prompt.txt`,参考截图 `codex/output/hn-site-style-reference-20261028.png`;旧纯黑图保留供回退。当前先接入本地供用户看效果;本地实测两图均624×255、加载成功且无横向溢出,页面截图 `codex/output/hn-site-style-preview-20261028.png`;广告位、链接配置与无扫光行为不变,DPL已认可版不变。GemDocs当前HN档案已登记2026-10-27独立上线,旧文“域名停放”属于历史状态;本任务未访问生产,也未将本地广告默认链接改到线上。未提交、推送或部署。
|
||||
|
||||
2026-10-28当前DPL广告按用户要求参考DPL网站重新设计,替换不获认可的蓝白玻璃版。已现场只读查看 `http://dpl.loc/`,并核对 `xb/stellar/src/views/Landing.vue` 与 `landing.css`:深蓝黑底、蓝紫渐变标题、细网格、轨道与悬浮线路卡片。当前图片 `public/images/ads/dpl-ad-site-style-20261028.png`(1962×801),由内置image_gen以首页截图及正确Logo为参考生成;文案“畅连全球网络”“日常访问 · 远程办公 · 在线娱乐”“查看套餐”,线路卡仅显示地区与装饰信号,不带延迟/速度/在线率数字。完整提示词 `codex/output/dpl-ad-site-style-20261028-prompt.txt`,风格参考截图 `codex/output/dpl-site-style-reference-20261028.png`。原蓝白版保留但不再引用。整图链接、焦点轮廓及无扫光行为保留,DPL与HN继续上下满行2.45:1;本地624×255加载回读通过。效果截图 `codex/output/dpl-site-style-preview-20261028.png`。HN未改,DPL源站代码未改,未提交、推送或部署。
|
||||
|
||||
2026-10-27按用户最新要求,仅在文章正文(含免费订阅和使用提示)之后、标签之前保留场景推荐广告区;同日按后续要求增加 HN,与 DPL 共同展示。首页/列表顶部横幅和文章文末轻卡已移除,组件中不再保留这两种分支,样式同步精简。
|
||||
|
||||
当前首页控制器直接展示最新免费节点文章,因此首页也只在同一文章内位置展示该推荐区,不另设顶部广告;分类列表 `/freenode` 无广告组件。
|
||||
|
||||
保留的白色推荐卡缩小内边距、品牌标志、标题和按钮间距;标题取消强制换行,精简说明文字,移除“另一种连接选择”独立小标题。用户最终要求增加卡片高度而恢复之前字号:桌面标题20px、正文与按钮13px、品牌14px,手机标题18px;保留增加后的纵向留白,桌面内边距24px、品牌与标题间距22px、底部区域上间距24px/内边距18px。桌面实测高度约255px,无横向溢出。
|
||||
|
||||
- 模板:`resources/views/components/dpl-article-ad.blade.php`,由 `components/article-ads.blade.php` 汇总 DPL 与 HN,`resources/views/pages/articles/default/show.blade.php` 在正文后引入;同页 CSS 只加载一次。
|
||||
- 样式:`public/css/dpl-article-ad.css`,通过 Blade styles 栈加载,链接带文件修改时间版本以避免旧样式缓存;使用独立类名,适配现有 `nice-dark-mode`。
|
||||
- 品牌素材:`public/images/ads/dpl-logo.svg`,2026-10-27已更正为 DPL 当前源文件 `/Users/hellcat/Documents/GemCodes/xb/stellar/public/favicon.svg`(带三条信号线),与 DPL 前台/邮件使用的视觉一致。原广告误用了旧聊天输出 `2026-10-07/dp-link-net-logo-var-www/outputs/dpl-logo-approved-b-layer-echo/dpl-logo.svg` 中的历史候选,不能作为当前品牌来源;旧广告与该候选的 SHA-256 均为 `fba12420cb7eb84d49a0035a830bf8c3428c6c96908ba6b2e85f929107ae93cd`。现用源文件哈希 `2f94a1311ae15ec9a41681ff288411d9b3f67bbba54f26e5fd8b5c78026c1bff`,图片URL带修改时间,避免缓存旧图。以后从 DPL 品牌维护入口取图,不从旧设计输出取图。
|
||||
- 配置:`config/advertising.php`,`dpl.enabled` 控制显示,`dpl.url` 为 `https://dp-link.net/`。
|
||||
- 点击新窗口打开,链接带 `sponsored noopener noreferrer`。组件没有预加载、远程图片、统计脚本或价格/速度承诺。
|
||||
|
||||
## 本次验证
|
||||
|
||||
当前固定入口为 `http://fna-v3.loc/`。2026-10-27在文章 `/a/fn20261021.html` 回读确认推荐区有 DPL、HN 各一张广告,桌面与390px手机视口无溢出,当前截图在 `codex/output/dpl-original-fonts-taller-card.png`。刷新时临时阻止外部线上资源请求,验证后恢复浏览器原设置。原2026-10-21三款广告验收属于历史状态,不能当作当前投放。
|
||||
|
||||
未提交、推送或部署。未改 FN_B、NodeHub 或 DPL 代码及数据库。其他聊天已有修改保持原样。
|
||||
|
||||
## 调整与回退
|
||||
|
||||
停用可将 `config/advertising.php` 的 `dpl.enabled` 设为 `false`;如启用了配置缓存,按本地运行方式刷新对应缓存。完全撤回时只移除文章正文后 `components.dpl-article-ad` 的 include,再删除本广告专属模板、配置、CSS及素材;勿回滚其他并行修改。
|
||||
|
||||
## HN 接入(2026-10-27)
|
||||
|
||||
- HN模板:`resources/views/components/hn-article-ad.blade.php`;Logo复制自HN当前配置指向的 `public/brand/hn/logo.svg`(独立工作树 `/Users/hellcat/Documents/Codex/2026-10-12/ji-cha/work/dpl-hn`),绿色眼镜H标志,不复用DPL或旧tpl-a设计素材。
|
||||
- 配置:`advertising.hn.enabled`、`advertising.hn.url`;本地环境默认 `http://hn.loc/`,可通过 `HN_AD_URL` 显式设置。生产未配置地址则不展示HN卡片:hardnerd.net只核实到停放状态,未把它当作已上线落地页。
|
||||
- 用户最新确认改为所有屏幕上下排列,DPL、HN各占一整行;不再使用桌面双列。原并排验收为历史记录:1280px视口实测两列343px、两卡等高约283px;390px手机视口单列322px,两卡均无溢出。Logo实际加载成功,DPL链接与HN本地链接分别回读正确。未打开落地页、未写HN数据、未发布。
|
||||
- 当前截图:`codex/output/dpl-hn-ads.png`。仅在原有文章推荐区增加HN,不恢复顶部横幅、侧栏或文末投放。
|
||||
|
||||
## HN整图广告(2026-10-27)
|
||||
|
||||
用户要求HN改为整张图片,保持原广告位尺寸。当前 `hn-article-ad.blade.php` 使用整图链接,文字、Logo及按钮全部在图片内,不再叠加HTML标题/按钮。图片为 `public/images/ads/hn-ad-20261027.png`,由内置 image_gen 生成,使用当前HN Logo为参考;完整提示词在 `codex/output/hn-ad-20261027-prompt.txt`。画面为黑色/荧光绿网络路径主题,文案“探索全球网络”“hardnerd · 网络服务”“了解 HN ↗”,无价格或速度承诺。
|
||||
|
||||
桌面1280px实测HN与DPL均343×283px(四舍五入),390px手机视口HN为322×248px,与此前HN卡片接近。整图使用 contain 保证图内文字不被裁切,空余部分延续黑底。链接仍为HN本地预览入口。加载及无溢出已确认;预览截图 `codex/output/hn-full-image-ad-preview.png`。DPL模板未改。
|
||||
|
||||
验证期间本机Vite5187进程已停止,已按现有固定入口配置恢复原回环监听;未新增登录项或扩大监听。未提交、推送、部署。
|
||||
|
||||
2026-10-27最终布局:DPL和HN上下各占一整行;HN后续已重新生成为2.45:1横版,铺满行宽,手机按图片比例缩放,不再保留旧版黑边。
|
||||
|
||||
## HN横版满幅更新(2026-10-27,当前)
|
||||
|
||||
按用户要求重新设计横版,非拉伸旧图。内置 image_gen 以原整图为参考生成1962×801px图片,当前文件 `public/images/ads/hn-ad-wide-20261027.png`;完整最终提示词在 `codex/output/hn-ad-wide-20261027-prompt.txt`。旧接近方形图保留为历史产物,不再在页面引用。
|
||||
|
||||
广告位宽高比2.45:1,图片cover铺满,去掉contain及固定手机高度,不再出现左右补黑。实测当前桌面624×255px,与原行高一致;390px手机视口322×131px,按相同比例展示,无溢出。当前页面截图 `codex/output/hn-wide-ad-preview.png`。DPL广告未变,HN仍使用原本地链接;未发布。
|
||||
|
||||
## HN突出Logo版本(2026-10-27,当前引用)
|
||||
|
||||
用户认可眼镜H标志并要求突出Logo,再次使用内置 image_gen 以官方Logo为参考制作。当前整图 `public/images/ads/hn-ad-logo-hero-20261027.png`(1959×803),大Logo占左侧主要面积,右侧hardnerd品牌字与“以硬核,连接世界”,弱化背景纹理,保留黑绿配色与整图链接。最终提示词 `codex/output/hn-ad-logo-hero-20261027-prompt.txt`,页面效果 `codex/output/hn-logo-hero-preview.png`。
|
||||
|
||||
广告位保持原横版2.45:1,当前本地实测624×255px,新图片加载成功且铺满。旧网络路径横幅仅保留作历史产物,页面不再引用。DPL与原有广告位置、链接配置均未改,未发布。
|
||||
|
||||
## HN纯黑独立图形版(2026-10-27,当前)
|
||||
|
||||
按用户纠正去掉Logo的圆角方块,只使用白色H与绿色眼镜图形,整张纯黑背景,取消光晕、纹理、几何背景和按钮底块。当前整图 `public/images/ads/hn-ad-pure-black-20261027.png`(1962×801),通过内置 image_gen 参照官方Logo重新设计;完整提示词 `codex/output/hn-ad-pure-black-20261027-prompt.txt`。旧版只作历史产物,不再引用。
|
||||
|
||||
已本地页面验证新图加载、624×255px原横幅尺寸、广告位背景为rgb(0,0,0);当前截图 `codex/output/hn-pure-black-preview.png`。Logo SVG原始文件未改,仅广告图去掉图标容器。DPL未变,未提交、推送或部署。
|
||||
|
||||
## HN协调构图版(2026-10-27,当前)
|
||||
|
||||
用户指出此前把“大Logo、纯黑”执行得过于绝对,要求重新设计而非机械照搬。当前通过内置 image_gen 重新构图:适中独立眼镜H标志与hardnerd品牌字组合,柔和深墨绿背景,低对比弧线与留白,主文案“以硬核,连接世界”,右下角小按钮。无圆角Logo容器,不再使用巨型图标或空白纯黑背景。
|
||||
|
||||
当前图片 `public/images/ads/hn-ad-balanced-20261027.png`(1962×801);完整提示词 `codex/output/hn-ad-balanced-20261027-prompt.txt`;当前页面效果 `codex/output/hn-balanced-preview.png`。本地已回读新图加载成功,广告位维持624×255px,DPL与链接未变。旧版保留作历史产物、不再引用。未部署。
|
||||
|
||||
## 当前选用版本
|
||||
|
||||
2026-10-27用户最终选择“纯黑背景版本”,当前页面重新引用 `public/images/ads/hn-ad-pure-black-20261027.png`,即独立H/眼镜图形、无Logo方框的纯黑横幅。协调构图版保留为候选,不再引用。尺寸、位置和链接不变,未部署。
|
||||
|
||||
## HN纯黑精简排版(2026-10-27,当前)
|
||||
|
||||
按用户要求同时缩小Logo和文字,调整字号层级与行距,品牌字改用较轻字重,整体居中组合、文案左对齐,增加留白,保持纯黑背景、无Logo容器和2.45:1横幅。最终图片 `public/images/ads/hn-ad-refined-black-v2-20261027.png`,通过内置 image_gen 以原纯黑版为参考制作,并作一次组合占比校准;完整两阶段提示词 `codex/output/hn-ad-refined-black-20261027-prompt.txt`。当前页面截图 `codex/output/hn-refined-black-preview.png`,DPL及链接不变,未部署。
|
||||
|
||||
2026-10-27用户要求品牌名全大写:通过内置image_gen仅替换图内wordmark为HARDNERD,当前文件 `public/images/ads/hn-ad-uppercase-20261027.png`,提示词 `codex/output/hn-ad-uppercase-20261027-prompt.txt`;布局、独立图形、文案与纯黑背景保留。同步图片替代文字,未部署。
|
||||
|
||||
2026-10-27用户将品牌名改为首字母大写Hardnerd,并要求重新协调字体、字号和间距。当前图片 `public/images/ads/hn-ad-titlecase-20261027.png`:品牌字/灰色中文副标题/绿色CTA分层,重新对齐组合,保留纯黑背景及无框眼镜H标志;由内置image_gen参照大写版重新排版,完整提示词 `codex/output/hn-ad-titlecase-20261027-prompt.txt`,效果截图 `codex/output/hn-titlecase-preview.png`。仍为本地接入,未部署。
|
||||
|
||||
2026-10-27HN广告增加与网站文章缩略图一致的鼠标扫光:沿用core-ui.css的shine关键帧、0.85秒时长、白色20%透明渐变、-25度斜角,伪元素不接收点击。不额外引入JS或改动其他图片;键盘焦点同样触发,减少动态效果偏好下禁用。浏览器实测hover为true、animationName为shine、duration为0.85s、pointer-events为none;图片为Hardnerd首字母大写新版。未部署。
|
||||
|
||||
2026-10-27用户反馈HN横幅扫光过快,仅该广告的时长从0.85秒改为1.6秒,使用ease-in-out缓动;网站其他图片不变。
|
||||
|
||||
2026-10-27用户最终要求去掉HN广告扫光,已移除扫光伪元素、hover/focus动画及对应减少动态效果规则,仅保留静态整图链接和键盘焦点轮廓。网站其他图片扫光不变。
|
||||
|
||||
## 资源正文引导与TG入口(2026-10-31)
|
||||
|
||||
按用户要求将免费节点(freenode)和免费苹果ID(shadowrocketids)正文中“点击加入我们的tg频道…”与“点击关注我们的github仓库…”两段移除展示,连带其后的空段。`ResourceArticlePresentation::body` 仅在这两个栏目匹配已知引导文案;不改文章存储、订阅字段、苹果ID内容、其他栏目或正常教程链接,所以后续日更同样生效。
|
||||
|
||||
导航使用 `components.telegram-link`:桌面右侧GitHub前增加纸飞机SVG,手机右上角同样提供入口,36px点击区、20px图标、说明标签和新窗口安全属性;不加载远程图标。链接沿用当前文章已有的 `https://t.me/clashfreenode`,配置 `community.telegram_url` / `COMMUNITY_TELEGRAM_URL`。不点击频道,不发送消息。原GitHub导航入口保留。
|
||||
|
||||
生产模板由现场版本定点修改,本地额外的机场推荐功能未随任务发布。应用提交 `de6b931823b3fe49811d1026393c38f073480054`,分支 `codex/tg-header-20261031`,恢复点 VPS-003 `/root/backups/cfn-tg-header-20261031`。回滚只撤销本次五个应用文件增量,保留其他聊天后续提交。单测2项4断言通过,32项服务器HTML/配置检查通过、0失败,覆盖两个栏目的最新/最早文章及首页/列表/教程。已完成服务器侧验收,未做线上页面验收;回执见 `output/tg-header-20261031/verification.json`;文档同步提交仅改本专题。
|
||||
|
||||
## 单张随机广告(2026-10-31)
|
||||
|
||||
用户确认每次打开只随机展示三张之一,并要求不影响页面渲染/速度。组件 `components.article-ads` 使用配置启用、URL存在、素材存在的候选;正式补齐DPL/FUC配置及对应网站风格素材,HN使用已发布refined版。JS在浏览器独立抽样,页面HTML缓存不固定选择;返回/前进命中bfcache时通过pageshow.persisted重新抽取,无定时轮播和接口请求。不保证每次不同。
|
||||
|
||||
所有图片候选放在原生template内,未选中图片不进入活动DOM、不请求;仅克隆一个链接+图片。脚本源 `public/js/random-article-ad.js` 不到1KB,内联进已有缓存HTML,不额外发起JS请求。独立CSS `public/css/random-article-ad.css` 替代旧HN广告CSS,总体仍为单个广告样式请求,2.45:1比例和圆角保留。关闭JavaScript时noscript展示首个有效候选;全部停用或缺图时无广告。不做访问统计或追踪。
|
||||
|
||||
配置沿用 `advertising.{dpl,hn,fuc}.enabled/url`;生产三者链接分别dp-link.net、hardnerd.net、福云123.com。DPL_AD_ENABLED / HN_AD_ENABLED / FUC_AD_ENABLED 可独立停用。线上文章模板定点切换为汇总组件,没有发布本地额外机场推荐逻辑。未改数据库、响应缓存策略或Vite构建。
|
||||
|
||||
应用提交 `cb8cd8467a8a61ef09deaa9a24c78e4c4dbed3f4` 已Git推送 `codex/random-ad-20261031` 并正式检出;恢复点 VPS-003 `/root/backups/cfn-random-ad-20261031`。回滚只撤本批增量,可先将show模板切回独立HN组件;不得整库/整站回退覆盖并行更新。
|
||||
|
||||
本地真实Blade组件隔离页已在浏览器验收:桌面760×310、390视口342×140,无横向溢出;活动DOM始终单图,观察到HN→福云变化,CDP网络仅一次选中福云图片请求。3项脚本测试通过,覆盖三个抽样区间、bfcache恢复、单个/零候选。截图与证据见 `output/random-ad-20261031/`。56项生产服务器HTML/资源检查全部通过,回执 `verification.json`;已完成服务器侧验收,未做线上页面验收。文档后续部署不改变应用文件。
|
||||
@@ -1,7 +1,5 @@
|
||||
# FNA_V3 独立文章 API
|
||||
|
||||
2026-10-31新增[经白色机的固定发布封装](EDITORIAL_RELEASE.md):周期写作使用本机SSH经白色机到业务服务器,由`editorial:release`进程调用本页原API路由。公网编辑API保持关闭,进程权限不落盘;无需逐次修改生产.env或启用公网密钥。以下HTTP契约继续有效,服务器命令复用同一套验证、事务和回执。
|
||||
|
||||
状态:2026-10-27本地实施并联调;2026-10-29已随独立test预览提交、推送和部署,10篇教程真实API迁移通过后,test编辑接口已关闭且临时密钥移除。正式站现已切换,正式10篇教程亦通过同一API迁移;生产临时密钥用后删除,编辑接口默认关闭,后续明确写作/发布任务再按绑定环境启用并完成后关闭。test执行和回执沿[发布记录](RELEASE_PREFLIGHT_2026-10-28.md#当前门槛先test预览确认后再切正式2026-10-29),日常本地调用不受影响。用户明确采用本站独立接收 API,不经过 ATOM;不新增 ATOM 依赖。入口为 `http://fna-v3.loc/api/editorial/v1`,生产地址尚未指定。
|
||||
|
||||
## 职责与数据
|
||||
@@ -10,7 +8,7 @@ ## 职责与数据
|
||||
|
||||
项目正文源保留可编辑稿;`editorial_drafts`保存收到并渲染后的冻结版本,发布读取该快照,不临时重新读取文件。`articles`为公开显示数据,草稿不写入它。`editorial_documents`按稳定`content_key`绑定本站文章;`editorial_versions`保留已发布版本和首次接管旧文的基线版本0;`editorial_publications`保存独立发布回执及后续处理状态。图片元信息在`editorial_assets`。
|
||||
|
||||
新API不调用旧接收器,不发送旧Telegram通知或ATOM请求。2026-10-31起编辑文章新增/实质修改后具有独立IndexNow回执与失败重试,见[教程SEO通知](EDITORIAL_INDEXNOW.md);本地和测试不真实外发。旧资源接收接口继续沿用原流程,不在本次改造范围;普通编辑API拒绝免费节点与小火箭ID两个自动资源栏目。旧接口/人工直接编辑同一文章会造成草稿基线变化,新API发布时返回409,不能静默覆盖并行修改。
|
||||
新API不调用旧接收器,不发送旧Telegram通知、IndexNow提交或ATOM请求。旧资源接收接口继续沿用原流程,不在本次改造范围;普通编辑API拒绝免费节点与小火箭ID两个自动资源栏目。旧接口/人工直接编辑同一文章会造成草稿基线变化,新API发布时返回409,不能静默覆盖并行修改。
|
||||
|
||||
## 凭据与环境
|
||||
|
||||
@@ -116,9 +114,9 @@ ### 3 发布确认过的版本
|
||||
|
||||
- `status: published`:本次内容已写入本站公开文章表;这是所调用环境的状态,本地成功不代表生产成功。
|
||||
- `articles`:各文章的`content_key`、`article_id`、`revision`和URL。
|
||||
- `effects.cache/search/sitemap/indexnow`:各后续处理的独立结果。搜索暂时失败不撤销已提交正文,返回`pending`,不能重发正文来弥补搜索失败。
|
||||
- `effects.cache/search/sitemap`:各后续处理的独立结果。搜索暂时失败不撤销已提交正文,返回`pending`,不能重发正文来弥补搜索失败。
|
||||
|
||||
后续处理为刷新本站响应缓存与热门数据缓存、同步本站搜索,以及使用数据库驱动的sitemap。缓存未刷新时sitemap也标记pending。IndexNow以独立`effects.indexnow`记录,不与sitemap结果混用,见[教程SEO通知](EDITORIAL_INDEXNOW.md)。
|
||||
后续处理为刷新本站响应缓存与热门数据缓存、同步本站搜索,以及使用数据库驱动的sitemap。缓存未刷新时sitemap也标记pending。不调用搜索引擎主动提交。
|
||||
|
||||
### 4 查询、重试与回退
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# 编辑文章 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必须一致,不跟随重定向,不从文章输入指定外部推送目标。
|
||||
|
||||
## SEO整体升级后的现行合同
|
||||
|
||||
2026-10-31随 `7c11ca77` 保留原编辑发布回执,并在实质更新通知中追加所属栏目/父栏目;日更资源改为通知稳定首页和栏目,新增持久出站队列及业务服务器重试,取消旧接收器无差别直推快照。首页及9个栏目真实通知返回200,旧回执不变。完整实现、边界及恢复点统一见[SEO实施记录](SEO_IMPLEMENTATION_2026-10-31.md);下面较早发布记录仅描述各自批次。
|
||||
|
||||
## 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缓存,保留新通知实现、内容及回执。
|
||||
@@ -1,56 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
# 经白色机的固定文章发布流程
|
||||
|
||||
## 设计
|
||||
|
||||
维护脚本:`tools/editorial/release.py`(本机传输)、`tools/editorial/ssh_askpass.py`(只向OpenSSH认证组件提供登记密码)、`editorial:release`(业务服务器命令)。现有文章API负责资产、草稿、版本、链接校验、原子发布、回执和搜索缓存同步,契约见[EDITORIAL_API.md](EDITORIAL_API.md)。本封装不另写文章SQL,不经ATOM。
|
||||
|
||||
固定路线:本机SSH→VPS-001白色机→VPS-003 `/www/wwwroot/clashfreenode-new.com`。SSH强制ProxyCommand、既有主机密钥核验,禁用配置文件和已有连接复用,不接受自定义目标/命令,也没有直连回退。白色机仅转发SSH,不保存稿件、凭据或运行定时器。
|
||||
|
||||
远端固定以nginx运行`php artisan editorial:release`,命令校验production环境、真实项目路径和base_url。JSON由stdin传递。服务器内通过Laravel HTTP Kernel调用原有API路由,经过原认证、校验和控制器;无需本机或公网HTTP。运行身份使用现有服务器权限,不改SSH策略或管理员凭据。
|
||||
|
||||
进程内临时API认证值只保存在内存,寿命10分钟,每次内部请求后恢复原配置,结束/断开杀进程即消失;不写.env或公用credential.json,不重载配置、不启用公网编辑入口。签名预览也在同一命令内渲染,公网API关闭时这些预览URL不可从外部打开。旧API的手动操作契约仍保留,周期发布改用本封装。
|
||||
|
||||
## 调用
|
||||
|
||||
本机在项目目录执行,输出文件包含私有预览,权限600,不提交Git:
|
||||
|
||||
```sh
|
||||
python3 tools/editorial/release.py catalog --input /私有目录/empty.json --output /私有目录/catalog.json
|
||||
python3 tools/editorial/release.py source --input /私有目录/source.json --output /私有目录/source-result.json
|
||||
python3 tools/editorial/release.py prepare --input /私有目录/bundle.json --output /私有目录/prepared.json
|
||||
python3 tools/editorial/release.py review --input /私有目录/id.json --output /私有目录/review.json
|
||||
python3 tools/editorial/release.py publish --input /私有目录/publish.json --output /私有目录/published.json
|
||||
python3 tools/editorial/release.py status --input /私有目录/id.json --output /私有目录/status.json
|
||||
```
|
||||
|
||||
- empty.json为`{}`;source.json为`{"article_id":真实整数ID}`。catalog/source只读,不创建release。
|
||||
- bundle.json含`release_id`(UUID)、`articles`(原API字段)及可选`assets`。每个asset为`{"name":"diagram","base64":"实际PNG/JPEG/WebP/GIF字节的base64"}`,正文/封面用`file:diagram`占位;程序上传后替换为asset引用。单图≤8MiB、最多10图、总输入≤48MiB;不接收SVG,既有本站SVG可以按真实路径引用。新画的技术SVG可在本地渲染为PNG后通过资产API上传,无需为了配图部署程序。
|
||||
- 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/IndexNow状态通过(无需通知的IndexNow skipped视为完成),且IndexNow通知为done或明确skipped;`published_pending`代表正文已提交但后续仍待处理,退出码2,不能据此另发正文。返回`published_at`来自服务器真实发布事务时间。
|
||||
|
||||
本机工具只输出结果文件路径及状态,不回显SSH认证、正文或预览。SSH断开、超时或非JSON输出都保存未知/失败状态,不自动重放写入;用原release_id查status。不存在草稿时沿原bundle恢复prepare。
|
||||
|
||||
## 状态与恢复
|
||||
|
||||
服务器台账`storage/app/private/editorial-releases/UUID.json`,权限600;原子替换并fsync,文件锁防并发,系统会在进程退出时释放锁。保存IDs先于写入API。台账记录prepared/reviewed/publishing/complete或published_pending;唯一发表事实仍以API事务回执为准。服务器台账损坏/丢失时须从原请求UUID和API回执恢复,不能另起ID重发。
|
||||
|
||||
回读校验包括真实版本、标题、摘要、slug、栏目、封面、正文哈希及内容寻址图文件SHA;点赞参数随结果返回供确认。文章完整HTTP页面及外部链接状态按任务另外验证,不能把内部Kernel渲染说成外部网络/浏览器验收。没有真实新稿时不向正式站发布演练文章。
|
||||
|
||||
上线前仅执行`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,66 +0,0 @@
|
||||
{
|
||||
"base": "4fb57e494de1796d314698c6317eb58bc1acbed1",
|
||||
"commit": "3a62bccbcdb2da0630e8c192b5b758c264624514",
|
||||
"branch": "codex/editorial-release-20261031",
|
||||
"files": [
|
||||
"AGENTS.md",
|
||||
"app/Console/Commands/EditorialRelease.php",
|
||||
"app/Http/Controllers/Api/Editorial/EditorialController.php",
|
||||
"app/Http/Middleware/EditorialAuthentication.php",
|
||||
"app/Models/Articles.php",
|
||||
"app/Services/Editorial/ProcessApi.php",
|
||||
"app/Services/Editorial/Publisher.php",
|
||||
"app/Services/Editorial/ReleaseRunner.php",
|
||||
"database/migrations/2026_10_31_150000_add_article_display_timestamp.php",
|
||||
"docs/content/WRITING.md",
|
||||
"docs/maintenance/EDITORIAL_API.md",
|
||||
"docs/maintenance/EDITORIAL_RELEASE.md",
|
||||
"docs/maintenance/EDITORIAL_RELEASE_2026-10-31.md",
|
||||
"docs/maintenance/WEEKLY_TUTORIALS.md",
|
||||
"tests/Feature/EditorialApiTest.php",
|
||||
"tests/Feature/EditorialReleaseTest.php",
|
||||
"tools/editorial/release.py",
|
||||
"tools/editorial/ssh_askpass.py",
|
||||
"tools/editorial/test_weekly.py",
|
||||
"tools/editorial/weekly.py"
|
||||
],
|
||||
"backup_directory": "/root/backups/cfn-editorial-release-20261031",
|
||||
"backup": {
|
||||
"articles": 188,
|
||||
"tables": 23,
|
||||
"backup_sha256": "b1ccc19cdc5e43a85ad85cf9b656ef2da97cbb07b23d49283078004e85d292ac"
|
||||
},
|
||||
"checks": {
|
||||
"environment": "production",
|
||||
"editorial_base": "https://clashfreenode.com",
|
||||
"public_api_enabled": false,
|
||||
"credential_file_exists": false,
|
||||
"articles": 188,
|
||||
"article_core_preserved": true,
|
||||
"display_values": 0,
|
||||
"process_api_catalog": true,
|
||||
"editorial_articles": 10,
|
||||
"tags_preserved": true,
|
||||
"http": {
|
||||
"/": 200,
|
||||
"/advanced": 200,
|
||||
"/a/system-proxy-vs-tun.html": 200,
|
||||
"/api/editorial/v1/catalog": 503
|
||||
},
|
||||
"local_wrapper_through_white_host": true
|
||||
},
|
||||
"head": "3a62bccbcdb2da0630e8c192b5b758c264624514",
|
||||
"status": "M resources/views/components/generated-tags-cloud.blade.php\n?? data.ms/",
|
||||
"tested_new_production_publication": false,
|
||||
"tests": {
|
||||
"php_tests": 30,
|
||||
"php_assertions": 268,
|
||||
"python_tests": 5
|
||||
},
|
||||
"automation": {
|
||||
"id": "fna",
|
||||
"check": "15:00 Asia/Shanghai daily",
|
||||
"weekly_target": 3,
|
||||
"starts_on": "2026-11-02"
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
# 文章发布封装实施记录(2026-10-31)
|
||||
|
||||
已通过Git提交、推送并部署正式cfn。功能HEAD `3a62bccbcdb2da0630e8c192b5b758c264624514`,基线 `4fb57e494de1796d314698c6317eb58bc1acbed1`,分支 `codex/editorial-release-20261031`。后续仅记录文档的提交不改变此功能版本。
|
||||
|
||||
范围:固定本机SSH→白色机VPS-001→业务服务器VPS-003,服务器进程内调用原有文章API,恢复台账/发布回读,新文独立展示时间,以及本机每周三篇、每日15:00检查的计划工具。没有部署白色机写作任务,没有修改SSH/网络/原定时器,没有恢复test。
|
||||
|
||||
## 验证
|
||||
|
||||
- 隔离SQLite业务测试30项、268断言通过,覆盖原API、点赞、发布封装:冻结草稿、图片上传和SHA、真实模板渲染、未review拒发、并行版本冲突、锁互斥、过期权限拒绝、失败后配置恢复、已提交但响应丢失后按原UUID恢复、搜索pending只重试同步、正文回读检测外部改动。新文随机展示偏移冻结、0~21600秒范围、真实创建/年度点赞时间不改、旧文修改保留展示日期均通过。
|
||||
- Python5项测试通过:三篇随机不同日期/每日15:00、漏跑回补、同日不连发、未决任务恢复和真实时间计数、跨周不积累未开始欠稿、固定白色机转发及主机核验。
|
||||
- 本地指定可空字段迁移已完成;第一次沙箱连接MySQL被拒,按授权提升后执行成功。
|
||||
- 正式站188篇文章的ID、slug、标题、正文、封面、栏目、创建/更新日期逐项保持;新增展示字段均为空,旧文显示不变。既有生成标签模板哈希和`data.ms/`并行目录保留。
|
||||
- 真实业务服务器命令以nginx读取10篇编辑文章目录通过;本机新release.py经固定白色机链路调用同一目录也通过,未访问本机线上HTTP。
|
||||
- 服务器侧HTTP:首页、/advanced、系统代理/TUN文章200;公网编辑目录503(保持关闭),公用编辑密钥文件不存在。进程内认证没有写入.env或凭据文件。
|
||||
|
||||
部署首次迁移因Git检出采用私有备份umask导致新代码文件不可被nginx读取,已自动回退;随后仅修正本次代码文件及路径的正常读取权限,沿原恢复点重试成功,私有配置/备份权限未放宽。未重置数据库或数据。
|
||||
|
||||
## 回滚与边界
|
||||
|
||||
私有恢复点位于VPS-003 `/root/backups/cfn-editorial-release-20261031/`:Git bundle、原HEAD/工作区状态、标签模板原件、23表一致性数据库备份、文章核心字段快照、提交及验收回执。正常代码回退检出上述基线并清响应缓存,保留新增可空列与既有文章/发布历史;不执行drop列或整库覆盖。暂停周期任务使用automation_update ID `fna`。
|
||||
|
||||
调度已更新为每周三篇、北京时间每天15:00,自2026-11-02当周开始;首轮自动写作未执行。为避免污染正式内容,本次没有在生产发布演练文章;端到端写入/恢复在隔离测试验证,生产验证为真实SSH、命令、API目录和服务器HTTP。已完成服务器侧验收,未做线上页面验收。精确回执见[JSON](EDITORIAL_RELEASE_2026-10-31.json)。
|
||||
@@ -1,40 +0,0 @@
|
||||
# Hardnerd 广告正式发布 · 2026-10-30
|
||||
|
||||
用户明确要求把此前Hardnerd广告放上去并发布,暂停后已恢复授权。此次只发布HN,不携带DPL/FUC广告或其他本地未提交功能。
|
||||
|
||||
## 当前实现
|
||||
|
||||
- 素材:`public/images/ads/hn-ad-refined-20261031.png`,1964×801,SHA-256 `f7af72fd5074908418ffaf7f634ce620e8bb14b6029931ff06ab86ac7c95fe2f`;采用此前参考HN网站完成的深炭灰、绿紫光晕、渐变Hardnerd品牌字、独立眼镜H版本,不是旧纯黑版。
|
||||
- 位置:文章正文之后、标签之前,首页当前展示最新文章时同样显示;栏目列表不增加广告。满行宽高比2.45,圆角12px,无扫光,保留键盘焦点轮廓。
|
||||
- 模板:`components/hn-article-ad.blade.php`,独立加载`public/css/hn-article-ad.css`一次;生产文章模板直接引入HN组件,不调用本地DPL/HN/FUC汇总组件。
|
||||
- 生产`config/advertising.php`仅包含HN配置,`HN_AD_ENABLED`默认true,`HN_AD_URL`默认`https://hardnerd.net/`。链接新窗口打开,含`sponsored noopener noreferrer`。本地保留其他广告配置及`hn.loc`开发落地页。
|
||||
|
||||
## Git 发布与验收
|
||||
|
||||
生产原提交`a5c5540b977eec4035ba64c1ffc1fa6b6f682152`;基于该提交建立隔离工作区,仅提交5个应用文件,推送既有`tom/fn_b.git`新分支`codex/hn-ad-20261030`,正式目录`/www/wwwroot/clashfreenode-new.com`检出功能提交`f0a0f34d8b687f1286d82e1f26ff72619b11a9e1`。现有未提交`generated-tags-cloud.blade.php`逐字保留,未触碰`data.ms`或其他实例。无需重建全站前端构建产物、数据库迁移或修改Nginx、调度、Resource服务。
|
||||
|
||||
以正式nginx身份清理Blade/响应缓存后,25项服务器侧验收通过、0失败:首页、最新文章`fn20261030`和系统代理/TUN教程各出现一次HN,CSS仅加载一次,链接及rel正确,位置在正文后标签前;`/freenode`列表无新增HN。图片/CSS的正式HTTPS响应200、类型正确、完整SHA与提交素材一致;未携带DPL/FUC素材。回执见`output/hn-ad-release-20261030/release.json`与`verification.json`。
|
||||
|
||||
已完成服务器侧验收,未做正式线上页面验收或打开HN落地页。本文档后续同步提交只更新文档,不改变已验收应用文件。
|
||||
|
||||
## 恢复与停用
|
||||
|
||||
恢复包:VPS-003 `/root/backups/cfn-hn-ad-20261030`,含发布前Git bundle、原HEAD/status、并行差异、原文章模板、发布及验收回执;目录0700,私密回执0600。
|
||||
|
||||
单独停用可在生产环境设置`HN_AD_ENABLED=false`,按当前配置缓存方式刷新配置,再以nginx身份清响应缓存;不要禁用HN业务网站或撤回其他广告。代码回退先检查有无后续提交,仅撤回本次HN配置/组件/CSS/图片及show模板中的HN include;不得整份覆盖新文章模板或回退之后发布的其他功能。
|
||||
|
||||
## 广告文案定点更新(2026-10-30)
|
||||
|
||||
用户指定将底部“了解 HN ↗”替换为“硬核专线架构,品质网络体验”。内置image_gen以原图为编辑目标,仅替换底部绿色文案并去除箭头,保留品牌图形、字形、主副标题和背景。新素材路径/尺寸/hash见当前实现;完整提示词 `output/hn-ad-release-20261030/quality-text-prompt.txt`,旧图保留回退。模板替代文字同步。
|
||||
|
||||
应用提交48a97f2820e3549580d3c7d1dff79197a9d0431e已推送codex/hn-ad-copy-20261030并在正式cfn检出;只增加新版图片和更新HN组件引用。24项服务器检查全部通过,含正式图片HTTPS完整SHA及页面引用/尺寸/链接/位置;没有HN业务站部署。回执 `output/hn-ad-copy-20261030/release.json` / `verification.json`;恢复点 `/root/backups/cfn-hn-ad-copy-20261030`。后续文档提交不改应用文件。已完成服务器侧验收,未做线上页面验收。
|
||||
|
||||
## 版式精简与侧栏撤广告(2026-10-31)
|
||||
|
||||
按用户指定删除HN底部绿字,白色文案改为“硬核架构,品质专线,全球网络畅通无阻”,两行品牌/文案重新居中并协调字号、字距与留白。内置image_gen编辑,最终提示词 `output/hn-ad-refine-20261031/prompt.txt`;当前图片见上表,旧文件保留恢复。
|
||||
|
||||
同时将 `components/banners.blade.php` 改为空输出组件,撤下首页、文章与列表的旧福云侧栏广告,包括“广告”标题及卡片。保留原调用避免影响其他布局,热门标签组件不变;未删除历史图片或改动FUC业务站。
|
||||
|
||||
基于现场HEAD `77f9b09c58b46ef2bbe0882ec89194bf25aa82cd` 构造隔离增量,应用提交 `6c94ecbd0bbfac229a63d650d95f80df608817b0` 已推送 `codex/hn-ad-refine-20261031` 并正式检出。仅三个应用文件;并行生成标签模板、data.ms、public/images/editorial与其他已发布功能保留。恢复点 `/root/backups/cfn-hn-ad-refine-20261031` 包含发布前Git bundle、tracked差异与回执。
|
||||
|
||||
清理nginx身份视图/响应缓存后完成31项服务器验收、0失败:首页、最新文章fn20261031、教程和列表均无旧福云图片及广告标题;HN新图、替代文案、位置、链接、尺寸和完整HTTPS SHA正确。最初检查错误地将热门标签共用CSS类当作广告残留,核对HTML后修正为广告图片/标题判据。回执 `output/hn-ad-refine-20261031/release.json` / `verification.json`。已完成服务器侧验收,未做线上页面验收。此次未发布HN业务站首页的本地调整。
|
||||
@@ -1,11 +0,0 @@
|
||||
# 插画交付接收
|
||||
|
||||
协议与画师操作唯一正文:[Resource交付说明](/Users/hellcat/Documents/GemCodes/resource.loc/v2/docs/ILLUSTRATION_DELIVERY.md)。
|
||||
|
||||
本项目新增 `illustrations:sync-deliveries`,开关 `ILLUSTRATION_DELIVERY_ENABLED=false` 默认关闭。VPS-003正式目录运行fna-illustration-delivery.timer(nginx,每分钟)。复用已有消费者凭据和LocalIllustrations下载/原子清单能力:只缓存本批资产,不执行全量旧文章同步;先验证所有交付资产已在清单/静态目录中,哈希一致才ACK;失败下轮重试,不重分配既有文章、不删除图片。没有新批次时只查交付队列,不下载图池。页面请求不调用该任务。
|
||||
|
||||
Resource持有唯一批次状态,FNA不复制完整提示词或私有原稿。Resource未完成的同步回执不影响已有静态图片。新增图片只扩充后续文章的候选池。
|
||||
|
||||
回退先停fna-illustration-delivery.timer和service、关闭开关;静态副本和旧配图保留。原同步/静态展示维护见[静态配图](LOCAL_ILLUSTRATIONS.md)。批次验收与具体SHA由Resource发布记录维护。
|
||||
|
||||
当前已上线,真实自动回执与既有停用图片的验收差异见[发布记录](/Users/hellcat/Documents/GemCodes/resource.loc/v2/docs/ILLUSTRATION_DELIVERY_RELEASE.md)。
|
||||
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"commit": "21bb77c17644087fa6624fb276911e7a0cd894bd",
|
||||
"restored": 20,
|
||||
"managed_articles": 178,
|
||||
"verified_unique_image_urls": 33,
|
||||
"article_core_unchanged": true,
|
||||
"unrelated_local_selections_unchanged": true,
|
||||
"source_references_and_disabled_states_unchanged": true,
|
||||
"parallel_template_unchanged": true,
|
||||
"example_slug": "fn20261014",
|
||||
"example_original_image": "https://clashfreenode.com/images/illustrations/c7e661cdf0eb1a813b86efe8c1b062f9738fc6c945471cc990092706619fa34f.webp",
|
||||
"example_article_http": 200,
|
||||
"restored_original_assets": {
|
||||
"fn20260731": "13caface-3d1e-4365-b460-2ea47d893d03",
|
||||
"fn20260806": "d6a919eb-f66d-45de-81ee-26a3ca853270",
|
||||
"fn20260816": "e27f185f-1127-4e62-93b3-433cfc541953",
|
||||
"fn20260817": "d6cd3ea0-824b-4f5f-91e0-fc073c043f28",
|
||||
"fn20260818": "c4a8150b-b41a-4567-89af-91bbd3ec9705",
|
||||
"fn20260821": "13caface-3d1e-4365-b460-2ea47d893d03",
|
||||
"fn20260827": "d6a919eb-f66d-45de-81ee-26a3ca853270",
|
||||
"fn20260912": "e27f185f-1127-4e62-93b3-433cfc541953",
|
||||
"fn20260913": "d6cd3ea0-824b-4f5f-91e0-fc073c043f28",
|
||||
"fn20260914": "c4a8150b-b41a-4567-89af-91bbd3ec9705",
|
||||
"fn20260917": "13caface-3d1e-4365-b460-2ea47d893d03",
|
||||
"fn20260923": "d6a919eb-f66d-45de-81ee-26a3ca853270",
|
||||
"fn20261003": "e27f185f-1127-4e62-93b3-433cfc541953",
|
||||
"fn20261004": "d6cd3ea0-824b-4f5f-91e0-fc073c043f28",
|
||||
"fn20261005": "c4a8150b-b41a-4567-89af-91bbd3ec9705",
|
||||
"fn20261008": "13caface-3d1e-4365-b460-2ea47d893d03",
|
||||
"fn20261014": "d6a919eb-f66d-45de-81ee-26a3ca853270",
|
||||
"fn20261026": "e27f185f-1127-4e62-93b3-433cfc541953",
|
||||
"fn20261027": "d6cd3ea0-824b-4f5f-91e0-fc073c043f28",
|
||||
"fn20261028": "c4a8150b-b41a-4567-89af-91bbd3ec9705"
|
||||
},
|
||||
"verified_at": "2026-10-31T05:28:32Z"
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
# 独立图片副本保留修复 · 2026-10-31
|
||||
|
||||
用户明确要求修复:源端(Resource/ATOM管理)的删除或停用不得影响FNA已保存副本。此次恢复原图,不采用此前候选换图方案。
|
||||
|
||||
根因:5张源资产停用后,全量同步把20篇旧文章的本地selection置null,文件实际仍完整。首次交付实现已改为只缓存交付批次,停止触发全量旧文同步,但旧null映射留存。此次同步同时修正源端selection消失时误删本地关联的问题。
|
||||
|
||||
功能提交`21bb77c17644087fa6624fb276911e7a0cd894bd`,基于当前正式`26cb1ed7244de9209ec7494e8525a4d12f7609fa`隔离构造,仅LocalIllustrations和专项测试。源端各种不可用状态均保留已验证本地副本;本地文件也异常时报告pending但保留关联,不让同步破坏恢复信息。不改用户图片GET性能,不改Source、交付timer或广告,不重开test。
|
||||
|
||||
本地40项业务测试/305断言通过,覆盖停用、撤销发布/权限、源文件缺失/损坏、源selection消失、无网络读取和并发分配。恢复从备份的原Resource固定引用精确取回20个asset ID,只使用FNA既存且SHA一致的图片;不重新开启源资产、不替换成别的图片、不改Source引用/游标或文章正文。其余本地映射和并行生成模板须逐项保持。
|
||||
|
||||
执行恢复点:VPS-003 `/root/backups/cfn-independent-images-20261031/`;包含原本地清单、20项原关联恢复计划及最终验收JSON。此前备份`/root/backups/cfn-empty-images-20261031/`中的候选换图计划未执行。正式部署、HTTP与恢复覆盖结果以最终验收回执为准。
|
||||
|
||||
回滚代码可检回基线并清响应缓存;不要把null清单恢复覆盖到后来新增分配。如确需撤回本次数据修复,只能在锁内核对当前值仍为本次恢复值后逐项恢复目标20项旧值,保留其他文章、文件和交付数据。停用旧逻辑的全量同步,避免再次清空。
|
||||
|
||||
## 已完成
|
||||
|
||||
功能提交已推送`codex/independent-local-images-20261031`并部署正式站。2026-10-31 05:28:32 UTC完成20项原关联恢复,178篇资源文章均返回本站非空图片,33个实际引用的独立URL逐个HTTP200、Nginx静态交付及SHA验证通过;截图fn20261014详情HTTP200并包含原图。其余本地关联、Source全部引用/游标和资产停用状态、文章核心字段、并行模板摘要均不变。没有执行新文章发布、通知或IndexNow。已完成服务器侧验收,未做线上页面验收。详见[最终回执](INDEPENDENT_ILLUSTRATIONS_FIX_2026-10-31.json)。
|
||||
@@ -26,7 +26,7 @@ ## 不满意、撤回与删除
|
||||
|
||||
要替换图片,先在Resource修改受影响文章的selection,再同步FNA并刷新页面缓存;新哈希URL自然换图。仅移出pool不改变旧selection,扩池也不洗牌旧文章。
|
||||
|
||||
Resource物理文件丢失时,已验证的FNA副本仍可继续展示;本地文件丢失时浏览器会404,运行同步可重新下载,访问请求不负责修复。2026-10-31用户明确修正:源端删除、停用、撤销发布或授权均不影响FNA已有的独立副本与固定关联;源端selection消失时也保留本地关联。只有FNA本站明确撤图才停止展示。同步时若本地文件也缺失或损坏,仅报告pending并保留关联供恢复,不在用户请求时修复。同步不自动删除任何共享副本;退役需先确认无文章/正文引用,再清理指定副本及相关CDN缓存。
|
||||
Resource物理文件丢失时,已验证的FNA副本仍可继续展示;本地文件丢失时浏览器会404,运行同步可重新下载,访问请求不负责修复。主动撤回/取消授权等明确状态在同步后从页面映射停止展示。同步不自动删除任何共享副本;退役需先确认无文章/正文引用,再清理指定副本及相关CDN缓存。
|
||||
|
||||
长期公开缓存意味着不能承诺撤销Resource后立即让所有历史URL失效。FNA副本是独立公开发布物,需单独处理引用、源站文件及缓存;不要把Resource的即时撤回语义套到FNA静态副本。
|
||||
|
||||
@@ -38,22 +38,10 @@ ## 部署与恢复
|
||||
|
||||
## 2026-10-30 执行与验收
|
||||
|
||||
功能提交`ce27dbdd1eb206a9b7e7ac9b5a1c77778ed75e03`(后续仅文档提交`c663829c6dcc4295c08e6665883380a0e9a37d0d`),基于最新正式`f315215f6f64cf1b200d67fc426a9071ff557a09`隔离构造并已推送`codex/static-illustrations-20261030`。保留已上线年度点赞及并行生成模板;没有复制本地旧Git历史或广告实现。
|
||||
功能提交`ce27dbdd1eb206a9b7e7ac9b5a1c77778ed75e03`,基于最新正式`f315215f6f64cf1b200d67fc426a9071ff557a09`隔离构造并已推送`codex/static-illustrations-20261030`。保留已上线年度点赞及并行生成模板;没有复制本地旧Git历史或广告实现。
|
||||
|
||||
本地已启用,37张副本覆盖160篇;35项测试/277断言通过,涵盖下载校验、去重、失败原子性、并发分配、无网络读取,以及camelCase `sThumb`在模型/数组/JSON中的一致性。对外返回本站绝对URL,清单只存相对路径;侧栏缓存随同步清理。
|
||||
|
||||
test与正式均按同一功能提交部署。test 37张覆盖174篇,283项服务器检查通过,含关闭Resource客户端后的无缓存页面验证。正式37张覆盖176篇,246项服务器检查通过,正文/标题/slug/原始缩略图及年度点赞参数的部署前后摘要一致。最终HTTP、完整文件SHA、缓存/304/404、全量模型与数组同源图片、页面及真实接收helper既有分配重放结果见[本次发布回执](STATIC_ILLUSTRATIONS_RELEASE_2026-10-30.json)。未执行真实新文章接收、通知或IndexNow,未做线上页面验收。
|
||||
|
||||
VPS-003私有恢复点`/root/backups/cfn-static-illustrations-20261030/`保存原环境、Nginx、部署前身份摘要和逐项验收JSON。运行位置:正式`/www/wwwroot/clashfreenode-new.com`,test`/www/wwwroot/fna-v3-test`;两者独立目录和清单,静态location分别引入`/etc/nginx/snippets/fna-illustrations-production.conf`和`fna-illustrations-staging.conf`。新增目录由nginx写入,公开文件0644/目录0755,私有清单0600/目录0700。Source代码及其37张原文件保持原位;未新增定时同步或清理任务。
|
||||
|
||||
2026-10-30用户随后要求取消test,已下线;前述test验证为退役前历史结果,今后不作为在线入口。详见[test下线记录](TEST_RETIREMENT_2026-10-30.md)。
|
||||
|
||||
## 自动交付接收(2026-10-30)
|
||||
|
||||
新增按待交付批次触发的服务器定时同步,见[交付接收](ILLUSTRATION_DELIVERY.md)。此前“未新增定时同步”是静态副本首次上线时的记录。
|
||||
|
||||
## 2026-10-31 旧文章空白配图排查
|
||||
|
||||
服务器只读核对:当前FNA HEAD 26cb1ed7244de9209ec7494e8525a4d12f7609fa,47份静态资产文件均存在且SHA一致;178篇资源文章中20篇免费节点旧文章sThumb输出为null,包括fn20261014。Resource实时快照对应20项均为asset_disabled,可用猫图21张。根因为交付首次全量同步把已有5张停用资产所关联的20项本地映射置空;沿[交付发布记录](/Users/hellcat/Documents/GemCodes/resource.loc/v2/docs/ILLUSTRATION_DELIVERY_RELEASE.md)核实。不是本次重新停用或文件丢失。
|
||||
|
||||
已在VPS-003 `/root/backups/cfn-empty-images-20261031/`保存Resource一致性备份、引用/本地清单快照及精确20项候选替换计划。候选只使用当前可用猫图,避开相邻文章同图,计划仅更新相应selection与本地清单,不重启停用资产、不改正文/其他selection或游标。最初的换图方案未执行。用户随后明确要求保留原本地图片并授权修复,因此改为恢复原关联,源端5张资产仍保持停用,不执行候选换图计划。后续执行结果见[独立副本修复记录](INDEPENDENT_ILLUSTRATIONS_FIX_2026-10-31.md)。
|
||||
@@ -1,55 +0,0 @@
|
||||
# FNA_V3 SEO 实施与发布 · 2026-10-31
|
||||
|
||||
用户授权:落实已讨论方案,并全权优化 FNA_V3 SEO。范围为正式 cfn 的增量;开发初始基线 `77f9b09c58b46ef2bbe0882ec89194bf25aa82cd`;上线前发现HN广告并行发布,最终基线改为 `a820755e7e914180178e6928f73d5b42b0b24c86`,4个并行文件均不在本批覆盖范围,经白色机到 VPS-003 `/www/wwwroot/clashfreenode-new.com`。本地隔离工作副本 `output/seo-20261031/stage`。本文件是实现和本批验收唯一正文,36项总状态仍在 [SEO_PLAN](SEO_PLAN.md)。
|
||||
|
||||
搜索渠道按用户此前与雷欧确认的 Yandex / Bing 优先,保留通用搜索兼容;两者均支持本批采用的规范URL、sitemap与IndexNow。依据:[Bing指南](https://www.bing.com/webmasters/help/webmaster-guidelines-30fba23a)、[Yandex IndexNow](https://www.yandex.com/support/webmaster/en/indexing-options/index-now.html)、[IndexNow协议](https://www.indexnow.org/documentation)(2026-10-31核对)。
|
||||
|
||||
> 用户于本批上线后明确纠正:只做内部SEO,界面必须与优化前一致。可见布局、说明、分页、标题和图片呈现已恢复到优化前,修复已上线;现行约束及验证以[界面保留修复](SEO_UI_RESTORE_2026-10-31.md)为准,下面保留首批发布历史。
|
||||
|
||||
## 首批实现记录
|
||||
|
||||
- 首页 `/` 使用稳定标题/H1、WebSite、独立 canonical,显示最近可用记录全文及真实记录时间;明确零结果或失败不顶替上次记录,无可展示记录返回503/Retry-After。`/freenode` 是带历史说明的分页归档。旧的 `/?page=N` 定向到对应归档页;首页不是分页第一页。
|
||||
- 新免费节点记录创建即 `sSeoPolicy=archive`,可浏览、noindex、退出sitemap;已有资源仍保留分类7天策略,教程不继承资源期限。没有批量删除、合并、301到首页或恢复历史收录。取消 ClearDb 的180天正文删除,30天点赞明细清理保留。
|
||||
- `Seo` + `Articles::publicVisible` 统一公开、索引、URL、元信息。草稿、未来文章、隐藏分类或父分类在详情、列表、标签、搜索、推荐、sitemap中一致排除。已知平级子栏目一跳到真实父路径,错误父路径404,旧文章路径不变。Android/iOS纠正显示名称,保留原andorid路径。
|
||||
- 合法分页每页20条、自引用canonical带页码,移除跟踪参数;page=1归一,0/负数/非数字/数组/重复/越界404。HTML上一页下一页,JS读取实际下一页链接,追加去重、更新末页导航。robots放行查询参数,保留非内容路径限制。
|
||||
- 搜索使用当前站点数据库公开查询,转义LIKE通配字符,支持中文、空结果、无JS GET表单;不依赖过期的Meilisearch结果,也不删除/重建共享索引。现有发布索引副作用保留。普通浏览标签noindex,不做无流量证据的同义合并。
|
||||
- 去掉全局“今天”简介;纯文本实体解码、空白清洗、标题转义。首页、栏目、标签、搜索和文章各有主题。分享复制当前规范文章URL,OG一致,绝对图片URL,增加Twitter和真实Article/BreadcrumbList/CollectionPage结构;不输出评分或伪造作者资历。
|
||||
- 新增nullable `sContentUpdatedAt`:仅有实质内容变动时写入,点赞不改变。旧数据未知修改时间省略lastmod,不以updated_at冒充。新sitemap包含非空有效栏目、首页及可索引文章,排除日更新快照;栏目未建立可信历史时钟时不输出lastmod。
|
||||
- 免费节点接收校验字段与结果,失败、零节点、空正文拒绝并保留旧文。兼容旧摘要中的明确数量,状态默认unknown;数量不等于客户端连接实测,未向上游伪造check字段。已被编辑API接管的教程拒绝旧接口覆盖。
|
||||
- 原编辑API的持久IndexNow回执继续使用,实质更新通知文章与相关栏目;日更通知首页/栏目,取消无差别直接推送快照。新增 `seo_notifications` 出站表及业务服务器 `seo:indexnow-retry` 每5分钟最多10条、去重、5分钟到24小时退避;删除事件可以通知404地址,日志不含密钥。既有回执不自动补推,200/202仅代表接收。
|
||||
- HTML包含会话/点赞和随时间变化策略,因此关闭整页响应缓存路径(原生产也已关闭);静态资源缓存继续使用。GET点赞不再写数据,改POST+CSRF。非内容请求输出noindex头,旧/test路由仅local注册。
|
||||
- 保留教程横幅和既有广告;封面从CSS背景改为可发现img且保持原卡片比例,本地图片取真实尺寸;确认的福云/Hardnerd推广链接补sponsored,普通引用不一律nofollow。移动菜单增加可访问名称、展开状态、Escape关闭与焦点返回;无JS有导航和搜索后备。
|
||||
- 不新增后台:本次设置由现有应用配置维护,后续若做可视管理沿ATOM规范。域名不变无需DomainHub变更;未新增TeleHub消息,原日更通知调用保持。
|
||||
|
||||
## 验证
|
||||
|
||||
- 独立SQLite、冻结时钟和HTTP替身,62项业务测试523断言通过,无警告(APP_URL显式提供)。包含原编辑发布/重试、插画交付与独立副本、年度点赞、新URL/可见性/时间/清理/IndexNow合同。未往业务库插入测试文章。
|
||||
- 本地工作区最终整套64项/527断言通过,无警告。旧Laravel示例测试在未建表时访问首页,修正为独立健康入口启动及noindex检查;首页内容已有完整隔离数据测试。生产派生版本原62项/523断言通过,且本地/生产广告差异分别保留。
|
||||
- Vite正式构建通过;JS gzip约80.25KB,主题CSS gzip141.79KB。仅性能体积基线,不是线上CWV成绩;未重写框架。
|
||||
- 临时回环合成数据浏览器:从第2页滚动到第3页,26条且26个唯一ID、末页无next;390/320宽无横向溢出,菜单展开/键盘Escape;禁用JS仍有下一页链接。临时浏览器设置已复原。该验收不是生产页面验收。
|
||||
- 本地固定入口 `fna-v3.loc` 首页、免费节点第2页、Windows栏目均200,canonical使用本地域名,非生产统一noindex/nofollow。生产验收与精确提交、恢复点见下节。
|
||||
|
||||
## 保留边界与后续证据
|
||||
|
||||
历史正文、ID、URL、发布时间、插画关联和现有点赞设置不批量改动。旧资源7天noindex是过渡保留规则,不是给首页“转权重”的工具;未来按真实流量/外链与独立价值逐条处理。旧账号重复组保留既有noindex,不机械删文。既有客户端教程已经上线,本批不重写正文,未做客户端实机联网验证。
|
||||
|
||||
旧文章接收接口缺少入站认证;master01 `FnSitePublish::fn_b` 当前本地调用实现不带token,Nginx也未发现该路径专门认证。不得单方面启用token导致日更中断;需要在master01/FNA共同核对真实调用方并完成有兼容期的认证切换。当前编辑API认证保持,公网默认关闭。本批不把SEO发布宣称为旧接口安全问题全部解决。
|
||||
|
||||
未获取Search Console/Bing/Yandex的查询、外链、索引报告,不能据此承诺排名或声称历史URL没有流量;搜索平台效果、真实用户CWV、全部设备体验仍须后续数据观察。作者/运营反馈资料不虚构,现有点赞业务按用户此前明确设定保留,未作为搜索结构化评分。
|
||||
|
||||
## 回滚合同
|
||||
|
||||
代码回到本批base;只恢复本批覆盖的构建文件及缓存。新增列/出站表可保留,不还原整库覆盖发布后新文章。若需要撤销迁移,先确认无新写入并导出出站状态;默认不执行down。保留并行generated-tags-cloud、data.ms和public/images/editorial,禁止reset --hard/clean。不重启共享PHP-FPM;只定点失效本站变更文件OPcache。
|
||||
|
||||
## 发布记录
|
||||
|
||||
状态:**本批技术优化已Git提交、推送并部署正式cfn,服务器侧验收通过**。功能提交 `7c11ca77bcad5880ee0d50610f05419d40e18d46`,分支 `codex/fna-seo-20261031`,最终基线 `a820755e7e914180178e6928f73d5b42b0b24c86`;后续只同步本批文档与健康检查测试,不改运行代码。脱敏证据见 [发布回执](SEO_RELEASE_2026-10-31.json)。
|
||||
|
||||
- 189篇文章逐项HTTP200、规范地址、index/noindex、Article结构化数据及OG地址通过;全部核心字段、ID、日期、配图和旧编辑发布回执哈希保持。35个sitemap目标逐项200、自引用canonical、index/follow,无重复。原28项中的首页仅统一尾斜杠,原文章地址无移除,新增7个有效栏目。
|
||||
- 正式首页独立WebSite身份与最近可用文章一致;合法第2页及实际第3页HTML链接通过,非法父路径、无效/越界/重复分页均404。HTTP首页一跳301到HTTPS,HTTPS证书校验成功;XML、robots、CSS/JS状态及MIME通过。只存在已登记主域Nginx server_name,未为验收猜测www别名。
|
||||
- 编辑公网API保持关闭,调试路由404;原和新增IndexNow调度均在业务服务器存在。2026-10-31 15:52:55北京时间,由新持久队列通知首页及9个栏目共10个URL,回执done、1次、HTTP200;仅证明已接收,不代表已抓取、已收录或排名提升。未修改旧发布回执或补推历史文章。
|
||||
- 保留刚上线的HN广告调整、生产生成标签模板及data.ms、public/images/editorial并行目录。未改变DNS、邮件、Resource或其他实例;本地保留其DPL/FUC/HN组合广告差异,没有将本地其他未发布修改带上线。
|
||||
- 第一次切换因验收把首页尾斜杠变化当成URL丢失而自动回滚,已核实只有该等价变化;严格保留其他URL差异检查后再次切换成功。最终维护窗口1.34秒,维护标记已撤。未重启共享FPM,只定点失效本站PHP文件OPcache。
|
||||
- 私有恢复点:VPS-003 `/root/backups/cfn-seo-20261031/`,包含Git bundle、整库一致性备份、环境、Nginx、旧构建、前后状态、回滚失败原因与实际验收。新增SEO列与出站表为追加迁移,本地171篇原行旧字段保持;生产不回灌整库。
|
||||
|
||||
已完成服务器侧验收,未做线上页面验收。搜索平台报告、设备实机和真实用户性能不因这次技术发布自动完成;分项状态在SEO_PLAN。
|
||||
@@ -1,12 +1,8 @@
|
||||
> 2026-10-31界面约束更新:只做内部SEO,保持优化前外观。可见分页、说明/H1及列表图片改造撤回;以[界面恢复](SEO_UI_RESTORE_2026-10-31.md)为准,不能沿旧清单重新改版。
|
||||
|
||||
> 2026-10-31最新状态:本批技术实现已发布正式cfn,189篇服务器侧验收通过、原数据保持;sitemap 35项,IndexNow首页/栏目通知HTTP200。实现、限制及精确发布证据见 [SEO实施记录](SEO_IMPLEMENTATION_2026-10-31.md)。原审计的“未实施/未发布”仅描述其当时状态。
|
||||
|
||||
# FNA_V3 SEO 优化建议与执行清单
|
||||
|
||||
初始评估:2026-10-22,Asia/Shanghai;执行状态更新:2026-10-31。**本批技术优化已正式部署,20项按当前技术范围完成,16项仍有分项或长期证据缺口。** 本文件是唯一执行清单;下方审计证据保留原日期与原采样值,当前状态看第5节和[实施记录](SEO_IMPLEMENTATION_2026-10-31.md),不把旧审计的“未发布”当作当前状态。
|
||||
评估日期:2026-10-22,Asia/Shanghai。状态:**分析与建议文档已完成;SEO-001 的部署定位已由用户确认,配置改造尚未实施;SEO-020 于2026-10-27完成本地教程正文更新,设备实测及生产验收未做,D02首页最新免费节点全文展示于2026-10-27本地完成,其余项目尚未实施**。本文件是后续 SEO 工作的唯一执行清单;按 `SEO-001` 至 `SEO-036` 跟踪,实施后在本文件更新结果,不另建重复的“最新版计划”。
|
||||
|
||||
初始审计依据当时本地代码、数据库、HTTP及受限浏览器形成,只读未改站;当时的DPL广告纳入基准。cfn已于2026-10-29正式切换,本批SEO于2026-10-31增量部署,具体上线范围不从初始快照推断。
|
||||
本轮依据当前代码、当前本地数据库、重新取得的 HTTP 响应及受限浏览器检查形成结论。网站源码、样式和业务数据未作修改。当前三款 DPL 广告属于已存在的实现,纳入分析基准并保留。网站仍在独立本地副本中开发;用户随后确认未来替换现有 cfn,并支持同一套代码部署多个同类站点,ClashFreeNode 为主力站,尚未实际部署或迁移。
|
||||
|
||||
**最优先的工作是让有价值的内容拥有唯一、稳定、可发现的地址,并让页面真实兑现搜索结果中的承诺。** 当前主要问题集中于重复 URL、分页发现路径、内容生命周期和资源质量;仅增加标题、关键词或结构化数据不能解决这些问题。现有 Laravel Blade 已能在首次 HTML 响应中输出文章正文,没有证据表明必须改用另一套框架或全面重写网站。
|
||||
|
||||
@@ -28,9 +24,9 @@ ## 1 如何阅读和执行
|
||||
|
||||
证据等级:**已确认**指本轮代码、数据或响应直接支持;**条件性风险**指相关代码存在,但触发条件或生产影响未确认;**策略建议**指需要结合业务取舍决定;**待线上验证**指必须有实际生产环境或搜索平台数据才能判断。
|
||||
|
||||
2026-10-22审计以Google资料作为技术参考。按用户随后与雷欧明确的实际来源,2026-10-31实施以 **Yandex / Bing** 为主要搜索渠道,兼顾通用抓取与索引规则;使用IndexNow通知,效果核验优先两平台Webmaster报告,不把Google报告当作唯一指标。各平台是否收录与排序分别核实。
|
||||
本报告以 Google 的技术要求为主要参照;通用的 URL、HTTP、内容与内链原则也有助于其他搜索引擎。Bing、百度等渠道的具体投入,应由目标用户和后续数据决定,不能假定它们完全采用相同的收录规则。
|
||||
|
||||
## 2 2026-10-22审计基线与判断
|
||||
## 2 当前状态和核心判断
|
||||
|
||||
### 2.1 检查范围
|
||||
|
||||
@@ -98,7 +94,7 @@ ### 2.4 关键因果关系
|
||||
|
||||
## 3 实施前需要确定的产品决策
|
||||
|
||||
D01、D02早期已确认;2026-10-31用户确认讨论方案并授权全面优化。历史去留仍须逐条依据内容/流量证据,不授权无差别删除。
|
||||
D01、D02 已由用户确认;其余条目仍是建议,未因这些确认而自动获批。
|
||||
|
||||
| 决策 | 方案与确认状态 | 为什么 | 影响范围 |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -107,16 +103,16 @@ ## 3 实施前需要确定的产品决策
|
||||
| D03 日更文章的角色 | 稳定资源入口承接“当前可用”的需求;有独立记录价值的日更页保留,重复或失败记录不争取搜索曝光 | 用户需要可用资源,日期变动本身不是新价值 | 003、017、018 |
|
||||
| D04 历史内容 | 先按有效性、独立信息、已有流量/外链分类,再决定 index、noindex、合并或删除 | 不批量把 148 篇开放收录,也不机械全删/全跳首页 | 003、018、036 |
|
||||
| D05 标签 | 只培养有独立意图、有可维护内容的标签页;其余可保留浏览功能并 noindex | 25 个标签中存在同义名称和高度重叠文章集合 | 015 |
|
||||
| D06 渠道和目标 | 用户已明确Yandex/Bing为主要来源,按两平台有效自然访问、索引原因与实际使用完成率评估,Google保留通用兼容 | 没有搜索量和 Search Console 数据时不能编造关键词机会或流量预测 | 002、035 |
|
||||
| D06 渠道和目标 | 首先定义有效自然访问和实际使用完成率,Google 为初始技术基线;其他渠道按目标市场补充 | 没有搜索量和 Search Console 数据时不能编造关键词机会或流量预测 | 002、035 |
|
||||
| D07 样式边界 | 保持既有视觉语言和已批准广告方案;标题语义、链接、数据真实性先行;新增可见信息或调整广告占比单独评审 | SEO 改动不默认授权重设计整站或移除已批准广告 | 010、023、027 |
|
||||
|
||||
D01 的部署角色已明确。具体生产映射、新增实例清单以及多站相同内容的收录归属仍需在相应实施项确定;不阻塞本地分页、URL 规则和元数据开发。该段为2026-10-22审计历史;2026-10-31用户已授权全面落实,当前发布状态见本批实施记录。
|
||||
D01 的部署角色已明确。具体生产映射、新增实例清单以及多站相同内容的收录归属仍需在相应实施项确定;不阻塞本地分页、URL 规则和元数据开发。用户尚未授权本次上线或修改现有 cfn。
|
||||
|
||||
## 4 建议采用的 URL 与索引规则
|
||||
|
||||
### 4.1 页面行为矩阵
|
||||
|
||||
下表为初始目标合同;2026-10-31已实施部分按第5节及实施记录核验。标签index、历史合并等条件项未自动开启。
|
||||
下表为建议合同,实施前与 D02–D05 一起确认。
|
||||
|
||||
| 页面类型 | 建议 HTTP | 抓取与索引 | Canonical | Sitemap |
|
||||
| --- | --- | --- | --- | --- |
|
||||
@@ -170,48 +166,46 @@ ### 4.3 内容模型的最小改造方向
|
||||
|
||||
## 5 执行总表
|
||||
|
||||
2026-10-31用户授权全权落实。最新实现和验证见[本批实施记录](SEO_IMPLEMENTATION_2026-10-31.md);下方历史审计描述保留日期语义,以下总表以本次状态为准。
|
||||
所有项目当前均未实施。依赖列用于确定顺序,不是要求一次性同时完成全部项目。
|
||||
|
||||
| 完成 | 编号 | 项目 | 优先级 | 主要依赖 | 当前性质 |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| [x] | SEO-001 | 明确公开身份、主域名和环境边界 | P0 发布前 | D01 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-002 | 确定搜索意图、目标用户和效果基线 | P1 | D06 | 页面意图已区分;Yandex/Bing流量基线未取得 |
|
||||
| [x] | SEO-003 | 确定内容生命周期与索引资格 | P0 策略 | D03、D04 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-004 | 统一规范 URL 和历史别名 | P0 | D02 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-005 | 修复分页发现与滚动加载 | P0 | 004 | 滚动与canonical修复保留;原界面不新增分页条,无JS翻页未提供 |
|
||||
| [x] | SEO-006 | 协调 robots、参数和 noindex | P0 | 003、005 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-007 | 修复无效分页、空结果与错误状态 | P0 | 004、005 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-008 | 统一公开可见性与发布时间判断 | P0 发布前 | 003 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-009 | 修复面包屑和全站内链地址 | P1 | 004 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-010 | 分类、标签、搜索的标题与语义层级 | P1 | 001、004 | head元信息保留;可见H1/栏名完全沿用原界面 |
|
||||
| [x] | SEO-011 | 生成真实、干净的页面简介 | P1 | 010 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-012 | 分离真实内容日期并统一时间基准 | P1 | 003 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-013 | 统一 sitemap 的集合和 lastmod | P1 | 003、004、008、012 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-014 | 建立长期内链和内容导航 | P1 | 005、009、018 | 内链地址修复保留;新增说明和导航撤销 |
|
||||
| [~] | SEO-015 | 整理标签与重复主题页 | P1 | 002、003 | 普通标签noindex已上线;历史主题合并待流量证据 |
|
||||
| [x] | SEO-016 | 隔离并同步本站搜索索引 | P1 | 008、032 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-017 | 建立空资源与检测失败的发布门槛 | P0 内容 | 003 | 零结果/失败门槛已上线;上游结构化实测字段待接入 |
|
||||
| [x] | SEO-018 | 建立稳定资源入口和日更归档策略 | P1 | 002、003、004、017 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-019 | 处理真实重复文章与跨平台内容(本地Mac/Linux教程已区分) | P1 | 003、004 | 教程已区分;历史重复组保持,待流量/外链证据 |
|
||||
| [~] | SEO-020 | 提升客户端教程的任务完成能力(正文已上线,设备实机未验收) | P1 | 002、019 | 既有教程已上线;客户端实机联网未验收 |
|
||||
| [~] | SEO-021 | 明确来源、验证和跨站内容差异 | P1 | 017、020 | 时效与来源边界保留;真实资源验证及跨站差异待核实 |
|
||||
| [~] | SEO-022 | 作者、编辑责任与真实互动数据 | P1 | 001、012 | 不伪造作者或结构化评分;既有点赞按用户规则保留 |
|
||||
| [~] | SEO-023 | 推广链接、广告与正文体验 | P1 | D07 | 推广链接sponsored已上线;既有广告保留,完整体验待实测 |
|
||||
| [x] | SEO-024 | 添加匹配真实内容的结构化数据 | P2 | 009、010、012、022 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-025 | 修复分享地址和社交预览信息 | P2 | 001、004、011 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-026 | 图片语义、尺寸和加载方式 | P2 | 020、028 | 图片呈现恢复原样;列表img及新增宽高改造撤销 |
|
||||
| [~] | SEO-027 | 手机端与无障碍完整验收 | P2 | 005、010 | 320/390及键盘/无JS样本通过;全设备无障碍未覆盖 |
|
||||
| [~] | SEO-028 | 建立正式构建性能基线并按瓶颈优化 | P2 | 026、027 | 构建体积基线已建立;真实用户CWV未取得 |
|
||||
| [x] | SEO-029 | 缓存与发布、撤稿、到期一致性 | P1 启用前 | 003、008、012 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-030 | 文章接收、更新与删除的发布合同 | P0 发布前 | 003、008、017、029 | 校验、编辑保护和POST点赞已上线;旧入站认证须与master01协同 |
|
||||
| [x] | SEO-031 | 正式主机、HTTPS 与 HTTP 服务质量 | P0 发布前 | 001、004 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-032 | 本地、预发布和生产资源隔离 | P0 发布前 | 001 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-033 | 规范 IndexNow 及搜索提交 | P2 | 003、004、030、032 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [x] | SEO-034 | SEO 自动回归与数据样例 | P1 | 跟随各批次 | 已发布;本地回归及服务器侧验收通过 |
|
||||
| [~] | SEO-035 | 搜索平台与业务效果监测 | P1 上线后 | 001、002、036 | 通知回执已上线;Yandex/Bing实际索引和流量报告未取得 |
|
||||
| [x] | SEO-036 | 发布、迁移、回滚与复核 | P0 发布时 | 前述必需项 | 已发布;本地回归及服务器侧验收通过 |
|
||||
|
||||
按最新界面约束保留20项技术范围;16项保留部分验收或长期证据缺口。`[x]`只表示当前明确技术合同已交付,不表示排名、真实收录或所有设备验证通过。搜索改为本站数据库实时查询,未清空共享Meilisearch;整页缓存明确禁用,不再以未来启用缓存为完成条件。
|
||||
| [ ] | SEO-001 | 明确公开身份、主域名和环境边界 | P0 发布前 | D01 | 部署定位已确认,配置待实施 |
|
||||
| [ ] | SEO-002 | 确定搜索意图、目标用户和效果基线 | P1 | D06 | 待决策/待数据 |
|
||||
| [ ] | SEO-003 | 确定内容生命周期与索引资格 | P0 策略 | D03、D04 | 待决策 |
|
||||
| [ ] | SEO-004 | 统一规范 URL 和历史别名 | P0 | D02 | 已确认 |
|
||||
| [ ] | SEO-005 | 修复分页发现与滚动加载 | P0 | 004 | 已确认 |
|
||||
| [ ] | SEO-006 | 协调 robots、参数和 noindex | P0 | 003、005 | 已确认 |
|
||||
| [ ] | SEO-007 | 修复无效分页、空结果与错误状态 | P0 | 004、005 | 已确认 |
|
||||
| [ ] | SEO-008 | 统一公开可见性与发布时间判断 | P0 发布前 | 003 | 条件性风险 |
|
||||
| [ ] | SEO-009 | 修复面包屑和全站内链地址 | P1 | 004 | 已确认 |
|
||||
| [ ] | SEO-010 | 分类、标签、搜索的标题与语义层级 | P1 | 001、004 | 已确认 |
|
||||
| [ ] | SEO-011 | 生成真实、干净的页面简介 | P1 | 010 | 已确认 |
|
||||
| [ ] | SEO-012 | 分离真实内容日期并统一时间基准 | P1 | 003 | 已确认/条件性风险 |
|
||||
| [ ] | 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 | 已确认 |
|
||||
| [ ] | SEO-017 | 建立空资源与检测失败的发布门槛 | P0 内容 | 003 | 已确认/待上游核实 |
|
||||
| [ ] | SEO-018 | 建立稳定资源入口和日更归档策略 | P1 | 002、003、004、017 | 策略建议 |
|
||||
| [~] | SEO-019 | 处理真实重复文章与跨平台内容(本地Mac/Linux教程已区分) | P1 | 003、004 | 已确认 |
|
||||
| [~] | SEO-020 | 提升客户端教程的任务完成能力(本地全栏目正文完成,实机/生产未验收) | P1 | 002、019 | 已确认/内容建议 |
|
||||
| [ ] | SEO-021 | 明确来源、验证和跨站内容差异 | P1 | 017、020 | 策略建议 |
|
||||
| [ ] | SEO-022 | 作者、编辑责任与真实互动数据 | P1 | 001、012 | 已确认/策略建议 |
|
||||
| [ ] | SEO-023 | 推广链接、广告与正文体验 | P1 | D07 | 部分已具备,仍有缺口 |
|
||||
| [ ] | SEO-024 | 添加匹配真实内容的结构化数据 | P2 | 009、010、012、022 | 增强项 |
|
||||
| [ ] | SEO-025 | 修复分享地址和社交预览信息 | P2 | 001、004、011 | 已确认 |
|
||||
| [ ] | SEO-026 | 图片语义、尺寸和加载方式 | P2 | 020、028 | 已确认/待测量 |
|
||||
| [ ] | SEO-027 | 手机端与无障碍完整验收 | P2 | 005、010 | 部分样本通过 |
|
||||
| [ ] | SEO-028 | 建立正式构建性能基线并按瓶颈优化 | P2 | 026、027 | 待测量 |
|
||||
| [ ] | SEO-029 | 缓存与发布、撤稿、到期一致性 | P1 启用前 | 003、008、012 | 条件性风险 |
|
||||
| [ ] | 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-034 | SEO 自动回归与数据样例 | P1 | 跟随各批次 | 当前测试缺口 |
|
||||
| [ ] | SEO-035 | 搜索平台与业务效果监测 | P1 上线后 | 001、002、036 | 待线上数据 |
|
||||
| [ ] | SEO-036 | 发布、迁移、回滚与复核 | P0 发布时 | 前述必需项 | 待发布授权 |
|
||||
|
||||
## 6 各项优化的实施说明
|
||||
|
||||
@@ -231,7 +225,7 @@ ### SEO-001 明确公开身份、主域名和环境边界
|
||||
|
||||
多个站点的内容相同与否、是否各自争取独立收录,以及是否有副本归集到主力站,在 SEO-021 明确;“主力站”不自动授权把所有副站 canonical 指向它,也不代表复制内容的各站一定能获得独立搜索曝光。
|
||||
|
||||
**2026-10-31状态:** 正式cfn已发布统一配置生成的URL、品牌、schema及环境隔离;本地固定域名noindex,正式域名index。未把其他实例自动切为ClashFreeNode。
|
||||
**当前状态:部署定位与主力品牌已确认,配置统一和环境验收尚未实施;未修改代码,未部署。**
|
||||
|
||||
### SEO-002 确定搜索意图、目标用户和效果基线
|
||||
|
||||
@@ -358,8 +352,6 @@ ### 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。** 当前资源发现主要依赖列表首屏和“点赞活跃”;动态热门榜并不保证重要教程或可索引资源长期获得入口。
|
||||
@@ -547,8 +539,6 @@ ### 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、索引和发布规则回退。本轮未执行这些与审计目标无关的示例测试,也没有新增业务测试或修改代码。
|
||||
@@ -561,7 +551,7 @@ ### SEO-035 搜索平台与业务效果监测
|
||||
|
||||
**优先级:P1,上线后。** 本轮没有生产搜索数据,不能确认哪些页面已经收录、用户通过哪些查询进入、Google 选择了哪个 canonical,也不能证明某项缺陷已造成多少损失。
|
||||
|
||||
优先核实实际站点的Yandex Webmaster与Bing Webmaster Tools;Google Search Console作为补充。记录 sitemap 处理、页面索引原因、选定 canonical、查询与页面表现、地区/设备、人工处置及安全问题。服务器日志用于区分真实机器人抓取和普通流量;访客分析用于衡量实际使用,不记录订阅密钥、账号或敏感正文。
|
||||
获准后配置或核实实际站点的 Search Console;按目标渠道需要补 Bing 等平台。记录 sitemap 处理、页面索引原因、选定 canonical、查询与页面表现、地区/设备、人工处置及安全问题。服务器日志用于区分真实机器人抓取和普通流量;访客分析用于衡量实际使用,不记录订阅密钥、账号或敏感正文。
|
||||
|
||||
**验收:** 有可回溯的发布前基线或新站起始基线;页面类型与业务目标能分组分析;出现错误有明确负责人和处理方式。监测频率和通知自动化另行授权,本报告不创建定时任务。[Search Console 能提供的数据](https://developers.google.com/search/docs/monitor-debug/search-console-start)
|
||||
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
{
|
||||
"deployment": {
|
||||
"base": "a820755e7e914180178e6928f73d5b42b0b24c86",
|
||||
"commit": "7c11ca77bcad5880ee0d50610f05419d40e18d46",
|
||||
"branch": "codex/fna-seo-20261031",
|
||||
"backup_directory": "/root/backups/cfn-seo-20261031",
|
||||
"pushed": true,
|
||||
"head": "7c11ca77bcad5880ee0d50610f05419d40e18d46",
|
||||
"maintenance_seconds": 1.34,
|
||||
"articles_verified": 189,
|
||||
"core_preserved": true,
|
||||
"receipts_preserved": true,
|
||||
"before_sitemap": 28,
|
||||
"after_sitemap": 35,
|
||||
"sitemap_added": [
|
||||
"https://clashfreenode.com/client/andorid",
|
||||
"https://clashfreenode.com/client/ios",
|
||||
"https://clashfreenode.com/client/linux",
|
||||
"https://clashfreenode.com/client/mac",
|
||||
"https://clashfreenode.com/client/windows",
|
||||
"https://clashfreenode.com/freenode",
|
||||
"https://clashfreenode.com/shadowrocketids"
|
||||
],
|
||||
"sitemap_removed": [],
|
||||
"homepage_trailing_slash_normalized": true,
|
||||
"canonical_robots_schema_verified": true,
|
||||
"status": "M resources/views/components/generated-tags-cloud.blade.php\n?? data.ms/\n?? public/images/editorial/",
|
||||
"server_verification": true,
|
||||
"browser_production_verification": false
|
||||
},
|
||||
"verification": {
|
||||
"verified_at": "2026-10-31T07:52:55.987543+00:00",
|
||||
"head": "7c11ca77bcad5880ee0d50610f05419d40e18d46",
|
||||
"edge": {
|
||||
"http://clashfreenode.com/": {
|
||||
"status": 301,
|
||||
"location": "https://clashfreenode.com/",
|
||||
"content_type": "text/html",
|
||||
"tls_verify_result": "0"
|
||||
},
|
||||
"https://clashfreenode.com/": {
|
||||
"status": 200,
|
||||
"location": null,
|
||||
"content_type": "text/html; charset=utf-8",
|
||||
"tls_verify_result": "0"
|
||||
},
|
||||
"https://clashfreenode.com/sitemap.xml": {
|
||||
"status": 200,
|
||||
"location": null,
|
||||
"content_type": "application/xml; charset=UTF-8",
|
||||
"tls_verify_result": "0"
|
||||
},
|
||||
"https://clashfreenode.com/robots.txt": {
|
||||
"status": 200,
|
||||
"location": null,
|
||||
"content_type": "text/plain; charset=utf-8",
|
||||
"tls_verify_result": "0"
|
||||
},
|
||||
"https://clashfreenode.com/css/seo.css": {
|
||||
"status": 200,
|
||||
"location": null,
|
||||
"content_type": "text/css",
|
||||
"tls_verify_result": "0"
|
||||
}
|
||||
},
|
||||
"indexnow": {
|
||||
"id": 1,
|
||||
"urls": [
|
||||
"https://clashfreenode.com/",
|
||||
"https://clashfreenode.com/freenode",
|
||||
"https://clashfreenode.com/client",
|
||||
"https://clashfreenode.com/client/windows",
|
||||
"https://clashfreenode.com/client/andorid",
|
||||
"https://clashfreenode.com/client/ios",
|
||||
"https://clashfreenode.com/client/linux",
|
||||
"https://clashfreenode.com/client/mac",
|
||||
"https://clashfreenode.com/shadowrocketids",
|
||||
"https://clashfreenode.com/advanced"
|
||||
],
|
||||
"state": {
|
||||
"status": "done",
|
||||
"attempts": 1,
|
||||
"http_status": 200,
|
||||
"urls": [
|
||||
"https://clashfreenode.com/",
|
||||
"https://clashfreenode.com/freenode",
|
||||
"https://clashfreenode.com/client",
|
||||
"https://clashfreenode.com/client/windows",
|
||||
"https://clashfreenode.com/client/andorid",
|
||||
"https://clashfreenode.com/client/ios",
|
||||
"https://clashfreenode.com/client/linux",
|
||||
"https://clashfreenode.com/client/mac",
|
||||
"https://clashfreenode.com/shadowrocketids",
|
||||
"https://clashfreenode.com/advanced"
|
||||
],
|
||||
"submitted_at": "2026-10-31T07:52:55+00:00",
|
||||
"result": "received"
|
||||
}
|
||||
},
|
||||
"nginx_server_names": [
|
||||
"clashfreenode.com",
|
||||
"clashfreenode.com"
|
||||
],
|
||||
"maintenance_absent": true
|
||||
},
|
||||
"local_tests": {
|
||||
"production_derived_suite": {
|
||||
"tests": 62,
|
||||
"assertions": 523
|
||||
},
|
||||
"final_workspace_suite": {
|
||||
"tests": 64,
|
||||
"assertions": 527
|
||||
}
|
||||
},
|
||||
"production_browser_test": false
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
# SEO界面保留修复 · 2026-10-31
|
||||
|
||||
用户明确:先不改变网站布局,用户看到的界面必须与SEO优化前完全一样,只做内部SEO。本修复撤销前批7c11ca77引入的可见改变;以SEO前生产`a820755e7e914180178e6928f73d5b42b0b24c86`的页面模板为外观基线,增量接续`fa2bc2dafec4392c20004cef840ce54bc59ea41c`,不整站回退、不恢复旧广告或业务数据。
|
||||
|
||||
## 实施边界
|
||||
|
||||
- 恢复栏目横幅在左侧内容区的位置、旧卡片结构和CSS背景封面、原空结果样式、原导航/页脚文字。移除新增栏目说明、首页/文章历史说明块、可见分页条及额外导航。
|
||||
- 首页可见标题恢复当前文章标题,发布时间恢复原相对时间文字;不再添加可见更新时间。去掉seo.css和其全局图片/焦点样式覆盖。生产HN广告、此前已撤下的旧侧栏广告、本地DPL/FUC/HN组合保持各自现状。
|
||||
- 内部meta、canonical、robots、JSON-LD、sitemap、公开性/无效路径校验、内容时钟、发布门槛和IndexNow保留。面包屑地址与复制链接修正保留,不改变可见文字。原每页数量从既有page_limit配置读取。
|
||||
- 翻页辅助地址移入head的rel=prev/next,原滚动交互读取实际next并去重;不再增加可见分页,也不声称有无JS翻页能力。head关系仅为辅助元数据,不能保证搜索引擎将它当作完整发现链路;不使用隐藏关键词或给机器人单独渲染页面。
|
||||
|
||||
## 已取得的本地证据
|
||||
|
||||
- 完整64项测试、533断言通过;Vite发布构建通过。
|
||||
- 同一份隔离合成数据,首页、栏目、文章、空结果各在1280桌面及390手机视口与优化前模板对照,8组PNG字节/哈希完全一致。测试图、结果存项目output/seo-20261031/ui-comparison;不包含线上页面截图,不作为生产浏览器验收。
|
||||
- 正文DOM在仅归一内部URL/属性和语义time标签后四类一致;滚动从第2页追加到第3页,共26条/26唯一ID,末页next消失,无可见分页条。
|
||||
- 临时测试不访问生产网站,不往业务数据库插入文章。页面原样要求高于上一批关于可见H1、说明块、img改造或分页UI的实施记录。
|
||||
|
||||
## 发布与恢复
|
||||
|
||||
部署按Git显式提交,保留当前代码、构建、数据摘要及回滚点;本批不迁移数据库、不改内容或通知回执。已提交、推送并正式部署功能提交 `bc48be39e646bc365a1421fe4ad939f504f6615e`,分支 `codex/fna-seo-ui-20261031`;恢复点为VPS-003 `/root/backups/cfn-seo-ui-20261031/`。若补丁失败只回退本批代码,不能回灌整库覆盖新文章。
|
||||
|
||||
|
||||
## 正式结果
|
||||
|
||||
本次界面恢复已完成。189篇文章逐项HTTP、canonical、robots、Article结构化数据通过;首页可见H1与当前文章标题相同,原相对发布时间文字恢复,新增说明块/分页条/seo.css均已移除。原正文、日期、配图及编辑回执哈希不变,sitemap前后均35项且集合完全一致;原HN广告及并行生成标签、data.ms、编辑图片目录保持。维护窗口1.30秒,已退出维护。
|
||||
|
||||
已完成服务器侧验收,未做线上页面验收;8组本地截图对照与服务器检查分别记录,不混同证据。没有再次通知IndexNow,没有修改DNS、邮件、Resource或其他项目。脱敏回执见[界面恢复发布记录](SEO_UI_RESTORE_RELEASE_2026-10-31.json)。
|
||||
@@ -1,93 +0,0 @@
|
||||
{
|
||||
"deployment": {
|
||||
"base": "fa2bc2dafec4392c20004cef840ce54bc59ea41c",
|
||||
"commit": "bc48be39e646bc365a1421fe4ad939f504f6615e",
|
||||
"branch": "codex/fna-seo-ui-20261031",
|
||||
"backup_directory": "/root/backups/cfn-seo-ui-20261031",
|
||||
"pushed": true,
|
||||
"head": "bc48be39e646bc365a1421fe4ad939f504f6615e",
|
||||
"maintenance_seconds": 1.3,
|
||||
"articles_verified": 189,
|
||||
"core_preserved": true,
|
||||
"receipts_preserved": true,
|
||||
"before_sitemap": 35,
|
||||
"after_sitemap": 35,
|
||||
"sitemap_added": [],
|
||||
"sitemap_removed": [],
|
||||
"homepage_trailing_slash_normalized": true,
|
||||
"canonical_robots_schema_verified": true,
|
||||
"status": "M resources/views/components/generated-tags-cloud.blade.php\n?? data.ms/\n?? public/images/editorial/",
|
||||
"server_verification": true,
|
||||
"browser_production_verification": false,
|
||||
"ui_baseline": "a820755e7e914180178e6928f73d5b42b0b24c86",
|
||||
"ui_restored": true,
|
||||
"local_identical_screenshot_pairs": 8,
|
||||
"tests": 64,
|
||||
"assertions": 533
|
||||
},
|
||||
"local_screenshot_comparison": [
|
||||
{
|
||||
"page": "list",
|
||||
"width": 1280,
|
||||
"identical": true,
|
||||
"before_sha256": "695e25cf7547c2e19cc858d16de823ee661c338a00bcf0d7363672232849b6bd",
|
||||
"after_sha256": "695e25cf7547c2e19cc858d16de823ee661c338a00bcf0d7363672232849b6bd"
|
||||
},
|
||||
{
|
||||
"page": "home",
|
||||
"width": 1280,
|
||||
"identical": true,
|
||||
"before_sha256": "8ccc3f46f309d7fbddc72972e748e89640e550b9b12c8d798d8aa13ce7d8ceab",
|
||||
"after_sha256": "8ccc3f46f309d7fbddc72972e748e89640e550b9b12c8d798d8aa13ce7d8ceab"
|
||||
},
|
||||
{
|
||||
"page": "article",
|
||||
"width": 1280,
|
||||
"identical": true,
|
||||
"before_sha256": "6373c0ff398e07529bbed095d89302d8f2e1336b6660b14294a8228adc65e590",
|
||||
"after_sha256": "6373c0ff398e07529bbed095d89302d8f2e1336b6660b14294a8228adc65e590"
|
||||
},
|
||||
{
|
||||
"page": "empty",
|
||||
"width": 1280,
|
||||
"identical": true,
|
||||
"before_sha256": "ee48eaed8ef476839579f7ea65a9d223ff882e70cdef64ccb385d5b5a5909ecb",
|
||||
"after_sha256": "ee48eaed8ef476839579f7ea65a9d223ff882e70cdef64ccb385d5b5a5909ecb"
|
||||
},
|
||||
{
|
||||
"page": "list",
|
||||
"width": 390,
|
||||
"identical": true,
|
||||
"before_sha256": "49bfd131721f1f3b5ce08ab28d60ea4c7ac2b78650b75ea3d60f7d5804b58593",
|
||||
"after_sha256": "49bfd131721f1f3b5ce08ab28d60ea4c7ac2b78650b75ea3d60f7d5804b58593"
|
||||
},
|
||||
{
|
||||
"page": "home",
|
||||
"width": 390,
|
||||
"identical": true,
|
||||
"before_sha256": "abc76c5a1048711ac5e5653952c20073e9667e312df5216f983571265b5630e3",
|
||||
"after_sha256": "abc76c5a1048711ac5e5653952c20073e9667e312df5216f983571265b5630e3"
|
||||
},
|
||||
{
|
||||
"page": "article",
|
||||
"width": 390,
|
||||
"identical": true,
|
||||
"before_sha256": "2670e1a0668376414af3194419bd06355102886518089883806a2be0d138b66f",
|
||||
"after_sha256": "2670e1a0668376414af3194419bd06355102886518089883806a2be0d138b66f"
|
||||
},
|
||||
{
|
||||
"page": "empty",
|
||||
"width": 390,
|
||||
"identical": true,
|
||||
"before_sha256": "82f91577c5af25e233309ea01b15a862537881be9b519b514c075da098e90a94",
|
||||
"after_sha256": "82f91577c5af25e233309ea01b15a862537881be9b519b514c075da098e90a94"
|
||||
}
|
||||
],
|
||||
"infinite_scroll": {
|
||||
"starting_page": 2,
|
||||
"final_items": 26,
|
||||
"unique_ids": 26,
|
||||
"next_absent": true,
|
||||
"visible_pager": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"retired_at": "2026-10-30T04:36:51Z",
|
||||
"checks": [
|
||||
{
|
||||
"url": "http://test.clashfreenode.com/",
|
||||
"status": 410
|
||||
},
|
||||
{
|
||||
"url": "https://test.clashfreenode.com/",
|
||||
"status": 410
|
||||
},
|
||||
{
|
||||
"url": "https://test.clashfreenode.com/resource-v2/",
|
||||
"status": 410
|
||||
},
|
||||
{
|
||||
"url": "https://test.clashfreenode.com/images/illustrations/0000000000000000000000000000000000000000000000000000000000000000.png",
|
||||
"status": 410
|
||||
}
|
||||
],
|
||||
"production_http": 200,
|
||||
"production_nginx_unchanged": true,
|
||||
"test_renewal_disabled": true,
|
||||
"test_data_retained_offline": true,
|
||||
"dns": {
|
||||
"cloudflare_test_A_removed": true,
|
||||
"authoritative": [
|
||||
{
|
||||
"ns": "bradley.ns.cloudflare.com.",
|
||||
"status": "NXDOMAIN"
|
||||
},
|
||||
{
|
||||
"ns": "jewel.ns.cloudflare.com.",
|
||||
"status": "NXDOMAIN"
|
||||
}
|
||||
],
|
||||
"prior_record": {
|
||||
"type": "A",
|
||||
"name": "test.clashfreenode.com",
|
||||
"content": "45.153.247.44",
|
||||
"proxied": false,
|
||||
"ttl": "auto"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
# test 预览下线(2026-10-30)
|
||||
|
||||
用户明确要求切正式后取消test。当前唯一公开业务站为https://clashfreenode.com/;test.clashfreenode.com已撤销Cloudflare单条A记录(原45.153.247.44、DNS-only、自动TTL)。主域名、www、邮件等其余10条记录保留。DNS界面已核对单条test记录消失;管理截图仅留本地,不纳入服务器或Git。
|
||||
|
||||
经白色机SSH在VPS-003下线test网页及/resource-v2/入口,原虚拟主机不再指向测试代码或PHP;保留同名HTTP/HTTPS 410拒绝规则,避免尚有DNS缓存的客户端落入其他虚拟主机。关闭仅test的Certbot续期配置,现有证书只供缓存客户端返回410;未撤销或修改共享证书、PHP-FPM、Resource生产服务。Nginx配置验证/reload通过,正式站HTTP200且正式Nginx配置摘要未变。
|
||||
|
||||
测试代码、独立MySQL库和测试Resource SQLite/资产保留为离线恢复资料,不再提供公开访问;没有执行数据库删除、素材删除或撤销正式凭据。后续不得把test作为仍在线验收入口,也不自动重新开放。
|
||||
|
||||
VPS-003恢复点:`/root/backups/cfn-test-retirement-20261030/`,包含原test Nginx、原续期配置及退役回执。恢复须重新授权:恢复原test虚拟主机和续期配置,nginx -t后reload,再按原值重建精确test A记录并验证。不得用旧部署脚本擅自恢复。
|
||||
|
||||
已完成服务器侧验收,未做线上页面验收。
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"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/"
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
# 综合教程周期写作
|
||||
|
||||
2026-10-31用户最终规则:每周三篇,每天北京时间15:00检查;文章展示时间随机往前0~6小时,精确到秒。原每周两篇、早晚两个窗口的规则已替换。Codex heartbeat `fna`,名称“FNA 综合教程|每周三篇”,ACTIVE,绑定本聊天,自2026-11-02当周开始。调度已修改,首轮实际写作尚未执行。
|
||||
|
||||
## 执行入口
|
||||
|
||||
项目根运行 `python3 tools/editorial/weekly.py due`。未到期、当日已发表或本周额度满则安静退出。台账唯一位置为`storage/app/private/weekly-tutorials/state.json`,Git忽略;不保存凭据。电脑/Codex需开启,不保证关机仍执行或开机立即补跑。
|
||||
|
||||
每个自然周(Asia/Shanghai,周一至周日),在周一/二、周三/四、周五/六/日三组里各随机选一天,计划时间均为15:00,三篇间隔至少24小时。首次计划持久化,同一周不反复抽取。首周旧两篇计划尚未开始,已按最新规则重建三篇;具体日期以台账为准。
|
||||
|
||||
- `due`返回`write`后,先生成稳定release UUID,用`weekly.py claim --slot SLOT --release-id UUID`锁定任务,再写稿。每次最多一篇,同一天不连发。
|
||||
- `resume`表示已有未决release;先用[发布封装](EDITORIAL_RELEASE.md)的status查服务器,再沿原bundle、ID、草稿继续,不能创建另一篇。
|
||||
- `synchronize`表示正文已经发布、后处理待完成;沿原publish请求重试同步,不重发正文。
|
||||
- 发布完成或正文已提交但后处理pending时,用`weekly.py record --slot SLOT --receipt 私有发布结果.json`回写。只接受匹配release_id和真实published回执;用服务器事务时间计数,不用展示日期或本机收到结果的时间。
|
||||
- 漏掉的本周时段在下次15:00检查时补一篇;未开始的往周欠额不累计。跨周未决操作先查原回执,真实成功记入实际发表周,避免重复或计错额度。
|
||||
- 台账丢失、损坏或锁冲突时停止,先恢复/核对,不按空周补发。仅人工明确放弃无已发表结果的任务后可标记abandoned。人工另写文章只有明确登记替代时才占周期槽位。
|
||||
|
||||
## 内容与发布边界
|
||||
|
||||
写作规范、稳定文章与关联表唯一来源为[WRITING.md](../content/WRITING.md)。每篇先查正式目录与源稿,避免重复,官方一手资料核实事实,图解与缩略图沿现有风格。自然补下载/入门/专题内链,必要时只改直接相关旧文。公开内容不出现内部核验、未实测等说明,不编造设备实测。
|
||||
|
||||
新文点赞参数与展示偏移在API草稿中冻结;真实创建时间、回执和点赞起点仍真实记录。正文源、图片、渲染稿、关联表同任务维护。
|
||||
|
||||
生产固定经本机SSH→白色机VPS-001→正式业务服务器VPS-003。使用[固定发布命令](EDITORIAL_RELEASE.md),公网编辑API保持关闭,不在白色机部署写作服务。普通文章和图片通过内容API,源码/记录另做Git留档;程序/公共资源变更才单独Git部署,保留并行改动,不扩大成全站改版,不重建test。
|
||||
|
||||
用户授权周期内正常选题、写作、相关链接和正式发布,不逐篇再次确认。资料、权限或工具不足时保留草稿并报告真实缺口。只有有意义的完成、失败或需用户操作时通知,成功给标题和真实URL,不发每日检查流水。调度变更必须通过automation_update,不能手改调度文件或加系统cron替代。
|
||||
@@ -1,9 +0,0 @@
|
||||
function sa(n,t){return function(){return n.apply(t,arguments)}}const{toString:Hc}=Object.prototype,{getPrototypeOf:Fr}=Object,{iterator:Ti,toStringTag:oa}=Symbol,wi=(n=>t=>{const r=Hc.call(t);return n[r]||(n[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ve=n=>(n=n.toLowerCase(),t=>wi(t)===n),Si=n=>t=>typeof t===n,{isArray:on}=Array,Qt=Si("undefined");function Cn(n){return n!==null&&!Qt(n)&&n.constructor!==null&&!Qt(n.constructor)&&Oe(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const aa=Ve("ArrayBuffer");function $c(n){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(n):t=n&&n.buffer&&aa(n.buffer),t}const Fc=Si("string"),Oe=Si("function"),la=Si("number"),On=n=>n!==null&&typeof n=="object",Bc=n=>n===!0||n===!1,li=n=>{if(wi(n)!=="object")return!1;const t=Fr(n);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oa in n)&&!(Ti in n)},qc=n=>{if(!On(n)||Cn(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},Uc=Ve("Date"),Wc=Ve("File"),Vc=Ve("Blob"),zc=Ve("FileList"),Kc=n=>On(n)&&Oe(n.pipe),Yc=n=>{let t;return n&&(typeof FormData=="function"&&n instanceof FormData||Oe(n.append)&&((t=wi(n))==="formdata"||t==="object"&&Oe(n.toString)&&n.toString()==="[object FormData]"))},Gc=Ve("URLSearchParams"),[Xc,Qc,Jc,Zc]=["ReadableStream","Request","Response","Headers"].map(Ve),eu=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nn(n,t,{allOwnKeys:r=!1}={}){if(n===null||typeof n>"u")return;let o,c;if(typeof n!="object"&&(n=[n]),on(n))for(o=0,c=n.length;o<c;o++)t.call(null,n[o],o,n);else{if(Cn(n))return;const d=r?Object.getOwnPropertyNames(n):Object.keys(n),h=d.length;let p;for(o=0;o<h;o++)p=d[o],t.call(null,n[p],p,n)}}function ca(n,t){if(Cn(n))return null;t=t.toLowerCase();const r=Object.keys(n);let o=r.length,c;for(;o-- >0;)if(c=r[o],t===c.toLowerCase())return c;return null}const Tt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ua=n=>!Qt(n)&&n!==Tt;function Nr(){const{caseless:n,skipUndefined:t}=ua(this)&&this||{},r={},o=(c,d)=>{const h=n&&ca(r,d)||d;li(r[h])&&li(c)?r[h]=Nr(r[h],c):li(c)?r[h]=Nr({},c):on(c)?r[h]=c.slice():(!t||!Qt(c))&&(r[h]=c)};for(let c=0,d=arguments.length;c<d;c++)arguments[c]&&Nn(arguments[c],o);return r}const tu=(n,t,r,{allOwnKeys:o}={})=>(Nn(t,(c,d)=>{r&&Oe(c)?n[d]=sa(c,r):n[d]=c},{allOwnKeys:o}),n),nu=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),iu=(n,t,r,o)=>{n.prototype=Object.create(t.prototype,o),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:t.prototype}),r&&Object.assign(n.prototype,r)},ru=(n,t,r,o)=>{let c,d,h;const p={};if(t=t||{},n==null)return t;do{for(c=Object.getOwnPropertyNames(n),d=c.length;d-- >0;)h=c[d],(!o||o(h,n,t))&&!p[h]&&(t[h]=n[h],p[h]=!0);n=r!==!1&&Fr(n)}while(n&&(!r||r(n,t))&&n!==Object.prototype);return t},su=(n,t,r)=>{n=String(n),(r===void 0||r>n.length)&&(r=n.length),r-=t.length;const o=n.indexOf(t,r);return o!==-1&&o===r},ou=n=>{if(!n)return null;if(on(n))return n;let t=n.length;if(!la(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=n[t];return r},au=(n=>t=>n&&t instanceof n)(typeof Uint8Array<"u"&&Fr(Uint8Array)),lu=(n,t)=>{const o=(n&&n[Ti]).call(n);let c;for(;(c=o.next())&&!c.done;){const d=c.value;t.call(n,d[0],d[1])}},cu=(n,t)=>{let r;const o=[];for(;(r=n.exec(t))!==null;)o.push(r);return o},uu=Ve("HTMLFormElement"),fu=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,c){return o.toUpperCase()+c}),Xs=(({hasOwnProperty:n})=>(t,r)=>n.call(t,r))(Object.prototype),du=Ve("RegExp"),fa=(n,t)=>{const r=Object.getOwnPropertyDescriptors(n),o={};Nn(r,(c,d)=>{let h;(h=t(c,d,n))!==!1&&(o[d]=h||c)}),Object.defineProperties(n,o)},hu=n=>{fa(n,(t,r)=>{if(Oe(n)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=n[r];if(Oe(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},pu=(n,t)=>{const r={},o=c=>{c.forEach(d=>{r[d]=!0})};return on(n)?o(n):o(String(n).split(t)),r},gu=()=>{},mu=(n,t)=>n!=null&&Number.isFinite(n=+n)?n:t;function yu(n){return!!(n&&Oe(n.append)&&n[oa]==="FormData"&&n[Ti])}const vu=n=>{const t=new Array(10),r=(o,c)=>{if(On(o)){if(t.indexOf(o)>=0)return;if(Cn(o))return o;if(!("toJSON"in o)){t[c]=o;const d=on(o)?[]:{};return Nn(o,(h,p)=>{const m=r(h,c+1);!Qt(m)&&(d[p]=m)}),t[c]=void 0,d}}return o};return r(n,0)},_u=Ve("AsyncFunction"),bu=n=>n&&(On(n)||Oe(n))&&Oe(n.then)&&Oe(n.catch),da=((n,t)=>n?setImmediate:t?((r,o)=>(Tt.addEventListener("message",({source:c,data:d})=>{c===Tt&&d===r&&o.length&&o.shift()()},!1),c=>{o.push(c),Tt.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Oe(Tt.postMessage)),Eu=typeof queueMicrotask<"u"?queueMicrotask.bind(Tt):typeof process<"u"&&process.nextTick||da,Tu=n=>n!=null&&Oe(n[Ti]),O={isArray:on,isArrayBuffer:aa,isBuffer:Cn,isFormData:Yc,isArrayBufferView:$cLine truncated
|
||||
`).forEach(function(h){c=h.indexOf(":"),r=h.substring(0,c).trim().toLowerCase(),o=h.substring(c+1).trim(),!(!r||t[r]&&$u[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},eo=Symbol("internals");function En(n){return n&&String(n).trim().toLowerCase()}function ci(n){return n===!1||n==null?n:O.isArray(n)?n.map(ci):String(n)}function Bu(n){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(n);)t[o[1]]=o[2];return t}const qu=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function ir(n,t,r,o,c){if(O.isFunction(o))return o.call(this,t,r);if(c&&(t=r),!!O.isString(t)){if(O.isString(o))return t.indexOf(o)!==-1;if(O.isRegExp(o))return o.test(t)}}function Uu(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function Wu(n,t){const r=O.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(n,o+r,{value:function(c,d,h){return this[o].call(this,t,c,d,h)},configurable:!0})})}let Ne=class{constructor(t){t&&this.set(t)}set(t,r,o){const c=this;function d(p,m,_){const v=En(m);if(!v)throw new Error("header name must be a non-empty string");const C=O.findKey(c,v);(!C||c[C]===void 0||_===!0||_===void 0&&c[C]!==!1)&&(c[C||m]=ci(p))}const h=(p,m)=>O.forEach(p,(_,v)=>d(_,v,m));if(O.isPlainObject(t)||t instanceof this.constructor)h(t,r);else if(O.isString(t)&&(t=t.trim())&&!qu(t))h(Fu(t),r);else if(O.isObject(t)&&O.isIterable(t)){let p={},m,_;for(const v of t){if(!O.isArray(v))throw TypeError("Object iterator must return a key-value pair");p[_=v[0]]=(m=p[_])?O.isArray(m)?[...m,v[1]]:[m,v[1]]:v[1]}h(p,r)}else t!=null&&d(r,t,o);return this}get(t,r){if(t=En(t),t){const o=O.findKey(this,t);if(o){const c=this[o];if(!r)return c;if(r===!0)return Bu(c);if(O.isFunction(r))return r.call(this,c,o);if(O.isRegExp(r))return r.exec(c);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=En(t),t){const o=O.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||ir(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let c=!1;function d(h){if(h=En(h),h){const p=O.findKey(o,h);p&&(!r||ir(o,o[p],p,r))&&(delete o[p],c=!0)}}return O.isArray(t)?t.forEach(d):d(t),c}clear(t){const r=Object.keys(this);let o=r.length,c=!1;for(;o--;){const d=r[o];(!t||ir(this,this[d],d,t,!0))&&(delete this[d],c=!0)}return c}normalize(t){const r=this,o={};return O.forEach(this,(c,d)=>{const h=O.findKey(o,d);if(h){r[h]=ci(c),delete r[d];return}const p=t?Uu(d):String(d).trim();p!==d&&delete r[d],r[p]=ci(c),o[p]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return O.forEach(this,(o,c)=>{o!=null&&o!==!1&&(r[c]=t&&O.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
||||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(c=>o.set(c)),o}static accessor(t){const o=(this[eo]=this[eo]={accessors:{}}).accessors,c=this.prototype;function d(h){const p=En(h);o[p]||(Wu(c,h),o[p]=!0)}return O.isArray(t)?t.forEach(d):d(t),this}};Ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);O.reduceDescriptors(Ne.prototype,({value:n},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>n,set(o){this[r]=o}}});O.freezeMethods(Ne);function rr(n,t){const r=this||Dn,o=t||r,c=Ne.from(o.headers);let d=o.data;return O.forEach(n,function(p){d=p.call(r,d,c.normalize(),t?t.status:void 0)}),c.normalize(),d}function ba(n){return!!(n&&n.__CANCEL__)}function an(n,t,r){ie.call(this,n??"canceled",ie.ERR_CANCELED,t,r),this.name="CanceledError"}O.inherits(an,ie,{__CANCEL__:!0});function Ea(n,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?n(r):t(new ie("Request failed with status code "+r.status,[ie.ERR_BAD_REQUEST,ie.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Vu(n){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return t&&t[1]||""}function zu(n,t){n=n||10;const r=new Array(n),o=new Array(n);let c=0,d=0,h;return t=t!==void 0?t:1e3,function(m){const _=Date.now(),v=o[d];h||(h=_),r[c]=m,o[c]=_;let C=d,R=0;for(;C!==c;)R+=r[C++],C=C%n;if(c=(c+1)%n,c===d&&(d=(d+1)%n),_-h<t)return;const I=v&&_-v;return I?Math.round(R*1e3/I):void 0}}function Ku(n,t){let r=0,o=1e3/t,c,d;const h=(_,v=Date.now())=>{r=v,c=null,d&&(clearTimeout(d),d=null),n(..._)};return[(..._)=>{const v=Date.now(),C=v-r;C>=o?h(_,v):(c=_,d||(d=setTimeout(()=>{d=null,h(c)},o-C)))},()=>c&&h(c)]}const yi=(n,t,r=3)=>{let o=0;const c=zu(50,250);return Ku(d=>{const h=d.loaded,p=d.lengthComputable?d.total:void 0,m=h-o,_=c(m),v=h<=p;o=h;const C={loaded:h,total:p,progress:p?h/p:void 0,bytes:m,rate:_||void 0,estimated:_&&p&&v?(p-h)/_:void 0,event:d,lengthComputable:p!=null,[t?"download":"upload"]:!0};n(C)},r)},to=(n,t)=>{const r=n!=null;return[o=>t[0]({lengthComputable:r,total:n,loaded:o}),t[1]]},no=n=>(...t)=>O.asap(()=>n(...t)),Yu=Ee.hasStandardBrowserEnv?((n,t)=>r=>(r=new URL(r,Ee.origin),n.protocol===r.protocol&&n.host===r.host&&(t||n.port===r.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,Gu=Ee.hasStandardBrowserEnv?{write(n,t,r,o,c,d,h){if(typeof document>"u")return;const p=[`${n}=${encodeURIComponent(t)}`];O.isNumber(r)&&p.push(`expires=${new Date(r).toUTCString()}`),O.isString(o)&&p.push(`path=${o}`),O.isString(c)&&p.push(`domain=${c}`),d===!0&&p.push("secure"),O.isString(h)&&p.push(`SameSite=${h}`),document.cookie=p.join("; ")},read(n){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Xu(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Qu(n,t){return t?n.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):n}function Ta(n,t,r){let o=!Xu(t);return n&&(o||r==!1)?Qu(n,t):t}const io=n=>n instanceof Ne?{...n}:n;function Ot(n,t){t=t||{};const r={};function o(_,v,C,R){return O.isPlainObject(_)&&O.isPlainObject(v)?O.merge.call({caseless:R},_,v):O.isPlainObject(v)?O.merge({},v):O.isArray(v)?v.slice():v}function c(_,v,C,R){if(O.isUndefined(v)){if(!O.isUndefined(_))return o(void 0,_,C,R)}else return o(_,v,C,R)}function d(_,v){if(!O.isUndefined(v))return o(void 0,v)}function h(_,v){if(O.isUndefined(v)){if(!O.isUndefined(_))return o(void 0,_)}else return o(void 0,v)}function p(_,v,C){if(C in t)return o(_,v);if(C in n)return o(void 0,_)}const m={url:d,method:d,data:d,baseURL:h,transformRequest:h,transformResponse:h,paramsSerializer:h,timeout:h,timeoutMessage:h,withCredentials:h,withXSRFToken:h,adapter:h,responseType:h,xsrfCookieName:h,xsrfHeaderName:h,onUploadProgress:h,onDownloadProgress:h,decompress:h,maxContentLength:h,maxBodyLength:h,beforeRedirect:h,transport:h,httpAgent:h,httpsAgent:h,cancelToken:h,socketPath:h,responseEncoding:h,validateStatus:p,headers:(_,v,C)=>c(io(_),io(v),C,!0)};return O.forEach(Object.keys({...n,...t}),function(v){const C=m[v]||c,R=C(n[v],t[v],v);O.isUndefined(R)&&C!==p||(r[v]=R)}),r}const wa=n=>{const t=Ot({},n);let{data:r,withXSRFToken:o,xsrfHeaderName:c,xsrfCookieName:d,headers:h,auth:p}=t;if(t.headers=h=Ne.from(h),t.url=ya(Ta(t.baseURL,t.url,t.allowAbsoluteUrls),n.params,n.paramsSerializer),p&&h.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?unescape(encodeURIComponent(p.password)):""))),O.isFormData(r)){if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)h.setContentType(void 0);else if(O.isFunction(r.getHeaders)){const m=r.getHeaders(),_=["content-type","content-length"];Object.entries(m).forEach(([v,C])=>{_.inclu
Line truncated
|
||||
`+h.map(co).join(`
|
||||
`):" "+co(h[0]):"as no adapter specified";throw new ie("There is no suitable adapter to dispatch the request "+p,"ERR_NOT_SUPPORT")}return c}const Aa={getAdapter:cf,adapters:Ur};function sr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new an(null,n)}function uo(n){return sr(n),n.headers=Ne.from(n.headers),n.data=rr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Aa.getAdapter(n.adapter||Dn.adapter,n)(n).then(function(o){return sr(n),o.data=rr.call(n,n.transformResponse,o),o.headers=Ne.from(o.headers),o},function(o){return ba(o)||(sr(n),o&&o.response&&(o.response.data=rr.call(n,n.transformResponse,o.response),o.response.headers=Ne.from(o.response.headers))),Promise.reject(o)})}const xa="1.13.2",xi={};["object","boolean","number","function","string","symbol"].forEach((n,t)=>{xi[n]=function(o){return typeof o===n||"a"+(t<1?"n ":" ")+n}});const fo={};xi.transitional=function(t,r,o){function c(d,h){return"[Axios v"+xa+"] Transitional option '"+d+"'"+h+(o?". "+o:"")}return(d,h,p)=>{if(t===!1)throw new ie(c(h," has been removed"+(r?" in "+r:"")),ie.ERR_DEPRECATED);return r&&!fo[h]&&(fo[h]=!0,console.warn(c(h," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(d,h,p):!0}};xi.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function uf(n,t,r){if(typeof n!="object")throw new ie("options must be an object",ie.ERR_BAD_OPTION_VALUE);const o=Object.keys(n);let c=o.length;for(;c-- >0;){const d=o[c],h=t[d];if(h){const p=n[d],m=p===void 0||h(p,d,n);if(m!==!0)throw new ie("option "+d+" must be "+m,ie.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ie("Unknown option "+d,ie.ERR_BAD_OPTION)}}const ui={assertOptions:uf,validators:xi},Xe=ui.validators;let At=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Zs,response:new Zs}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const d=c.stack?c.stack.replace(/^.+\n/,""):"";try{o.stack?d&&!String(o.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
||||
`+d):o.stack=d}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ot(this.defaults,r);const{transitional:o,paramsSerializer:c,headers:d}=r;o!==void 0&&ui.assertOptions(o,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1),c!=null&&(O.isFunction(c)?r.paramsSerializer={serialize:c}:ui.assertOptions(c,{encode:Xe.function,serialize:Xe.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ui.assertOptions(r,{baseUrl:Xe.spelling("baseURL"),withXsrfToken:Xe.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let h=d&&O.merge(d.common,d[r.method]);d&&O.forEach(["delete","get","head","post","put","patch","common"],E=>{delete d[E]}),r.headers=Ne.concat(h,d);const p=[];let m=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(r)===!1||(m=m&&S.synchronous,p.unshift(S.fulfilled,S.rejected))});const _=[];this.interceptors.response.forEach(function(S){_.push(S.fulfilled,S.rejected)});let v,C=0,R;if(!m){const E=[uo.bind(this),void 0];for(E.unshift(...p),E.push(..._),R=E.length,v=Promise.resolve(r);C<R;)v=v.then(E[C++],E[C++]);return v}R=p.length;let I=r;for(;C<R;){const E=p[C++],S=p[C++];try{I=E(I)}catch(x){S.call(this,x);break}}try{v=uo.call(this,I)}catch(E){return Promise.reject(E)}for(C=0,R=_.length;C<R;)v=v.then(_[C++],_[C++]);return v}getUri(t){t=Ot(this.defaults,t);const r=Ta(t.baseURL,t.url,t.allowAbsoluteUrls);return ya(r,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){At.prototype[t]=function(r,o){return this.request(Ot(o||{},{method:t,url:r,data:(o||{}).data}))}});O.forEach(["post","put","patch"],function(t){function r(o){return function(d,h,p){return this.request(Ot(p||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:d,data:h}))}}At.prototype[t]=r(),At.prototype[t+"Form"]=r(!0)});let ff=class Ca{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(d){r=d});const o=this;this.promise.then(c=>{if(!o._listeners)return;let d=o._listeners.length;for(;d-- >0;)o._listeners[d](c);o._listeners=null}),this.promise.then=c=>{let d;const h=new Promise(p=>{o.subscribe(p),d=p}).then(c);return h.cancel=function(){o.unsubscribe(d)},h},t(function(d,h,p){o.reason||(o.reason=new an(d,h,p),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Ca(function(c){t=c}),cancel:t}}};function df(n){return function(r){return n.apply(null,r)}}function hf(n){return O.isObject(n)&&n.isAxiosError===!0}const Pr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Pr).forEach(([n,t])=>{Pr[t]=n});function Oa(n){const t=new At(n),r=sa(At.prototype.request,t);return O.extend(r,At.prototype,t,{allOwnKeys:!0}),O.extend(r,t,null,{allOwnKeys:!0}),r.create=function(c){return Oa(Ot(n,c))},r}const ye=Oa(Dn);ye.Axios=At;ye.CanceledError=an;ye.CancelToken=ff;ye.isCancel=ba;ye.VERSION=xa;ye.toFormData=Ai;ye.AxiosError=ie;ye.Cancel=ye.CanceledError;ye.all=function(t){return Promise.all(t)};ye.spread=df;ye.isAxiosError=hf;ye.mergeConfig=Ot;ye.AxiosH
Line truncated
|
||||
`):e)),i};var Tc=/\[\]$/,qs=/\r?\n/g,wc=/^(?:submit|button|image|reset|file)$/i,Sc=/^(?:input|select|textarea|keygen)/i;function Qi(e,i,s,a){var u;if(Array.isArray(i))l.each(i,function(f,g){s||Tc.test(e)?a(e,g):Qi(e+"["+(typeof g=="object"&&g!=null?f:"")+"]",g,s,a)});else if(!s&&E(i)==="object")for(u in i)Qi(e+"["+u+"]",i[u],s,a);else a(e,i)}l.param=function(e,i){var s,a=[],u=function(f,g){var b=typeof g=="function"?g():g;a[a.length]=encodeURIComponent(f)+"="+encodeURIComponent(b??"")};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!l.isPlainObject(e))l.each(e,function(){u(this.name,this.value)});else for(s in e)Qi(s,e[s],i,u);return a.join("&")},l.fn.extend({serialize:function(){return l.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=l.prop(this,"elements");return e?l.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!l(this).is(":disabled")&&Sc.test(this.nodeName)&&!wc.test(e)&&(this.checked||!Yn.test(e))}).map(function(e,i){var s=l(this).val();return s==null?null:Array.isArray(s)?l.map(s,function(a){return{name:i.name,value:a.replace(qs,`\r
|
||||
`)}}):{name:i.name,value:s.replace(qs,`\r
|
||||
`)}}).get()}});var Ac=/%20/g,xc=/#.*$/,Cc=/([?&])_=[^&]*/,Oc=/^(.*?):[ \t]*([^\r\n]*)$/mg,Nc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Dc=/^(?:GET|HEAD)$/,Lc=/^\/\//,Us={},Ji={},Ws="*/".concat("*"),Zi=P.createElement("a");Zi.href=_n.href;function Vs(e){return function(i,s){typeof i!="string"&&(s=i,i="*");var a,u=0,f=i.toLowerCase().match(Re)||[];if(typeof s=="function")for(;a=f[u++];)a[0]==="+"?(a=a.slice(1)||"*",(e[a]=e[a]||[]).unshift(s)):(e[a]=e[a]||[]).push(s)}}function zs(e,i,s,a){var u={},f=e===Ji;function g(b){var y;return u[b]=!0,l.each(e[b]||[],function(T,A){var L=A(i,s,a);if(typeof L=="string"&&!f&&!u[L])return i.dataTypes.unshift(L),g(L),!1;if(f)return!(y=L)}),y}return g(i.dataTypes[0])||!u["*"]&&g("*")}function er(e,i){var s,a,u=l.ajaxSettings.flatOptions||{};for(s in i)i[s]!==void 0&&((u[s]?e:a||(a={}))[s]=i[s]);return a&&l.extend(!0,e,a),e}function Pc(e,i,s){for(var a,u,f,g,b=e.contents,y=e.dataTypes;y[0]==="*";)y.shift(),a===void 0&&(a=e.mimeType||i.getResponseHeader("Content-Type"));if(a){for(u in b)if(b[u]&&b[u].test(a)){y.unshift(u);break}}if(y[0]in s)f=y[0];else{for(u in s){if(!y[0]||e.converters[u+" "+y[0]]){f=u;break}g||(g=u)}f=f||g}if(f)return f!==y[0]&&y.unshift(f),s[f]}function Rc(e,i,s,a){var u,f,g,b,y,T={},A=e.dataTypes.slice();if(A[1])for(g in e.converters)T[g.toLowerCase()]=e.converters[g];for(f=A.shift();f;)if(e.responseFields[f]&&(s[e.responseFields[f]]=i),!y&&a&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),y=f,f=A.shift(),f){if(f==="*")f=y;else if(y!=="*"&&y!==f){if(g=T[y+" "+f]||T["* "+f],!g){for(u in T)if(b=u.split(" "),b[1]===f&&(g=T[y+" "+b[0]]||T["* "+b[0]],g)){g===!0?g=T[u]:T[u]!==!0&&(f=b[0],A.unshift(b[1]));break}}if(g!==!0)if(g&&e.throws)i=g(i);else try{i=g(i)}catch(L){return{state:"parsererror",error:g?L:"No conversion from "+y+" to "+f}}}}return{state:"success",data:i}}l.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:_n.href,type:"GET",isLocal:Nc.test(_n.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ws,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":l.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,i){return i?er(er(e,l.ajaxSettings),i):er(l.ajaxSettings,e)},ajaxPrefilter:Vs(Us),ajaxTransport:Vs(Ji),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var s,a,u,f,g,b,y,T,A,L,w=l.ajaxSetup({},i),D=w.context||w,$=w.context&&(D.nodeType||D.jquery)?l(D):l.event,ee=l.Deferred(),G=l.Callbacks("once memory"),ge=w.statusCode||{},pe={},xe={},be="canceled",le={readyState:0,getResponseHeader:function(ue){var ve;if(y){if(!f)for(f={};ve=Oc.exec(u);)f[ve[1].toLowerCase()+" "]=(f[ve[1].toLowerCase()+" "]||[]).concat(ve[2]);ve=f[ue.toLowerCase()+" "]}return ve==null?null:ve.join(", ")},getAllResponseHeaders:function(){return y?u:null},setRequestHeader:function(ue,ve){return y==null&&(ue=xe[ue.toLowerCase()]=xe[ue.toLowerCase()]||ue,pe[ue]=ve),this},overrideMimeType:function(ue){return y==null&&(w.mimeType=ue),this},statusCode:function(ue){var ve;if(ue)if(y)le.always(ue[le.status]);else for(ve in ue)ge[ve]=[ge[ve],ue[ve]];return this},abort:function(ue){var ve=ue||be;return s&&s.abort(ve),Zn(0,ve),this}};if(ee.promise(le),w.url=((e||w.url||_n.href)+"").replace(Lc,_n.protocol+"//"),w.type=i.method||i.type||w.method||w.type,w.dataTypes=(w.dataType||"*").toLowerCase().match(Re)||[""],w.crossDomain==null){b=P.createElement("a");try{b.href=w.url,b.href=b.href,w.crossDomain=Zi.protocol+"//"+Zi.host!=b.protocol+"//"+b.host}catch{w.crossDomain=!0}}if(zs(Us,w,i,le),w.data&&w.processData&&typeof w.data!="string"&&(w.data=l.param(w.data,w.traditional)),y)return le;T=l.event&&w.global,T&&l.active++===0&&l.event.trigger("ajaxStart"),w.type=w.type.toUpperCase(),w.hasContent=!Dc.test(w.type),a=w.url.replace(xc,""),w.hasContent?w.data&&w.processData&&(w.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(w.data=w.data.replace(Ac,"+")):(L=w.url.slice(a.length),w.data&&(w.processData||typeof w.data=="string")&&(a+=(Xi.test(a)?"&":"?")+w.data,delete w.data),w.cache===!1&&(a=a.replace(Cc,"$1"),L=(Xi.test(a)?"&":"?")+"_="+Bs.guid+++L),w.url=a+L),w.ifModified&&(l.lastModified[a]&&le.setRequestHeader("If-Modified-Since",l.lastModified[a]),l.etag[a]&&le.setRequestHeader("If-None-Match",l.etag[a])),(w.data&&w.hasContent&&w.contentType!==!1||i.contentType)&&le.setRequestHeader("Content-Type",w.contentType),le.setRequestHeader("Accept",w.dataTypes[0]&&w.accepts[w.dataTypes[0]]?w.accepts[w.dataTypes[0]]+(w.dataTypes[0]!=="*"?", "+Ws+"; q=0.01":""):w.accepts["*"]);for(A in w.headers)le.setRequestHeader(A,w.headers[A]);if(w.beforeSend&&(w.beforeSend.call(D,le,w)===!1||y))return le.abort();if(be="abort",G.a
Line truncated
|
||||
@@ -1,9 +0,0 @@
|
||||
function sa(n,t){return function(){return n.apply(t,arguments)}}const{toString:Hc}=Object.prototype,{getPrototypeOf:Fr}=Object,{iterator:Ti,toStringTag:oa}=Symbol,wi=(n=>t=>{const r=Hc.call(t);return n[r]||(n[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Ve=n=>(n=n.toLowerCase(),t=>wi(t)===n),Si=n=>t=>typeof t===n,{isArray:on}=Array,Qt=Si("undefined");function Cn(n){return n!==null&&!Qt(n)&&n.constructor!==null&&!Qt(n.constructor)&&Oe(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const aa=Ve("ArrayBuffer");function $c(n){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(n):t=n&&n.buffer&&aa(n.buffer),t}const Fc=Si("string"),Oe=Si("function"),la=Si("number"),On=n=>n!==null&&typeof n=="object",Bc=n=>n===!0||n===!1,li=n=>{if(wi(n)!=="object")return!1;const t=Fr(n);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(oa in n)&&!(Ti in n)},qc=n=>{if(!On(n)||Cn(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},Uc=Ve("Date"),Wc=Ve("File"),Vc=Ve("Blob"),zc=Ve("FileList"),Kc=n=>On(n)&&Oe(n.pipe),Yc=n=>{let t;return n&&(typeof FormData=="function"&&n instanceof FormData||Oe(n.append)&&((t=wi(n))==="formdata"||t==="object"&&Oe(n.toString)&&n.toString()==="[object FormData]"))},Gc=Ve("URLSearchParams"),[Xc,Qc,Jc,Zc]=["ReadableStream","Request","Response","Headers"].map(Ve),eu=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nn(n,t,{allOwnKeys:r=!1}={}){if(n===null||typeof n>"u")return;let o,c;if(typeof n!="object"&&(n=[n]),on(n))for(o=0,c=n.length;o<c;o++)t.call(null,n[o],o,n);else{if(Cn(n))return;const d=r?Object.getOwnPropertyNames(n):Object.keys(n),h=d.length;let p;for(o=0;o<h;o++)p=d[o],t.call(null,n[p],p,n)}}function ca(n,t){if(Cn(n))return null;t=t.toLowerCase();const r=Object.keys(n);let o=r.length,c;for(;o-- >0;)if(c=r[o],t===c.toLowerCase())return c;return null}const Tt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ua=n=>!Qt(n)&&n!==Tt;function Nr(){const{caseless:n,skipUndefined:t}=ua(this)&&this||{},r={},o=(c,d)=>{const h=n&&ca(r,d)||d;li(r[h])&&li(c)?r[h]=Nr(r[h],c):li(c)?r[h]=Nr({},c):on(c)?r[h]=c.slice():(!t||!Qt(c))&&(r[h]=c)};for(let c=0,d=arguments.length;c<d;c++)arguments[c]&&Nn(arguments[c],o);return r}const tu=(n,t,r,{allOwnKeys:o}={})=>(Nn(t,(c,d)=>{r&&Oe(c)?n[d]=sa(c,r):n[d]=c},{allOwnKeys:o}),n),nu=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),iu=(n,t,r,o)=>{n.prototype=Object.create(t.prototype,o),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:t.prototype}),r&&Object.assign(n.prototype,r)},ru=(n,t,r,o)=>{let c,d,h;const p={};if(t=t||{},n==null)return t;do{for(c=Object.getOwnPropertyNames(n),d=c.length;d-- >0;)h=c[d],(!o||o(h,n,t))&&!p[h]&&(t[h]=n[h],p[h]=!0);n=r!==!1&&Fr(n)}while(n&&(!r||r(n,t))&&n!==Object.prototype);return t},su=(n,t,r)=>{n=String(n),(r===void 0||r>n.length)&&(r=n.length),r-=t.length;const o=n.indexOf(t,r);return o!==-1&&o===r},ou=n=>{if(!n)return null;if(on(n))return n;let t=n.length;if(!la(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=n[t];return r},au=(n=>t=>n&&t instanceof n)(typeof Uint8Array<"u"&&Fr(Uint8Array)),lu=(n,t)=>{const o=(n&&n[Ti]).call(n);let c;for(;(c=o.next())&&!c.done;){const d=c.value;t.call(n,d[0],d[1])}},cu=(n,t)=>{let r;const o=[];for(;(r=n.exec(t))!==null;)o.push(r);return o},uu=Ve("HTMLFormElement"),fu=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,o,c){return o.toUpperCase()+c}),Xs=(({hasOwnProperty:n})=>(t,r)=>n.call(t,r))(Object.prototype),du=Ve("RegExp"),fa=(n,t)=>{const r=Object.getOwnPropertyDescriptors(n),o={};Nn(r,(c,d)=>{let h;(h=t(c,d,n))!==!1&&(o[d]=h||c)}),Object.defineProperties(n,o)},hu=n=>{fa(n,(t,r)=>{if(Oe(n)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const o=n[r];if(Oe(o)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},pu=(n,t)=>{const r={},o=c=>{c.forEach(d=>{r[d]=!0})};return on(n)?o(n):o(String(n).split(t)),r},gu=()=>{},mu=(n,t)=>n!=null&&Number.isFinite(n=+n)?n:t;function yu(n){return!!(n&&Oe(n.append)&&n[oa]==="FormData"&&n[Ti])}const vu=n=>{const t=new Array(10),r=(o,c)=>{if(On(o)){if(t.indexOf(o)>=0)return;if(Cn(o))return o;if(!("toJSON"in o)){t[c]=o;const d=on(o)?[]:{};return Nn(o,(h,p)=>{const m=r(h,c+1);!Qt(m)&&(d[p]=m)}),t[c]=void 0,d}}return o};return r(n,0)},_u=Ve("AsyncFunction"),bu=n=>n&&(On(n)||Oe(n))&&Oe(n.then)&&Oe(n.catch),da=((n,t)=>n?setImmediate:t?((r,o)=>(Tt.addEventListener("message",({source:c,data:d})=>{c===Tt&&d===r&&o.length&&o.shift()()},!1),c=>{o.push(c),Tt.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",Oe(Tt.postMessage)),Eu=typeof queueMicrotask<"u"?queueMicrotask.bind(Tt):typeof process<"u"&&process.nextTick||da,Tu=n=>n!=null&&Oe(n[Ti]),O={isArray:on,isArrayBuffer:aa,isBuffer:Cn,isFormData:Yc,isArrayBufferView:$cLine truncated
|
||||
`).forEach(function(h){c=h.indexOf(":"),r=h.substring(0,c).trim().toLowerCase(),o=h.substring(c+1).trim(),!(!r||t[r]&&$u[r])&&(r==="set-cookie"?t[r]?t[r].push(o):t[r]=[o]:t[r]=t[r]?t[r]+", "+o:o)}),t},eo=Symbol("internals");function En(n){return n&&String(n).trim().toLowerCase()}function ci(n){return n===!1||n==null?n:O.isArray(n)?n.map(ci):String(n)}function Bu(n){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let o;for(;o=r.exec(n);)t[o[1]]=o[2];return t}const qu=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function ir(n,t,r,o,c){if(O.isFunction(o))return o.call(this,t,r);if(c&&(t=r),!!O.isString(t)){if(O.isString(o))return t.indexOf(o)!==-1;if(O.isRegExp(o))return o.test(t)}}function Uu(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,o)=>r.toUpperCase()+o)}function Wu(n,t){const r=O.toCamelCase(" "+t);["get","set","has"].forEach(o=>{Object.defineProperty(n,o+r,{value:function(c,d,h){return this[o].call(this,t,c,d,h)},configurable:!0})})}let Ne=class{constructor(t){t&&this.set(t)}set(t,r,o){const c=this;function d(p,m,_){const v=En(m);if(!v)throw new Error("header name must be a non-empty string");const C=O.findKey(c,v);(!C||c[C]===void 0||_===!0||_===void 0&&c[C]!==!1)&&(c[C||m]=ci(p))}const h=(p,m)=>O.forEach(p,(_,v)=>d(_,v,m));if(O.isPlainObject(t)||t instanceof this.constructor)h(t,r);else if(O.isString(t)&&(t=t.trim())&&!qu(t))h(Fu(t),r);else if(O.isObject(t)&&O.isIterable(t)){let p={},m,_;for(const v of t){if(!O.isArray(v))throw TypeError("Object iterator must return a key-value pair");p[_=v[0]]=(m=p[_])?O.isArray(m)?[...m,v[1]]:[m,v[1]]:v[1]}h(p,r)}else t!=null&&d(r,t,o);return this}get(t,r){if(t=En(t),t){const o=O.findKey(this,t);if(o){const c=this[o];if(!r)return c;if(r===!0)return Bu(c);if(O.isFunction(r))return r.call(this,c,o);if(O.isRegExp(r))return r.exec(c);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=En(t),t){const o=O.findKey(this,t);return!!(o&&this[o]!==void 0&&(!r||ir(this,this[o],o,r)))}return!1}delete(t,r){const o=this;let c=!1;function d(h){if(h=En(h),h){const p=O.findKey(o,h);p&&(!r||ir(o,o[p],p,r))&&(delete o[p],c=!0)}}return O.isArray(t)?t.forEach(d):d(t),c}clear(t){const r=Object.keys(this);let o=r.length,c=!1;for(;o--;){const d=r[o];(!t||ir(this,this[d],d,t,!0))&&(delete this[d],c=!0)}return c}normalize(t){const r=this,o={};return O.forEach(this,(c,d)=>{const h=O.findKey(o,d);if(h){r[h]=ci(c),delete r[d];return}const p=t?Uu(d):String(d).trim();p!==d&&delete r[d],r[p]=ci(c),o[p]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return O.forEach(this,(o,c)=>{o!=null&&o!==!1&&(r[c]=t&&O.isArray(o)?o.join(", "):o)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
|
||||
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const o=new this(t);return r.forEach(c=>o.set(c)),o}static accessor(t){const o=(this[eo]=this[eo]={accessors:{}}).accessors,c=this.prototype;function d(h){const p=En(h);o[p]||(Wu(c,h),o[p]=!0)}return O.isArray(t)?t.forEach(d):d(t),this}};Ne.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);O.reduceDescriptors(Ne.prototype,({value:n},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>n,set(o){this[r]=o}}});O.freezeMethods(Ne);function rr(n,t){const r=this||Dn,o=t||r,c=Ne.from(o.headers);let d=o.data;return O.forEach(n,function(p){d=p.call(r,d,c.normalize(),t?t.status:void 0)}),c.normalize(),d}function ba(n){return!!(n&&n.__CANCEL__)}function an(n,t,r){ie.call(this,n??"canceled",ie.ERR_CANCELED,t,r),this.name="CanceledError"}O.inherits(an,ie,{__CANCEL__:!0});function Ea(n,t,r){const o=r.config.validateStatus;!r.status||!o||o(r.status)?n(r):t(new ie("Request failed with status code "+r.status,[ie.ERR_BAD_REQUEST,ie.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Vu(n){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return t&&t[1]||""}function zu(n,t){n=n||10;const r=new Array(n),o=new Array(n);let c=0,d=0,h;return t=t!==void 0?t:1e3,function(m){const _=Date.now(),v=o[d];h||(h=_),r[c]=m,o[c]=_;let C=d,R=0;for(;C!==c;)R+=r[C++],C=C%n;if(c=(c+1)%n,c===d&&(d=(d+1)%n),_-h<t)return;const I=v&&_-v;return I?Math.round(R*1e3/I):void 0}}function Ku(n,t){let r=0,o=1e3/t,c,d;const h=(_,v=Date.now())=>{r=v,c=null,d&&(clearTimeout(d),d=null),n(..._)};return[(..._)=>{const v=Date.now(),C=v-r;C>=o?h(_,v):(c=_,d||(d=setTimeout(()=>{d=null,h(c)},o-C)))},()=>c&&h(c)]}const yi=(n,t,r=3)=>{let o=0;const c=zu(50,250);return Ku(d=>{const h=d.loaded,p=d.lengthComputable?d.total:void 0,m=h-o,_=c(m),v=h<=p;o=h;const C={loaded:h,total:p,progress:p?h/p:void 0,bytes:m,rate:_||void 0,estimated:_&&p&&v?(p-h)/_:void 0,event:d,lengthComputable:p!=null,[t?"download":"upload"]:!0};n(C)},r)},to=(n,t)=>{const r=n!=null;return[o=>t[0]({lengthComputable:r,total:n,loaded:o}),t[1]]},no=n=>(...t)=>O.asap(()=>n(...t)),Yu=Ee.hasStandardBrowserEnv?((n,t)=>r=>(r=new URL(r,Ee.origin),n.protocol===r.protocol&&n.host===r.host&&(t||n.port===r.port)))(new URL(Ee.origin),Ee.navigator&&/(msie|trident)/i.test(Ee.navigator.userAgent)):()=>!0,Gu=Ee.hasStandardBrowserEnv?{write(n,t,r,o,c,d,h){if(typeof document>"u")return;const p=[`${n}=${encodeURIComponent(t)}`];O.isNumber(r)&&p.push(`expires=${new Date(r).toUTCString()}`),O.isString(o)&&p.push(`path=${o}`),O.isString(c)&&p.push(`domain=${c}`),d===!0&&p.push("secure"),O.isString(h)&&p.push(`SameSite=${h}`),document.cookie=p.join("; ")},read(n){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Xu(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function Qu(n,t){return t?n.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):n}function Ta(n,t,r){let o=!Xu(t);return n&&(o||r==!1)?Qu(n,t):t}const io=n=>n instanceof Ne?{...n}:n;function Ot(n,t){t=t||{};const r={};function o(_,v,C,R){return O.isPlainObject(_)&&O.isPlainObject(v)?O.merge.call({caseless:R},_,v):O.isPlainObject(v)?O.merge({},v):O.isArray(v)?v.slice():v}function c(_,v,C,R){if(O.isUndefined(v)){if(!O.isUndefined(_))return o(void 0,_,C,R)}else return o(_,v,C,R)}function d(_,v){if(!O.isUndefined(v))return o(void 0,v)}function h(_,v){if(O.isUndefined(v)){if(!O.isUndefined(_))return o(void 0,_)}else return o(void 0,v)}function p(_,v,C){if(C in t)return o(_,v);if(C in n)return o(void 0,_)}const m={url:d,method:d,data:d,baseURL:h,transformRequest:h,transformResponse:h,paramsSerializer:h,timeout:h,timeoutMessage:h,withCredentials:h,withXSRFToken:h,adapter:h,responseType:h,xsrfCookieName:h,xsrfHeaderName:h,onUploadProgress:h,onDownloadProgress:h,decompress:h,maxContentLength:h,maxBodyLength:h,beforeRedirect:h,transport:h,httpAgent:h,httpsAgent:h,cancelToken:h,socketPath:h,responseEncoding:h,validateStatus:p,headers:(_,v,C)=>c(io(_),io(v),C,!0)};return O.forEach(Object.keys({...n,...t}),function(v){const C=m[v]||c,R=C(n[v],t[v],v);O.isUndefined(R)&&C!==p||(r[v]=R)}),r}const wa=n=>{const t=Ot({},n);let{data:r,withXSRFToken:o,xsrfHeaderName:c,xsrfCookieName:d,headers:h,auth:p}=t;if(t.headers=h=Ne.from(h),t.url=ya(Ta(t.baseURL,t.url,t.allowAbsoluteUrls),n.params,n.paramsSerializer),p&&h.set("Authorization","Basic "+btoa((p.username||"")+":"+(p.password?unescape(encodeURIComponent(p.password)):""))),O.isFormData(r)){if(Ee.hasStandardBrowserEnv||Ee.hasStandardBrowserWebWorkerEnv)h.setContentType(void 0);else if(O.isFunction(r.getHeaders)){const m=r.getHeaders(),_=["content-type","content-length"];Object.entries(m).forEach(([v,C])=>{_.inclu
Line truncated
|
||||
`+h.map(co).join(`
|
||||
`):" "+co(h[0]):"as no adapter specified";throw new ie("There is no suitable adapter to dispatch the request "+p,"ERR_NOT_SUPPORT")}return c}const Aa={getAdapter:cf,adapters:Ur};function sr(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new an(null,n)}function uo(n){return sr(n),n.headers=Ne.from(n.headers),n.data=rr.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Aa.getAdapter(n.adapter||Dn.adapter,n)(n).then(function(o){return sr(n),o.data=rr.call(n,n.transformResponse,o),o.headers=Ne.from(o.headers),o},function(o){return ba(o)||(sr(n),o&&o.response&&(o.response.data=rr.call(n,n.transformResponse,o.response),o.response.headers=Ne.from(o.response.headers))),Promise.reject(o)})}const xa="1.13.2",xi={};["object","boolean","number","function","string","symbol"].forEach((n,t)=>{xi[n]=function(o){return typeof o===n||"a"+(t<1?"n ":" ")+n}});const fo={};xi.transitional=function(t,r,o){function c(d,h){return"[Axios v"+xa+"] Transitional option '"+d+"'"+h+(o?". "+o:"")}return(d,h,p)=>{if(t===!1)throw new ie(c(h," has been removed"+(r?" in "+r:"")),ie.ERR_DEPRECATED);return r&&!fo[h]&&(fo[h]=!0,console.warn(c(h," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(d,h,p):!0}};xi.spelling=function(t){return(r,o)=>(console.warn(`${o} is likely a misspelling of ${t}`),!0)};function uf(n,t,r){if(typeof n!="object")throw new ie("options must be an object",ie.ERR_BAD_OPTION_VALUE);const o=Object.keys(n);let c=o.length;for(;c-- >0;){const d=o[c],h=t[d];if(h){const p=n[d],m=p===void 0||h(p,d,n);if(m!==!0)throw new ie("option "+d+" must be "+m,ie.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new ie("Unknown option "+d,ie.ERR_BAD_OPTION)}}const ui={assertOptions:uf,validators:xi},Xe=ui.validators;let At=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Zs,response:new Zs}}async request(t,r){try{return await this._request(t,r)}catch(o){if(o instanceof Error){let c={};Error.captureStackTrace?Error.captureStackTrace(c):c=new Error;const d=c.stack?c.stack.replace(/^.+\n/,""):"";try{o.stack?d&&!String(o.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(o.stack+=`
|
||||
`+d):o.stack=d}catch{}}throw o}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=Ot(this.defaults,r);const{transitional:o,paramsSerializer:c,headers:d}=r;o!==void 0&&ui.assertOptions(o,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1),c!=null&&(O.isFunction(c)?r.paramsSerializer={serialize:c}:ui.assertOptions(c,{encode:Xe.function,serialize:Xe.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),ui.assertOptions(r,{baseUrl:Xe.spelling("baseURL"),withXsrfToken:Xe.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let h=d&&O.merge(d.common,d[r.method]);d&&O.forEach(["delete","get","head","post","put","patch","common"],E=>{delete d[E]}),r.headers=Ne.concat(h,d);const p=[];let m=!0;this.interceptors.request.forEach(function(S){typeof S.runWhen=="function"&&S.runWhen(r)===!1||(m=m&&S.synchronous,p.unshift(S.fulfilled,S.rejected))});const _=[];this.interceptors.response.forEach(function(S){_.push(S.fulfilled,S.rejected)});let v,C=0,R;if(!m){const E=[uo.bind(this),void 0];for(E.unshift(...p),E.push(..._),R=E.length,v=Promise.resolve(r);C<R;)v=v.then(E[C++],E[C++]);return v}R=p.length;let I=r;for(;C<R;){const E=p[C++],S=p[C++];try{I=E(I)}catch(x){S.call(this,x);break}}try{v=uo.call(this,I)}catch(E){return Promise.reject(E)}for(C=0,R=_.length;C<R;)v=v.then(_[C++],_[C++]);return v}getUri(t){t=Ot(this.defaults,t);const r=Ta(t.baseURL,t.url,t.allowAbsoluteUrls);return ya(r,t.params,t.paramsSerializer)}};O.forEach(["delete","get","head","options"],function(t){At.prototype[t]=function(r,o){return this.request(Ot(o||{},{method:t,url:r,data:(o||{}).data}))}});O.forEach(["post","put","patch"],function(t){function r(o){return function(d,h,p){return this.request(Ot(p||{},{method:t,headers:o?{"Content-Type":"multipart/form-data"}:{},url:d,data:h}))}}At.prototype[t]=r(),At.prototype[t+"Form"]=r(!0)});let ff=class Ca{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(d){r=d});const o=this;this.promise.then(c=>{if(!o._listeners)return;let d=o._listeners.length;for(;d-- >0;)o._listeners[d](c);o._listeners=null}),this.promise.then=c=>{let d;const h=new Promise(p=>{o.subscribe(p),d=p}).then(c);return h.cancel=function(){o.unsubscribe(d)},h},t(function(d,h,p){o.reason||(o.reason=new an(d,h,p),r(o.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=o=>{t.abort(o)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Ca(function(c){t=c}),cancel:t}}};function df(n){return function(r){return n.apply(null,r)}}function hf(n){return O.isObject(n)&&n.isAxiosError===!0}const Pr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Pr).forEach(([n,t])=>{Pr[t]=n});function Oa(n){const t=new At(n),r=sa(At.prototype.request,t);return O.extend(r,At.prototype,t,{allOwnKeys:!0}),O.extend(r,t,null,{allOwnKeys:!0}),r.create=function(c){return Oa(Ot(n,c))},r}const ye=Oa(Dn);ye.Axios=At;ye.CanceledError=an;ye.CancelToken=ff;ye.isCancel=ba;ye.VERSION=xa;ye.toFormData=Ai;ye.AxiosError=ie;ye.Cancel=ye.CanceledError;ye.all=function(t){return Promise.all(t)};ye.spread=df;ye.isAxiosError=hf;ye.mergeConfig=Ot;ye.AxiosH
Line truncated
|
||||
`):e)),i};var Tc=/\[\]$/,qs=/\r?\n/g,wc=/^(?:submit|button|image|reset|file)$/i,Sc=/^(?:input|select|textarea|keygen)/i;function Qi(e,i,s,a){var u;if(Array.isArray(i))l.each(i,function(f,g){s||Tc.test(e)?a(e,g):Qi(e+"["+(typeof g=="object"&&g!=null?f:"")+"]",g,s,a)});else if(!s&&E(i)==="object")for(u in i)Qi(e+"["+u+"]",i[u],s,a);else a(e,i)}l.param=function(e,i){var s,a=[],u=function(f,g){var b=typeof g=="function"?g():g;a[a.length]=encodeURIComponent(f)+"="+encodeURIComponent(b??"")};if(e==null)return"";if(Array.isArray(e)||e.jquery&&!l.isPlainObject(e))l.each(e,function(){u(this.name,this.value)});else for(s in e)Qi(s,e[s],i,u);return a.join("&")},l.fn.extend({serialize:function(){return l.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=l.prop(this,"elements");return e?l.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!l(this).is(":disabled")&&Sc.test(this.nodeName)&&!wc.test(e)&&(this.checked||!Yn.test(e))}).map(function(e,i){var s=l(this).val();return s==null?null:Array.isArray(s)?l.map(s,function(a){return{name:i.name,value:a.replace(qs,`\r
|
||||
`)}}):{name:i.name,value:s.replace(qs,`\r
|
||||
`)}}).get()}});var Ac=/%20/g,xc=/#.*$/,Cc=/([?&])_=[^&]*/,Oc=/^(.*?):[ \t]*([^\r\n]*)$/mg,Nc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Dc=/^(?:GET|HEAD)$/,Lc=/^\/\//,Us={},Ji={},Ws="*/".concat("*"),Zi=P.createElement("a");Zi.href=_n.href;function Vs(e){return function(i,s){typeof i!="string"&&(s=i,i="*");var a,u=0,f=i.toLowerCase().match(Re)||[];if(typeof s=="function")for(;a=f[u++];)a[0]==="+"?(a=a.slice(1)||"*",(e[a]=e[a]||[]).unshift(s)):(e[a]=e[a]||[]).push(s)}}function zs(e,i,s,a){var u={},f=e===Ji;function g(b){var y;return u[b]=!0,l.each(e[b]||[],function(T,A){var L=A(i,s,a);if(typeof L=="string"&&!f&&!u[L])return i.dataTypes.unshift(L),g(L),!1;if(f)return!(y=L)}),y}return g(i.dataTypes[0])||!u["*"]&&g("*")}function er(e,i){var s,a,u=l.ajaxSettings.flatOptions||{};for(s in i)i[s]!==void 0&&((u[s]?e:a||(a={}))[s]=i[s]);return a&&l.extend(!0,e,a),e}function Pc(e,i,s){for(var a,u,f,g,b=e.contents,y=e.dataTypes;y[0]==="*";)y.shift(),a===void 0&&(a=e.mimeType||i.getResponseHeader("Content-Type"));if(a){for(u in b)if(b[u]&&b[u].test(a)){y.unshift(u);break}}if(y[0]in s)f=y[0];else{for(u in s){if(!y[0]||e.converters[u+" "+y[0]]){f=u;break}g||(g=u)}f=f||g}if(f)return f!==y[0]&&y.unshift(f),s[f]}function Rc(e,i,s,a){var u,f,g,b,y,T={},A=e.dataTypes.slice();if(A[1])for(g in e.converters)T[g.toLowerCase()]=e.converters[g];for(f=A.shift();f;)if(e.responseFields[f]&&(s[e.responseFields[f]]=i),!y&&a&&e.dataFilter&&(i=e.dataFilter(i,e.dataType)),y=f,f=A.shift(),f){if(f==="*")f=y;else if(y!=="*"&&y!==f){if(g=T[y+" "+f]||T["* "+f],!g){for(u in T)if(b=u.split(" "),b[1]===f&&(g=T[y+" "+b[0]]||T["* "+b[0]],g)){g===!0?g=T[u]:T[u]!==!0&&(f=b[0],A.unshift(b[1]));break}}if(g!==!0)if(g&&e.throws)i=g(i);else try{i=g(i)}catch(L){return{state:"parsererror",error:g?L:"No conversion from "+y+" to "+f}}}}return{state:"success",data:i}}l.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:_n.href,type:"GET",isLocal:Nc.test(_n.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ws,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":l.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,i){return i?er(er(e,l.ajaxSettings),i):er(l.ajaxSettings,e)},ajaxPrefilter:Vs(Us),ajaxTransport:Vs(Ji),ajax:function(e,i){typeof e=="object"&&(i=e,e=void 0),i=i||{};var s,a,u,f,g,b,y,T,A,L,w=l.ajaxSetup({},i),D=w.context||w,$=w.context&&(D.nodeType||D.jquery)?l(D):l.event,ee=l.Deferred(),G=l.Callbacks("once memory"),ge=w.statusCode||{},pe={},xe={},be="canceled",le={readyState:0,getResponseHeader:function(ue){var ve;if(y){if(!f)for(f={};ve=Oc.exec(u);)f[ve[1].toLowerCase()+" "]=(f[ve[1].toLowerCase()+" "]||[]).concat(ve[2]);ve=f[ue.toLowerCase()+" "]}return ve==null?null:ve.join(", ")},getAllResponseHeaders:function(){return y?u:null},setRequestHeader:function(ue,ve){return y==null&&(ue=xe[ue.toLowerCase()]=xe[ue.toLowerCase()]||ue,pe[ue]=ve),this},overrideMimeType:function(ue){return y==null&&(w.mimeType=ue),this},statusCode:function(ue){var ve;if(ue)if(y)le.always(ue[le.status]);else for(ve in ue)ge[ve]=[ge[ve],ue[ve]];return this},abort:function(ue){var ve=ue||be;return s&&s.abort(ve),Zn(0,ve),this}};if(ee.promise(le),w.url=((e||w.url||_n.href)+"").replace(Lc,_n.protocol+"//"),w.type=i.method||i.type||w.method||w.type,w.dataTypes=(w.dataType||"*").toLowerCase().match(Re)||[""],w.crossDomain==null){b=P.createElement("a");try{b.href=w.url,b.href=b.href,w.crossDomain=Zi.protocol+"//"+Zi.host!=b.protocol+"//"+b.host}catch{w.crossDomain=!0}}if(zs(Us,w,i,le),w.data&&w.processData&&typeof w.data!="string"&&(w.data=l.param(w.data,w.traditional)),y)return le;T=l.event&&w.global,T&&l.active++===0&&l.event.trigger("ajaxStart"),w.type=w.type.toUpperCase(),w.hasContent=!Dc.test(w.type),a=w.url.replace(xc,""),w.hasContent?w.data&&w.processData&&(w.contentType||"").indexOf("application/x-www-form-urlencoded")===0&&(w.data=w.data.replace(Ac,"+")):(L=w.url.slice(a.length),w.data&&(w.processData||typeof w.data=="string")&&(a+=(Xi.test(a)?"&":"?")+w.data,delete w.data),w.cache===!1&&(a=a.replace(Cc,"$1"),L=(Xi.test(a)?"&":"?")+"_="+Bs.guid+++L),w.url=a+L),w.ifModified&&(l.lastModified[a]&&le.setRequestHeader("If-Modified-Since",l.lastModified[a]),l.etag[a]&&le.setRequestHeader("If-None-Match",l.etag[a])),(w.data&&w.hasContent&&w.contentType!==!1||i.contentType)&&le.setRequestHeader("Content-Type",w.contentType),le.setRequestHeader("Accept",w.dataTypes[0]&&w.accepts[w.dataTypes[0]]?w.accepts[w.dataTypes[0]]+(w.dataTypes[0]!=="*"?", "+Ws+"; q=0.01":""):w.accepts["*"]);for(A in w.headers)le.setRequestHeader(A,w.headers[A]);if(w.beforeSend&&(w.beforeSend.call(D,le,w)===!1||y))return le.abort();if(be="abort",G.a
Line truncated
|
||||
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.woff2": {
|
||||
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.woff2": {
|
||||
"file": "assets/fa-brands-400-BfBXV7Mm.woff2",
|
||||
"src": "../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.woff2"
|
||||
"src": "node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.woff2"
|
||||
},
|
||||
"../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2": {
|
||||
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2": {
|
||||
"file": "assets/fa-regular-400-BVHPE7da.woff2",
|
||||
"src": "../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2"
|
||||
"src": "node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2"
|
||||
},
|
||||
"../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff2": {
|
||||
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff2": {
|
||||
"file": "assets/fa-solid-900-8GirhLYJ.woff2",
|
||||
"src": "../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff2"
|
||||
"src": "node_modules/@fortawesome/fontawesome-free/webfonts/fa-solid-900.woff2"
|
||||
},
|
||||
"../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-v4compatibility.woff2": {
|
||||
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-v4compatibility.woff2": {
|
||||
"file": "assets/fa-v4compatibility-DnhYSyY-.woff2",
|
||||
"src": "../../../node_modules/@fortawesome/fontawesome-free/webfonts/fa-v4compatibility.woff2"
|
||||
"src": "node_modules/@fortawesome/fontawesome-free/webfonts/fa-v4compatibility.woff2"
|
||||
},
|
||||
"resources/css/app.css": {
|
||||
"file": "assets/app-BCx10ygF.css",
|
||||
@@ -28,7 +28,7 @@
|
||||
"src": "resources/fonts/iconfont/iconfont.woff"
|
||||
},
|
||||
"resources/js/app.js": {
|
||||
"file": "assets/app-BJweg-u1.js",
|
||||
"file": "assets/app-DDSp2ths.js",
|
||||
"name": "app",
|
||||
"src": "resources/js/app.js",
|
||||
"isEntry": true
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
.hn-article-ad {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
aspect-ratio: 2.45;
|
||||
margin: 20px 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid #181b1e;
|
||||
border-radius: 12px;
|
||||
background: #181b1e;
|
||||
}
|
||||
.article-ad-group .hn-article-ad { margin: 0; }
|
||||
.hn-image-ad__link { position: absolute; inset: 0; display: block; }
|
||||
.hn-image-ad__link img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
||||
.hn-image-ad__link:focus-visible { outline: 3px solid #b4f047; outline-offset: -4px; }
|
||||
@@ -1,5 +0,0 @@
|
||||
.random-article-ad { position: relative; min-width: 0; aspect-ratio: 2.45; margin: 20px 0; overflow: hidden; border-radius: 12px; background: #181b1e; }
|
||||
.random-article-ad[hidden] { display: none !important; }
|
||||
.random-article-ad > a { display: block; position: absolute; inset: 0; }
|
||||
.random-article-ad img { display: block; width: 100%; height: 100%; object-fit: cover; }
|
||||
.random-article-ad > a:focus-visible { outline: 3px solid #8ab4ff; outline-offset: -4px; }
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB |
@@ -1,18 +0,0 @@
|
||||
(() => {
|
||||
const slots = [];
|
||||
function choose(slot, choices) {
|
||||
const selected = choices[Math.floor(Math.random() * choices.length)];
|
||||
slot.replaceChildren(selected.content.cloneNode(true));
|
||||
slot.dataset.adSelected = selected.dataset.adChoice;
|
||||
slot.hidden = false;
|
||||
}
|
||||
document.querySelectorAll('[data-random-article-ad]').forEach(slot => {
|
||||
const choices = Array.from(slot.querySelectorAll('template[data-ad-choice]'));
|
||||
if (!choices.length) return;
|
||||
slots.push({ slot, choices });
|
||||
choose(slot, choices);
|
||||
});
|
||||
window.addEventListener('pageshow', event => {
|
||||
if (event.persisted) slots.forEach(({ slot, choices }) => choose(slot, choices));
|
||||
});
|
||||
})();
|
||||
Regular → Executable
+27
-26
@@ -7,6 +7,7 @@ import ClipboardJS from 'clipboard';
|
||||
|
||||
|
||||
const initHeaderScroll = (sHeaderSelector) => {
|
||||
console.log('检查点1:函数跑起来了,选择器是:');
|
||||
const $oHeader = $(sHeaderSelector);
|
||||
const iHeaderHeight = $oHeader.outerHeight();
|
||||
const oRoot = document.documentElement;
|
||||
@@ -16,6 +17,7 @@ const initHeaderScroll = (sHeaderSelector) => {
|
||||
const iThreshold = 5; // 加上一个细微的阈值,防止手抖产生的位移
|
||||
|
||||
$(window).on('scroll', () => {
|
||||
console.log('检查点3:你在滚,我也在动'); // 看看控制台刷不刷屏
|
||||
let iCurrentScroll = $(window).scrollTop();
|
||||
|
||||
// 1. 忽略极小的滚动(防止灵敏度过高)
|
||||
@@ -45,11 +47,26 @@ const initHeaderScroll = (sHeaderSelector) => {
|
||||
const initArticleLoader = (sContainerSelector) => {
|
||||
const $oContainer = $(sContainerSelector);
|
||||
|
||||
if ($oContainer.length === 0 || !document.querySelector('.pagination-next')) return;
|
||||
if ($oContainer.length === 0) return;
|
||||
|
||||
const oInfScroll = new InfiniteScroll($oContainer[0], {
|
||||
path: '.pagination-next',
|
||||
checkLastPage: true,
|
||||
// 使用函数式 path,灵活得飞起
|
||||
path: function() {
|
||||
let sUrl = window.location.origin + window.location.pathname; // 当前基础路径
|
||||
let sSearch = window.location.search; // 当前已有的参数(比如 ?s=关键字)
|
||||
let iNextPage = this.loadCount + 2; // InfiniteScroll 内部计数从0开始,第二页就是2
|
||||
|
||||
// 原则:判断当前 URL 是否已经有了其他参数
|
||||
if (sSearch) {
|
||||
// 如果已有参数,判断是否带 page,没有就拼 &page=,有就替换(正则处理最稳)
|
||||
if (sSearch.indexOf('page=') > -1) {
|
||||
return sSearch.replace(/page=\d+/, 'page=' + iNextPage);
|
||||
}
|
||||
return sSearch + '&page=' + iNextPage;
|
||||
} else {
|
||||
return '?page=' + iNextPage;
|
||||
}
|
||||
},
|
||||
append: '.ajax-item',
|
||||
history: false,
|
||||
// prefill: true,
|
||||
@@ -58,18 +75,7 @@ const initArticleLoader = (sContainerSelector) => {
|
||||
responseBody: 'text',
|
||||
});
|
||||
|
||||
oInfScroll.on('append', (xResponse, sPath, aItems) => {
|
||||
const seen = new Set();
|
||||
document.querySelectorAll('.ajax-item[data-article-id]').forEach(item => {
|
||||
if (seen.has(item.dataset.articleId)) item.remove(); else seen.add(item.dataset.articleId);
|
||||
});
|
||||
const nextDoc = typeof xResponse === 'string' ? new DOMParser().parseFromString(xResponse, 'text/html') : xResponse;
|
||||
// Pagination remains metadata; the existing infinite-scroll interface stays unchanged.
|
||||
for (const rel of ['next', 'prev']) {
|
||||
document.querySelector(`link.pagination-${rel}`)?.remove();
|
||||
const link = nextDoc?.querySelector(`link.pagination-${rel}`);
|
||||
if (link) document.head.appendChild(link.cloneNode(true));
|
||||
}
|
||||
$oContainer.on('append.infiniteScroll', (oEvent, xResponse, sPath, aItems) => {
|
||||
const $aNewItems = $(aItems);
|
||||
|
||||
$aNewItems.addClass('ajax-item-fade-in');
|
||||
@@ -78,6 +84,7 @@ const initArticleLoader = (sContainerSelector) => {
|
||||
$aNewItems.addClass('is-visible');
|
||||
}, 50);
|
||||
|
||||
console.log(`[ArticleLoader] s-Hungarian 风格追加成功: ${sPath}`);
|
||||
});
|
||||
|
||||
window.oMainInfScroll = oInfScroll;
|
||||
@@ -110,8 +117,7 @@ $(() => {
|
||||
$this.addClass("requesting");
|
||||
$.ajax({
|
||||
url: "/like/"+id,
|
||||
type: "POST",
|
||||
headers: {"X-CSRF-TOKEN": document.querySelector('meta[name="csrf-token"]').content},
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
}).done(function(data) {
|
||||
ncPopupTips(1, data.msg);
|
||||
@@ -129,12 +135,9 @@ $(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('keydown', function(event) {
|
||||
if (event.key === 'Escape' && $('.mobile-sidebar').hasClass('active')) $('.sidebar-close').trigger('click');
|
||||
});
|
||||
initHeaderScroll('#header');
|
||||
|
||||
document.getElementById('searchform')?.addEventListener('submit', function(e) {
|
||||
document.getElementById('searchform').addEventListener('submit', function(e) {
|
||||
e.preventDefault(); // 拦截默认提交
|
||||
let sKeywords = document.getElementById('s').value;
|
||||
if (sKeywords.trim() !== '') {
|
||||
@@ -282,6 +285,7 @@ $(() => {
|
||||
const bIsInitialized = fnTryInit(oSettings, oObjects);
|
||||
|
||||
if (!bIsInitialized) {
|
||||
console.log("TSS: Body width smaller than options.minWidth. Init delayed.");
|
||||
|
||||
$(document).on("scroll." + oSettings.sNamespace, function (e) {
|
||||
if (fnTryInit(oSettings, oObjects)) {
|
||||
@@ -480,15 +484,12 @@ $(() => {
|
||||
function toggleSidebar() {
|
||||
$(".sidebar-close, .mobile-overlay").on("click", function() {
|
||||
$("body").removeClass("modal-open");
|
||||
$(".mobile-sidebar").removeClass("active").attr("aria-hidden", "true");
|
||||
$("#sidebarCollapse").attr("aria-expanded", "false").trigger("focus");
|
||||
$(".mobile-sidebar").removeClass("active");
|
||||
$(".mobile-overlay").removeClass("active")
|
||||
});
|
||||
$("#sidebarCollapse").on("click", function() {
|
||||
$("body").addClass("modal-open");
|
||||
$(".mobile-sidebar").addClass("active").attr("aria-hidden", "false");
|
||||
$("#sidebarCollapse").attr("aria-expanded", "true");
|
||||
$(".sidebar-close").trigger("focus");
|
||||
$(".mobile-sidebar").addClass("active");
|
||||
$(".mobile-overlay").addClass("active");
|
||||
$(".collapse.in").toggleClass("in");
|
||||
$("a[aria-expanded=true]").attr("aria-expanded", "false")
|
||||
|
||||
Regular → Executable
+8
-30
@@ -7,18 +7,8 @@
|
||||
'sOgImg' => '/sites/'.config("app.site_code_short").'/siteimg.jpg',
|
||||
'sRobots' => 'index, follow',
|
||||
'bEditorialPreview' => false,
|
||||
'seo' => [],
|
||||
'pagination' => null,
|
||||
])
|
||||
|
||||
@php
|
||||
$sTitle = $seo['title'] ?? $sTitle;
|
||||
$sDesc = \App\Services\Seo::text($seo['description'] ?? $sDesc);
|
||||
$sCanonical = $seo['canonical'] ?? \App\Services\Seo::url(request()->path());
|
||||
$sRobots = $bEditorialPreview ? 'noindex, nofollow' : ($seo['robots'] ?? $sRobots);
|
||||
$sOgType = $seo['type'] ?? $sOgType;
|
||||
$sOgImg = str_starts_with($sOgImg ?? '', '/') ? \App\Services\Seo::url($sOgImg) : $sOgImg;
|
||||
@endphp
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
@@ -27,37 +17,25 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta name="slug" content="{{ $sSlug }}">
|
||||
<meta name="robots" content="{{ !app()->environment(['production','testing']) ? 'noindex, nofollow' : $sRobots }}">
|
||||
|
||||
<meta name="robots" content="{{ app()->environment('staging') ? 'noindex, nofollow' : $sRobots }}">
|
||||
|
||||
@php
|
||||
$sTodayDate = now()->format('Y年m月d日'); //有问题?
|
||||
@endphp
|
||||
|
||||
{{-- SEO 三杰 --}}
|
||||
<title>{{ $sTitle }}</title>
|
||||
<meta name="description" content="{{ $sDesc }}">
|
||||
<meta name="description" content="{{ $sTodayDate.$sDesc }}">
|
||||
<meta name="keywords" content="{{ $sKeywords }}">
|
||||
<link rel="canonical" href="{{ $sCanonical }}">
|
||||
<link rel="canonical" href="{{ url()->current() }}">
|
||||
|
||||
{{-- 社交媒体 Meta (Open Graph) - 现在的标准配置 --}}
|
||||
<meta property="og:title" content="{{ $sTitle }}">
|
||||
<meta property="og:description" content="{{ $sDesc }}">
|
||||
<meta property="og:type" content="{{ $sOgType }}">
|
||||
<meta property="og:url" content="{{ $sCanonical }}">
|
||||
<meta property="og:url" content="{{ url()->current() }}">
|
||||
<meta property="og:image" content="{{ str_starts_with($sOgImg ?? '', '/') ? url($sOgImg) : $sOgImg }}">
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta name="twitter:title" content="{{ $sTitle }}">
|
||||
<meta name="twitter:description" content="{{ $sDesc }}">
|
||||
<meta name="twitter:image" content="{{ $sOgImg }}">
|
||||
@unless($bEditorialPreview)
|
||||
@foreach($seo['schema'] ?? [] as $schema)
|
||||
<script type="application/ld+json">{!! json_encode($schema, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT) !!}</script>
|
||||
@endforeach
|
||||
@endunless
|
||||
@if($pagination)
|
||||
@if($pagination->previousPageUrl())<link class="pagination-prev" rel="prev" href="{{ $pagination->currentPage() === 2 ? $pagination->path() : $pagination->previousPageUrl() }}">@endif
|
||||
@if($pagination->nextPageUrl())<link class="pagination-next" rel="next" href="{{ $pagination->nextPageUrl() }}">@endif
|
||||
@endif
|
||||
|
||||
{{-- 声明它是 PNG,并告诉浏览器它的实际尺寸 --}}
|
||||
<link rel="icon" type="image/png" href="/sites/{{ config('app.site_code_short') }}/icon.png" sizes="166x166">
|
||||
|
||||
@@ -71,7 +49,7 @@
|
||||
|
||||
@stack('styles')
|
||||
|
||||
@if(app()->environment('production') && ! $bEditorialPreview && config('app.site_code_short') == 'cfn')
|
||||
@if(! app()->environment('staging') && ! $bEditorialPreview && config('app.site_code_short') == 'cfn')
|
||||
<script defer src="https://umami.gemcook.net/script.js" data-website-id="c553e118-942e-4d6b-9e6d-9d7e696ab5fd"></script>
|
||||
@endif
|
||||
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
@php
|
||||
$adChoices = collect([
|
||||
['key' => 'dpl', 'file' => 'dpl-ad-site-style-20261028.png', 'width' => 1962, 'height' => 801, 'alt' => 'DPL:畅连全球网络。日常访问、远程办公、在线娱乐,查看套餐。'],
|
||||
['key' => 'hn', 'file' => 'hn-ad-refined-20261031.png', 'width' => 1964, 'height' => 801, 'alt' => 'Hardnerd:硬核架构,品质专线,全球网络畅通无阻。'],
|
||||
['key' => 'fuc', 'file' => 'fuc-ad-site-style-20261028.png', 'width' => 1962, 'height' => 801, 'alt' => '福云:全球网络中继服务。随时随处,尽情使用。了解福云。'],
|
||||
])->filter(fn ($ad) => config('advertising.'.$ad['key'].'.enabled')
|
||||
&& config('advertising.'.$ad['key'].'.url')
|
||||
&& is_file(public_path('images/ads/'.$ad['file'])))->values();
|
||||
@endphp
|
||||
@if ($adChoices->isNotEmpty())
|
||||
@once
|
||||
@push('styles')
|
||||
<link rel="stylesheet" href="/css/random-article-ad.css?v={{ filemtime(public_path('css/random-article-ad.css')) }}">
|
||||
@endpush
|
||||
@endonce
|
||||
<aside class="random-article-ad" data-random-article-ad aria-label="网络服务广告" hidden>
|
||||
@foreach ($adChoices as $ad)
|
||||
<template data-ad-choice="{{ $ad['key'] }}">
|
||||
<a href="{{ config('advertising.'.$ad['key'].'.url') }}" target="_blank" rel="sponsored noopener noreferrer" aria-label="广告:{{ $ad['alt'] }}(新窗口打开)">
|
||||
<img src="/images/ads/{{ $ad['file'] }}?v={{ filemtime(public_path('images/ads/'.$ad['file'])) }}" alt="{{ $ad['alt'] }}" width="{{ $ad['width'] }}" height="{{ $ad['height'] }}" decoding="async">
|
||||
</a>
|
||||
</template>
|
||||
@endforeach
|
||||
</aside>
|
||||
<noscript>
|
||||
@php($ad = $adChoices->first())
|
||||
<aside class="random-article-ad" aria-label="网络服务广告">
|
||||
<a href="{{ config('advertising.'.$ad['key'].'.url') }}" target="_blank" rel="sponsored noopener noreferrer">
|
||||
<img src="/images/ads/{{ $ad['file'] }}?v={{ filemtime(public_path('images/ads/'.$ad['file'])) }}" alt="{{ $ad['alt'] }}" width="{{ $ad['width'] }}" height="{{ $ad['height'] }}">
|
||||
</a>
|
||||
</aside>
|
||||
</noscript>
|
||||
@once
|
||||
<script>{!! file_get_contents(public_path('js/random-article-ad.js')) !!}</script>
|
||||
@endonce
|
||||
@endif
|
||||
Regular → Executable
+4
-4
@@ -1,12 +1,12 @@
|
||||
@props(['oArticle'])
|
||||
<div class="list-item default block ajax-item" data-article-id="{{ $oArticle->id }}">
|
||||
<div class="list-item default block ajax-item">
|
||||
<div class="media media-3x2 col-4 col-md-3 col-xl-4">
|
||||
<a class="media-content" href="{{ url('/a/'.$oArticle->sSlug).'.html' }}" title="{{ $oArticle->sTitle }}" style="background-image:url('{{ $oArticle->sThumb }}')"></a>
|
||||
</div>
|
||||
<div class="list-content">
|
||||
<div class="list-body">
|
||||
<a href=" {{ url('/a/'.$oArticle->sSlug.'.html') }} " title="{{$oArticle->sTitle}}" class="list-title h5 h-2x">
|
||||
{{ $oArticle->sTitle }}
|
||||
{!! $oArticle->sTitle !!}
|
||||
</a>
|
||||
<div class="list-desc d-none d-xl-block text-secondary text-sm mt-2">
|
||||
<div class="h-2x">
|
||||
@@ -16,13 +16,13 @@
|
||||
</div>
|
||||
<div class="list-footer">
|
||||
<div class="d-flex flex-fill align-items-center text-xs text-muted">
|
||||
<a href="{{ \App\Services\Seo::url(\App\Services\Seo::categoryPath($oArticle->oCategory)) }}" class="me-2 me-md-3"><i class="text-sm iconfont icon-dots-circle me-1"></i>{!! $oArticle->oCategory->sName !!}</a>
|
||||
<a href="{{ url($oArticle->oCategory->sSlug) }}" class="me-2 me-md-3"><i class="text-sm iconfont icon-dots-circle me-1"></i>{!! $oArticle->oCategory->sName !!}</a>
|
||||
<div class="flex-fill"></div>
|
||||
@if ($oArticle->iIsTop)
|
||||
<span class="d-none d-md-inline-block ms-2 ms-md-3" style="color: var(--color-primary);">置顶</span>
|
||||
<!-- <i class="text-sm iconfont icon-pushpin me-1" style="color: var(--color-primary);"></i> -->
|
||||
@endif
|
||||
<time datetime="{{ $oArticle->created_at?->toAtomString() }}" class="d-none d-md-inline-block ms-2 ms-md-3">{{ $oArticle->sCreatedAtDiff }}</time>
|
||||
<time class="d-none d-md-inline-block ms-2 ms-md-3">{{ $oArticle->sCreatedAtDiff }}</time>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Regular → Executable
+13
-1
@@ -1 +1,13 @@
|
||||
{{-- Legacy sidebar advertisement removed at user request, 2026-10-31. --}}
|
||||
<div class="widget card widget_nice_tag_cloud">
|
||||
<div class="widget-header h6">
|
||||
广告
|
||||
<div class="widget-border"></div>
|
||||
</div>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://{{ env('url_ad_fu') }}">
|
||||
<img src="/upload/images/ad_fu.png" style="border-radius: 10px;">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
Regular → Executable
+1
-1
@@ -8,7 +8,7 @@
|
||||
{{-- Fixed Menu --}}
|
||||
<ul class="scroll-fixed-menu">
|
||||
<li id="scrollToTOP" class="scroll-to-top">
|
||||
<button aria-label="回到顶部" class="btn btn-primary btn-icon btn-rounded">
|
||||
<button class="btn btn-primary btn-icon btn-rounded">
|
||||
<span><i class="iconfont icon-arrowup"></i></span>
|
||||
</button>
|
||||
</li>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
@if (config('advertising.hn.enabled') && config('advertising.hn.url') && is_file(public_path('images/ads/hn-ad-refined-20261031.png')))
|
||||
@once
|
||||
@push('styles')
|
||||
<link rel="stylesheet" href="/css/hn-article-ad.css?v={{ filemtime(public_path('css/hn-article-ad.css')) }}">
|
||||
@endpush
|
||||
@endonce
|
||||
<aside class="hn-article-ad hn-image-ad" aria-label="HN 图片广告">
|
||||
<a class="hn-image-ad__link" href="{{ config('advertising.hn.url') }}" target="_blank" rel="sponsored noopener noreferrer" aria-label="广告:了解 Hardnerd 网络服务(新窗口打开)">
|
||||
<img src="/images/ads/hn-ad-refined-20261031.png?v={{ filemtime(public_path('images/ads/hn-ad-refined-20261031.png')) }}" alt="Hardnerd 广告:硬核架构,品质专线,全球网络畅通无阻" width="1964" height="801">
|
||||
</a>
|
||||
</aside>
|
||||
@endif
|
||||
Regular → Executable
+3
-5
@@ -10,10 +10,9 @@ class="d-none logo-dark nc-no-lazy"
|
||||
alt="{{ config('app.name') }}">
|
||||
</a>
|
||||
<button class="btn btn-link btn-icon btn-sm btn-rounded navbar-toggler order-1" type="button"
|
||||
id="sidebarCollapse" aria-label="打开导航菜单" aria-controls="mobile-navigation" aria-expanded="false">
|
||||
id="sidebarCollapse">
|
||||
<span><i class="iconfont icon-menu"></i></span>
|
||||
</button>
|
||||
<div class="d-xl-none order-3 ms-auto me-2">@include('components.telegram-link')</div>
|
||||
<button class="btn btn-link btn-icon btn-sm btn-rounded navbar-toggler nav-search order-3 collapsed"
|
||||
data-bs-target="#navbar-search" data-bs-toggle="collapse" aria-expanded="false"
|
||||
aria-controls="navbar-search">
|
||||
@@ -52,7 +51,6 @@ class="d-none logo-dark nc-no-lazy"
|
||||
</ul>
|
||||
<ul class="navbar-nav align-items-center">
|
||||
<li class="nav-item me-2 me-md-3">
|
||||
@include('components.telegram-link')
|
||||
<a href="{{ config('path.url_github_href') }}" target="_blank" rel="noopener noreferrer">
|
||||
<button class="btn btn-link btn-icon btn-sm btn-rounded nav-search collapsed">
|
||||
<span>
|
||||
@@ -74,10 +72,10 @@ class="d-none logo-dark nc-no-lazy"
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="mobile-sidebar" id="mobile-navigation" aria-hidden="true">
|
||||
<div class="mobile-sidebar">
|
||||
<div class="mobile-sidebar-inner">
|
||||
<div class="mobile-sidebar-header text-end p-3">
|
||||
<button type="button" class="btn btn-text btn-icon btn-rounded sidebar-close" aria-label="关闭导航菜单">
|
||||
<button type="button" class="btn btn-text btn-icon btn-rounded sidebar-close">
|
||||
<span><i class="text-xl iconfont icon-close-circle-fill"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
<a href="{{ config('community.telegram_url') }}" target="_blank" rel="noopener noreferrer"
|
||||
class="btn btn-link btn-icon btn-sm btn-rounded community-telegram"
|
||||
aria-label="加入 Telegram 频道(新窗口打开)" title="Telegram 频道"
|
||||
style="display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;padding:8px;color:#229ed9">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">
|
||||
<path d="M21.94 4.67 18.9 19c-.23 1.01-.83 1.26-1.67.79l-4.63-3.41-2.23 2.15c-.25.25-.46.46-.95.46l.33-4.71 8.58-7.75c.37-.33-.08-.52-.57-.19L7.15 13.02l-4.57-1.43c-.99-.31-1.01-.99.21-1.47L20.66 3.23c.83-.31 1.56.2 1.28 1.44Z"/>
|
||||
</svg>
|
||||
</a>
|
||||
Regular → Executable
-2
@@ -1,6 +1,4 @@
|
||||
<x-app-layout
|
||||
:seo="$seo"
|
||||
:pagination="$oArticles"
|
||||
:sSlug="$oCategory->sSlug ?? ''"
|
||||
:sTitle="isset($oCategory) && in_array($oCategory->sSlug, ['client', 'advanced']) ? $oCategory->sName . ' - ' . config('app.name') : config('app.title') . ' - ' . config('app.name')"
|
||||
:sDesc="isset($oCategory) && in_array($oCategory->sSlug, ['client', 'advanced']) ? $oCategory->sDescription : config('app.desc')"
|
||||
|
||||
Regular → Executable
+12
-13
@@ -1,16 +1,17 @@
|
||||
@php
|
||||
$bIsHome = $bIsHome ?? false;
|
||||
$seo = $seo ?? \App\Services\Seo::articleMeta($oArticle);
|
||||
$iNoIndexDays = (int) ($oArticle->oCategory->aOpt['noindexday'] ?? 0);
|
||||
$bIsExpired = $iNoIndexDays > 0 && $oArticle->created_at->copy()->addDays($iNoIndexDays)->isPast();
|
||||
$bIsHome = request()->routeIs('articles.home');
|
||||
$sRobotsStatus = ! $bIsHome && $bIsExpired ? 'noindex, follow' : 'index, follow';
|
||||
@endphp
|
||||
|
||||
<x-app-layout
|
||||
:seo="$seo"
|
||||
:sSlug="$oCategory->sSlug ?? ''"
|
||||
:sTitle="$oArticle->sTitle . ' - ' . $oArticle->oCategory->sName"
|
||||
:sDesc="$oArticle->sTitleSub"
|
||||
sOgType="article"
|
||||
:sOgImg="$oArticle->sThumb"
|
||||
:sRobots="($bEditorialPreview ?? false) ? 'noindex, nofollow' : $seo['robots']"
|
||||
:sRobots="($bEditorialPreview ?? false) ? 'noindex, nofollow' : $sRobotsStatus"
|
||||
:bEditorialPreview="$bEditorialPreview ?? false"
|
||||
>
|
||||
|
||||
@@ -36,7 +37,7 @@
|
||||
<i class="text-primary iconfont icon-dot"></i>
|
||||
</span>
|
||||
<span itemprop="itemListElement">
|
||||
<a href="{{ \App\Services\Seo::url(\App\Services\Seo::categoryPath($oArticle->oCategory->oParent)) }}" itemprop="item">
|
||||
<a href="{{ url($oArticle->oCategory->oParent->sSlug) }}" itemprop="item">
|
||||
<span itemprop="name">{{ $oArticle->oCategory->oParent->sName }}</span>
|
||||
</a>
|
||||
</span>
|
||||
@@ -45,7 +46,7 @@
|
||||
<i class="text-primary iconfont icon-dot"></i>
|
||||
</span>
|
||||
<span itemprop="itemListElement">
|
||||
<a href="{{ \App\Services\Seo::url(\App\Services\Seo::categoryPath($oArticle->oCategory)) }}" itemprop="item">
|
||||
<a href="{{ url($oArticle->oCategory->sSlug) }}" itemprop="item">
|
||||
<span itemprop="name">{{ $oArticle->oCategory->sName }}</span>
|
||||
</a>
|
||||
</span>
|
||||
@@ -63,25 +64,23 @@
|
||||
<div class="post-meta text-xs">
|
||||
<a href="/"><i class="text-sm iconfont icon-user1 me-1"></i>{{ config('app.name') }}</a>
|
||||
<i class="text-primary iconfont icon-dot mx-2"></i>
|
||||
<time class="text-muted" datetime="{{ $oArticle->created_at?->toAtomString() }}">发布于 {{ $oArticle->sCreatedAtDiff }}</time>
|
||||
<span class="text-muted">发布于 {{ $oArticle->sCreatedAtDiff }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
@if ($oArticle->bPageThumb && $oArticle->sThumb)
|
||||
<p>
|
||||
<img decoding="async" alt="" class="size-full wp-image-28 aligncenter" src="{{ $oArticle->sThumb }}" style="border-radius: 6px;">
|
||||
<img decoding="async" class="size-full wp-image-28 aligncenter" src="{{ $oArticle->sThumb }}" style="border-radius: 6px;">
|
||||
</p>
|
||||
@endif
|
||||
{!! nl2br(\App\Services\Seo::body(\App\Services\ResourceArticlePresentation::body($oArticle->sContent ?? '', $oArticle->oCategory?->sSlug))) !!}
|
||||
{!! nl2br($oArticle->sContent) !!}
|
||||
</div>
|
||||
|
||||
|
||||
@include('components.article-ads')
|
||||
|
||||
<div class="post-tags mt-3 mt-md-4">
|
||||
<div class="">
|
||||
@foreach($oArticle->oTags as $oTag)
|
||||
<a href="/tag/{{ $oTag->sSlug }}" rel="tag"><span># {{ $oTag->sName }}</span></a>
|
||||
<a href="/tag/{{ $oTag->sSlug }}" rel"rag"><span># {{ $oTag->sName }}</span></a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,7 +100,7 @@ class="post-like-button btn btn-light btn-w-md btn-rounded me-2"
|
||||
<template id="single-share-template">
|
||||
<div class="row g-0 text-center justify-content-center py-3 py-md-4 mx-md-0">
|
||||
<div class="col-4 col-md-3">
|
||||
<a href="javascript:;" id="urlCopy" data-clipboard-text="{{ $seo['canonical'] }}" class="d-inline-block copy-permalink">
|
||||
<a href="javascript:;" id="urlCopy" data-clipboard-text="{{ config('app.url') }}" class="d-inline-block copy-permalink">
|
||||
<div class="btn btn-light btn-icon btn-md btn-rounded mb-1">
|
||||
<span><i class="iconfont icon-link"></i></span>
|
||||
</div>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<x-app-layout sTitle="资源暂不可用" sRobots="noindex, follow"><main class="container py-5"><h1>资源暂不可用</h1><p>暂时没有可展示的节点记录,请稍后再试。</p><a href="/client">查看入门教程</a></main></x-app-layout>
|
||||
Regular → Executable
+16
-3
@@ -1,6 +1,19 @@
|
||||
{!! '<' . '?xml version="1.0" encoding="UTF-8"?' . '>' !!}
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
@foreach($entries as $entry)
|
||||
<url><loc>{{ $entry['url'] }}</loc>@if($entry['modified'])<lastmod>{{ $entry['modified'] }}</lastmod>@endif</url>
|
||||
@endforeach
|
||||
{{-- 首页 --}}
|
||||
<url>
|
||||
<loc>{{ config('app.url') }}</loc>
|
||||
<priority>1.0</priority>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
|
||||
{{-- 未过期的文章 --}}
|
||||
@foreach($cArticles as $oArticles)
|
||||
<url>
|
||||
<loc>{{ config('app.url') }}/a/{{ $oArticles->sSlug }}.html</loc>
|
||||
<lastmod>{{ \Carbon\Carbon::parse($oArticles->updated_at)->tz('UTC')->toAtomString() }}</lastmod>
|
||||
<priority>0.8</priority>
|
||||
<changefreq>daily</changefreq>
|
||||
</url>
|
||||
@endforeach
|
||||
</urlset>
|
||||
Regular → Executable
-4
@@ -19,8 +19,6 @@
|
||||
|
||||
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. 没传参数?直接亮红牌!
|
||||
@@ -54,5 +52,3 @@
|
||||
//
|
||||
// $this->info("表 [{$sTable}] 重建成功!任务完成!");
|
||||
//})->purpose('定点爆破并重建指定的表,不带参数不动手');
|
||||
|
||||
Schedule::command('seo:indexnow-retry')->everyFiveMinutes()->environments(['production'])->withoutOverlapping(10);
|
||||
Regular → Executable
+1
-4
@@ -15,14 +15,11 @@
|
||||
Route::get('robots.txt', [RobotsController::class, 'index']);
|
||||
Route::get('sitemap.xml', [SitemapController::class, 'index']);
|
||||
|
||||
if (app()->environment('local')) {
|
||||
Route::get('/test/hello', [TestController::class, 'hello']); // 找个控制器为什么无效了
|
||||
Route::get('/test/test1', [TestController::class, 'test1']);
|
||||
Route::get('/test/test2', [TestController::class, 'test2']);
|
||||
Route::get('/test/test3', [TestController::class, 'test3']);
|
||||
|
||||
}
|
||||
|
||||
Route::post('/api/article/receive/shadowrocketids', [ApiV1ArticlesController::class, 'receiveShadowrocketids']);
|
||||
Route::post('/api/article/receive/freenode', [ApiV1ArticlesController::class, 'receiveFreenode']);
|
||||
Route::post('/api/article/receive', [ApiV1ArticlesController::class, 'receive']);
|
||||
@@ -32,7 +29,7 @@
|
||||
Route::get('/', [ArticlesController::class, 'home'])
|
||||
->name('articles.home');
|
||||
|
||||
Route::post('/like/{iId}', [ArticlesController::class, 'like'])->name('article.like');
|
||||
Route::get('/like/{iId}', [ArticlesController::class, 'like'])->name('article.like');
|
||||
|
||||
Route::get('/search/{sKeyword}', [ArticlesController::class, 'search'])->where('sKeywords', '.*')->name('article.list.search');
|
||||
//Route::get('/s/ajax/{sKeyword}', [ArticlesController::class, 'searchAjax'])->name('article.list.search.ajax');
|
||||
|
||||
@@ -75,8 +75,6 @@ protected function setUp(): void
|
||||
});
|
||||
(require database_path('migrations/2026_10_27_190000_create_editorial_tables.php'))->up();
|
||||
(require database_path('migrations/2026_10_29_200000_add_one_year_article_likes.php'))->up();
|
||||
(require database_path('migrations/2026_10_31_150000_add_article_display_timestamp.php'))->up();
|
||||
(require database_path('migrations/2026_10_31_160000_add_article_seo_state.php'))->up();
|
||||
DB::table('categories')->insert([
|
||||
['id' => 1, 'sSlug' => 'freenode', 'sName' => '资源'], ['id' => 3, 'sSlug' => 'windows', 'sName' => 'Windows'],
|
||||
['id' => 10, 'sSlug' => 'advanced', 'sName' => '进阶教程'],
|
||||
@@ -183,7 +181,7 @@ public function test_authentication_and_environment_binding_and_cache_bypass():
|
||||
$this->getJson('/api/editorial/v1/catalog')->assertOk()->assertHeader('Cache-Control', 'no-store, private');
|
||||
config(['responsecache.enabled' => true]);
|
||||
$this->assertFalse(app(ArticleResponseCacheProfile::class)->enabled(Request::create('/api/editorial/v1/catalog')));
|
||||
$this->assertFalse(app(ArticleResponseCacheProfile::class)->enabled(Request::create('/windows')));
|
||||
$this->assertTrue(app(ArticleResponseCacheProfile::class)->enabled(Request::create('/windows')));
|
||||
file_put_contents($this->credential, json_encode(['project' => 'fna-v3', 'environment' => 'production', 'schema' => 'gemdocs.credential.v1', 'fields' => ['api_key' => $this->token]]));
|
||||
$this->getJson('/api/editorial/v1/catalog')->assertStatus(503);
|
||||
}
|
||||
@@ -390,116 +388,4 @@ 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', 'https://example.org/advanced']);
|
||||
$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, 'iShowChildren' => 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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,290 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Services\Editorial\ProcessApi;
|
||||
use App\Services\Editorial\ReleaseRunner;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses]
|
||||
#[\PHPUnit\Framework\Attributes\PreserveGlobalState(false)]
|
||||
class EditorialReleaseTest extends \Tests\TestCase
|
||||
{
|
||||
private string $releaseRoot;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
config(['database.default' => 'sqlite', 'database.connections.sqlite.database' => ':memory:',
|
||||
'editorial.enabled' => false, 'editorial.base_url' => 'http://localhost',
|
||||
'scout.driver' => 'collection', 'responsecache.enabled' => false, 'cache.default' => 'array']);
|
||||
DB::purge('sqlite');
|
||||
Http::preventStrayRequests();
|
||||
Schema::create('categories', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->string('sSlug');
|
||||
$t->string('sName');
|
||||
$t->integer('iParentId')->default(0);
|
||||
$t->integer('iStatus')->default(1);
|
||||
$t->integer('iSort')->default(0);
|
||||
$t->integer('iShowChildren')->default(0);
|
||||
$t->string('sHtmlClass')->nullable();
|
||||
$t->text('aOpt')->nullable();
|
||||
});
|
||||
Schema::create('articles', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->integer('iCategoryId');
|
||||
$t->integer('iUserId')->default(1);
|
||||
$t->string('sSlug')->unique();
|
||||
$t->string('sTitle');
|
||||
$t->string('sTitleSub')->nullable();
|
||||
$t->text('sContent');
|
||||
$t->string('sThumb')->nullable();
|
||||
$t->integer('iStatus')->default(1);
|
||||
$t->boolean('bPageThumb')->default(false);
|
||||
foreach (['iViews', 'iLikeCount', 'i7like', 'i365like', 'iIsTop'] as $field) {
|
||||
$t->integer($field)->default(0);
|
||||
}
|
||||
$t->timestamp('sLastLikedAt')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
Schema::create('tags', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->string('sSlug');
|
||||
$t->string('sName');
|
||||
$t->integer('iArticleCount')->default(0);
|
||||
});
|
||||
Schema::create('article_tag', function (Blueprint $t) {
|
||||
$t->integer('iArticleId');
|
||||
$t->integer('iTagId');
|
||||
});
|
||||
(require database_path('migrations/2026_10_27_190000_create_editorial_tables.php'))->up();
|
||||
(require database_path('migrations/2026_10_29_200000_add_one_year_article_likes.php'))->up();
|
||||
(require database_path('migrations/2026_10_31_150000_add_article_display_timestamp.php'))->up();
|
||||
DB::table('categories')->insert([
|
||||
['id' => 1, 'sSlug' => 'freenode', 'sName' => '资源'], ['id' => 3, 'sSlug' => 'windows', 'sName' => 'Windows'],
|
||||
['id' => 10, 'sSlug' => 'advanced', 'sName' => '进阶教程'],
|
||||
]);
|
||||
DB::table('tags')->insert(['id' => 1, 'sSlug' => 'clash', 'sName' => 'Clash']);
|
||||
$this->releaseRoot = sys_get_temp_dir().'/fna-release-test-'.Str::uuid();
|
||||
config(['editorial.enabled' => false, 'editorial.release_directory' => $this->releaseRoot]);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
foreach (glob($this->releaseRoot.'/*') ?: [] as $file) {
|
||||
unlink($file);
|
||||
}
|
||||
@rmdir($this->releaseRoot);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function bundle(): array
|
||||
{
|
||||
return ['operation' => 'prepare', 'release_id' => (string) Str::uuid(), 'articles' => [[
|
||||
'content_key' => 'release-example', 'expected_revision' => 0, 'slug' => 'release-example',
|
||||
'title' => '发布演练', 'summary' => '演练摘要', 'category_slug' => 'advanced',
|
||||
'body' => '<h2 id="check">检查</h2><p>正文测试。</p>',
|
||||
]]];
|
||||
}
|
||||
|
||||
public function test_release_retry_after_lost_response_preserves_ids_and_single_publication(): void
|
||||
{
|
||||
$runner = app(ReleaseRunner::class);
|
||||
$bundle = $this->bundle();
|
||||
$prepared = $runner->run($bundle);
|
||||
$repeat = $runner->run($bundle);
|
||||
$this->assertSame($prepared['publication_request_id'], $repeat['publication_request_id']);
|
||||
$this->assertSame(1, DB::table('editorial_documents')->value('revision'));
|
||||
$this->assertFalse(config('editorial.enabled'));
|
||||
$this->assertNull(config('editorial.process_credential'));
|
||||
$review = $runner->run(['operation' => 'review', 'release_id' => $bundle['release_id']]);
|
||||
$this->assertStringContainsString('正文测试', $review['previews']['release-example']);
|
||||
$publish = ['operation' => 'publish', 'release_id' => $bundle['release_id'],
|
||||
'expected_hash' => $review['review']['hash'], 'review_digest' => $review['review']['digest']];
|
||||
// Server committed, but the caller lost its response before saving the local receipt.
|
||||
app(ProcessApi::class)->call('POST', 'drafts/'.$prepared['draft_id'].'/publish', [
|
||||
'request_id' => $prepared['publication_request_id'], 'expected_hash' => $review['review']['hash']]);
|
||||
$done = $runner->run($publish);
|
||||
$this->assertSame('complete', $done['phase']);
|
||||
$again = $runner->run($publish);
|
||||
$this->assertSame($done['receipt'], $again['receipt']);
|
||||
$this->assertSame(1, DB::table('articles')->count());
|
||||
$this->assertSame(1, DB::table('editorial_publications')->count());
|
||||
$this->assertFalse(config('editorial.enabled'));
|
||||
$this->assertNull(config('editorial.process_credential'));
|
||||
$this->getJson('/api/editorial/v1/catalog')->assertStatus(503);
|
||||
}
|
||||
|
||||
public function test_release_changed_input_and_unreviewed_publish_fail_closed(): void
|
||||
{
|
||||
$runner = app(ReleaseRunner::class);
|
||||
$bundle = $this->bundle();
|
||||
$runner->run($bundle);
|
||||
try {
|
||||
$runner->run(['operation' => 'publish', 'release_id' => $bundle['release_id']]);
|
||||
$this->fail('Unreviewed publication accepted');
|
||||
} catch (HttpException $e) {
|
||||
$this->assertSame(409, $e->getStatusCode());
|
||||
}
|
||||
$bundle['articles'][0]['body'] .= '变动';
|
||||
try {
|
||||
$runner->run($bundle);
|
||||
$this->fail('Changed bundle accepted');
|
||||
} catch (HttpException $e) {
|
||||
$this->assertSame(409, $e->getStatusCode());
|
||||
}
|
||||
$this->assertSame(0, DB::table('articles')->count());
|
||||
$this->assertFalse(config('editorial.enabled'));
|
||||
}
|
||||
|
||||
public function test_release_lock_and_failure_restore_process_permission(): void
|
||||
{
|
||||
mkdir($this->releaseRoot, 0700, true);
|
||||
$lock = fopen($this->releaseRoot.'/runner.lock', 'c');
|
||||
flock($lock, LOCK_EX);
|
||||
try {
|
||||
app(ReleaseRunner::class)->run($this->bundle());
|
||||
$this->fail('Concurrent release accepted');
|
||||
} catch (HttpException $e) {
|
||||
$this->assertSame(409, $e->getStatusCode());
|
||||
} finally {
|
||||
flock($lock, LOCK_UN);
|
||||
fclose($lock);
|
||||
}
|
||||
$bundle = $this->bundle();
|
||||
$bundle['articles'][0]['category_slug'] = 'unknown';
|
||||
try {
|
||||
app(ReleaseRunner::class)->run($bundle);
|
||||
$this->fail('Unknown category accepted');
|
||||
} catch (HttpException $e) {
|
||||
$this->assertSame(422, $e->getStatusCode());
|
||||
}
|
||||
$this->assertFalse(config('editorial.enabled'));
|
||||
$this->assertNull(config('editorial.process_credential'));
|
||||
$this->assertSame(0, DB::table('articles')->count());
|
||||
}
|
||||
|
||||
public function test_release_expired_process_credential_is_rejected(): void
|
||||
{
|
||||
config(['editorial.enabled' => true, 'editorial.process_credential' => ['expires_at' => time() - 1]]);
|
||||
$this->getJson('/api/editorial/v1/catalog')->assertStatus(401);
|
||||
}
|
||||
|
||||
public function test_release_asset_batch_and_pending_effects_recover_without_republishing(): void
|
||||
{
|
||||
$bundle = $this->bundle();
|
||||
$bytes = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aXZkAAAAASUVORK5CYII=');
|
||||
$sha = hash('sha256', $bytes);
|
||||
$bundle['assets'] = [['name' => 'diagram', 'base64' => base64_encode($bytes)]];
|
||||
$bundle['articles'][0]['body'] .= '<img src="file:diagram" alt="示意图">';
|
||||
$runner = app(ReleaseRunner::class);
|
||||
try {
|
||||
$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']];
|
||||
config(['scout.driver' => null]);
|
||||
$pending = $runner->run($publish);
|
||||
$this->assertSame('published_pending', $pending['phase']);
|
||||
$this->assertStringContainsString('/images/editorial/'.$sha.'.png', DB::table('articles')->value('sContent'));
|
||||
$this->assertSame($sha, hash_file('sha256', public_path('images/editorial/'.$sha.'.png')));
|
||||
config(['scout.driver' => 'collection']);
|
||||
$done = $runner->run($publish);
|
||||
$this->assertSame('complete', $done['phase']);
|
||||
$this->assertTrue($done['readback'][0]['content_matches']);
|
||||
$this->assertNotEmpty($done['published_at']);
|
||||
$this->assertSame(1, DB::table('editorial_publications')->count());
|
||||
// An external edit cannot be reported as verified merely because revision metadata matches.
|
||||
DB::table('articles')->update(['sTitle' => '并行修改']);
|
||||
$check = $runner->run(['operation' => 'status', 'release_id' => $bundle['release_id']]);
|
||||
$this->assertSame('published_pending', $check['phase']);
|
||||
} finally {
|
||||
@unlink(app(\App\Services\Editorial\ContentRenderer::class)->privateImage($sha));
|
||||
@unlink(public_path('images/editorial/'.$sha.'.png'));
|
||||
}
|
||||
}
|
||||
|
||||
public function test_release_superseded_draft_does_not_publish(): void
|
||||
{
|
||||
$runner = app(ReleaseRunner::class);
|
||||
$bundle = $this->bundle();
|
||||
$runner->run($bundle);
|
||||
$review = $runner->run(['operation' => 'review', 'release_id' => $bundle['release_id']]);
|
||||
$other = $bundle;
|
||||
$other['release_id'] = (string) Str::uuid();
|
||||
$other['articles'][0]['expected_revision'] = 1;
|
||||
$other['articles'][0]['body'] = '其他编辑的新版本';
|
||||
$runner->run($other);
|
||||
try {
|
||||
$runner->run(['operation' => 'publish', 'release_id' => $bundle['release_id'],
|
||||
'expected_hash' => $review['review']['hash'], 'review_digest' => $review['review']['digest']]);
|
||||
$this->fail('Superseded draft accepted');
|
||||
} catch (HttpException $e) {
|
||||
$this->assertSame(409, $e->getStatusCode());
|
||||
}
|
||||
$this->assertSame(0, DB::table('articles')->count());
|
||||
$this->assertFalse(config('editorial.enabled'));
|
||||
}
|
||||
|
||||
public function test_release_display_time_is_frozen_and_real_publish_time_is_preserved(): void
|
||||
{
|
||||
$this->travelTo(\Carbon\Carbon::parse('2026-11-02 15:37:42'));
|
||||
$runner = app(ReleaseRunner::class);
|
||||
$bundle = $this->bundle();
|
||||
$prepared = $runner->run($bundle);
|
||||
$offset = $prepared['draft']['articles'][0]['display_offset_seconds'];
|
||||
$this->assertGreaterThanOrEqual(0, $offset);
|
||||
$this->assertLessThanOrEqual(21600, $offset);
|
||||
$this->assertSame($offset, $runner->run($bundle)['draft']['articles'][0]['display_offset_seconds']);
|
||||
$review = $runner->run(['operation' => 'review', 'release_id' => $bundle['release_id']]);
|
||||
$runner->run(['operation' => 'publish', 'release_id' => $bundle['release_id'],
|
||||
'expected_hash' => $review['review']['hash'], 'review_digest' => $review['review']['digest']]);
|
||||
$article = DB::table('articles')->first();
|
||||
$this->assertSame('2026-11-02 15:37:42', $article->created_at);
|
||||
$this->assertSame($article->created_at, $article->sYearLikeStartedAt);
|
||||
$this->assertSame(now()->subSeconds($offset)->toDateTimeString(), $article->sDisplayPublishedAt);
|
||||
$model = new \App\Models\Articles;
|
||||
$model->forceFill(['created_at' => now(), 'sDisplayPublishedAt' => now()->subHours(4)->toDateTimeString()]);
|
||||
$this->assertSame('4小时前', $model->sCreatedAtDiff);
|
||||
$edit = $this->bundle();
|
||||
$edit['articles'][0]['expected_revision'] = 1;
|
||||
$edit['articles'][0]['body'] = '更新正文';
|
||||
$runner->run($edit);
|
||||
$review = $runner->run(['operation' => 'review', 'release_id' => $edit['release_id']]);
|
||||
$runner->run(['operation' => 'publish', 'release_id' => $edit['release_id'],
|
||||
'expected_hash' => $review['review']['hash'], 'review_digest' => $review['review']['digest']]);
|
||||
$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);
|
||||
}
|
||||
|
||||
}
|
||||
Regular → Executable
+8
-5
@@ -2,15 +2,18 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
// use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
public function test_health_endpoint_boots_without_content_and_stays_out_of_search(): void
|
||||
/**
|
||||
* A basic test example.
|
||||
*/
|
||||
public function test_the_application_returns_a_successful_response(): void
|
||||
{
|
||||
// Homepage content has its own fixtures and tests in SeoContractTest.
|
||||
$this->get('/up')
|
||||
->assertOk()
|
||||
->assertHeader('X-Robots-Tag', 'noindex, nofollow');
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
#[\PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses]
|
||||
#[\PHPUnit\Framework\Attributes\PreserveGlobalState(false)]
|
||||
class IllustrationDeliveryTest extends TestCase
|
||||
{
|
||||
private string $dir;
|
||||
|
||||
private string $id = '11111111-1111-4111-8111-111111111111';
|
||||
|
||||
private string $asset = '22222222-2222-4222-8222-222222222222';
|
||||
|
||||
private string $sha;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->app['env'] = 'production';
|
||||
$this->dir = sys_get_temp_dir().'/delivery-fna-'.bin2hex(random_bytes(8));
|
||||
mkdir($this->dir, 0700, true);
|
||||
mkdir($this->dir.'/public');
|
||||
file_put_contents($this->dir.'/credential.json', json_encode(['project' => 'fna-v3', 'base_url' => 'https://resource-v2.gemcook.net', 'token' => 'rsv2_'.str_repeat('a', 64)]));
|
||||
config(['illustrations.enabled' => true, 'illustrations.local_enabled' => true, 'illustrations.delivery_enabled' => true, 'illustrations.base_url' => 'https://resource-v2.gemcook.net', 'illustrations.credential_file' => $this->dir.'/credential.json', 'illustrations.local_directory' => $this->dir.'/public', 'illustrations.local_manifest' => $this->dir.'/manifest.json']);
|
||||
$this->sha = hash('sha256', 'verified-copy');
|
||||
file_put_contents($this->dir.'/public/'.$this->sha.'.webp', 'verified-copy');
|
||||
file_put_contents($this->dir.'/manifest.json', json_encode(['version' => 1, 'assets' => [$this->asset => ['sha256' => $this->sha, 'mime' => 'image/webp', 'bytes' => strlen('verified-copy'), 'url' => '/images/illustrations/'.$this->sha.'.webp']], 'selections' => ['freenode' => ['old-article' => 'old-asset']]]));
|
||||
Http::preventStrayRequests();
|
||||
Artisan::all();
|
||||
\Illuminate\Support\Facades\Schema::create('articles', function ($t) {
|
||||
$t->id();
|
||||
$t->integer('iCategoryId');
|
||||
$t->integer('iStatus');
|
||||
$t->string('sSlug');
|
||||
$t->timestamp('created_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
File::deleteDirectory($this->dir);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function fake(int $sync = 0, int $ack = 200): void
|
||||
{
|
||||
|
||||
Http::fake([
|
||||
'https://resource-v2.gemcook.net/api/v2/pools/*' => Http::response(['data' => ['items' => [['asset_id' => $this->asset, 'url' => 'https://resource-v2.gemcook.net/media/'.$this->id]], 'selections' => [], 'unavailable' => [], 'next' => null]], $sync ? 503 : 200),
|
||||
'https://resource-v2.gemcook.net/api/v2/illustration-deliveries' => Http::response(['data' => [['id' => $this->id, 'state' => 'awaiting_sync', 'fingerprint' => str_repeat('b', 64), 'assets' => [['asset_id' => $this->asset, 'sha256' => $this->sha, 'pool' => 'freenode']]]]]),
|
||||
'https://resource-v2.gemcook.net/api/v2/illustration-deliveries/*/ack' => Http::response(['data' => ['state' => 'completed']], $ack),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_verified_copy_is_acknowledged_and_lost_ack_can_retry(): void
|
||||
{
|
||||
$this->fake(0, 503);
|
||||
$this->artisan('illustrations:sync-deliveries')->assertExitCode(1);
|
||||
Http::swap(new \Illuminate\Http\Client\Factory);
|
||||
Http::preventStrayRequests();
|
||||
$this->fake();
|
||||
$this->artisan('illustrations:sync-deliveries')->assertExitCode(0);
|
||||
$this->assertSame('old-asset', json_decode(file_get_contents($this->dir.'/manifest.json'), true)['selections']['freenode']['old-article']);
|
||||
Http::assertSent(fn ($r) => str_ends_with($r->url(), '/ack') && $r['fingerprint'] === str_repeat('b', 64) && $r['manifest_sha256'] === hash_file('sha256', $this->dir.'/manifest.json'));
|
||||
}
|
||||
|
||||
public function test_failed_sync_sends_no_ack(): void
|
||||
{
|
||||
$this->fake(1);
|
||||
$this->artisan('illustrations:sync-deliveries')->assertExitCode(1);
|
||||
Http::assertNotSent(fn ($r) => str_ends_with($r->url(), '/ack'));
|
||||
}
|
||||
|
||||
public function test_corrupt_copy_sends_no_ack(): void
|
||||
{
|
||||
$this->fake();
|
||||
file_put_contents($this->dir.'/public/'.$this->sha.'.webp', 'corrupt');
|
||||
$this->artisan('illustrations:sync-deliveries')->assertExitCode(1);
|
||||
Http::assertNotSent(fn ($r) => str_ends_with($r->url(), '/ack'));
|
||||
}
|
||||
|
||||
public function test_disabled_worker_does_not_contact_resource(): void
|
||||
{
|
||||
config(['illustrations.delivery_enabled' => false]);
|
||||
$this->artisan('illustrations:sync-deliveries')->assertExitCode(1);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
}
|
||||
@@ -24,8 +24,6 @@ protected function setUp(): void
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('sSlug');
|
||||
$table->integer('iStatus')->default(1);
|
||||
$table->integer('iParentId')->default(0);
|
||||
});
|
||||
Schema::create('articles', function (Blueprint $table) {
|
||||
$table->id();
|
||||
@@ -72,11 +70,11 @@ public function test_empty_pool_and_equal_dates_are_deterministic(): void
|
||||
$this->assertSame('second', $service->getLatestFreeNodeSlug());
|
||||
}
|
||||
|
||||
public function test_personalized_html_bypasses_response_cache(): void
|
||||
public function test_home_bypasses_cache_and_categories_keep_existing_cache_policy(): void
|
||||
{
|
||||
config(['responsecache.enabled' => true]);
|
||||
$profile = app(ArticleResponseCacheProfile::class);
|
||||
$this->assertFalse($profile->enabled(Request::create('/')));
|
||||
$this->assertFalse($profile->enabled(Request::create('/freenode')));
|
||||
$this->assertTrue($profile->enabled(Request::create('/freenode')));
|
||||
}
|
||||
}
|
||||
@@ -111,35 +111,14 @@ public function test_new_article_assignment_downloads_before_returning_local_url
|
||||
Http::assertSentCount(4); // Two assignment requests; content downloaded once.
|
||||
}
|
||||
|
||||
public function test_source_withdrawal_disabling_and_deletion_preserve_independent_local_copies(): void
|
||||
public function test_sync_stops_showing_withdrawn_mapping_without_automatically_deleting_shared_file(): void
|
||||
{
|
||||
$this->fakeImages();$local = app(LocalIllustrations::class);$image = $this->image();
|
||||
$local->storeSelection('freenode', 'fn1', $image);$local->storeSelection('freenode', 'fn2', $image);
|
||||
Http::fake();
|
||||
foreach (['publication_revoked', 'asset_disabled', 'asset_inactive', 'access_revoked', 'file_missing', 'file_corrupt', 'file_symlink'] as $reason) {
|
||||
$result = $local->synchronize(['freenode' => ['items' => [], 'selections' => [], 'unavailable' => ['fn1' => $reason]]]);
|
||||
$this->assertSame([], $result['pending']);
|
||||
$this->assertSame('/images/illustrations/'.$this->sha.'.png', $local->thumbnail('freenode', 'fn1'));
|
||||
}
|
||||
// A deleted upstream selection is absent even from the unavailable map.
|
||||
$local->synchronize(['freenode' => ['items' => [], 'selections' => [], 'unavailable' => []]]);
|
||||
$this->assertNotNull($local->thumbnail('freenode', 'fn1'));
|
||||
$local->synchronize(['freenode' => ['items' => [$image], 'selections' => ['fn2' => $image], 'unavailable' => ['fn1' => 'publication_revoked']]]);
|
||||
$this->assertNull($local->thumbnail('freenode', 'fn1'));
|
||||
$this->assertNotNull($local->thumbnail('freenode', 'fn2'));
|
||||
$this->assertFileExists($this->dir.'/public/'.$this->sha.'.png');
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_sync_reports_missing_local_file_without_erasing_its_assignment(): void
|
||||
{
|
||||
$this->fakeImages();$local = app(LocalIllustrations::class);
|
||||
$local->storeSelection('freenode', 'fn1', $this->image());
|
||||
unlink($this->dir.'/public/'.$this->sha.'.png');
|
||||
Http::fake();
|
||||
$result = $local->synchronize(['freenode' => ['items' => [], 'selections' => [], 'unavailable' => ['fn1' => 'asset_disabled']]]);
|
||||
$this->assertSame(['freenode:fn1' => 'asset_disabled'], $result['pending']);
|
||||
$state = json_decode(file_get_contents($this->dir.'/private/manifest.json'), true);
|
||||
$this->assertSame($this->id, $state['selections']['freenode']['fn1']);
|
||||
Http::assertNothingSent();
|
||||
}
|
||||
|
||||
public function test_missing_manifest_never_fetches_resource_or_returns_remote_fallback(): void
|
||||
|
||||
@@ -19,12 +19,9 @@ protected function setUp(): void
|
||||
config(['database.default' => 'sqlite', 'database.connections.sqlite.database' => ':memory:',
|
||||
'scout.driver' => null, 'cache.default' => 'array']);
|
||||
DB::purge('sqlite');
|
||||
Schema::create('categories', function (Blueprint $t) { $t->id(); $t->integer('iStatus')->default(1); $t->integer('iParentId')->default(0); });
|
||||
DB::table('categories')->insert(['id'=>1]);
|
||||
Schema::create('articles', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->integer('iStatus')->default(1);
|
||||
$t->integer('iCategoryId')->default(1);
|
||||
foreach (['iLikeCount', 'i7like', 'i365like'] as $field) {
|
||||
$t->integer($field)->default(0);
|
||||
}
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\Feature;
|
||||
use App\Models\Articles;
|
||||
use App\Services\Seo;
|
||||
use App\Services\ArticlesService;
|
||||
use App\Services\ResourcePublication;
|
||||
use App\Services\SeoNotifications;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
#[\PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses]
|
||||
#[\PHPUnit\Framework\Attributes\PreserveGlobalState(false)]
|
||||
class SeoContractTest extends TestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
config(['database.default'=>'sqlite','database.connections.sqlite.database'=>':memory:','scout.driver'=>'collection',
|
||||
'app.url'=>'https://example.org','editorial.base_url'=>'https://example.org','app.site_code'=>'example.org',
|
||||
'app.site_code_short'=>'cfn','seo.brand'=>'Example','responsecache.enabled'=>false,'seo.page_size'=>2,
|
||||
'illustrations.enabled'=>false,'editorial.indexnow_enabled'=>false]);
|
||||
DB::purge('sqlite'); Http::preventStrayRequests(); $this->withoutVite();
|
||||
$this->travelTo(\Carbon\Carbon::parse('2026-10-31 12:00:00','UTC'));
|
||||
Schema::create('categories',function(Blueprint $t){$t->id();$t->string('sSlug');$t->string('sName');$t->integer('iParentId')->default(0);$t->integer('iStatus')->default(1);$t->integer('iSort')->default(0);$t->integer('iShowChildren')->default(0);$t->string('sHtmlClass')->nullable();$t->text('aOpt')->nullable();$t->text('sDescription')->nullable();$t->text('aBanner')->nullable();});
|
||||
Schema::create('articles',function(Blueprint $t){$t->id();$t->integer('iCategoryId');$t->integer('iUserId')->default(1);$t->string('sSlug')->unique();$t->string('sTitle');$t->text('sTitleSub')->nullable();$t->text('sContent');$t->string('sThumb')->nullable();$t->integer('iStatus')->default(1);$t->boolean('bPageThumb')->default(false);foreach(['iViews','iLikeCount','i7like','i365like','iIsTop'] as $f)$t->integer($f)->default(0);$t->timestamp('sLastLikedAt')->nullable();$t->timestamps();});
|
||||
Schema::create('tags',function(Blueprint $t){$t->id();$t->string('sSlug');$t->string('sName');});
|
||||
Schema::create('article_tag',function(Blueprint $t){$t->integer('iArticleId');$t->integer('iTagId');});
|
||||
Schema::create('article_likes',function(Blueprint $t){$t->id();$t->integer('iArticleId');$t->string('sIp');$t->string('sFingerprint');$t->timestamps();});
|
||||
(require database_path('migrations/2026_10_31_160000_add_article_seo_state.php'))->up();
|
||||
foreach([[1,'freenode','免费节点',0],[2,'client','入门教程',0],[3,'windows','Windows',2],[4,'advanced','综合教程',0]] as [$id,$slug,$name,$parent]) DB::table('categories')->insert(['id'=>$id,'sSlug'=>$slug,'sName'=>$name,'iParentId'=>$parent,'iShowChildren'=>$id===2?1:0,'aOpt'=>$id===1?' {"noindexday":7}':null]);
|
||||
DB::table('tags')->insert(['id'=>1,'sSlug'=>'clash','sName'=>'Clash']);
|
||||
}
|
||||
protected function tearDown(): void { $this->travelBack(); parent::tearDown(); }
|
||||
private function article(string $slug, array $extra=[]): int
|
||||
{
|
||||
return DB::table('articles')->insertGetId($extra+['sSlug'=>$slug,'sTitle'=>'教程 '.$slug,'sTitleSub'=>'<b>示例</b> & 摘要','sContent'=>'<h2>操作步骤</h2><p>示例正文</p>','iCategoryId'=>3,'created_at'=>'2026-10-30 10:00:00','updated_at'=>'2026-10-31 01:00:00']);
|
||||
}
|
||||
public function test_category_aliases_pagination_and_parameters(): void
|
||||
{
|
||||
foreach(range(1,5) as $n)$this->article('guide'.$n);
|
||||
$this->get('/windows?page=2&utm_source=x')->assertRedirect('https://example.org/client/windows?page=2')->assertStatus(301);
|
||||
foreach(['/wrong/windows','/wrong/freenode','/client/freenode','/client/windows?page=0','/client/windows?page=-1','/client/windows?page=abc','/client/windows?page=99','/client/windows?page[]=2','/client/windows?page=2&page=3'] as $url)$this->get($url)->assertNotFound();
|
||||
$this->get('/client/windows?page=1')->assertStatus(301)->assertRedirect('https://example.org/client/windows');
|
||||
$html=$this->get('/client/windows?page=2&utm_source=x')->assertOk()->getContent();
|
||||
$this->assertStringContainsString('rel="canonical" href="https://example.org/client/windows?page=2"',$html);
|
||||
$this->assertStringContainsString('rel="next" href="https://example.org/client/windows?page=3"',$html);
|
||||
$this->assertStringContainsString('rel="prev" href="https://example.org/client/windows"',$html);
|
||||
$this->assertStringNotContainsString('guide5.html',$html);
|
||||
$dom=new \DOMDocument();@$dom->loadHTML($html);$xp=new \DOMXPath($dom);
|
||||
$this->assertSame(1,$xp->query('//head/link[@class="pagination-next"]')->length);
|
||||
$this->assertSame(0,$xp->query('//body/nav[@class="seo-pagination"]')->length);
|
||||
$this->assertSame(0,$xp->query('//*[contains(@class,"seo-card-image")]')->length);
|
||||
$this->get('/client/windows?page=3')->assertOk()->assertDontSee('class="pagination-next"',false);
|
||||
$this->get('/robots.txt')->assertOk()->assertDontSee('Disallow: /*?*',false);
|
||||
}
|
||||
public function test_hidden_and_future_content_are_absent_from_every_public_query(): void
|
||||
{
|
||||
$good=$this->article('good');
|
||||
foreach(['draft'=>['iStatus'=>0],'future'=>['created_at'=>'2026-11-01 00:00:00']] as $slug=>$extra){$id=$this->article($slug,$extra);DB::table('article_tag')->insert(['iArticleId'=>$id,'iTagId'=>1]);$this->get('/a/'.$slug.'.html')->assertNotFound();}
|
||||
$this->get('/search/'.rawurlencode('教程'))->assertOk()->assertSee('good.html',false)->assertDontSee('draft.html',false)->assertDontSee('future.html',false)->assertSee('noindex, follow',false);
|
||||
$this->get('/?s='.rawurlencode('教程'))->assertStatus(301)->assertRedirect(Seo::url('/search/'.rawurlencode('教程')));
|
||||
$this->get('/search/'.rawurlencode('不存在的内容'))->assertOk()->assertSee('看起来这里没有任何东西…');
|
||||
$this->get('/tag/clash')->assertOk()->assertDontSee('draft.html',false);
|
||||
DB::table('categories')->where('id',2)->update(['iStatus'=>0]);
|
||||
$this->get('/a/good.html')->assertNotFound();$this->get('/client/windows')->assertNotFound();
|
||||
$this->get('/sitemap.xml')->assertOk()->assertDontSee('good.html',false);
|
||||
$this->get('/search/'.rawurlencode('教程'))->assertOk()->assertDontSee('good.html',false);
|
||||
}
|
||||
public function test_home_is_stable_and_failed_refresh_does_not_replace_it(): void
|
||||
{
|
||||
$this->article('fn-good',['iCategoryId'=>1,'sTitle'=>'日期标题','sTitleSub'=>'共20个可用节点']);
|
||||
$this->article('fn-zero',['iCategoryId'=>1,'sTitleSub'=>'本次更新共0个可用节点','created_at'=>'2026-10-31 11:00:00']);
|
||||
$this->assertSame('fn-good',app(ArticlesService::class)->getLatestFreeNodeSlug());
|
||||
$html=$this->get('/')->assertOk()->getContent();
|
||||
$this->assertStringContainsString('<h1 class="mb-3">日期标题</h1>',$html);
|
||||
$this->assertStringContainsString('rel="canonical" href="https://example.org/"',$html);
|
||||
$this->assertStringContainsString('property="og:type" content="website"',$html);
|
||||
$this->assertStringContainsString('示例正文',$html);
|
||||
$this->assertStringNotContainsString('resource-context',$html);
|
||||
$this->assertStringNotContainsString('/css/seo.css',$html);
|
||||
$this->assertStringContainsString('发布于',$html);
|
||||
$this->travel(10)->days();$this->get('/')->assertOk()->assertSee('content="index, follow"',false);
|
||||
$this->get('/a/fn-good.html')->assertOk()->assertSee('content="noindex, follow"',false)->assertDontSee('resource-context',false);
|
||||
DB::table('articles')->delete();$this->get('/')->assertStatus(503)->assertHeader('Retry-After','3600');
|
||||
}
|
||||
public function test_new_snapshots_are_archives_and_content_clock_ignores_likes(): void
|
||||
{
|
||||
$id=$this->article('old',['iCategoryId'=>1]);$old=Articles::find($id);
|
||||
$this->assertTrue(Seo::indexable($old));$this->assertNull(Seo::modified($old));
|
||||
$new=Articles::create(['sSlug'=>'new','sTitle'=>'新的记录','sTitleSub'=>'共10个可用节点','sContent'=>'<p>有效资源</p>','iCategoryId'=>1,'iStatus'=>1]);
|
||||
$this->assertSame('archive',$new->sSeoPolicy);$this->assertFalse(Seo::indexable($new));
|
||||
$clock=Seo::modified($new);$this->travel(1)->hours();$new->increment('iLikeCount');$this->assertSame($clock,Seo::modified($new->fresh()));
|
||||
$new->sContent='<p>更新资源内容</p>';$new->save();$this->assertNotSame($clock,Seo::modified($new->fresh()));
|
||||
$this->get('/sitemap.xml')->assertOk()->assertDontSee('/a/new.html',false)->assertSee('/a/old.html',false);
|
||||
$this->travelTo(\Carbon\Carbon::parse('2026-11-06 10:00:01','UTC'));
|
||||
$this->get('/sitemap.xml')->assertOk()->assertDontSee('/a/old.html',false);
|
||||
}
|
||||
public function test_metadata_and_structured_data_are_clean_and_share_article_url(): void
|
||||
{
|
||||
$this->article('clean',['sTitle'=>'标题 </script> & "引用"']);
|
||||
$html=$this->get('/a/clean.html?utm_source=test')->assertOk()->getContent();
|
||||
$dom=new \DOMDocument();@$dom->loadHTML($html);$xp=new \DOMXPath($dom);
|
||||
$this->assertSame('示例 & 摘要',$xp->query('//meta[@name="description"]')->item(0)->getAttribute('content'));
|
||||
$this->assertSame('https://example.org/a/clean.html',$xp->query('//a[@id="urlCopy"]')->item(0)->getAttribute('data-clipboard-text'));
|
||||
foreach($xp->query('//script[@type="application/ld+json"]') as $script)$this->assertIsArray(json_decode($script->textContent,true,512,JSON_THROW_ON_ERROR));
|
||||
$this->assertStringNotContainsString('dateModified',$html);$this->assertStringNotContainsString('AggregateRating',$html);
|
||||
$this->assertStringContainsString('href="https://example.org/client/windows"',$html);
|
||||
}
|
||||
public function test_rejected_resource_does_not_change_articles(): void
|
||||
{
|
||||
$id=$this->article('last',['iCategoryId'=>1]);
|
||||
$payload=['title'=>'更新','title_sub'=>'共12个可用节点','content'=>'<p>内容</p>','tags'=>[]];
|
||||
$this->assertSame(12,ResourcePublication::validate($payload)['iResourceCount']);
|
||||
$this->assertSame('unknown',ResourcePublication::validate($payload)['sResourceStatus']);
|
||||
foreach([['check_status'=>'failed'],['valid_count'=>0],['title_sub'=>'本次更新共0个可用节点'],['content'=>'']] as $bad){
|
||||
try { ResourcePublication::validate(array_replace($payload,$bad));$this->fail('Invalid refresh accepted'); } catch(\Symfony\Component\HttpKernel\Exception\HttpException|\Illuminate\Validation\ValidationException $e){$this->assertNotEmpty($e->getMessage());}
|
||||
}
|
||||
$this->assertSame('last',Articles::find($id)->sSlug);$this->assertSame(1,Articles::count());
|
||||
}
|
||||
public function test_durable_home_notifications_retry_and_deletions_need_no_http_probe(): void
|
||||
{
|
||||
config(['editorial.indexnow_enabled'=>true,'key.indexnow'=>'test-key-12345678']);
|
||||
Http::fake(['api.indexnow.org/*'=>Http::sequence()->push('',429)->push('',202)->push('',200)]);
|
||||
$id=$this->article('snapshot',['iCategoryId'=>1,'sSeoPolicy'=>'archive']);$service=app(SeoNotifications::class);
|
||||
$service->changed(Articles::find($id));$service->changed(Articles::find($id));$this->assertSame(1,DB::table('seo_notifications')->count());
|
||||
$service->retry();Http::assertSentCount(1);$service->retry();Http::assertSentCount(1);
|
||||
$this->travel(6)->minutes();$service->retry();Http::assertSentCount(2);
|
||||
Http::assertSent(fn($req)=>$req['urlList']===['https://example.org/','https://example.org/freenode']);
|
||||
$service->changed(Articles::find($id),true);DB::table('articles')->where('id',$id)->delete();$service->retry();Http::assertSentCount(3);
|
||||
Http::assertSent(fn($req)=>in_array('https://example.org/a/snapshot.html',$req['urlList']));
|
||||
}
|
||||
public function test_cleanup_retains_old_resource_urls_and_get_cannot_like(): void
|
||||
{
|
||||
$id=$this->article('historical',['iCategoryId'=>1,'created_at'=>'2025-01-01 00:00:00']);
|
||||
$this->artisan('clear_db')->assertExitCode(0);$this->assertNotNull(Articles::find($id));
|
||||
$this->get('/like/'.$id)->assertNotFound();$this->assertSame(0,Articles::find($id)->iLikeCount);
|
||||
}
|
||||
public function test_commercial_attributes_and_zero_string_validation(): void
|
||||
{
|
||||
$html='<a href="https://xn--123-9i9dj97q.com/" rel="nofollow">推广</a><a href="https://example.net/doc">参考</a>';
|
||||
$body=Seo::body($html);$this->assertStringContainsString('rel="nofollow sponsored noopener"',$body);
|
||||
$this->assertStringContainsString('<a href="https://example.net/doc">参考</a>',$body);
|
||||
$this->expectException(\Symfony\Component\HttpKernel\Exception\HttpException::class);
|
||||
ResourcePublication::validate(['title'=>'资源','title_sub'=>'数量未知','content'=>'内容','tags'=>[],'valid_count'=>'0']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fixed local SSH -> VPS-001 -> VPS-003 transport. No local HTTP or direct fallback."""
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
OPERATIONS = ('catalog', 'source', 'prepare', 'review', 'publish', 'status')
|
||||
REMOTE_COMMAND = 'cd /www/wwwroot/clashfreenode-new.com && exec runuser -u nginx -- php artisan editorial:release'
|
||||
|
||||
|
||||
def ssh_command():
|
||||
options = ['-F', '/dev/null', '-T', '-o', 'StrictHostKeyChecking=yes',
|
||||
'-o', 'PreferredAuthentications=password', '-o', 'PubkeyAuthentication=no',
|
||||
'-o', 'NumberOfPasswordPrompts=1', '-o', 'ConnectTimeout=15',
|
||||
'-o', 'ServerAliveInterval=15', '-o', 'ServerAliveCountMax=3',
|
||||
'-o', 'ControlMaster=no', '-o', 'ControlPath=none',
|
||||
'-o', 'ClearAllForwardings=yes', '-o', 'PermitLocalCommand=no']
|
||||
jump = shlex.join(['ssh', *options, '-W', '45.153.247.44:22', '[email protected]'])
|
||||
return ['ssh', *options, '-o', 'ProxyCommand=' + jump, '[email protected]', REMOTE_COMMAND]
|
||||
|
||||
|
||||
def atomic_json(path, data):
|
||||
path = Path(path)
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
fd, temp = tempfile.mkstemp(prefix=path.name + '.', dir=path.parent)
|
||||
try:
|
||||
with os.fdopen(fd, 'w') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
os.replace(temp, path)
|
||||
finally:
|
||||
if os.path.exists(temp):
|
||||
os.unlink(temp)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('operation', choices=OPERATIONS)
|
||||
parser.add_argument('--input', type=Path, help='JSON request, without operation; stdin if omitted')
|
||||
parser.add_argument('--output', type=Path, required=True, help='Private JSON result; review includes HTML, never load its online assets locally')
|
||||
args = parser.parse_args()
|
||||
raw = args.input.read_bytes() if args.input else sys.stdin.buffer.read(48 * 1024 * 1024 + 1)
|
||||
if len(raw) > 48 * 1024 * 1024:
|
||||
parser.error('Input exceeds 48 MiB')
|
||||
payload = json.loads(raw or b'{}')
|
||||
if not isinstance(payload, dict) or ('operation' in payload and payload['operation'] != args.operation):
|
||||
parser.error('Invalid operation payload')
|
||||
payload['operation'] = args.operation
|
||||
helper = Path(__file__).with_name('ssh_askpass.py').resolve()
|
||||
env = os.environ.copy()
|
||||
env.update(SSH_ASKPASS=str(helper), SSH_ASKPASS_REQUIRE='force', DISPLAY=':0')
|
||||
try:
|
||||
result = subprocess.run(ssh_command(), input=json.dumps(payload, ensure_ascii=False).encode(),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, timeout=660)
|
||||
try:
|
||||
reply = json.loads(result.stdout)
|
||||
except (ValueError, UnicodeError):
|
||||
reply = {'ok': False, 'error': 'SSH/server response unavailable. Query status with the original release_id; no direct fallback.',
|
||||
'transport_exit': result.returncode}
|
||||
atomic_json(args.output, reply)
|
||||
print(json.dumps({'ok': reply.get('ok', False), 'phase': reply.get('data', {}).get('phase'),
|
||||
'result_file': str(args.output.resolve()), 'transport_exit': result.returncode}))
|
||||
return result.returncode if result.returncode in (0, 1, 2) else 1
|
||||
except subprocess.TimeoutExpired:
|
||||
atomic_json(args.output, {'ok': False, 'error': 'Transport timed out; publication may have completed. Query original release_id.'})
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Only OpenSSH may consume this helper's output; never run it interactively."""
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
if __name__ == '__main__':
|
||||
prompt = sys.argv[1] if len(sys.argv) == 2 else ''
|
||||
match = re.fullmatch(r"root@(104\.168\.30\.40|45\.153\.247\.44)'s password: ?", prompt)
|
||||
if not match or os.environ.get('SSH_ASKPASS_REQUIRE') != 'force':
|
||||
raise SystemExit(2)
|
||||
root = Path('/Users/hellcat/Documents/GemDocs/AI版')
|
||||
sys.path.insert(0, str(root / 'tools'))
|
||||
import credentials
|
||||
resource = {'104.168.30.40': 'VPS-001', '45.153.247.44': 'VPS-003'}[match[1]]
|
||||
try:
|
||||
password = credentials.get_field(root, resource, 'password')
|
||||
os.write(1, password.encode())
|
||||
except Exception:
|
||||
raise SystemExit(2)
|
||||
@@ -1,72 +0,0 @@
|
||||
import unittest
|
||||
from datetime import datetime, timedelta
|
||||
import copy
|
||||
from weekly import due, new_week, record, ZONE
|
||||
from release import ssh_command, REMOTE_COMMAND
|
||||
|
||||
|
||||
class WeeklyTests(unittest.TestCase):
|
||||
def state(self):
|
||||
return {'starts_on': '2026-11-02', 'weeks': {'2026-11-02': {'slots': [
|
||||
{'slot_id': str(i), 'status': 'planned', 'planned_at': f'2026-11-0{day}T15:00:00+08:00',
|
||||
'release_id': None, 'published_at': None} for i, day in enumerate([2, 4, 6])
|
||||
]}}}
|
||||
|
||||
def test_random_plans_have_three_distinct_days_at_fifteen(self):
|
||||
for _ in range(200):
|
||||
slots = new_week('2026-11-02')['slots']
|
||||
times = [datetime.fromisoformat(s['planned_at']) for s in slots]
|
||||
self.assertEqual(len({t.date() for t in times}), 3)
|
||||
self.assertTrue(all(t.hour == 15 and t.minute == t.second == 0 for t in times))
|
||||
self.assertTrue(all(b-a >= timedelta(hours=24) for a, b in zip(times, times[1:])))
|
||||
|
||||
def test_missed_slot_catches_up_without_two_same_day(self):
|
||||
state = self.state()
|
||||
now = datetime(2026, 11, 4, 15, tzinfo=ZONE)
|
||||
self.assertEqual(due(state, now)['slot']['slot_id'], '0')
|
||||
slot = state['weeks']['2026-11-02']['slots'][0]
|
||||
slot.update(status='published', published_at=now.isoformat())
|
||||
self.assertEqual(due(state, now)['reason'], 'already_published_today')
|
||||
self.assertEqual(due(state, now+timedelta(days=1))['slot']['slot_id'], '1')
|
||||
|
||||
def test_retry_pending_is_not_a_new_article(self):
|
||||
state = self.state()
|
||||
slot = state['weeks']['2026-11-02']['slots'][0]
|
||||
slot.update(release_id='original', status='publishing')
|
||||
self.assertEqual(due(state, datetime(2026, 11, 9, 15, tzinfo=ZONE))['action'], 'resume')
|
||||
response = {'ok': True, 'data': {'release_id': 'original', 'phase': 'published_pending',
|
||||
'published_at': '2026-11-08T16:11:10+08:00',
|
||||
'receipt': {'status': 'published', 'publication_id': 'receipt', 'articles': [{'url': '/a/example.html'}]}}}
|
||||
record(state, '0', response, datetime(2026, 11, 9, 15, tzinfo=ZONE))
|
||||
self.assertEqual(slot['published_at'], '2026-11-08T16:11:10+08:00')
|
||||
self.assertEqual(due(state, datetime(2026, 11, 9, 15, tzinfo=ZONE))['action'], 'synchronize')
|
||||
response['ok'] = False
|
||||
before = copy.deepcopy(state)
|
||||
with self.assertRaises(ValueError):
|
||||
record(state, '0', response, datetime(2026, 11, 9, 15, tzinfo=ZONE))
|
||||
self.assertEqual(before, state)
|
||||
|
||||
def test_next_week_does_not_publish_unstarted_backlog(self):
|
||||
state = self.state()
|
||||
now = datetime(2026, 11, 9, 15, tzinfo=ZONE)
|
||||
result = due(state, now)
|
||||
if result['action'] == 'write':
|
||||
self.assertTrue(result['slot']['slot_id'].startswith('2026-11-09'))
|
||||
for i, slot in enumerate(state['weeks']['2026-11-02']['slots']):
|
||||
slot.update(status='published', published_at=f'2026-11-0{2+i}T16:00:00+08:00')
|
||||
self.assertEqual(due(state, datetime(2026, 11, 6, 15, tzinfo=ZONE))['reason'], 'weekly_quota_met')
|
||||
|
||||
def test_transport_always_forces_white_host_and_fixed_remote_command(self):
|
||||
command = ssh_command()
|
||||
proxy = next(a for a in command if a.startswith('ProxyCommand='))
|
||||
self.assertIn('[email protected]', proxy)
|
||||
self.assertIn('-W 45.153.247.44:22', proxy)
|
||||
self.assertIn('StrictHostKeyChecking=yes', proxy)
|
||||
self.assertIn('ControlPath=none', proxy)
|
||||
self.assertEqual(command[-2], '[email protected]')
|
||||
self.assertEqual(command[-1], REMOTE_COMMAND)
|
||||
self.assertEqual(command[1:3], ['-F', '/dev/null'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,114 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Weekly writing quota and missed-window recovery; never publishes by itself."""
|
||||
import argparse
|
||||
from datetime import datetime, timedelta
|
||||
import fcntl
|
||||
import json
|
||||
from pathlib import Path
|
||||
import secrets
|
||||
import sys
|
||||
from zoneinfo import ZoneInfo
|
||||
from release import atomic_json
|
||||
|
||||
ZONE = ZoneInfo('Asia/Shanghai')
|
||||
STATE = Path(__file__).resolve().parents[2] / 'storage/app/private/weekly-tutorials/state.json'
|
||||
|
||||
|
||||
def week_start(now):
|
||||
return (now - timedelta(days=now.weekday())).date().isoformat()
|
||||
|
||||
|
||||
def new_week(key):
|
||||
monday = datetime.fromisoformat(key).replace(tzinfo=ZONE)
|
||||
while True:
|
||||
times = [monday + timedelta(days=secrets.choice(days), hours=15)
|
||||
for days in ([0, 1], [2, 3], [4, 5, 6])]
|
||||
if all(b - a >= timedelta(hours=24) for a, b in zip(times, times[1:])):
|
||||
return {'slots': [{'slot_id': f'{key}-{i + 1}', 'planned_at': t.isoformat(), 'status': 'planned',
|
||||
'release_id': None, 'published_at': None, 'urls': []} for i, t in enumerate(times)]}
|
||||
|
||||
|
||||
def published_slots(state):
|
||||
return [s for w in state['weeks'].values() for s in w['slots'] if s.get('published_at')]
|
||||
|
||||
|
||||
def due(state, now):
|
||||
if now.date().isoformat() < state['starts_on']:
|
||||
return {'action': 'wait', 'reason': 'not_started'}
|
||||
key = week_start(now)
|
||||
state['weeks'].setdefault(key, new_week(key))
|
||||
published = published_slots(state)
|
||||
for slot in published:
|
||||
if slot['status'] == 'published_pending':
|
||||
return {'action': 'synchronize', 'slot': slot}
|
||||
if any(datetime.fromisoformat(s['published_at']).astimezone(ZONE).date() == now.date() for s in published):
|
||||
return {'action': 'wait', 'reason': 'already_published_today'}
|
||||
# Uncertain old work must be reconciled before creating a new release or applying the quota.
|
||||
for week in sorted(state['weeks']):
|
||||
for slot in state['weeks'][week]['slots']:
|
||||
if slot.get('release_id') and not slot.get('published_at') and slot['status'] != 'abandoned':
|
||||
return {'action': 'resume', 'slot': slot}
|
||||
count = sum(week_start(datetime.fromisoformat(s['published_at']).astimezone(ZONE)) == key for s in published)
|
||||
if count >= 3:
|
||||
return {'action': 'wait', 'reason': 'weekly_quota_met'}
|
||||
for slot in state['weeks'][key]['slots']:
|
||||
if slot['status'] == 'planned' and datetime.fromisoformat(slot['planned_at']) <= now:
|
||||
return {'action': 'write', 'slot': slot}
|
||||
return {'action': 'wait', 'reason': 'not_due'}
|
||||
|
||||
|
||||
def record(state, slot_id, response, now):
|
||||
if response.get('ok') is not True:
|
||||
raise ValueError('No successful server response')
|
||||
data = response['data']
|
||||
receipt = data.get('receipt', {})
|
||||
if receipt.get('status') != 'published' or data.get('phase') not in ('complete', 'published_pending'):
|
||||
raise ValueError('No committed publication receipt')
|
||||
slot = next(s for w in state['weeks'].values() for s in w['slots'] if s['slot_id'] == slot_id)
|
||||
if slot.get('release_id') != data['release_id']:
|
||||
raise ValueError('Release does not match claimed slot')
|
||||
# Record actual server transaction timestamp, not the time a delayed response was received.
|
||||
published_at = data.get('published_at')
|
||||
if not published_at:
|
||||
raise ValueError('Missing server publication timestamp')
|
||||
instant = datetime.fromisoformat(published_at).astimezone(ZONE)
|
||||
if instant > now + timedelta(minutes=5):
|
||||
raise ValueError('Publication timestamp is in the future')
|
||||
slot.update(status='published' if data['phase'] == 'complete' else 'published_pending',
|
||||
published_at=instant.isoformat(), publication_id=receipt['publication_id'],
|
||||
urls=[a['url'] for a in receipt['articles']], receipt_phase=data['phase'])
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('operation', choices=['due', 'claim', 'record'])
|
||||
parser.add_argument('--slot')
|
||||
parser.add_argument('--release-id')
|
||||
parser.add_argument('--receipt', type=Path)
|
||||
args = parser.parse_args()
|
||||
now = datetime.now(ZONE)
|
||||
STATE.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(STATE.with_suffix('.lock'), 'a') as lock:
|
||||
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
# Missing/corrupt state must be reconciled with server receipts, not reset to an empty quota.
|
||||
state = json.loads(STATE.read_text())
|
||||
result = due(state, now)
|
||||
if args.operation == 'claim':
|
||||
import uuid
|
||||
release_id = str(uuid.UUID(args.release_id))
|
||||
if result['action'] != 'write' or result['slot']['slot_id'] != args.slot:
|
||||
raise ValueError('Requested slot is not due')
|
||||
result['slot'].update(status='drafting', release_id=release_id)
|
||||
elif args.operation == 'record':
|
||||
record(state, args.slot, json.loads(args.receipt.read_text()), now)
|
||||
result = {'action': 'recorded', 'slot_id': args.slot}
|
||||
atomic_json(STATE, state)
|
||||
print(json.dumps(result, ensure_ascii=False))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
main()
|
||||
except Exception as error:
|
||||
print(json.dumps({'action': 'blocked', 'reason': str(error)}))
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user