From 9e3db6b88216695110d6930317c1965e9d7a0c72 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Tue, 2 Apr 2024 19:40:41 +0300 Subject: [PATCH 1/6] feat: more icons for source urls (#218) --- lib/philomena_web/views/image_view.ex | 55 ++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index 7034c8e78..a0d5308eb 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -318,14 +318,20 @@ defmodule PhilomenaWeb.ImageView do "fab fa-twitter" u - when u in ["deviantart.com", "sta.sh", "www.sta.sh"] -> + when u in [ + "deviantart.com", + "sta.sh", + "www.sta.sh", + "images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com", + "wixmp-ed30a86b8c4ca887773594c2.wixmp.com" + ] -> "fab fa-deviantart" u when u in ["cdn.discordapp.com", "discordapp.com", "discord.com", "media.discordapp.net"] -> "fab fa-discord" - u when u in ["youtube.com", "www.youtube.com"] -> + u when u in ["youtube.com", "www.youtube.com", "youtu.be"] -> "fab fa-youtube" u when u in ["pillowfort.social", "www.pillowfort.social"] -> @@ -343,6 +349,7 @@ defmodule PhilomenaWeb.ImageView do u when u in [ "ych.art", + "cdn.ych.art", "ych.commishes.com", "commishes.com", "portfolio.commishes.com", @@ -350,13 +357,29 @@ defmodule PhilomenaWeb.ImageView do ] -> "fa fa-palette" + u + when u in ["ko-fi.com", "storage.ko-fi.com", "buymeacoffee.com", "www.buymeacoffee.com"] -> + "fa fa-coffee" + u when u in ["artstation.com", "www.artstation.com"] -> "fab fa-artstation" u when u in ["instagram.com", "www.instagram.com"] -> "fab fa-instagram" - u when u in ["reddit.com", "www.reddit.com"] -> + u when u in ["t.me"] -> + "fab fa-telegram" + + u + when u in [ + "reddit.com", + "www.reddit.com", + "old.reddit.com", + "redd.it", + "i.redd.it", + "v.redd.it", + "preview.redd.it" + ] -> "fab fa-reddit" u when u in ["facebook.com", "www.facebook.com", "fb.me", "www.fb.me"] -> @@ -405,12 +428,26 @@ defmodule PhilomenaWeb.ImageView do link -> cond do - Enum.member?(site_domains, link) -> "favicon-home" - String.ends_with?(link, ".tumblr.com") -> "fab fa-tumblr" - String.ends_with?(link, ".deviantart.com") -> "fab fa-deviantart" - String.ends_with?(link, ".sofurry.com") -> "fa fa-paw" - String.ends_with?(link, ".userapi.com") -> "fab fa-vk" - true -> "fa fa-link" + Enum.member?(site_domains, link) -> + "favicon-home" + + String.ends_with?(link, ".tumblr.com") -> + "fab fa-tumblr" + + String.ends_with?(link, ".deviantart.com") -> + "fab fa-deviantart" + + String.ends_with?(link, ".sofurry.com") -> + "fa fa-paw" + + String.ends_with?(link, ".userapi.com") -> + "fab fa-vk" + + String.ends_with?(link, ".patreonusercontent.com") -> + "fab fa-patreon" + + true -> + "fa fa-link" end end end From 625eef3792a0b630452146e1430fd33ab2376ffe Mon Sep 17 00:00:00 2001 From: mdashlw Date: Wed, 3 Apr 2024 15:11:11 +0300 Subject: [PATCH 2/6] ci: fix (#219) --- .github/workflows/elixir.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index ff5a2c79a..dfdfab46d 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -7,40 +7,40 @@ jobs: name: 'Build Elixir app' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache mix deps - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | _build deps key: ${{ runner.os }}-build-deps-${{ hashFiles('mix.lock') }} - - run: docker-compose pull - - run: docker-compose build + - run: docker compose pull + - run: docker compose build - name: Build and test - run: docker-compose run app run-test + run: docker compose run app run-test - name: Security lint run: | - docker-compose run app mix sobelow --config - docker-compose run app mix deps.audit + docker compose run app mix sobelow --config + docker compose run app mix deps.audit lint-and-test: name: 'JavaScript Linting and Unit Tests' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' - name: Cache node_modules id: cache-node-modules - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ./assets/node_modules key: node_modules-${{ hashFiles('./assets/package-lock.json') }} From 5a6b2bd8747b51eae947c0dd5372505ad16f9abf Mon Sep 17 00:00:00 2001 From: mdashlw Date: Fri, 5 Apr 2024 15:07:54 +0300 Subject: [PATCH 3/6] feat: more icons for source urls (#220) --- lib/philomena_web/views/image_view.ex | 63 ++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index a0d5308eb..dc9d9be8f 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -323,15 +323,22 @@ defmodule PhilomenaWeb.ImageView do "sta.sh", "www.sta.sh", "images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com", - "wixmp-ed30a86b8c4ca887773594c2.wixmp.com" + "wixmp-ed30a86b8c4ca887773594c2.wixmp.com", + "api-da.wixmp.com", + "fav.me" ] -> "fab fa-deviantart" u - when u in ["cdn.discordapp.com", "discordapp.com", "discord.com", "media.discordapp.net"] -> + when u in [ + "cdn.discordapp.com", + "discordapp.com", + "discord.com", + "discord.gg" + ] -> "fab fa-discord" - u when u in ["youtube.com", "www.youtube.com", "youtu.be"] -> + u when u in ["youtube.com", "www.youtube.com", "youtu.be", "m.youtube.com"] -> "fab fa-youtube" u when u in ["pillowfort.social", "www.pillowfort.social"] -> @@ -340,9 +347,13 @@ defmodule PhilomenaWeb.ImageView do u when u in ["vk.com", "vk.ru"] -> "fab fa-vk" - u when u in ["pixiv.net", "www.pixiv.net", "artfight.net", "www.artfight.net"] -> + u + when u in ["artfight.net", "www.artfight.net", "newgrounds.com"] -> "fa fa-paintbrush" + u when u in ["pixiv.net", "www.pixiv.net", "pixiv.me"] -> + "fab fa-pixiv" + u when u in ["patreon.com", "www.patreon.com"] -> "fab fa-patreon" @@ -382,7 +393,7 @@ defmodule PhilomenaWeb.ImageView do ] -> "fab fa-reddit" - u when u in ["facebook.com", "www.facebook.com", "fb.me", "www.fb.me"] -> + u when u in ["facebook.com", "www.facebook.com", "fb.me", "www.fb.me", "m.facebook.com"] -> "fab fa-facebook" u when u in ["tiktok.com", "www.tiktok.com"] -> @@ -391,12 +402,14 @@ defmodule PhilomenaWeb.ImageView do u when u in [ "furaffinity.net", - "www.furaffinity.net", "furbooru.org", "inkbunny.net", "e621.net", "e926.net", - "sofurry.com" + "sofurry.com", + "weasyl.com", + "www.weasyl.com", + "cdn.weasyl.com" ] -> "fa fa-paw" @@ -423,9 +436,15 @@ defmodule PhilomenaWeb.ImageView do "fab fa-mastodon" u - when u in ["tumbex.com", "www.tumbex.com", "tumblr.com"] -> + when u in ["tumbex.com", "www.tumbex.com", "tumblr.com", "tmblr.co"] -> "fab fa-tumblr" + u when u in ["flickr.com", "www.flickr.com"] -> + "fab fa-flickr" + + u when u in ["etsy.com", "www.etsy.com"] -> + "fab fa-etsy" + link -> cond do Enum.member?(site_domains, link) -> @@ -434,18 +453,40 @@ defmodule PhilomenaWeb.ImageView do String.ends_with?(link, ".tumblr.com") -> "fab fa-tumblr" - String.ends_with?(link, ".deviantart.com") -> + String.ends_with?(link, ".deviantart.com") or String.ends_with?(link, ".deviantart.net") -> "fab fa-deviantart" - String.ends_with?(link, ".sofurry.com") -> + String.ends_with?(link, ".furaffinity.net") or String.ends_with?(link, ".sofurry.com") or + String.ends_with?(link, ".facdn.net") -> "fa fa-paw" - String.ends_with?(link, ".userapi.com") -> + String.ends_with?(link, ".userapi.com") or String.ends_with?(link, ".vk.me") -> "fab fa-vk" String.ends_with?(link, ".patreonusercontent.com") -> "fab fa-patreon" + String.ends_with?(link, ".discordapp.net") -> + "fab fa-discord" + + String.ends_with?(link, ".ytimg.com") -> + "fab fa-youtube" + + String.ends_with?(link, ".fbcdn.net") -> + "fab fa-facebook" + + String.ends_with?(link, ".newgrounds.com") or String.ends_with?(link, ".ngfiles.com") -> + "fa fa-paintbrush" + + String.ends_with?(link, ".apple.com") -> + "fab fa-apple" + + String.ends_with?(link, ".staticflickr.com") -> + "fab fa-flickr" + + String.ends_with?(link, ".etsystatic.com") -> + "fab fa-etsy" + true -> "fa fa-link" end From 2cfde149ef6fd0b34553c2d32d153f5760ded80b Mon Sep 17 00:00:00 2001 From: mdashlw Date: Fri, 5 Apr 2024 19:59:16 +0300 Subject: [PATCH 4/6] Twitter scraper description (#221) * feat(scrapers/twitter): return received tweet text Also: use url and username from received json for the sake of consistent capitalizaton * fix: all fields are under "tweet" --- lib/philomena/scrapers/twitter.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/philomena/scrapers/twitter.ex b/lib/philomena/scrapers/twitter.ex index 9575c4e51..0ba64180e 100644 --- a/lib/philomena/scrapers/twitter.ex +++ b/lib/philomena/scrapers/twitter.ex @@ -13,9 +13,10 @@ defmodule Philomena.Scrapers.Twitter do {:ok, %Tesla.Env{status: 200, body: body}} = Philomena.Http.get(api_url) json = Jason.decode!(body) + tweet = json["tweet"] images = - Enum.map(json["tweet"]["media"]["photos"], fn p -> + Enum.map(tweet["media"]["photos"], fn p -> %{ url: "#{p["url"]}:orig", camo_url: Camo.Image.image_url(p["url"]) @@ -23,8 +24,9 @@ defmodule Philomena.Scrapers.Twitter do end) %{ - source_url: "https://twitter.com/#{user}/status/#{status_id}", - author_name: user, + source_url: tweet["url"], + author_name: tweet["author"]["screen_name"], + description: tweet["text"], images: images } end From 3714ae115c0a881ce1405a7256011cd44a52faff Mon Sep 17 00:00:00 2001 From: mdashlw Date: Sat, 6 Apr 2024 21:10:33 +0300 Subject: [PATCH 5/6] fix: misleading error if image is corrupted (#222) width/height can be nil here, first case doesn't match but nil is indeed bigger than 32767, so the incorrect error message will be displayed --- lib/philomena/images/image.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/philomena/images/image.ex b/lib/philomena/images/image.ex index a6892185e..d8e791c89 100644 --- a/lib/philomena/images/image.ex +++ b/lib/philomena/images/image.ex @@ -187,7 +187,7 @@ defmodule Philomena.Images.Image do height = fetch_field!(changeset, :image_height) cond do - width <= 0 or height <= 0 -> + is_nil(width) or is_nil(height) or width <= 0 or height <= 0 -> add_error( changeset, :image, From cc32f5d3b9e34e2d88300530dae08160c4d81171 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Sat, 6 Apr 2024 23:05:32 +0300 Subject: [PATCH 6/6] feat(search): force display dnp entries even if found no images (#223) --- lib/philomena_web/templates/search/index.html.slime | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/philomena_web/templates/search/index.html.slime b/lib/philomena_web/templates/search/index.html.slime index 7bc09cebc..878d24861 100644 --- a/lib/philomena_web/templates/search/index.html.slime +++ b/lib/philomena_web/templates/search/index.html.slime @@ -1,5 +1,5 @@ = cond do - - Enum.any?(@images) -> + - Enum.any?(@images) or Enum.any?(@tags, &Enum.any?(elem(&1, 0).dnp_entries)) -> = render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Searching for #{@conn.params["q"]}", route: fn p -> Routes.search_path(@conn, :index, p) end, scope: scope(@conn) - assigns[:error] ->