From fd2d30bab62144ed5cd79980c355ba80f59668bb Mon Sep 17 00:00:00 2001
From: Alicia
Date: Sat, 23 Feb 2019 14:37:47 +0000
Subject: [PATCH] Add some stuff
---
profbackground.go | 29 ++++++++++++++++++++++++++
templates/settings/profbackground.html | 17 ++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/profbackground.go b/profbackground.go
index 5588f8d..5766d49 100644
--- a/profbackground.go
+++ b/profbackground.go
@@ -73,6 +73,35 @@ func profBackground(c *gin.Context) {
return
}
saveProfileBackground(ctx, 2, col)
+ case "3":
+ // image
+ file, _, err := c.Request.FormFile("value")
+ if err != nil {
+ m = errorMessage{T(c, "An error occurred.")}
+ return
+ }
+ img, _, err := image.Decode(file)
+ if err != nil {
+ m = errorMessage{T(c, "An error occurred.")}
+ return
+ }
+ img = resize.Thumbnail(2496, 1404, img, resize.Bilinear)
+ f, err := os.Create(fmt.Sprintf("static/profbackgrounds/%d.gif", ctx.User.ID))
+ defer f.Close()
+ if err != nil {
+ m = errorMessage{T(c, "An error occurred.")}
+ c.Error(err)
+ return
+ }
+ err = jpeg.Encode(f, img, &jpeg.Options{
+ Quality: 88,
+ })
+ if err != nil {
+ m = errorMessage{T(c, "We were not able to save your profile background.")}
+ c.Error(err)
+ return
+ }
+ saveProfileBackground(ctx, 1, fmt.Sprintf("%d.gif?%d", ctx.User.ID, time.Now().Unix()))
}
}
diff --git a/templates/settings/profbackground.html b/templates/settings/profbackground.html
index ca6c013..0c8b20d 100644
--- a/templates/settings/profbackground.html
+++ b/templates/settings/profbackground.html
@@ -3,7 +3,6 @@ Handler=/settings/profbackground
TitleBar=Profile background
KyutGrill=settings2.jpg
Include=menu.html
-MinPrivileges=6
AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.js
*/}}
{{ define "tpl" }}
@@ -21,6 +20,7 @@ AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jque
+
@@ -67,6 +67,21 @@ AdditionalJS=https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jque
+