forgot the word but pages

This commit is contained in:
2026-11-21 15:33:39 -05:00
parent 2f27f8bd4f
commit 741b91b637
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -266,7 +266,7 @@ func uploadHandler(db *gorm.DB, cfg Config, pages *Pages) http.HandlerFunc {
switch returnType { switch returnType {
// html & maybe xml? cant think of other return types // html & maybe xml? cant think of other return types
case "html": case "html":
render(pages, w, "upload.html", response) pages.render(w, "upload.html", response)
case "redirect": case "redirect":
http.Redirect(w, r, "/"+id, http.StatusSeeOther) http.Redirect(w, r, "/"+id, http.StatusSeeOther)
default: default:
+6 -6
View File
@@ -29,7 +29,7 @@ type HomePageData struct {
PasteMaxSize string PasteMaxSize string
} }
func render(pages *Pages, w http.ResponseWriter, name string, data any) { func (pages *Pages) render(w http.ResponseWriter, name string, data any) {
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
if err := pages.Templates.ExecuteTemplate(w, name, data); err != nil { if err := pages.Templates.ExecuteTemplate(w, name, data); err != nil {
log.Printf("render %s: %v", name, err) log.Printf("render %s: %v", name, err)
@@ -38,7 +38,7 @@ func render(pages *Pages, w http.ResponseWriter, name string, data any) {
func staticPage(pages *Pages, name string) http.HandlerFunc { func staticPage(pages *Pages, name string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
render(pages, w, name, getRandomQt(pages.Qts)) pages.render(w, name, getRandomQt(pages.Qts))
} }
} }
@@ -50,7 +50,7 @@ func resultPage(pages *Pages, title string, message string, statusCode ...int) h
} }
w.WriteHeader(code) w.WriteHeader(code)
render(pages, w, "result.html", map[string]any{ pages.render(w, "result.html", map[string]any{
"Qt": getRandomQt(pages.Qts), "Qt": getRandomQt(pages.Qts),
"Title": title, "Title": title,
"Message": message, "Message": message,
@@ -118,13 +118,13 @@ func homeHandler(pages *Pages, cfg Config) http.HandlerFunc {
data.PastePlaceholder = pages.Placeholders[rand.IntN(len(pages.Placeholders))] data.PastePlaceholder = pages.Placeholders[rand.IntN(len(pages.Placeholders))]
} }
render(pages, w, "home.html", data) pages.render(w, "home.html", data)
} }
} }
func faqHandler(pages *Pages, cfg Config) http.HandlerFunc { func faqHandler(pages *Pages, cfg Config) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
render(pages, w, "faq.html", map[string]any{ pages.render(w, "faq.html", map[string]any{
"Expiries": cfg.Expiries, "Expiries": cfg.Expiries,
"Host": cfg.Host, "Host": cfg.Host,
"NormalizeMIMETypes": cfg.NormalizeMIMETypes, "NormalizeMIMETypes": cfg.NormalizeMIMETypes,
@@ -140,7 +140,7 @@ func reportPageHandler(pages *Pages, store *ChallengeStore, cfg Config) http.Han
http.Error(w, "failed to generate PoW challenge", http.StatusInternalServerError) http.Error(w, "failed to generate PoW challenge", http.StatusInternalServerError)
return return
} }
render(pages, w, "report.html", map[string]any{ pages.render(w, "report.html", map[string]any{
"Qt": getRandomQt(pages.Qts), "Qt": getRandomQt(pages.Qts),
"Challenge": map[string]any{ "Challenge": map[string]any{
"Data": hex.EncodeToString(challenge.Data), "Data": hex.EncodeToString(challenge.Data),