Upload app.py
Browse files979 unmodified lines98098198298398498524 unmodified lines10101011101210131014101510161 unmodified line101810191020102110221023102410251026104 unmodified lines11311132113311341135113654 unmodified lines1191119211931194119511961197979 unmodified lines# ββ JS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββJS = """function _findField(elemId) {let el = document.querySelector('#' + elemId + ' textarea, #' + elemId + ' input');if (el) return el;24 unmodified linesif (!_gradioSet(elemId, v)) setTimeout(() => _gradioSet(elemId, v), 120);}window.selectWord = function(word) {document.querySelectorAll('.word').forEach(el => {el.style.outline = '';if (el.textContent.trim() === word) el.style.outline = '2px solid #2980b9';1 unmodified line_send('word-selector', word);};window.navigateToFolio = function(folio) { _send('folio-nav-target', folio); };window.appAction = function(action, arg) { _send('action-bridge', action + '|' + arg); };window.collocateFilter = function(word) { _send('action-bridge', 'filter|' + word); };"""# ββ CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ104 unmodified lines.kwic-nb { font-family: monospace; font-size: 11px; color: #aaa; padding: 2px 4px 2px 24px; }.nb-lbl { font-family: system-ui, sans-serif; font-size: 9px; text-transform: uppercase; margin-right: 8px; }.js-bridge, #word-selector, #folio-nav-target, #action-bridge {position: absolute !important; width: 1px !important; height: 1px !important;padding: 0 !important; margin: -1px !important; border: 0 !important;54 unmodified lineslabel="Concordance: line position")nav_html = gr.HTML()folio_stats_html = gr.HTML()detail_html = gr.HTML()corpus_btn = gr.Button("Corpus statistics", size="sm")corpus_html = gr.HTML(build_corpus_stats(_default_view), visible=False)table_btn = gr.Button("Frequency table", size="sm")979 unmodified lines98098198298398498598698798898999099199299399424 unmodified lines10191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521 unmodified line105410551056105710581059106010611062106310641065104 unmodified lines117011711172117311741175117611771178117911801181118211831184118511861187118811891190119154 unmodified lines1246124712481249125012511252979 unmodified lines# ββ JS ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββJS = """// The manuscript styling is designed for light mode; Gradio's dark theme washes it out.(function () {const u = new URL(window.location.href);if (u.searchParams.get('__theme') !== 'light') {u.searchParams.set('__theme', 'light');window.location.replace(u.toString());}})();function _findField(elemId) {let el = document.querySelector('#' + elemId + ' textarea, #' + elemId + ' input');if (el) return el;24 unmodified linesif (!_gradioSet(elemId, v)) setTimeout(() => _gradioSet(elemId, v), 120);}// On a phone the page and the sidebar are stacked, so whatever a tap changes can be// off-screen. Scroll to it once Gradio has re-rendered it.function _narrow() { return window.matchMedia('(max-width: 900px)').matches; }function _revealAfterUpdate(elemId) {if (!_narrow()) return;const el = document.getElementById(elemId);if (!el) return;// Wait until the re-render has settled, so the scroll lands where the content ends up.let timer = null;const obs = new MutationObserver(() => {clearTimeout(timer);timer = setTimeout(() => {obs.disconnect();el.scrollIntoView({ behavior: 'smooth', block: 'start' });}, 300);});obs.observe(el, { childList: true, subtree: true, characterData: true });setTimeout(() => obs.disconnect(), 8000);}document.addEventListener('click', (e) => {const b = e.target.closest('button');if (!b) return;const t = b.textContent.trim();if (['Page', 'Collocates', 'Concordance', 'Prev', 'Next', 'Go'].includes(t)) _revealAfterUpdate('folio-col');}, true);window.selectWord = function(word) {_revealAfterUpdate('detail-panel');document.querySelectorAll('.word').forEach(el => {el.style.outline = '';if (el.textContent.trim() === word) el.style.outline = '2px solid #2980b9';1 unmodified line_send('word-selector', word);};window.navigateToFolio = function(folio) { _revealAfterUpdate('folio-col'); _send('folio-nav-target', folio); };window.appAction = function(action, arg) {if (action === 'mode' || action === 'kpage' || action === 'cpage') _revealAfterUpdate('folio-col');_send('action-bridge', action + '|' + arg);};window.collocateFilter = function(word) { _revealAfterUpdate('folio-col'); _send('action-bridge', 'filter|' + word); };"""# ββ CSS βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ104 unmodified lines.kwic-nb { font-family: monospace; font-size: 11px; color: #aaa; padding: 2px 4px 2px 24px; }.nb-lbl { font-family: system-ui, sans-serif; font-size: 9px; text-transform: uppercase; margin-right: 8px; }/* Phones and narrow windows: stack the page above the sidebar and let the page scroll. */@media (max-width: 900px) {html, body { height: auto !important; overflow: auto !important; }#main-row { position: static !important; flex-direction: column !important;overflow: visible !important; height: auto !important; }#folio-col, #sidebar-col { min-width: 0 !important; width: 100% !important; max-width: 100% !important;height: auto !important; overflow: visible !important; flex: none !important; }.ms-scroll { height: 62vh; height: 62dvh; padding: 20px 16px; border-right: none; border-bottom: 1px solid #ddd; }.ms-folio-id { margin-bottom: 12px; }.word { font-size: 20px; }#sidebar-col { border-left: none; }.sidebar-pad { padding: 12px 16px 48px; }.kwic summary, .kwic-head { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) 64px; }.kwic summary .km:nth-child(n+5), .kwic-head .km:nth-child(n+5) { display: none; }}.js-bridge, #word-selector, #folio-nav-target, #action-bridge {position: absolute !important; width: 1px !important; height: 1px !important;padding: 0 !important; margin: -1px !important; border: 0 !important;54 unmodified lineslabel="Concordance: line position")nav_html = gr.HTML()folio_stats_html = gr.HTML()detail_html = gr.HTML(elem_id="detail-panel")corpus_btn = gr.Button("Corpus statistics", size="sm")corpus_html = gr.HTML(build_corpus_stats(_default_view), visible=False)table_btn = gr.Button("Frequency table", size="sm")
app.py+59-4