Build Mission Core promo, product knowledge and original media
This commit is contained in:
@@ -18,18 +18,18 @@ const REGION_TOKEN = {
|
||||
};
|
||||
|
||||
const PAGE_SEO_DEFAULTS = {
|
||||
title: "NODE.DC - платформа для процессов, данных и ИИ-агентов",
|
||||
title: "Mission Core — управление беспилотными системами | NODE.DC",
|
||||
description:
|
||||
"NODE.DC объединяет Hub, Engine, Ops, прикладные модули и сквозного ассистента для задач, workflow, данных, ролей, интеграций и инженерных моделей.",
|
||||
canonicalUrl: "https://nodedc.dctouch.ru/",
|
||||
"Mission Core: аппараты, оборудование, миссии, цифровые локации, симуляции и AI.",
|
||||
canonicalUrl: "https://nodedc.ru/",
|
||||
robots: "index,follow,max-image-preview:large",
|
||||
siteName: "NODE.DC",
|
||||
locale: "ru_RU",
|
||||
ogImage: "https://nodedc.dctouch.ru/assets/site/images/69b6acdde3123ef078e2b7f3_og-img.jpg",
|
||||
imageAlt: "NODE.DC - платформа для процессов, данных и ИИ-агентов",
|
||||
ogImage: "https://nodedc.ru/assets/site/images/69b6acdde3123ef078e2b7f3_og-img.jpg",
|
||||
imageAlt: "Mission Core — управление беспилотными системами | NODE.DC",
|
||||
organizationName: "DCTOUCH",
|
||||
organizationUrl: "https://dctouch.ru/",
|
||||
applicationCategory: "BusinessApplication",
|
||||
applicationCategory: "EngineeringApplication",
|
||||
};
|
||||
|
||||
const page = JSON.parse(await readFile(pagePath, "utf8"));
|
||||
@@ -304,7 +304,7 @@ function collectKnowledgeUrls(source, canonical) {
|
||||
}
|
||||
|
||||
function canonicalUrl(model) {
|
||||
const fallback = "https://nodedc.dctouch.ru/";
|
||||
const fallback = "https://nodedc.ru/";
|
||||
const value = String(model.seo?.canonicalUrl || fallback).trim() || fallback;
|
||||
|
||||
try {
|
||||
|
||||
@@ -172,7 +172,7 @@ function renderKnowledgeShortcodes(html) {
|
||||
}
|
||||
|
||||
function canonicalHome() {
|
||||
const fallback = "https://nodedc.dctouch.ru/";
|
||||
const fallback = "https://nodedc.ru/";
|
||||
const value = String(home.seo?.canonicalUrl || fallback).trim() || fallback;
|
||||
|
||||
try {
|
||||
@@ -766,4 +766,20 @@ for (const record of records) {
|
||||
}
|
||||
|
||||
await writeSeoFiles(records);
|
||||
// Replace legacy business pages on incremental hosting uploads as well.
|
||||
// Redirects are separate from the editable knowledge tree and its sitemap.
|
||||
const redirects = JSON.parse(await readFile(join(repoRoot, "content", "redirects.json"), "utf8").catch(error => {
|
||||
if (error.code === "ENOENT") return "{}";
|
||||
throw error;
|
||||
}));
|
||||
const rules = [];
|
||||
for (const [from, to] of Object.entries(redirects)) {
|
||||
if (!/^\/(?:[a-z0-9-]+\/)+$/.test(from) || !/^\/knowledge\/(?:[a-z0-9-]+\/)*$/.test(to) || from === to) {
|
||||
throw new Error(`Invalid redirect: ${from} → ${to}`);
|
||||
}
|
||||
if (records.some(record => record.urlPath === from)) throw new Error(`Redirect replaces an active article: ${from}`);
|
||||
await writePage(from, `<!doctype html><html lang="ru"><meta charset="utf-8"><meta name="robots" content="noindex,follow"><meta http-equiv="refresh" content="0;url=${to}"><link rel="canonical" href="${canonicalForPath(to)}"><title>Mission Core</title><p><a href="${to}">Перейти к материалам Mission Core</a></p></html>`);
|
||||
rules.push(`RedirectMatch 301 ^${from}(?:index\\.html)?$ ${to}`);
|
||||
}
|
||||
await writeFile(join(repoRoot, ".htaccess"), `# Generated legacy URL redirects\n${rules.join("\n")}\n`);
|
||||
console.log(`Rendered ${records.length + 1} knowledge pages -> /${knowledgeBasePath()}/`);
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
from pathlib import Path
|
||||
from html.parser import HTMLParser
|
||||
from urllib.parse import urlsplit,unquote
|
||||
from collections import Counter
|
||||
import json,re,subprocess
|
||||
r=Path(__file__).resolve().parents[1];fail=[];assets=set();anchors=[]
|
||||
class Page(HTMLParser):
|
||||
def __init__(self):super().__init__();self.ids=[];self.refs=[];self.h1=0;self.scripts=[];self.ld=False;self.text=[];self.script=False;self.canonical=[]
|
||||
def handle_starttag(self,t,attrs):
|
||||
a=dict(attrs)
|
||||
if 'id'in a:self.ids.append(a['id'])
|
||||
self.h1+=t=='h1'
|
||||
for k in ('src','href','poster','data-media-src'):
|
||||
if a.get(k):self.refs.append(a[k])
|
||||
if a.get('srcset'):self.refs.extend(x.strip().split(' ')[0] for x in a['srcset'].split(','))
|
||||
if t=='script':self.script=True;self.ld=a.get('type')=='application/ld+json'
|
||||
if t=='link'and a.get('rel')=='canonical':self.canonical.append(a.get('href'))
|
||||
def handle_data(self,d):
|
||||
if self.ld:self.scripts.append(d)
|
||||
if not self.script:self.text.append(d)
|
||||
def handle_endtag(self,t):
|
||||
if t=='script':self.script=False;self.ld=False
|
||||
for f in [r/'index.html',*sorted((r/'knowledge').rglob('index.html'))]:
|
||||
s=f.read_text();p=Page();p.feed(s)
|
||||
if '{{'in s:fail.append((str(f),'unrendered template'))
|
||||
duplicates=[k for k,v in Counter(p.ids).items() if v>1]
|
||||
if duplicates:fail.append((str(f),'duplicate ids',duplicates))
|
||||
if 'http-equiv="refresh"'not in s and p.h1!=1:fail.append((str(f),'h1 count',p.h1))
|
||||
if len(p.canonical)!=1 or not p.canonical[0].startswith('https://nodedc.ru/'):fail.append((str(f),'canonical',p.canonical))
|
||||
for ld in p.scripts:json.loads(ld)
|
||||
for url in p.refs:
|
||||
parsed=urlsplit(url)
|
||||
if parsed.scheme or parsed.netloc or url.startswith('data:'):continue
|
||||
path=unquote(parsed.path)
|
||||
target=(r/path.lstrip('/'))if path.startswith('/')else(f.parent/path)
|
||||
if not path:target=f
|
||||
if target.is_dir():target=target/'index.html'
|
||||
if not target.exists():fail.append((str(f),'missing',url));continue
|
||||
if target.suffix not in ('.html',):assets.add(str(target.resolve().relative_to(r.resolve())))
|
||||
if parsed.fragment and target==f and parsed.fragment not in p.ids:fail.append((str(f),'missing anchor',url))
|
||||
if re.search(r'1С|тендер|бухгалтер|юридическ', ' '.join(p.text),re.I):fail.append((str(f),'old business copy'))
|
||||
old=json.loads(subprocess.check_output(['git','show','system-automation:content/pages/home.json'],cwd=r))
|
||||
new=json.loads((r/'content/pages/home.json').read_text())
|
||||
def videos(data):
|
||||
result=set()
|
||||
for reg in data['regions']:
|
||||
for block in reg['blocks']:
|
||||
content=block['content']
|
||||
for item in [content,*content.get('sliderItems',[])]:
|
||||
src=item.get('videoSrc','')
|
||||
if src.endswith(('.mp4','.mov','.webm')):result.add(src)
|
||||
return result
|
||||
oldvideos=videos(old);newvideos=videos(new)
|
||||
assert oldvideos<=newvideos,oldvideos-newvideos
|
||||
report={'pages':len(list((r/'knowledge').rglob('index.html')))+1,'activeKnowledgeArticles':len(json.loads((r/'content/knowledge.json').read_text())['tree']),'legacyRedirects':len(json.loads((r/'content/redirects.json').read_text())),'preservedVideos':len(oldvideos),'referencedAssets':len(assets),'failures':fail}
|
||||
print(json.dumps(report,ensure_ascii=False,indent=2));raise SystemExit(bool(fail))
|
||||
Reference in New Issue
Block a user