forgot the word but pages
This commit is contained in:
+1
-1
@@ -266,7 +266,7 @@ func uploadHandler(db *gorm.DB, cfg Config, pages *Pages) http.HandlerFunc {
|
||||
switch returnType {
|
||||
// html & maybe xml? cant think of other return types
|
||||
case "html":
|
||||
render(pages, w, "upload.html", response)
|
||||
pages.render(w, "upload.html", response)
|
||||
case "redirect":
|
||||
http.Redirect(w, r, "/"+id, http.StatusSeeOther)
|
||||
default:
|
||||
|
||||
@@ -29,7 +29,7 @@ type HomePageData struct {
|
||||
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")
|
||||
if err := pages.Templates.ExecuteTemplate(w, name, data); err != nil {
|
||||
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 {
|
||||
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)
|
||||
|
||||
render(pages, w, "result.html", map[string]any{
|
||||
pages.render(w, "result.html", map[string]any{
|
||||
"Qt": getRandomQt(pages.Qts),
|
||||
"Title": title,
|
||||
"Message": message,
|
||||
@@ -118,13 +118,13 @@ func homeHandler(pages *Pages, cfg Config) http.HandlerFunc {
|
||||
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 {
|
||||
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,
|
||||
"Host": cfg.Host,
|
||||
"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)
|
||||
return
|
||||
}
|
||||
render(pages, w, "report.html", map[string]any{
|
||||
pages.render(w, "report.html", map[string]any{
|
||||
"Qt": getRandomQt(pages.Qts),
|
||||
"Challenge": map[string]any{
|
||||
"Data": hex.EncodeToString(challenge.Data),
|
||||
|
||||
Reference in New Issue
Block a user