diff --git a/.dockerignore b/.dockerignore deleted file mode 100755 index 6833fbe..0000000 --- a/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -cache -compose.yaml -*.json -LICENSE -*.md -services diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index 63ca398..b52ba21 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ **/cache -**/compose.yaml **/config.json **/skunkyart **/skunkyart-* diff --git a/Dockerfile b/Dockerfile deleted file mode 100755 index fdc1919..0000000 --- a/Dockerfile +++ /dev/null @@ -1,23 +0,0 @@ -ARG GO_VERSION=1.18 - -FROM --platform=$BUILDPLATFORM golang:${GO_VERSION} AS build -ARG TARGETOS -ARG TARGETARCH - -WORKDIR /build -COPY . . -RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} GOOS=${TARGETOS} go build -ldflags "-s -w -extldflags '-static'" && \ - echo "skunkyart:x:10000:10000:SkunkyArt user:/:/sbin/nologin" > /etc/minimal-passwd && \ - echo "skunkyart:x:10000:" > /etc/minimal-group - -FROM scratch - -COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=build /build/static /static -COPY --from=build /build/skunkyart /skunkyart -COPY --from=build /etc/minimal-passwd /etc/passwd -COPY --from=build /etc/minimal-group /etc/group - -USER skunkyart - -ENTRYPOINT ["/skunkyart"] diff --git a/INSTANCES.md b/INSTANCES.md old mode 100755 new mode 100644 index 38cd5bb..32b0e50 --- a/INSTANCES.md +++ b/INSTANCES.md @@ -2,10 +2,8 @@ JSON variant should be used from master — https://git.macaw.me/skunky/SkunkyAr |Instance|Yggdrasil|I2P|Tor|NSFW|Proxifying|Modified Sources|Country| |:------:|:-------:|:-:|:-:|:--:|:--------:|:--------------:|:-----:| -|[lost-skunk.cc](https://lost-skunk.cc/skunkyart)|[Yes](http://[201:f137:d1ac:920e:cd42:bfd1:1e83:da1d]/skunkyart)|No|No| No | Yes | No | Finland | -|[orehus.club](https://sa.orehus.club)|No|No|No| Yes | No | No | Germany | +|[skunky.ebloid.ru](https://skunky.ebloid.ru/art)|[Yes](http://[201:eba5:d1fc:bf7b:cfcb:a811:4b8b:7ea3]/art)|No|No| No | Yes | No | Russia | +|[clovius.club](https://skunky.clovius.club)|No|No|No| Yes | Yes | No | Sweden | |[bloat.cat](https://skunky.bloat.cat)|No|No|No| Yes | Yes | No | Germany | |[lumaeris.com](https://skunkyart.lumaeris.com)|No|No|No| Yes | Yes | No | Germany | -|[art.bloat.cat](https://art.bloat.cat)|No|No|No| Yes | Yes | No | Germany | -|[dc09.ru](https://sa.dc09.ru)|No|No|No| No | Yes | No | Russia | -|[opnxng.com](https://da.opnxng.com)|No|No|No| Yes | Yes | No | Singapore | +|[art.bloat.cat](https://art.bloat.cat)|No|No|No| Yes | Yes | No | Germany | \ No newline at end of file diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 index e5f404d..b61b0bd --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ -> [!NOTE] -> Currently, due to school, I cannot actively develop this project :( -> However, this does not mean that development has stopped. Just wait for the summer. For questions, write either to the Matrix room or to me in DM. - SkunkyArt -[![Matrix room](https://img.shields.io/badge/matrix-000000?style=for-the-badge&logo=Matrix&logoColor=white)](https://go.kde.org/matrix/#/#skunkyart:gnulinux.club) +[![Matrix room](https://img.shields.io/badge/matrix-000000?style=for-the-badge&logo=Matrix&logoColor=white)](https://go.kde.org/matrix/#/#skunkyart:ebloid.ru) Instances: [`INSTANCES.md`](/skunky/SkunkyArt/src/branch/master/INSTANCES.md) @@ -25,7 +21,6 @@ To do this, you must either make a PR by adding your instance to the `instances. 1. the Instance must not use Cloudflare. 2. If your instance has modified source code, you need to publish it to any free platform. For example, Github and Gitlab are not. ## Acknowledgements -* [vlnst](https://git.bloat.cat/vlnst) — wrote a Docker file. * [Лис⚛](https://go.kde.org/matrix/#/@fox:matrix.org) — helped me understand Go and gave me a lot of useful advice on this language. * [meoww](https://codeberg.org/meoww) — translated some sentences into English and wrote a service for openrc @@ -46,6 +41,5 @@ SkunkyArt 🦨 — альтернативный фронтенд к DeviantArt, 1. Инстанс не должен использовать Cloudflare итп. 2. Если ваш инстанс имеет модифицированный исходный код, то вам нужно опубликовать его на любую свободную площадку. Например, Github и Gitlab таковыми не являются. ## Благодарности -* [vlnst](https://git.bloat.cat/vlnst) — написал Docker-файл. * [Лис⚛](https://go.kde.org/matrix/#/@fox:matrix.org) — помог разобраться в Go и много чего полезного посоветовал по этому языку. * [meoww](https://codeberg.org/meoww) — перевела некоторые предложения на английский язык и написала сервис для openrc \ No newline at end of file diff --git a/REDIRECTS.md b/REDIRECTS.md old mode 100755 new mode 100644 diff --git a/SETUP-RU.md b/SETUP-RU.md old mode 100755 new mode 100644 diff --git a/SETUP.md b/SETUP.md old mode 100755 new mode 100644 diff --git a/TODO.md b/TODO.md old mode 100755 new mode 100644 diff --git a/app/api.go b/app/api.go old mode 100755 new mode 100644 index d2a5655..048bc2a --- a/app/api.go +++ b/app/api.go @@ -41,18 +41,12 @@ func (a API) Error(description string, status int) { func (a API) sendMedia(d *devianter.Deviation) { mediaUrl, name := devianter.UrlFromMedia(d.Media) a.main.SetFilename(name) - if len(mediaUrl) != 0 { - return - } - if CFG.Proxy { + if len(mediaUrl) != 0 { mediaUrl = mediaUrl[21:] dot := strings.Index(mediaUrl, ".") a.main.Writer.Header().Del("Content-Type") a.main.DownloadAndSendMedia(mediaUrl[:dot], mediaUrl[dot+11:]) - } else { - a.main.Writer.Header().Add("Location", mediaUrl) - a.main.Writer.WriteHeader(302) } } diff --git a/app/cache.go b/app/cache.go old mode 100755 new mode 100644 index e03db67..f9225be --- a/app/cache.go +++ b/app/cache.go @@ -38,7 +38,17 @@ func (s skunkyart) DownloadAndSendMedia(subdomain, path string) { fileName := sha1.Sum([]byte(subdomain + path)) filePath := CFG.Cache.Path + "/" + hex.EncodeToString(fileName[:]) - c := func() { + mx.Lock() + if tempFS[fileName] == nil { + tempFS[fileName] = &file{} + } + mx.Unlock() + + if tempFS[fileName].Content != nil { + response = tempFS[fileName].Content + tempFS[fileName].Score += 2 + break + } else { file, err := os.Open(filePath) if err != nil { if dwnld := Download(url.String()); dwnld.Status == 200 && dwnld.Headers["Content-Type"][0][:5] == "image" { @@ -53,44 +63,27 @@ func (s skunkyart) DownloadAndSendMedia(subdomain, path string) { try(e) response = file } - } - if CFG.Cache.MemCache { - mx.Lock() - if tempFS[fileName] == nil { - tempFS[fileName] = &file{} - } - mx.Unlock() + go func() { + defer restore() - if tempFS[fileName].Content != nil { - response = tempFS[fileName].Content - tempFS[fileName].Score += 2 - break - } else { - c() - go func() { - defer restore() + mx.RLock() + tempFS[fileName].Content = response + mx.RUnlock() - mx.RLock() - tempFS[fileName].Content = response - mx.RUnlock() + for { + time.Sleep(1 * time.Minute) - for { - time.Sleep(1 * time.Minute) - - mx.Lock() - if tempFS[fileName].Score <= 0 { - delete(tempFS, fileName) - mx.Unlock() - return - } - tempFS[fileName].Score-- + mx.Lock() + if tempFS[fileName].Score <= 0 { + delete(tempFS, fileName) mx.Unlock() + return } - }() - } - } else { - c() + tempFS[fileName].Score-- + mx.Unlock() + } + }() } case CFG.Proxy: dwnld := Download(url.String()) @@ -119,7 +112,6 @@ func InitCacheSystem() { println(err.Error()) } - var total int64 for _, file := range dir { fileName := c.Path + "/" + file.Name() fileInfo, err := file.Info() @@ -136,15 +128,9 @@ func InitCacheSystem() { } } - total += fileInfo.Size() - // if c.MaxSize != 0 && fileInfo.Size() > c.MaxSize { - // try(os.RemoveAll(fileName)) - // } - } - - if c.MaxSize != 0 && total > c.MaxSize { - try(os.RemoveAll(c.Path)) - os.Mkdir(c.Path, 0700) + if c.MaxSize != 0 && fileInfo.Size() > c.MaxSize { + try(os.RemoveAll(fileName)) + } } time.Sleep(time.Second * time.Duration(c.UpdateInterval)) diff --git a/app/cli.go b/app/cli.go old mode 100755 new mode 100644 diff --git a/app/config.go b/app/config.go old mode 100755 new mode 100644 index 813453c..2ba39a9 --- a/app/config.go +++ b/app/config.go @@ -12,13 +12,12 @@ import ( ) var Release struct { - Version string + Version string Description string } type cache_config struct { Enabled bool - MemCache bool `json:"memcache"` Path string MaxSize int64 `json:"max-size"` Lifetime string @@ -94,9 +93,9 @@ func ExecuteConfig() { About = instanceAbout{ Proxy: CFG.Proxy, - Nsfw: CFG.Nsfw, + Nsfw: CFG.Nsfw, } - + static.StaticPath = CFG.StaticPath devianter.UserAgent = CFG.UserAgent } diff --git a/app/parsers.go b/app/parsers.go old mode 100755 new mode 100644 index 192a88d..b7f15fd --- a/app/parsers.go +++ b/app/parsers.go @@ -46,7 +46,7 @@ func (s skunkyart) ParseComments(c devianter.Comments, daError devianter.Error) if x.Parent > 0 { cmmts.WriteString(` In reply to `) diff --git a/app/router.go b/app/router.go old mode 100755 new mode 100644 index ac65c3d..eddf0a9 --- a/app/router.go +++ b/app/router.go @@ -9,7 +9,7 @@ import ( "strings" ) -var Host string +var Host, Path string func Router() { parsepath := func(path string) map[int]string { @@ -54,14 +54,15 @@ func Router() { // функция, что управляет всем handle := func(w http.ResponseWriter, r *http.Request) { - path := parsepath(r.URL.Path) + Path = r.URL.Path + path := parsepath(Path) Host = "http://" + r.Host + if h := r.Header["X-Forwarded-Proto"]; len(h) != 0 && h[0] == "https" { Host = "https://" + r.Host } var skunky = skunkyart{Version: Release.Version} - skunky._pth = r.URL.Path skunky.Args = r.URL.Query() arg := skunky.Args.Get diff --git a/app/stat-freebsd.go b/app/stat-freebsd.go old mode 100755 new mode 100644 diff --git a/app/stat.go b/app/stat.go old mode 100755 new mode 100644 diff --git a/app/util.go b/app/util.go old mode 100755 new mode 100644 index 6ece2e8..9c8d400 --- a/app/util.go +++ b/app/util.go @@ -63,7 +63,6 @@ type instanceAbout struct { type skunkyart struct { Writer http.ResponseWriter - _pth string Args url.Values Page int @@ -275,7 +274,7 @@ func (s skunkyart) NavBase(c DeviationList) string { prevrev := func(msg string, page int, onpage bool) { if !onpage { list.WriteString(`

NSFW content are disabled on this instance.

`) - return - } - if post.Post.Comments.Total <= 50 { post.Post.Comments.Cursor = "" } diff --git a/compose.example.yaml b/compose.example.yaml deleted file mode 100755 index 5eead70..0000000 --- a/compose.example.yaml +++ /dev/null @@ -1,12 +0,0 @@ -services: - skunkyart: - container_name: skunkyart - restart: unless-stopped - build: . - ports: - - "127.0.0.1:3003:3003" - security_opt: - - no-new-privileges:true - volumes: - - ./config.json:/config.json:ro - - ./cache:/cache # Ensure cache folder has a 10000:10000 ownership. diff --git a/config.example.json b/config.example.json old mode 100755 new mode 100644 index 70e1c1b..b38e47e --- a/config.example.json +++ b/config.example.json @@ -6,12 +6,11 @@ "path": "cache", "lifetime": null, "max-size": 200, - "memcache": false, "update-interval": 5 }, "static-path": "static", "download-proxy": "http://127.0.0.1:8080", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", "proxy": true, - "nsfw": false + "nsfw": true } diff --git a/go.mod b/go.mod old mode 100755 new mode 100644 diff --git a/go.sum b/go.sum old mode 100755 new mode 100644 diff --git a/instances.json b/instances.json old mode 100755 new mode 100644 index ceec4f6..a3a2f4a --- a/instances.json +++ b/instances.json @@ -1,11 +1,11 @@ { "instances": [ { - "title": "lost-skunk.cc", - "country": "Finland", + "title": "skunky.ebloid.ru", + "country": "Russia", "urls": { - "ygg": "http://[201:f137:d1ac:920e:cd42:bfd1:1e83:da1d]/skunkyart", - "clearnet": "https://lost-skunk.cc/skunkyart" + "ygg": "http://[201:eba5:d1fc:bf7b:cfcb:a811:4b8b:7ea3]/art", + "clearnet": "https://skunky.ebloid.ru/art" }, "settings": { "proxy": true, @@ -13,13 +13,13 @@ } }, { - "title": "orehus.club", - "country": "Germany", + "title": "clovius.club", + "country": "Sweden", "urls": { - "clearnet": "https://sa.orehus.club" + "clearnet": "https://skunky.clovius.club" }, "settings": { - "proxy": false, + "proxy": true, "nsfw": true } }, @@ -55,28 +55,6 @@ "proxy": true, "nsfw": true } - }, - { - "title": "dc09.ru", - "country": "Russia", - "urls": { - "clearnet": "https://sa.dc09.ru" - }, - "settings": { - "proxy": true, - "nsfw": false - } - }, - { - "title": "opnxng.com", - "country": "Singapore", - "urls": { - "clearnet": "https://da.opnxng.com" - }, - "settings": { - "proxy": true, - "nsfw": true - } } ] -} +} \ No newline at end of file diff --git a/main.go b/main.go old mode 100755 new mode 100644 diff --git a/services/skunkyart.example.service b/services/skunkyart.example.service old mode 100755 new mode 100644 diff --git a/static/css/skunky.css b/static/css/skunky.css old mode 100755 new mode 100644 index 09cc71c..a7258c8 --- a/static/css/skunky.css +++ b/static/css/skunky.css @@ -1,6 +1,6 @@ /* TAGS */ html { - font-family: ubuntu, system-ui; + font-family: Ubuntu; background-color:black; color: rgb(234, 216, 216); } @@ -45,22 +45,24 @@ input:focus { justify-content: center; } .block { - padding: 0px 0px 6px 0px; - border: 3px solid #000; + max-width: 20%; + height: 0%; + padding: 4px; + border-radius: 2px; + border: 3px solid #091f19; word-break: break-all; background-color: #091f19; margin-left: 5px; margin-top: 5px; text-align: center; } -.block h1 { - padding: 8.5vh; -} .block:hover { border: 3px solid #4d27d6; transition: 400ms; } - +.block img, .plates .user-plate img { + width: 100%; +} .block p { word-break: break-all; } @@ -183,20 +185,6 @@ input:focus { font-size: 60%; max-width: 80% } - .block img, .plates .user-plate img { - width: 100%; - } -} - -@media (orientation: landscape) { - .block { - width: 20%; - } - .block img, .plates .user-plate img { - width: 100%; - height: 30vh; - object-fit: cover; - } } @media (max-width: 1462px) and (orientation: landscape) { diff --git a/static/html/about.htm b/static/html/about.htm old mode 100755 new mode 100644 index ae2da3f..eac4e47 --- a/static/html/about.htm +++ b/static/html/about.htm @@ -6,7 +6,7 @@

SkunkyArt is an alternative frontend for deviantart.com, written in Go.

-

Room in [matrix]

+

Room in [matrix]

Instance settings: -

Copyright lost+skunk, X11. SkunkyArt v{{.Version}}

+

Copyright lost+skunk, X11. SkunkyArt v{{.Version}}

diff --git a/static/html/daily.htm b/static/html/daily.htm old mode 100755 new mode 100644 diff --git a/static/html/deviantion.htm b/static/html/deviantion.htm old mode 100755 new mode 100644 diff --git a/static/html/gruser.htm b/static/html/gruser.htm old mode 100755 new mode 100644 index 4e8e3d1..6593951 --- a/static/html/gruser.htm +++ b/static/html/gruser.htm @@ -30,7 +30,7 @@

| {{.Templates.GroupUser.GR.Owner.Username}}

{{if eq .Type 'a'}} - {{if and (and (ne .Templates.About.Nsfw true) (ne .Templates.GroupUser.About.BGMeta.NSFW true)) (ne .Templates.GroupUser.About.BG "")}} + {{if ne .Templates.GroupUser.About.BG ""}} {{end}} diff --git a/static/html/head.htm b/static/html/head.htm old mode 100755 new mode 100644 diff --git a/static/html/header.htm b/static/html/header.htm old mode 100755 new mode 100644 diff --git a/static/html/index.htm b/static/html/index.htm old mode 100755 new mode 100644 diff --git a/static/html/search.htm b/static/html/search.htm old mode 100755 new mode 100644 diff --git a/static/images/logo.png b/static/images/logo.png old mode 100755 new mode 100644 diff --git a/static/templates-noembed.go b/static/templates-noembed.go old mode 100755 new mode 100644 diff --git a/static/templates.go b/static/templates.go old mode 100755 new mode 100644