users: add dark mode account setting (fix #4158).
This commit is contained in:
@@ -101,7 +101,7 @@ class UsersController < ApplicationController
|
||||
permitted_params = %i[
|
||||
password old_password password_confirmation email
|
||||
comment_threshold default_image_size favorite_tags blacklisted_tags
|
||||
time_zone per_page custom_style
|
||||
time_zone per_page custom_style theme
|
||||
|
||||
receive_email_notifications always_resize_images enable_post_navigation
|
||||
new_post_navigation_layout enable_privacy_mode
|
||||
|
||||
@@ -174,7 +174,7 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def body_attributes(user = CurrentUser.user)
|
||||
attributes = [:id, :name, :level, :level_string, :can_approve_posts?, :can_upload_free?]
|
||||
attributes = [:id, :name, :level, :level_string, :theme, :can_approve_posts?, :can_upload_free?]
|
||||
attributes += User::Roles.map { |role| :"is_#{role}?" }
|
||||
|
||||
controller_param = params[:controller].parameterize.dasherize
|
||||
|
||||
@@ -114,6 +114,8 @@ class User < ApplicationRecord
|
||||
belongs_to :inviter, class_name: "User", optional: true
|
||||
accepts_nested_attributes_for :dmail_filter
|
||||
|
||||
enum theme: { light: 0, dark: 100 }, _suffix: true
|
||||
|
||||
module BanMethods
|
||||
def validate_ip_addr_is_not_banned
|
||||
if IpBan.is_banned?(CurrentUser.ip_addr)
|
||||
|
||||
@@ -31,17 +31,17 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= f.input :time_zone, :include_blank => false %>
|
||||
<%= f.input :receive_email_notifications, :as => :select, :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
|
||||
<%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %>
|
||||
<%= f.input :default_image_size, :hint => "Show original image or show resized #{Danbooru.config.large_image_width} pixel version", :label => "Default image width", :collection => [["850px", "large"], ["original", "original"]], :include_blank => false %>
|
||||
<%= f.input :theme, collection: User.themes.keys, include_blank: false, hint: "The site's colorscheme (light mode or dark mode)." %>
|
||||
<%= f.input :enable_safe_mode, label: "Safe mode", hint: "Show only safe images. Hide questionable and explicit images.", as: :select, include_blank: false, collection: [["Yes", "true"], ["No", "false"]] %>
|
||||
|
||||
<% if CurrentUser.user.is_gold? %>
|
||||
<%= f.input :per_page, :label => "Posts per page", :as => :select, :hint => "Number of thumbnails per page", :collection => (1..PostSets::Post::MAX_PER_PAGE), :include_blank => false %>
|
||||
<% end %>
|
||||
|
||||
<%= f.input :enable_safe_mode, :label => "Safe mode", :hint => "Show only safe images. Hide questionable and explicit images.", :as => :select, :include_blank => false, :collection => [["Yes", "true"], ["No", "false"]] %>
|
||||
<%= f.input :blacklisted_tags, :hint => "Posts with these tags will be hidden. Put each tag on a separate line. <a href='/wiki_pages/help:blacklists'>View help.</a>".html_safe, :input_html => {:size => "40x5", :data => {:autocomplete => "tag-query"}} %>
|
||||
<%= f.input :default_image_size, hint: "Show full original images or resized #{Danbooru.config.large_image_width}px width samples.", label: "Default image width", collection: [["850px", "large"], ["original", "original"]], include_blank: false %>
|
||||
<%= f.input :receive_email_notifications, as: :select, include_blank: false, collection: [["Yes", "true"], ["No", "false"]], hint: "Receive an email when you receive a new dmail." %>
|
||||
<%= f.input :time_zone, include_blank: false, hint: "The timezone to use for timestamps." %>
|
||||
<%= f.input :comment_threshold, hint: "Comments below this score will be hidden by default" %>
|
||||
<%= f.input :blacklisted_tags, hint: "Posts with these tags will be hidden. Put each tag on a separate line. <a href='/wiki_pages/help:blacklists'>View help.</a>".html_safe, :input_html => {:size => "40x5", :data => {:autocomplete => "tag-query"}} %>
|
||||
</fieldset>
|
||||
|
||||
<fieldset id="advanced-settings-section">
|
||||
|
||||
5
db/migrate/20190919175836_add_theme_to_users.rb
Normal file
5
db/migrate/20190919175836_add_theme_to_users.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddThemeToUsers < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
add_column :users, :theme, :integer, default: 0, null: false
|
||||
end
|
||||
end
|
||||
@@ -3108,7 +3108,8 @@ furry -rating:s'::text,
|
||||
custom_style text,
|
||||
bit_prefs bigint DEFAULT 0 NOT NULL,
|
||||
last_ip_addr inet,
|
||||
unread_dmail_count integer DEFAULT 0 NOT NULL
|
||||
unread_dmail_count integer DEFAULT 0 NOT NULL,
|
||||
theme integer DEFAULT 0 NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -7337,6 +7338,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20190829055758'),
|
||||
('20190902224045'),
|
||||
('20190908031103'),
|
||||
('20190908035317');
|
||||
('20190908035317'),
|
||||
('20190919175836');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user