mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
few fixes, design + format
This commit is contained in:
parent
a1e2122ce4
commit
4d3310eef7
10 changed files with 121 additions and 32 deletions
|
@ -322,3 +322,16 @@ span.spoiler div.image-container {
|
||||||
.full-height {
|
.full-height {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image_sources {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 2em auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image_source__icon, .image_source__link {
|
||||||
|
padding: 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image_source__icon {
|
||||||
|
justify-self: center;
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ config :philomena,
|
||||||
badge_url_root: System.fetch_env!("BADGE_URL_ROOT"),
|
badge_url_root: System.fetch_env!("BADGE_URL_ROOT"),
|
||||||
mailer_address: System.fetch_env!("MAILER_ADDRESS"),
|
mailer_address: System.fetch_env!("MAILER_ADDRESS"),
|
||||||
tag_file_root: System.fetch_env!("TAG_FILE_ROOT"),
|
tag_file_root: System.fetch_env!("TAG_FILE_ROOT"),
|
||||||
|
site_domains: System.fetch_env!("SITE_DOMAINS"),
|
||||||
tag_url_root: System.fetch_env!("TAG_URL_ROOT"),
|
tag_url_root: System.fetch_env!("TAG_URL_ROOT"),
|
||||||
redis_host: System.get_env("REDIS_HOST", "localhost"),
|
redis_host: System.get_env("REDIS_HOST", "localhost"),
|
||||||
proxy_host: System.get_env("PROXY_HOST"),
|
proxy_host: System.get_env("PROXY_HOST"),
|
||||||
|
|
|
@ -342,12 +342,12 @@ defmodule Philomena.Images do
|
||||||
|> Image.source_changeset(%{}, old_sources, new_sources)
|
|> Image.source_changeset(%{}, old_sources, new_sources)
|
||||||
|> repo.update()
|
|> repo.update()
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, image} ->
|
{:ok, image} ->
|
||||||
{:ok, {image, image.added_sources, image.removed_sources}}
|
{:ok, {image, image.added_sources, image.removed_sources}}
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
error
|
error
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|> Multi.run(:added_source_changes, fn repo, %{image: {image, added_sources, _removed}} ->
|
|> Multi.run(:added_source_changes, fn repo, %{image: {image, added_sources, _removed}} ->
|
||||||
source_changes =
|
source_changes =
|
||||||
|
|
|
@ -59,7 +59,8 @@ defmodule Philomena.Images.SourceDiffer do
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
_ -> []
|
_ ->
|
||||||
|
[]
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ defmodule PhilomenaWeb.DuplicateReportController do
|
||||||
|> preload([
|
|> preload([
|
||||||
:user,
|
:user,
|
||||||
:modifier,
|
:modifier,
|
||||||
image: [:user, tags: :aliases],
|
image: [:user, :sources, tags: :aliases],
|
||||||
duplicate_of_image: [:user, tags: :aliases]
|
duplicate_of_image: [:user, :sources, tags: :aliases]
|
||||||
])
|
])
|
||||||
|> order_by(desc: :created_at)
|
|> order_by(desc: :created_at)
|
||||||
|> Repo.paginate(conn.assigns.scrivener)
|
|> Repo.paginate(conn.assigns.scrivener)
|
||||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.ImageController do
|
||||||
Images.Source,
|
Images.Source,
|
||||||
Comments.Comment,
|
Comments.Comment,
|
||||||
Galleries.Gallery
|
Galleries.Gallery
|
||||||
}
|
}
|
||||||
|
|
||||||
alias Philomena.Elasticsearch
|
alias Philomena.Elasticsearch
|
||||||
alias Philomena.Interactions
|
alias Philomena.Interactions
|
||||||
|
|
|
@ -46,16 +46,6 @@
|
||||||
' Source:
|
' Source:
|
||||||
- else
|
- else
|
||||||
' Sources:
|
' Sources:
|
||||||
|
|
||||||
p
|
|
||||||
= if has_sources do
|
|
||||||
= for source <- @image.sources do
|
|
||||||
a.js-source-link href=source.source
|
|
||||||
strong= source.source
|
|
||||||
|
|
||||||
- else
|
|
||||||
em> not provided yet
|
|
||||||
|
|
||||||
= if @source_change_count > 0 do
|
= if @source_change_count > 0 do
|
||||||
a.button.button--link.button--separate-left href=Routes.image_source_change_path(@conn, :index, @image) title="Source history"
|
a.button.button--link.button--separate-left href=Routes.image_source_change_path(@conn, :index, @image) title="Source history"
|
||||||
i.fa.fa-history>
|
i.fa.fa-history>
|
||||||
|
@ -68,3 +58,22 @@
|
||||||
button.button.button--state-danger.button--separate-left type="submit" data-confirm="Are you really, really sure?" title="Wipe sources"
|
button.button.button--state-danger.button--separate-left type="submit" data-confirm="Are you really, really sure?" title="Wipe sources"
|
||||||
i.fas.fa-eraser>
|
i.fas.fa-eraser>
|
||||||
' Wipe
|
' Wipe
|
||||||
|
.image_sources
|
||||||
|
= if has_sources do
|
||||||
|
- [first_source | sources] = @image.sources
|
||||||
|
.image_source__icon
|
||||||
|
i class=image_source_icon(first_source.source)
|
||||||
|
.image_source__link
|
||||||
|
a.js-source-link href=first_source.source
|
||||||
|
strong = first_source.source
|
||||||
|
= for source <- sources do
|
||||||
|
.image_source__icon
|
||||||
|
i class=image_source_icon(source.source)
|
||||||
|
.image_source__link
|
||||||
|
a href=source.source
|
||||||
|
strong = source.source
|
||||||
|
- else
|
||||||
|
.image_source__icon
|
||||||
|
i.fa.fa-unlink
|
||||||
|
.image_source__link
|
||||||
|
em> not provided yet
|
||||||
|
|
|
@ -58,19 +58,24 @@ defmodule PhilomenaWeb.DuplicateReportView do
|
||||||
do: abs(duplicate_of_image.image_aspect_ratio - image.image_aspect_ratio) <= 0.009
|
do: abs(duplicate_of_image.image_aspect_ratio - image.image_aspect_ratio) <= 0.009
|
||||||
|
|
||||||
def neither_have_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def neither_have_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||||
do: blank?(duplicate_of_image.source_url) and blank?(image.source_url)
|
do: Enum.empty?(duplicate_of_image.sources) and Enum.empty?(image.sources)
|
||||||
|
|
||||||
def same_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def same_source?(%{image: image, duplicate_of_image: duplicate_of_image}) do
|
||||||
do: to_string(duplicate_of_image.source_url) == to_string(image.source_url)
|
MapSet.equal?(MapSet.new(image.sources), MapSet.new(duplicate_of_image.sources))
|
||||||
|
end
|
||||||
|
|
||||||
def similar_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def similar_source?(%{image: image, duplicate_of_image: duplicate_of_image}) do
|
||||||
do: uri_host(image.source_url) == uri_host(duplicate_of_image.source_url)
|
MapSet.equal?(
|
||||||
|
MapSet.new(image.sources, &URI.parse(&1.source).host),
|
||||||
|
MapSet.new(duplicate_of_image.sources, &URI.parse(&1.source).host)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
def source_on_target?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def source_on_target?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||||
do: present?(duplicate_of_image.source_url) and blank?(image.source_url)
|
do: Enum.any?(duplicate_of_image.sources) and Enum.empty?(image.sources)
|
||||||
|
|
||||||
def source_on_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def source_on_source?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||||
do: blank?(duplicate_of_image.source_url) && present?(image.source_url)
|
do: Enum.empty?(duplicate_of_image.sources) && Enum.any?(image.sources)
|
||||||
|
|
||||||
def same_artist_tags?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
def same_artist_tags?(%{image: image, duplicate_of_image: duplicate_of_image}),
|
||||||
do: MapSet.equal?(artist_tags(image), artist_tags(duplicate_of_image))
|
do: MapSet.equal?(artist_tags(image), artist_tags(duplicate_of_image))
|
||||||
|
|
|
@ -287,4 +287,68 @@ defmodule PhilomenaWeb.ImageView do
|
||||||
|
|
||||||
Philomena.Search.Evaluator.hits?(doc, query)
|
Philomena.Search.Evaluator.hits?(doc, query)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def image_source_icon(nil), do: "fa fa-link"
|
||||||
|
def image_source_icon(""), do: "fa fa-link"
|
||||||
|
|
||||||
|
def image_source_icon(source) do
|
||||||
|
site_domains =
|
||||||
|
String.split(Application.get_env(:philomena, :site_domains), ",") ++
|
||||||
|
Application.get_env(:philomena, :cdn_host)
|
||||||
|
|
||||||
|
uri = URI.parse(source)
|
||||||
|
|
||||||
|
case uri.host do
|
||||||
|
"twitter.com" ->
|
||||||
|
"fab fa-twitter"
|
||||||
|
|
||||||
|
"www.twitter.com" ->
|
||||||
|
"fab fa-twitter"
|
||||||
|
|
||||||
|
"pbs.twimg.com" ->
|
||||||
|
"fab fa-twitter"
|
||||||
|
|
||||||
|
"twimg.com" ->
|
||||||
|
"fab fa-twitter"
|
||||||
|
|
||||||
|
"deviantart.com" ->
|
||||||
|
"fab fa-deviantart"
|
||||||
|
|
||||||
|
"www.deviantart.com" ->
|
||||||
|
"fab fa-deviantart"
|
||||||
|
|
||||||
|
"sta.sh" ->
|
||||||
|
"fab fa-deviantart"
|
||||||
|
|
||||||
|
"www.sta.sh" ->
|
||||||
|
"fab fa-deviantart"
|
||||||
|
|
||||||
|
"cdn.discordapp.com" ->
|
||||||
|
"fab fa-discord"
|
||||||
|
|
||||||
|
"discordapp.com" ->
|
||||||
|
"fab fa-discord"
|
||||||
|
|
||||||
|
"discord.com" ->
|
||||||
|
"fab fa-discord"
|
||||||
|
|
||||||
|
"derpibooru.org" ->
|
||||||
|
"fab fa-phoenix-framework"
|
||||||
|
|
||||||
|
"www.derpibooru.org" ->
|
||||||
|
"fab fa-phoenix-framework"
|
||||||
|
|
||||||
|
"trixiebooru.org" ->
|
||||||
|
"fab fa-phoenix-framework"
|
||||||
|
|
||||||
|
"www.trixiebooru.org" ->
|
||||||
|
"fab fa-phoenix-framework"
|
||||||
|
|
||||||
|
"derpicdn.net" ->
|
||||||
|
"fab fa-phoenix-framework"
|
||||||
|
|
||||||
|
link ->
|
||||||
|
if Enum.member?(site_domains, link), do: "favicon-home", else: "fa fa-link"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,9 +49,7 @@ defmodule Philomena.Repo.Migrations.RewriteSourceChanges do
|
||||||
check: "length(source) >= 8 and length(source) <= 1024"
|
check: "length(source) >= 8 and length(source) <= 1024"
|
||||||
)
|
)
|
||||||
|
|
||||||
create constraint(:image_sources, :image_sources_source_check,
|
create constraint(:image_sources, :image_sources_source_check, check: "source ~* '^https?://'")
|
||||||
check: "source ~* '^https?://'"
|
|
||||||
)
|
|
||||||
|
|
||||||
execute("""
|
execute("""
|
||||||
insert into image_sources (image_id, source)
|
insert into image_sources (image_id, source)
|
||||||
|
@ -122,9 +120,7 @@ defmodule Philomena.Repo.Migrations.RewriteSourceChanges do
|
||||||
|
|
||||||
execute("truncate image_sources")
|
execute("truncate image_sources")
|
||||||
|
|
||||||
drop constraint(:image_sources, :image_sources_source_check,
|
drop constraint(:image_sources, :image_sources_source_check, check: "source ~* '^https?://'")
|
||||||
check: "source ~* '^https?://'"
|
|
||||||
)
|
|
||||||
|
|
||||||
create constraint(:image_sources, :length_must_be_valid,
|
create constraint(:image_sources, :length_must_be_valid,
|
||||||
check: "length(source) >= 8 and length(source) <= 1024"
|
check: "length(source) >= 8 and length(source) <= 1024"
|
||||||
|
|
Loading…
Reference in a new issue