From 673fe6cd69d5d39bb5d05df5ee878b504838dbf6 Mon Sep 17 00:00:00 2001 From: Vicente Ferrari Smith Date: Sun, 5 Oct 2025 18:48:53 +0200 Subject: [PATCH] adding the news, man --- cmd/web/handlers.go | 29 +++++++++++++++++++++++++++++ cmd/web/main.go | 1 + ui/html/base.html | 21 +++++++++++---------- ui/static/style.css | 30 ++++++++++++++++++++++++++---- 4 files changed, 67 insertions(+), 14 deletions(-) diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 5f1cc9b..1d8fb93 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -107,6 +107,35 @@ func home(w http.ResponseWriter, r *http.Request) { } } +func news(w http.ResponseWriter, r *http.Request) { + id := authenticatedUser(w, r) + account, _ := users.GetAccount(id) + + active_subscription := subscriptions.HasActiveSubscription(id) + + text, err := template.ParseFiles("ui/html/base.html", "ui/html/news.html") + if err != nil { + http.Error(w, "Internal Server Error", 500) + log.Println(err) + } + + switch r.Method { + case http.MethodGet: + err := text.Execute(w, TemplateData{AuthenticatedUser: id, Account: account, ActiveSubscription: active_subscription}) + if err != nil { + log.Println(err) + http.Error(w, "Internal Server Error", 500) + } + + case http.MethodPost: + err := text.Execute(w, TemplateData{}) + if err != nil { + log.Println(err) + http.Error(w, "Internal Server Error", 500) + } + } +} + func login(w http.ResponseWriter, r *http.Request) { text, err := template.ParseFiles("ui/html/base.html", "ui/html/login.html") if err != nil { diff --git a/cmd/web/main.go b/cmd/web/main.go index 35099c2..6be34ed 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -71,6 +71,7 @@ func main() { mux.HandleFunc("/favicon.ico", favicon) mux.HandleFunc("/", home) + mux.HandleFunc("/news", news) mux.HandleFunc("/login", login) mux.HandleFunc("/logout", logout) mux.HandleFunc("/register", register) diff --git a/ui/html/base.html b/ui/html/base.html index 42f9e32..a71493a 100644 --- a/ui/html/base.html +++ b/ui/html/base.html @@ -22,17 +22,18 @@ diff --git a/ui/static/style.css b/ui/static/style.css index 8044bd1..a459e2b 100644 --- a/ui/static/style.css +++ b/ui/static/style.css @@ -22,9 +22,9 @@ body { min-height: 100%; } -header { +/* header { -} +} */ nav { padding-left: 8px; @@ -50,7 +50,7 @@ nav { } } -.loginbutton { +.alfheimbutton { align-self: center; display: flex; border: 12px solid; @@ -90,9 +90,10 @@ p { border-radius: 15px; padding: 30px 40px; font-size: 1.5rem; + margin: 10px; } -.wrapper { +/* .wrapper { display: inline-block; background: transparent; border: 2px solid white; @@ -102,6 +103,27 @@ p { padding: 30px 40px; width: 80%; text-align: center; + margin: 10px; +} */ + +.wrapper { + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; + background: transparent; + border: 2px solid white; + backdrop-filter: blur(20px); + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); + border-radius: 15px; + padding: 30px 40px; + width: 80%; + text-align: center; + margin: 10px; +} + +.wrapper form { + width: 100%; /* make each form stretch full width */ } .wrapper h1 {