tos and privacy (these are probably shit)
also implemented random paste placeholder text, got bored and dont feel like implementing real features
This commit is contained in:
@@ -38,6 +38,8 @@ func main() {
|
||||
"templates/home.html",
|
||||
"templates/header.html",
|
||||
"templates/upload.html",
|
||||
"templates/tos.html",
|
||||
"templates/privacy.html",
|
||||
)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@@ -60,6 +62,21 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
pastePlaceholders, err := os.ReadFile("paste-placeholders.txt")
|
||||
if err != nil && !errors.Is(err, os.ErrNotExist) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var placeholders []string
|
||||
if err == nil {
|
||||
content := strings.ReplaceAll(string(pastePlaceholders), "\r\n", "\n")
|
||||
placeholders = strings.Split(strings.TrimSpace(content), "\n")
|
||||
} else {
|
||||
placeholders = []string{
|
||||
"cmon, paste something already!",
|
||||
}
|
||||
}
|
||||
|
||||
mux := http.NewServeMux()
|
||||
fs := http.FileServer(http.Dir("static"))
|
||||
mux.Handle("GET /css/", fs)
|
||||
@@ -75,16 +92,33 @@ func main() {
|
||||
}
|
||||
|
||||
if len(qts) > 0 {
|
||||
log.Println(len(qts))
|
||||
data.Qt = qts[rand.IntN(len(qts))]
|
||||
}
|
||||
|
||||
if len(placeholders) > 0 {
|
||||
data.PastePlaceholder = placeholders[rand.IntN(len(placeholders))]
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
if err := pages.ExecuteTemplate(w, "home.html", data); err != nil {
|
||||
log.Println("render home page:", err)
|
||||
}
|
||||
})
|
||||
mux.HandleFunc("GET /tos", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
if err := pages.ExecuteTemplate(w, "tos.html", nil); err != nil {
|
||||
log.Println("render terms page:", err)
|
||||
}
|
||||
})
|
||||
mux.HandleFunc("GET /privacy", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
|
||||
if err := pages.ExecuteTemplate(w, "privacy.html", nil); err != nil {
|
||||
log.Println("render terms page:", err)
|
||||
}
|
||||
})
|
||||
mux.HandleFunc("GET /{id}", contentHandler(db, config))
|
||||
mux.HandleFunc("POST /upload", uploadHandler(db, config, pages))
|
||||
mux.HandleFunc("DELETE /{id}", deleteHandler(db, config))
|
||||
|
||||
Reference in New Issue
Block a user