プロジェクト

全般

プロフィール

Vote #80511

完了

Make languages in Highlighted code button in toolbar customizable

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Text formatting_26
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
26
version_id:
152
issue_org_id:
32528
author_id:
259873
assigned_to_id:
332
comments:
8
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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

Admin Redmine さんが約2年前に更新

  • カテゴリText formatting_26 にセット
  • 対象バージョン4.2.0_152 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0