diff options
author | Go MAEDA <maeda@farend.jp> | 2020-01-14 14:38:48 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-01-14 14:38:48 +0000 |
commit | 6611f5bf5dd78d5c7ba9b11eafc498049e05fa52 (patch) | |
tree | 499425f933124e0342055ecd70d01343959313bf /app | |
parent | 7f60d56201e479be4f1235e873e1119e493679ad (diff) | |
download | redmine-6611f5bf5dd78d5c7ba9b11eafc498049e05fa52.tar.gz redmine-6611f5bf5dd78d5c7ba9b11eafc498049e05fa52.zip |
Make languages in Highlighted code button in toolbar customizable (#32528).
Patch by Mizuki ISHIKAWA.
git-svn-id: http://svn.redmine.org/redmine/trunk@19429 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user_preference.rb | 13 | ||||
-rw-r--r-- | app/views/users/_preferences.html.erb | 1 |
2 files changed, 13 insertions, 1 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 597ac9c90..3f0d9743c 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -35,9 +35,11 @@ class UserPreference < ActiveRecord::Base 'no_self_notified', 'textarea_font', 'recently_used_projects', - 'history_default_tab') + 'history_default_tab', + 'toolbar_language_options') TEXTAREA_FONT_OPTIONS = ['monospace', 'proportional'] + DEFAULT_TOOLBAR_LANGUAGE_OPTIONS = %w[c cpp csharp css diff go groovy html java javascript objc perl php python r ruby sass scala shell sql swift xml yaml] def initialize(attributes=nil, *args) super @@ -98,6 +100,15 @@ class UserPreference < ActiveRecord::Base def history_default_tab; self[:history_default_tab]; end def history_default_tab=(value); self[:history_default_tab]=value; end + def toolbar_language_options + self[:toolbar_language_options].presence || DEFAULT_TOOLBAR_LANGUAGE_OPTIONS.join(',') + end + + def toolbar_language_options=(value) + languages = value.to_s.delete(' ').split(',').select{|lang| Redmine::SyntaxHighlighting.language_supported?(lang) }.compact + self[:toolbar_language_options] = languages.join(',') + end + # Returns the names of groups that are displayed on user's page # Example: # preferences.my_page_groups diff --git a/app/views/users/_preferences.html.erb b/app/views/users/_preferences.html.erb index 6397c3a38..3734c3064 100644 --- a/app/views/users/_preferences.html.erb +++ b/app/views/users/_preferences.html.erb @@ -6,4 +6,5 @@ <p><%= pref_fields.select :textarea_font, textarea_font_options %></p> <p><%= pref_fields.text_field :recently_used_projects, :size => 2 %></p> <p><%= pref_fields.select :history_default_tab, history_default_tab_options %></p> +<p><%= pref_fields.text_area :toolbar_language_options, :rows => 4 %></p> <% end %> |