mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
merging sources, fix ui bugs, more icons
This commit is contained in:
parent
516b35f2fd
commit
b70c0a11f6
5 changed files with 110 additions and 28 deletions
|
@ -1,5 +1,7 @@
|
|||
// DOM Utils
|
||||
|
||||
type PhilomenaInputElements = HTMLTextAreaElement | HTMLInputElement | HTMLButtonElement;
|
||||
|
||||
/**
|
||||
* Get the first matching element
|
||||
*/
|
||||
|
@ -34,13 +36,13 @@ export function clearEl<E extends HTMLElement>(...elements: E[] | ConcatArray<E>
|
|||
});
|
||||
}
|
||||
|
||||
export function disableEl<E extends HTMLInputElement>(...elements: E[] | ConcatArray<E>[]) {
|
||||
export function disableEl<E extends PhilomenaInputElements>(...elements: E[] | ConcatArray<E>[]) {
|
||||
([] as E[]).concat(...elements).forEach(el => {
|
||||
el.disabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
export function enableEl<E extends HTMLInputElement>(...elements: E[] | ConcatArray<E>[]) {
|
||||
export function enableEl<E extends PhilomenaInputElements>(...elements: E[] | ConcatArray<E>[]) {
|
||||
([] as E[]).concat(...elements).forEach(el => {
|
||||
el.disabled = false;
|
||||
});
|
||||
|
|
|
@ -548,6 +548,13 @@ defmodule Philomena.Images do
|
|||
|> Multi.run(:copy_tags, fn _, %{} ->
|
||||
{:ok, Tags.copy_tags(image, duplicate_of_image)}
|
||||
end)
|
||||
|> Multi.run(:migrate_sources, fn repo, %{} ->
|
||||
{:ok,
|
||||
migrate_sources(
|
||||
repo.preload(image, [:sources]),
|
||||
repo.preload(duplicate_of_image, [:sources])
|
||||
)}
|
||||
end)
|
||||
|> Multi.run(:migrate_comments, fn _, %{} ->
|
||||
{:ok, Comments.migrate_comments(image, duplicate_of_image)}
|
||||
end)
|
||||
|
@ -920,6 +927,17 @@ defmodule Philomena.Images do
|
|||
{:ok, count}
|
||||
end
|
||||
|
||||
def migrate_sources(source, target) do
|
||||
sources =
|
||||
(source.sources ++ target.sources)
|
||||
|> Enum.uniq()
|
||||
|> Enum.take(10)
|
||||
|
||||
target
|
||||
|> Image.sources_changeset(sources)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
def notify_merge(source, target) do
|
||||
Exq.enqueue(Exq, "notifications", NotificationWorker, ["Images", [source.id, target.id]])
|
||||
end
|
||||
|
|
|
@ -214,6 +214,11 @@ defmodule Philomena.Images.Image do
|
|||
|> SourceDiffer.diff_input(old_sources, new_sources)
|
||||
end
|
||||
|
||||
def sources_changeset(image, new_sources) do
|
||||
change(image)
|
||||
|> put_assoc(:sources, new_sources)
|
||||
end
|
||||
|
||||
def tag_changeset(image, attrs, old_tags, new_tags, excluded_tags \\ []) do
|
||||
image
|
||||
|> cast(attrs, [])
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
p
|
||||
' You can't edit the source on this image.
|
||||
|
||||
.flex.flex--wrap.flex--centered#image-source
|
||||
p
|
||||
.flex.flex--wrap.flex--column#image-source
|
||||
.flex
|
||||
a.button.button--separate-right#edit-source data-click-focus=".js-image-source" data-click-hide="#image-source" data-click-show="#source-form" title="Edit source" accessKey="s"
|
||||
i.fas.fa-edit>
|
||||
= if !has_sources || length(@image.sources) == 1 do
|
||||
|
|
|
@ -308,18 +308,75 @@ defmodule PhilomenaWeb.ImageView do
|
|||
u when u in ["cdn.discordapp.com", "discordapp.com", "discord.com"] ->
|
||||
"fab fa-discord"
|
||||
|
||||
u when u in ["youtube.com", "www.youtube.com"] ->
|
||||
"fab fa-youtube"
|
||||
|
||||
u when u in ["pillowfort.social", "www.pillowfort.social"] ->
|
||||
"fa fa-bed"
|
||||
|
||||
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"] ->
|
||||
"fa fa-paintbrush"
|
||||
|
||||
u when u in ["patreon.com", "www.patreon.com"] ->
|
||||
"fab fa-patreon"
|
||||
|
||||
u when u in ["ych.art", "ych.commishes.com", "commishes.com"] ->
|
||||
"fa fa-palette"
|
||||
|
||||
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"] ->
|
||||
"fab fa-reddit"
|
||||
|
||||
u when u in ["facebook.com", "www.facebook.com", "fb.me", "www.fb.me"] ->
|
||||
"fab fa-facebook"
|
||||
|
||||
u when u in ["tiktok.com", "www.tiktok.com"] ->
|
||||
"fab fa-tiktok"
|
||||
|
||||
u
|
||||
when u in [
|
||||
"derpibooru.org",
|
||||
"www.derpibooru.org",
|
||||
"trixiebooru.org",
|
||||
"www.trixiebooru.org",
|
||||
"derpicdn.net"
|
||||
"furaffinity.net",
|
||||
"www.furaffinity.net",
|
||||
"furbooru.org",
|
||||
"inkbunny.net",
|
||||
"e621.net",
|
||||
"e926.net"
|
||||
] ->
|
||||
"fab fa-phoenix-framework"
|
||||
"fa fa-paw"
|
||||
|
||||
u
|
||||
when u in [
|
||||
"awoo.space",
|
||||
"bark.lgbt",
|
||||
"equestria.social",
|
||||
"foxy.social",
|
||||
"mastodon.art",
|
||||
"mastodon.social",
|
||||
"meow.social",
|
||||
"pawoo.net",
|
||||
"pettingzoo.co",
|
||||
"pony.social",
|
||||
"vulpine.club",
|
||||
"yiff.life"
|
||||
] ->
|
||||
"fab fa-mastodon"
|
||||
|
||||
link ->
|
||||
if Enum.member?(site_domains, link), do: "favicon-home", else: "fa fa-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
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue