Add caching headers to static files, and fix explicit width and height (closes #52)

Signed-off-by: Odyssey <hi@odyssey346.dev>
This commit is contained in:
Odyssey
2023-02-08 17:32:22 +01:00
parent 34fef31226
commit a41e5ac009
4 changed files with 16 additions and 11 deletions
+4 -1
View File
@@ -24,4 +24,7 @@ go.work
tmp/
# Gothub binary.
gothub
gothub
# Fiber compressed files
*.fiber.gz
-4
View File
@@ -42,10 +42,6 @@ main {
padding: 8px;
}
.navbarImg {
height: 30px;
}
.indexGitHub {
background: #252525;
color: #fff;
+11 -5
View File
@@ -74,12 +74,18 @@ func Serve() {
},
})
staticConfig := fiber.Static{
Compress: true,
// Cache-Control: max-age=31536000
MaxAge: 31536000,
}
app.Get("/", pages.HandleIndex)
app.Static("/css", "./public/css")
app.Static("/fonts", "./public/fonts")
app.Static("/robots.txt", "./public/robots.txt")
app.Static("/favicon.ico", "./public/assets/favicon.ico")
app.Static("/logo.svg", "./public/assets/logo.svg")
app.Static("/css", "./public/css", staticConfig)
app.Static("/fonts", "./public/fonts", staticConfig)
app.Static("/robots.txt", "./public/robots.txt", staticConfig)
app.Static("/favicon.ico", "./public/assets/favicon.ico", staticConfig)
app.Static("/logo.svg", "./public/assets/logo.svg", staticConfig)
app.Get("/explore", ratelimiter, pages.HandleExplore)
app.Get("/:user", ratelimiter, pages.HandleUser)
app.Get("/avatar/:id", func(c *fiber.Ctx) error {
+1 -1
View File
@@ -13,7 +13,7 @@
<body>
<nav>
<div class="navbar">
<a href="/" style="text-decoration: none;" class="brand"><img src="/logo.svg" class="navbarImg" alt="GotHub" /><b class="navbarSlogan">GotHub (alpha)</b></a>
<a href="/" style="text-decoration: none;" class="brand"><img src="/logo.svg" class="navbarImg" height="30" width="30" alt="GotHub" /><b class="navbarSlogan">GotHub (alpha)</b></a>
<div class="navbarLinks">
<a href="/explore">Explore</a>
<a href="https://codeberg.org/gothub/gothub">Source code</a>