This commit is contained in:
partisan 2024-08-22 19:10:14 +02:00
parent b890637222
commit d69f561c55

18
main.go
View file

@ -106,6 +106,16 @@ func main() {
// Serve static files (CSS, JS, etc.) from the /static directory // Serve static files (CSS, JS, etc.) from the /static directory
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir)))) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
// Serve downloads.html at /downloads
http.HandleFunc("/download", func(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "download.html", nil)
})
// Serve download-linux.html at /download-linux
http.HandleFunc("/download-linux", func(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "download-linux.html", nil)
})
// Define route handlers // Define route handlers
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" { if r.URL.Path == "/" {
@ -452,14 +462,6 @@ func updateBlogEntries(blogName, path string) {
log.Printf("Created new blog %s with entry %d", blogName, entry.Number) log.Printf("Created new blog %s with entry %d", blogName, entry.Number)
} }
func getFileModTime(path string) (time.Time, error) {
info, err := os.Stat(path)
if err != nil {
return time.Time{}, err
}
return info.ModTime(), nil
}
func sendNotifications(entry BlogEntry) { func sendNotifications(entry BlogEntry) {
message := fmt.Sprintf("New blog post published!\nTitle: %s\nDescription: %s\nAuthor: %s\nDate: %s", message := fmt.Sprintf("New blog post published!\nTitle: %s\nDescription: %s\nAuthor: %s\nDate: %s",
entry.Title, entry.Description, entry.Author, entry.Date.Format("2006-01-02 15:04")) entry.Title, entry.Description, entry.Author, entry.Date.Format("2006-01-02 15:04"))