From 0adb7c37830097f1164ba886be87e540398aae8b Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 29 Jan 2025 10:26:40 +0000 Subject: [PATCH] add timeline page we can start clicking links and stuff now --- routes/handler.go | 3 ++- routes/routes.go | 18 +++++++++++++++++- templates/layouts/topbar.html | 12 ++++++++++++ templates/timeline.html | 14 ++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 templates/layouts/topbar.html create mode 100644 templates/timeline.html diff --git a/routes/handler.go b/routes/handler.go index 377cd8b..f1134d1 100644 --- a/routes/handler.go +++ b/routes/handler.go @@ -56,8 +56,9 @@ func Setup(c *config.Config, db *db.DB) (http.Handler, error) { auth: auth, } + r.Get("/", h.Timeline) + r.Group(func(r chi.Router) { - r.Use(h.AuthMiddleware) r.Get("/login", h.Login) r.Post("/login", h.Login) }) diff --git a/routes/routes.go b/routes/routes.go index 3075768..62437d8 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -464,7 +464,7 @@ func (h *Handle) Login(w http.ResponseWriter, r *http.Request) { } log.Printf("successfully saved session for %s (%s)", atSession.Handle, atSession.Did) - http.Redirect(w, r, "/", http.StatusPermanentRedirect) + http.Redirect(w, r, "/", http.StatusSeeOther) return } } @@ -564,3 +564,19 @@ func (h *Handle) NewRepo(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } } + +func (h *Handle) Timeline(w http.ResponseWriter, r *http.Request) { + session, err := h.s.Get(r, "bild-session") + user := make(map[string]string) + if err != nil || session.IsNew { + // user is not logged in + } else { + user["handle"] = session.Values["handle"].(string) + user["did"] = session.Values["did"].(string) + } + + if err := h.t.ExecuteTemplate(w, "timeline", user); err != nil { + log.Println(err) + return + } +} diff --git a/templates/layouts/topbar.html b/templates/layouts/topbar.html new file mode 100644 index 0000000..18e2dee --- /dev/null +++ b/templates/layouts/topbar.html @@ -0,0 +1,12 @@ + + diff --git a/templates/timeline.html b/templates/timeline.html new file mode 100644 index 0000000..1e83910 --- /dev/null +++ b/templates/timeline.html @@ -0,0 +1,14 @@ +{{ define "timeline" }} + +{{ template "layouts/head" . }} + +
+

timeline

+
+ +
+ {{ template "layouts/topbar" . }} +
+ + +{{ end }} -- 2.51.2