diff --git a/app/main.py b/app/main.py index 05b5e28..c3bb35e 100644 --- a/app/main.py +++ b/app/main.py @@ -8,8 +8,12 @@ Security model: every request to the logged-in member. Environment (all provided by Cloudron env vars): - PORTAL_BASE — base URL of the member portal (e.g. https://portal.inference.coop) - BROKER_SECRET — shared secret for the portal's broker endpoints + PORTAL_BASE — base URL of the member portal (e.g. https://portal.inference.coop) + BROKER_SECRET — shared secret for the portal's broker endpoints + CREDIT_PACK_URL — where the "Buy a credit pack" link sends members (defaults to + the Open Collective contribute page, which is what actually + credits a member). Configuration, not code, because the + destination can move (a future pack page) without a deploy here. """ import os @@ -28,6 +32,14 @@ logger = logging.getLogger("member-dashboard") PORTAL_BASE = os.environ.get("PORTAL_BASE", "").rstrip("/") BROKER_SECRET = os.environ.get("BROKER_SECRET", "") +# Where the always-visible "Buy a credit pack" link points. Configuration, not a +# constant in the template: the co-op sets this per app (same convention the +# portal uses) so the destination changes in one place. The Open Collective +# contribution page is the default because that is what actually credits a +# member today (the webhook settles contributions into credits). +DEFAULT_CREDIT_PACK_URL = "https://opencollective.com/inference-cooperative/contribute" +CREDIT_PACK_URL = (os.environ.get("CREDIT_PACK_URL") or "").strip() or DEFAULT_CREDIT_PACK_URL + app = FastAPI() @@ -296,7 +308,10 @@ def _esc(s: str) -> str: def render_page(identity: str) -> str: - return PAGE_HTML.replace("@@IDENTITY@@", _esc(identity)) + return ( + PAGE_HTML.replace("@@IDENTITY@@", _esc(identity)) + .replace("@@CREDIT_PACK_URL@@", _esc(CREDIT_PACK_URL)) + ) PAGE_HTML = """ @@ -357,6 +372,20 @@ PAGE_HTML = """ .bar .fill { height: 100%; background: var(--green-mid); border-radius: 6px; transition: width .3s ease; } .bar .fill.warn { background: #d99a3e; } .meta { color: var(--muted); font-size: 13px; margin-top: 8px; } + /* Always-visible buy path: members could not find a way to add usage. + A green button (same green + radius as the other buttons) out to the + configured pack page, plus the member's real credit status and a link + to the docs section that explains allowance vs. credits. */ + .buy-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; } + a.buy-btn { + display: inline-block; background: var(--green-deep); color: #fff; + border-radius: 8px; font-size: 14px; font-weight: 600; + padding: 8px 16px; text-decoration: none; transition: background .15s ease; + } + a.buy-btn:hover { background: #4e7a4d; } + .buy-hint { color: var(--muted); font-size: 12px; } + a.buy-docs { color: var(--green-deep); font-weight: 600; text-decoration: none; white-space: nowrap; } + a.buy-docs:hover { text-decoration: underline; } .models { margin-top: 16px; } .model-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; @@ -557,6 +586,12 @@ PAGE_HTML = """
+