Skip to content

Commit 9e64ed8

Browse files
committed
refactor: replace background with gradients
1 parent e320f26 commit 9e64ed8

4 files changed

Lines changed: 9 additions & 21 deletions

File tree

‎.dockerignore‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
!go.sum
44
!main.go
55
!page.html
6-
!background.jpg

‎background.jpg‎

-530 KB
Binary file not shown.

‎main.go‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ import (
1313
//go:embed page.html
1414
var pageHTML string
1515

16-
//go:embed background.jpg
17-
var background []byte
18-
1916
var tmpl = template.Must(template.New("page").Parse(pageHTML))
2017

2118
// identityHeaders are the headers Tinyauth sets on authenticated requests.
@@ -58,13 +55,6 @@ func render(w http.ResponseWriter, r *http.Request, protected bool, logoutURL st
5855
}
5956
}
6057

61-
func backgroundHandler(w http.ResponseWriter, _ *http.Request) {
62-
w.Header().Set("Content-Type", "image/jpeg")
63-
w.Header().Set("Cache-Control", "public, max-age=3600")
64-
w.Header().Set("X-Content-Type-Options", "nosniff")
65-
w.Write(background)
66-
}
67-
6858
func main() {
6959
logoutURL := os.Getenv("LOGOUT_URL")
7060
if logoutURL == "" {
@@ -74,7 +64,6 @@ func main() {
7464
mux := http.NewServeMux()
7565
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) { render(w, r, false, logoutURL) })
7666
mux.HandleFunc("GET /protected", func(w http.ResponseWriter, r *http.Request) { render(w, r, true, logoutURL) })
77-
mux.HandleFunc("GET /background.jpg", backgroundHandler)
7867

7968
addr := ":3000"
8069
log.Printf("tinyauth-demo listening on %s (logout -> %s)", addr, logoutURL)

‎page.html‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@
173173
}
174174
</style>
175175
</head>
176-
<body class="flex flex-col justify-center items-center min-h-svh px-4 py-8">
177-
<div
178-
class="fixed inset-0 -z-10 bg-[url(/background.jpg)] bg-cover bg-center"
179-
aria-hidden="true"
180-
></div>
176+
{{ if.Protected }}
177+
<body class="flex flex-col justify-center items-center min-h-svh px-4 py-8 bg-gradient-to-br from-[#4FD1D9] to-[#34D399]">
178+
{{ else }}
179+
<body class="flex flex-col justify-center items-center min-h-svh px-4 py-8 bg-gradient-to-br from-[#4A7BA8] to-[#334155]">
180+
{{ end }}
181181
<div class="w-full max-w-lg">
182182
<main class="card relative">
183183
{{if .Protected}}
@@ -190,7 +190,7 @@
190190
aria-hidden="true"
191191
>
192192
<svg
193-
class="size-6"
193+
class="size-6 stroke-[2.25]"
194194
xmlns="http://www.w3.org/2000/svg"
195195
width="24"
196196
height="24"
@@ -257,7 +257,7 @@ <h1 class="card-title text-xl">
257257
aria-hidden="true"
258258
>
259259
<svg
260-
class="size-6"
260+
class="size-6 stroke-[2.25]"
261261
xmlns="http://www.w3.org/2000/svg"
262262
width="24"
263263
height="24"
@@ -321,11 +321,11 @@ <h1 class="card-title text-xl">This page is public</h1>
321321
>Log out</a
322322
>
323323
<a class="btn btn-ghost w-full" href="/"
324-
>&larr; Back to the public page</a
324+
>Back to the public page</a
325325
>
326326
{{else}}
327327
<a class="btn btn-default w-full" href="/protected"
328-
>Open protected page &rarr;</a
328+
>Open protected page</a
329329
>
330330
<p class="text-muted-foreground text-xs text-center">
331331
This app does no auth of its own.

0 commit comments

Comments
 (0)