这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
31 changes: 31 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down
83 changes: 80 additions & 3 deletions templates/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,85 @@
{{ define "footer" }}
</main>
<footer>
<p>&copy; 2024 Killed by *</p>
<div class="footer-content">
<div class="footer-links">
<h3>Quick Links</h3>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
<li><a href="/privacy">Privacy Policy</a></li>
<li><a href="/terms">Terms of Service</a></li>
</ul>
</div>
<div class="footer-social">
<h3>Follow Us</h3>
<ul>
<li><a href="https://twitter.com/yourprofile" target="_blank">Twitter</a></li>
<li><a href="https://facebook.com/yourprofile" target="_blank">Facebook</a></li>
<li><a href="https://instagram.com/yourprofile" target="_blank">Instagram</a></li>
<li><a href="https://linkedin.com/in/yourprofile" target="_blank">LinkedIn</a></li>
</ul>
</div>
<div class="footer-contact">
<h3>Contact Us</h3>
<p>Email: <a href="mailto:support@killedby.com">support@killedby.com</a></p>
<p>Phone: (123) 456-7890</p>
<p>Address: 123 Main St, Anytown, USA</p>
</div>
</div>
<div class="footer-bottom">
<p>&copy; 2024 Killed by *</p>
</div>
</footer>
</body>
</html>
<style>
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
main {
flex: 1;
}
footer {
background-color: #1e1e1e;
color: #e0e0e0;
padding: 20px;
box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
}
.footer-content {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
width: 100%;
max-width: 1200px;
}
.footer-links, .footer-social, .footer-contact {
margin: 20px;
}
.footer-links ul, .footer-social ul {
list-style: none;
padding: 0;
}
.footer-links ul li, .footer-social ul li {
margin: 10px 0;
}
.footer-links a, .footer-social a {
color: #bb86fc;
text-decoration: none;
}
.footer-links a:hover, .footer-social a:hover {
text-decoration: underline;
}
.footer-bottom {
margin-top: 20px;
}
</style>
{{ end }}