Community / app.py
LordMo2's picture
feat(ui): NEXUSMON operator-grade shell — app.py
e924868 verified
Raw
History Blame Contribute Delete
3.91 kB
"""NEXUSMON — Community
Public ritual space. Part of the Nexusmon sovereign AI organism.
"""
from __future__ import annotations
import base64
import time
from pathlib import Path
import gradio as gr
ORG_URL = "https://huggingface.co/Nexusmon"
FRONT_DOOR_URL = "https://huggingface.co/spaces/Nexusmon/README"
RANKING_URL = "https://huggingface.co/spaces/Nexusmon/hf-nexusmon-ranking"
KNOWLEDGE_URL = "https://huggingface.co/spaces/Nexusmon/hf-nexusmon-knowledge"
PRESENCE_BANNER = "nexusmon-presence.svg"
def _presence_banner_src() -> str | None:
candidates = [
Path(__file__).resolve().parent / "assets" / PRESENCE_BANNER,
Path(__file__).resolve().parents[4] / "assets" / PRESENCE_BANNER,
]
for candidate in candidates:
if candidate.is_file():
encoded = base64.b64encode(candidate.read_bytes()).decode("ascii")
return f"data:image/svg+xml;base64,{encoded}"
return None
def build() -> str:
now = time.strftime("%Y-%m-%d %H:%M UTC", time.gmtime())
banner_src = _presence_banner_src()
if banner_src:
banner = f"""
<div class="nx-presence-frame" style="margin-bottom: 1rem; padding: 0.7rem; border: 1px solid rgba(255,255,255,0.08); border-radius: 24px; background: rgba(255,255,255,0.02); box-shadow: 0 18px 44px rgba(0, 0, 0, 0.28);">
<img src="{banner_src}" alt="NEXUSMON presence banner" style="display:block;width:100%;height:auto;border-radius:18px;" />
</div>
""".strip()
else:
banner = """
<div class="nx-presence-frame" style="margin-bottom: 1rem; padding: 1rem 1.2rem; border: 1px solid rgba(255,255,255,0.08); border-radius: 24px; background: rgba(255,255,255,0.02); color: #8fefff; text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.72rem;">
NEXUSMON presence banner unavailable
</div>
""".strip()
return f"""
<div class="nx-root">
{banner}
<header class="nx-header">
<div class="nx-header-left">
<span class="nx-eyebrow">NEXUSMON / public ritual space</span>
<h1 class="nx-wordmark">Community</h1>
<p class="nx-tagline">Open membrane for the NEXUSMON community. Sovereign AI collective.</p>
</div>
<nav class="nx-header-links">
<a href="{ORG_URL}" target="_blank" rel="noreferrer" class="nx-nav-link">Org</a>
<a href="{FRONT_DOOR_URL}" target="_blank" rel="noreferrer" class="nx-nav-link">Front Door</a>
<a href="{RANKING_URL}" target="_blank" rel="noreferrer" class="nx-nav-link">Ranking</a>
<a href="{KNOWLEDGE_URL}" target="_blank" rel="noreferrer" class="nx-nav-link">Knowledge</a>
</nav>
</header>
<div class="nx-shell-body">
<p class="nx-shell-note">This surface is part of the NEXUSMON sovereign AI organism. Navigate via the links above.</p>
<span class="nx-render-stamp">Rendered {now}</span>
</div>
</div>
""".strip()
theme = gr.themes.Base(
primary_hue=gr.themes.Color(
c100="#e0f2fe", c200="#bae6fd", c300="#7dd3fc", c400="#38bdf8",
c500="#0ea5e9", c600="#0284c7", c700="#0369a1", c800="#075985",
c900="#0c4a6e", c950="#082f49",
),
secondary_hue=gr.themes.colors.indigo,
neutral_hue=gr.themes.colors.slate,
font=[gr.themes.GoogleFont("Space Grotesk"), gr.themes.GoogleFont("Inter"), "system-ui", "sans-serif"],
font_mono=[gr.themes.GoogleFont("IBM Plex Mono"), "monospace"],
).set(
body_background_fill="#07080f",
body_text_color="#e8f4ff",
block_background_fill="#0d101c",
block_border_width="0px",
)
css = Path(__file__).with_name("custom.css").read_text(encoding="utf-8")
with gr.Blocks(theme=theme, css=css, title="NEXUSMON — Community", analytics_enabled=False) as demo:
content = gr.HTML()
demo.load(fn=build, outputs=content)
demo.queue()
demo.launch()