aboutsummaryrefslogtreecommitdiff
path: root/lib/waev_web
diff options
context:
space:
mode:
Diffstat (limited to 'lib/waev_web')
-rw-r--r--lib/waev_web/controllers/exports_controller.ex19
-rw-r--r--lib/waev_web/router.ex1
-rw-r--r--lib/waev_web/templates/exports/show.html.eex8
3 files changed, 21 insertions, 7 deletions
diff --git a/lib/waev_web/controllers/exports_controller.ex b/lib/waev_web/controllers/exports_controller.ex
index 764accf..f2b6fb4 100644
--- a/lib/waev_web/controllers/exports_controller.ex
+++ b/lib/waev_web/controllers/exports_controller.ex
@@ -15,15 +15,28 @@ defmodule WaevWeb.ExportsController do
end
def get_media(conn, %{"id" => id, "at_id" => at_id}) do
- case Waev.Export.Message.File.path(id, at_id) do
- {:ok, path} ->
+ case Waev.Export.Message.File.media_path(id, at_id) do
+ nil ->
+ conn
+ |> put_status(:not_found)
+ |> put_view(WaevWeb.ErrorView)
+ |> render("404.html")
+
+ path ->
send_download(conn, {:file, path}, filename: at_id)
+ end
+ end
- :error ->
+ def get_avatar(conn, %{"id" => id, "av_id" => av_id}) do
+ case Waev.Export.Party.avatar_path(id, av_id) do
+ nil ->
conn
|> put_status(:not_found)
|> put_view(WaevWeb.ErrorView)
|> render("404.html")
+
+ path ->
+ send_download(conn, {:file, path}, filename: av_id)
end
end
end
diff --git a/lib/waev_web/router.ex b/lib/waev_web/router.ex
index 1e9ed0f..29d1b20 100644
--- a/lib/waev_web/router.ex
+++ b/lib/waev_web/router.ex
@@ -20,6 +20,7 @@ defmodule WaevWeb.Router do
# index,edit,new,show,create,update
resources "/exports", ExportsController, only: [:show]
get "/exports/:id/media/:at_id", ExportsController, :get_media
+ get "/exports/:id/avatars/:av_id", ExportsController, :get_avatar
end
# Other scopes may use custom stacks.
diff --git a/lib/waev_web/templates/exports/show.html.eex b/lib/waev_web/templates/exports/show.html.eex
index 265374a..4d7de74 100644
--- a/lib/waev_web/templates/exports/show.html.eex
+++ b/lib/waev_web/templates/exports/show.html.eex
@@ -1,9 +1,11 @@
<div class="container">
<div class="row">
<div class="column column-50 wa-avatar">
+ <img alt="<%= @export.left.name %>" src="<%= Routes.exports_path(@conn, :get_avatar, @id, @export.left.name) %>" />
<%= @export.left.name %>
</div>
<div class="column column-50 wa-avatar">
+ <img alt="<%= @export.right.name %>" src="<%= Routes.exports_path(@conn, :get_avatar, @id, @export.right.name) %>" />
<%= @export.right.name %>
</div>
</div>
@@ -20,15 +22,13 @@
<div class="wa-message">
<%= case message.attachment do %>
- <% %Waev.Export.Message.File{filename: filename, available: true, type: :photo} -> %>
+ <% %Waev.Export.Message.File{filename: filename, type: :image} -> %>
<img class="wa-message-photo" alt="<%= filename %>" src="<%= Routes.exports_path(@conn, :get_media, @id, filename) %>" />
<% _ -> %>
<% end %>
<div class="wa-message-box">
<%= case message.attachment do %>
- <% %Waev.Export.Message.File{filename: filename, available: false} -> %>
- <i class="wa-message-text"><%= filename %></i> (fichero adjunto no disponible)
- <% %Waev.Export.Message.File{filename: filename, available: true, type: :file} -> %>
+ <% %Waev.Export.Message.File{filename: filename, type: :file} -> %>
<a class="wa-message-text" href="<%= Routes.exports_path(@conn, :get_media, @id, filename) %>"><%= filename %></a>
<% _ -> %>
<% end %>