From 0a00051d30184c94a666638f66f1d145df855995 Mon Sep 17 00:00:00 2001 From: horus_arch Date: Mon, 18 May 2015 14:38:35 +0200 Subject: Add tos, privacy policy, noscript alert and updated the mailgraph html. --- handler.go | 45 +++++++++++++++++++++ handler_test.go | 1 + main.go | 2 + static/css/style.css | 16 ++++++++ statistics/mailgraph.cgi | 101 ++++++++++++++++++++++++++++------------------- struct.go | 1 + views/footer.html | 31 ++++++++++----- views/navbar.html | 12 ++++++ views/navbar_de.html | 14 ++++++- views/password.html | 2 +- views/password_de.html | 18 ++++----- views/privacy.html | 42 ++++++++++++++++++++ views/privacy_de.html | 42 ++++++++++++++++++++ views/register.html | 16 ++++++-- views/register_de.html | 16 ++++++-- views/tos.html | 38 ++++++++++++++++++ views/tos_de.html | 37 +++++++++++++++++ 17 files changed, 366 insertions(+), 68 deletions(-) create mode 100644 views/privacy.html create mode 100644 views/privacy_de.html create mode 100644 views/tos.html create mode 100644 views/tos_de.html diff --git a/handler.go b/handler.go index e372052..63ab5ce 100644 --- a/handler.go +++ b/handler.go @@ -45,6 +45,44 @@ func RegisterHandler(w http.ResponseWriter, r *http.Request) { } } +func PrivacyHandler(w http.ResponseWriter, r *http.Request) { + session, err := store.Get(r, "_SID") + if err != nil { + log.Println("Info: ", err) + } + session.Values["page"] = "/privacy" + + flash := Flash{} + flash.Error = session.Flashes("error") + flash.Success = session.Flashes("success") + session.Save(r, w) + + err = ExecTemplate("privacy", w, r, flash) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } +} + +func TosHandler(w http.ResponseWriter, r *http.Request) { + session, err := store.Get(r, "_SID") + if err != nil { + log.Println("Info: ", err) + } + session.Values["page"] = "/tos" + + flash := Flash{} + flash.Error = session.Flashes("error") + flash.Success = session.Flashes("success") + session.Save(r, w) + + err = ExecTemplate("tos", w, r, flash) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } +} + func CreateNewEntryHandler(w http.ResponseWriter, r *http.Request) { err := r.ParseForm() if err != nil { @@ -66,6 +104,13 @@ func CreateNewEntryHandler(w http.ResponseWriter, r *http.Request) { log.Println("Info: ", err) } + if !req.Legal { + session.AddFlash("Please accept the Terms of Service and the Privacy Policy.", "error") + session.Save(r, w) + http.Redirect(w, r, "/register", 302) + return + } + if !CompareStrings(req.Email, req.ConfirmEmail) { session.AddFlash("E-Mail don't match.", "error") session.Save(r, w) diff --git a/handler_test.go b/handler_test.go index 8bbf36a..87be720 100644 --- a/handler_test.go +++ b/handler_test.go @@ -104,6 +104,7 @@ func TestCreateNewEntryHandler(t *testing.T) { form.Set("ConfirmEmail", "createNewEntry@"+domain) form.Set("Password", "Password") form.Set("ConfirmPassword", "Password") + form.Set("Legal", "1") request, err := http.NewRequest("POST", "/create", strings.NewReader(form.Encode())) if err != nil { diff --git a/main.go b/main.go index 750fbfe..208c9bc 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,8 @@ func main() { r := mux.NewRouter() r.HandleFunc("/", IndexHandler) r.HandleFunc("/register", RegisterHandler) + r.HandleFunc("/privacy", PrivacyHandler) + r.HandleFunc("/tos", TosHandler) r.HandleFunc("/about", AboutHandler) r.HandleFunc("/howto", HowtoHandler) r.HandleFunc("/server", ServerHandler) diff --git a/static/css/style.css b/static/css/style.css index 4504e38..10666ba 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -70,3 +70,19 @@ body { .italic { font-style: italic; } +@media (min-width:570px){ + .lg-pull-right { + float: right !important; + } + .sm-display { + display: none; + } +} +@media (max-width:580px){ + .footer { + height: 60px; + } + .sm-diplay { + display: inline !important; + } +} diff --git a/statistics/mailgraph.cgi b/statistics/mailgraph.cgi index 60c81a2..f911769 100644 --- a/statistics/mailgraph.cgi +++ b/statistics/mailgraph.cgi @@ -233,45 +233,59 @@ a:hover { text-decoration: underline; }
@@ -306,8 +320,13 @@ HEADER
diff --git a/struct.go b/struct.go index a59b766..a19ed3b 100644 --- a/struct.go +++ b/struct.go @@ -46,6 +46,7 @@ type Request struct { ConfirmEmail string Password string ConfirmPassword string + Legal bool } type Flash struct { diff --git a/views/footer.html b/views/footer.html index db85f61..6581cac 100644 --- a/views/footer.html +++ b/views/footer.html @@ -2,9 +2,26 @@
@@ -19,6 +36,7 @@