Merge pull request #152 from lnbits/LNURLimg

This commit is contained in:
fiatjaf
2021-03-14 22:02:43 -03:00
committed by GitHub
4 changed files with 274 additions and 194 deletions
@@ -58,7 +58,20 @@
type="a"
:href="props.row.withdraw_url"
target="_blank"
></q-btn>
>
<q-tooltip> shareable link </q-tooltip></q-btn
>
<q-btn
unelevated
dense
size="xs"
icon="web_asset"
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
type="a"
:href="'/withdraw/img/' + props.row.id"
target="_blank"
><q-tooltip> embeddable image </q-tooltip></q-btn
>
<q-btn
unelevated
dense
@@ -66,7 +79,8 @@
icon="visibility"
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
@click="openQrCodeDialog(props.row.id)"
></q-btn>
><q-tooltip> view LNURL </q-tooltip></q-btn
>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
{{ col.value }}
+20 -1
View File
@@ -1,6 +1,7 @@
from quart import g, abort, render_template
from http import HTTPStatus
import pyqrcode
from io import BytesIO
from lnbits.decorators import check_user_exists, validate_uuids
from . import withdraw_ext
@@ -20,6 +21,24 @@ async def display(link_id):
return await render_template("withdraw/display.html", link=link, unique=True)
@withdraw_ext.route("/img/<link_id>")
async def img(link_id):
link = await get_withdraw_link(link_id, 0) or abort(HTTPStatus.NOT_FOUND, "Withdraw link does not exist.")
qr = pyqrcode.create(link.lnurl)
stream = BytesIO()
qr.svg(stream, scale=3)
return (
stream.getvalue(),
200,
{
"Content-Type": "image/svg+xml",
"Cache-Control": "no-cache, no-store, must-revalidate",
"Pragma": "no-cache",
"Expires": "0",
},
)
@withdraw_ext.route("/print/<link_id>")
async def print_qr(link_id):
link = await get_withdraw_link(link_id) or abort(HTTPStatus.NOT_FOUND, "Withdraw link does not exist.")