diff --git a/go.mod b/go.mod index dc6c0d2..537da0c 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,6 @@ require ( github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect golang.org/x/image v0.18.0 // indirect - golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect + golang.org/x/net v0.27.0 // indirect golang.org/x/text v0.16.0 // indirect ) diff --git a/go.sum b/go.sum index 1516a9b..54b0769 100644 --- a/go.sum +++ b/go.sum @@ -12,5 +12,7 @@ golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0= golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= diff --git a/main.go b/main.go index 2e7e10e..4271563 100644 --- a/main.go +++ b/main.go @@ -154,6 +154,17 @@ func main() { "isFutureDate": isFutureDate, } + // Fetch custom footer if available + customFooter, err := fetchCustomFooter() + if err == nil { + err = os.WriteFile("templates/footer.html", []byte(customFooter), 0644) + if err != nil { + log.Printf("Error writing custom footer: %v", err) + } + } else { + log.Printf("Using default footer: %v", err) + } + tmpl, err := template.New("").Funcs(funcMap).ParseGlob("templates/*.html") if err != nil { log.Fatalf("Error parsing templates: %v", err) @@ -168,6 +179,26 @@ func main() { log.Fatal(http.ListenAndServe(":8080", nil)) } +func fetchCustomFooter() (string, error) { + customFooterURL := fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/main/templates/footer.html", githubUsername, githubRepository) + resp, err := http.Get(customFooterURL) + if err != nil { + return "", err + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusOK { + return "", fmt.Errorf("custom footer not found") + } + + body, err := io.ReadAll(resp.Body) + if err != nil { + return "", err + } + + return string(body), nil +} + func indexHandler(tmpl *template.Template) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { scheme := "http" diff --git a/templates/footer.html b/templates/footer.html index 7d95c23..0cf9f34 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -1,8 +1,85 @@ {{ define "footer" }} - - + {{ end }}