fixes #70: improve visibility of adult streams

This commit is contained in:
byte[] 2020-05-01 22:50:54 -04:00
parent 2df7e1c2f8
commit 1f5f5ce104
5 changed files with 44 additions and 7 deletions

View file

@ -15,7 +15,6 @@ export function setupSettings() {
// Local settings // Local settings
localCheckboxes.forEach(checkbox => { localCheckboxes.forEach(checkbox => {
checkbox.checked = Boolean(store.get(checkbox.id));
checkbox.addEventListener('change', () => { checkbox.addEventListener('change', () => {
store.set(checkbox.id.replace('user_', ''), checkbox.checked); store.set(checkbox.id.replace('user_', ''), checkbox.checked);
}); });

View file

@ -0,0 +1,25 @@
defmodule PhilomenaWeb.Channel.NsfwController do
use PhilomenaWeb, :controller
alias Plug.Conn
def create(conn, _params) do
conn
|> set_cookie("chan_nsfw", "true")
|> put_flash(:info, "Successfully updated channel visibility.")
|> redirect(to: Routes.channel_path(conn, :index))
end
def delete(conn, _params) do
conn
|> set_cookie("chan_nsfw", "false")
|> put_flash(:info, "Successfully updated channel visibility.")
|> redirect(to: Routes.channel_path(conn, :index))
end
# Duplicated from setting controller
defp set_cookie(conn, cookie_name, value) do
# JS wants access; max-age is set to 25 years from now
Conn.put_resp_cookie(conn, cookie_name, value, max_age: 788_923_800, http_only: false)
end
end

View file

@ -485,6 +485,10 @@ defmodule PhilomenaWeb.Router do
resources "/history", Page.HistoryController, only: [:index] resources "/history", Page.HistoryController, only: [:index]
end end
scope "/channels", Channel, as: :channel do
resources "/nsfw", NsfwController, only: [:create, :delete], singleton: true
end
resources "/dnp", DnpEntryController, only: [:index, :show] resources "/dnp", DnpEntryController, only: [:index, :show]
resources "/staff", StaffController, only: [:index] resources "/staff", StaffController, only: [:index]
resources "/stats", StatController, only: [:index] resources "/stats", StatController, only: [:index]

View file

@ -12,6 +12,15 @@ h1 Livestreams
.block__header .block__header
= pagination = pagination
= if @conn.cookies["chan_nsfw"] == "true" do
a href=Routes.channel_nsfw_path(@conn, :delete) data-method="delete"
i.fa.fa-eye-slash>
' Hide NSFW streams
- else
a href=Routes.channel_nsfw_path(@conn, :create) data-method="create"
i.fa.fa-eye>
' Show NSFW streams
.block__content .block__content
= for channel <- @channels do = for channel <- @channels do
= render PhilomenaWeb.ChannelView, "_channel_box.html", channel: channel, conn: @conn, subscriptions: @subscriptions = render PhilomenaWeb.ChannelView, "_channel_box.html", channel: channel, conn: @conn, subscriptions: @subscriptions

View file

@ -104,28 +104,28 @@ h1 Content Settings
.block.block--fixed.block--warning Settings on this tab are saved in the current browser. They are independent of your login. .block.block--fixed.block--warning Settings on this tab are saved in the current browser. They are independent of your login.
.field .field
=> label f, :hidpi, "Serve HiDPI thumbnails" => label f, :hidpi, "Serve HiDPI thumbnails"
=> checkbox f, :hidpi, value: @conn.cookies["hidpi"] => checkbox f, :hidpi, checked: @conn.cookies["hidpi"] == "true"
.fieldlabel: i Use high quality thumbnails on displays with a high pixel density. Requires more data than regular thumbnails. .fieldlabel: i Use high quality thumbnails on displays with a high pixel density. Requires more data than regular thumbnails.
.field .field
=> label f, :serve_webm, "Serve WebM" => label f, :serve_webm, "Serve WebM"
=> checkbox f, :serve_webm, value: @conn.cookies["serve_webm"] => checkbox f, :serve_webm, checked: @conn.cookies["serve_webm"] == "true"
.fieldlabel: i Serve WebM/MP4 versions of GIF images when available. Good for lower-bandwidth connections, but the video versions may have missing start/end frames, and do not support transparency. .fieldlabel: i Serve WebM/MP4 versions of GIF images when available. Good for lower-bandwidth connections, but the video versions may have missing start/end frames, and do not support transparency.
.field .field
=> label f, :webm, "Use video thumbnails" => label f, :webm, "Use video thumbnails"
=> checkbox f, :webm, value: @conn.cookies["webm"] => checkbox f, :webm, checked: @conn.cookies["webm"] == "true"
.fieldlabel: i Use video thumbnails for WebM videos. Does not apply to GIF images. .fieldlabel: i Use video thumbnails for WebM videos. Does not apply to GIF images.
.field .field
=> label f, :hide_uploader => label f, :hide_uploader
=> checkbox f, :hide_uploader, value: @conn.cookies["hide_uploader"] => checkbox f, :hide_uploader, checked: @conn.cookies["hide_uploader"] == "true"
.fieldlabel: i Hide the uploader and date posted information on image pages. .fieldlabel: i Hide the uploader and date posted information on image pages.
.field .field
=> label f, :chan_nsfw, "Show NSFW channels" => label f, :chan_nsfw, "Show NSFW channels"
=> checkbox f, :chan_nsfw, value: @conn.cookies["chan_nsfw"] => checkbox f, :chan_nsfw, checked: @conn.cookies["chan_nsfw"] == "true"
.fieldlabel: i Show streams marked as NSFW on the channels page. .fieldlabel: i Show streams marked as NSFW on the channels page.
= if staff?(@conn.assigns.current_user) do = if staff?(@conn.assigns.current_user) do
.field .field
=> label f, :hide_staff_tools => label f, :hide_staff_tools
=> checkbox f, :hide_staff_tools, value: @conn.cookies["hide_staff_tools"] => checkbox f, :hide_staff_tools, checked: @conn.cookies["hide_staff_tools"] == "true"
.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. .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 = if !@conn.assigns.current_user do