mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fix source url display, provide all source urls
This commit is contained in:
parent
a569008267
commit
e0eb226abe
44 changed files with 90 additions and 70 deletions
|
@ -20,12 +20,12 @@ defmodule Philomena.Polymorphic do
|
|||
}
|
||||
|
||||
@preloads %{
|
||||
"Comment" => [:user, image: [tags: :aliases]],
|
||||
"Comment" => [:user, image: [:sources, tags: :aliases]],
|
||||
"Commission" => [:user],
|
||||
"Conversation" => [:from, :to],
|
||||
"DnpEntry" => [:requesting_user, :tag],
|
||||
"Gallery" => [:creator],
|
||||
"Image" => [:user, tags: :aliases],
|
||||
"Image" => [:user, :sources, tags: :aliases],
|
||||
"Post" => [:user, topic: :forum],
|
||||
"Topic" => [:forum, :user],
|
||||
"Report" => [:user]
|
||||
|
|
|
@ -77,7 +77,7 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
|> filter_hidden(user, conn.params["hidden"])
|
||||
|> order_by([i, f], desc: f.created_at)
|
||||
|> limit(1)
|
||||
|> preload(tags: :aliases)
|
||||
|> preload([:sources, tags: :aliases])
|
||||
|> Repo.one()
|
||||
|
||||
streams =
|
||||
|
@ -147,9 +147,9 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
Elasticsearch.msearch_records(
|
||||
[images, top_scoring, comments],
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Comment, [:user, image: [tags: :aliases]])
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Comment, [:user, image: [:sources, tags: :aliases]])
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -160,10 +160,10 @@ defmodule PhilomenaWeb.ActivityController do
|
|||
Elasticsearch.msearch_records(
|
||||
[images, top_scoring, comments, watched],
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Comment, [:user, image: [tags: :aliases]]),
|
||||
preload(Image, tags: :aliases)
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Comment, [:user, image: [:sources, tags: :aliases]]),
|
||||
preload(Image, [:sources, tags: :aliases])
|
||||
]
|
||||
)
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Api.Json.Image.FeaturedController do
|
|||
|> where([i], i.hidden_from_users == false)
|
||||
|> order_by([_i, f], desc: f.created_at)
|
||||
|> limit(1)
|
||||
|> preload([:user, :intensity, tags: :aliases])
|
||||
|> preload([:user, :intensity, :sources, tags: :aliases])
|
||||
|> Repo.one()
|
||||
|
||||
case featured_image do
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Api.Json.ImageController do
|
|||
image =
|
||||
Image
|
||||
|> where(id: ^id)
|
||||
|> preload([:user, :intensity, tags: :aliases])
|
||||
|> preload([:user, :intensity, :sources, tags: :aliases])
|
||||
|> Repo.one()
|
||||
|
||||
case image do
|
||||
|
|
|
@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Api.Json.OembedController do
|
|||
defp load_image(id) do
|
||||
Image
|
||||
|> where(id: ^id, hidden_from_users: false)
|
||||
|> preload([:user, tags: :aliases])
|
||||
|> preload([:user, :sources, tags: :aliases])
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ defmodule PhilomenaWeb.Api.Json.Search.ImageController do
|
|||
import Ecto.Query
|
||||
|
||||
def index(conn, params) do
|
||||
queryable = Image |> preload([:user, :intensity, tags: :aliases])
|
||||
queryable = Image |> preload([:user, :intensity, :sources, tags: :aliases])
|
||||
user = conn.assigns.current_user
|
||||
|
||||
case ImageLoader.search_string(conn, params["q"]) do
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule PhilomenaWeb.Api.Rss.WatchedController do
|
|||
|
||||
def index(conn, _params) do
|
||||
{:ok, {images, _tags}} = ImageLoader.search_string(conn, "my:watched")
|
||||
images = Elasticsearch.search_records(images, preload(Image, tags: :aliases))
|
||||
images = Elasticsearch.search_records(images, preload(Image, [:sources, tags: :aliases]))
|
||||
|
||||
# NB: this is RSS, but using the RSS format causes Phoenix not to
|
||||
# escape HTML
|
||||
|
|
|
@ -36,7 +36,7 @@ defmodule PhilomenaWeb.CommentController do
|
|||
conn.assigns.pagination
|
||||
)
|
||||
|> Elasticsearch.search_records(
|
||||
preload(Comment, [:deleted_by, image: [tags: :aliases], user: [awards: :badge]])
|
||||
preload(Comment, [:deleted_by, image: [:sources, tags: :aliases], user: [awards: :badge]])
|
||||
)
|
||||
|
||||
rendered = MarkdownRenderer.render_collection(comments.entries, conn)
|
||||
|
|
|
@ -74,7 +74,7 @@ defmodule PhilomenaWeb.CommissionController do
|
|||
where: ui.updated_at >= ago(2, "week"),
|
||||
group_by: c.id,
|
||||
order_by: [asc: fragment("random()")],
|
||||
preload: [user: [awards: :badge], items: [example_image: [tags: :aliases]]]
|
||||
preload: [user: [awards: :badge], items: [example_image: [:sources, tags: :aliases]]]
|
||||
end
|
||||
|
||||
defp presence(nil),
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.FingerprintProfile.SourceChangeController do
|
|||
SourceChange
|
||||
|> where(fingerprint: ^fingerprint)
|
||||
|> order_by(desc: :id)
|
||||
|> preload([:user, image: [:user, tags: :aliases]])
|
||||
|> preload([:user, image: [:user, :sources, tags: :aliases]])
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
render(conn, "index.html",
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.FingerprintProfile.TagChangeController do
|
|||
TagChange
|
||||
|> where(fingerprint: ^fingerprint)
|
||||
|> added_filter(params)
|
||||
|> preload([:tag, :user, image: [:user, tags: :aliases]])
|
||||
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
plug :load_and_authorize_resource,
|
||||
model: Gallery,
|
||||
except: [:index],
|
||||
preload: [:creator, thumbnail: [tags: :aliases]]
|
||||
preload: [:creator, thumbnail: [:sources, tags: :aliases]]
|
||||
|
||||
def index(conn, params) do
|
||||
galleries =
|
||||
|
@ -32,7 +32,9 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
},
|
||||
conn.assigns.pagination
|
||||
)
|
||||
|> Elasticsearch.search_records(preload(Gallery, [:creator, thumbnail: [tags: :aliases]]))
|
||||
|> Elasticsearch.search_records(
|
||||
preload(Gallery, [:creator, thumbnail: [:sources, tags: :aliases]])
|
||||
)
|
||||
|
||||
render(conn, "index.html",
|
||||
title: "Galleries",
|
||||
|
@ -63,9 +65,9 @@ defmodule PhilomenaWeb.GalleryController do
|
|||
Elasticsearch.msearch_records_with_hits(
|
||||
[images, gallery_prev, gallery_next],
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases)
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases])
|
||||
]
|
||||
)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Image.Comment.ReportController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
plug PhilomenaWeb.LoadCommentPlug
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Image.CommentController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
plug :verify_authorized when action in [:show]
|
||||
plug PhilomenaWeb.FilterForcedUsersPlug when action in [:create, :edit, :update]
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Image.DescriptionController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [:user, tags: :aliases]
|
||||
preload: [:user, :sources, tags: :aliases]
|
||||
|
||||
def update(conn, %{"image" => image_params}) do
|
||||
image = conn.assigns.image
|
||||
|
|
|
@ -13,7 +13,7 @@ defmodule PhilomenaWeb.Image.FaveController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
plug PhilomenaWeb.FilterForcedUsersPlug
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ defmodule PhilomenaWeb.Image.RelatedController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [:faves, tags: :aliases]
|
||||
preload: [:faves, :sources, tags: :aliases]
|
||||
|
||||
def index(conn, _params) do
|
||||
image = conn.assigns.image
|
||||
|
@ -60,7 +60,7 @@ defmodule PhilomenaWeb.Image.RelatedController do
|
|||
pagination: %{conn.assigns.image_pagination | page_number: 1}
|
||||
)
|
||||
|
||||
images = Elasticsearch.search_records(images, preload(Image, tags: :aliases))
|
||||
images = Elasticsearch.search_records(images, preload(Image, [:sources, tags: :aliases]))
|
||||
|
||||
interactions = Interactions.user_interactions(images, user)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Image.ReportController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
def new(conn, _params) do
|
||||
image = conn.assigns.image
|
||||
|
|
|
@ -11,7 +11,7 @@ defmodule PhilomenaWeb.Image.ReportingController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
def show(conn, _params) do
|
||||
image = conn.assigns.image
|
||||
|
@ -21,8 +21,8 @@ defmodule PhilomenaWeb.Image.ReportingController do
|
|||
|> preload([
|
||||
:user,
|
||||
:modifier,
|
||||
image: [:user, tags: :aliases],
|
||||
duplicate_of_image: [:user, tags: :aliases]
|
||||
image: [:user, :sources, tags: :aliases],
|
||||
duplicate_of_image: [:user, :sources, tags: :aliases]
|
||||
])
|
||||
|> where([d], d.image_id == ^image.id or d.duplicate_of_image_id == ^image.id)
|
||||
|> Repo.all()
|
||||
|
|
|
@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Image.SourceChangeController do
|
|||
source_changes =
|
||||
SourceChange
|
||||
|> where(image_id: ^image.id)
|
||||
|> preload([:user, image: [:user, tags: :aliases]])
|
||||
|> preload([:user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
TagChange
|
||||
|> where(image_id: ^image.id)
|
||||
|> added_filter(params)
|
||||
|> preload([:tag, :user, image: [:user, tags: :aliases]])
|
||||
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
plug :load_and_authorize_resource,
|
||||
model: Image,
|
||||
id_name: "image_id",
|
||||
preload: [:user, :locked_tags, tags: :aliases]
|
||||
preload: [:user, :locked_tags, :sources, tags: :aliases]
|
||||
|
||||
def update(conn, %{"image" => image_params}) do
|
||||
attributes = conn.assigns.attributes
|
||||
|
@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
|
||||
image =
|
||||
image
|
||||
|> Repo.preload([tags: :aliases], force: true)
|
||||
|> Repo.preload([:sources, tags: :aliases], force: true)
|
||||
|
||||
changeset = Images.change_image(image)
|
||||
|
||||
|
@ -78,7 +78,7 @@ defmodule PhilomenaWeb.Image.TagController do
|
|||
{:error, :image, changeset, _} ->
|
||||
image =
|
||||
image
|
||||
|> Repo.preload([tags: :aliases], force: true)
|
||||
|> Repo.preload([:sources, tags: :aliases], force: true)
|
||||
|
||||
conn
|
||||
|> put_view(PhilomenaWeb.ImageView)
|
||||
|
|
|
@ -13,7 +13,7 @@ defmodule PhilomenaWeb.Image.VoteController do
|
|||
model: Image,
|
||||
id_name: "image_id",
|
||||
persisted: true,
|
||||
preload: [tags: :aliases]
|
||||
preload: [:sources, tags: :aliases]
|
||||
|
||||
plug PhilomenaWeb.FilterForcedUsersPlug
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ defmodule PhilomenaWeb.ImageController do
|
|||
{:ok, {images, _tags}} =
|
||||
ImageLoader.search_string(conn, "created_at.lte:3 minutes ago, -thumbnails_generated:false")
|
||||
|
||||
images = Elasticsearch.search_records(images, preload(Image, tags: :aliases))
|
||||
images = Elasticsearch.search_records(images, preload(Image, [:sources, tags: :aliases]))
|
||||
|
||||
interactions = Interactions.user_interactions(images, conn.assigns.current_user)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule PhilomenaWeb.IpProfile.SourceChangeController do
|
|||
SourceChange
|
||||
|> where(ip: ^ip)
|
||||
|> order_by(desc: :id)
|
||||
|> preload([:user, image: [:user, tags: :aliases]])
|
||||
|> preload([:user, image: [:user, :sources, tags: :aliases]])
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
render(conn, "index.html",
|
||||
|
|
|
@ -14,7 +14,7 @@ defmodule PhilomenaWeb.IpProfile.TagChangeController do
|
|||
TagChange
|
||||
|> where(ip: ^ip)
|
||||
|> added_filter(params)
|
||||
|> preload([:tag, :user, image: [:user, tags: :aliases]])
|
||||
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do
|
|||
preload: [
|
||||
:verified_links,
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
sheet_image: [:sources, tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
items: [example_image: [:sources, tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
|
|
@ -20,9 +20,9 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do
|
|||
preload: [
|
||||
:verified_links,
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
sheet_image: [:sources, tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
items: [example_image: [:sources, tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
|
|
@ -15,9 +15,9 @@ defmodule PhilomenaWeb.Profile.CommissionController do
|
|||
preload: [
|
||||
:verified_links,
|
||||
commission: [
|
||||
sheet_image: [tags: :aliases],
|
||||
sheet_image: [:sources, tags: :aliases],
|
||||
user: [awards: :badge],
|
||||
items: [example_image: [tags: :aliases]]
|
||||
items: [example_image: [:sources, tags: :aliases]]
|
||||
]
|
||||
],
|
||||
persisted: true
|
||||
|
|
|
@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Profile.SourceChangeController do
|
|||
[sc, i],
|
||||
sc.user_id == ^user.id and not (i.user_id == ^user.id and i.anonymous == true)
|
||||
)
|
||||
|> preload([:user, image: [:user, tags: :aliases]])
|
||||
|> preload([:user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Profile.TagChangeController do
|
|||
tc.user_id == ^user.id and not (i.user_id == ^user.id and i.anonymous == true)
|
||||
)
|
||||
|> added_filter(params)
|
||||
|> preload([:tag, :user, image: [:user, tags: :aliases]])
|
||||
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -28,7 +28,10 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
awards: [:badge, :awarded_by],
|
||||
public_links: :tag,
|
||||
verified_links: :tag,
|
||||
commission: [sheet_image: [tags: :aliases], items: [example_image: [tags: :aliases]]]
|
||||
commission: [
|
||||
sheet_image: [:sources, tags: :aliases],
|
||||
items: [example_image: [:sources, tags: :aliases]]
|
||||
]
|
||||
]
|
||||
|
||||
plug :set_admin_metadata
|
||||
|
@ -119,10 +122,10 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
Elasticsearch.msearch_records(
|
||||
[recent_uploads, recent_faves, recent_artwork, recent_comments, recent_posts],
|
||||
[
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Image, tags: :aliases),
|
||||
preload(Comment, user: [awards: :badge], image: [tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Image, [:sources, tags: :aliases]),
|
||||
preload(Comment, user: [awards: :badge], image: [:sources, tags: :aliases]),
|
||||
preload(Post, user: [awards: :badge], topic: :forum)
|
||||
]
|
||||
)
|
||||
|
@ -144,7 +147,7 @@ defmodule PhilomenaWeb.ProfileController do
|
|||
recent_galleries =
|
||||
Gallery
|
||||
|> where(creator_id: ^user.id)
|
||||
|> preload([:creator, thumbnail: [tags: :aliases]])
|
||||
|> preload([:creator, thumbnail: [:sources, tags: :aliases]])
|
||||
|> limit(4)
|
||||
|> Repo.all()
|
||||
|
||||
|
|
|
@ -12,7 +12,12 @@ defmodule PhilomenaWeb.SearchController do
|
|||
|
||||
case ImageLoader.search_string(conn, params["q"]) do
|
||||
{:ok, {images, tags}} ->
|
||||
images = search_function(custom_ordering?(conn)).(images, preload(Image, tags: :aliases))
|
||||
images =
|
||||
search_function(custom_ordering?(conn)).(
|
||||
images,
|
||||
preload(Image, [:sources, tags: :aliases])
|
||||
)
|
||||
|
||||
interactions = Interactions.user_interactions(images, user)
|
||||
|
||||
conn
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Tag.TagChangeController do
|
|||
TagChange
|
||||
|> where(tag_id: ^tag.id)
|
||||
|> added_filter(params)
|
||||
|> preload([:tag, :user, image: [:user, tags: :aliases]])
|
||||
|> preload([:tag, :user, image: [:user, :sources, tags: :aliases]])
|
||||
|> order_by(desc: :id)
|
||||
|> Repo.paginate(conn.assigns.scrivener)
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ defmodule PhilomenaWeb.TagController do
|
|||
|
||||
{images, _tags} = ImageLoader.query(conn, %{term: %{"namespaced_tags.name" => tag.name}})
|
||||
|
||||
images = Elasticsearch.search_records(images, preload(Image, tags: :aliases))
|
||||
images = Elasticsearch.search_records(images, preload(Image, [:sources, tags: :aliases]))
|
||||
|
||||
interactions = Interactions.user_interactions(images, user)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ defmodule PhilomenaWeb.ImageReverse do
|
|||
dist = normalize_dist(image_params)
|
||||
|
||||
DuplicateReports.duplicates_of(intensities, aspect, dist, dist)
|
||||
|> preload([:user, :intensity, [tags: :aliases]])
|
||||
|> preload([:user, :intensity, [:sources, tags: :aliases]])
|
||||
|> Repo.all()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ defmodule PhilomenaWeb.MarkdownRenderer do
|
|||
|
||||
Image
|
||||
|> where([i], i.id in ^ids)
|
||||
|> preload(tags: :aliases)
|
||||
|> preload([:sources, tags: :aliases])
|
||||
|> Repo.all()
|
||||
|> Map.new(&{&1.id, &1})
|
||||
end
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
p Loading...
|
||||
.block__tab.hidden data-tab="sharing"
|
||||
#embed_options
|
||||
- source_link = if @image.source_url in [nil, ""], do: " (Original source unknown at time of posting)", else: " - [url=#{@image.source_url}]Original source[/url]"
|
||||
- source_link = if image_has_sources(@image), do: " - [url=#{image_first_source(@image)}]Original source[/url]", else: " (Original source unknown at time of posting)"
|
||||
h5 Derpibooru
|
||||
p
|
||||
strong> Small thumbnail
|
||||
|
|
|
@ -17,8 +17,8 @@ meta name="format-detection" content="telephone=no"
|
|||
= for tag <- artist_tags(image.tags) do
|
||||
meta property="dc:creator" content=tag.name_in_namespace
|
||||
|
||||
= if image.source_url not in [nil, ""] do
|
||||
meta property="foaf:primaryTopic" content=image.source_url
|
||||
= if image_has_sources(image) do
|
||||
meta property="foaf:primaryTopic" content=image_first_source(image)
|
||||
|
||||
link rel="alternate" type="application/json+oembed" href=Routes.api_json_oembed_url(@conn, :index, url: Routes.image_path(@conn, :show, image)) title="oEmbed JSON Profile"
|
||||
|
||||
|
|
|
@ -48,9 +48,9 @@ h1 Reverse Search
|
|||
th
|
||||
h3 = link "##{match.id}", to: Routes.image_path(@conn, :show, match)
|
||||
p
|
||||
= if match.source_url not in [nil, ""] do
|
||||
= if image_has_sources(match) do
|
||||
span.source_url
|
||||
= link "Source", to: match.source_url
|
||||
= link "Source", to: image_first_source(match)
|
||||
- else
|
||||
' Unknown source
|
||||
|
||||
|
|
|
@ -80,7 +80,9 @@ defmodule PhilomenaWeb.Api.Json.ImageView do
|
|||
comment_count: image.comments_count,
|
||||
tag_count: length(image.tags),
|
||||
description: image.description,
|
||||
source_url: image.source_url,
|
||||
source_url:
|
||||
if(Enum.count(image.sources) > 0, do: Enum.at(image.sources, 0).source, else: ""),
|
||||
source_urls: Enum.map(image.sources, & &1.source),
|
||||
view_url: ImageView.pretty_url(image, false, false),
|
||||
representations: ImageView.thumb_urls(image, false),
|
||||
thumbnails_generated: image.thumbnails_generated,
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Api.Json.OembedView do
|
|||
version: "1.0",
|
||||
type: "photo",
|
||||
title: "##{image.id} - #{tag_list(image)} - Derpibooru",
|
||||
author_url: image.source_url || "",
|
||||
author_url: image_first_source(image),
|
||||
author_name: artist_tags(image.tags),
|
||||
provider_name: "Derpibooru",
|
||||
provider_url: PhilomenaWeb.Endpoint.url(),
|
||||
|
|
|
@ -241,6 +241,12 @@ defmodule PhilomenaWeb.AppView do
|
|||
]
|
||||
end
|
||||
|
||||
def image_has_sources(image), do: Enum.count(image.sources) > 0
|
||||
|
||||
def image_first_source(image) do
|
||||
if image_has_sources(image), do: Enum.at(image.sources, 0).source, else: ""
|
||||
end
|
||||
|
||||
def get_flash(%{assigns: %{flash: nil}}), do: %{}
|
||||
def get_flash(%{assigns: %{flash: flash}}), do: flash
|
||||
def get_flash(_), do: %{}
|
||||
|
|
|
@ -162,7 +162,9 @@ defmodule PhilomenaWeb.ImageView do
|
|||
downvotes: image.downvotes_count,
|
||||
comment_count: image.comments_count,
|
||||
created_at: DateTime.to_iso8601(image.created_at),
|
||||
source_url: image.source_url,
|
||||
source_url:
|
||||
if(Enum.count(image.sources) > 0, do: Enum.at(image.sources, 0).source, else: ""),
|
||||
source_urls: Jason.encode!(Enum.map(image.sources, & &1.source)),
|
||||
uris: Jason.encode!(thumb_urls(image, can?(conn, :show, image))),
|
||||
width: image.image_width,
|
||||
height: image.image_height,
|
||||
|
|
Loading…
Reference in a new issue