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 | 30 | location ((BASE URL)) { # if you have a separate subdomain for the frontend, insert '/' instead of '((BASE URL))'. |
| 31 | 31 | proxy_set_header Scheme $scheme; |
| 32 | proxy_set_header Host $host; |
| 32 | 33 | proxy_http_version 1.1; |
| 33 | 34 | proxy_pass http://((IP)):((PORT)); |
| 34 | 35 | } |
| @@ -63,6 +64,7 @@ server { |
| 63 | 64 | |
| 64 | 65 | location ((BASE URL)) { # если у вас отдельный поддомен для фронтенда, вместо '((BASE URL))' вставляйте '/' |
| 65 | 66 | proxy_set_header Scheme $scheme; |
| 67 | proxy_set_header Host $host; |
| 66 | 68 | proxy_http_version 1.1; |
| 67 | 69 | proxy_pass http://((IP)):((PORT)); |
| 68 | 70 | } |
app/router.go
+3 −4
| @@ -51,7 +51,6 @@ func Router() { |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | path := parsepath(r.URL.Path) |
| 54 | | |
| 55 | 54 | // структура с функциями |
| 56 | 55 | var skunky skunkyart |
| 57 | 56 | skunky.Writer = w |
| @@ -77,7 +76,7 @@ func Router() { |
| 77 | 76 | default: |
| 78 | 77 | skunky.ReturnHTTPError(404) |
| 79 | 78 | case "": |
| 80 | | skunky.ExecuteTemplate("html/index.htm", &CFG.BasePath) |
| 79 | skunky.ExecuteTemplate("index.htm", &CFG.BasePath) |
| 81 | 80 | case "post": |
| 82 | 81 | skunky.Deviation(path[2], path[3]) |
| 83 | 82 | case "search": |
| @@ -98,10 +97,10 @@ func Router() { |
| 98 | 97 | skunky.About() |
| 99 | 98 | case "stylesheet": |
| 100 | 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 | 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 | 112 | url.WriteString(s.Args.Get("token")) |
| 113 | 113 | |
| 114 | 114 | if CFG.Cache.Enabled { |
| 115 | | os.Mkdir(CFG.Cache.Path, 0700) |
| 116 | 115 | fname := CFG.Cache.Path + "/" + base64.StdEncoding.EncodeToString([]byte(subdomain+path)) |
| 117 | 116 | file, e := os.Open(fname) |
| 118 | 117 | |
| @@ -138,6 +137,7 @@ func (s skunkyart) DownloadAndSendMedia(subdomain, path string) { |
| 138 | 137 | |
| 139 | 138 | func InitCacheSystem() { |
| 140 | 139 | c := &CFG.Cache |
| 140 | os.Mkdir(CFG.Cache.Path, 0700) |
| 141 | 141 | for { |
| 142 | 142 | dir, e := os.Open(c.Path) |
| 143 | 143 | try(e) |
| @@ -175,10 +175,9 @@ func CopyTemplatesToMemory() { |
| 175 | 175 | try_with_exitstatus(e, 1) |
| 176 | 176 | |
| 177 | 177 | for _, x := range dir { |
| 178 | | n := dirname + "/" + x.Name() |
| 179 | | file, e := os.ReadFile(n) |
| 178 | file, e := os.ReadFile(dirname + "/" + x.Name()) |
| 180 | 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 | 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 | 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 | 265 | } else { |
| 266 | 266 | s.ReturnHTTPError(400) |
| 267 | 267 | } |
| @@ -274,7 +274,7 @@ func (s skunkyart) DD() { |
| 274 | 274 | More: dd.HasMore, |
| 275 | 275 | }) |
| 276 | 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 | |
| 348 | 348 | func (s skunkyart) Emojitar(name string) { |
| @@ -361,5 +361,5 @@ func (s skunkyart) About() { |
| 361 | 361 | s.Templates.About.Nsfw = CFG.Nsfw |
| 362 | 362 | s.Templates.About.Proxy = CFG.Proxy |
| 363 | 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 | 3 | "base-path": "/", |
| 4 | 4 | "cache": { |
| 5 | 5 | "enabled": true, |
| 6 | | "path": "cache", |
| 6 | "path": "/home/skunk/projects/skunkyart/cache", |
| 7 | 7 | "lifetime": null, |
| 8 | 8 | "max-size": 100000, |
| 9 | 9 | "update-interval": 5 |
| 10 | 10 | }, |
| 11 | 11 | "dirs-to-memory": [ |
| 12 | | "html", |
| 13 | | "css" |
| 12 | "/home/skunk/projects/skunkyart/html", |
| 13 | "/home/skunk/projects/skunkyart/css" |
| 14 | 14 | ], |
| 15 | | "download-proxy": "", |
| 15 | "download-proxy": null, |
| 16 | 16 | "proxy": true, |
| 17 | 17 | "nsfw": false |
| 18 | | } |
| \ No newline at end of file |
| 18 | } |