From 8619726d9ec0d5f0a50c99245ce01aef4612386a Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 17 Nov 2019 17:51:14 -0500 Subject: [PATCH] add appropriate layout classes --- .../controllers/activity_controller.ex | 3 ++- lib/philomena_web/controllers/comment_controller.ex | 2 +- lib/philomena_web/controllers/image_controller.ex | 5 +++-- lib/philomena_web/controllers/post_controller.ex | 2 +- lib/philomena_web/controllers/search_controller.ex | 2 +- lib/philomena_web/controllers/tag_controller.ex | 2 +- .../templates/layout/_header.html.slime | 13 +++++-------- lib/philomena_web/templates/layout/app.html.slime | 2 +- .../templates/notification/index.html.slime | 1 + lib/philomena_web/views/layout_view.ex | 4 ++++ 10 files changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/philomena_web/controllers/activity_controller.ex b/lib/philomena_web/controllers/activity_controller.ex index e2fd606f..c09c8e27 100644 --- a/lib/philomena_web/controllers/activity_controller.ex +++ b/lib/philomena_web/controllers/activity_controller.ex @@ -132,7 +132,8 @@ defmodule PhilomenaWeb.ActivityController do featured_image: featured_image, streams: streams, topics: topics, - interactions: interactions + interactions: interactions, + layout_class: "layout--wide" ) end end diff --git a/lib/philomena_web/controllers/comment_controller.ex b/lib/philomena_web/controllers/comment_controller.ex index 36da8307..ab72ff87 100644 --- a/lib/philomena_web/controllers/comment_controller.ex +++ b/lib/philomena_web/controllers/comment_controller.ex @@ -28,7 +28,7 @@ defmodule PhilomenaWeb.CommentController do comments = %{comments | entries: Enum.zip(comments.entries, rendered)} - render(conn, "index.html", comments: comments) + render(conn, "index.html", comments: comments, layout_class: "layout--wide") end defp parse_search(conn, %{"comment" => comment_params}) do diff --git a/lib/philomena_web/controllers/image_controller.ex b/lib/philomena_web/controllers/image_controller.ex index 90787481..af9a1303 100644 --- a/lib/philomena_web/controllers/image_controller.ex +++ b/lib/philomena_web/controllers/image_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.ImageController do interactions = Interactions.user_interactions(images, conn.assigns.current_user) - render(conn, "index.html", images: images, interactions: interactions) + render(conn, "index.html", layout_class: "layout--wide", images: images, interactions: interactions) end def show(conn, %{"id" => _id}) do @@ -68,7 +68,8 @@ defmodule PhilomenaWeb.ImageController do comment_changeset: comment_changeset, description: description, interactions: interactions, - watching: watching + watching: watching, + layout_class: "layout--wide" ) end end diff --git a/lib/philomena_web/controllers/post_controller.ex b/lib/philomena_web/controllers/post_controller.ex index 34a0d637..b0915e11 100644 --- a/lib/philomena_web/controllers/post_controller.ex +++ b/lib/philomena_web/controllers/post_controller.ex @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.PostController do forums = [{"-", ""} | forums] - render(conn, "index.html", posts: posts, forums: forums) + render(conn, "index.html", posts: posts, forums: forums, layout_class: "layout--wide") end defp parse_search(conn, %{"post" => post_params}) do diff --git a/lib/philomena_web/controllers/search_controller.ex b/lib/philomena_web/controllers/search_controller.ex index 35b53f5b..4970696a 100644 --- a/lib/philomena_web/controllers/search_controller.ex +++ b/lib/philomena_web/controllers/search_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.SearchController do Interactions.user_interactions(images, user) conn - |> render("index.html", images: images, search_query: params["q"], interactions: interactions) + |> render("index.html", images: images, search_query: params["q"], interactions: interactions, layout_class: "layout--wide") else {:error, msg} -> conn diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 02687f88..56cb6967 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -41,6 +41,6 @@ defmodule PhilomenaWeb.TagController do Image |> preload([:tags, :user]) ) - render(conn, "show.html", tag: tag, images: images) + render(conn, "show.html", tag: tag, images: images, layout_class: "layout--wide") end end diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index 16540fe1..dfc0dae1 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -23,12 +23,9 @@ header.header .flex.flex--centered.flex--no-wrap.header__force-right = if @current_user do - - notification_count = @conn.assigns.notification_count - - conversation_count = @conn.assigns.conversation_count - a.header__link href="/notifications" title="Notifications" i.fa-embedded--notification> - span.js-notification-ticker.fa__text.header__counter data-notification-count=notification_count = notification_count + span.js-notification-ticker.fa__text.header__counter data-notification-count=@notification_count = @notification_count a.header__link href="/conversations" title="Conversations" = if @conversation_count > 0 do @@ -44,11 +41,11 @@ header.header i.fa.fa-filter span.hide-limited-desktop< Filters - = form_for @conn.assigns.user_changeset, Routes.filter_current_path(@conn, :update), [class: "header__filter-form", id: "filter-quick-form"], fn f -> - = select f, :current_filter_id, @conn.assigns.available_filters, name: "id", id: "filter-quick-menu", class: "input header__input", data: [change_submit: "#filter-quick-form"], autocomplete: "off" + = form_for @user_changeset, Routes.filter_current_path(@conn, :update), [class: "header__filter-form", id: "filter-quick-form"], fn f -> + = select f, :current_filter_id, @available_filters, name: "id", id: "filter-quick-menu", class: "input header__input", data: [change_submit: "#filter-quick-form"], autocomplete: "off" - = form_for @conn.assigns.user_changeset, Routes.filter_spoiler_type_path(@conn, :update), [class: "header__filter-form hide-mobile hide-limited-desktop", id: "spoiler-quick-form"], fn f -> - = select f, :spoiler_type, @conn.assigns.spoiler_types, id: "spoiler-quick-menu", class: "input header__input", data: [change_submit: "#spoiler-quick-form"], autocomplete: "off" + = form_for @user_changeset, Routes.filter_spoiler_type_path(@conn, :update), [class: "header__filter-form hide-mobile hide-limited-desktop", id: "spoiler-quick-form"], fn f -> + = select f, :spoiler_type, @spoiler_types, id: "spoiler-quick-menu", class: "input header__input", data: [change_submit: "#spoiler-quick-form"], autocomplete: "off" .dropdown.header__dropdown a.header__link.header__link-user href="/" diff --git a/lib/philomena_web/templates/layout/app.html.slime b/lib/philomena_web/templates/layout/app.html.slime index 06e69b00..66a0e825 100644 --- a/lib/philomena_web/templates/layout/app.html.slime +++ b/lib/philomena_web/templates/layout/app.html.slime @@ -24,7 +24,7 @@ html lang="en" #container = render PhilomenaWeb.LayoutView, "_header.html", assigns = render PhilomenaWeb.LayoutView, "_flash_warnings.html", assigns - main#content class="layout--wide" + main#content class=layout_class(@conn) = render @view_module, @view_template, assigns = render PhilomenaWeb.LayoutView, "_footer.html", assigns = clientside_data(@conn) \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/index.html.slime b/lib/philomena_web/templates/notification/index.html.slime index 93ccd547..b755f11d 100644 --- a/lib/philomena_web/templates/notification/index.html.slime +++ b/lib/philomena_web/templates/notification/index.html.slime @@ -8,5 +8,6 @@ h1 Notification Area = for notification <- @notifications do = render PhilomenaWeb.NotificationView, "_notification.html", notification: notification, conn: @conn +br p To get notifications on new comments and forum posts, click the 'Subscribe' button in the bar at the top of an image or forum topic. You'll get notifications here for any new posts or comments. p By default you'll be subscribed to any images or topics you reply to. You can configure this in your user settings page. diff --git a/lib/philomena_web/views/layout_view.ex b/lib/philomena_web/views/layout_view.ex index dc5559bf..311cc938 100644 --- a/lib/philomena_web/views/layout_view.ex +++ b/lib/philomena_web/views/layout_view.ex @@ -1,6 +1,10 @@ defmodule PhilomenaWeb.LayoutView do use PhilomenaWeb, :view + def layout_class(conn) do + conn.assigns[:layout_class] || "layout--narrow" + end + def render_time(conn) do (Time.diff(Time.utc_now(), conn.assigns[:start_time], :microsecond) / 1000.0) |> Float.round(3)