Commit e02174cb71

e02174cb710e6d6abd642f03e64ce91bbac38130

parent: 4b3bf2c6a0

Unsigned

lost+skunk <skunky@ebloid.ru> · 2024-07-13 20:55 UTC

Исправление некоторых обосрамсов

Layout: unified · split

README.md +2
@@ -29,6 +29,7 @@ server {
29 29
30 location ((BASE URL)) { # if you have a separate subdomain for the frontend, insert '/' instead of '((BASE URL))'. 30 location ((BASE URL)) { # if you have a separate subdomain for the frontend, insert '/' instead of '((BASE URL))'.
31 proxy_set_header Scheme $scheme; 31 proxy_set_header Scheme $scheme;
32 proxy_set_header Host $host;
32 proxy_http_version 1.1; 33 proxy_http_version 1.1;
33 proxy_pass http://((IP)):((PORT)); 34 proxy_pass http://((IP)):((PORT));
34 } 35 }
@@ -63,6 +64,7 @@ server {
63 64
64 location ((BASE URL)) { # если у вас отдельный поддомен для фронтенда, вместо '((BASE URL))' вставляйте '/' 65 location ((BASE URL)) { # если у вас отдельный поддомен для фронтенда, вместо '((BASE URL))' вставляйте '/'
65 proxy_set_header Scheme $scheme; 66 proxy_set_header Scheme $scheme;
67 proxy_set_header Host $host;
66 proxy_http_version 1.1; 68 proxy_http_version 1.1;
67 proxy_pass http://((IP)):((PORT)); 69 proxy_pass http://((IP)):((PORT));
68 } 70 }
app/router.go +3 −4
@@ -51,7 +51,6 @@ func Router() {
51 } 51 }
52 52
53 path := parsepath(r.URL.Path) 53 path := parsepath(r.URL.Path)
54
55 // структура с функциями 54 // структура с функциями
56 var skunky skunkyart 55 var skunky skunkyart
57 skunky.Writer = w 56 skunky.Writer = w
@@ -77,7 +76,7 @@ func Router() {
77 default: 76 default:
78 skunky.ReturnHTTPError(404) 77 skunky.ReturnHTTPError(404)
79 case "": 78 case "":
80 skunky.ExecuteTemplate("html/index.htm", &CFG.BasePath) 79 skunky.ExecuteTemplate("index.htm", &CFG.BasePath)
81 case "post": 80 case "post":
82 skunky.Deviation(path[2], path[3]) 81 skunky.Deviation(path[2], path[3])
83 case "search": 82 case "search":
@@ -98,10 +97,10 @@ func Router() {
98 skunky.About() 97 skunky.About()
99 case "stylesheet": 98 case "stylesheet":
100 w.Header().Add("content-type", "text/css") 99 w.Header().Add("content-type", "text/css")
101 io.WriteString(w, Templates["css/skunky.css"]) 100 io.WriteString(w, Templates["skunky.css"])
102 } 101 }
103 } 102 }
104 103
105 http.HandleFunc("/", handle) 104 http.HandleFunc("/", handle)
106 http.ListenAndServe(CFG.Listen, nil) 105 try_with_exitstatus(http.ListenAndServe(CFG.Listen, nil), 1)
107} 106}
app/util.go +3 −4
@@ -112,7 +112,6 @@ func (s skunkyart) DownloadAndSendMedia(subdomain, path string) {
112 url.WriteString(s.Args.Get("token")) 112 url.WriteString(s.Args.Get("token"))
113 113
114 if CFG.Cache.Enabled { 114 if CFG.Cache.Enabled {
115 os.Mkdir(CFG.Cache.Path, 0700)
116 fname := CFG.Cache.Path + "/" + base64.StdEncoding.EncodeToString([]byte(subdomain+path)) 115 fname := CFG.Cache.Path + "/" + base64.StdEncoding.EncodeToString([]byte(subdomain+path))
117 file, e := os.Open(fname) 116 file, e := os.Open(fname)
118 117
@@ -138,6 +137,7 @@ func (s skunkyart) DownloadAndSendMedia(subdomain, path string) {
138 137
139func InitCacheSystem() { 138func InitCacheSystem() {
140 c := &CFG.Cache 139 c := &CFG.Cache
140 os.Mkdir(CFG.Cache.Path, 0700)
141 for { 141 for {
142 dir, e := os.Open(c.Path) 142 dir, e := os.Open(c.Path)
143 try(e) 143 try(e)
@@ -175,10 +175,9 @@ func CopyTemplatesToMemory() {
175 try_with_exitstatus(e, 1) 175 try_with_exitstatus(e, 1)
176 176
177 for _, x := range dir { 177 for _, x := range dir {
178 n := dirname + "/" + x.Name() 178 file, e := os.ReadFile(dirname + "/" + x.Name())
179 file, e := os.ReadFile(n)
180 try_with_exitstatus(e, 1) 179 try_with_exitstatus(e, 1)
181 Templates[n] = string(file) 180 Templates[x.Name()] = string(file)
182 } 181 }
183 } 182 }
184} 183}
app/wrapper.go +5 −5
@@ -216,7 +216,7 @@ func (s skunkyart) GRUser() {
216 } 216 }
217 217
218 if !s.Atom { 218 if !s.Atom {
219 s.ExecuteTemplate("html/gruser.htm", &s) 219 s.ExecuteTemplate("gruser.htm", &s)
220 } 220 }
221} 221}
222 222
@@ -261,7 +261,7 @@ func (s skunkyart) Deviation(author, postname string) {
261 261
262 post.Comments = s.ParseComments(devianter.CommentsFunc(id, post.Post.Comments.Cursor, s.Page, 1)) 262 post.Comments = s.ParseComments(devianter.CommentsFunc(id, post.Post.Comments.Cursor, s.Page, 1))
263 263
264 s.ExecuteTemplate("html/deviantion.htm", &s) 264 s.ExecuteTemplate("deviantion.htm", &s)
265 } else { 265 } else {
266 s.ReturnHTTPError(400) 266 s.ReturnHTTPError(400)
267 } 267 }
@@ -274,7 +274,7 @@ func (s skunkyart) DD() {
274 More: dd.HasMore, 274 More: dd.HasMore,
275 }) 275 })
276 if !s.Atom { 276 if !s.Atom {
277 s.ExecuteTemplate("html/list.htm", &s) 277 s.ExecuteTemplate("list.htm", &s)
278 } 278 }
279} 279}
280 280
@@ -342,7 +342,7 @@ func (s skunkyart) Search() {
342 }) 342 })
343 } 343 }
344 344
345 s.ExecuteTemplate("html/search.htm", &s) 345 s.ExecuteTemplate("search.htm", &s)
346} 346}
347 347
348func (s skunkyart) Emojitar(name string) { 348func (s skunkyart) Emojitar(name string) {
@@ -361,5 +361,5 @@ func (s skunkyart) About() {
361 s.Templates.About.Nsfw = CFG.Nsfw 361 s.Templates.About.Nsfw = CFG.Nsfw
362 s.Templates.About.Proxy = CFG.Proxy 362 s.Templates.About.Proxy = CFG.Proxy
363 try(json.Unmarshal([]byte(Templates["instances.json"]), &s.Templates.About)) 363 try(json.Unmarshal([]byte(Templates["instances.json"]), &s.Templates.About))
364 s.ExecuteTemplate("html/about.htm", &s) 364 s.ExecuteTemplate("about.htm", &s)
365} 365}
config.example.json +5 −5
@@ -3,16 +3,16 @@
3 "base-path": "/", 3 "base-path": "/",
4 "cache": { 4 "cache": {
5 "enabled": true, 5 "enabled": true,
6 "path": "cache", 6 "path": "/home/skunk/projects/skunkyart/cache",
7 "lifetime": null, 7 "lifetime": null,
8 "max-size": 100000, 8 "max-size": 100000,
9 "update-interval": 5 9 "update-interval": 5
10 }, 10 },
11 "dirs-to-memory": [ 11 "dirs-to-memory": [
12 "html", 12 "/home/skunk/projects/skunkyart/html",
13 "css" 13 "/home/skunk/projects/skunkyart/css"
14 ], 14 ],
15 "download-proxy": "", 15 "download-proxy": null,
16 "proxy": true, 16 "proxy": true,
17 "nsfw": false 17 "nsfw": false
18}\ No newline at end of file 18}