thuthi-plugin 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +55 -0
- package/README.md +13 -2
- package/bin/parallel-browser.js +109 -0
- package/extension/background.js +1329 -0
- package/extension/config.json +1 -0
- package/extension/guard.js +44 -0
- package/extension/manifest.json +10 -0
- package/extension/overlay.js +104 -0
- package/extension/popup.html +34 -0
- package/extension/popup.js +39 -0
- package/extension-reloader/manifest.json +13 -0
- package/extension-reloader/sw.js +17 -0
- package/package.json +13 -4
- package/plugins/thuthi/.claude-plugin/plugin.json +8 -0
- package/plugins/thuthi/context.md +3 -0
- package/plugins/thuthi/hooks/hooks.json +15 -0
- package/plugins/thuthi/skills/setup/SKILL.md +55 -0
- package/plugins/thuthi/skills/setup/scripts/doctor.py +249 -0
- package/plugins/thuthi/skills/setup/scripts/selftest.py +188 -0
- package/plugins/thuthi/tools/claude-switch/claude_switch.py +8 -0
- package/plugins/thuthi/tools/legacy_launcher.py +65 -0
- package/plugins/thuthi/tools/statusline/statusline.py +8 -0
- package/plugins/thuthi-accounts/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-accounts/bin/claude-switch +5 -0
- package/plugins/thuthi-accounts/bin/claude-switch.cmd +4 -0
- package/plugins/thuthi-accounts/hooks/hooks.json +15 -0
- package/plugins/thuthi-accounts/lib/tls.py +68 -0
- package/plugins/thuthi-accounts/lib/usage_store.py +150 -0
- package/plugins/thuthi-accounts/setup_check.py +21 -0
- package/plugins/thuthi-accounts/skills/claude-switch/SKILL.md +48 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude-switch-tui.py +397 -0
- package/plugins/thuthi-accounts/tools/claude-switch/claude_switch.py +1204 -0
- package/plugins/thuthi-accounts/tools/claude-switch/credstore.py +417 -0
- package/plugins/thuthi-accounts/tools/claude-switch/install.py +301 -0
- package/plugins/thuthi-accounts/tools/claude-switch/tests/selftest.py +491 -0
- package/plugins/thuthi-accounts/tools/statusline/statusline.py +212 -0
- package/plugins/thuthi-agenda-picker/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-agenda-picker/context.md +3 -0
- package/plugins/thuthi-agenda-picker/hooks/hooks.json +15 -0
- package/plugins/thuthi-agenda-picker/lib/pbpage.py +397 -0
- package/plugins/thuthi-agenda-picker/setup_check.py +18 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/SKILL.md +280 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/design-rules.md +110 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/diagram/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/agenda.json +146 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/A-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/B-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/C-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/base.css +33 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/name-B.html +15 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-dark.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/references/example/shots/now-light.svg +5 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/picker.py +1286 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/selftest.py +771 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/shot.py +117 -0
- package/plugins/thuthi-agenda-picker/skills/agenda-picker/scripts/template.html +1029 -0
- package/plugins/thuthi-arch-diagram/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-arch-diagram/lib/pbpage.py +397 -0
- package/plugins/thuthi-arch-diagram/lib/tls.py +68 -0
- package/plugins/thuthi-arch-diagram/setup_check.py +10 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/SKILL.md +125 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/design-rules.md +110 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/references/example-shop.py +167 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/check.py +194 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/diagramkit.py +682 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/interact_test.py +115 -0
- package/plugins/thuthi-arch-diagram/skills/arch-diagram/scripts/render.py +113 -0
- package/plugins/thuthi-browser/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-browser/context.md +3 -0
- package/plugins/thuthi-browser/hooks/hooks.json +15 -0
- package/plugins/thuthi-browser/lib/pbpage.py +397 -0
- package/plugins/thuthi-browser/setup_check.py +93 -0
- package/plugins/thuthi-browser/skills/parallel-browser/SKILL.md +271 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/api.md +243 -0
- package/plugins/thuthi-browser/skills/parallel-browser/references/install.md +106 -0
- package/plugins/thuthi-demo-video/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-demo-video/lib/pbpage.py +397 -0
- package/plugins/thuthi-demo-video/setup_check.py +14 -0
- package/plugins/thuthi-demo-video/skills/demo-video/SKILL.md +261 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/caption.html +16 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/cursor.js +132 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/demo_video.py +2416 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/example_scenario.py +97 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/frame.html +95 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/overlay.js +129 -0
- package/plugins/thuthi-demo-video/skills/demo-video/scripts/title.html +30 -0
- package/plugins/thuthi-no-more-slop/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-no-more-slop/setup_check.py +10 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/LICENSE +21 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SKILL.md +235 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/SOURCE.txt +1 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/agents/openai.yaml +6 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/examples.md +289 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/tokens.md +46 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/references/unslop-fallback.md +36 -0
- package/plugins/thuthi-no-more-slop/skills/no-more-slop/scripts/count_tells.py +426 -0
- package/plugins/thuthi-orca/.claude-plugin/plugin.json +9 -0
- package/plugins/thuthi-orca/context.md +5 -0
- package/plugins/thuthi-orca/hooks/hooks.json +18 -0
- package/plugins/thuthi-orca/hooks/orca-team-grid.ts +21 -0
- package/plugins/thuthi-orca/setup_check.py +12 -0
- package/plugins/thuthi-orca/skills/orca-new-work/SKILL.md +492 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/bin/tmux +338 -0
- package/plugins/thuthi-orca/tools/orca-team-grid/tests/selftest.py +299 -0
- package/runtime/client.js +69 -0
- package/runtime/daemon.js +503 -0
- package/runtime/focus-monitor.js +53 -0
- package/runtime/keys.js +86 -0
- package/runtime/owner.js +64 -0
- package/runtime/recorder.js +267 -0
- package/runtime/relay.js +95 -0
- package/runtime/session.js +1599 -0
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""diagramkit — 문서·조사 결과를 Overview + 팝업 상세 다이어그램 HTML 로 만드는 SVG 조립 라이브러리.
|
|
3
|
+
|
|
4
|
+
에디토리얼 디자인 시스템(white-smoke paper · jet-black ink · atomic-tangerine accent) 위에
|
|
5
|
+
한글 규칙(Pretendard → Apple SD Gothic Neo, 한글 최소 12px, 제목 산세리프)을 적용한다.
|
|
6
|
+
CSS :target 팝업 + hover 1.1배 확대 + 배경 스크롤 잠금은 CSS 만으로 동작하고, 인라인 JS 가 ESC 닫기를 더한다.
|
|
7
|
+
|
|
8
|
+
사용 예는 references/example-shop.py 참고.
|
|
9
|
+
"""
|
|
10
|
+
import base64
|
|
11
|
+
import html as H
|
|
12
|
+
import os
|
|
13
|
+
import re
|
|
14
|
+
import sys
|
|
15
|
+
import urllib.request
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
PAPER="#f5f5f5"; INK="#2d3142"; MUTED="#4f5d75"; SOFT="#7a8399"; ACC="#eb6c36"; ACCT="rgba(235,108,54,0.08)"; LINK="#2e5aa8"
|
|
18
|
+
SANS="'Pretendard', 'Pretendard Variable', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif"
|
|
19
|
+
MONO="'Geist Mono', monospace"
|
|
20
|
+
def esc(s): return H.escape(s, quote=True)
|
|
21
|
+
|
|
22
|
+
STYLES = {
|
|
23
|
+
'focal': ('rgba(235,108,54,0.08)', ACC, 'rgba(235,108,54,0.50)', ACC),
|
|
24
|
+
'step': ('#ffffff', INK, 'rgba(45,49,66,0.40)', INK),
|
|
25
|
+
'store': ('rgba(45,49,66,0.05)', MUTED, 'rgba(79,93,117,0.50)', MUTED),
|
|
26
|
+
'ext': ('rgba(45,49,66,0.03)', 'rgba(45,49,66,0.30)', 'rgba(45,49,66,0.22)', SOFT),
|
|
27
|
+
'input': ('rgba(79,93,117,0.10)', SOFT, 'rgba(122,131,153,0.40)', SOFT),
|
|
28
|
+
'opt': ('rgba(45,49,66,0.02)', 'rgba(45,49,66,0.20)', 'rgba(45,49,66,0.22)', SOFT),
|
|
29
|
+
'gate': ('rgba(235,108,54,0.05)', 'rgba(235,108,54,0.50)', 'rgba(235,108,54,0.40)', 'rgba(235,108,54,0.8)'),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def measure(text, size, mono=False):
|
|
33
|
+
adv = 0.62 if mono else 0.6
|
|
34
|
+
return sum(1 if ord(c)>0x3000 else adv for c in text)*size
|
|
35
|
+
|
|
36
|
+
WARN=[]
|
|
37
|
+
def node(x,y,w,h,name,subs=(),tag=None,style='step',dashed=False,badge=None,korean_sub=False):
|
|
38
|
+
fill,stroke,tagstroke,tagfill=STYLES[style]
|
|
39
|
+
da = ' stroke-dasharray="4,3"' if dashed else ''
|
|
40
|
+
o=[f'<rect x="{x}" y="{y}" width="{w}" height="{h}" rx="6" fill="{PAPER}"/>',
|
|
41
|
+
f'<rect class="node-box" x="{x}" y="{y}" width="{w}" height="{h}" rx="6" fill="{fill}" stroke="{stroke}" stroke-width="1"{da}/>']
|
|
42
|
+
cx=x+w/2
|
|
43
|
+
top=y+6
|
|
44
|
+
if tag:
|
|
45
|
+
tw=len(tag)*5.2+10; tw=int((tw+3)//4*4)
|
|
46
|
+
o.append(f'<rect x="{x+8}" y="{y+6}" width="{tw}" height="12" rx="2" fill="transparent" stroke="{tagstroke}" stroke-width="0.8"/>')
|
|
47
|
+
o.append(f'<text x="{x+8+tw/2}" y="{y+15}" fill="{tagfill}" font-size="7" font-family="{MONO}" text-anchor="middle" letter-spacing="0.08em">{esc(tag)}</text>')
|
|
48
|
+
top=y+18
|
|
49
|
+
if badge:
|
|
50
|
+
if any(ord(c)>0x3000 for c in badge): WARN.append(('badge-korean', badge, '7px 모노 뱃지에 한글 금지 — 라틴으로'))
|
|
51
|
+
bw=len(badge)*5.2+10; bw=int((bw+3)//4*4)
|
|
52
|
+
o.append(f'<rect x="{x+w-8-bw}" y="{y+6}" width="{bw}" height="12" rx="2" fill="{MUTED}"/>')
|
|
53
|
+
o.append(f'<text x="{x+w-8-bw/2}" y="{y+15}" fill="{PAPER}" font-size="7" font-family="{MONO}" text-anchor="middle" letter-spacing="0.08em">{esc(badge)}</text>')
|
|
54
|
+
n=len(subs)
|
|
55
|
+
lh = 15 if korean_sub else 13
|
|
56
|
+
block=14+ n*lh
|
|
57
|
+
if measure(name,12)>w-16: WARN.append(('name',name,round(measure(name,12)),w))
|
|
58
|
+
for sname in subs:
|
|
59
|
+
kw = measure(sname,12) if korean_sub else measure(sname,9,True)
|
|
60
|
+
if kw>w-12: WARN.append(('sub',sname,round(kw),w))
|
|
61
|
+
avail_top = top; avail_h = (y+h)-avail_top
|
|
62
|
+
ny = avail_top + (avail_h-block)/2 + 12
|
|
63
|
+
# 마지막 줄 baseline + 글자 아래 여유(3px)가 상자 밖으로 나가면 잘린다 — check.py 는 이걸 못 잡는다
|
|
64
|
+
# (실측: 태그 + 모노 보조줄 3개를 높이 72 에 넣으면 셋째 줄이 잘렸다. 80 이면 들어간다).
|
|
65
|
+
last = ny + (15 + (n-1)*lh if n else 0)
|
|
66
|
+
if last + 3 > y + h: WARN.append(('overflow-v', name, f'{n} subs', f'h={h} → 높이를 늘리거나 줄 수를 줄인다'))
|
|
67
|
+
o.append(f'<text x="{cx}" y="{ny:.0f}" fill="{INK}" font-size="12" font-weight="600" font-family="{SANS}" text-anchor="middle">{esc(name)}</text>')
|
|
68
|
+
for i,s in enumerate(subs):
|
|
69
|
+
fam = SANS if korean_sub else MONO
|
|
70
|
+
fs = 12 if korean_sub else 9
|
|
71
|
+
o.append(f'<text x="{cx}" y="{ny+15+i*lh:.0f}" fill="{MUTED}" font-size="{fs}" font-family="{fam}" text-anchor="middle">{esc(s)}</text>')
|
|
72
|
+
return '\n'.join(o)
|
|
73
|
+
|
|
74
|
+
def zone(x,y,w,h,label,accent=False):
|
|
75
|
+
stroke = 'rgba(235,108,54,0.45)' if accent else 'rgba(45,49,66,0.10)'
|
|
76
|
+
fill = 'rgba(235,108,54,0.03)' if accent else 'rgba(45,49,66,0.02)'
|
|
77
|
+
da = ' stroke-dasharray="4,4"' if accent else ''
|
|
78
|
+
if any(ord(c)>0x3000 for c in label): WARN.append(('zone-korean', label, '7px 모노 존 라벨에 한글 금지 — 라틴으로'))
|
|
79
|
+
lw=len(label)*5.6+12
|
|
80
|
+
return (f'<rect x="{x}" y="{y}" width="{w}" height="{h}" rx="8" fill="{fill}" stroke="{stroke}" stroke-width="0.8"{da}/>'
|
|
81
|
+
f'<rect x="{x+12}" y="{y+4}" width="{lw:.0f}" height="12" rx="2" fill="{PAPER}"/>'
|
|
82
|
+
f'<text x="{x+12+lw/2:.0f}" y="{y+13}" fill="rgba(45,49,66,0.45)" font-size="7" font-family="{MONO}" text-anchor="middle" letter-spacing="0.14em">{esc(label)}</text>')
|
|
83
|
+
|
|
84
|
+
def arrow_attrs(kind='default',dashed=False,w=1.2):
|
|
85
|
+
col={'default':MUTED,'accent':ACC,'link':LINK}[kind]
|
|
86
|
+
mk={'default':'arrow','accent':'arrow-accent','link':'arrow-link'}[kind]
|
|
87
|
+
da=' stroke-dasharray="5,4"' if dashed else ''
|
|
88
|
+
return f'fill="none" stroke="{col}" stroke-width="{w}"{da} marker-end="url(#{mk})"'
|
|
89
|
+
|
|
90
|
+
def hline(x1,x2,y,**k): return f'<path d="M {x1},{y} H {x2}" {arrow_attrs(**k)}/>'
|
|
91
|
+
def vline(x,y1,y2,**k): return f'<path d="M {x},{y1} V {y2}" {arrow_attrs(**k)}/>'
|
|
92
|
+
|
|
93
|
+
def elbow_h(x1,y1,x2,y2,mid=None,**k):
|
|
94
|
+
"""right(or left) then vertical then horizontal; two bends r=8"""
|
|
95
|
+
r=8
|
|
96
|
+
if mid is None: mid=(x1+x2)/2
|
|
97
|
+
sx = 1 if x2>x1 else -1
|
|
98
|
+
sy = 1 if y2>y1 else -1
|
|
99
|
+
d=(f'M {x1},{y1} H {mid-sx*r} Q {mid},{y1} {mid},{y1+sy*r} V {y2-sy*r} Q {mid},{y2} {mid+sx*r},{y2} H {x2}')
|
|
100
|
+
return f'<path d="{d}" {arrow_attrs(**k)}/>'
|
|
101
|
+
|
|
102
|
+
def L_hv(x1,y1,x2,y2,**k):
|
|
103
|
+
"""horizontal from source side, one bend, vertical into dest top/bottom"""
|
|
104
|
+
r=8; sx=1 if x2>x1 else -1; sy=1 if y2>y1 else -1
|
|
105
|
+
d=f'M {x1},{y1} H {x2-sx*r} Q {x2},{y1} {x2},{y1+sy*r} V {y2}'
|
|
106
|
+
return f'<path d="{d}" {arrow_attrs(**k)}/>'
|
|
107
|
+
|
|
108
|
+
def L_vh(x1,y1,x2,y2,**k):
|
|
109
|
+
"""vertical from source top/bottom, one bend, horizontal into dest side"""
|
|
110
|
+
r=8; sx=1 if x2>x1 else -1; sy=1 if y2>y1 else -1
|
|
111
|
+
d=f'M {x1},{y1} V {y2-sy*r} Q {x1},{y2} {x1+sx*r},{y2} H {x2}'
|
|
112
|
+
return f'<path d="{d}" {arrow_attrs(**k)}/>'
|
|
113
|
+
|
|
114
|
+
def elbow_v(x1,y1,x2,y2,mid=None,**k):
|
|
115
|
+
"""vertical, horizontal, vertical (two bends)"""
|
|
116
|
+
r=8
|
|
117
|
+
if mid is None: mid=(y1+y2)/2
|
|
118
|
+
sx=1 if x2>x1 else -1; sy=1 if y2>y1 else -1
|
|
119
|
+
d=f'M {x1},{y1} V {mid-sy*r} Q {x1},{mid} {x1+sx*r},{mid} H {x2-sx*r} Q {x2},{mid} {x2},{mid+sy*r} V {y2}'
|
|
120
|
+
return f'<path d="{d}" {arrow_attrs(**k)}/>'
|
|
121
|
+
|
|
122
|
+
def label(cx,cy,text,color=SOFT,korean=None):
|
|
123
|
+
"""label centered at (cx, cy) -- cy is text baseline center; mask around."""
|
|
124
|
+
if korean is None: korean = any(ord(c)>0x3000 for c in text)
|
|
125
|
+
if korean:
|
|
126
|
+
w=sum(1 if ord(c)>0x3000 else 0.6 for c in text)*12+8; w=int((w+3)//4*4); h=16
|
|
127
|
+
return (f'<rect x="{cx-w/2:.0f}" y="{cy-8}" width="{w}" height="{h}" rx="2" fill="{PAPER}"/>'
|
|
128
|
+
f'<text x="{cx}" y="{cy+4}" fill="{color}" font-size="12" font-weight="500" font-family="{SANS}" text-anchor="middle">{esc(text)}</text>')
|
|
129
|
+
w=len(text)*5.6+8; w=int((w+3)//4*4); h=12
|
|
130
|
+
return (f'<rect x="{cx-w/2:.0f}" y="{cy-6}" width="{w}" height="{h}" rx="2" fill="{PAPER}"/>'
|
|
131
|
+
f'<text x="{cx}" y="{cy+3}" fill="{color}" font-size="8" font-family="{MONO}" text-anchor="middle" letter-spacing="0.06em">{esc(text)}</text>')
|
|
132
|
+
|
|
133
|
+
def lbl_w(text):
|
|
134
|
+
korean = any(ord(c)>0x3000 for c in text)
|
|
135
|
+
if korean:
|
|
136
|
+
w=measure(text,12)+8
|
|
137
|
+
else:
|
|
138
|
+
w=len(text)*5.6+8
|
|
139
|
+
return int((w+3)//4*4)
|
|
140
|
+
|
|
141
|
+
def lside(line_x, cy, text, side='right', color=SOFT):
|
|
142
|
+
w=lbl_w(text)
|
|
143
|
+
cx = line_x + 8 + w/2 if side=='right' else line_x - 8 - w/2
|
|
144
|
+
return label(cx, cy, text, color=color)
|
|
145
|
+
|
|
146
|
+
def legend(x,y,w,items):
|
|
147
|
+
o=[f'<line x1="{x}" y1="{y-8}" x2="{x+w}" y2="{y-8}" stroke="rgba(45,49,66,0.10)" stroke-width="0.8"/>',
|
|
148
|
+
f'<text x="{x}" y="{y+8}" fill="{MUTED}" font-size="8" font-family="{MONO}" letter-spacing="0.14em">LEGEND</text>']
|
|
149
|
+
cx=x+70
|
|
150
|
+
for kind,spec,text in items:
|
|
151
|
+
need = (20 if kind=='box' else 24) + measure(text,12)
|
|
152
|
+
if cx+need > x+w:
|
|
153
|
+
cx=x+70; y+=24
|
|
154
|
+
if kind=='box':
|
|
155
|
+
fill,stroke,da=spec
|
|
156
|
+
dd = ' stroke-dasharray="3,3"' if da else ''
|
|
157
|
+
o.append(f'<rect x="{cx}" y="{y}" width="14" height="10" rx="2" fill="{fill}" stroke="{stroke}" stroke-width="1"{dd}/>')
|
|
158
|
+
else:
|
|
159
|
+
col,da,mk=spec
|
|
160
|
+
dd = ' stroke-dasharray="4,3"' if da else ''
|
|
161
|
+
o.append(f'<line x1="{cx}" y1="{y+5}" x2="{cx+18}" y2="{y+5}" stroke="{col}" stroke-width="1.2"{dd} marker-end="url(#{mk})"/>')
|
|
162
|
+
tx = cx+20 if kind=='box' else cx+24
|
|
163
|
+
o.append(f'<text x="{tx}" y="{y+10}" fill="{MUTED}" font-size="12" font-family="{SANS}">{esc(text)}</text>')
|
|
164
|
+
cx = tx + measure(text,12) + 32
|
|
165
|
+
return '\n'.join(o)
|
|
166
|
+
|
|
167
|
+
DEFS=f'''<defs>
|
|
168
|
+
<marker id="arrow" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="{MUTED}"/></marker>
|
|
169
|
+
<marker id="arrow-accent" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="{ACC}"/></marker>
|
|
170
|
+
<marker id="arrow-link" markerWidth="8" markerHeight="6" refX="7" refY="3" orient="auto"><polygon points="0 0, 8 3, 0 6" fill="{LINK}"/></marker>
|
|
171
|
+
</defs>'''
|
|
172
|
+
|
|
173
|
+
def svg(slug,title,desc,W,Hh,body,grid=False):
|
|
174
|
+
"""접근성 계약(role=img · title 첫 자식 · 슬러그 접두 id)을 채운 <svg>. 마커 · 패턴 · 필터 id 에 슬러그 접두를 붙여
|
|
175
|
+
한 페이지에 svg 여러 장이 있어도 id 가 겹치지 않는다.
|
|
176
|
+
grid=True 가 기본 스타일(타일): #f8fafc 바탕 + 48px 모눈, tile · group · edge · chip 이 쓰는 defs.
|
|
177
|
+
grid=False 는 옛 에디토리얼 스타일(paper 바탕, node · zone · hline …)."""
|
|
178
|
+
if grid:
|
|
179
|
+
defs = TILE_DEFS.replace('id="dk-', f'id="{slug}-dk-')
|
|
180
|
+
body = body.replace('url(#dk-', f'url(#{slug}-dk-')
|
|
181
|
+
bg = f'<rect width="100%" height="100%" fill="{BG}"/>\n<rect width="100%" height="100%" fill="url(#{slug}-dk-grid)"/>'
|
|
182
|
+
limit = PAGE_W
|
|
183
|
+
else:
|
|
184
|
+
defs = DEFS.replace('id="arrow', f'id="{slug}-arrow')
|
|
185
|
+
body = body.replace('url(#arrow', f'url(#{slug}-arrow')
|
|
186
|
+
bg = f'<rect width="100%" height="100%" fill="{PAPER}"/>'
|
|
187
|
+
limit = 1280
|
|
188
|
+
# 페이지 폭보다 넓은 캔버스는 줄이지 않고 제 폭 그대로 그린다 — .diagram-container 의 overflow-x 로 좌우 스크롤된다.
|
|
189
|
+
wide = f' style="width:{W}px;min-width:{W}px"' if W > limit else ''
|
|
190
|
+
return (f'<svg viewBox="0 0 {W} {Hh}"{wide} xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="{slug}-title {slug}-desc">\n'
|
|
191
|
+
f'<title id="{slug}-title">{esc(title)}</title>\n<desc id="{slug}-desc">{esc(desc)}</desc>\n{defs}\n'
|
|
192
|
+
f'{bg}\n{body}\n</svg>')
|
|
193
|
+
|
|
194
|
+
def lane_frame(lanes, x0, x1, y0, lane_h, col_x=180):
|
|
195
|
+
o=[]
|
|
196
|
+
n=len(lanes)
|
|
197
|
+
for i in range(n+1):
|
|
198
|
+
y=y0+i*lane_h
|
|
199
|
+
strong = i in (0,n)
|
|
200
|
+
o.append(f'<line x1="{x0}" y1="{y}" x2="{x1}" y2="{y}" stroke="rgba(45,49,66,{"0.22" if strong else "0.10"})" stroke-width="1"/>')
|
|
201
|
+
o.append(f'<line x1="{col_x}" y1="{y0}" x2="{col_x}" y2="{y0+n*lane_h}" stroke="rgba(45,49,66,0.22)" stroke-width="1"/>')
|
|
202
|
+
for i,(name,sub) in enumerate(lanes):
|
|
203
|
+
cy=y0+i*lane_h+lane_h/2
|
|
204
|
+
o.append(f'<text x="{x0+16}" y="{cy-2:.0f}" fill="{INK}" font-size="12" font-weight="600" font-family="{SANS}">{esc(name)}</text>')
|
|
205
|
+
o.append(f'<text x="{x0+16}" y="{cy+12:.0f}" fill="{SOFT}" font-size="9" font-family="{MONO}">{esc(sub)}</text>')
|
|
206
|
+
return '\n'.join(o)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# ───────────────────────── 타일 스타일 (기본) ─────────────────────────
|
|
210
|
+
# 모눈 바탕 위에 공식 로고 타일 · 색 묶음 · 직각 선 · 번호 매긴 흐름 · 명령 칩으로 그린다 (design-rules §1~§4).
|
|
211
|
+
# 위의 node · zone · hline … 은 옛 에디토리얼 스타일로 그대로 동작한다 (예전 생성 스크립트 호환).
|
|
212
|
+
BG="#f8fafc"; GRID="#e5e7eb"; TBORDER="#d4d4d8"; NAME="#18181b"; SUBC="#71717a"; INK2="#52525b"
|
|
213
|
+
EDGE={'main':"#1d74f5", 'int':"#52525b", 'ext':"#b45309"}
|
|
214
|
+
GROUPS={ # kind: (fill, stroke, 글자색, 기본 아이콘, 점선)
|
|
215
|
+
'server': ("#eff6ff", "#93c5fd", "#1d4ed8", 'server', False),
|
|
216
|
+
'pc': ("#f5f3ff", "#c4b5fd", "#6d28d9", 'laptop', False),
|
|
217
|
+
'outside': ("#fffbeb", "#f59e0b", "#b45309", 'person', True), # 이 구조 밖, 사람이 손으로 하는 단계
|
|
218
|
+
'external':("#fff7ed", "#fdba74", "#c2410c", 'cloud', True), # 외부 SaaS · 남의 시스템
|
|
219
|
+
'data': ("#f0fdf4", "#86efac", "#047857", 'database', False),
|
|
220
|
+
'neutral': ("#fafafa", "#d4d4d8", "#52525b", None, False),
|
|
221
|
+
}
|
|
222
|
+
TILE=100
|
|
223
|
+
PAGE_W=1600 # 타일 스타일 페이지의 그림 폭. 이보다 넓으면 좌우 스크롤
|
|
224
|
+
MONO_T="'Geist Mono', 'SF Mono', ui-monospace, Menlo, monospace"
|
|
225
|
+
|
|
226
|
+
# 로고가 없을 때 쓰는 선 아이콘 (24×24 좌표, stroke 로 그린다. {c} 는 색)
|
|
227
|
+
ICONS = {
|
|
228
|
+
'person': '<circle cx="12" cy="8" r="4"/><path d="M4 21c0-4.4 3.6-7 8-7s8 2.6 8 7"/>',
|
|
229
|
+
'users': '<circle cx="9" cy="8" r="3.5"/><path d="M2.5 20c0-3.8 3-6 6.5-6s6.5 2.2 6.5 6"/><path d="M15.5 4.8a3.5 3.5 0 0 1 0 6.4M17.5 14.3c2.4.6 4 2.6 4 5.7"/>',
|
|
230
|
+
'server': '<rect x="3" y="3" width="18" height="7" rx="1.5"/><rect x="3" y="14" width="18" height="7" rx="1.5"/><circle cx="7" cy="6.5" r="1" fill="{c}"/><circle cx="7" cy="17.5" r="1" fill="{c}"/>',
|
|
231
|
+
'robot': '<rect x="5" y="8" width="14" height="11" rx="2"/><circle cx="9.5" cy="13.5" r="1.2" fill="{c}"/><circle cx="14.5" cy="13.5" r="1.2" fill="{c}"/><path d="M12 8V4.5M10 4h4"/>',
|
|
232
|
+
'laptop': '<rect x="4" y="5" width="16" height="11" rx="1.5"/><path d="M2 19h20"/>',
|
|
233
|
+
'studio': '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M8 9v11"/><path d="M11 13h7M11 16h5"/>',
|
|
234
|
+
'window': '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18"/><circle cx="6" cy="6.5" r=".6" fill="{c}"/><circle cx="8.5" cy="6.5" r=".6" fill="{c}"/>',
|
|
235
|
+
'folder': '<path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/>',
|
|
236
|
+
'file': '<path d="M6 3h8l4 4v14H6z"/><path d="M14 3v4h4M9 12h6M9 16h6"/>',
|
|
237
|
+
'film': '<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M7 4v16M17 4v16M3 9h4M3 15h4M17 9h4M17 15h4"/>',
|
|
238
|
+
'database':'<ellipse cx="12" cy="5.5" rx="7.5" ry="2.8"/><path d="M4.5 5.5v13c0 1.5 3.4 2.8 7.5 2.8s7.5-1.3 7.5-2.8v-13"/><path d="M4.5 12c0 1.5 3.4 2.8 7.5 2.8s7.5-1.3 7.5-2.8"/>',
|
|
239
|
+
'queue': '<rect x="3" y="6" width="4" height="12" rx="1"/><rect x="10" y="6" width="4" height="12" rx="1"/><rect x="17" y="6" width="4" height="12" rx="1"/>',
|
|
240
|
+
'globe': '<circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c2.5 2.6 3.8 5.6 3.8 9s-1.3 6.4-3.8 9c-2.5-2.6-3.8-5.6-3.8-9S9.5 5.6 12 3z"/>',
|
|
241
|
+
'cloud': '<path d="M7 18h10a4 4 0 0 0 .6-8A6 6 0 0 0 6.2 9 4.5 4.5 0 0 0 7 18z"/>',
|
|
242
|
+
'mail': '<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3.5 6.5 12 13l8.5-6.5"/>',
|
|
243
|
+
'card': '<rect x="2.5" y="5" width="19" height="14" rx="2"/><path d="M2.5 10h19M6 15h4"/>',
|
|
244
|
+
'box': '<path d="M12 3 20.5 7.5v9L12 21l-8.5-4.5v-9z"/><path d="M3.5 7.5 12 12l8.5-4.5M12 12v9"/>',
|
|
245
|
+
'gear': '<circle cx="12" cy="12" r="3"/><path d="M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1"/>',
|
|
246
|
+
'terminal':'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3M12.5 15H17"/>',
|
|
247
|
+
'lock': '<rect x="5" y="10.5" width="14" height="10" rx="2"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/>',
|
|
248
|
+
'bell': '<path d="M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z"/><path d="M10 20.5a2 2 0 0 0 4 0"/>',
|
|
249
|
+
'phone': '<rect x="7" y="2.5" width="10" height="19" rx="2"/><path d="M11 18.5h2"/>',
|
|
250
|
+
'clock': '<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3.5 2"/>',
|
|
251
|
+
'list': '<path d="M9 6h11M9 12h11M9 18h11"/><circle cx="4.5" cy="6" r="1" fill="{c}"/><circle cx="4.5" cy="12" r="1" fill="{c}"/><circle cx="4.5" cy="18" r="1" fill="{c}"/>',
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
def icon(kind, x, y, size, color=INK2, sw=1.6):
|
|
255
|
+
"""선 아이콘 하나. 중첩 <svg> 대신 <g transform> 로 그린다 — check.py · render.py 가 바깥 svg 를 정규식으로 자르기 때문."""
|
|
256
|
+
if kind not in ICONS:
|
|
257
|
+
WARN.append(('icon', kind, f'없는 아이콘 — {sorted(ICONS)} 중에서'))
|
|
258
|
+
kind = 'box'
|
|
259
|
+
k = size / 24
|
|
260
|
+
inner = ICONS[kind].replace('{c}', color)
|
|
261
|
+
return (f'<g transform="translate({x:g},{y:g}) scale({k:.4f})" fill="none" stroke="{color}" stroke-width="{sw}" '
|
|
262
|
+
f'stroke-linecap="round" stroke-linejoin="round">{inner}</g>')
|
|
263
|
+
|
|
264
|
+
# ── 공식 로고: devicon · simple-icons 에서 한 번 받아 사용자 캐시에 두고 data URI 로 박는다 ──
|
|
265
|
+
def _cache_dir():
|
|
266
|
+
if os.name == 'nt' and os.environ.get('LOCALAPPDATA'):
|
|
267
|
+
base = Path(os.environ['LOCALAPPDATA'])
|
|
268
|
+
else:
|
|
269
|
+
base = Path(os.environ.get('XDG_CACHE_HOME') or (Path.home() / '.cache'))
|
|
270
|
+
return base / 'thuthi-arch-diagram' / 'logos'
|
|
271
|
+
|
|
272
|
+
def _ssl_ctx():
|
|
273
|
+
# 회사 TLS 검사 아래에서도 붙도록 공용 tls.py (키체인 · NODE_EXTRA_CA_CERTS) 를 쓴다. 없으면 기본.
|
|
274
|
+
try:
|
|
275
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / 'lib'))
|
|
276
|
+
import tls
|
|
277
|
+
return tls.ssl_context()
|
|
278
|
+
except Exception:
|
|
279
|
+
import ssl
|
|
280
|
+
return ssl.create_default_context()
|
|
281
|
+
|
|
282
|
+
def _logo_urls(spec):
|
|
283
|
+
"""'react' · 'devicon:react' · 'devicon:react/plain' → devicon (original → plain 순),
|
|
284
|
+
'si:stripe' · 'si:stripe/635BFF' → simple-icons (색을 안 주면 공식 브랜드 색)."""
|
|
285
|
+
if spec.startswith('si:'):
|
|
286
|
+
slug = spec[3:]
|
|
287
|
+
return [('si-' + slug.replace('/', '-'), f'https://cdn.simpleicons.org/{slug}')]
|
|
288
|
+
name = spec.split(':', 1)[1] if spec.startswith('devicon:') else spec
|
|
289
|
+
name, _, var = name.partition('/')
|
|
290
|
+
vars_ = [var] if var else ['original', 'plain']
|
|
291
|
+
return [(f'devicon-{name}-{v}', f'https://cdn.jsdelivr.net/gh/devicons/devicon/icons/{name}/{name}-{v}.svg') for v in vars_]
|
|
292
|
+
|
|
293
|
+
_LOGOS = {}
|
|
294
|
+
def logo(spec):
|
|
295
|
+
"""공식 로고의 data:image URI. 실패하면 None + WARN (tile 은 선 아이콘으로 떨어진다).
|
|
296
|
+
spec: devicon 이름('react') · 'si:<slug>' · 로컬 파일 경로(.svg/.png). 로고는 색을 바꾸지 않는다."""
|
|
297
|
+
if spec in _LOGOS: return _LOGOS[spec]
|
|
298
|
+
data, mime = None, 'image/svg+xml'
|
|
299
|
+
lp = Path(os.path.expanduser(spec))
|
|
300
|
+
if ('/' in spec or '\\' in spec) and lp.suffix.lower() in ('.svg', '.png') and lp.is_file():
|
|
301
|
+
data = lp.read_bytes(); mime = 'image/png' if lp.suffix.lower() == '.png' else mime
|
|
302
|
+
else:
|
|
303
|
+
cdir = _cache_dir()
|
|
304
|
+
for key, url in _logo_urls(spec):
|
|
305
|
+
f = cdir / f'{key}.svg'
|
|
306
|
+
if f.is_file() and f.stat().st_size > 0:
|
|
307
|
+
data = f.read_bytes(); break
|
|
308
|
+
try:
|
|
309
|
+
req = urllib.request.Request(url, headers={'User-Agent': 'thuthi-arch-diagram'})
|
|
310
|
+
with urllib.request.urlopen(req, timeout=10, context=_ssl_ctx()) as r:
|
|
311
|
+
body = r.read(300_000)
|
|
312
|
+
except Exception as e: # 404 · 403(devicon 없는 이름) · 오프라인 · TLS
|
|
313
|
+
last = e; continue
|
|
314
|
+
if b'<svg' not in body[:500] or re.search(rb'<script|\son\w+\s*=', body):
|
|
315
|
+
last = 'SVG 가 아님'; continue
|
|
316
|
+
try:
|
|
317
|
+
cdir.mkdir(parents=True, exist_ok=True); f.write_bytes(body)
|
|
318
|
+
except OSError:
|
|
319
|
+
pass
|
|
320
|
+
data = body; break
|
|
321
|
+
if data is None:
|
|
322
|
+
WARN.append(('logo', spec, f'못 받음 ({locals().get("last")}) — 선 아이콘으로 그린다. 캐시: {cdir}'))
|
|
323
|
+
uri = f'data:{mime};base64,{base64.b64encode(data).decode()}' if data else None
|
|
324
|
+
_LOGOS[spec] = uri
|
|
325
|
+
return uri
|
|
326
|
+
|
|
327
|
+
def _tw(text, size, mono=False, bold=False):
|
|
328
|
+
"""글자 폭 추정 (한글 1em, 라틴 0.6em · 모노 0.62em, 굵으면 +4%)."""
|
|
329
|
+
w = measure(text, size, mono)
|
|
330
|
+
return w * (1.04 if bold else 1)
|
|
331
|
+
|
|
332
|
+
def _box(x, y, w, h, kind):
|
|
333
|
+
return f' data-box="{x:.0f} {y:.0f} {w:.0f} {h:.0f}" data-kind="{kind}"'
|
|
334
|
+
|
|
335
|
+
def badge(cx, cy, kind, color=INK2, r=13):
|
|
336
|
+
"""타일 모서리에 붙는 작은 원 + 선 아이콘. 사람(person) · 기계(server/robot) 를 로고 타일에도 표시할 때."""
|
|
337
|
+
return (f'<circle cx="{cx}" cy="{cy}" r="{r}" fill="#fff" stroke="{color}" stroke-width="1.5"/>'
|
|
338
|
+
+ icon(kind, cx - r*0.62, cy - r*0.62, r*1.24, color, sw=2))
|
|
339
|
+
|
|
340
|
+
def chip(cx, y, text, slash=True):
|
|
341
|
+
"""명령 · 스킬 이름 칩 (굵은 모노, 회색 바탕). 스킬 · 슬래시 명령은 앞에 '/' 를 붙인다 (빠졌으면 붙여 준다)."""
|
|
342
|
+
if slash and not text.startswith('/'): text = '/' + text
|
|
343
|
+
w = _tw(text, 14, True, True) + 22
|
|
344
|
+
return (f'<rect class="chip-box" x="{cx - w/2:.0f}" y="{y}" width="{w:.0f}" height="26" rx="6" fill="#f4f4f5" stroke="{TBORDER}"{_box(cx-w/2, y, w, 26, "chip")}/>'
|
|
345
|
+
f'<text x="{cx}" y="{y + 18}" text-anchor="middle" font-size="14" font-weight="700" fill="{NAME}" font-family="{MONO_T}">{esc(text)}</text>')
|
|
346
|
+
|
|
347
|
+
def tile(x, y, name, sub=None, *, logo_spec=None, icon_kind=None, color=INK2, tint='#fff', badge_kind=None,
|
|
348
|
+
chips=(), size=TILE, count=None):
|
|
349
|
+
"""컴포넌트 타일: 흰(또는 옅은 색) 정사각 + 공식 로고 또는 선 아이콘, 아래 굵은 이름 + 회색 모노 보조줄 + 명령 칩.
|
|
350
|
+
logo_spec 를 못 받으면 icon_kind (없으면 'box') 로 떨어진다. count=3 이면 이름 뒤에 '× 3' — 같은 상자를 여러 번 그리지 않는다.
|
|
351
|
+
클릭해서 팝업을 열려면 link('#popup-x', tile(...)) 로 감싼다. 차지하는 높이는 tile_h(sub, chips)."""
|
|
352
|
+
cx = x + size/2
|
|
353
|
+
o = [f'<rect class="tile-box" x="{x}" y="{y}" width="{size}" height="{size}" rx="14" fill="{tint}" stroke="{TBORDER}" stroke-width="1.5" filter="url(#dk-shadow)"{_box(x, y, size, size, "tile")}/>']
|
|
354
|
+
uri = logo(logo_spec) if logo_spec else None
|
|
355
|
+
pad = size * 0.22
|
|
356
|
+
if uri:
|
|
357
|
+
o.append(f'<image href="{uri}" x="{x+pad:g}" y="{y+pad:g}" width="{size-2*pad:g}" height="{size-2*pad:g}"/>')
|
|
358
|
+
else:
|
|
359
|
+
o.append(icon(icon_kind or 'box', x + size*0.24, y + size*0.24, size*0.52, color))
|
|
360
|
+
if badge_kind:
|
|
361
|
+
o.append(badge(x + size - 4, y + 4, badge_kind, color))
|
|
362
|
+
nm = name + (f' × {count}' if count else '')
|
|
363
|
+
ny = y + size + 30
|
|
364
|
+
nw = _tw(nm, 19, bold=True)
|
|
365
|
+
o.append(f'<text x="{cx}" y="{ny}" text-anchor="middle" font-size="19" font-weight="700" fill="{NAME}" font-family="{SANS}"{_box(cx-nw/2, ny-16, nw, 21, "name")}>{esc(nm)}</text>')
|
|
366
|
+
cy = ny + 8
|
|
367
|
+
if sub:
|
|
368
|
+
sw_ = _tw(sub, 13.5, True)
|
|
369
|
+
o.append(f'<text x="{cx}" y="{ny+22}" text-anchor="middle" font-size="13.5" fill="{SUBC}" font-family="{MONO_T}"{_box(cx-sw_/2, ny+11, sw_, 15, "name")}>{esc(sub)}</text>')
|
|
370
|
+
cy = ny + 32
|
|
371
|
+
for i, c in enumerate(chips):
|
|
372
|
+
o.append(chip(cx, cy + 6 + i*34, c))
|
|
373
|
+
return '<g class="tile">' + '\n'.join(o) + '</g>'
|
|
374
|
+
|
|
375
|
+
def tile_h(sub=True, chips=(), size=TILE):
|
|
376
|
+
"""tile() 이 차지하는 전체 높이 (타일 + 이름 + 보조줄 + 칩)."""
|
|
377
|
+
return size + 38 + (24 if sub else 0) + (len(chips)*34 + 6 if chips else 0)
|
|
378
|
+
|
|
379
|
+
def group(x, y, w, h, label, kind='server', *, icon_kind='', note=None, dashed=None, fill=None, stroke=None, color=None):
|
|
380
|
+
"""묶음: 옅은 색 둥근 사각 + 왼쪽 위 아이콘 · 굵은 라벨 (묶음 색), 오른쪽 위 회색 모노 메모(note, 선택).
|
|
381
|
+
kind: server(파랑) · pc(보라) · outside(주황 점선, 이 구조 밖 사람 손 단계) · external(주황 점선, 외부 서비스) · data(초록) · neutral(회색)."""
|
|
382
|
+
f0, s0, c0, i0, d0 = GROUPS[kind]
|
|
383
|
+
fill = fill or f0; stroke = stroke or s0; color = color or c0
|
|
384
|
+
ik = i0 if icon_kind == '' else icon_kind
|
|
385
|
+
da = ' stroke-dasharray="8 6"' if (d0 if dashed is None else dashed) else ''
|
|
386
|
+
o = [f'<rect class="group-box" x="{x}" y="{y}" width="{w}" height="{h}" rx="16" fill="{fill}" stroke="{stroke}" stroke-width="1.6"{da}/>']
|
|
387
|
+
tx = x + 24
|
|
388
|
+
if ik:
|
|
389
|
+
o.append(icon(ik, x + 20, y + 19, 24, color, sw=1.8)); tx = x + 52
|
|
390
|
+
lw = _tw(label, 18, bold=True)
|
|
391
|
+
o.append(f'<text x="{tx}" y="{y+38}" font-size="18" font-weight="700" fill="{color}" font-family="{SANS}"{_box(tx, y+22, lw, 22, "glabel")}>{esc(label)}</text>')
|
|
392
|
+
if note:
|
|
393
|
+
nw = _tw(note, 13.5, True)
|
|
394
|
+
o.append(f'<text x="{x+w-24}" y="{y+38}" text-anchor="end" font-size="13.5" fill="{SUBC}" font-family="{MONO_T}"{_box(x+w-24-nw, y+27, nw, 15, "glabel")}>{esc(note)}</text>')
|
|
395
|
+
return '\n'.join(o)
|
|
396
|
+
|
|
397
|
+
def note(x, y, text, anchor='start', color=SUBC):
|
|
398
|
+
"""그림 안 짧은 회색 모노 메모 한 줄 (묶음 설명, 결과물 이름). 긴 설명은 그림 밖 본문으로."""
|
|
399
|
+
w = _tw(text, 13.5, True)
|
|
400
|
+
x0 = x - w if anchor == 'end' else (x - w/2 if anchor == 'middle' else x)
|
|
401
|
+
return f'<text x="{x}" y="{y}" text-anchor="{anchor}" font-size="13.5" fill="{color}" font-family="{MONO_T}"{_box(x0, y-11, w, 15, "label")}>{esc(text)}</text>'
|
|
402
|
+
|
|
403
|
+
def circled(n):
|
|
404
|
+
"""1 → ①, 20 까지. 흐름 번호는 이 글자를 라벨 앞에 붙인다 (원 도형 안에 숫자를 따로 그리지 않는다)."""
|
|
405
|
+
return chr(0x2460 + n - 1) if 1 <= n <= 20 else f'({n})'
|
|
406
|
+
|
|
407
|
+
def edge(pts, text=None, *, kind='main', num=None, both=False, dashed=None, at=None, anchor=None, halo=BG):
|
|
408
|
+
"""직각 연결선. pts = [(x,y), …] 수평 · 수직 마디만 (대각선이면 WARN).
|
|
409
|
+
kind: main(파랑, 주 흐름) · int(회색, 내부 · 보조) · ext(주황, 외부 · 흐름 밖, 기본 점선).
|
|
410
|
+
num=1 → 라벨 앞에 ① (주 흐름 읽는 순서). both=True 면 양방향 화살촉.
|
|
411
|
+
라벨은 at=(x, y) 로 직접 두거나, 안 주면 가장 긴 마디의 가운데 — 가로 마디면 선 12px 위, 세로 마디면 오른쪽 10px.
|
|
412
|
+
라벨 글자에 바탕색 테두리(paint-order: stroke)를 둘러 선이 글자를 지나가도 읽히게 하지만, 선 위에 두지 않는 게 원칙이다."""
|
|
413
|
+
col = EDGE[kind]
|
|
414
|
+
if dashed is None: dashed = kind == 'ext'
|
|
415
|
+
for (x1, y1), (x2, y2) in zip(pts, pts[1:]):
|
|
416
|
+
if x1 != x2 and y1 != y2:
|
|
417
|
+
WARN.append(('edge-diagonal', (x1, y1, x2, y2), '수평 · 수직 마디만'))
|
|
418
|
+
d = 'M' + ' L'.join(f'{x:g},{y:g}' for x, y in pts)
|
|
419
|
+
da = ' stroke-dasharray="7 6"' if dashed else ''
|
|
420
|
+
mk = f'url(#dk-ar-{kind})'
|
|
421
|
+
o = [f'<path class="edge" d="{d}" fill="none" stroke="{col}" stroke-width="2.4"{da} marker-end="{mk}"'
|
|
422
|
+
+ (f' marker-start="{mk}"' if both else '') + '/>']
|
|
423
|
+
if num is not None:
|
|
424
|
+
text = circled(num) + (' ' + text if text else '')
|
|
425
|
+
if text:
|
|
426
|
+
if at is None:
|
|
427
|
+
segs = sorted(zip(pts, pts[1:]), key=lambda s: -(abs(s[0][0]-s[1][0]) + abs(s[0][1]-s[1][1])))
|
|
428
|
+
(x1, y1), (x2, y2) = segs[0]
|
|
429
|
+
if y1 == y2: lx, ly, anc = (x1+x2)/2, y1 - 12, 'middle'
|
|
430
|
+
else: lx, ly, anc = x1 + 10, (y1+y2)/2 + 5, 'start'
|
|
431
|
+
else:
|
|
432
|
+
lx, ly = at; anc = 'middle'
|
|
433
|
+
anc = anchor or anc
|
|
434
|
+
w = _tw(text, 14, True)
|
|
435
|
+
x0 = lx - w if anc == 'end' else (lx - w/2 if anc == 'middle' else lx)
|
|
436
|
+
o.append(f'<text x="{lx:g}" y="{ly:g}" text-anchor="{anc}" font-size="14" fill="{col}" font-family="{MONO_T}" '
|
|
437
|
+
f'paint-order="stroke" stroke="{halo}" stroke-width="6" stroke-linejoin="round"{_box(x0, ly-12, w, 16, "label")}>{esc(text)}</text>')
|
|
438
|
+
return '\n'.join(o)
|
|
439
|
+
|
|
440
|
+
def legend_tiles(x, y, items):
|
|
441
|
+
"""타일 스타일 범례 한 줄: items = [('main'|'int'|'ext', 글), …] 선 종류, 또는 ('chip', 글)."""
|
|
442
|
+
o = []; cx = x
|
|
443
|
+
for k, t in items:
|
|
444
|
+
if k == 'chip':
|
|
445
|
+
o.append(chip(cx + 40, y - 18, '/command')); cx += 92
|
|
446
|
+
else:
|
|
447
|
+
da = ' stroke-dasharray="7 6"' if k == 'ext' else ''
|
|
448
|
+
o.append(f'<path d="M{cx},{y-5} L{cx+40},{y-5}" stroke="{EDGE[k]}" stroke-width="2.4"{da} marker-end="url(#dk-ar-{k})"/>'); cx += 52
|
|
449
|
+
w = _tw(t, 14)
|
|
450
|
+
o.append(f'<text x="{cx}" y="{y}" font-size="14" fill="{INK2}" font-family="{SANS}"{_box(cx, y-12, w, 16, "label")}>{esc(t)}</text>')
|
|
451
|
+
cx += w + 36
|
|
452
|
+
return '\n'.join(o)
|
|
453
|
+
|
|
454
|
+
TILE_DEFS = f'''<defs>
|
|
455
|
+
<pattern id="dk-grid" width="48" height="48" patternUnits="userSpaceOnUse"><path d="M48 0H0V48" fill="none" stroke="{GRID}" stroke-width="1"/></pattern>
|
|
456
|
+
<filter id="dk-shadow" x="-20%" y="-20%" width="140%" height="140%"><feDropShadow dx="0" dy="1.5" stdDeviation="1.5" flood-color="#0f172a" flood-opacity=".08"/></filter>
|
|
457
|
+
''' + ''.join(f'<marker id="dk-ar-{k}" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" fill="{c}"/></marker>\n' for k, c in EDGE.items()) + '</defs>'
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
# ───────────────────────── 페이지 조립 ─────────────────────────
|
|
461
|
+
FONT_LINK = ''' <link href="https://fonts.googleapis.com/css2?family=Geist+Mono:wght@400;500&family=Noto+Sans+KR:wght@400;500;700&display=swap" rel="stylesheet">'''
|
|
462
|
+
|
|
463
|
+
CSS = ''' <style>
|
|
464
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
465
|
+
:root {
|
|
466
|
+
--color-paper: #f5f5f5; --color-paper-2: #ececec; --color-ink: #2d3142; --color-muted: #4f5d75; --color-soft: #7a8399;
|
|
467
|
+
--color-rule: rgba(45,49,66,0.12); --color-accent: #eb6c36; --color-link: #2e5aa8;
|
|
468
|
+
--font-sans: 'Pretendard', 'Pretendard Variable', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
|
|
469
|
+
--font-serif: var(--font-sans);
|
|
470
|
+
--font-mono: 'Geist Mono', ui-monospace, Menlo, monospace;
|
|
471
|
+
}
|
|
472
|
+
body { font-family: var(--font-sans); background: var(--color-paper); min-height: 100vh; padding: 3rem 2rem; color: var(--color-ink); }
|
|
473
|
+
.container { max-width: 1280px; margin: 0 auto; }
|
|
474
|
+
.header { margin-bottom: 2.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--color-rule); }
|
|
475
|
+
h1 { font-family: var(--font-sans); font-size: clamp(1.5rem, 2vw + 1rem, 1.95rem); font-weight: 700; line-height: 1.3; margin-bottom: 0.4rem; }
|
|
476
|
+
.meta { font-size: 0.8rem; line-height: 1.5; color: var(--color-soft); }
|
|
477
|
+
.meta code { font-family: var(--font-mono); font-size: 0.74rem; }
|
|
478
|
+
.intro { font-size: 0.95rem; line-height: 1.75; margin-top: 1.1rem; max-width: 60em; }
|
|
479
|
+
.section { margin-top: 3.25rem; }
|
|
480
|
+
h2 { font-family: var(--font-sans); font-size: 1.15rem; font-weight: 700; line-height: 1.4; margin-bottom: 0.7rem; }
|
|
481
|
+
h2 .num { color: var(--color-soft); font-weight: 500; margin-right: 0.45rem; }
|
|
482
|
+
.section > p { font-size: 0.9rem; line-height: 1.75; margin-bottom: 1.25rem; max-width: 62em; }
|
|
483
|
+
.diagram-container { background: transparent; border: none; padding: 0; overflow-x: auto; }
|
|
484
|
+
svg { width: 100%; min-width: 960px; display: block; }
|
|
485
|
+
.cards { display: grid; grid-template-columns: 1.1fr 1fr 0.9fr; gap: 2rem; margin-top: 1.5rem; }
|
|
486
|
+
@media (max-width: 900px) { .cards { grid-template-columns: 1fr; gap: 1.75rem; } }
|
|
487
|
+
.card h3 { font-size: 0.9rem; font-weight: 700; line-height: 1.45; margin-bottom: 0.7rem; padding-bottom: 0.55rem; border-bottom: 1px solid var(--color-rule); }
|
|
488
|
+
.card ul { list-style: disc; padding-left: 1.1rem; font-size: 0.85rem; line-height: 1.75; }
|
|
489
|
+
.card li { margin-bottom: 0.85rem; }
|
|
490
|
+
.card li::marker { color: var(--color-soft); }
|
|
491
|
+
.card ul ul { list-style: circle; padding-left: 1rem; margin: 0.35rem 0 0.1rem; font-size: 1em; }
|
|
492
|
+
.card li li { margin-bottom: 0.3rem; }
|
|
493
|
+
.card b { display: block; font-weight: 600; color: var(--color-ink); margin-bottom: 0.2rem; }
|
|
494
|
+
.aside { font-size: 0.875rem; line-height: 1.7; color: var(--color-muted); border-top: 1px solid var(--color-rule); padding-top: 0.9rem; margin: 1.25rem 0 0; }
|
|
495
|
+
.pbody, .ovbody { font-size: 0.9rem; line-height: 1.75; margin-bottom: 1.25rem; max-width: 62em; }
|
|
496
|
+
.pbody p, .ovbody p, .aside p, .intro p { margin: 0 0 0.6rem; }
|
|
497
|
+
.pbody ul, .ovbody ul, .aside ul { list-style: disc; padding-left: 1.2rem; margin: 0.2rem 0 0.7rem; }
|
|
498
|
+
.pbody ul ul, .ovbody ul ul, .aside ul ul { list-style: circle; margin: 0.3rem 0 0.2rem; }
|
|
499
|
+
.pbody li, .ovbody li, .aside li { margin-bottom: 0.4rem; }
|
|
500
|
+
.pbody li::marker, .ovbody li::marker, .aside li::marker { color: var(--color-soft); }
|
|
501
|
+
.pbody b, .ovbody b, .aside b { font-weight: 600; color: var(--color-ink); margin-right: 0.35rem; }
|
|
502
|
+
.pbody code, .ovbody code, .aside code, .intro code, .hint code, .card code, .section > p code { font-family: var(--font-mono); font-size: 0.8em; color: var(--color-ink); background: rgba(45,49,66,0.07); border: 1px solid rgba(45,49,66,0.10); border-radius: 4px; padding: 0.05em 0.35em; margin: 0 0.05em; white-space: nowrap; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
|
|
503
|
+
.node-link { cursor: pointer; transform-box: fill-box; transform-origin: center; transition: transform .18s cubic-bezier(.2,.8,.2,1); }
|
|
504
|
+
.node-link .node-box, .node-link .tile-box { transition: stroke-width .18s ease, stroke .18s ease; }
|
|
505
|
+
.node-link:hover, .node-link:focus-visible { transform: scale(1.1); }
|
|
506
|
+
.node-link:hover .node-box, .node-link:focus-visible .node-box { stroke-width: 2.4; stroke: var(--color-accent); }
|
|
507
|
+
.node-link:hover .tile-box, .node-link:focus-visible .tile-box { stroke-width: 2.4; stroke: #1d74f5; }
|
|
508
|
+
@media (prefers-reduced-motion: reduce) { .node-link, .node-link .node-box, .node-link .tile-box { transition: none; } .node-link:hover, .node-link:focus-visible { transform: none; } }
|
|
509
|
+
.hint { font-size: 0.85rem; line-height: 1.7; color: var(--color-soft); margin-top: 0.9rem; }
|
|
510
|
+
.hint b { color: var(--color-muted); font-weight: 500; }
|
|
511
|
+
.modal { display: none; position: fixed; inset: 0; z-index: 20; }
|
|
512
|
+
.modal:target { display: block; }
|
|
513
|
+
body:has(.modal:target) { overflow: hidden; }
|
|
514
|
+
.modal-backdrop { position: absolute; inset: 0; background: rgba(45,49,66,0.45); }
|
|
515
|
+
.modal-panel { position: relative; margin: 3vh auto; width: min(1320px, 96vw); max-height: 94vh; overflow: auto; overscroll-behavior: contain; background: var(--color-paper); border: 1px solid var(--color-rule); border-radius: 8px; padding: 1.75rem 2rem 2rem; }
|
|
516
|
+
.modal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
|
|
517
|
+
.modal-close { flex-shrink: 0; font-size: 0.8rem; color: var(--color-muted); text-decoration: none; border: 1px solid var(--color-rule); border-radius: 4px; padding: 0.35rem 0.7rem; background: #fff; }
|
|
518
|
+
.modal-panel > p { font-size: 0.9rem; line-height: 1.75; margin-bottom: 1.25rem; }
|
|
519
|
+
.modal-close:hover { color: var(--color-ink); border-color: var(--color-ink); }
|
|
520
|
+
.modal .diagram-container { margin-top: 0.5rem; }
|
|
521
|
+
@media print { .modal { display: block; position: static; } .modal-backdrop, .modal-close { display: none; } .modal-panel { width: auto; max-height: none; border: none; padding: 0; margin: 2rem 0 0; } }
|
|
522
|
+
.roles { border-collapse: collapse; width: 100%; font-size: 0.85rem; margin-top: 0.4rem; }
|
|
523
|
+
.roles th, .roles td { border-bottom: 1px solid var(--color-rule); padding: 0.55rem 0.65rem; text-align: left; vertical-align: top; line-height: 1.6; }
|
|
524
|
+
.roles th { background: rgba(45,49,66,0.04); font-weight: 600; color: var(--color-muted); }
|
|
525
|
+
.roles td:first-child { white-space: nowrap; font-weight: 600; }
|
|
526
|
+
.roles code { font-family: var(--font-mono); font-size: 0.85em; background: #f4f4f5; border: 1px solid #d4d4d8; border-radius: 5px; padding: 0.05em 0.4em; white-space: nowrap; }
|
|
527
|
+
.footer { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--color-rule); font-size: 0.8rem; color: var(--color-soft); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
|
|
528
|
+
</style>'''
|
|
529
|
+
|
|
530
|
+
# 타일 스타일(기본) 페이지: 흰 바탕, 넓은 본문(1600), 그림은 테두리 둥근 카드 안. 옛 CSS 위에 덮어쓴다.
|
|
531
|
+
TILE_CSS = ''' <style>
|
|
532
|
+
:root { --color-paper: #ffffff; --color-ink: #18181b; --color-muted: #52525b; --color-soft: #71717a; --color-rule: #e4e4e7; --color-accent: #1d74f5; }
|
|
533
|
+
body { padding: 2rem 2rem 3.5rem; }
|
|
534
|
+
.container { max-width: 1600px; }
|
|
535
|
+
.header { margin-bottom: 1.6rem; padding-bottom: 0; border-bottom: none; }
|
|
536
|
+
h1 { font-size: 1.45rem; }
|
|
537
|
+
.intro { font-size: 0.9rem; color: var(--color-muted); margin-top: 0.5rem; max-width: 72em; }
|
|
538
|
+
.section { margin-top: 2rem; }
|
|
539
|
+
.section > .diagram-container, .modal .diagram-container { border: 1px solid var(--color-rule); border-radius: 12px; overflow-x: auto; }
|
|
540
|
+
svg { min-width: 1080px; }
|
|
541
|
+
.modal-panel { width: min(1680px, 96vw); background: #fff; border-radius: 12px; }
|
|
542
|
+
.modal-backdrop { background: rgba(15,23,42,0.45); }
|
|
543
|
+
</style>'''
|
|
544
|
+
|
|
545
|
+
SCRIPT = '''<script>
|
|
546
|
+
(function () {
|
|
547
|
+
// ESC → 열린 팝업 닫기 (CSS :target 이 기본 동작이라 JS 없이도 열고 닫힌다)
|
|
548
|
+
document.addEventListener('keydown', function (e) {
|
|
549
|
+
if (e.key === 'Escape' && document.querySelector('.modal:target')) {
|
|
550
|
+
location.hash = '#overview';
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
// 주의: hover 한 노드를 appendChild 로 맨 앞에 올리는 방식은 쓰지 않는다 — SVG 요소를 DOM 에서 옮기면
|
|
554
|
+
// Chrome 이 :hover 를 잃고(마우스를 움직여도 복구 안 됨) 클릭도 취소된다. 실측으로 확인함.
|
|
555
|
+
})();
|
|
556
|
+
</script>'''
|
|
557
|
+
|
|
558
|
+
def card_html(c):
|
|
559
|
+
items=''.join(f'<li>{i}</li>' for i in c.get('items',[]))
|
|
560
|
+
return f'<div class="card"><h3>{esc(c["title"])}</h3><ul>{items}</ul></div>'
|
|
561
|
+
|
|
562
|
+
def _block(html, cls=''):
|
|
563
|
+
"""본문 한 덩어리를 감싼다. 문단 · 목록 HTML(<p> · <ul> · <ol> · <div> 로 시작)이면 div 로, 평문이면 p 로.
|
|
564
|
+
긴 설명은 짧은 문단과 목록으로 나눠 넘긴다 — 한 문단에 다 몰면 읽기 어렵다는 사용자 지적(2026-09-28)."""
|
|
565
|
+
c = f' class="{cls}"' if cls else ''
|
|
566
|
+
if re.match(r'\s*<(p|ul|ol|div)\b', html or ''):
|
|
567
|
+
return f'<div{c}>{html}</div>'
|
|
568
|
+
return f'<p{c}>{html}</p>'
|
|
569
|
+
|
|
570
|
+
# ───────────────────────── 설명 속 식별자를 코드 칩으로 ─────────────────────────
|
|
571
|
+
# 한글 문장과 식별자를 눈으로 가르려고 설명 HTML 의 태그 밖 글자에서 식별자를 찾아 <code> 로 감싼다
|
|
572
|
+
# (사용자 지적 2026-09-28 "일반 한글과 agent 이름 · 티켓 이름을 분리해 달라"). 이미 <code> 안이거나 태그 속성이면
|
|
573
|
+
# 건드리지 않는다. 기본 패턴은 모양만으로 식별자임이 분명한 것만 잡는다 — 한 단어 kebab(read-only, sub-agent)이나
|
|
574
|
+
# 평범한 영단어는 잡지 않으므로, 그 프로젝트에서 이름으로 쓰이는 짧은 낱말(runner, auditor, map …)은 names 로 넘긴다.
|
|
575
|
+
_CODE_DEFAULT = [
|
|
576
|
+
r'\b[A-Z][A-Z0-9]+-\d+\b', # 티켓 번호 (ABC-123, IT250218R-873)
|
|
577
|
+
r'[\w./{}*\-]+\.(?:md|json|ya?ml|py|mjs|cjs|js|ts|tsx|jsx|sh|toml|diff|html|css|sql|txt)\b', # 파일 · 경로
|
|
578
|
+
r'(?<![\w-])--[a-z][a-z0-9-]*', # CLI 플래그
|
|
579
|
+
r'\b[a-z_]+=[\w.\-]+', # key=value
|
|
580
|
+
r'\b\w+\[\](?:\.\w+)*', # 배열 필드 (items[], shells[].match)
|
|
581
|
+
r'\b\w+\(\)', # 호출 모양 (url())
|
|
582
|
+
r'\b[a-z][a-z0-9]*(?:_[a-z0-9]+)+\b', # snake_case
|
|
583
|
+
r'\b[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+\b', # SCREAMING_SNAKE (enum · mode)
|
|
584
|
+
r'\b[a-z][a-z0-9]*(?:-[a-z0-9]+){2,}\b', # 두 번 이상 이어진 kebab id (shop-01-domain-catalog)
|
|
585
|
+
]
|
|
586
|
+
_TAG_SPLIT = re.compile(r'(<code>.*?</code>|<[^>]+>)', re.S)
|
|
587
|
+
|
|
588
|
+
def codeify(html_text, names=(), patterns=()):
|
|
589
|
+
"""html_text 의 태그 밖 식별자를 <code> 로 감싼다.
|
|
590
|
+
patterns: 먼저 적용할 정규식 (여러 낱말 명령 'receipt --seal' 같은 것), names: 낱말 목록 (단어 경계로 감쌈, 긴 것부터)."""
|
|
591
|
+
alts = list(patterns)
|
|
592
|
+
if names:
|
|
593
|
+
alts.append(r'(?<![\w-])(?:' + '|'.join(re.escape(n) for n in sorted(set(names), key=len, reverse=True)) + r')(?![\w-])')
|
|
594
|
+
alts += _CODE_DEFAULT
|
|
595
|
+
rx = re.compile('|'.join(f'(?:{a})' for a in alts))
|
|
596
|
+
parts = _TAG_SPLIT.split(html_text or '')
|
|
597
|
+
return ''.join(p if (not p or p.startswith('<')) else rx.sub(lambda m: f'<code>{m.group(0)}</code>', p) for p in parts)
|
|
598
|
+
|
|
599
|
+
def popup_html(p):
|
|
600
|
+
aside = _block(p['aside'], 'aside') if p.get('aside') else ''
|
|
601
|
+
return f''' <div class="modal" id="{p['id']}" role="dialog" aria-labelledby="{p['id']}-h2">
|
|
602
|
+
<a class="modal-backdrop" href="#overview" aria-label="닫기"></a>
|
|
603
|
+
<div class="modal-panel">
|
|
604
|
+
<div class="modal-top">
|
|
605
|
+
<h2 id="{p['id']}-h2">{esc(p['title'])}</h2>
|
|
606
|
+
<a class="modal-close" href="#overview">닫기</a>
|
|
607
|
+
</div>
|
|
608
|
+
{_block(p.get('body',''), 'pbody')}
|
|
609
|
+
<div class="diagram-container">{p['svg']}</div>
|
|
610
|
+
{aside}
|
|
611
|
+
</div>
|
|
612
|
+
</div>
|
|
613
|
+
'''
|
|
614
|
+
|
|
615
|
+
def build_page(*, lang='ko', title, meta, h1, intro, overview_h2, overview_body, overview_svg,
|
|
616
|
+
hint='', popups=(), cards=(), cards_h2='', cards_body='', footer_left='', footer_right='',
|
|
617
|
+
table=None, theme='tile'):
|
|
618
|
+
"""단일 HTML 문자열을 만든다.
|
|
619
|
+
|
|
620
|
+
구조는 한 단계만 쓴다: 제목 바로 아래 본문. 제목 위에 얹는 눈썹(작은 대문자 라벨)이나
|
|
621
|
+
제목-부제-본문 3단 반복은 쓰지 않는다. popups: [{id, title, body, svg, aside?}], cards: [{title, items[]}]
|
|
622
|
+
table: {title, head: [...], rows: [[...], ...]} — "누가 무엇을 맡나" 같은 작은 표 하나 (칸은 HTML 허용). 긴 산문 대신 쓴다.
|
|
623
|
+
theme: 'tile' (기본, svg(grid=True) 와 짝) · 'paper' (옛 에디토리얼 스타일)
|
|
624
|
+
"""
|
|
625
|
+
n = 2
|
|
626
|
+
table_block = ''
|
|
627
|
+
if table:
|
|
628
|
+
th = ''.join(f'<th>{esc(h)}</th>' for h in table.get('head', []))
|
|
629
|
+
trs = ''.join('<tr>' + ''.join(f'<td>{c}</td>' for c in r) + '</tr>' for r in table['rows'])
|
|
630
|
+
table_block = (f'\n <div class="section"><h2><span class="num">{n}.</span>{esc(table["title"])}</h2>'
|
|
631
|
+
f'<table class="roles"><thead><tr>{th}</tr></thead><tbody>{trs}</tbody></table></div>\n')
|
|
632
|
+
n += 1
|
|
633
|
+
cards_block = ''
|
|
634
|
+
if cards:
|
|
635
|
+
head = f'<h2><span class="num">{n}.</span>{esc(cards_h2)}</h2>' if cards_h2 else ''
|
|
636
|
+
lead = f'<p>{cards_body}</p>' if cards_body else ''
|
|
637
|
+
cards_block = (f'\n <div class="section">{head}{lead}'
|
|
638
|
+
f'<div class="cards">{"".join(card_html(c) for c in cards)}</div></div>\n')
|
|
639
|
+
hint_html = f'<p class="hint">{hint}</p>' if hint else ''
|
|
640
|
+
return f'''<!DOCTYPE html>
|
|
641
|
+
<html lang="{lang}">
|
|
642
|
+
<head>
|
|
643
|
+
<meta charset="UTF-8">
|
|
644
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
645
|
+
<title>{esc(title)}</title>
|
|
646
|
+
{FONT_LINK}
|
|
647
|
+
{CSS}
|
|
648
|
+
{TILE_CSS if theme == 'tile' else ''}
|
|
649
|
+
</head>
|
|
650
|
+
<body>
|
|
651
|
+
<div class="container">
|
|
652
|
+
<div class="header">
|
|
653
|
+
<h1>{esc(h1)}</h1>
|
|
654
|
+
<p class="meta">{meta}</p>
|
|
655
|
+
{_block(intro, 'intro')}
|
|
656
|
+
</div>
|
|
657
|
+
|
|
658
|
+
<div class="section" id="overview">
|
|
659
|
+
<h2><span class="num">1.</span>{esc(overview_h2)}</h2>
|
|
660
|
+
{_block(overview_body, 'ovbody')}
|
|
661
|
+
<div class="diagram-container">{overview_svg}</div>
|
|
662
|
+
{hint_html}
|
|
663
|
+
</div>
|
|
664
|
+
|
|
665
|
+
{"".join(popup_html(p) for p in popups)}
|
|
666
|
+
{table_block}{cards_block}
|
|
667
|
+
<div class="footer">
|
|
668
|
+
<span>{esc(footer_left)}</span>
|
|
669
|
+
<span>{esc(footer_right)}</span>
|
|
670
|
+
</div>
|
|
671
|
+
</div>
|
|
672
|
+
{SCRIPT}
|
|
673
|
+
</body>
|
|
674
|
+
</html>
|
|
675
|
+
'''
|
|
676
|
+
|
|
677
|
+
def link(href, inner):
|
|
678
|
+
"""노드 · 타일을 팝업 링크로 감싼다 (hover 1.1배 확대 + 테두리 강조는 CSS .node-link 가 담당)."""
|
|
679
|
+
return f'<a href="{href}" class="node-link">{inner}</a>'
|
|
680
|
+
|
|
681
|
+
def report_warnings():
|
|
682
|
+
for w in WARN: print('WARN', w)
|