Implement ProgCode identity and real shared reading UI kit
Build and deploy / deploy (push) Successful in 2m39s

This commit is contained in:
huncode committed 2026-10-27 15:19:49 +03:00
1 parent 99c848189e
commit 12562baeb5
2040 files changed
+184656 -181

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import re,json,subprocess,argparse
from pathlib import Path
from html.parser import HTMLParser
r=Path('/Users/gavrilovdev/tmp/progcode.ru');w=r/'web';base=Path('/tmp/progcode-metrika-frozen-527ea7bf774e');parser=argparse.ArgumentParser();parser.add_argument('--candidate',type=Path,default=Path('/tmp/progcode-ds-frozen-f5d927948163'));args=parser.parse_args();new=args.candidate;source=json.loads((new/'build-identity.json').read_text())['sourceHash'];out=r/'docs/design-system/candidates'/source[:12];out.mkdir(parents=True,exist_ok=True)
for name in ['articles-v2.json','articles.json','publication-report.json','archive-routes.json','shortlinks.json','figure-placements.json']:
assert subprocess.run(['git','show','0458a99:web/data/'+name],cwd=r,capture_output=True,check=True).stdout==(w/'data'/name).read_bytes(),name
oldpages={p.relative_to(base) for p in base.rglob('*.html')};newpages={p.relative_to(new) for p in new.rglob('*.html')};assert oldpages<=newpages
class Times(HTMLParser):
def __init__(self,text):super().__init__();self.current=None;self.values=[];self.feed(text)
def handle_starttag(self,tag,attrs):
if tag=='time':self.current=[dict(attrs).get('datetime'),'']
def handle_data(self,text):
if self.current is not None:self.current[1]+=text
def handle_endtag(self,tag):
if tag=='time' and self.current is not None:self.values.append(tuple(self.current));self.current=None
def inner(html):
m=re.search(r'<div\b[^>]*class="[^"]*\barticle-content\b[^"]*"[^>]*>',html);assert m
start=m.end();depth=1
for tag in re.finditer(r'</?div\b[^>]*>',html[start:]):
depth+=-1 if tag.group().startswith('</') else 1
if depth==0:return html[start:start+tag.start()]
raise AssertionError('Unclosed body')
compared=[];times=0;dateMismatches=[]
for path in sorted(oldpages):
old=(base/path).read_text();newtext=(new/path).read_text();ot=Times(old).values;nt=Times(newtext).values;dateMismatches.extend([{'path':str(path),'old':a,'new':b} for a,b in zip(ot,nt) if a!=b]);assert len(ot)==len(nt);times+=len(ot)
if 'class="article-shell"' in old:assert inner(old)==inner(newtext),str(path);compared.append(str(path))
media=[]
for p in (base/'visuals').rglob('*'):
if p.is_file():q=p.relative_to(base);assert p.read_bytes()==(new/q).read_bytes();media.append(str(q))
report={'sourceHash':json.loads((new/'build-identity.json').read_text())['sourceHash'],'baselineCommit':'0458a99d3a3880a42c8d809731ce6aea09cb4342','dataInputsAndPublicationReportsByteIdentical':6,'oldHTMLRoutesPreserved':len(oldpages),'newHTMLRoutes':sorted(str(p) for p in newpages-oldpages),'canonicalLegacyArticleBodiesByteIdentical':len(compared),'bodyPaths':compared,'dateElementsCompared':times,'dateTextMismatches':dateMismatches,'allDateTextAndISOEqual':not dateMismatches,'historicalMediaByteIdentical':len(media),'media':media,'sourceHelperIncludesFSDAndAllPublic':True,'wholeHTMLParityClaimed':False}
(out/'preservation.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)+'\n');print(json.dumps(report,ensure_ascii=False))