Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Apr 8, 2024
2 parents ace039a + cc32f5d commit 3baae3b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 31 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena/images/image.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions lib/philomena/scrapers/twitter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ 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"])
}
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
Expand Down
2 changes: 1 addition & 1 deletion lib/philomena_web/templates/search/index.html.slime
Original file line number Diff line number Diff line change
@@ -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] ->
Expand Down
108 changes: 93 additions & 15 deletions lib/philomena_web/views/image_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,27 @@ 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",
"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"] ->
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"] ->
Expand All @@ -334,32 +347,53 @@ 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"

u
when u in [
"ych.art",
"cdn.ych.art",
"ych.commishes.com",
"commishes.com",
"portfolio.commishes.com",
"commishes.io"
] ->
"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"] ->
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"] ->
Expand All @@ -368,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"

Expand All @@ -400,17 +436,59 @@ 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) -> "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") or String.ends_with?(link, ".deviantart.net") ->
"fab fa-deviantart"

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") 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
end
end
Expand Down

0 comments on commit 3baae3b

Please sign in to comment.