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, 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')
|
|
@@ -149,6 +149,7 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 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"""
|
|
@@ -166,6 +167,13 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 166 |
</a>
|
| 167 |
</div>
|
| 168 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
html_template = f"""
|
| 170 |
{schema_script}
|
| 171 |
|
|
@@ -202,7 +210,8 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 202 |
<i class="fa-solid fa-shield-halved" style="color: #10b981;"></i> Links encrypted. VirusTotal checked.
|
| 203 |
</p>
|
| 204 |
|
| 205 |
-
<div style="display: flex; justify-content: center; gap: 20px; margin-top: 20px; font-size: 0.9rem; font-weight: 600;">
|
|
|
|
| 206 |
<a href="mailto:admin@lexicalspace.com?subject=Broken Link Report: {title}" style="color: #ef4444; text-decoration: none; transition: 0.2s;"><i class="fa-solid fa-link-slash"></i> Link not working?</a>
|
| 207 |
<a href="mailto:admin@lexicalspace.com?subject=App Issue Report: {title}" style="color: #f59e0b; text-decoration: none; transition: 0.2s;"><i class="fa-solid fa-flag"></i> Report Issue</a>
|
| 208 |
</div>
|
|
@@ -215,8 +224,6 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 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>
|
|
@@ -245,6 +252,10 @@ def generate_blogger_html(app_query, custom_link, mod_features, theme_color, tel
|
|
| 245 |
</div>
|
| 246 |
</div>
|
| 247 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 248 |
word_count = str(len(html_template.split()))
|
| 249 |
|
| 250 |
keyword_density = str(html_template.lower().count(title.lower()[:10]))
|
|
@@ -399,6 +410,7 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 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")
|
|
@@ -457,12 +469,12 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 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,8 +498,8 @@ with gr.Blocks(title="Lexical Space Internal Tool", theme=gr.themes.Monochrome(p
|
|
| 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 |
-
outputs=[html_output, preview_output, word_count_out, kw_density_out, login_screen, main_app, session_state, file_download]
|
| 491 |
)
|
| 492 |
|
| 493 |
# 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, tutorial_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')
|
|
|
|
| 149 |
|
| 150 |
# Final Base HTML Template Construction
|
| 151 |
# Required App HTML Generation
|
| 152 |
+
|
| 153 |
required_app_html = ""
|
| 154 |
if req_name and req_link:
|
| 155 |
required_app_html = f"""
|
|
|
|
| 167 |
</a>
|
| 168 |
</div>
|
| 169 |
"""
|
| 170 |
+
|
| 171 |
+
# Tutorial Button HTML Generation
|
| 172 |
+
tutorial_html = ""
|
| 173 |
+
if tutorial_link:
|
| 174 |
+
tutorial_html = f'<a href="{tutorial_link.strip()}" target="_blank" style="color: #a855f7; text-decoration: none; transition: 0.2s;"><i class="fa-solid fa-book-open"></i> View Tutorial</a>'
|
| 175 |
+
|
| 176 |
+
# Final Base HTML Template Construction
|
| 177 |
html_template = f"""
|
| 178 |
{schema_script}
|
| 179 |
|
|
|
|
| 210 |
<i class="fa-solid fa-shield-halved" style="color: #10b981;"></i> Links encrypted. VirusTotal checked.
|
| 211 |
</p>
|
| 212 |
|
| 213 |
+
<div style="display: flex; justify-content: center; flex-wrap: wrap; gap: 20px; margin-top: 20px; font-size: 0.9rem; font-weight: 600;">
|
| 214 |
+
{tutorial_html}
|
| 215 |
<a href="mailto:admin@lexicalspace.com?subject=Broken Link Report: {title}" style="color: #ef4444; text-decoration: none; transition: 0.2s;"><i class="fa-solid fa-link-slash"></i> Link not working?</a>
|
| 216 |
<a href="mailto:admin@lexicalspace.com?subject=App Issue Report: {title}" style="color: #f59e0b; text-decoration: none; transition: 0.2s;"><i class="fa-solid fa-flag"></i> Report Issue</a>
|
| 217 |
</div>
|
|
|
|
| 224 |
|
| 225 |
{required_app_html}
|
| 226 |
|
|
|
|
|
|
|
| 227 |
<h2 style="border-left: 5px solid #38bdf8; padding-left: 12px; margin-bottom: 20px; font-size: 1.4rem;">App Information</h2>
|
| 228 |
<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);">
|
| 229 |
<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>
|
|
|
|
| 252 |
</div>
|
| 253 |
</div>
|
| 254 |
"""
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
|
| 259 |
word_count = str(len(html_template.split()))
|
| 260 |
|
| 261 |
keyword_density = str(html_template.lower().count(title.lower()[:10]))
|
|
|
|
| 410 |
with gr.Accordion("Companion/Required App (Optional)", open=False):
|
| 411 |
req_app_name = gr.Textbox(label="Companion App Name (e.g., MicroG)", placeholder="Leave blank if none...")
|
| 412 |
req_app_link = gr.Textbox(label="Companion App Download Link", placeholder="https://...")
|
| 413 |
+
tutorial_link = gr.Textbox(label="Tutorial/Guide Link (YouTube or Blog)", placeholder="https://...")
|
| 414 |
|
| 415 |
with gr.Accordion("Advanced SEO Settings", open=False):
|
| 416 |
theme_color = gr.ColorPicker(label="Fallback Accent Color", value="#3b82f6")
|
|
|
|
| 469 |
else:
|
| 470 |
return state, gr.update(visible=True), gr.update(visible=False), gr.update(value="❌ Incorrect password.", visible=True)
|
| 471 |
|
| 472 |
+
def secure_generate(app_query, custom_link, mod_features, t_color, t_link, c_size, c_date, req_name, req_link, tutorial_link, state):
|
| 473 |
if not state.get("logged_in") or (time.time() - state.get("login_time", 0) > 1800):
|
| 474 |
state["logged_in"] = False
|
| 475 |
return ("Session expired.", "Session expired.", "0", "0", gr.update(visible=True), gr.update(visible=False), state, gr.update(visible=False))
|
| 476 |
|
| 477 |
+
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, tutorial_link)
|
| 478 |
|
| 479 |
if os.path.exists("latest_draft.txt") and not code.startswith("Error"):
|
| 480 |
file_update = gr.update(value="latest_draft.txt", visible=True)
|
|
|
|
| 498 |
|
| 499 |
generate_btn.click(
|
| 500 |
fn=secure_generate,
|
| 501 |
+
inputs=[app_input, link_input, features_input, theme_color, telegram_link, custom_size, custom_date, req_app_name, req_app_link, tutorial_link, session_state],
|
| 502 |
+
outputs=[html_output, preview_output, word_count_out, kw_density_out, login_screen, main_app, session_state, file_download]
|
| 503 |
)
|
| 504 |
|
| 505 |
# AI OpenRouter Enhance binding
|