package index

import (
	"net/http"

	"git.kirsle.net/apps/gosocial/pkg/templates"
)

// Static pages.

func About() http.HandlerFunc {
	tmpl := templates.Must("about.html")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if err := tmpl.Execute(w, r, nil); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	})
}

func FAQ() http.HandlerFunc {
	tmpl := templates.Must("faq.html")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if err := tmpl.Execute(w, r, nil); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	})
}

func TOS() http.HandlerFunc {
	tmpl := templates.Must("tos.html")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if err := tmpl.Execute(w, r, nil); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	})
}

func Privacy() http.HandlerFunc {
	tmpl := templates.Must("privacy.html")
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		if err := tmpl.Execute(w, r, nil); err != nil {
			http.Error(w, err.Error(), http.StatusInternalServerError)
			return
		}
	})
}
