Compare commits
1 commit
master
...
ke/display
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebf5d6afb5 |
4 changed files with 53 additions and 0 deletions
|
|
@ -62,6 +62,31 @@ defmodule PinchflatWeb.Sources.SourceController do
|
||||||
render(conn, :show, source: source, pending_tasks: pending_tasks)
|
render(conn, :show, source: source, pending_tasks: pending_tasks)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: test
|
||||||
|
# TODO: also do for media items
|
||||||
|
# TODO: check to see if I've lost the plot here
|
||||||
|
def show_image(conn, %{"source_id" => id, "image_type" => image_type}) do
|
||||||
|
source = Sources.get_source!(id)
|
||||||
|
|
||||||
|
filepath =
|
||||||
|
case image_type do
|
||||||
|
"poster" -> source.poster_filepath
|
||||||
|
"fanart" -> source.fanart_filepath
|
||||||
|
"banner" -> source.banner_filepath
|
||||||
|
_ -> nil
|
||||||
|
end
|
||||||
|
|
||||||
|
if filepath && File.exists?(filepath) do
|
||||||
|
conn
|
||||||
|
|> put_resp_content_type(MIME.from_path(filepath))
|
||||||
|
|> send_file(200, filepath)
|
||||||
|
else
|
||||||
|
conn
|
||||||
|
|> put_status(404)
|
||||||
|
|> text("Image not found")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit(conn, %{"id" => id}) do
|
def edit(conn, %{"id" => id}) do
|
||||||
source = Sources.get_source!(id)
|
source = Sources.get_source!(id)
|
||||||
changeset = Sources.change_source(source)
|
changeset = Sources.change_source(source)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,16 @@ defmodule PinchflatWeb.Sources.SourceHTML do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def source_image_mapping(source) do
|
||||||
|
image_mapping = [
|
||||||
|
{"Poster", source.poster_filepath, "poster"},
|
||||||
|
{"Banner", source.banner_filepath, "banner"},
|
||||||
|
{"Fanart", source.fanart_filepath, "fanart"}
|
||||||
|
]
|
||||||
|
|
||||||
|
Enum.filter(image_mapping, fn {_, filepath, _} -> filepath end)
|
||||||
|
end
|
||||||
|
|
||||||
def rss_feed_url(conn, source) do
|
def rss_feed_url(conn, source) do
|
||||||
url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml"
|
url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,23 @@
|
||||||
<.list_items_from_map map={Map.from_struct(@source)} />
|
<.list_items_from_map map={Map.from_struct(@source)} />
|
||||||
</div>
|
</div>
|
||||||
</:tab>
|
</:tab>
|
||||||
|
<:tab title="Images">
|
||||||
|
<section>
|
||||||
|
<h3 class="font-bold text-xl mt-6 mb-4">Images</h3>
|
||||||
|
<%= if source_image_mapping(@source) == [] do %>
|
||||||
|
<p class="text-black dark:text-white">Nothing Here!</p>
|
||||||
|
<% else %>
|
||||||
|
<div class="grid grid-cols-1 gap-4 lg:grid-cols-3">
|
||||||
|
<div :for={{name, _, image_type} <- source_image_mapping(@source)}>
|
||||||
|
<span><%= name %></span>
|
||||||
|
<a href={~p"/sources/#{@source}/image/#{image_type}"} target="_blank">
|
||||||
|
<img src={~p"/sources/#{@source}/image/#{image_type}"} alt={name} class="w-full h-auto" />
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
</:tab>
|
||||||
<:tab title="Pending Media">
|
<:tab title="Pending Media">
|
||||||
<%= live_render(
|
<%= live_render(
|
||||||
@conn,
|
@conn,
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ defmodule PinchflatWeb.Router do
|
||||||
resources "/settings", Settings.SettingController, only: [:show, :update], singleton: true
|
resources "/settings", Settings.SettingController, only: [:show, :update], singleton: true
|
||||||
|
|
||||||
resources "/sources", Sources.SourceController do
|
resources "/sources", Sources.SourceController do
|
||||||
|
get "/image/:image_type", Sources.SourceController, :show_image
|
||||||
post "/force_download", Sources.SourceController, :force_download
|
post "/force_download", Sources.SourceController, :force_download
|
||||||
post "/force_index", Sources.SourceController, :force_index
|
post "/force_index", Sources.SourceController, :force_index
|
||||||
post "/force_metadata_refresh", Sources.SourceController, :force_metadata_refresh
|
post "/force_metadata_refresh", Sources.SourceController, :force_metadata_refresh
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue