feat: change options
This commit is contained in:
parent
8b46beb1dd
commit
10946dcafb
2
main.go
2
main.go
@ -22,6 +22,8 @@ func main() {
|
|||||||
c.String(200, "User-agent: *\nDisallow: /")
|
c.String(200, "User-agent: *\nDisallow: /")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.GET("/options/:name", routes.ChangeOptions)
|
||||||
|
|
||||||
r.GET("/", routes.GetHome)
|
r.GET("/", routes.GetHome)
|
||||||
|
|
||||||
r.POST("/", routes.PostHome)
|
r.POST("/", routes.PostHome)
|
||||||
|
@ -9,7 +9,6 @@ body {
|
|||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
|
|
||||||
overflow: hidden;
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
color: white;
|
color: white;
|
||||||
@ -78,6 +77,10 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.options {
|
||||||
|
margin-top: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 800px) {
|
@media screen and (max-width: 800px) {
|
||||||
body {
|
body {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
|
25
src/routes/options.go
Normal file
25
src/routes/options.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package routes
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ChangeOptions(c *gin.Context) {
|
||||||
|
name := c.Param("name")
|
||||||
|
|
||||||
|
switch name {
|
||||||
|
case "images":
|
||||||
|
text := "disabled"
|
||||||
|
if c.MustGet("disable_images").(bool) {
|
||||||
|
text = "enabled"
|
||||||
|
}
|
||||||
|
c.SetCookie("disable_images", fmt.Sprintf("%t", !c.MustGet("disable_images").(bool)), 60*60*24*365*10, "/", "", false, true)
|
||||||
|
c.String(200, "Images are now %s", text)
|
||||||
|
default:
|
||||||
|
c.String(400, "400 Bad Request")
|
||||||
|
}
|
||||||
|
|
||||||
|
c.Redirect(302, "/")
|
||||||
|
}
|
@ -36,6 +36,11 @@
|
|||||||
<button class="view-button" type="submit">View</button>
|
<button class="view-button" type="submit">View</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
<div class="options">
|
||||||
|
<a class="toggle" href="/options/images"
|
||||||
|
>Toggle Image Loading</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
<p class="footer">
|
<p class="footer">
|
||||||
Brought to you by
|
Brought to you by
|
||||||
<a
|
<a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user