8cea7dee20
- SiteForge Enterprise V8.10.0-dev.1 upstream source (210 tests) - Fix: v8_workflows._mapped_input now reads both 类型/分类 columns so WXR imports keep post/product types instead of collapsing to page - Docs: trade-pro theme port spec (R3) and implementation plan Co-Authored-By: Claude Code <noreply@anthropic.com>
25 lines
1.7 KiB
Python
25 lines
1.7 KiB
Python
"""One-time developer script: break V3 full themes into independently maintainable Jinja page templates."""
|
|
from pathlib import Path
|
|
import re
|
|
base=Path(__file__).resolve().parent.parent/'themes'
|
|
types={'home':['home'],'search':['search'],'listing':['listing','category'],'product':['product'],
|
|
'brand':['brand'],'article':['article'],'case':['case'],'info':['about','service','contact','faq','standard'],'notfound':['notfound']}
|
|
markers=[("{% if kind=='home' %}",'home'),("{% elif kind=='search' %}",'search'),("{% elif kind in ['listing','category'] %}",'listing'),("{% elif kind=='product' %}",'product'),("{% elif kind=='brand' %}",'brand'),("{% elif kind=='article' %}",'article'),("{% elif kind=='case' %}",'case'),("{% elif kind in ('about','service','contact','faq','standard') %}",'info'),("{% elif kind=='notfound' %}",'notfound')]
|
|
for name in ('automotive','industrial','corporate','minimal'):
|
|
p=base/name/'pro.html'
|
|
t=p.read_text(encoding='utf-8')
|
|
beginning=t.index(markers[0][0]); ending=t.index('{% endif %}\n{% if has_custom',beginning)
|
|
common=t[:beginning]
|
|
remainder=t[ending+len('{% endif %}'):] # preserve custom blocks and footer
|
|
dir=base/name/'pages';dir.mkdir(parents=True,exist_ok=True)
|
|
pieces={}
|
|
for i,(marker,key) in enumerate(markers):
|
|
start=t.index(marker,beginning)+len(marker)
|
|
finish=t.index(markers[i+1][0],start) if i+1<len(markers) else ending
|
|
pieces[key]=t[start:finish].strip()+'\n'
|
|
for key,kinds in types.items():
|
|
for kind in kinds:
|
|
(dir/(kind+'.html')).write_text(pieces[key],encoding='utf-8')
|
|
p.write_text(common+"{% include '"+name+"/pages/' ~ kind ~ '.html' %}\n"+remainder,encoding='utf-8')
|
|
print(name,len(list(dir.glob('*.html'))),'page family files')
|