このコミットが含まれているのは:
2026-07-04 21:47:16 +09:00
コミット 518c5fa0f2
16個のファイルの変更840行の追加598行の削除
+2 -40
ファイルの表示
@@ -1,46 +1,20 @@
class Setting < ApplicationRecord
THEMES = ['system', 'light', 'dark'].freeze
DISPLAY_DENSITIES = ['comfortable', 'compact'].freeze
FONT_SIZES = ['small', 'normal', 'large'].freeze
POST_LIST_LIMITS = [20, 50, 100].freeze
POST_LIST_ORDERS = [
'title_asc',
'title_desc',
'url_asc',
'url_desc',
'original_created_at_asc',
'original_created_at_desc',
'created_at_asc',
'created_at_desc',
'updated_at_asc',
'updated_at_desc',
].freeze
VIEWED_POST_DISPLAYS = ['show', 'dim'].freeze
AUTO_FETCH_MODES = ['auto', 'manual', 'off'].freeze
WIKI_EDITOR_MODES = ['split', 'write', 'preview'].freeze
STRING_ATTRIBUTES = [
'theme',
'display_density',
'font_size',
'post_list_order',
'viewed_post_display',
'auto_fetch_title',
'auto_fetch_thumbnail',
'wiki_editor_mode',
].freeze
INTEGER_ATTRIBUTES = ['post_list_limit'].freeze
BOOLEAN_ATTRIBUTES = ['tag_autocomplete_nico'].freeze
INTEGER_ATTRIBUTES = [].freeze
BOOLEAN_ATTRIBUTES = [].freeze
EDITABLE_ATTRIBUTES =
(STRING_ATTRIBUTES + INTEGER_ATTRIBUTES + BOOLEAN_ATTRIBUTES).freeze
TYPE_BY_ATTRIBUTE = {
'theme' => :string,
'display_density' => :string,
'font_size' => :string,
'post_list_limit' => :integer,
'post_list_order' => :string,
'viewed_post_display' => :string,
'tag_autocomplete_nico' => :boolean,
'auto_fetch_title' => :string,
'auto_fetch_thumbnail' => :string,
'wiki_editor_mode' => :string,
@@ -52,12 +26,6 @@ class Setting < ApplicationRecord
validates :user_id, uniqueness: true
validates :theme, inclusion: { in: THEMES }
validates :display_density, inclusion: { in: DISPLAY_DENSITIES }
validates :font_size, inclusion: { in: FONT_SIZES }
validates :post_list_limit, inclusion: { in: POST_LIST_LIMITS }
validates :post_list_order, inclusion: { in: POST_LIST_ORDERS }
validates :viewed_post_display, inclusion: { in: VIEWED_POST_DISPLAYS }
validates :tag_autocomplete_nico, inclusion: { in: [true, false] }
validates :auto_fetch_title, inclusion: { in: AUTO_FETCH_MODES }
validates :auto_fetch_thumbnail, inclusion: { in: AUTO_FETCH_MODES }
validates :wiki_editor_mode, inclusion: { in: WIKI_EDITOR_MODES }
@@ -65,12 +33,6 @@ class Setting < ApplicationRecord
def self.defaults
{
theme: 'system',
display_density: 'comfortable',
font_size: 'normal',
post_list_limit: 50,
post_list_order: 'created_at_desc',
viewed_post_display: 'show',
tag_autocomplete_nico: true,
auto_fetch_title: 'manual',
auto_fetch_thumbnail: 'manual',
wiki_editor_mode: 'split',