mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 02:24:24 +00:00
[WIP]
This commit is contained in:
parent
98c2812ee8
commit
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)
|
||||
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
|
||||
source = Sources.get_source!(id)
|
||||
changeset = Sources.change_source(source)
|
||||
|
|
|
|||
|
|
@ -25,6 +25,16 @@ defmodule PinchflatWeb.Sources.SourceHTML do
|
|||
]
|
||||
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
|
||||
url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,6 +36,23 @@
|
|||
<.list_items_from_map map={Map.from_struct(@source)} />
|
||||
</div>
|
||||
</: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">
|
||||
<%= live_render(
|
||||
@conn,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ defmodule PinchflatWeb.Router do
|
|||
resources "/settings", Settings.SettingController, only: [:show, :update], singleton: true
|
||||
|
||||
resources "/sources", Sources.SourceController do
|
||||
get "/image/:image_type", Sources.SourceController, :show_image
|
||||
post "/force_download", Sources.SourceController, :force_download
|
||||
post "/force_index", Sources.SourceController, :force_index
|
||||
post "/force_metadata_refresh", Sources.SourceController, :force_metadata_refresh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue