From f01607946ae82641bfbab14d4a3da5b7c9ffe252 Mon Sep 17 00:00:00 2001 From: rramiachraf <51409801+rramiachraf@users.noreply.github.com> Date: Sat, 17 Dec 2022 21:45:45 +0100 Subject: [PATCH] feat: add footer which includes the repo link --- static/style.css | 26 +++++++++++++++++++++++++- utils.go | 12 ++++++++++-- views/footer.tmpl | 5 +++++ views/home.tmpl | 18 +++++++++--------- views/lyrics.tmpl | 7 +++---- views/navbar.tmpl | 5 +++++ 6 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 views/footer.tmpl create mode 100644 views/navbar.tmpl diff --git a/static/style.css b/static/style.css index 7198479..ddc61cb 100644 --- a/static/style.css +++ b/static/style.css @@ -161,9 +161,9 @@ a { display: flex; flex-direction: column; gap: 1.5rem; - justify-content: center; align-items: center; padding: 2rem; + flex-grow: 1; } #home div { @@ -198,3 +198,27 @@ a { align-items: center; } } + +footer { + text-align: center; + background-color: #ffcd38; + padding: 1rem; +} + +footer a { + font-weight: 500; + color: #1b1a17; + transition: .3s ease text-decoration; + font-size: 1.4rem; + text-transform: uppercase; +} + +footer a:hover { + text-decoration: underline; +} + +#app { + display: flex; + flex-direction: column; + min-height: 100vh; +} diff --git a/utils.go b/utils.go index 168c658..9a34c39 100644 --- a/utils.go +++ b/utils.go @@ -60,9 +60,17 @@ func securityHeaders(next http.Handler) http.Handler { }) } +func getTemplates(templates ...string) []string { + var pths []string + for _, t := range templates { + tmpl := path.Join("views",fmt.Sprintf("%s.tmpl", t)) + pths = append(pths, tmpl) + } + return pths +} + func render(n string, w http.ResponseWriter, data any) { - tmpl := fmt.Sprintf("%s.tmpl",n ) - t, err := template.ParseFiles(path.Join("views", tmpl)) + t, err := template.ParseFiles(getTemplates(n, "navbar", "footer")...) if err != nil { w.WriteHeader(http.StatusInternalServerError) return diff --git a/views/footer.tmpl b/views/footer.tmpl new file mode 100644 index 0000000..dd76a40 --- /dev/null +++ b/views/footer.tmpl @@ -0,0 +1,5 @@ +{{define "footer"}} + +{{end}} diff --git a/views/home.tmpl b/views/home.tmpl index e3d977d..5af7fde 100644 --- a/views/home.tmpl +++ b/views/home.tmpl @@ -7,16 +7,16 @@ - - -
-
-

Welcome to dumb

-

An alternative frontend for genius.com

+
+ {{template "navbar"}} +
+
+

Welcome to dumb

+

An alternative frontend for genius.com

+
+ Just redirect Genius URLs to this instance and It's all good.
- Just redirect Genius URLs to this instance and It's all good. + {{template "footer"}}
diff --git a/views/lyrics.tmpl b/views/lyrics.tmpl index e51f2fe..c532685 100644 --- a/views/lyrics.tmpl +++ b/views/lyrics.tmpl @@ -7,10 +7,8 @@ - - + + {{template "navbar"}}
@@ -35,5 +33,6 @@
+ {{template "footer"}} diff --git a/views/navbar.tmpl b/views/navbar.tmpl new file mode 100644 index 0000000..bf117cd --- /dev/null +++ b/views/navbar.tmpl @@ -0,0 +1,5 @@ +{{define "navbar"}} + +{{end}}