diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c078eb908..9fb1ab28f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 53b506749..12481db75 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index cd395f277..9341105ae 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 5df373ea5..a6f018cbf 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -31,17 +31,17 @@
- <%= 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. View help.".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. View help.".html_safe, :input_html => {:size => "40x5", :data => {:autocomplete => "tag-query"}} %>