Vote #80511
完了Make languages in Highlighted code button in toolbar customizable
0%
説明
Languages often used in code highlights differ from person to person.
I think it would be convenient if the language set in the user setting is given as a candidate.
journals
I attached a patch.
After applying this patch to the development environment, you need to restart Redmine.
* user setting
!{width: 70%; border: 1px solid #ccc}example1.png!
* wiki toolbar
!{width: 500px; border: 1px solid #ccc}example2.png!
--------------------------------------------------------------------------------
Thank you for writing the patch. But I think that filling the textarea in "My account" with the default languages is better. The reason is that it makes easier to customize the default values.
Suppose that you are about to add "soncole" to the menu. You can see the current languages list in the textarea of "My account" page as a placeholder. But the placeholder is cleared when you start typing and you have to manage to remember the value that was displayed just before. The small frustration can be resolved by applying the following patch on top of your patch.
<pre><code class="diff">
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 63c6a9151..26f1efdcf 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -100,7 +100,9 @@ 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 code_highlighting_languages; self[:code_highlighting_languages]; end
+ def code_highlighting_languages
+ self[:code_highlighting_languages].presence || DEFAULT_CODE_HIGHLIGHTING_LANGUAGES.join(',')
+ end
def code_highlighting_languages=(value)
languages = value.to_s.gsub(' ', '').split(',').select{|lang| Redmine::SyntaxHighlighting.language_supported?(lang) }.compact
self[:code_highlighting_languages] = languages.join(',')
diff --git a/app/views/users/_preferences.html.erb b/app/views/users/_preferences.html.erb
index 2daa7cef4..c344ab4d8 100644
--- a/app/views/users/_preferences.html.erb
+++ b/app/views/users/_preferences.html.erb
@@ -6,5 +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 :code_highlighting_languages, :placeholder => UserPreference::DEFAULT_CODE_HIGHLIGHTING_LANGUAGES.join(','), :rows => 4 %></p>
+<p><%= pref_fields.text_area :code_highlighting_languages, :rows => 4 %></p>
<% end %>
</code></pre>
--------------------------------------------------------------------------------
Thank you for your feedback.
I updated the patch.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
This is a nice improvement.
When the code highlight button was introduced in Redmine 3.3, the code highlighter supported only about 20 languages and the button covered almost all supported languages. But now, the code highlighter in Redmine 4.0 supports over 100 languages. It is no longer possible to put all supported languages in the toolbar button.
As Mizuki mentioned, languages that should be in the toolbar is different per user. For example, I don't use most default options such as go, java, and php but often use "console".
Allowing users to customize the options in the toolbar button solves problems above. I think this feature is useful for all users who use code highlighting.
--------------------------------------------------------------------------------
I slightly updated the patch (changed the preference name from 'code_highlighting_languages' to 'toolbar_language_options').
Setting the target version to 4.2.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you for improving Redmine.
--------------------------------------------------------------------------------
related_issues
relates,Closed,14937,Code highlighting toolbar button