88 lines
3.5 KiB
Python
88 lines
3.5 KiB
Python
import os
|
|
import re
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
with open('tools/test_extract.py', 'r', encoding='utf-8') as fp:
|
|
code = fp.read()
|
|
exec(code[:code.find("test_files = [")])
|
|
|
|
def build_html(filepath, html):
|
|
title, meta_desc, content, pattern = extract_content(html)
|
|
|
|
# パンくずの確認と補完
|
|
has_breadcrumbs = 'wiki-breadcrumbs' in content or 'wiki-breadcrumb' in content
|
|
if not has_breadcrumbs:
|
|
genre = "ダンジョン攻略" if "dungeons" in filepath else ("レイド攻略" if "raids" in filepath else "討滅戦攻略")
|
|
clean_title = re.sub(r'【.*?】', '', title).replace('完全攻略', '').replace('攻略', '').strip()
|
|
breadcrumb = f' <div class="wiki-breadcrumbs">\n <a href="../index.html">トップ</a> > <a href="index.html">{genre}</a> > <strong>{clean_title}</strong>\n </div>\n\n'
|
|
content = breadcrumb + content
|
|
else:
|
|
# id="wiki-breadcrumb" を class="wiki-breadcrumbs" に統一
|
|
content = re.sub(r'<div\s+id=["\']wiki-breadcrumb["\']>', '<div class="wiki-breadcrumbs">', content)
|
|
# 空のパンくずの場合は置換
|
|
if '<div class="wiki-breadcrumbs"></div>' in content or '<div class="wiki-breadcrumbs">\s*</div>' in content:
|
|
genre = "ダンジョン攻略" if "dungeons" in filepath else ("レイド攻略" if "raids" in filepath else "討滅戦攻略")
|
|
clean_title = re.sub(r'【.*?】', '', title).replace('完全攻略', '').replace('攻略', '').strip()
|
|
new_bc = f'<div class="wiki-breadcrumbs">\n <a href="../index.html">トップ</a> > <a href="index.html">{genre}</a> > <strong>{clean_title}</strong>\n </div>'
|
|
content = re.sub(r'<div class="wiki-breadcrumbs">\s*</div>', new_bc, content)
|
|
|
|
template = f'''<!DOCTYPE html>
|
|
<html lang="ja">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
|
|
<meta http-equiv="Pragma" content="no-cache">
|
|
<meta http-equiv="Expires" content="0">
|
|
<title>{title}</title>
|
|
{meta_desc} <link rel="stylesheet" href="../common/css/seesaa_neutral_gray.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div id="wiki-wrapper">
|
|
|
|
<!-- 共通ヘッダー&グローバルナビ(iframe共通化) -->
|
|
<iframe src="../common/header.html" class="wiki-header-frame" frameborder="0" scrolling="no"></iframe>
|
|
|
|
<!-- 2カラムコンテンツ -->
|
|
<div id="wiki-container">
|
|
|
|
<!-- 共通左サイドバー(iframe共通化) -->
|
|
<div id="wiki-sidebar">
|
|
<iframe src="../common/sidebar.html" class="wiki-sidebar-frame" frameborder="0"></iframe>
|
|
</div>
|
|
|
|
<main id="wiki-main">
|
|
{content}
|
|
</main>
|
|
</div>
|
|
|
|
<!-- フッター -->
|
|
<footer id="wiki-footer">
|
|
<p>© SQUARE ENIX CO., LTD. All Rights Reserved. | FINAL FANTASY XIV</p>
|
|
<p>FF14 攻略Wiki (Seesaa Wiki ニュートラルグレー テンプレート完全準拠)</p>
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
<script src="../common/js/wiki_common.js"></script>
|
|
</body>
|
|
</html>
|
|
'''
|
|
return template
|
|
|
|
for p in ['trials/ultima_weapon.html', 'trials/extreme_hades.html']:
|
|
with open(p, 'r', encoding='utf-8', errors='ignore') as fp:
|
|
html = fp.read()
|
|
res = build_html(p, html)
|
|
lines = res.splitlines()
|
|
print(f"=== {p} PREVIEW (最初の35行) ===")
|
|
for l in lines[:35]:
|
|
print(l)
|
|
print(f"=== {p} PREVIEW (最後の20行) ===")
|
|
for l in lines[-20:]:
|
|
print(l)
|
|
print("\n" + "="*50 + "\n")
|