diff --git a/assets/js/staffhider.js b/assets/js/staffhider.js index 4f3d2339..2a2e3035 100644 --- a/assets/js/staffhider.js +++ b/assets/js/staffhider.js @@ -7,7 +7,7 @@ import { $$ } from './utils/dom'; function hideStaffTools() { - if (window.booru.hideStaffTools) { + if (window.booru.hideStaffTools == "true") { $$('.js-staff-action').forEach(el => { el.classList.add('hidden'); }); diff --git a/lib/philomena_web/controllers/setting_controller.ex b/lib/philomena_web/controllers/setting_controller.ex index 9294374c..3627b0e8 100644 --- a/lib/philomena_web/controllers/setting_controller.ex +++ b/lib/philomena_web/controllers/setting_controller.ex @@ -39,6 +39,7 @@ defmodule PhilomenaWeb.SettingController do |> set_cookie(user_params, "hidpi", "hidpi") |> set_cookie(user_params, "webm", "webm") |> set_cookie(user_params, "chan_nsfw", "chan_nsfw") + |> set_cookie(user_params, "hide_staff_tools", "hide_staff_tools") end defp set_cookie(conn, params, param_name, cookie_name) do diff --git a/lib/philomena_web/templates/comment/_comment.html.slime b/lib/philomena_web/templates/comment/_comment.html.slime index 4c1bc5f8..5bc4b1ee 100644 --- a/lib/philomena_web/templates/comment/_comment.html.slime +++ b/lib/philomena_web/templates/comment/_comment.html.slime @@ -53,9 +53,9 @@ article.block.communication id="comment_#{@comment.id}" - true -> = if can?(@conn, :show, :ip_address) do - .communication__info + .communication__info.js-staff-action =<> link_to_ip(@conn, @comment.ip) - .communication__info + .communication__info.js-staff-action =<> link_to_fingerprint(@conn, @comment.fingerprint) = form_for :comment, Routes.image_comment_hide_path(@conn, :create, @comment.image_id, @comment), [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> diff --git a/lib/philomena_web/templates/comment/_comment_with_image.html.slime b/lib/philomena_web/templates/comment/_comment_with_image.html.slime index 631e209b..2f38b379 100644 --- a/lib/philomena_web/templates/comment/_comment_with_image.html.slime +++ b/lib/philomena_web/templates/comment/_comment_with_image.html.slime @@ -58,9 +58,9 @@ article.block.communication id="comment_#{@comment.id}" - true -> = if can?(@conn, :show, :ip_address) do - .communication__info + .communication__info.js-staff-action =<> link_to_ip(@conn, @comment.ip) - .communication__info + .communication__info.js-staff-action =<> link_to_fingerprint(@conn, @comment.fingerprint) = form_for :comment, Routes.image_comment_hide_path(@conn, :create, @comment.image_id, @comment), [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> diff --git a/lib/philomena_web/templates/image/_deleted_toggle.html.slime b/lib/philomena_web/templates/image/_deleted_toggle.html.slime index 426c5a89..bcc61343 100644 --- a/lib/philomena_web/templates/image/_deleted_toggle.html.slime +++ b/lib/philomena_web/templates/image/_deleted_toggle.html.slime @@ -1,31 +1,31 @@ - del = @conn.params["del"] = if blank?(del) do - a href=@route.(Keyword.put(@params, :del, 1)) title="Include Deleted/Merged Images" + a.js-staff-action href=@route.(Keyword.put(@params, :del, 1)) title="Include Deleted/Merged Images" i.fa.fa-plus i.fa.fa-exclamation> span.hide-mobile.hide-limited-desktop Show Deleted = if del != "only" do - a href=@route.(Keyword.put(@params, :del, "only")) title="Only Deleted/Merged Images" + a.js-staff-action href=@route.(Keyword.put(@params, :del, "only")) title="Only Deleted/Merged Images" i.fa.fa-minus i.fa.fa-check> span.hide-mobile.hide-limited-desktop Only Deleted = if del == "only" do - a href=@route.(Keyword.put(@params, :del, 1)) title="Include Images Visible to Users" + a.js-staff-action href=@route.(Keyword.put(@params, :del, 1)) title="Include Images Visible to Users" i.fa.fa-plus i.fa.fa-check> span.hide-mobile.hide-limited-desktop Show Non-Deleted = if present?(del) do - a href=@route.(Keyword.delete(@params, :del)) title="Hide Deleted/Merged Images" + a.js-staff-action href=@route.(Keyword.delete(@params, :del)) title="Hide Deleted/Merged Images" i.fa.fa-minus i.fa.fa-exclamation> span.hide-mobile.hide-limited-desktop Hide Deleted = if present?(del) and del != "deleted" do - a href=@route.(Keyword.put(@params, :del, "deleted")) title="Only Deleted (Strict)" + a.js-staff-action href=@route.(Keyword.put(@params, :del, "deleted")) title="Only Deleted (Strict)" i.fa.fa-minus i.fa.fa-object-group> span.hide-mobile.hide-limited-desktop Exclude Merges diff --git a/lib/philomena_web/templates/image/_options.html.slime b/lib/philomena_web/templates/image/_options.html.slime index b779fe7f..d12b2dd0 100644 --- a/lib/philomena_web/templates/image/_options.html.slime +++ b/lib/philomena_web/templates/image/_options.html.slime @@ -11,7 +11,7 @@ a href="#" data-click-tab="favoriters" data-load-tab=Routes.image_favorite_path(@conn, :index, @image) i.fa.fa-star> | List favoriters - = if display_mod_tools? do + = if display_mod_tools? and not hide_staff_tools?(@conn) do a href="#" data-click-tab="replace" i.fa.fa-upload> | Replace diff --git a/lib/philomena_web/templates/image/_source.html.slime b/lib/philomena_web/templates/image/_source.html.slime index 023d0aa6..4baccf80 100644 --- a/lib/philomena_web/templates/image/_source.html.slime +++ b/lib/philomena_web/templates/image/_source.html.slime @@ -42,7 +42,7 @@ = @source_change_count | ) - = if can?(@conn, :hide, @image) do + = if can?(@conn, :hide, @image) and not hide_staff_tools?(@conn) do = form_for @changeset, Routes.image_source_history_path(@conn, :delete, @image), [method: "delete"], fn _f -> button.button.button--state-danger.button--separate-left type="submit" data-confirm="Are you really, really sure?" title="Wipe sources" i.fas.fa-eraser> diff --git a/lib/philomena_web/templates/image/_uploader.html.slime b/lib/philomena_web/templates/image/_uploader.html.slime index 6a03412d..0711fa7c 100644 --- a/lib/philomena_web/templates/image/_uploader.html.slime +++ b/lib/philomena_web/templates/image/_uploader.html.slime @@ -2,7 +2,7 @@ span.image_uploader ' by => render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @image, awards: true, conn: @conn - = if can?(@conn, :show, :ip_address) do + = if can?(@conn, :show, :ip_address) and not hide_staff_tools?(@conn) do => link_to_ip(@conn, @image.ip) => link_to_fingerprint(@conn, @image.fingerprint) a#edit-uploader href="#" data-click-hide=".image_uploader" data-click-show="#uploader-form" diff --git a/lib/philomena_web/templates/image/comment/index.html.slime b/lib/philomena_web/templates/image/comment/index.html.slime index b84675ad..7678a5da 100644 --- a/lib/philomena_web/templates/image/comment/index.html.slime +++ b/lib/philomena_web/templates/image/comment/index.html.slime @@ -13,7 +13,7 @@ elixir: i.fa.fa-sync span.hide-mobile<> Refresh -= for {comment, body} <- @comments, not comment.destroyed_content or can?(@conn, :show, comment) do += for {comment, body} <- @comments, not comment.destroyed_content or (can?(@conn, :show, comment) and not hide_staff_tools?(@conn)) do = render PhilomenaWeb.CommentView, "_comment.html", comment: comment, body: body, conn: @conn .block diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index 4bb3cf1b..6cc57fb7 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -20,7 +20,7 @@ header.header input type="hidden" name="sd" value=@conn.params["sd"] = if hides_images?(@conn) do - = select f, :del, [{"-D", ""}, {"+D", 1}, {"*D", "deleted"}, {"DO", "only"}], name: "del", class: "input header__input", autocomplete: "off" + = select f, :del, [{"-D", ""}, {"+D", 1}, {"*D", "deleted"}, {"DO", "only"}], name: "del", class: "input header__input js-staff-action", autocomplete: "off" button.header__search__button type="submit" title="Search" i.fa-embedded--search diff --git a/lib/philomena_web/templates/layout/_header_staff_links.html.slime b/lib/philomena_web/templates/layout/_header_staff_links.html.slime index a308bb2f..385add61 100644 --- a/lib/philomena_web/templates/layout/_header_staff_links.html.slime +++ b/lib/philomena_web/templates/layout/_header_staff_links.html.slime @@ -1,4 +1,3 @@ -/ Dummy view for the admin bar .flex.flex--centered.header--secondary__admin-links.stretched-mobile-links.js-staff-action .dropdown.hide-mobile a.header__link title="Admin" diff --git a/lib/philomena_web/templates/post/_post.html.slime b/lib/philomena_web/templates/post/_post.html.slime index be025f6d..1293fa1d 100644 --- a/lib/philomena_web/templates/post/_post.html.slime +++ b/lib/philomena_web/templates/post/_post.html.slime @@ -32,7 +32,7 @@ article.block.communication id="post_#{@post.id}" .flex.flex--wrap.flex--spaced-out = render PhilomenaWeb.PostView, "_post_options.html", conn: @conn, post: @post - = if can?(@conn, :hide, @post) do + = if can?(@conn, :hide, @post) and not hide_staff_tools?(@conn) do = cond do - @post.hidden_from_users and not @post.destroyed_content -> = link(to: Routes.forum_topic_post_hide_path(@conn, :delete, @post.topic.forum, @post.topic, @post), data: [confirm: "Are you sure?"], method: "delete", class: "communication__interaction") do diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index 0b29191b..c140e279 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -36,7 +36,8 @@ li = link("Source changes", to: Routes.profile_source_change_path(@conn, :index, @user)) = if can_index_user?(@conn) do - = render PhilomenaWeb.ProfileView, "_admin_block.html", assigns + .js-staff-action + = render PhilomenaWeb.ProfileView, "_admin_block.html", assigns = if (current?(@user, @conn.assigns.current_user) or can?(@conn, :index, Philomena.Bans.User)) and Enum.any?(@bans) do .block @@ -79,7 +80,7 @@ ' Edit .block - = if manages_awards?(@conn) do + = if manages_awards?(@conn) and not hide_staff_tools?(@conn) do a.block__header--single-item href=Routes.profile_award_path(@conn, :new, @user) Badges - else .block__header @@ -110,7 +111,7 @@ = render PhilomenaWeb.ProfileView, "_about_me.html", user: @user, about_me: @about_me, conn: @conn - = if can_read_mod_notes?(@conn) do + = if can_read_mod_notes?(@conn) and not hide_staff_tools?(@conn) do .block a.block__header--single-item href=Routes.profile_detail_path(@conn, :index, @user) Mod Notes table.table diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index ee5c9795..048bc767 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -122,6 +122,11 @@ h1 Content Settings => label f, :chan_nsfw, "Show NSFW channels" => checkbox f, :chan_nsfw .fieldlabel: i Show streams marked as NSFW on the channels page. + = if @conn.assigns.current_user.role != "user" do + .field + => label f, :hide_staff_tools + => checkbox f, :hide_staff_tools, class: "checkbox" + .fieldlabel: i Hide most of the staff tools (e.g. IPs, anon names) making your site appear as if you weren't staff, this is useful when browsing in public. = if !@conn.assigns.current_user do .block__tab.hidden data-tab="join-the-herd" diff --git a/lib/philomena_web/templates/user_attribution/_anon_user.html.slime b/lib/philomena_web/templates/user_attribution/_anon_user.html.slime index 4c7c6ba3..b27abcb2 100644 --- a/lib/philomena_web/templates/user_attribution/_anon_user.html.slime +++ b/lib/philomena_web/templates/user_attribution/_anon_user.html.slime @@ -5,10 +5,10 @@ = if assigns[:awards] do = render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards - - not is_nil(@object.user) and can?(@conn, :reveal_anon, @object) -> + - not is_nil(@object.user) and (can?(@conn, :reveal_anon, @object) and not hide_staff_tools?(@conn)) -> strong<> = link(anonymous_name(@object, true), to: Routes.profile_path(@conn, :show, @object.user)) - true -> strong<> - = anonymous_name(@object) \ No newline at end of file + = anonymous_name(@object) diff --git a/lib/philomena_web/views/app_view.ex b/lib/philomena_web/views/app_view.ex index f7f14ec6..bb615e59 100644 --- a/lib/philomena_web/views/app_view.ex +++ b/lib/philomena_web/views/app_view.ex @@ -150,6 +150,9 @@ defmodule PhilomenaWeb.AppView do def communication_body_class(%{destroyed_content: true}), do: "communication--destroyed" def communication_body_class(_communication), do: nil + def hide_staff_tools?(conn), + do: conn.cookies["hide_staff_tools"] == "true" + def blank?(nil), do: true def blank?(""), do: true def blank?([]), do: true diff --git a/lib/philomena_web/views/layout_view.ex b/lib/philomena_web/views/layout_view.ex index 9c9715f0..78423656 100644 --- a/lib/philomena_web/views/layout_view.ex +++ b/lib/philomena_web/views/layout_view.ex @@ -32,6 +32,7 @@ defmodule PhilomenaWeb.LayoutView do interactions = Map.get(conn.assigns, :interactions, []) user = conn.assigns.current_user filter = conn.assigns.current_filter + conn = Plug.Conn.fetch_cookies(conn) data = [ filter_id: filter.id, @@ -49,7 +50,8 @@ defmodule PhilomenaWeb.LayoutView do fancy_tag_edit: if(user, do: user.fancy_tag_field_on_edit, else: true), fancy_tag_upload: if(user, do: user.fancy_tag_field_on_upload, else: true), interactions: Jason.encode!(interactions), - ignored_tag_list: Jason.encode!(ignored_tag_list(conn.assigns[:tags])) + ignored_tag_list: Jason.encode!(ignored_tag_list(conn.assigns[:tags])), + hide_staff_tools: Jason.encode!(conn.cookies["hide_staff_tools"]) ] data = Keyword.merge(data, extra)