- wiki/ 안으로 옮김: .obsidian, raw, assets, tools, CLAUDE.md, PROJECT.md
- 맨 위 CLAUDE.md 는 `@wiki/CLAUDE.md` 한 줄 (Claude Code 자동 참조용)
- 맨 위에 남김: .claude (Claude Code), README.md (Gitea 첫 화면), 프로그램 파일
- wiki/tools 도구 기준 폴더를 wiki 로, .claude 명령·.gitignore·문서 속 경로 갱신
- wiki/.obsidian/app.json: 볼트 밖이 된 폴더 제외 목록 삭제
- 작업현황·변경기록·지시기록 갱신 (v2.1.0, d1a8009 포함)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HnDmXrFqktWwYa1cuJRAVZ
76 lines
4.6 KiB
Python
76 lines
4.6 KiB
Python
"""폴더 = 메뉴. wiki/08_화면 의 폴더 구조로 메뉴 HTML 과 화면목록.md 를 만든다.
|
|
폴더 이름 규칙: 숫자_메뉴이름 (숫자 = 순서). 폴더를 바꾸고 다시 실행하면 메뉴도 같이 바뀐다.
|
|
사용: python tools/build_menu.py → wiki/08_화면/menu.html, wiki/08_화면/00_화면목록.md"""
|
|
import pathlib, re, html, urllib.parse
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent # = wiki 폴더 (볼트)
|
|
SCR = ROOT / "08_화면"
|
|
PAT = re.compile(r"^(\d+)_(.+)$")
|
|
|
|
def menu_dirs(d):
|
|
return sorted([p for p in d.iterdir() if p.is_dir() and PAT.match(p.name)], key=lambda p: int(PAT.match(p.name)[1]))
|
|
|
|
def label(p):
|
|
return PAT.match(p.name)[2]
|
|
|
|
def status(p):
|
|
f = p / "화면설명.md"
|
|
if f.exists():
|
|
m = re.search(r"^status:\s*(\S+)", f.read_text(encoding="utf-8"), re.M)
|
|
if m: return m[1]
|
|
return "없음"
|
|
|
|
def rel(p):
|
|
return urllib.parse.quote(p.relative_to(SCR).as_posix())
|
|
|
|
def tree_html(d, depth=0):
|
|
out = []
|
|
for p in menu_dirs(d):
|
|
imgs = sorted(p.glob("화면*.png"))
|
|
img = "|".join(rel(i) for i in imgs) # 슬라이드가 여러 장이면 전부 표시
|
|
proto = rel(p / "prototype.html") if (p / "prototype.html").exists() else "" # 실행 가능한 시제품
|
|
out.append(f'<li><a href="#" data-img="{img}" data-proto="{proto}" data-md="{rel(p / "화면설명.md")}">'
|
|
f'{html.escape(label(p))} <small>[{status(p)}]</small></a>')
|
|
sub = tree_html(p, depth + 1)
|
|
if sub: out.append(f"<ul>{sub}</ul>")
|
|
out.append("</li>")
|
|
return "".join(out)
|
|
|
|
def tree_md(d, depth=0):
|
|
lines = []
|
|
for p in menu_dirs(d):
|
|
link = (p / "화면설명").relative_to(SCR.parent).as_posix()
|
|
lines.append(f"{' ' * depth}- [[{link}|{label(p)}]] `{status(p)}`")
|
|
lines += tree_md(p, depth + 1)
|
|
return lines
|
|
|
|
PAGE = """<!DOCTYPE html><html lang="ko"><head><meta charset="utf-8"><title>화면 메뉴 미리보기</title>
|
|
<style>body{margin:0;display:flex;height:100vh;font-family:'Malgun Gothic',sans-serif}
|
|
nav{width:300px;overflow:auto;border-right:1px solid #ccc;padding:12px;background:#f7f7f9}
|
|
nav ul{list-style:none;padding-left:16px}nav a{text-decoration:none;color:#222;display:block;padding:3px}
|
|
nav a.on{background:#2b6cb0;color:#fff;border-radius:4px}small{color:#888}nav a.on small{color:#dde}
|
|
main{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#e9ecef}
|
|
#tabs{margin:8px}#tabs button{margin:0 3px;padding:4px 12px;border:1px solid #2b6cb0;background:#fff;color:#2b6cb0;border-radius:4px;cursor:pointer}#tabs button.on{background:#2b6cb0;color:#fff}#tabs a.run{margin-left:12px;padding:4px 12px;background:#f6ad55;color:#222;border-radius:4px;text-decoration:none;font-weight:bold}
|
|
img{max-width:95%;max-height:88vh;box-shadow:0 2px 12px #0003;background:#fff}#t{margin:8px;color:#555}</style></head>
|
|
<body><nav><b>메뉴 (폴더 구조)</b><ul>__TREE__</ul></nav><main><div id="tabs"></div><img id="v" alt=""><div id="t">왼쪽 메뉴를 누르면 화면이 보입니다</div></main>
|
|
<script>document.querySelectorAll('nav a').forEach(a=>a.onclick=e=>{e.preventDefault();
|
|
document.querySelectorAll('nav a').forEach(x=>x.classList.remove('on'));a.classList.add('on');
|
|
const imgs=(a.dataset.img||'').split('|').filter(x=>x);const tb=document.getElementById('tabs');tb.innerHTML='';
|
|
const show=i=>{document.getElementById('v').src=imgs[i]||'';
|
|
document.getElementById('t').textContent=imgs.length?decodeURIComponent(imgs[i]):'화면 이미지가 아직 없습니다';
|
|
tb.querySelectorAll('button').forEach((b,j)=>b.classList.toggle('on',i==j));};
|
|
if(imgs.length>1)imgs.forEach((x,i)=>{const b=document.createElement('button');b.textContent='화면 '+(i+1);b.onclick=()=>show(i);tb.appendChild(b);});
|
|
if(a.dataset.proto){const r=document.createElement('a');r.className='run';r.href=a.dataset.proto;r.target='_blank';r.textContent='▶ 실행해 보기';tb.appendChild(r);}
|
|
show(0);});
|
|
const f=document.querySelector('nav a');if(f)f.click();</script></body></html>"""
|
|
|
|
def main():
|
|
(SCR / "menu.html").write_text(PAGE.replace("__TREE__", tree_html(SCR)), encoding="utf-8")
|
|
md = ["# 00_화면목록 (자동 생성 — 직접 수정하지 마세요)", "",
|
|
"폴더를 추가/이름변경하고 `python tools/build_menu.py` 를 실행하면 갱신됩니다.",
|
|
"브라우저 미리보기: `wiki/08_화면/menu.html`", ""] + tree_md(SCR)
|
|
(SCR / "00_화면목록.md").write_text("\n".join(md) + "\n", encoding="utf-8")
|
|
print("메뉴 갱신 완료:", SCR / "menu.html")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|