mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-23 06:35:23 +01:00
add PWA support for the tpos extension
This commit is contained in:
parent
102dc56c4a
commit
f9b929ae7d
2 changed files with 39 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
<link rel="manifest" href="/tpos/manifest/{{ tpos.id }}.webmanifest" />
|
||||||
{% extends "public.html" %}
|
{% extends "public.html" %}
|
||||||
{% block toolbar_title %}
|
{% block toolbar_title %}
|
||||||
{{ tpos.name }}
|
{{ tpos.name }}
|
||||||
|
|
|
@ -8,6 +8,10 @@ from starlette.responses import HTMLResponse
|
||||||
|
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
|
from lnbits.settings import (
|
||||||
|
LNBITS_CUSTOM_LOGO,
|
||||||
|
LNBITS_SITE_TITLE,
|
||||||
|
)
|
||||||
|
|
||||||
from . import tpos_ext, tpos_renderer
|
from . import tpos_ext, tpos_renderer
|
||||||
from .crud import get_tpos
|
from .crud import get_tpos
|
||||||
|
@ -33,3 +37,37 @@ async def tpos(request: Request, tpos_id):
|
||||||
return tpos_renderer().TemplateResponse(
|
return tpos_renderer().TemplateResponse(
|
||||||
"tpos/tpos.html", {"request": request, "tpos": tpos}
|
"tpos/tpos.html", {"request": request, "tpos": tpos}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@tpos_ext.get("/manifest/{tpos_id}.webmanifest")
|
||||||
|
async def manifest(tpos_id: str):
|
||||||
|
tpos = await get_tpos(tpos_id)
|
||||||
|
if not tpos:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.NOT_FOUND, detail="TPoS does not exist."
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"short_name": LNBITS_SITE_TITLE,
|
||||||
|
"name": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": LNBITS_CUSTOM_LOGO if LNBITS_CUSTOM_LOGO else "https://cdn.jsdelivr.net/gh/lnbits/lnbits@0.3.0/docs/logos/lnbits.png",
|
||||||
|
"type": "image/png",
|
||||||
|
"sizes": "900x900",
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "/tpos/" + tpos_id,
|
||||||
|
"background_color": "#1F2234",
|
||||||
|
"description": "Bitcoin Lightning tPOS",
|
||||||
|
"display": "standalone",
|
||||||
|
"scope": "/tpos/" + tpos_id,
|
||||||
|
"theme_color": "#1F2234",
|
||||||
|
"shortcuts": [
|
||||||
|
{
|
||||||
|
"name": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
||||||
|
"short_name": tpos.name,
|
||||||
|
"description": tpos.name + ' - ' + LNBITS_SITE_TITLE,
|
||||||
|
"url": "/tpos/" + tpos_id,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue