Spaces:
Running
Update app.py
Browse filesHere is how the newly configured layout translates into clean code mechanics, mapping perfectly to your orange suggestion markers:
Markers [2] & [3] (The Monolithic Configuration Row): We have packed the Gemini API Key, the Manuscript Name, the Bible Book box, the Chapter/Verse drop-downs, and the Hebrew Input Text String box all into a single, sweeping horizontal control banner right at the top of the interface.
The "Zero-Scroll" Button Relocation: The "Generate", "Clear", and "Copy for Google Docs" buttons have been placed side-by-side inside a compact utility belt directly below your inputs. This ensures that the copy button is immediately available to you without moving your eyes or mouse down the page!
Marker [4] (The Massive Table Theater Canvas): By compressing all your cockpit controls into the top 25% of the viewport, the bottom 75% of your browser window turns into a sprawling preview deck dedicated completely to displaying your table grids!
3 unmodified lines4567789103 unmodified lines1415161718192021222324252617181912 unmodified lines32333445353637383940515253414243444546604748497 unmodified lines5758597460766162786364651 unmodified line6768698670717273744 unmodified lines79808198998283848586104105106107878889901109192939495969791 unmodified lines18919019120919219319419594 unmodified lines2902912923103113122932942952962972983163172993003013023033043053063193203213223233243253263273283293303313073083093103113123133143333343153163173363373383393403183193203213223233243253263273283293303313 unmodified linesimport timeimport json
# --- Shorashim Pro Premium Layout Engine ---# --- Shorashim Pro Ultra-Compact Horizontal Layout Engine ---custom_css = """/* Completely hide technical loading bars & indicators */.subpanel.loading, .generating, div[class*="loading"], .progress-wrap {3 unmodified lines overflow: hidden !important;}
/* Polished Minimalist Progress Window */.progress-container { padding: 12px; text-align: center; border: 1px solid #d4af37; border-radius: 6px; background-color: #111827; margin-bottom: 12px;}
/* White Canvas Table Wrapper for clear document viewing */.white-canvas { display: flex;12 unmodified lines.gradio-container h1, .gradio-container h2, .gradio-container h3 { color: #d4af37 !important; font-weight: 600 !important; margin-top: 0px !important; margin: 0px !important;}.gradio-container p, .gradio-container span { color: #9ca3af !important;}
/* Compact Forms Fix */.form { gap: 8px !important; }
/* Input Fields Customized with Gold Accent Focus Rings */input, textarea, select, .dropdown { border-radius: 6px !important; border: 1px solid #1f2937 !important; background-color: #111827 !important; color: #ffffff !important; padding: 6px 10px !important;}input:focus, textarea:focus, select:focus { border-color: #d4af37 !important;7 unmodified lines border-radius: 6px !important; color: #ffffff !important; font-weight: bold !important; padding: 8px 16px !important; cursor: pointer; transition: opacity 0.2s; height: 42px !important;}button.primary-btn:hover { opacity: 0.9; }
/* Secondary Actions / Clear Button (Dark Slate Accent) */button.secondary-btn {1 unmodified line border: 1px solid #374151 !important; border-radius: 6px !important; color: #e5e7eb !important; padding: 8px 16px !important; cursor: pointer; height: 42px !important;}
/* Google Docs Copy Button (Shorashim Pro Signature Gold) */4 unmodified lines color: #0b0f19 !important; font-weight: 800 !important; font-size: 14px !important; padding: 10px 20px !important; width: 100% !important; cursor: pointer; box-shadow: 0 4px 6px -1px rgba(212, 175, 55, 0.2); height: 42px !important;}
/* Zero-Scroll Scroll Container Attached Safely via Native Column Class Selector */.scroll-viewport { max-height: 68vh !important; overflow-y: auto !important;/* Fixed Table Theater Container Viewport */.theater-viewport { border: 1px solid #1f2937 !important; border-radius: 8px !important; padding: 12px !important; padding: 16px !important; background-color: #0d1321 !important; margin-top: 12px !important; min-height: 45vh !important;}"""
91 unmodified lines english_cell_style = f"font-family: Arial, sans-serif !important; font-size: 14.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: top; line-height: 1.0 !important; {base_cell}" heading_cell_style = f"font-family: 'Times New Roman', serif !important; font-size: 18.6667px !important; color: #000000 !important; text-align: center !important; vertical-align: middle; line-height: 1.0 !important; {base_cell}" html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 15px; border-radius: 6px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">'] html_output = ['<div id="table-payload" class="white-canvas" style="background-color: #ffffff; padding: 15px; border-radius: 8px; display: inline-block; width: 100%; box-sizing: border-box; text-align: center;">'] table_chunks = calculate_clean_chunks(words_data) html_output.append(f'<table style="{table_style}" align="center" cellpadding="5" cellspacing="0">')94 unmodified lines
with gr.Blocks(title="Shorashim Pro Interlinear Workspace") as demo: gr.HTML( "<div style='background: linear-gradient(135deg, #111827 0%, #0b0f19 100%); padding: 12px; border-radius: 8px; margin-bottom: 12px; text-align: center; border: 1px solid #d4af37;'>" "<h1 style='margin: 0 0 2px 0; font-size: 22px; font-weight: 700; color: #d4af37;'>π Shorashim Pro Workspace</h1>" "<p style='margin: 0; font-size: 12px; color: #9ca3af;'>Zero-Scroll Balanced 7-Inch Monolithic Document Publisher</p>" "<div style='background: linear-gradient(135deg, #111827 0%, #0b0f19 100%); padding: 10px; border-radius: 6px; margin-bottom: 10px; text-align: center; border: 1px solid #d4af37;'>" "<h1 style='margin: 0 0 2px 0; font-size: 20px; font-weight: 700; color: #d4af37;'>π Shorashim Pro Workspace</h1>" "<p style='margin: 0; font-size: 12px; color: #9ca3af;'>Convert raw Hebrew text strings into BEI style interlinear tables</p>" "</div>" ) # 2-Column Responsive Workspace Split Grid FIXED with gr.Row(equal_height=False): with gr.Accordion("π API Key Setup Instructions", open=False): gr.Markdown( "1. Visit [Google AI Studio](https://aistudio.google.com/).\n" "2. Click the **Get API Key** button on the left workspace menu.\n" "3. Click **Create API Key** (or select your existing default placeholder string).\n" "4. Copy your generated string key, paste it into the **Gemini API Key** input element below, and the app will cache it safely!" ) # --- LEFT COLUMN: Input Panel Control Deck (35% Space) --- with gr.Column(scale=35): gr.Markdown("### π οΈ Configuration Panel") api_key_input = gr.Textbox(label="π Gemini API Key", type="password", placeholder="Key securely loaded...") manuscript_input = gr.Textbox(label="π Manuscript Reference", value="Marseilles MS-24") book_input = gr.Textbox(label="π Bible Book", value="Luke") with gr.Row(): chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Chapter", value="11", allow_custom_value=True) verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Verse", value="49", allow_custom_value=True) text_string_input = gr.Textbox(label="π Hebrew Input Text String", placeholder="Paste text line segments here...", lines=3) # --- MONOLITHIC COCKPIT INPUT ROW --- with gr.Row(): api_key_input = gr.Textbox(label="π Gemini API Key", type="password", placeholder="Key safely saved...", scale=2) manuscript_input = gr.Textbox(label="π Manuscript", value="Marseilles MS-24", scale=2) book_input = gr.Textbox(label="π Book", value="Luke", scale=2) with gr.Column(scale=2): with gr.Row(): submit_btn = gr.Button("π Generate", elem_classes=["primary-btn"]) clear_btn = gr.Button("π§Ή Clear", elem_classes=["secondary-btn"]) chapter_input = gr.Dropdown(choices=[str(x) for x in range(1, 151)], label="Ch.", value="11", allow_custom_value=True) verse_input = gr.Dropdown(choices=[str(x) for x in range(1, 177)], label="Ver.", value="49", allow_custom_value=True) # --- RIGHT COLUMN: Document Output Pavilion Viewport (65% Space) FIXED NATIVE LAYOUT --- with gr.Column(scale=65, elem_classes=["scroll-viewport"]): copy_btn = gr.Button("π Copy for Google Docs", elem_classes=["gold-copy-btn"], visible=False) gr.HTML("<div style='margin-bottom: 8px;'></div>") output_html = gr.HTML(label="Shorashim Document Frame Canvas") text_string_input = gr.Textbox(label="π Hebrew Verses Input String", placeholder="Paste line segments...", scale=4)
# --- ZERO-SCROLL CONTROL BELT HUB --- with gr.Row(): submit_btn = gr.Button("π Generate Canvas", elem_classes=["primary-btn"], scale=3) clear_btn = gr.Button("π§Ή Clear Input", elem_classes=["secondary-btn"], scale=2) copy_btn = gr.Button("π Copy for Google Docs", elem_classes=["gold-copy-btn"], visible=False, scale=5)
# --- FULL WIDTH THEATER CANVAS VIEWPORT --- with gr.Column(elem_classes=["theater-viewport"]): output_html = gr.HTML(label="Shorashim Frame Canvas")
demo.load(fn=None, inputs=None, outputs=None, js=sticky_session_and_layout_js)