Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add timeline page

we can start clicking links and stuff now

authored by

Akshay and committed by
Anirudh Oppiliappan
0adb7c37 6e6a97ba

+45 -2
+2 -1
routes/handler.go
··· 56 56 auth: auth, 57 57 } 58 58 59 + r.Get("/", h.Timeline) 60 + 59 61 r.Group(func(r chi.Router) { 60 - r.Use(h.AuthMiddleware) 61 62 r.Get("/login", h.Login) 62 63 r.Post("/login", h.Login) 63 64 })
+17 -1
routes/routes.go
··· 464 464 } 465 465 466 466 log.Printf("successfully saved session for %s (%s)", atSession.Handle, atSession.Did) 467 - http.Redirect(w, r, "/", http.StatusPermanentRedirect) 467 + http.Redirect(w, r, "/", http.StatusSeeOther) 468 468 return 469 469 } 470 470 } ··· 562 562 563 563 w.Header().Set("HX-Redirect", fmt.Sprintf("/@%s/%s", handle, name)) 564 564 w.WriteHeader(http.StatusOK) 565 + } 566 + } 567 + 568 + func (h *Handle) Timeline(w http.ResponseWriter, r *http.Request) { 569 + session, err := h.s.Get(r, "bild-session") 570 + user := make(map[string]string) 571 + if err != nil || session.IsNew { 572 + // user is not logged in 573 + } else { 574 + user["handle"] = session.Values["handle"].(string) 575 + user["did"] = session.Values["did"].(string) 576 + } 577 + 578 + if err := h.t.ExecuteTemplate(w, "timeline", user); err != nil { 579 + log.Println(err) 580 + return 565 581 } 566 582 }
+12
templates/layouts/topbar.html
··· 1 + <nav> 2 + <ul> 3 + {{ if . }} 4 + <li>logged in as 5 + <a href="/@{{ .handle }}">{{ .handle }}</a> (with {{ .did }}) 6 + </li> 7 + {{ else }} 8 + <li><a href="/login">login</a></li> 9 + {{ end }} 10 + </ul> 11 + </nav> 12 +
+14
templates/timeline.html
··· 1 + {{ define "timeline" }} 2 + <html> 3 + {{ template "layouts/head" . }} 4 + 5 + <header> 6 + <h1>timeline</h1> 7 + </header> 8 + <body> 9 + <main> 10 + {{ template "layouts/topbar" . }} 11 + </main> 12 + </body> 13 + </html> 14 + {{ end }}