diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6833fbe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +cache +compose.yaml +*.json +LICENSE +*.md +services diff --git a/.gitignore b/.gitignore index 4686488..63ca398 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/cache +**/compose.yaml **/config.json **/skunkyart +**/skunkyart-* diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fdc1919 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +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 index 1637971..e5fffdd 100644 --- a/INSTANCES.md +++ b/INSTANCES.md @@ -1,7 +1,10 @@ +JSON variant should be used from master — https://git.macaw.me/skunky/SkunkyArt/raw/branch/master/instances.json + |Instance|Yggdrasil|I2P|Tor|NSFW|Proxifying|Modified Sources|Country| |:------:|:-------:|:-:|:-:|:--:|:--------:|:--------------:|:-----:| -|[skunky.ebloid.ru](https://skunky.ebloid.ru/art)|[Yes](http://[201:eba5:d1fc:bf7b:cfcb:a811:4b8b:7ea3]/art)|No|No| No | No | 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 | Romania | -|[frontendfriendly.xyz](https://skunkyart.frontendfriendly.xyz)|No|No|No| Yes | Yes | No | Finland | -|[lumaeris.com](https://skunkyart.lumaeris.com)|No|No|No| Yes | Yes | No | US | \ No newline at end of file +|[lost-skunk.cc](https://lost-skunk.cc/skunkyart)|[Yes](http://[201:f137:d1ac:920e:cd42:bfd1:1e83:da1d]/skunkyart)|No|No| No | Yes | No | Germany | +|[orehus.club](https://sa.orehus.club)|No|No|No| Yes | No | No | Germany | +|[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 | \ No newline at end of file diff --git a/README.md b/README.md index 6eaa831..e5f404d 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,51 @@ - +> [!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. -[](https://go.kde.org/matrix/#/#skunkyart:ebloid.ru) + -Instances: [`INSTANCES.md`](https://git.macaw.me/skunky/SkunkyArt/src/branch/master/INSTANCES.md) +[](https://go.kde.org/matrix/#/#skunkyart:gnulinux.club) + +Instances: [`INSTANCES.md`](/skunky/SkunkyArt/src/branch/master/INSTANCES.md) # EN 🇺🇸 ## Description SkunkyArt 🦨 — alternative frontend for DevianArt, which works without JS. +## Build (translated via DeepL) +It is recommended to build with the 'embed' tag because it embeds the presets in the binary. If you plan to modify the templates, then do not use this tag. You can also add the `-ldflags "-w -s"` argument (GCCGO has a different name for it — `gccgoflags`) to reduce the size of the output file. Here is an example: + +`go build -tags embed -ldflags "-w -s"` + +Pre-compiled binaries can be found in the [Releases](https://git.macaw.me/skunky/skunkyart/releases) tab. ## Setup The sample config is in the `config.example.json` file. For custom config, use `--config` option. -See the [`SETUP.md`](https://git.macaw.me/skunky/SkunkyArt/src/branch/master/SETUP.md) file for more info about directives. +See the [`SETUP.md`](/skunky/SkunkyArt/src/branch/master/SETUP.md) file for more info about directives. ## Adding instance to the list To do this, you must either make a PR by adding your instance to the `instances.json` and `INSTANCES.md` files (you can use `--add-instance` cli-argument to automatically add the instance to these files), or create an Issue, or report it to the room in Matrix. Keep in mind that your instance must comply with the following rules: 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 # RU 🇷🇺 ## Описание SkunkyArt 🦨 — альтернативный фронтенд к DeviantArt, который полностью работает без JS (JavaScript). +## Сборка +Рекомендуется производить сборку с тегом 'embed', поскольку он встраивает заготовки в бинарный файл. Если вы планируете изменять заготовки, то не используйте этот тег. Также вы можете добавить аргумент `-ldflags "-w -s"` (у GCCGO он называется по-другому — `gccgoflags`) для уменьшения размера выходного файла. Вот пример: + +`go build -tags embed -ldflags "-w -s"` + +Готовые бинари находятся во вкладке [Releases](https://git.macaw.me/skunky/skunkyart/releases). ## Настройка Пример конфига находится в файле `config.example.json`. Чтобы указать свой конфиг, используйте cli-аргумент `--config`. -См. [`SETUP-RU.md`](https://git.macaw.me/skunky/SkunkyArt/src/branch/master/SETUP-RU.md) для информации о настройки фронтенда. +См. [`SETUP-RU.md`](/skunky/SkunkyArt/src/branch/master/SETUP-RU.md) для информации о настройки фронтенда. ## Добавление инстанса в список Чтобы это сделать, вы должны либо сделать PR, добавив в файлы `instances.json` и `INSTANCES.md` свой инстанс (можете воспользоваться cli-аргументом `--add-instance`, который автоматически это сделает), либо создать Issue, или сообщить о нём в комнате в Matrix. Учтите, что ваш инстанс должен соблюсти следущие правила: 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 new file mode 100644 index 0000000..2469977 --- /dev/null +++ b/REDIRECTS.md @@ -0,0 +1,13 @@ +# Search +* `deviantart.com/search?q=$QUERY` => `/search?q=$QUERY&type=all` +# Daily Deviations +* `deviantart.com` => `/dd` +# Deviations +* (`$USER_GROUP.deviantart.com/art/$ID`|`deviantart.com/$USER_GROUP/art/$ID`) => `/post/$USER_GROUP/$ID` +# Groups and users +## Main user page +* (`$USER_GROUP.deviantart.com`|`deviantart.com/$USER_GROUP`) => `/group_user?type=about&q=$USER_GROUP` +## Gallery +* (`$USER_GROUP.deviantart.com/gallery`|`deviantart.com/$USER_GROUP/gallery`) => `/group_user?type=gallery&q=$USER_GROUP` +## Favourites +* (`$USER_GROUP.deviantart.com/favourites`|`deviantart.com/$USER_GROUP/favourites`) => `/group_user?type=favourites&q=$USER_GROUP` diff --git a/SETUP-RU.md b/SETUP-RU.md index 6ff3c23..7d7d04c 100644 --- a/SETUP-RU.md +++ b/SETUP-RU.md @@ -1,4 +1,4 @@ -[English version 🇬🇧](https://git.macaw.me/skunky/SkunkyArt/src/branch/master/SETUP.md) +[English version 🇬🇧](/skunky/SkunkyArt/src/branch/master/SETUP.md) # Единицы измерения Размер файла в кеше измеряется в мегабайтах. @@ -12,13 +12,13 @@ # Конфигурация * `listen` — IP и порт для слушанья; заполняется по такой форме: ip:port * `uri` — URI инстанса. Пример: `"uri":"/art/"` -> https://skunky.ebloid.ru/art/ -* `cache` — Система кеширования; по умолчанию выключена. +* `cache` — Система кеширования; по умолчанию выключена * `enabled` — Состояние системы кеширования; требуется булёвое значение * `path` — Полный путь до каталога, куда будет сохраняться кеш * `lifetime` — Время жизни файла в кеше, требует целочисленное значение, дополненное суффиксом времени (см. 'Единицы времени') * `max-size` — Максимальный размер файла * `update-interval` — Интервал для автоматической ротации кеша -* `dirs-to-memory` — Массив, заполнив который скопируются все файлы из указанных каталогов +* `static-path` — Строка, являющаяся путём до статики. SkunkyArt при запуске скопирует содержимое этого каталога в ОЗУ. Однако, если вы собрали фронтенд с тегом 'embed', то этого не произайдёт * `download-proxy` — Адрес прокси для загрузки файлов * `user-agent` — Строка, которая используется в качестве User-Agent'а diff --git a/SETUP.md b/SETUP.md index ab30165..cc89118 100644 --- a/SETUP.md +++ b/SETUP.md @@ -1,4 +1,4 @@ -[Версия на русском языке 🇷🇺](https://git.macaw.me/skunky/SkunkyArt/src/branch/master/SETUP-RU.md) +[Версия на русском языке 🇷🇺](/skunky/SkunkyArt/src/branch/master/SETUP-RU.md) # Units Maximum file size in megabytes, requires numeric value. @@ -18,7 +18,7 @@ Time units: * `lifetime` — Cached file life time, requires numeric value, followed by multiplicative suffix (see Time Units for details) * `max-size` — Maximum file size in megabytes * `update-interval` — Automatic rotation interval -* `dirs-to-memory` — This setting determines which directories will be copied to RAM when SkunkyArt is started. Mandatory +* `static-path` — This setting determines path to static, which will be copied to RAM when SkunkyArt is started. Useless if you're use binary compiled with 'embed' tag. * `download-proxy` — Proxy address for downloading files. * `user-agent` — String, which SkunkyArt uses as UA diff --git a/TODO.md b/TODO.md index ee50111..01bc524 100644 --- a/TODO.md +++ b/TODO.md @@ -1,19 +1,23 @@ # v1.3.x * Почистить говнокод +* Добавить фильтры поиска +* ~~Сделать порт под FreeBSD~~ ✔️ * **Доделать парсинг описания** -* Избавиться от хардкода под Linux -* ~~Реализовать стрипы в ежедневных артах~~ -* Сделать нормальное отображение ошибок -* ~~Исправить баг с навигацией по страницам~~ -* ~~Сделать единицы в конфиге более понятными~~ -* Добавить возможность включить темплейты в бинарник -* ~~Реализовать миниатюры и оптимизировать CSS под маленькие экраны~~ +* ~~Реализовать стрипы в ежедневных артах~~ ✔️ +* ~~Исправить баг с навигацией по страницам~~ ✔️ +* ~~Сделать нормальное отображение ошибок~~ ✔️ +* ~~Сделать единицы в конфиге более понятными~~ ✔️ +* Добавить чекер инстанса на работоспособность +* ~~Добавить просмотр понравившихся артов пользователю~~ ✔️ +* Добавить возможность включить темплейты в бинарник [P] +* ~~Реализовать миниатюры и оптимизировать CSS под маленькие экраны~~ ✔️ * Написать Makefile и скрипт для автоматического развёртывания инстанса -* **Реализовать отображение контента, отличного от картинок (видео, аудио, etc)** * Исправить баг с эмоджи, когда некоторые кастомные эмоции могут не отображаться -* Добавить флаг сборки, который позволит собрать бинарник со встроенными темплейтами -* Улучшить систему кеширования: добавить рейтинг для удаления и копирование изображений в ОЗУ +* ~~Добавить аргумент &filename, который будет выдавать файл с нормально выглядещем именем~~ ✔️ +* ~~Улучшить систему кеширования: добавить рейтинг для удаления и копирование изображений в ОЗУ~~ ✔️ # v1.4 * Реализовать API * Реализовать темы -* Реализовать многоязычный интерфейс \ No newline at end of file +* Перейти на арены в кеше +* Реализовать многоязычный интерфейс + diff --git a/app/api.go b/app/api.go new file mode 100644 index 0000000..d2a5655 --- /dev/null +++ b/app/api.go @@ -0,0 +1,82 @@ +package app + +import ( + "encoding/json" + "math/rand" + "strings" + + "git.macaw.me/skunky/devianter" +) + +type API struct { + main *skunkyart +} + +type info struct { + Version string `json:"version"` + Settings settingsParams `json:"settings"` +} + +func (a API) Info() { + json, err := json.Marshal(info{ + Version: a.main.Version, + Settings: settingsParams{ + Nsfw: CFG.Nsfw, + Proxy: CFG.Proxy, + }, + }) + try(err) + a.main.Writer.Write(json) +} + +func (a API) Error(description string, status int) { + a.main.Writer.WriteHeader(status) + var response strings.Builder + response.WriteString(`{"error":"`) + response.WriteString(description) + response.WriteString(`"}`) + wr(a.main.Writer, response.String()) +} + +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 { + 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) + } +} + +// TODO: сделать фильтры +func (a API) Random() { + for attempt := 1; ; { + if attempt > 3 { + a.Error("Sorry, butt NSFW on this are disabled, and the instance failed to find a random art without NSFW", 500) + } + + s, err, daErr := devianter.PerformSearch(string(rand.Intn(999)), rand.Intn(30), 'a') + try(err) + if daErr.RAW != nil { + continue + } + + deviation := &s.Results[rand.Intn(len(s.Results))] + + if deviation.NSFW && !CFG.Nsfw { + attempt++ + continue + } + + a.sendMedia(deviation) + return + } +} diff --git a/app/cache.go b/app/cache.go new file mode 100644 index 0000000..e03db67 --- /dev/null +++ b/app/cache.go @@ -0,0 +1,152 @@ +// TODO: реализовать кеширование JSON и почистить код +package app + +import ( + "crypto/sha1" + "encoding/hex" + "io" + "os" + "strings" + "sync" + "syscall" + "time" +) + +type file struct { + Score int + Content []byte +} + +var tempFS = make(map[[20]byte]*file) +var mx = &sync.RWMutex{} + +func (s skunkyart) DownloadAndSendMedia(subdomain, path string) { + var url strings.Builder + url.WriteString("https://images-wixmp-") + url.WriteString(subdomain) + url.WriteString(".wixmp.com/") + url.WriteString(path) + if t := s.Args.Get("token"); t != "" { + url.WriteString("?token=") + url.WriteString(t) + } + + var response []byte + + switch { + case CFG.Cache.Enabled: + fileName := sha1.Sum([]byte(subdomain + path)) + filePath := CFG.Cache.Path + "/" + hex.EncodeToString(fileName[:]) + + c := func() { + file, err := os.Open(filePath) + if err != nil { + if dwnld := Download(url.String()); dwnld.Status == 200 && dwnld.Headers["Content-Type"][0][:5] == "image" { + response = dwnld.Body + try(os.WriteFile(filePath, response, 0700)) + } else { + s.ReturnHTTPError(dwnld.Status) + return + } + } else { + file, e := io.ReadAll(file) + try(e) + response = file + } + } + + if CFG.Cache.MemCache { + 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 { + c() + go func() { + defer restore() + + mx.RLock() + tempFS[fileName].Content = response + mx.RUnlock() + + for { + time.Sleep(1 * time.Minute) + + mx.Lock() + if tempFS[fileName].Score <= 0 { + delete(tempFS, fileName) + mx.Unlock() + return + } + tempFS[fileName].Score-- + mx.Unlock() + } + }() + } + } else { + c() + } + case CFG.Proxy: + dwnld := Download(url.String()) + if dwnld.Status != 200 { + s.ReturnHTTPError(dwnld.Status) + return + } + response = dwnld.Body + default: + s.Writer.WriteHeader(403) + response = []byte("Sorry, butt proxy on this instance are disabled.") + } + + s.Writer.Write(response) +} + +func InitCacheSystem() { + c := &CFG.Cache + for { + dir, err := os.ReadDir(c.Path) + if err != nil { + if os.IsNotExist(err) { + os.Mkdir(c.Path, 0700) + continue + } + println(err.Error()) + } + + var total int64 + for _, file := range dir { + fileName := c.Path + "/" + file.Name() + fileInfo, err := file.Info() + try(err) + + if c.Lifetime != "" { + now := time.Now().UnixMilli() + + stat := fileInfo.Sys().(*syscall.Stat_t) + time := statTime(stat) + + if time+lifetimeParsed <= now { + try(os.RemoveAll(fileName)) + } + } + + 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) + } + + time.Sleep(time.Second * time.Duration(c.UpdateInterval)) + } +} diff --git a/app/cli.go b/app/cli.go index 2247223..0480bdb 100644 --- a/app/cli.go +++ b/app/cli.go @@ -4,19 +4,20 @@ import ( "bufio" "bytes" "encoding/json" + "html/template" "os" "time" ) func ExecuteCommandLineArguments() { - const helpmsg = `SkunkyArt v1.3.1 [CSS improvements for mobile and the strips on Daily Deviations] + var helpmsg = `SkunkyArt v{{.Version}} [{{.Description}}] Usage: - [-c|--config] | path to config - [-a|--add-instance] | generates 'instances.json' and 'INSTANCES.md' files with ur instance - [-h|--help] | returns this message Example: ./skunkyart -c config.json -Copyright lost+skunk, X11. https://git.macaw.me/skunky/skunkyart/src/tag/v1.3.1` +Copyright lost+skunk, X11. https://git.macaw.me/skunky/skunkyart/src/tag/v{{.Version}}` a := os.Args[1:] for n, x := range a { @@ -28,7 +29,11 @@ Copyright lost+skunk, X11. https://git.macaw.me/skunky/skunkyart/src/tag/v1.3.1` exit("Not enought arguments", 1) } case "-h", "--help": - exit(helpmsg, 0) + var buf bytes.Buffer + t := template.New("help") + t.Parse(helpmsg) + t.Execute(&buf, &Release) + exit(buf.String(), 0) case "-a", "--add-instance": addInstance() } @@ -78,16 +83,16 @@ func addInstance() { try(err) defer instancesJson.Close() - instances, err := os.OpenFile("INSTANCES.md", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + instancesFile, err := os.OpenFile("INSTANCES.md", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) try(err) - defer instances.Close() + defer instancesFile.Close() for { - if Templates["instances.json"] == "" { + if string(instances) == "" { print("\rDownloading instance list...") } else { println("\r\033[2KDownloaded!") - try(json.Unmarshal([]byte(Templates["instances.json"]), &settingsVar)) + try(json.Unmarshal(instances, &settingsVar)) settingsVar.Instances = append(settingsVar.Instances, settings{ Title: prompt("Title", true), @@ -113,51 +118,46 @@ func addInstance() { settingsVar := &settingsVar.Instances[len(settingsVar.Instances)-1] var mdstr bytes.Buffer - mdstr.WriteString("\n|") - if settingsVar.Urls.Clearnet != "" { - mdstr.WriteString("[") - mdstr.WriteString(settingsVar.Title) - mdstr.WriteString("](") - mdstr.WriteString(settingsVar.Urls.Clearnet) - mdstr.WriteString(")") - } else { - mdstr.WriteString(settingsVar.Title) + mdbuilder := func(yes bool, link string, title string) { + switch { + case yes && (title != "" && link != ""): + mdstr.WriteString("[") + mdstr.WriteString(title) + mdstr.WriteString("](") + mdstr.WriteString(link) + mdstr.WriteString(")") + case yes && link != "": + mdstr.WriteString("[Yes](") + mdstr.WriteString(link) + mdstr.WriteString(")") + case yes: + mdstr.WriteString("Yes") + default: + mdstr.WriteString("No") + } + mdstr.WriteString("|") } - mdstr.WriteString("|") + + mdstr.WriteString("\n|") + mdbuilder(settingsVar.Urls.Clearnet != "", settingsVar.Urls.Clearnet, settingsVar.Title) urls := []string{settingsVar.Urls.Ygg, settingsVar.Urls.I2P, settingsVar.Urls.Tor} for i, l := 0, len(urls); i < l; i++ { url := urls[i] - if url != "" { - mdstr.WriteString("[Yes](") - mdstr.WriteString(url) - mdstr.WriteString(")|") - } else { - mdstr.WriteString("No|") - } + mdbuilder(url != "", url, "") } settings := []bool{settingsVar.Settings.Nsfw, settingsVar.Settings.Proxy} for i, l := 0, len(settings); i < l; i++ { - if settings[i] { - mdstr.WriteString("Yes|") - } else { - mdstr.WriteString("No|") - } + mdbuilder(settings[i], "", "") } - if settingsVar.ModifiedSrc != "" { - mdstr.WriteString("[Yes](") - mdstr.WriteString(settingsVar.ModifiedSrc) - mdstr.WriteString(")|") - } else { - mdstr.WriteString("No|") - } + mdbuilder(settingsVar.ModifiedSrc != "", settingsVar.ModifiedSrc, "") mdstr.WriteString(settingsVar.Country) mdstr.WriteString("|") - instances.Write(mdstr.Bytes()) + instancesFile.Write(mdstr.Bytes()) break } time.Sleep(500 * time.Millisecond) diff --git a/app/config.go b/app/config.go index a6ac756..813453c 100644 --- a/app/config.go +++ b/app/config.go @@ -4,14 +4,21 @@ import ( "encoding/json" "os" "regexp" + "skunkyart/static" "strconv" "time" "git.macaw.me/skunky/devianter" ) +var Release struct { + Version string + Description string +} + type cache_config struct { Enabled bool + MemCache bool `json:"memcache"` Path string MaxSize int64 `json:"max-size"` Lifetime string @@ -24,9 +31,9 @@ type config struct { URI string `json:"uri"` Cache cache_config Proxy, Nsfw bool - UserAgent string `json:"user-agent"` - DownloadProxy string `json:"download-proxy"` - Dirs []string `json:"dirs-to-memory"` + UserAgent string `json:"user-agent"` + DownloadProxy string `json:"download-proxy"` + StaticPath string `json:"static-path"` } var CFG = config{ @@ -38,10 +45,10 @@ var CFG = config{ Path: "cache", UpdateInterval: 1, }, - Dirs: []string{"html", "css", "misc"}, - UserAgent: "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: true, + StaticPath: "static", + UserAgent: "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: true, } var lifetimeParsed int64 @@ -50,7 +57,6 @@ func ExecuteConfig() { if CFG.cfg != "" { f, err := os.ReadFile(CFG.cfg) tryWithExitStatus(err, 1) - tryWithExitStatus(json.Unmarshal(f, &CFG), 1) if CFG.Cache.Enabled && !CFG.Proxy { exit("Incompatible settings detected: cannot use caching media content without proxy", 1) @@ -82,9 +88,16 @@ func ExecuteConfig() { lifetimeParsed = duration * int64(num) } - CFG.Cache.MaxSize /= 1024 ^ 2 + CFG.Cache.MaxSize *= 1024 ^ 2 go InitCacheSystem() } + + About = instanceAbout{ + Proxy: CFG.Proxy, + Nsfw: CFG.Nsfw, + } + + static.StaticPath = CFG.StaticPath devianter.UserAgent = CFG.UserAgent } } diff --git a/app/parsers.go b/app/parsers.go index b39e172..192a88d 100644 --- a/app/parsers.go +++ b/app/parsers.go @@ -9,7 +9,11 @@ import ( "golang.org/x/net/html" ) -func (s skunkyart) ParseComments(c devianter.Comments) string { +func (s skunkyart) ParseComments(c devianter.Comments, daError devianter.Error) string { + if daError.RAW != nil { + return "Failed to fetch comments :(" + } + var cmmts strings.Builder replied := make(map[int]string) @@ -41,7 +45,9 @@ func (s skunkyart) ParseComments(c devianter.Comments) string { cmmts.WriteString(" ") if x.Parent > 0 { - cmmts.WriteString(` In reply to `) if replied[x.Parent] == "" { @@ -82,6 +88,7 @@ func (s skunkyart) DeviationList(devs []devianter.Deviation, allowAtom bool, con data := &devs[i] if preview, fullview := ParseMedia(data.Media, 320), ParseMedia(data.Media); !(data.NSFW && !CFG.Nsfw) { if allowAtom && s.Atom { + s.Writer.Header().Add("Content-type", "application/atom+xml") id := strconv.Itoa(data.ID) listContent.WriteString(``) listContent.WriteString(data.Author.Username) @@ -181,6 +188,7 @@ type text struct { To int } +// переписать весь этот пиздец нахуй func ParseDescription(dscr devianter.Text) string { var parsedDescription strings.Builder TagBuilder := func(content string, tags ...string) string { diff --git a/app/router.go b/app/router.go index f87aa50..ac65c3d 100644 --- a/app/router.go +++ b/app/router.go @@ -1,8 +1,10 @@ package app import ( + "io" "net/http" - u "net/url" + url "net/url" + "skunkyart/static" "strconv" "strings" ) @@ -41,41 +43,61 @@ func Router() { return } + open := func(name string) []byte { + file, err := static.Templates.Open(name) + try(err) + fileReaded, err := io.ReadAll(file) + try(err) + + return fileReaded + } + // функция, что управляет всем handle := func(w http.ResponseWriter, r *http.Request) { + path := parsepath(r.URL.Path) + Host = "http://" + r.Host if h := r.Header["X-Forwarded-Proto"]; len(h) != 0 && h[0] == "https" { - Host = h[0] + "://" + r.Host - } else { - Host = "http://" + r.Host + Host = "https://" + r.Host } - path := parsepath(r.URL.Path) - // структура с функциями - var skunky skunkyart - skunky.Writer = w - skunky.Args = r.URL.Query() - skunky.BasePath = CFG.URI + var skunky = skunkyart{Version: Release.Version} + skunky._pth = r.URL.Path + skunky.Args = r.URL.Query() arg := skunky.Args.Get + p, _ := strconv.Atoi(arg("p")) + + skunky.Endpoint = path[1] + skunky.API.main = &skunky + skunky.Writer = w + skunky.BasePath = CFG.URI skunky.QueryRaw = arg("q") - skunky.Query = u.QueryEscape(skunky.QueryRaw) + skunky.Query = url.QueryEscape(skunky.QueryRaw) + skunky.Page = p if t := arg("type"); len(t) > 0 { skunky.Type = rune(t[0]) } - p, _ := strconv.Atoi(arg("p")) - skunky.Page = p if arg("atom") == "true" { skunky.Atom = true } - // пути - switch path[1] { - default: - skunky.ReturnHTTPError(404) + if CFG.Proxy { + w.Header().Add("Content-Security-Policy", "default-src 'self'; script-src 'none'; style-src 'self' 'unsafe-inline'") + } else { + w.Header().Add("Content-Security-Policy", "default-src 'self'; img-src 'self' *.wixmp.com; script-src 'none'; style-src 'self' 'unsafe-inline'") + } + + w.Header().Add("X-Frame-Options", "DENY") + + switch skunky.Endpoint { + // main case "": - skunky.ExecuteTemplate("index.htm", &CFG.URI) + skunky.ExecuteTemplate("index.htm", "html", &CFG.URI) + case "about": + skunky.Templates.About = About + skunky.ExecuteTemplate("about.htm", "html", &skunky) case "post": skunky.Deviation(path[2], path[3]) case "search": @@ -85,20 +107,38 @@ func Router() { case "group_user": skunky.GRUser() + // media case "media": switch path[2] { case "file": + if a := arg("filename"); a != "" { + skunky.SetFilename(a) + } skunky.DownloadAndSendMedia(path[3], next(path, 4)) case "emojitar": skunky.Emojitar(path[3]) } - case "about": - skunky.About() case "stylesheet": w.Header().Add("content-type", "text/css") - wr(w, Templates["skunky.css"]) + w.Write(open("css/skunky.css")) case "favicon.ico": - wr(w, Templates["logo.png"]) + w.Write(open("images/logo.png")) + + // API + case "api": + w.Header().Add("Content-Type", "application/json") + switch path[2] { + case "instance": + skunky.API.Info() + case "random": + skunky.API.Random() + default: + skunky.API.Error("Not Found", 404) + } + + // 404 + default: + skunky.ReturnHTTPError(404) } } diff --git a/app/stat-freebsd.go b/app/stat-freebsd.go new file mode 100644 index 0000000..445eeae --- /dev/null +++ b/app/stat-freebsd.go @@ -0,0 +1,13 @@ +//go:build freebsd +// +build freebsd + +package app + +import ( + "syscall" + "time" +) + +func statTime(stat *syscall.Stat_t) int64 { + return time.Unix(stat.Ctimespec.Unix()).UnixMilli() +} diff --git a/app/stat.go b/app/stat.go new file mode 100644 index 0000000..a5bebcc --- /dev/null +++ b/app/stat.go @@ -0,0 +1,13 @@ +//go:build !freebsd +// +build !freebsd + +package app + +import ( + "syscall" + "time" +) + +func statTime(stat *syscall.Stat_t) int64 { + return time.Unix(stat.Ctim.Unix()).UnixMilli() +} diff --git a/app/util.go b/app/util.go index 8c26760..6ece2e8 100644 --- a/app/util.go +++ b/app/util.go @@ -1,14 +1,14 @@ package app import ( - "encoding/base64" + "encoding/json" "io" "net/http" - u "net/url" + "net/url" "os" + "skunkyart/static" "strconv" "strings" - "syscall" "text/template" "time" @@ -17,6 +17,8 @@ import ( ) /* INTERNAL */ +var wr = io.WriteString + func exit(msg string, code int) { println(msg) os.Exit(code) @@ -32,26 +34,99 @@ func tryWithExitStatus(err error, code int) { } } +func restore() { + if r := recover(); r != nil { + recover() + } +} + +var instances []byte +var About instanceAbout + func RefreshInstances() { for { func() { - defer func() { - if r := recover(); r != nil { - recover() - } - }() - Templates["instances.json"] = string(Download("https://git.macaw.me/skunky/SkunkyArt/raw/branch/master/instances.json").Body) + 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 -func (s skunkyart) ExecuteTemplate(file string, data any) { +type instanceAbout struct { + Proxy bool + Nsfw bool + Instances []settings +} + +type skunkyart struct { + Writer http.ResponseWriter + _pth string + + Args url.Values + Page int + Type rune + Atom bool + + BasePath, Endpoint string + Query, QueryRaw string + + API API + Version string + + Templates struct { + About instanceAbout + + SomeList string + DDStrips string + Deviation struct { + Post devianter.Post + Related string + StringTime string + Tags string + Comments string + } + + GroupUser struct { + GR devianter.GRuser + Admins string + Group bool + CreationDate string + + About struct { + A devianter.About + + DescriptionFormatted string + Interests, Social string + Comments string + BG string + BGMeta devianter.Deviation + } + + Gallery struct { + Folders string + Pages int + List string + } + } + Search struct { + Content devianter.Search + List string + } + } +} + +func (s skunkyart) ExecuteTemplate(file, dir string, data any) { var buf strings.Builder tmp := template.New(file) - tmp, e := tmp.Parse(Templates[file]) - try(e) + tmp, err := tmp.ParseFS(static.Templates, dir+"/*") + if err != nil { + s.Writer.WriteHeader(500) + wr(s.Writer, err.Error()) + return + } try(tmp.Execute(&buf, &data)) wr(s.Writer, buf.String()) } @@ -63,13 +138,26 @@ func UrlBuilder(strs ...string) string { str.WriteString(CFG.URI) for n, x := range strs { str.WriteString(x) - if n+1 < l && !(strs[n+1][0] == '?' || strs[n+1][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("/") } } return str.String() } +func (s skunkyart) Error(dAerr devianter.Error) { + s.Writer.WriteHeader(502) + + var msg strings.Builder + msg.WriteString(`DeviantArt error — '`) + msg.WriteString(dAerr.Error) + msg.WriteString("'") + + wr(s.Writer, msg.String()) +} + func (s skunkyart) ReturnHTTPError(status int) { s.Writer.WriteHeader(status) @@ -85,21 +173,29 @@ func (s skunkyart) ReturnHTTPError(status int) { wr(s.Writer, msg.String()) } +func (s skunkyart) SetFilename(name string) { + var filename strings.Builder + filename.WriteString(`filename="`) + filename.WriteString(name) + filename.WriteString(`"`) + s.Writer.Header().Add("Content-Disposition", filename.String()) +} + type Downloaded struct { Headers http.Header Status int Body []byte } -func Download(url string) (d Downloaded) { +func Download(urlString string) (d Downloaded) { cli := &http.Client{} if CFG.DownloadProxy != "" { - u, e := u.Parse(CFG.DownloadProxy) + u, e := url.Parse(CFG.DownloadProxy) try(e) cli.Transport = &http.Transport{Proxy: http.ProxyURL(u)} } - req, e := http.NewRequest("GET", url, nil) + req, e := http.NewRequest("GET", urlString, nil) try(e) req.Header.Set("User-Agent", CFG.UserAgent) @@ -115,97 +211,20 @@ func Download(url string) (d Downloaded) { return } -// caching -func (s skunkyart) DownloadAndSendMedia(subdomain, path string) { - var url strings.Builder - url.WriteString("https://images-wixmp-") - url.WriteString(subdomain) - url.WriteString(".wixmp.com/") - url.WriteString(path) - url.WriteString("?token=") - url.WriteString(s.Args.Get("token")) - - if CFG.Cache.Enabled { - fname := CFG.Cache.Path + "/" + base64.StdEncoding.EncodeToString([]byte(subdomain+path)) - file, e := os.Open(fname) - - if e != nil { - dwnld := Download(url.String()) - if dwnld.Status == 200 && dwnld.Headers["Content-Type"][0][:5] == "image" { - try(os.WriteFile(fname, dwnld.Body, 0700)) - s.Writer.Write(dwnld.Body) - } - } else { - file, e := io.ReadAll(file) - try(e) - s.Writer.Write(file) - } - } else if CFG.Proxy { - dwnld := Download(url.String()) - s.Writer.Write(dwnld.Body) - } else { - s.Writer.WriteHeader(403) - s.Writer.Write([]byte("Sorry, butt proxy on this instance are disabled.")) - } -} - -func InitCacheSystem() { - c := &CFG.Cache - os.Mkdir(CFG.Cache.Path, 0700) - for { - dir, e := os.Open(c.Path) - try(e) - stat, e := dir.Stat() - try(e) - - dirnames, e := dir.Readdirnames(-1) - try(e) - for _, a := range dirnames { - a = c.Path + "/" + a - if c.Lifetime != "" { - now := time.Now().UnixMilli() - - f, _ := os.Stat(a) - stat := f.Sys().(*syscall.Stat_t) - time := time.Unix(stat.Ctim.Unix()).UnixMilli() - - if time+lifetimeParsed <= now { - try(os.RemoveAll(a)) - } - } - if c.MaxSize != 0 && stat.Size() > c.MaxSize { - try(os.RemoveAll(a)) - } - } - - dir.Close() - time.Sleep(time.Second * time.Duration(CFG.Cache.UpdateInterval)) - } -} - -func CopyTemplatesToMemory() { - for _, dirname := range CFG.Dirs { - dir, e := os.ReadDir(dirname) - tryWithExitStatus(e, 1) - - for _, x := range dir { - file, e := os.ReadFile(dirname + "/" + x.Name()) - tryWithExitStatus(e, 1) - Templates[x.Name()] = string(file) - } - } -} - /* PARSING HELPERS */ func ParseMedia(media devianter.Media, thumb ...int) string { - url := devianter.UrlFromMedia(media, thumb...) - if len(url) != 0 && CFG.Proxy { - url = url[21:] - dot := strings.Index(url, ".") - - return UrlBuilder("media", "file", url[:dot], url[dot+11:]) + mediaUrl, filename := devianter.UrlFromMedia(media, thumb...) + if len(mediaUrl) != 0 && CFG.Proxy { + mediaUrl = mediaUrl[21:] + dot := strings.Index(mediaUrl, ".") + if filename == "" { + filename = "image.gif" + } + return UrlBuilder("media", "file", mediaUrl[:dot], mediaUrl[dot+11:], "&filename=", filename) + } else if !CFG.Proxy { + return mediaUrl } - return url + return "" } func ConvertDeviantArtUrlToSkunkyArt(url string) (output string) { @@ -255,7 +274,9 @@ func (s skunkyart) NavBase(c DeviationList) string { list.WriteString("") prevrev := func(msg string, page int, onpage bool) { if !onpage { - list.WriteString(` 0 { - group.Gallery.List = s.DeviationList(gallery.Content.Results, true, DeviationList{ - More: gallery.Content.HasMore, + if daError.RAW != nil { + s.Error(daError) + return + } + + if folderid > 0 || (s.Type == 'f' && all) { + group.Gallery.List = s.DeviationList(content.Content.Results, true, DeviationList{ + More: content.Content.HasMore, }) } else { - for _, x := range gallery.Content.Gruser.Page.Modules { + for _, x := range content.Content.Gruser.Page.Modules { if l := len(x.ModuleData.Folders.Results); l != 0 { var folders strings.Builder folders.WriteString(`# Folders`) for _, x := range x.ModuleData.Folders.Results { - folders.WriteString(``) + if x.FolderId != -1 && x.Size != 0 { + folders.WriteString(``) - if !(x.Thumb.NSFW && !CFG.Nsfw) { - folders.WriteString(``) - } else { - folders.WriteString(`[ NSFW ]`) + if !(x.Thumb.NSFW && !CFG.Nsfw) { + folders.WriteString(``) + } else { + folders.WriteString(`[ NSFW ]`) + } + folders.WriteString("") + + folders.WriteString(``) + folders.WriteString(x.Name) + folders.WriteString(``) + + folders.WriteString("") } - folders.WriteString("") - - folders.WriteString(``) - folders.WriteString(x.Name) - folders.WriteString(``) - - folders.WriteString("") } folders.WriteString(`# Content`) group.Gallery.Folders = folders.String() @@ -209,7 +163,7 @@ func (s skunkyart) GRUser() { } if !s.Atom { - s.ExecuteTemplate("gruser.htm", &s) + s.ExecuteTemplate("gruser.htm", "html", &s) } } @@ -221,19 +175,34 @@ func (s skunkyart) Deviation(author, postname string) { return } + var err devianter.Error post := &s.Templates.Deviation id := id_search[len(id_search)-1] - post.Post = devianter.GetDeviation(id, author) + post.Post, err = devianter.GetDeviation(id, author) + if err.RAW != nil { + s.Error(err) + return + } + + if post.Post.Deviation.NSFW && !CFG.Nsfw { + s.Writer.WriteHeader(403) + wr(s.Writer, `NSFW content are disabled on this instance.`) + return + } + + if post.Post.Comments.Total <= 50 { + post.Post.Comments.Cursor = "" + } if post.Post.Deviation.TextContent.Excerpt != "" { post.Post.Description = ParseDescription(post.Post.Deviation.TextContent) } else { post.Post.Description = ParseDescription(post.Post.Deviation.Extended.DescriptionText) } - // время публикации - post.StringTime = post.Post.Deviation.PublishedTime.UTC().String() - post.Post.IMG = ParseMedia(post.Post.Deviation.Media) + for _, x := range post.Post.Deviation.Extended.RelatedContent { if len(x.Deviations) != 0 { post.Related += s.DeviationList(x.Deviations, false) @@ -252,17 +221,19 @@ func (s skunkyart) Deviation(author, postname string) { post.Tags += tag.String() } - if post.Post.Comments.Total <= 50 { - post.Post.Comments.Cursor = "" - } - post.Comments = s.ParseComments(devianter.GetComments(id, post.Post.Comments.Cursor, s.Page, 1)) + post.StringTime = post.Post.Deviation.PublishedTime.UTC().String() + post.Post.IMG = ParseMedia(post.Post.Deviation.Media) - s.ExecuteTemplate("deviantion.htm", &s) + s.ExecuteTemplate("deviantion.htm", "html", &s) } func (s skunkyart) DD() { - dd := devianter.GetDailyDeviations(s.Page) + dd, err := devianter.GetDailyDeviations(s.Page) + if err.RAW != nil { + s.Error(err) + return + } var strips strings.Builder for _, x := range dd.Strips { strips.WriteString(` - - - SkunkyArt | Daily Deviations - - - - - - HOME | DD | RSS - - - - All - Tag - Groups - - Search! - - - {{if ne .Templates.DDStrips ""}} - # Strips - {{.Templates.DDStrips}} - {{end}} - # Content - {{.Templates.SomeList}} - - \ No newline at end of file diff --git a/html/index.htm b/html/index.htm deleted file mode 100644 index 08feba5..0000000 --- a/html/index.htm +++ /dev/null @@ -1,22 +0,0 @@ - - - - SkunkyArt - - - - - - - - - All - Tag - Groups - - Search! - - Daily Deviations | About | Source Code - - - \ No newline at end of file diff --git a/html/search.htm b/html/search.htm deleted file mode 100644 index df1cf85..0000000 --- a/html/search.htm +++ /dev/null @@ -1,30 +0,0 @@ - - - - SkunkyArt | Search "{{.QueryRaw}}" - - - - - - HOME | DD - - - - All - Tag - Groups - - Search! - - - {{if ne .Templates.Search.List ""}} - {{if ne .Templates.Search.Content.Total 0}} - Results by request '{{.QueryRaw}}': {{.Templates.Search.Content.Total}} - {{end}} - {{.Templates.Search.List}} - {{else}} - No results :( - {{end}} - - \ No newline at end of file diff --git a/instances.json b/instances.json index cd95b78..725e524 100644 --- a/instances.json +++ b/instances.json @@ -1,59 +1,70 @@ { "instances": [ { - "title": "skunky.ebloid.ru", - "country": "Russia", + "title": "lost-skunk.cc", + "country": "Germany", "urls": { - "ygg": "http://[201:eba5:d1fc:bf7b:cfcb:a811:4b8b:7ea3]/art", - "clearnet": "https://skunky.ebloid.ru/art" + "ygg": "http://[201:f137:d1ac:920e:cd42:bfd1:1e83:da1d]/skunkyart", + "clearnet": "https://lost-skunk.cc/skunkyart" }, "settings": { - "nsfw": false, - "proxy": false + "proxy": true, + "nsfw": false } }, { - "title": "clovius.club", - "country": "Sweden", + "title": "orehus.club", + "country": "Germany", "urls": { - "clearnet": "https://skunky.clovius.club" + "clearnet": "https://sa.orehus.club" }, "settings": { - "nsfw": true, - "proxy": true + "proxy": false, + "nsfw": true } }, { "title": "bloat.cat", - "country": "Romania", + "country": "Germany", "urls": { "clearnet": "https://skunky.bloat.cat" }, "settings": { - "nsfw": true, - "proxy": true - } - }, - { - "title": "frontendfriendly.xyz", - "country": "Finland", - "urls": { - "clearnet": "https://skunkyart.frontendfriendly.xyz" - }, - "settings": { - "nsfw": true, - "proxy": true + "proxy": true, + "nsfw": true } }, { "title": "lumaeris.com", - "country": "US", + "country": "Germany", "urls": { "clearnet": "https://skunkyart.lumaeris.com" }, "settings": { - "nsfw": true, - "proxy": true + "proxy": true, + "nsfw": true + } + }, + { + "title": "art.bloat.cat", + "country": "Germany", + "urls": { + "clearnet": "https://art.bloat.cat" + }, + "settings": { + "proxy": true, + "nsfw": true + } + }, + { + "title": "dc09.ru", + "country": "Russia", + "urls": { + "clearnet": "https://sa.dc09.ru" + }, + "settings": { + "proxy": true, + "nsfw": false } } ] diff --git a/main.go b/main.go index 0224816..d7009ae 100644 --- a/main.go +++ b/main.go @@ -2,17 +2,20 @@ package main import ( "skunkyart/app" + "skunkyart/static" "time" "git.macaw.me/skunky/devianter" ) func main() { + app.Release.Version = "1.3.2" + app.Release.Description = "Two API endpoints and template embedding into binary" go app.RefreshInstances() app.ExecuteCommandLineArguments() app.ExecuteConfig() - app.CopyTemplatesToMemory() + static.CopyTemplatesToMemory() go func() { for { diff --git a/css/skunky.css b/static/css/skunky.css similarity index 81% rename from css/skunky.css rename to static/css/skunky.css index 2126968..09cc71c 100644 --- a/css/skunky.css +++ b/static/css/skunky.css @@ -1,6 +1,6 @@ /* TAGS */ html { - font-family: Ubuntu; + font-family: ubuntu, system-ui; background-color:black; color: rgb(234, 216, 216); } @@ -19,15 +19,21 @@ header h1 { header form { align-self: center; } -header { +header, form { display: flex; } +form { + border: solid #164e3e 1px; + max-width: fit-content; +} form input, button, select { background-color: #134134; padding: 5px; color: whitesmoke; - border: 0px; - border-radius: 1px; + border: 0; +} +input:focus { + outline: none; } /* BLOCKS */ @@ -39,24 +45,22 @@ form input, button, select { justify-content: center; } .block { - max-width: 20%; - height: 0%; - padding: 4px; - border-radius: 2px; - border: 3px solid #091f19; + padding: 0px 0px 6px 0px; + border: 3px solid #000; 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; } @@ -140,19 +144,18 @@ form input, button, select { font-size: 80% } - center form { - font-size: 60% - } - - header form { - font-size: 60%; - } - header, center { + header { + margin-left: 3%; text-align: center; - display: block; + display: inline-block; clear: both; font-size: 200%; } + + form { + font-size: 60%; + border: solid #164e3e 5px; + } .content { margin: auto; @@ -180,6 +183,20 @@ form input, button, select { 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/html/about.htm b/static/html/about.htm similarity index 64% rename from html/about.htm rename to static/html/about.htm index edb576d..ae2da3f 100644 --- a/html/about.htm +++ b/static/html/about.htm @@ -1,27 +1,12 @@ - - SkunkyArt - - - + {{template "head" .}} - - HOME | DD - - - - All - Tag - Groups - - Search! - - + {{template "header" .}} SkunkyArt is an alternative frontend for deviantart.com, written in Go. - Room in Matrix + Room in [matrix] Instance settings: NSFW: {{if .Templates.About.Nsfw}}YES{{else}}NO{{end}} @@ -59,6 +44,6 @@ {{end}} - Copyright lost+skunk, X11. SkunkyArt v1.3.1 + Copyright lost+skunk, X11. SkunkyArt v{{.Version}} - \ No newline at end of file +
No results :(
SkunkyArt is an alternative frontend for deviantart.com, written in Go.
Copyright lost+skunk, X11. SkunkyArt v1.3.1
Copyright lost+skunk, X11. SkunkyArt v{{.Version}}