qtify other pages + fixed position on qts
working on showing the max upload size, just figuring out how to make it look good and where to position it. there's probably a better way to include qts in all of these pages without having to pass all of these variables
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -97,11 +99,10 @@ func main() {
|
||||
))
|
||||
mux.HandleFunc("GET /{$}", func(w http.ResponseWriter, r *http.Request) {
|
||||
data := HomePageData{
|
||||
Expiries: config.Expiries,
|
||||
}
|
||||
|
||||
if len(qts) > 0 {
|
||||
data.Qt = qts[rand.IntN(len(qts))]
|
||||
Expiries: config.Expiries,
|
||||
FileMaxSize: humanize.Bytes(uint64(config.MaxFileBytes)),
|
||||
PasteMaxSize: humanize.Bytes(uint64(config.MaxPasteBytes)),
|
||||
Qt: getRandomQt(qts),
|
||||
}
|
||||
|
||||
if len(placeholders) > 0 {
|
||||
@@ -110,21 +111,22 @@ func main() {
|
||||
|
||||
render(pages, w, "home.html", data)
|
||||
})
|
||||
mux.HandleFunc("GET /tos", staticPage(pages, "tos.html"))
|
||||
mux.HandleFunc("GET /privacy", staticPage(pages, "privacy.html"))
|
||||
mux.HandleFunc("GET /tos", staticPage(pages, "tos.html", qts))
|
||||
mux.HandleFunc("GET /privacy", staticPage(pages, "privacy.html", qts))
|
||||
mux.HandleFunc("GET /faq", func(w http.ResponseWriter, r *http.Request) {
|
||||
render(pages, w, "faq.html", map[string]any{
|
||||
"Expiries": config.Expiries,
|
||||
"Host": config.Host,
|
||||
"NormalizeMIMETypes": config.NormalizeMIMETypes,
|
||||
"Qt": getRandomQt(qts),
|
||||
})
|
||||
})
|
||||
uploads := http.NewServeMux()
|
||||
uploads.HandleFunc("GET /{id}", contentHandler(db, config, tracker))
|
||||
uploads.HandleFunc("GET /{id}/info", contentInfoHandler(db, tracker))
|
||||
mux.Handle("/", uploads)
|
||||
mux.HandleFunc("POST /upload", uploadHandler(db, config, pages))
|
||||
mux.HandleFunc("PUT /upload", uploadHandler(db, config, pages))
|
||||
mux.HandleFunc("POST /upload", uploadHandler(db, config, pages, qts))
|
||||
mux.HandleFunc("PUT /upload", uploadHandler(db, config, pages, qts))
|
||||
mux.HandleFunc("DELETE /{id}", deleteHandler(db, config))
|
||||
mux.HandleFunc("POST /{id}/delete", deleteHandler(db, config))
|
||||
mux.HandleFunc("GET /health", health)
|
||||
@@ -136,3 +138,10 @@ func main() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func getRandomQt(qts []string) string {
|
||||
if len(qts) > 0 {
|
||||
return qts[rand.IntN(len(qts))]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user