aboutsummaryrefslogtreecommitdiff
path: root/app/util.go
diff options
context:
space:
mode:
authorlost+skunk <[email protected]>2024-09-23 09:38:32 +0300
committerlost+skunk <[email protected]>2024-09-23 09:38:32 +0300
commit191984b31ef228c4077904a2831a2af593352670 (patch)
tree33d8dd464d525ce2ad8c92a749436f1c12442800 /app/util.go
parentc39399403e031a8c1ad53969770e4261d2c9e7aa (diff)
downloadskunky-art-1.3.2.tar.gz
skunky-art-1.3.2.tar.bz2
skunky-art-1.3.2.zip
v1.3.2v1.3.2
Diffstat (limited to 'app/util.go')
-rw-r--r--app/util.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/app/util.go b/app/util.go
index c698090..9c8d400 100644
--- a/app/util.go
+++ b/app/util.go
@@ -1,6 +1,7 @@
package app
import (
+ "encoding/json"
"io"
"net/http"
"net/url"
@@ -40,18 +41,26 @@ func restore() {
}
var instances []byte
+var About instanceAbout
func RefreshInstances() {
for {
func() {
defer restore()
instances = Download("https://git.macaw.me/skunky/SkunkyArt/raw/branch/master/instances.json").Body
+ try(json.Unmarshal(instances, &About))
}()
time.Sleep(1 * time.Hour)
}
}
// some crap for frontend
+type instanceAbout struct {
+ Proxy bool
+ Nsfw bool
+ Instances []settings
+}
+
type skunkyart struct {
Writer http.ResponseWriter
@@ -63,15 +72,11 @@ type skunkyart struct {
BasePath, Endpoint string
Query, QueryRaw string
- API API
- Version string
+ API API
+ Version string
Templates struct {
- About struct {
- Proxy bool
- Nsfw bool
- Instances []settings
- }
+ About instanceAbout
SomeList string
DDStrips string
@@ -132,7 +137,7 @@ func UrlBuilder(strs ...string) string {
str.WriteString(CFG.URI)
for n, x := range strs {
str.WriteString(x)
- if n := n+1; n < l && len(strs[n]) != 0 && !(strs[n][0] == '?' || strs[n][0] == '&') && !(x[0] == '?' || x[0] == '&') {
+ if n := n + 1; n < l && len(strs[n]) != 0 && !(strs[n][0] == '?' || strs[n][0] == '&') && !(x[0] == '?' || x[0] == '&') {
str.WriteString("/")
}
}
@@ -215,6 +220,8 @@ func ParseMedia(media devianter.Media, thumb ...int) string {
filename = "image.gif"
}
return UrlBuilder("media", "file", mediaUrl[:dot], mediaUrl[dot+11:], "&filename=", filename)
+ } else if !CFG.Proxy {
+ return mediaUrl
}
return ""
}