Feature #32528
closedMake languages in Highlighted code button in toolbar customizable
Added by Mizuki ISHIKAWA almost 5 years ago. Updated almost 5 years ago.
0%
Description
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.
Files
example2.png (43.5 KB) example2.png | Mizuki ISHIKAWA, 2019-11-29 03:24 | ||
example1.png (137 KB) example1.png | Mizuki ISHIKAWA, 2019-11-29 03:24 | ||
feature-32528.patch (6.85 KB) feature-32528.patch | Mizuki ISHIKAWA, 2019-11-29 03:24 | ||
feature-32528-2.patch (6.82 KB) feature-32528-2.patch | Mizuki ISHIKAWA, 2019-12-04 01:00 | ||
feature-32528-3.patch (6.75 KB) feature-32528-3.patch | Go MAEDA, 2019-12-15 09:10 |
Related issues
Updated by Mizuki ISHIKAWA almost 5 years ago
- File example1.png example1.png added
- File example2.png example2.png added
- File feature-32528.patch feature-32528.patch added
I attached a patch.
After applying this patch to the development environment, you need to restart Redmine.
- user setting
- wiki toolbar
Updated by Go MAEDA almost 5 years ago
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.
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 %>
Updated by Mizuki ISHIKAWA almost 5 years ago
- File feature-32528-2.patch feature-32528-2.patch added
Thank you for your feedback.
I updated the patch.
Updated by Go MAEDA almost 5 years ago
- Category changed from Wiki to Text formatting
- Target version set to Candidate for next major release
Updated by Go MAEDA almost 5 years ago
- Related to Feature #14937: Code highlighting toolbar button added
Updated by Go MAEDA almost 5 years ago
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.
Updated by Go MAEDA almost 5 years ago
- File feature-32528-3.patch feature-32528-3.patch added
- Target version changed from Candidate for next major release to 4.2.0
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.
Updated by Go MAEDA almost 5 years ago
- Subject changed from Customize language options for highlight tag insertion in the Wiki toolbar to Make languages in Highlighted code button in toolbar customizable
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you for improving Redmine.