Skip to content

Commit

Permalink
Add unstyled privacy policy
Browse files Browse the repository at this point in the history
  • Loading branch information
theandrew168 committed Oct 19, 2024
1 parent 12711ae commit 5ad1146
Show file tree
Hide file tree
Showing 4 changed files with 429 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func Handler(
// The main application routes start here.
mux.Handle("GET /{$}", HandleIndexPage(find))

// Documentation routes.
mux.Handle("GET /privacy", HandlePrivacyPolicy())

// Check if the debug auth method should be enabled.
enableDebugAuth := os.Getenv("ENABLE_DEBUG_AUTH") != ""
if enableDebugAuth {
Expand Down Expand Up @@ -127,6 +130,7 @@ func Handler(
mux.Handle("GET /accounts", requireAdmin(HandleAccountList(repo)))
mux.Handle("POST /accounts/{accountID}/delete", requireAdmin(HandleAccountDeleteForm(repo)))

// Debug endpoint for testing toasts.
mux.HandleFunc("GET /toast", func(w http.ResponseWriter, r *http.Request) {
cookie := util.NewSessionCookie(util.ToastCookieName, "Toasts are awesome!")
http.SetCookie(w, &cookie)
Expand Down
37 changes: 37 additions & 0 deletions backend/web/page/privacy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package page

import (
_ "embed"
"html/template"
"io"

"github.com/theandrew168/bloggulus/backend/web/layout"
)

//go:embed privacy.html
var PrivacyPolicyHTML string

type PrivacyPolicyData struct {
layout.BaseData
}

type PrivacyPolicyPage struct {
tmpl *template.Template
}

func NewPrivacyPolicy() *PrivacyPolicyPage {
sources := []string{
layout.BaseHTML,
PrivacyPolicyHTML,
}

tmpl := newTemplate("default", sources)
page := PrivacyPolicyPage{
tmpl: tmpl,
}
return &page
}

func (p *PrivacyPolicyPage) Render(w io.Writer, data PrivacyPolicyData) error {
return p.tmpl.ExecuteTemplate(w, "default", data)
}
Loading

0 comments on commit 5ad1146

Please sign in to comment.