Implemented hub

This commit is contained in:
2024-02-24 15:31:33 +01:00
parent 49988edd82
commit 8f5739fb68
4 changed files with 38 additions and 13 deletions

View File

@ -29,7 +29,7 @@ func Login(db *data.DB) http.HandlerFunc {
return
}
template.Must(template.ParseFiles("web/templates/editor.html")).ExecuteTemplate(w, "page-content", nil)
template.Must(template.ParseFiles("web/templates/hub.html")).ExecuteTemplate(w, "page-content", nil)
}
}
@ -54,13 +54,7 @@ func FinishEdit(feed *data.Feed) http.HandlerFunc {
})
feed.Save("tmp/rss.gob")
rss, err := feed.ToRss()
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
template.Must(template.ParseFiles("web/templates/feed.rss")).ExecuteTemplate(w, "page-content", rss)
template.Must(template.ParseFiles("web/templates/hub.html")).ExecuteTemplate(w, "page-content", nil)
}
}
@ -124,6 +118,30 @@ func AddUser(db *data.DB) http.HandlerFunc {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
template.Must(template.ParseFiles("web/templates/editor.html")).Execute(w, nil)
template.Must(template.ParseFiles("web/templates/hub.html")).ExecuteTemplate(w, "page-content", nil)
}
}
func WriteArticle() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("web/templates/editor.html")).ExecuteTemplate(w, "page-content", nil)
}
}
func ShowRSS(feed *data.Feed) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
rss, err := feed.ToRss()
if err != nil {
log.Println(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
template.Must(template.ParseFiles("web/templates/index.html", "web/templates/feed.rss")).Execute(w, rss)
}
}
func CreateUser() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
template.Must(template.ParseFiles("web/templates/add-user.html")).ExecuteTemplate(w, "page-content", nil)
}
}