Compare commits
No commits in common. "b3f31f398d078edc9248bbea47be1f61a4abb505" and "b2a701c87a1334b624c9bcf5a31acc342088097a" have entirely different histories.
b3f31f398d
...
b2a701c87a
@ -52,11 +52,7 @@ func WriteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,11 +120,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,11 +179,7 @@ func ResubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,11 +217,7 @@ func ShowUnpublishedUnrejectedAndPublishedRejectedArticles(c *b.Config, db *b.DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/unpublished-articles.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/unpublished-articles.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", articles); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", articles)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,11 +249,7 @@ func ShowRejectedArticles(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerF
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/rejected-articles.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/rejected-articles.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", data); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,11 +305,7 @@ func ReviewRejectedArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.Handler
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", data); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,11 +390,7 @@ func PublishArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,11 +416,7 @@ func RejectArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,11 +434,7 @@ func ShowCurrentArticles(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/current-articles.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/current-articles.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", articles); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", articles)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,11 +492,7 @@ func ShowPublishedArticles(c *b.Config, db *b.DB, s *b.CookieStore, action strin
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/published-articles.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/published-articles.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", data); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,11 +563,7 @@ func ReviewArticle(c *b.Config, db *b.DB, s *b.CookieStore, action, title, butto
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/review-article.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/review-article.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,11 +607,7 @@ func DeleteArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -707,11 +659,7 @@ func AllowEditArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -766,10 +714,6 @@ func EditArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
data.Action = fmt.Sprint("save/", data.Article.ID)
|
data.Action = fmt.Sprint("save/", data.Article.ID)
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/editor.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package frontend
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
b "streifling.com/jason/cpolis/cmd/backend"
|
b "streifling.com/jason/cpolis/cmd/backend"
|
||||||
@ -15,11 +14,7 @@ func CreateTag(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-tag.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-tag.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +29,6 @@ func AddTag(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -132,11 +132,7 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"]); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package frontend
|
package frontend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
@ -33,17 +34,14 @@ func getSession(w http.ResponseWriter, r *http.Request, c *b.Config, s *b.Cookie
|
|||||||
|
|
||||||
tmpSession, err := s.Get(r, "cookie")
|
tmpSession, err := s.Get(r, "cookie")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err = template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", msg); err != nil {
|
template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", msg)
|
||||||
return nil, fmt.Errorf("error executing template: %v", err)
|
return nil, err
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("error getting session: %v", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
session := &b.Session{Session: *tmpSession}
|
session := &b.Session{Session: *tmpSession}
|
||||||
if session.IsNew {
|
if session.IsNew {
|
||||||
if err = template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", msg); err != nil {
|
template.Must(tmpl, tmplErr).ExecuteTemplate(w, "page-content", msg)
|
||||||
return nil, fmt.Errorf("error executing template: %v", err)
|
return session, errors.New("error: no existing session")
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return session, nil
|
return session, nil
|
||||||
@ -56,34 +54,21 @@ func HomePage(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
files := make([]string, 2)
|
files := []string{c.WebDir + "/templates/index.html"}
|
||||||
files[0] = c.WebDir + "/templates/index.html"
|
|
||||||
if numRows == 0 {
|
if numRows == 0 {
|
||||||
files[1] = c.WebDir + "/templates/first-user.html"
|
files = append(files, c.WebDir+"/templates/first-user.html")
|
||||||
tmpl, err := template.ParseFiles(files...)
|
tmpl, err := template.ParseFiles(files...)
|
||||||
if err = template.Must(tmpl, err).Execute(w, nil); err != nil {
|
template.Must(tmpl, err).Execute(w, nil)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
session, _ := s.Get(r, "cookie")
|
session, _ := s.Get(r, "cookie")
|
||||||
if auth, ok := session.Values["authenticated"].(bool); auth && ok {
|
if auth, ok := session.Values["authenticated"].(bool); auth && ok {
|
||||||
files[1] = c.WebDir + "/templates/hub.html"
|
files = append(files, c.WebDir+"/templates/hub.html")
|
||||||
tmpl, err := template.ParseFiles(files...)
|
tmpl, err := template.ParseFiles(files...)
|
||||||
if err = template.Must(tmpl, err).Execute(w, session.Values["role"]); err != nil {
|
template.Must(tmpl, err).Execute(w, session.Values["role"])
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
files[1] = c.WebDir + "/templates/login.html"
|
files = append(files, c.WebDir+"/templates/login.html")
|
||||||
tmpl, err := template.ParseFiles(files...)
|
tmpl, err := template.ParseFiles(files...)
|
||||||
if err = template.Must(tmpl, err).Execute(w, nil); err != nil {
|
template.Must(tmpl, err).Execute(w, nil)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,11 +105,7 @@ func Login(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user.Role); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user.Role)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,11 +124,7 @@ func Logout(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/login.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/login.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,10 +143,6 @@ func ShowHub(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,7 @@ func CreateUser(c *b.Config, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", nil)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,11 +70,7 @@ func AddUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
len(htmlData.LastName) == 0 || len(pass) == 0 || len(pass2) == 0 {
|
len(htmlData.LastName) == 0 || len(pass) == 0 || len(pass2) == 0 {
|
||||||
htmlData.Msg = "Alle Felder müssen ausgefüllt werden."
|
htmlData.Msg = "Alle Felder müssen ausgefüllt werden."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userString, stringLen, ok := checkUserStrings(htmlData.User)
|
userString, stringLen, ok := checkUserStrings(htmlData.User)
|
||||||
@ -86,11 +78,7 @@ func AddUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
htmlData.Msg = fmt.Sprint(userString, " ist zu lang. Maximal ",
|
htmlData.Msg = fmt.Sprint(userString, " ist zu lang. Maximal ",
|
||||||
stringLen, " Zeichen erlaubt.")
|
stringLen, " Zeichen erlaubt.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id, _ := db.GetID(htmlData.UserName)
|
id, _ := db.GetID(htmlData.UserName)
|
||||||
@ -98,21 +86,13 @@ func AddUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
htmlData.Msg = fmt.Sprint(htmlData.UserName,
|
htmlData.Msg = fmt.Sprint(htmlData.UserName,
|
||||||
" ist bereits vergeben. Bitte anderen Benutzernamen wählen.")
|
" ist bereits vergeben. Bitte anderen Benutzernamen wählen.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pass != pass2 {
|
if pass != pass2 {
|
||||||
htmlData.Msg = "Die Passwörter stimmen nicht überein."
|
htmlData.Msg = "Die Passwörter stimmen nicht überein."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,11 +105,7 @@ func AddUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,11 +124,7 @@ func EditSelf(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-self.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-self.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,11 +152,7 @@ func UpdateSelf(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
userData.Msg = "Alle Felder mit * müssen ausgefüllt sein."
|
userData.Msg = "Alle Felder mit * müssen ausgefüllt sein."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData.Msg); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData.Msg)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,11 +162,7 @@ func UpdateSelf(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
stringLen, " Zeichen erlaubt.")
|
stringLen, " Zeichen erlaubt.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,11 +172,7 @@ func UpdateSelf(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
userData.UserName = ""
|
userData.UserName = ""
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,20 +187,12 @@ func UpdateSelf(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
newPass2); err != nil {
|
newPass2); err != nil {
|
||||||
userData.Msg = "Aktualisierung der Benutzerdaten fehlgeschlagen."
|
userData.Msg = "Aktualisierung der Benutzerdaten fehlgeschlagen."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", userData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,11 +214,7 @@ func AddFirstUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
len(htmlData.LastName) == 0 || len(pass) == 0 || len(pass2) == 0 {
|
len(htmlData.LastName) == 0 || len(pass) == 0 || len(pass2) == 0 {
|
||||||
htmlData.Msg = "Alle Felder müssen ausgefüllt werden."
|
htmlData.Msg = "Alle Felder müssen ausgefüllt werden."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userString, stringLen, ok := checkUserStrings(htmlData.User)
|
userString, stringLen, ok := checkUserStrings(htmlData.User)
|
||||||
@ -274,11 +222,7 @@ func AddFirstUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
htmlData.Msg = fmt.Sprint(userString, " ist zu lang. Maximal ",
|
htmlData.Msg = fmt.Sprint(userString, " ist zu lang. Maximal ",
|
||||||
stringLen, " Zeichen erlaubt.")
|
stringLen, " Zeichen erlaubt.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
id, _ := db.GetID(htmlData.UserName)
|
id, _ := db.GetID(htmlData.UserName)
|
||||||
@ -286,21 +230,13 @@ func AddFirstUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
htmlData.Msg = fmt.Sprint(htmlData.UserName,
|
htmlData.Msg = fmt.Sprint(htmlData.UserName,
|
||||||
" ist bereits vergeben. Bitte anderen Benutzernamen wählen.")
|
" ist bereits vergeben. Bitte anderen Benutzernamen wählen.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if pass != pass2 {
|
if pass != pass2 {
|
||||||
htmlData.Msg = "Die Passwörter stimmen nicht überein."
|
htmlData.Msg = "Die Passwörter stimmen nicht überein."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/add-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", htmlData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,11 +266,7 @@ func AddFirstUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", 0); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", 0)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,11 +292,7 @@ func ShowAllUsers(c *b.Config, db *b.DB, s *b.CookieStore, action string) http.H
|
|||||||
|
|
||||||
delete(data.Users, session.Values["id"].(int64))
|
delete(data.Users, session.Values["id"].(int64))
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/show-all-users.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/show-all-users.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", data)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,11 +317,7 @@ func EditUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", user)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,11 +359,7 @@ func UpdateUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
userData.Msg = "Alle Felder mit * müssen ausgefüllt sein."
|
userData.Msg = "Alle Felder mit * müssen ausgefüllt sein."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData.Msg); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData.Msg)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -449,11 +369,7 @@ func UpdateUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
stringLen, " Zeichen erlaubt.")
|
stringLen, " Zeichen erlaubt.")
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,11 +379,7 @@ func UpdateUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
userData.UserName = ""
|
userData.UserName = ""
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", userData); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,20 +394,12 @@ func UpdateUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
userData.Role); err != nil {
|
userData.Role); err != nil {
|
||||||
userData.Msg = "Aktualisierung der Benutzerdaten fehlgeschlagen."
|
userData.Msg = "Aktualisierung der Benutzerdaten fehlgeschlagen."
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/edit-user.html")
|
||||||
if err = template.Must(tmpl, err).ExecuteTemplate(w, "page-content", userData); err != nil {
|
template.Must(tmpl, err).ExecuteTemplate(w, "page-content", userData)
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,10 +425,6 @@ func DeleteUser(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
tmpl, err := template.ParseFiles(c.WebDir + "/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
tmpl = template.Must(tmpl, err)
|
||||||
if err = tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int)); err != nil {
|
tmpl.ExecuteTemplate(w, "page-content", session.Values["role"].(int))
|
||||||
log.Println(err)
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user