-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathARCHITECTURE.html
More file actions
206 lines (193 loc) ยท 8.28 KB
/
Copy pathARCHITECTURE.html
File metadata and controls
206 lines (193 loc) ยท 8.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sidecar โ ์ํคํ
์ฒ</title>
<!--
Self-contained viewer for ARCHITECTURE.json (the SSOT). Zero dependencies.
Renders the tree as a column grid: `columns[]` defines the columns; the column
flagged `tree:true` draws the tree branches, the rest align as separate columns.
Edit the JSON, reload โ this file holds no data.
Local: `python3 -m http.server` then open http://localhost:8000/ARCHITECTURE.html
(file:// blocks fetch; a drag&drop fallback is offered.)
-->
<style>
:root {
--bg:#0d1117; --panel:#161b22; --line:#30363d; --fg:#e6edf3;
--dim:#8b949e; --accent:#58a6ff; --leaf:#7ee787; --head:#1f2630;
}
@media (prefers-color-scheme: light) {
:root { --bg:#fff; --panel:#f6f8fa; --line:#d0d7de; --fg:#1f2328; --dim:#656d76; --accent:#0969da; --leaf:#1a7f37; --head:#eaeef2; }
}
* { box-sizing: border-box; }
body { margin:0; background:var(--bg); color:var(--fg);
font:13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
header { position:sticky; top:0; z-index:5; background:var(--panel);
border-bottom:1px solid var(--line); padding:12px 18px; }
h1 { margin:0 0 3px; font-size:16px; }
.summary { color:var(--dim); font-size:12px; max-width:80ch; }
.bar { margin-top:9px; display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
input[type=search]{ flex:1 1 220px; min-width:160px; background:var(--bg); color:var(--fg);
border:1px solid var(--line); border-radius:6px; padding:6px 10px; font:inherit; }
button{ background:var(--bg); color:var(--fg); border:1px solid var(--line);
border-radius:6px; padding:6px 12px; font:inherit; cursor:pointer; }
button:hover{ border-color:var(--accent); color:var(--accent); }
main{ padding:0 18px 60px; }
.grid{ display:grid; width:max-content; min-width:100%; }
.cell{ padding:3px 14px 3px 0; border-bottom:1px solid var(--line); white-space:pre; }
.cell.wrap{ white-space:normal; max-width:60ch; }
.head{ position:sticky; top:84px; background:var(--head); font-weight:700;
border-bottom:2px solid var(--line); z-index:4; padding:6px 14px 6px 0; }
.tree{ white-space:pre; }
.branch{ color:var(--dim); }
.tw{ color:var(--dim); cursor:pointer; }
.nm{ font-weight:600; cursor:pointer; }
.nm.leaf{ color:var(--leaf); font-weight:500; }
.colrole{ color:var(--fg); }
.colsub{ color:var(--dim); }
.colmuted{ color:var(--dim); }
.rowhover:hover{ background:var(--panel); }
.hidden{ display:none; }
mark{ background:#bb800966; color:inherit; border-radius:2px; }
#err{ color:#f85149; padding:20px; max-width:72ch; }
#err code{ background:var(--panel); padding:1px 5px; border-radius:4px; }
#drop{ margin-top:10px; padding:14px; border:1px dashed var(--line); border-radius:8px; color:var(--dim); }
</style>
</head>
<body>
<header>
<h1 id="title">sidecar โ ์ํคํ
์ฒ</h1>
<div class="summary" id="summary"></div>
<div class="bar">
<input type="search" id="q" placeholder="๊ฒ์ (๋ชจ๋ ์ปฌ๋ผ)โฆ" autocomplete="off">
<button id="expand">์ ์ฒด ํผ์นจ</button>
<button id="collapse">์ ์ฒด ์ ๊ธฐ</button>
<span class="colmuted" id="meta"></span>
</div>
</header>
<main>
<div id="tree"></div>
<div id="err" class="hidden"></div>
</main>
<script>
const SRC = "ARCHITECTURE.json";
let DOC, COLS, TREEKEY, rows = [], collapsed = new Set();
function el(t, c, x){ const e=document.createElement(t); if(c)e.className=c; if(x!=null)e.textContent=x; return e; }
// Flatten the tree into rows, computing each node's `tree` branch prefix.
function flatten(node, prefix, isLast, depth, parentId, idRef){
const id = idRef.n++;
const connector = depth === 0 ? "" : (isLast ? "โโ " : "โโ ");
const kids = node.children || [];
rows.push({ id, depth, parentId, node, branch: prefix + connector, hasKids: kids.length>0 });
const childPrefix = depth === 0 ? "" : prefix + (isLast ? " " : "โ ");
kids.forEach((c,i)=> flatten(c, childPrefix, i===kids.length-1, depth+1, id, idRef));
}
function colClass(key){
if (key === COLS[1]?.key) return "colrole";
if (key === COLS[2]?.key) return "colsub";
return "colmuted";
}
function build(doc){
DOC = doc;
COLS = doc.columns || [{key:"name",tree:true},{key:"role"}];
TREEKEY = (COLS.find(c=>c.tree) || COLS[0]).key;
document.getElementById("title").textContent = doc.title || "์ํคํ
์ฒ";
document.getElementById("summary").textContent = doc.summary || "";
document.getElementById("meta").textContent = "schema "+(doc.schemaVersion||"?")+" ยท SSOT "+SRC;
rows = [];
flatten(doc.tree || doc.node, "", true, 0, -1, {n:0});
const grid = el("div","grid");
grid.style.gridTemplateColumns = "max-content " + COLS.slice(1).map(()=>"max-content").join(" ");
// header row
COLS.forEach(c => grid.appendChild(el("div","cell head", c.label || c.key)));
// data rows
rows.forEach(r => {
// tree column
const left = el("div","cell tree rowhover");
left.dataset.id = r.id;
const br = el("span","branch", r.branch);
left.appendChild(br);
if (r.hasKids){
const tw = el("span","tw", collapsed.has(r.id) ? "โธ " : "โพ ");
tw.onclick = () => { collapsed.has(r.id) ? collapsed.delete(r.id) : collapsed.add(r.id); refresh(); };
left.appendChild(tw);
}
const nm = el("span","nm"+(r.hasKids?"":" leaf"), r.node[TREEKEY] || "");
left.appendChild(nm);
grid.appendChild(left);
// other columns
COLS.slice(1).forEach(c => {
const v = r.node[c.key] || "";
const cell = el("div","cell wrap "+colClass(c.key)+" rowhover", v);
cell.dataset.id = r.id;
grid.appendChild(cell);
});
});
const tree = document.getElementById("tree");
tree.textContent = "";
tree.appendChild(grid);
refresh();
}
// A row is hidden if any ancestor is collapsed.
function isVisible(r){
let p = r.parentId;
while (p !== -1){
if (collapsed.has(p)) return false;
p = rows[p].parentId;
}
return true;
}
function refresh(filterTerm){
const q = (filterTerm||"").trim().toLowerCase();
// recompute toggle glyphs
document.querySelectorAll(".grid .tree .tw").forEach(tw=>{
const id = +tw.parentElement.dataset.id;
tw.textContent = collapsed.has(id) ? "โธ " : "โพ ";
});
let matchIds = null;
if (q){
matchIds = new Set();
rows.forEach(r=>{
const hay = COLS.map(c=> (r.node[c.key]||"")).join(" ").toLowerCase();
if (hay.includes(q)){ let id=r.id; while(id!==-1){ matchIds.add(id); id=rows[id].parentId; } }
});
}
rows.forEach(r=>{
const show = (q ? matchIds.has(r.id) : isVisible(r));
document.querySelectorAll('.grid .cell[data-id="'+r.id+'"]').forEach(c=>{
c.classList.toggle("hidden", !show);
});
});
}
function setAll(collapse){
collapsed = new Set();
if (collapse) rows.forEach(r=>{ if(r.hasKids) collapsed.add(r.id); });
refresh();
}
function showError(msg, allowDrop){
const err = document.getElementById("err");
err.classList.remove("hidden"); err.innerHTML = msg;
if (allowDrop){
const drop = el("div"); drop.id="drop";
drop.textContent = "๋๋ ์ฌ๊ธฐ๋ก ARCHITECTURE.json ํ์ผ์ ๋๋๊ทธ&๋๋กญ ํ์ธ์.";
err.appendChild(drop);
drop.ondragover = e=>{ e.preventDefault(); drop.style.borderColor="var(--accent)"; };
drop.ondragleave = ()=> drop.style.borderColor="var(--line)";
drop.ondrop = e=>{ e.preventDefault(); const f=e.dataTransfer.files[0]; if(!f)return;
const rd=new FileReader(); rd.onload=()=>{ try{ err.classList.add("hidden"); build(JSON.parse(rd.result)); }
catch(x){ showError("JSON ํ์ฑ ์คํจ: "+x.message,false); } }; rd.readAsText(f); };
}
}
fetch(SRC).then(r=>{ if(!r.ok) throw new Error("HTTP "+r.status); return r.json(); })
.then(build)
.catch(e=> showError(
"<b>"+SRC+" ๋ฅผ ๋ถ๋ฌ์ค์ง ๋ชปํ์ต๋๋ค.</b> ("+e.message+")<br><br>"+
"<code>file://</code> ๋ก ์ง์ ์ด๋ฉด ๋ณด์์ fetch๊ฐ ๋งํ๋๋ค. ๊ฐ์ ํด๋์์<br>"+
"<code>python3 -m http.server</code> ํ <code>http://localhost:8000/ARCHITECTURE.html</code> ๋ก ์ฌ์ธ์.", true));
document.getElementById("q").addEventListener("input", e=> refresh(e.target.value));
document.getElementById("expand").onclick = ()=> setAll(false);
document.getElementById("collapse").onclick = ()=> setAll(true);
</script>
</body>
</html>