From a0e08f49c3320fe0eaf397a20fb477e324491c3e Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Mon, 11 Nov 2019 19:31:22 -0500 Subject: [PATCH] image page scaling --- assets/static/images/tagblocked.svg | 3 +++ .../templates/image/_image_page.html.slime | 2 +- .../templates/image/_image_target.html.slime | 14 ++++++++++++++ lib/philomena_web/views/app_view.ex | 4 ++-- lib/philomena_web/views/image_view.ex | 8 +++++--- 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 assets/static/images/tagblocked.svg create mode 100644 lib/philomena_web/templates/image/_image_target.html.slime diff --git a/assets/static/images/tagblocked.svg b/assets/static/images/tagblocked.svg new file mode 100644 index 00000000..ad17669b --- /dev/null +++ b/assets/static/images/tagblocked.svg @@ -0,0 +1,3 @@ + +Tag Hidden + diff --git a/lib/philomena_web/templates/image/_image_page.html.slime b/lib/philomena_web/templates/image/_image_page.html.slime index 1cac9e23..2f353001 100644 --- a/lib/philomena_web/templates/image/_image_page.html.slime +++ b/lib/philomena_web/templates/image/_image_page.html.slime @@ -1,6 +1,6 @@ .center--layout--flex = if @image.thumbnails_generated do - = render PhilomenaWeb.ImageView, "_image_container.html", image: @image, size: :full + = render PhilomenaWeb.ImageView, "_image_target.html", image: @image - else #thumbnails-not-yet-generated.block.block--fixed.block--warning.layout--narrow h3 Just a moment diff --git a/lib/philomena_web/templates/image/_image_target.html.slime b/lib/philomena_web/templates/image/_image_target.html.slime new file mode 100644 index 00000000..cc91aeb6 --- /dev/null +++ b/lib/philomena_web/templates/image/_image_target.html.slime @@ -0,0 +1,14 @@ += content_tag :div, [data: image_container_data(@image, :full), class: "image-show-container"] do + .block.block--fixed.block--warning.block--no-margin.image-filtered.hidden + strong + = link("This image is blocked by your current filter - click here to display it anyway", to: "#", data: [click_unfilter: @image.id]) + p + = img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/tagblocked.svg"), width: 250, height: 250, data: [click_unfilter: @image.id]) + span.filter-explanation + =< link("your current filter", to: "#", class: "filter-link") + + #image_target.hidden.image-show data-scaled="true" data-uris=Jason.encode!(thumb_urls(@image, false)) data-width=@image.image_width data-height=@image.image_height + = if @image.image_mime_type == "video/webm" do + video controls=true + - else + picture \ No newline at end of file diff --git a/lib/philomena_web/views/app_view.ex b/lib/philomena_web/views/app_view.ex index dde97b9d..6aa4a462 100644 --- a/lib/philomena_web/views/app_view.ex +++ b/lib/philomena_web/views/app_view.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.AppView do def pretty_time(time) do seconds = NaiveDateTime.diff(NaiveDateTime.utc_now(), time, :second) relation = if seconds < 0, do: "from now", else: "ago" - time = time |> DateTime.from_naive!("Etc/UTC") + time = time |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601() seconds = abs(seconds) minutes = abs(div(seconds, 60)) @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.AppView do true -> String.replace(@time_strings[:years], "%d", to_string(years)) end - content_tag(:time, "#{words} #{relation}", datetime: time |> DateTime.to_iso8601()) + content_tag(:time, "#{words} #{relation}", datetime: time, title: time) end def can?(conn, action, model) do diff --git a/lib/philomena_web/views/image_view.ex b/lib/philomena_web/views/image_view.ex index a110a1cd..e000f087 100644 --- a/lib/philomena_web/views/image_view.ex +++ b/lib/philomena_web/views/image_view.ex @@ -44,8 +44,8 @@ defmodule PhilomenaWeb.ImageView do Application.get_env(:philomena, :image_url_root) end - def image_container(image, size, block) do - data = [ + def image_container_data(image, size) do + [ image_id: image.id, image_tags: Jason.encode!(Enum.map(image.tags, & &1.id)), score: image.score, @@ -61,8 +61,10 @@ defmodule PhilomenaWeb.ImageView do aspect_ratio: image.image_aspect_ratio, size: size ] + end - content_tag(:div, block.(), class: "image-container #{size}", data: data) + def image_container(image, size, block) do + content_tag(:div, block.(), class: "image-container #{size}", data: image_container_data(image, size)) end def display_order(tags) do