From bf7d9c79cae53f64fcd04527248987bd4e7ca3c4 Mon Sep 17 00:00:00 2001 From: Mitchell Riedstra Date: Sun, 19 Jun 2022 23:57:04 -0400 Subject: 0.0.17a / Alpha. Introduce users and page editing. Breaking changes: inc/base.html is now tpl/base.md by default. This can be overridden on the command line. 404.md is now tpl/404.md. This can be overridden with templatedirectory in the configuration file. Additional files: `auth.json` file that stores credentials and settings for authorization cookie. Further notes: This will likely receive some major updates and changes over the next few commits. The scaffolidng is now in place for user accounts, login handling, and page editing. It's all extremely basic at the moment, on the idea list: Listing of all markdown files File uploader and general content management Flags to turn on/off git integration for edits. Download / Upload of all markdown files as a backup/restore. It's of course, all subject to change. --- cmd/server/handlers.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cmd/server/handlers.go') diff --git a/cmd/server/handlers.go b/cmd/server/handlers.go index 205d462..1711ae3 100644 --- a/cmd/server/handlers.go +++ b/cmd/server/handlers.go @@ -15,6 +15,13 @@ func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { rtr.HandleFunc(a.ReIndexPath, a.RebuildIndexHandler) rtr.PathPrefix("/static/").Handler(a.StaticHandler()) + rtr.HandleFunc("/login", a.LoginHandler) + rtr.Handle("/logout", a.RequiresLogin(http.HandlerFunc(a.LogoutHandler))) + rtr.PathPrefix("/edit/").Handler( + a.RequiresLogin(http.StripPrefix("/edit/", http.HandlerFunc(a.EditPage)))).Methods("GET") + rtr.PathPrefix("/edit/").Handler( + a.RequiresLogin(http.StripPrefix("/edit/", http.HandlerFunc(a.SaveEditPage)))).Methods("POST") + if a.redisPool != nil { rtr.PathPrefix(fmt.Sprintf("/%s/{tag}", a.FeedPrefix)).Handler( rediscache.HandleWithParams(a.redisPool, a.RedisKey, -- cgit v1.2.3