Spaces:
Running on Zero
Running on Zero
Upload upsampler_theme.py with huggingface_hub
Browse files- upsampler_theme.py +54 -0
upsampler_theme.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Shared Upsampler look-and-feel for every Upsampler/* HF Space.
|
| 2 |
+
|
| 3 |
+
`create_and_push.py` uploads this file alongside each Space's app.py, so every
|
| 4 |
+
Space imports the exact same theme, CSS, header, and footer. Keep this the
|
| 5 |
+
single source of truth (v3 recipe): Soft indigo/purple theme, gradient primary
|
| 6 |
+
button, Gradio's own footer hidden, 1000px max width, minimal header/footer.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import gradio as gr
|
| 10 |
+
|
| 11 |
+
UPSAMPLER_THEME = gr.themes.Soft(
|
| 12 |
+
primary_hue=gr.themes.colors.indigo,
|
| 13 |
+
secondary_hue=gr.themes.colors.purple,
|
| 14 |
+
neutral_hue=gr.themes.colors.slate,
|
| 15 |
+
font=[gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
|
| 16 |
+
).set(
|
| 17 |
+
button_primary_background_fill="linear-gradient(90deg, #6366f1 0%, #a855f7 100%)",
|
| 18 |
+
button_primary_background_fill_hover="linear-gradient(90deg, #4f46e5 0%, #9333ea 100%)",
|
| 19 |
+
button_primary_text_color="#ffffff",
|
| 20 |
+
button_primary_border_color="*primary_500",
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Hide Gradio's built-in footer and keep the app narrow and centered.
|
| 24 |
+
UPSAMPLER_CSS = """
|
| 25 |
+
footer { display: none !important; }
|
| 26 |
+
.gradio-container { max-width: 1000px !important; margin: 0 auto !important; }
|
| 27 |
+
#usp-header h1 { font-size: 1.7rem; font-weight: 700; margin: 0 0 .25rem; }
|
| 28 |
+
#usp-header p { opacity: .6; margin: 0; }
|
| 29 |
+
#usp-footer { opacity: .5; font-size: .85rem; margin-top: 1.25rem; }
|
| 30 |
+
#usp-footer a { text-decoration: none; }
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def header_html(title: str, subtitle: str) -> str:
|
| 35 |
+
return f"""<div id="usp-header">
|
| 36 |
+
<h1>{title}</h1>
|
| 37 |
+
<p>{subtitle}</p>
|
| 38 |
+
</div>"""
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
_LINK_STYLE = "color:#8b7cf6;font-weight:600;text-decoration:none"
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def footer_html(description: str, tool_url: str, tool_anchor: str) -> str:
|
| 45 |
+
"""SEO footer (v4 recipe): a short paragraph describing what the model
|
| 46 |
+
does (unique per Space, keyword-bearing) plus the Upsampler attribution
|
| 47 |
+
with a deep link to the matching /free-* tool on upsampler.com. No model
|
| 48 |
+
credit/license line (the README frontmatter carries the license). Spaces
|
| 49 |
+
target model-name queries; the site pages keep the intent queries
|
| 50 |
+
("free X no signup"), so the two never compete."""
|
| 51 |
+
return f"""<div id="usp-footer">
|
| 52 |
+
<p style="margin:0 0 10px">{description}</p>
|
| 53 |
+
<p style="margin:0">Maintained by <a href="https://upsampler.com" target="_blank" rel="noopener" style="{_LINK_STYLE}">Upsampler</a>. Check out the <a href="{tool_url}" target="_blank" rel="noopener" style="{_LINK_STYLE}">{tool_anchor}</a>, no sign-up required.</p>
|
| 54 |
+
</div>"""
|