45 lines
1.7 KiB
Plaintext
45 lines
1.7 KiB
Plaintext
package pages
|
|
|
|
import "github.com/skip2/go-qrcode"
|
|
import "encoding/base64"
|
|
|
|
templ Overlay(lnurl string) {
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>zaply</title>
|
|
<link href="/css/tailwind.css" rel="stylesheet">
|
|
<link href="/css/zap.css" rel="stylesheet">
|
|
<script src={ GetBaseUrl(ctx) + "/js/htmx.min.js" } integrity="sha384-HGfztofotfshcF7+8n44JQL2oJmowVChPTg48S+jvZoztPfvwD79OC/LTtG6dMp+" crossorigin="anonymous"></script>
|
|
<script src={ GetBaseUrl(ctx) + "/js/htmx-sse.js" } crossorigin="anonymous"></script>
|
|
if GetEnv(ctx) == "development" {
|
|
<script src={ GetBaseUrl(ctx) + "/js/livereload.js" }></script>
|
|
}
|
|
</head>
|
|
<body>
|
|
<div hx-ext="sse" sse-connect="/overlay/sse" sse-swap="zap" hx-swap="beforeend" class="fixed bottom-0 right-0" />
|
|
<script>
|
|
document.body.addEventListener('htmx:sseMessage', function (e) {
|
|
setTimeout(() => {
|
|
const div = document.getElementById(e.detail.lastEventId)
|
|
div.classList.add('zap-animate-out')
|
|
div.addEventListener('animationend', div.remove)
|
|
}, 60_000)
|
|
})
|
|
</script>
|
|
<div class="fixed bottom-0 left-0">
|
|
<img src={ "data:image/jpeg;base64," + qrEncode(lnurl) }/>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
func qrEncode(value string) string {
|
|
png, err := qrcode.Encode(value, qrcode.Medium, 256)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
return base64.StdEncoding.EncodeToString([]byte(png))
|
|
}
|