Pointf5ive commited on
Commit
2dbd364
Β·
verified Β·
1 Parent(s): aa7e2c2

Make sidebar Codex Extractor open Codex tab

Browse files
Files changed (1) hide show
  1. app.py +53 -2
app.py CHANGED
@@ -98,6 +98,10 @@ footer { display: none !important; }
98
  border-color: #d99e1b !important;
99
  }
100
 
 
 
 
 
101
  #hidden-export, #hidden-status {
102
  max-width: 1180px;
103
  margin: 0 auto 18px auto;
@@ -255,6 +259,53 @@ footer { display: none !important; }
255
  }
256
  """
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
  REVISION_ACTIONS = {
260
  "Clarity": "Simplify the line and sharpen the subject/action.",
@@ -807,7 +858,7 @@ def dashboard_html(path: Path, notice: str = "") -> str:
807
  <div class="nav-item">β–₯ TOTEM Analytics</div>
808
  <div class="nav-item">☷ Revision Queue</div>
809
  <div class="nav-item">⬑ Risk Clusters</div>
810
- <div class="nav-item">β—ˆ Codex Extractor</div>
811
  <div class="nav-item">⇩ Export</div>
812
  <div class="sidebar-foot">Knowledge. Structure.<br>Story. Performance.</div>
813
  </aside>
@@ -1124,7 +1175,7 @@ def single_score(active_path, sequence, stanza_id, draft_pass, clarity, rhythm,
1124
 
1125
  # ── GRADIO INTERFACE ──────────────────────────────────────────────────────────
1126
 
1127
- with gr.Blocks(title="TOTEM Studio", css=CSS) as demo:
1128
  active_path = gr.State(str(DEFAULT_WORKBOOK))
1129
  log_state = gr.State(pd.DataFrame(columns=LOG_COLUMNS))
1130
 
 
98
  border-color: #d99e1b !important;
99
  }
100
 
101
+ .nav-item[role="button"] {
102
+ cursor: pointer;
103
+ }
104
+
105
  #hidden-export, #hidden-status {
106
  max-width: 1180px;
107
  margin: 0 auto 18px auto;
 
259
  }
260
  """
261
 
262
+ HEAD = """
263
+ <script>
264
+ (() => {
265
+ const switchToCodexTab = () => {
266
+ const tabs = Array.from(document.querySelectorAll('[role="tab"]'));
267
+ if (!tabs.length) return false;
268
+ const target = tabs.find((tab) => /codex extractor/i.test((tab.textContent || "").trim()));
269
+ if (target) {
270
+ target.click();
271
+ return true;
272
+ }
273
+ if (tabs.length > 1) {
274
+ tabs[1].click();
275
+ return true;
276
+ }
277
+ return false;
278
+ };
279
+
280
+ const bindSidebarCodexLinks = () => {
281
+ document.querySelectorAll('.js-open-codex').forEach((el) => {
282
+ if (el.dataset.boundCodexNav === "1") return;
283
+ el.dataset.boundCodexNav = "1";
284
+ el.addEventListener('click', (e) => {
285
+ e.preventDefault();
286
+ switchToCodexTab();
287
+ });
288
+ el.addEventListener('keydown', (e) => {
289
+ if (e.key === 'Enter' || e.key === ' ') {
290
+ e.preventDefault();
291
+ switchToCodexTab();
292
+ }
293
+ });
294
+ });
295
+ };
296
+
297
+ const observer = new MutationObserver(() => bindSidebarCodexLinks());
298
+ observer.observe(document.documentElement, { childList: true, subtree: true });
299
+
300
+ if (document.readyState === 'loading') {
301
+ document.addEventListener('DOMContentLoaded', bindSidebarCodexLinks);
302
+ } else {
303
+ bindSidebarCodexLinks();
304
+ }
305
+ })();
306
+ </script>
307
+ """
308
+
309
 
310
  REVISION_ACTIONS = {
311
  "Clarity": "Simplify the line and sharpen the subject/action.",
 
858
  <div class="nav-item">β–₯ TOTEM Analytics</div>
859
  <div class="nav-item">☷ Revision Queue</div>
860
  <div class="nav-item">⬑ Risk Clusters</div>
861
+ <div class="nav-item js-open-codex" role="button" tabindex="0" aria-label="Open Codex Extractor tab">β—ˆ Codex Extractor</div>
862
  <div class="nav-item">⇩ Export</div>
863
  <div class="sidebar-foot">Knowledge. Structure.<br>Story. Performance.</div>
864
  </aside>
 
1175
 
1176
  # ── GRADIO INTERFACE ──────────────────────────────────────────────────────────
1177
 
1178
+ with gr.Blocks(title="TOTEM Studio", css=CSS, head=HEAD) as demo:
1179
  active_path = gr.State(str(DEFAULT_WORKBOOK))
1180
  log_state = gr.State(pd.DataFrame(columns=LOG_COLUMNS))
1181