8884e100f9
Overlay 190 upstream items (V8.22→8.31) preserving trade-pro theme, registry tests, and design docs. Re-applied full patch set on identical anchors (discovery/env_for/blocks.css/type-mapping/locale-override/ theme_color/frontend entries/test_theme_pro_v3 mods) plus compose pins. Verified: theme suites 35/35; dual-baseline full run 415 passed vs pristine 386+29 ours, FAILED-set diff EMPTY (same 10 Windows env fails). Live: container 8.31.1-dev.1 healthy, hesupipe 192 entries intact, trade-pro build 203 pages 0 errors. Co-Authored-By: Claude Code <noreply@anthropic.com>
72 lines
5.2 KiB
Python
72 lines
5.2 KiB
Python
"""Build four fully static demonstration sites from the real V3 builder.
|
|
All sample names and content here are clearly fictitious demonstration data.
|
|
"""
|
|
import json, os, shutil
|
|
from pathlib import Path
|
|
BASE=Path(__file__).resolve().parent.parent
|
|
DATA=Path(os.environ.get('SITEFORGE_DATA_DIR',str(BASE/'demo_storage_v830')))
|
|
os.environ['SITEFORGE_DATA_DIR']=str(DATA)
|
|
from app import db,theme_store,builder,quality
|
|
from app.core import uid,save_entry
|
|
from app.factory_api import bootstrap_site
|
|
|
|
def put(sid,typ,title,route,summary='',body='',category='',brand='',extra=None):
|
|
fields={'category':category,'brand':brand}
|
|
if extra:fields.update(extra)
|
|
return save_entry(sid,{'type':typ,'title':title,'route':route,'summary':summary,'body':body,
|
|
'meta':{'fields':fields}},source='demo')
|
|
|
|
def build_demo():
|
|
db.init();theme_store.setup()
|
|
demos={
|
|
'automotive':('NOVA MOBILITY','探索更广阔的出行可能','汽车与出行演示主题','Cars'),
|
|
'industrial':('ARC INDUSTRIES','面向现代工程的产品与服务','工业制造演示主题','Materials'),
|
|
'corporate':('NORTHLINE GROUP','以专业的服务连接企业与未来','企业品牌演示主题','Services'),
|
|
'minimal':('MONO STUDIO','少而精,让每一项作品更清晰','极简设计演示主题','Objects'),
|
|
}
|
|
out=Path(os.environ.get('SITEFORGE_DEMO_OUT',str(BASE/'examples'/'v830-built-sites')));out.mkdir(parents=True,exist_ok=True)
|
|
results={}
|
|
for theme,(name,tagline,about,term) in demos.items():
|
|
sid=uid()
|
|
settings={'nav':[{'title':x,'route':r} for x,r in [('首页','/'),('产品','/products/'),('品牌','/brands/'),('新闻','/news/'),('案例','/cases/'),('关于','/about/'),('联系','/contact/')]],
|
|
'email':'hello@example.com','footer_text':'此为 SiteForge 主题演示网站。公司、产品及内容均为虚构示例。'}
|
|
db.insert('INSERT INTO sites VALUES (?,?,?,?,?,?,?,?,?,?,?)',
|
|
(sid,name,'https://'+theme+'.example.test',tagline,theme,'#315f92','', 'new',json.dumps(settings,ensure_ascii=False),db.now(),db.now()))
|
|
theme_store.pin(sid,theme,'1.4.0' if theme=='automotive' else '1.3.0')
|
|
put(sid,'page','首页','/',tagline)
|
|
for i,(route,title,description) in enumerate([
|
|
('/about/','关于我们','企业介绍、发展理念、合作能力与团队故事。'),
|
|
('/contact/','联系我们','欢迎通过邮件与我们的演示团队取得联系。'),
|
|
('/products/','产品中心','查看系列、类别及产品资料。'),
|
|
('/brands/','品牌中心','探索与产品相关的品牌。'),
|
|
('/news/','新闻资讯','了解最新消息与团队动态。'),
|
|
('/cases/','项目案例','精选项目展示。'),
|
|
('/services/','服务与解决方案','从咨询到交付的全链路服务。'),
|
|
('/faq/','常见问题','更多问题可以联系我们。')]):
|
|
put(sid,'page',title,route,description,'<p>本页为演示内容。您可以在网站工厂中直接修改和替换。</p>')
|
|
for i,(prod,cat,brand) in enumerate([
|
|
(f'{term} Alpha','旗舰系列','NOVA'),(f'{term} Beta','旗舰系列','NOVA'),
|
|
(f'{term} Gamma','畅销系列','ARC'),(f'{term} Delta','畅销系列','ARC'),
|
|
(f'{term} Epsilon','定制系列','MONO'),(f'{term} Zeta','定制系列','MONO'),
|
|
(f'{term} Eta','专业系列','NOVA'),(f'{term} Theta','专业系列','ARC')]):
|
|
put(sid,'product',prod,f'/products/{i+1}/',f'{prod} — 针对多样应用的演示产品。',
|
|
'<h2>产品说明</h2><p>此处可以展示产品特点、应用场景和可用规格。</p>',cat,brand,
|
|
{'model':'MX-'+str(200+i),'material':'Example / Demo','version':'2026','energy':'EV' if theme=='automotive' else 'Standard'})
|
|
for name_b in ('NOVA','ARC','MONO'):
|
|
put(sid,'brand',name_b,'/brands/'+name_b.lower()+'/',f'{name_b} 品牌产品与应用。')
|
|
for i in range(3):
|
|
put(sid,'post',f'企业动态 · {i+1:02d}',f'/news/{i+1}/','在这里发布新闻资讯与品牌动态。',
|
|
'<p>这是可替换的新闻正文内容,可包含图片、表格和链接。</p>',extra={'publish_date':f'2026-10-{11+i:02}'})
|
|
put(sid,'case',f'精选项目 · {i+1:02d}',f'/cases/{i+1}/','展示项目背景、过程与成果。',
|
|
'<p>本页仅为项目结构示例,并非实际完成的工程项目。</p>',extra={'location':'Demo location','industry':'Demo industry'})
|
|
put(sid,'service','供应与交付方案','/services/solution/','灵活、可配置的供应交付服务。')
|
|
r=builder.build(sid)
|
|
src=db.DATA/'builds'/sid/r['version']/'dist'
|
|
dst=out/theme
|
|
if dst.exists():shutil.rmtree(dst)
|
|
shutil.copytree(src,dst)
|
|
results[theme]={'page_count':r['pages'],'warnings':r['warnings'],'quality':quality.report(sid,r['version'])}
|
|
(out/'BUILD_REPORT.json').write_text(json.dumps(results,ensure_ascii=False,indent=2),encoding='utf-8')
|
|
print(json.dumps({k:{'pages':v['page_count'],'warnings':len(v['warnings']),'quality_errors':v['quality']['errors']} for k,v in results.items()},ensure_ascii=False,indent=2))
|
|
if __name__=='__main__':build_demo()
|