Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -54,7 +54,7 @@ def save_theme_to_dataset(xml_file):
|
|
| 54 |
return f"❌ Error saving theme to dataset: {e}"
|
| 55 |
|
| 56 |
|
| 57 |
-
def generate_blogger_html(app_query, custom_link, mod_features, theme_color, telegram_link, custom_size, custom_date):
|
| 58 |
"""Scrapes Google Play and generates the base SEO-optimized Blogger HTML."""
|
| 59 |
try:
|
| 60 |
search_results = search(app_query, lang='en', country='us')
|
|
@@ -148,6 +148,24 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 148 |
schema_script = f'<script type="application/ld+json">\n[{json.dumps(schema_app)}, {json.dumps(schema_faq)}, {json.dumps(schema_sysreq)}]\n</script>'
|
| 149 |
|
| 150 |
# Final Base HTML Template Construction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
html_template = f"""
|
| 152 |
{schema_script}
|
| 153 |
|
|
@@ -195,6 +213,10 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 195 |
<a href="{telegram_link}" target="_blank" style="display: inline-block; background: #0088cc; color: white; padding: 8px 20px; border-radius: 25px; text-decoration: none; font-weight: bold; font-size: 0.95rem; transition: 0.2s; margin-top: 10px;">✈️ Telegram</a>
|
| 196 |
</div>
|
| 197 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
<h2 style="border-left: 5px solid #38bdf8; padding-left: 12px; margin-bottom: 20px; font-size: 1.4rem;">App Information</h2>
|
| 199 |
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-bottom: 35px; background: rgba(255,255,255,0.02); padding: 20px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); box-shadow: inset 0 0 15px rgba(0,0,0,0.3);">
|
| 200 |
<div style="background: rgba(255,255,255,0.03); padding: 15px; border-radius: 10px;"><span style="display: block; font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; margin-bottom: 5px;">Developer</span><strong style="font-size: 1.05rem;">{developer}</strong></div>
|
|
@@ -374,7 +396,10 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 374 |
xml_theme_input = gr.File(label="Upload website_theme.xml")
|
| 375 |
save_theme_btn = gr.Button("Save Theme to Dataset")
|
| 376 |
theme_status_out = gr.Textbox(label="Theme Status", interactive=False)
|
| 377 |
-
|
|
|
|
|
|
|
|
|
|
| 378 |
with gr.Accordion("Advanced SEO Settings", open=False):
|
| 379 |
theme_color = gr.ColorPicker(label="Fallback Accent Color", value="#3b82f6")
|
| 380 |
telegram_link = gr.Textbox(label="Your Telegram Channel Link", value="https://t.me/lexicalspace")
|
|
@@ -432,12 +457,12 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 432 |
else:
|
| 433 |
return state, gr.update(visible=True), gr.update(visible=False), gr.update(value="❌ Incorrect password.", visible=True)
|
| 434 |
|
| 435 |
-
def secure_generate(app_query, custom_link, mod_features, t_color, t_link, c_size, c_date, state):
|
| 436 |
if not state.get("logged_in") or (time.time() - state.get("login_time", 0) > 1800):
|
| 437 |
state["logged_in"] = False
|
| 438 |
return ("Session expired.", "Session expired.", "0", "0", gr.update(visible=True), gr.update(visible=False), state, gr.update(visible=False))
|
| 439 |
|
| 440 |
-
code, preview, words, keywords = generate_blogger_html(app_query, custom_link, mod_features, t_color, t_link, c_size, c_date)
|
| 441 |
|
| 442 |
if os.path.exists("latest_draft.txt") and not code.startswith("Error"):
|
| 443 |
file_update = gr.update(value="latest_draft.txt", visible=True)
|
|
@@ -461,8 +486,7 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 461 |
|
| 462 |
generate_btn.click(
|
| 463 |
fn=secure_generate,
|
| 464 |
-
inputs=[app_input, link_input, features_input, theme_color, telegram_link, custom_size, custom_date, session_state],
|
| 465 |
-
outputs=[html_output, preview_output, word_count_out, kw_density_out, login_screen, main_app, session_state, file_download]
|
| 466 |
)
|
| 467 |
|
| 468 |
# AI OpenRouter Enhance binding
|
|
|
|
| 54 |
return f"❌ Error saving theme to dataset: {e}"
|
| 55 |
|
| 56 |
|
| 57 |
+
def generate_blogger_html(app_query, custom_link, mod_features, theme_color, telegram_link, custom_size, custom_date, req_name, req_link):
|
| 58 |
"""Scrapes Google Play and generates the base SEO-optimized Blogger HTML."""
|
| 59 |
try:
|
| 60 |
search_results = search(app_query, lang='en', country='us')
|
|
|
|
| 148 |
schema_script = f'<script type="application/ld+json">\n[{json.dumps(schema_app)}, {json.dumps(schema_faq)}, {json.dumps(schema_sysreq)}]\n</script>'
|
| 149 |
|
| 150 |
# Final Base HTML Template Construction
|
| 151 |
+
# Required App HTML Generation
|
| 152 |
+
required_app_html = ""
|
| 153 |
+
if req_name and req_link:
|
| 154 |
+
required_app_html = f"""
|
| 155 |
+
<h2 style="border-left: 5px solid #ef4444; padding-left: 12px; margin-bottom: 20px; font-size: 1.4rem;">Additional Requirements</h2>
|
| 156 |
+
<div style="background: rgba(239, 68, 68, 0.05); border: 1px solid rgba(239, 68, 68, 0.2); padding: 20px; border-radius: 16px; display: flex; align-items: center; gap: 15px; margin-bottom: 35px; flex-wrap: wrap;">
|
| 157 |
+
<div style="width: 50px; height: 50px; background: rgba(239, 68, 68, 0.1); border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #ef4444; font-size: 1.5rem; flex-shrink: 0;">
|
| 158 |
+
<i class="fa-solid fa-puzzle-piece"></i>
|
| 159 |
+
</div>
|
| 160 |
+
<div style="flex: 1; min-width: 200px;">
|
| 161 |
+
<h3 style="margin: 0 0 5px 0; font-size: 1.1rem; color: #fff;">{req_name.strip()}</h3>
|
| 162 |
+
<p style="margin: 0; font-size: 0.85rem; color: #94a3b8;">This application requires a companion app to function properly.</p>
|
| 163 |
+
</div>
|
| 164 |
+
<a href="{req_link.strip()}" target="_blank" rel="nofollow noopener" style="background: #ef4444; color: #fff; padding: 10px 20px; border-radius: 50px; text-decoration: none; font-weight: 700; font-size: 0.9rem; transition: 0.3s; white-space: nowrap; box-shadow: 0 5px 15px rgba(239, 68, 68, 0.3);">
|
| 165 |
+
Get Companion <i class="fa-solid fa-download" style="margin-left: 5px;"></i>
|
| 166 |
+
</a>
|
| 167 |
+
</div>
|
| 168 |
+
"""
|
| 169 |
html_template = f"""
|
| 170 |
{schema_script}
|
| 171 |
|
|
|
|
| 213 |
<a href="{telegram_link}" target="_blank" style="display: inline-block; background: #0088cc; color: white; padding: 8px 20px; border-radius: 25px; text-decoration: none; font-weight: bold; font-size: 0.95rem; transition: 0.2s; margin-top: 10px;">✈️ Telegram</a>
|
| 214 |
</div>
|
| 215 |
|
| 216 |
+
{required_app_html}
|
| 217 |
+
|
| 218 |
+
<h2 style="border-left: 5px solid #38bdf8; padding-left: 12px; margin-bottom: 20px; font-size: 1.4rem;">App Information</h2>
|
| 219 |
+
|
| 220 |
<h2 style="border-left: 5px solid #38bdf8; padding-left: 12px; margin-bottom: 20px; font-size: 1.4rem;">App Information</h2>
|
| 221 |
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-bottom: 35px; background: rgba(255,255,255,0.02); padding: 20px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); box-shadow: inset 0 0 15px rgba(0,0,0,0.3);">
|
| 222 |
<div style="background: rgba(255,255,255,0.03); padding: 15px; border-radius: 10px;"><span style="display: block; font-size: 0.8rem; color: #94a3b8; text-transform: uppercase; margin-bottom: 5px;">Developer</span><strong style="font-size: 1.05rem;">{developer}</strong></div>
|
|
|
|
| 396 |
xml_theme_input = gr.File(label="Upload website_theme.xml")
|
| 397 |
save_theme_btn = gr.Button("Save Theme to Dataset")
|
| 398 |
theme_status_out = gr.Textbox(label="Theme Status", interactive=False)
|
| 399 |
+
with gr.Accordion("Companion/Required App (Optional)", open=False):
|
| 400 |
+
req_app_name = gr.Textbox(label="Companion App Name (e.g., MicroG)", placeholder="Leave blank if none...")
|
| 401 |
+
req_app_link = gr.Textbox(label="Companion App Download Link", placeholder="https://...")
|
| 402 |
+
|
| 403 |
with gr.Accordion("Advanced SEO Settings", open=False):
|
| 404 |
theme_color = gr.ColorPicker(label="Fallback Accent Color", value="#3b82f6")
|
| 405 |
telegram_link = gr.Textbox(label="Your Telegram Channel Link", value="https://t.me/lexicalspace")
|
|
|
|
| 457 |
else:
|
| 458 |
return state, gr.update(visible=True), gr.update(visible=False), gr.update(value="❌ Incorrect password.", visible=True)
|
| 459 |
|
| 460 |
+
def secure_generate(app_query, custom_link, mod_features, t_color, t_link, c_size, c_date, req_name, req_link, state):
|
| 461 |
if not state.get("logged_in") or (time.time() - state.get("login_time", 0) > 1800):
|
| 462 |
state["logged_in"] = False
|
| 463 |
return ("Session expired.", "Session expired.", "0", "0", gr.update(visible=True), gr.update(visible=False), state, gr.update(visible=False))
|
| 464 |
|
| 465 |
+
code, preview, words, keywords = generate_blogger_html(app_query, custom_link, mod_features, t_color, t_link, c_size, c_date, req_name, req_link)
|
| 466 |
|
| 467 |
if os.path.exists("latest_draft.txt") and not code.startswith("Error"):
|
| 468 |
file_update = gr.update(value="latest_draft.txt", visible=True)
|
|
|
|
| 486 |
|
| 487 |
generate_btn.click(
|
| 488 |
fn=secure_generate,
|
| 489 |
+
inputs=[app_input, link_input, features_input, theme_color, telegram_link, custom_size, custom_date, req_app_name, req_app_link, session_state],
|
|
|
|
| 490 |
)
|
| 491 |
|
| 492 |
# AI OpenRouter Enhance binding
|