From a4e77991079f48e403244ffd94f9aab12662a9e1 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Sat, 23 Mar 2024 17:19:43 +0300 Subject: [PATCH 1/2] ImageView: add more hosts for source icons --- lib/philomena_web/views/image_view.ex | 54 +++++++++++++++++++-------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index ba93a50c2..ae09d4b80 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -305,13 +305,25 @@ defmodule PhilomenaWeb.ImageView do uri = URI.parse(source) case uri.host do - u when u in ["twitter.com", "www.twitter.com", "pbs.twimg.com", "twimg.com"] -> + u + when u in [ + "twitter.com", + "www.twitter.com", + "mobile.twitter.com", + "x.com", + "mobile.x.com", + "pbs.twimg.com", + "twimg.com" + ] -> "fab fa-twitter" - u when u in ["deviantart.com", "www.deviantart.com", "sta.sh", "www.sta.sh"] -> + u + when u in ["deviantart.com", "sta.sh", "www.sta.sh"] or + String.ends_with?(u, ".deviantart.com") -> "fab fa-deviantart" - u when u in ["cdn.discordapp.com", "discordapp.com", "discord.com"] -> + 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"] -> @@ -320,7 +332,7 @@ defmodule PhilomenaWeb.ImageView do u when u in ["pillowfort.social", "www.pillowfort.social"] -> "fa fa-bed" - u when u in ["vk.com", "vk.ru"] -> + u when u in ["vk.com", "vk.ru"] or String.ends_with?(u, ".userapi.com") -> "fab fa-vk" u when u in ["pixiv.net", "www.pixiv.net", "artfight.net", "www.artfight.net"] -> @@ -329,7 +341,14 @@ defmodule PhilomenaWeb.ImageView do u when u in ["patreon.com", "www.patreon.com"] -> "fab fa-patreon" - u when u in ["ych.art", "ych.commishes.com", "commishes.com"] -> + u + when u in [ + "ych.art", + "ych.commishes.com", + "commishes.com", + "portfolio.commishes.com", + "commishes.io" + ] -> "fa fa-palette" u when u in ["artstation.com", "www.artstation.com"] -> @@ -355,7 +374,7 @@ defmodule PhilomenaWeb.ImageView do "inkbunny.net", "e621.net", "e926.net" - ] -> + ] or String.ends_with?(u, ".sofurry.com") -> "fa fa-paw" u @@ -373,18 +392,23 @@ defmodule PhilomenaWeb.ImageView do "vulpine.club", "yiff.life", "socel.net", - "octodon.social" + "octodon.social", + "filly.social", + "pone.social", + "hooves.social" ] -> "fab fa-mastodon" - link -> - cond do - Enum.member?(site_domains, link) -> "favicon-home" - String.contains?(link, "tumblr") -> "fab fa-tumblr" - String.contains?(link, "deviantart") -> "fab fa-deviantart" - String.contains?(link, "sofurry") -> "fa fa-paw" - true -> "fa fa-link" - end + u + when u in ["tumbex.com", "www.tumbex.com", "tumblr.com"] or + String.ends_with?(u, ".tumblr.com") -> + "fab fa-tumblr" + + u when Enum.member?(site_domains, u) -> + "favicon-home" + + _ -> + "fa fa-link" end end end From 798ae643f2e6e569a5086ccaffec734af30bc989 Mon Sep 17 00:00:00 2001 From: mdashlw Date: Sat, 23 Mar 2024 17:34:17 +0300 Subject: [PATCH 2/2] fix compile errors --- lib/philomena_web/views/image_view.ex | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index ae09d4b80..7034c8e78 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -318,8 +318,7 @@ defmodule PhilomenaWeb.ImageView do "fab fa-twitter" u - when u in ["deviantart.com", "sta.sh", "www.sta.sh"] or - String.ends_with?(u, ".deviantart.com") -> + when u in ["deviantart.com", "sta.sh", "www.sta.sh"] -> "fab fa-deviantart" u @@ -332,7 +331,7 @@ defmodule PhilomenaWeb.ImageView do u when u in ["pillowfort.social", "www.pillowfort.social"] -> "fa fa-bed" - u when u in ["vk.com", "vk.ru"] or String.ends_with?(u, ".userapi.com") -> + 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"] -> @@ -373,8 +372,9 @@ defmodule PhilomenaWeb.ImageView do "furbooru.org", "inkbunny.net", "e621.net", - "e926.net" - ] or String.ends_with?(u, ".sofurry.com") -> + "e926.net", + "sofurry.com" + ] -> "fa fa-paw" u @@ -400,15 +400,18 @@ defmodule PhilomenaWeb.ImageView do "fab fa-mastodon" u - when u in ["tumbex.com", "www.tumbex.com", "tumblr.com"] or - String.ends_with?(u, ".tumblr.com") -> + when u in ["tumbex.com", "www.tumbex.com", "tumblr.com"] -> "fab fa-tumblr" - u when Enum.member?(site_domains, u) -> - "favicon-home" - - _ -> - "fa fa-link" + 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" + end end end end