summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-04-09 21:29:25 +0200
committerewy <ewy0@protonmail.com>2026-04-09 21:29:25 +0200
commitc2ab8ee9409ac26a95e9a4c80c8ada51a22313f1 (patch)
tree94a070e764abad211335a0f99a78ac181233976a
parent6e896ae0e108eef385b46c26e770dc191ae936ba (diff)
-rw-r--r--main.go1
-rw-r--r--pages/create.go25
-rw-r--r--pages/html/create.gohtml (renamed from pages/create.gohtml)6
-rw-r--r--pages/html/header.gohtml (renamed from pages/header.gohtml)0
-rw-r--r--pages/html/landing.gohtml (renamed from pages/landing.gohtml)3
-rw-r--r--pages/html/meta.gohtml15
-rw-r--r--pages/html/style.gohtml (renamed from pages/style.gohtml)0
-rw-r--r--pages/landing.go2
8 files changed, 32 insertions, 20 deletions
diff --git a/main.go b/main.go
index e06c63f..009219a 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,6 @@ package main
import (
"delayed.link/pages"
- _ "delayed.link/pages"
"delayed.link/storage"
"delayed.link/storage/sqlite"
"github.com/spf13/pflag"
diff --git a/pages/create.go b/pages/create.go
index 5469ee8..f16d2d8 100644
--- a/pages/create.go
+++ b/pages/create.go
@@ -2,10 +2,13 @@ package pages
import (
"delayed.link/storage"
+ "embed"
_ "embed"
"html/template"
+ "io/fs"
"net/http"
"net/url"
+ "path/filepath"
"strconv"
"strings"
"time"
@@ -83,17 +86,17 @@ func Create(w http.ResponseWriter, r *http.Request) {
}
}
-//go:embed create.gohtml
-var recContent string
-
-//go:embed style.gohtml
-var style string
-
-//go:embed header.gohtml
-var header string
+//go:embed html
+var pages embed.FS
func init() {
- template.Must(tmpl.Parse(style))
- template.Must(tmpl.Parse(header))
- template.Must(tmpl.New("create").Parse(recContent))
+ entries, _ := pages.ReadDir("html")
+ for _, entry := range entries {
+ name := entry.Name()
+ if !entry.IsDir() && strings.HasSuffix(name, ".gohtml") {
+ tmplName := strings.SplitN(name, ".", 2)[0]
+ content, _ := fs.ReadFile(pages, filepath.Join("html", name))
+ template.Must(tmpl.New(tmplName).Parse(string(content)))
+ }
+ }
}
diff --git a/pages/create.gohtml b/pages/html/create.gohtml
index d50582a..c08fd93 100644
--- a/pages/create.gohtml
+++ b/pages/html/create.gohtml
@@ -1,12 +1,8 @@
<!doctype html>
<html lang="en">
<head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <link rel="icon" href="data:,"/>
<title>delayed.link: created</title>
+ {{ template "meta" . }}
{{ template "style" . }}
</head>
<body>
diff --git a/pages/header.gohtml b/pages/html/header.gohtml
index 5af455e..5af455e 100644
--- a/pages/header.gohtml
+++ b/pages/html/header.gohtml
diff --git a/pages/landing.gohtml b/pages/html/landing.gohtml
index 021cb95..268ae90 100644
--- a/pages/landing.gohtml
+++ b/pages/html/landing.gohtml
@@ -1,12 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <meta charset="UTF-8">
- <link rel="icon" href="data:,"/>
<title>delayed.link</title>
{{ template "style" . }}
</head>
<body>
+{{ template "meta" . }}
{{ template "header" . }}
<main>
<form method="POST" action="/">
diff --git a/pages/html/meta.gohtml b/pages/html/meta.gohtml
new file mode 100644
index 0000000..07d515b
--- /dev/null
+++ b/pages/html/meta.gohtml
@@ -0,0 +1,15 @@
+{{ define "meta" }}
+ <meta charset="UTF-8">
+ <meta name="viewport"
+ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
+ <meta http-equiv="X-UA-Compatible" content="ie=edge">
+ <link rel="icon" href="data:,"/>
+ <meta content="delayed.link" property="og:title" />
+ <meta content="https://delayed.link/" property="og:url" />
+ {{ if (eq . nil) }}
+ <meta content="send something now, they unlock it later" property="og:description" />
+ {{ else }}
+ <meta content="this link will unlock in {{ .MinutesLeft }} minute{{ if gt .MinutesLeft 1 }}s{{end}} after this embed was created." />
+ {{ end }}
+ <meta content="#f2cae2" data-react-helmet="true" name="theme-color" />
+{{end}} \ No newline at end of file
diff --git a/pages/style.gohtml b/pages/html/style.gohtml
index bb15fb9..bb15fb9 100644
--- a/pages/style.gohtml
+++ b/pages/html/style.gohtml
diff --git a/pages/landing.go b/pages/landing.go
index d2c2fc3..a4a6f90 100644
--- a/pages/landing.go
+++ b/pages/landing.go
@@ -6,7 +6,7 @@ import (
"net/http"
)
-//go:embed landing.gohtml
+//go:embed html/landing.gohtml
var landContent string
func Land(w http.ResponseWriter, r *http.Request) {