mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Image scale setting (#134)
This commit is contained in:
parent
aa8b7b9aa6
commit
f8382b055f
6 changed files with 36 additions and 9 deletions
|
@ -79,7 +79,7 @@ defmodule Philomena.Users.User do
|
||||||
field :fancy_tag_field_in_settings, :boolean, default: true
|
field :fancy_tag_field_in_settings, :boolean, default: true
|
||||||
field :autorefresh_by_default, :boolean, default: false
|
field :autorefresh_by_default, :boolean, default: false
|
||||||
field :anonymous_by_default, :boolean, default: false
|
field :anonymous_by_default, :boolean, default: false
|
||||||
field :scale_large_images, :boolean, default: true
|
field :scale_large_images, :string, default: "true"
|
||||||
field :comments_newest_first, :boolean, default: true
|
field :comments_newest_first, :boolean, default: true
|
||||||
field :comments_always_jump_to_last, :boolean, default: true
|
field :comments_always_jump_to_last, :boolean, default: true
|
||||||
field :comments_per_page, :integer, default: 20
|
field :comments_per_page, :integer, default: 20
|
||||||
|
@ -347,6 +347,7 @@ defmodule Philomena.Users.User do
|
||||||
|> validate_inclusion(:theme, ~W(default dark red))
|
|> validate_inclusion(:theme, ~W(default dark red))
|
||||||
|> validate_inclusion(:images_per_page, 1..50)
|
|> validate_inclusion(:images_per_page, 1..50)
|
||||||
|> validate_inclusion(:comments_per_page, 1..100)
|
|> validate_inclusion(:comments_per_page, 1..100)
|
||||||
|
|> validate_inclusion(:scale_large_images, ["false", "partscaled", "true"])
|
||||||
|> Search.validate_search(:watched_images_query_str, user, true)
|
|> Search.validate_search(:watched_images_query_str, user, true)
|
||||||
|> Search.validate_search(:watched_images_exclude_str, user, true)
|
|> Search.validate_search(:watched_images_exclude_str, user, true)
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,15 +73,15 @@ h1 Content Settings
|
||||||
i
|
i
|
||||||
' This is the number of images per page that are displayed on image listings and searches, up to a maximum of 50.
|
' This is the number of images per page that are displayed on image listings and searches, up to a maximum of 50.
|
||||||
' For 1080p monitors, try 24.
|
' For 1080p monitors, try 24.
|
||||||
.field
|
|
||||||
=> label f, :scale_large_images
|
|
||||||
=> checkbox f, :scale_large_images, class: "checkbox"
|
|
||||||
.fieldlabel: i Scale large images down to fit your monitor (approximately) server-side before downloading. Disabling this will load full images immediately on image pages.
|
|
||||||
.field
|
.field
|
||||||
=> label f, :theme
|
=> label f, :theme
|
||||||
=> select f, :theme, theme_options(@conn), class: "input"
|
=> select f, :theme, theme_options(@conn), class: "input"
|
||||||
= error_tag f, :theme
|
= error_tag f, :theme
|
||||||
.fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme.
|
.fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme.
|
||||||
|
.field
|
||||||
|
=> label f, :scale_large_images
|
||||||
|
=> select f, :scale_large_images, scale_options(), class: "input"
|
||||||
|
= error_tag f, :scale_large_images
|
||||||
|
|
||||||
.block__tab.hidden.flex.flex--maybe-wrap data-tab="comments"
|
.block__tab.hidden.flex.flex--maybe-wrap data-tab="comments"
|
||||||
div
|
div
|
||||||
|
|
|
@ -203,7 +203,7 @@ defmodule PhilomenaWeb.ImageView do
|
||||||
def deleter(%{deleter: %{name: name}}), do: name
|
def deleter(%{deleter: %{name: name}}), do: name
|
||||||
def deleter(_image), do: "System"
|
def deleter(_image), do: "System"
|
||||||
|
|
||||||
def scaled_value(%{scale_large_images: false}), do: "false"
|
def scaled_value(%{scale_large_images: scale}), do: scale
|
||||||
def scaled_value(_user), do: "true"
|
def scaled_value(_user), do: "true"
|
||||||
|
|
||||||
def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{})
|
def hides_images?(conn), do: can?(conn, :hide, %Philomena.Images.Image{})
|
||||||
|
|
|
@ -13,6 +13,14 @@ defmodule PhilomenaWeb.SettingView do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def scale_options do
|
||||||
|
[
|
||||||
|
[key: "Load full images on image pages", value: "false"],
|
||||||
|
[key: "Load full images on image pages, sized to fit the page", value: "partscaled"],
|
||||||
|
[key: "Scale large images down before downloading", value: "true"]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
def local_tab_class(conn) do
|
def local_tab_class(conn) do
|
||||||
case conn.assigns.current_user do
|
case conn.assigns.current_user do
|
||||||
nil -> ""
|
nil -> ""
|
||||||
|
|
17
priv/repo/migrations/20210921025336_change_image_scale_option_type.exs
Executable file
17
priv/repo/migrations/20210921025336_change_image_scale_option_type.exs
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
defmodule Philomena.Repo.Migrations.ChangeImageScaleOptionType do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
alter table(:users) do
|
||||||
|
add :scale_large_images0, :string, default: "true", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
execute("update users set scale_large_images0 = (case when scale_large_images then 'true' else 'false' end);")
|
||||||
|
|
||||||
|
alter table(:users) do
|
||||||
|
remove :scale_large_images
|
||||||
|
end
|
||||||
|
|
||||||
|
rename table(:users), :scale_large_images0, to: :scale_large_images
|
||||||
|
end
|
||||||
|
end
|
|
@ -1964,7 +1964,6 @@ CREATE TABLE public.users (
|
||||||
fancy_tag_field_in_settings boolean DEFAULT true NOT NULL,
|
fancy_tag_field_in_settings boolean DEFAULT true NOT NULL,
|
||||||
autorefresh_by_default boolean DEFAULT false NOT NULL,
|
autorefresh_by_default boolean DEFAULT false NOT NULL,
|
||||||
anonymous_by_default boolean DEFAULT false NOT NULL,
|
anonymous_by_default boolean DEFAULT false NOT NULL,
|
||||||
scale_large_images boolean DEFAULT true NOT NULL,
|
|
||||||
comments_newest_first boolean DEFAULT true NOT NULL,
|
comments_newest_first boolean DEFAULT true NOT NULL,
|
||||||
comments_always_jump_to_last boolean DEFAULT false NOT NULL,
|
comments_always_jump_to_last boolean DEFAULT false NOT NULL,
|
||||||
comments_per_page integer DEFAULT 20 NOT NULL,
|
comments_per_page integer DEFAULT 20 NOT NULL,
|
||||||
|
@ -2010,9 +2009,10 @@ CREATE TABLE public.users (
|
||||||
forced_filter_id bigint,
|
forced_filter_id bigint,
|
||||||
confirmed_at timestamp(0) without time zone,
|
confirmed_at timestamp(0) without time zone,
|
||||||
senior_staff boolean DEFAULT false,
|
senior_staff boolean DEFAULT false,
|
||||||
bypass_rate_limits boolean DEFAULT false,
|
|
||||||
description_md character varying,
|
description_md character varying,
|
||||||
scratchpad_md character varying
|
scratchpad_md character varying,
|
||||||
|
bypass_rate_limits boolean DEFAULT false,
|
||||||
|
scale_large_images character varying(255) DEFAULT 'true'::character varying NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -4870,3 +4870,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20210301012137);
|
||||||
INSERT INTO public."schema_migrations" (version) VALUES (20210427022351);
|
INSERT INTO public."schema_migrations" (version) VALUES (20210427022351);
|
||||||
INSERT INTO public."schema_migrations" (version) VALUES (20210912171343);
|
INSERT INTO public."schema_migrations" (version) VALUES (20210912171343);
|
||||||
INSERT INTO public."schema_migrations" (version) VALUES (20210917190346);
|
INSERT INTO public."schema_migrations" (version) VALUES (20210917190346);
|
||||||
|
INSERT INTO public."schema_migrations" (version) VALUES (20210921025336);
|
||||||
|
|
Loading…
Reference in a new issue