From 196b242aa35b095841147141498a7595767ba31b Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Tue, 19 Feb 2019 11:39:05 +0900 Subject: [PATCH 1/6] Introduce the raw-HTML customize type --- app/models/view_customize.rb | 8 +++++++- app/views/view_customizes/show.html.erb | 2 +- config/locales/en.yml | 1 + config/locales/ja.yml | 1 + lib/view_customize/view_hook.rb | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/view_customize.rb b/app/models/view_customize.rb index 0a77dfd..979bc26 100644 --- a/app/models/view_customize.rb +++ b/app/models/view_customize.rb @@ -10,10 +10,12 @@ class ViewCustomize < ActiveRecord::Base TYPE_JAVASCRIPT = "javascript" TYPE_CSS = "css" + TYPE_HTML = "html" @@customize_types = { :label_javascript => TYPE_JAVASCRIPT, - :label_css => TYPE_CSS + :label_css => TYPE_CSS, + :label_html => TYPE_HTML } INSERTION_POSITION_HTML_HEAD = "html_head" @@ -50,6 +52,10 @@ def is_css? customize_type == TYPE_CSS end + def is_html? + customize_type == TYPE_HTML + end + def available?(user=User.current) is_enabled && (!is_private || author == user) end diff --git a/app/views/view_customizes/show.html.erb b/app/views/view_customizes/show.html.erb index 7cedbc1..7117b69 100644 --- a/app/views/view_customizes/show.html.erb +++ b/app/views/view_customizes/show.html.erb @@ -28,7 +28,7 @@ <%=h l(:field_code) %>
<%= highlight_by_language( - @view_customize.code, @view_customize.is_javascript? ? :js : :css) %>
+ @view_customize.code, @view_customize.customize_type) %> <%=h l(:field_comments) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 413a775..35aa72e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,7 @@ en: label_view_customizes_new: "New view customize" label_javascript: "JavaScript" label_css: "CSS" + label_html: "HTML" label_insertion_position_html_head: "Head of all pages" label_insertion_position_issue_form: "Bottom of issue form" label_insertion_position_issue_show: "Bottom of issue detail" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index b71e9ec..6d315b5 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -4,6 +4,7 @@ ja: label_view_customizes_new: "新しい表示のカスタマイズ" label_javascript: "JavaScript" label_css: "CSS" + label_html: "HTML" label_insertion_position_html_head: "全てのページのヘッダ" label_insertion_position_issue_form: "チケット入力欄の下" label_insertion_position_issue_show: "チケット詳細の下" diff --git a/lib/view_customize/view_hook.rb b/lib/view_customize/view_hook.rb index 0939ad5..9098671 100644 --- a/lib/view_customize/view_hook.rb +++ b/lib/view_customize/view_hook.rb @@ -63,6 +63,8 @@ def to_html(view_customize) html << "" + elsif view_customize.is_html? + html << view_customize.code end return html From 1dccbd83a362d47060ffb3f0b1737dc1f741b551 Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Sat, 23 Feb 2019 10:34:34 +0900 Subject: [PATCH 2/6] update README for HTML customize type --- README.ja.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.ja.md b/README.ja.md index 398bc8b..23ed399 100644 --- a/README.ja.md +++ b/README.ja.md @@ -4,7 +4,7 @@ ## 機能 -条件に一致した画面に対して、JavaScript、CSSを埋め込むことで、画面をカスタマイズします。 +条件に一致した画面に対して、JavaScript、CSS、HTMLを埋め込むことで、画面をカスタマイズします。 ## インストール方法 @@ -50,7 +50,7 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production 該当ページにコードの挿入位置に該当する箇所が無かった場合、コードは埋め込まれません。たとえば、「Path pattern」で`.*`で全ページを指定しても、「Insertion position」に「Bottom of issue detail」を指定していると、チケットの詳細表示画面でしか実行されないことになります。 -「Type」にてコードの種類(「JavaScript」または「CSS」)を選択し、「Code」に実際のコードを入力します。 +「Type」にてコードの種類(「JavaScript」、「CSS」または「HTML」)を選択し、「Code」に実際のコードを入力します。 「Comment」にはカスタマイズに対する概要を記載できます。ここで入力した内容は、一覧表示で表示されます。(Commentが入力されていればComment、Commentが入力されていない場合はCodeが一覧に表示) diff --git a/README.md b/README.md index 52086d4..61cb245 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This a plugin allows you to customize the view for the [Redmine](http://www.redm ## Features -Customize the page by inserting JavaScript or CSS on the page that matched the condition. +Customize the page by inserting JavaScript, CSS or HTML on the page that matched the condition. ## Installation @@ -53,7 +53,7 @@ Issue input fields are reconstructed when trackers or statuses are changed. If " If there is no part corresponding to the insertion position of the code on the page, the code is not insert. For example, even if you specify `.*` in "Path pattern", if "Bottom of issue detail" is specified for "Insertion position", it will be executed only on the issue detail page. -In "Type", select the type of code ("JavaScript" or "CSS") and enter the actual code in "Code". +In "Type", select the type of code ("JavaScript", "CSS" or "HTML") and enter the actual code in "Code". For "Comment" you can put an overview on customization. The contents entered here are displayed in the list display. When "Comment" is entered, "Comment" is displayed on the list. From 53163f8d64869932b29f1029b73e54d7bab56f48 Mon Sep 17 00:00:00 2001 From: cat_in_136 Date: Sat, 23 Feb 2019 10:43:12 +0900 Subject: [PATCH 3/6] Fix regression bug where language arugument should be a Symbol (to keep compatible with redmine 3.x Coderay) --- app/views/view_customizes/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/view_customizes/show.html.erb b/app/views/view_customizes/show.html.erb index 7117b69..74254ab 100644 --- a/app/views/view_customizes/show.html.erb +++ b/app/views/view_customizes/show.html.erb @@ -28,7 +28,7 @@ <%=h l(:field_code) %>
<%= highlight_by_language( - @view_customize.code, @view_customize.customize_type) %>
+ @view_customize.code, @view_customize.customize_type.to_sym) %> <%=h l(:field_comments) %> From d5795439f8dc249ae577bc00bf8fdb05393e7034 Mon Sep 17 00:00:00 2001 From: onozaty Date: Sun, 17 Mar 2019 00:16:54 +0900 Subject: [PATCH 4/6] [WIP] Development for 2.1.0 From a854f0ce092cb66abbeae74eab8d676961504fcd Mon Sep 17 00:00:00 2001 From: onozaty Date: Sun, 17 Mar 2019 22:02:02 +0900 Subject: [PATCH 5/6] Update version number to 2.1.0 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index 1bc0355..d9f76c7 100644 --- a/init.rb +++ b/init.rb @@ -5,7 +5,7 @@ name 'View Customize plugin' author 'onozaty' description 'View Customize plugin for Redmine' - version '2.0.1' + version '2.1.0' url 'https://github.com/onozaty/redmine-view-customize' author_url 'https://github.com/onozaty' From fa0786f2e300235578004e20dcaa7abdb4842e7b Mon Sep 17 00:00:00 2001 From: onozaty Date: Tue, 19 Mar 2019 01:13:02 +0900 Subject: [PATCH 6/6] Changed the description of the supported versions so that it can be understood that it supports Redmine 4.0 --- README.ja.md | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.ja.md b/README.ja.md index 23ed399..978b61b 100644 --- a/README.ja.md +++ b/README.ja.md @@ -127,7 +127,7 @@ ViewCustomize = { ## サポートバージョン -* 最新バージョン : Redmine 3.1.x 以降 +* 最新バージョン : Redmine 3.1.x から 3.4.x、4.0.x 以降 * 1.2.2 : Redmine 2.0.x から 3.4.x ## ライセンス diff --git a/README.md b/README.md index 61cb245..6b79b13 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ For example, to access the user's API key is `ViewCustomize.context.user.apiKey` ## Supported versions -* Current version : Redmine 3.1.x or later +* Current version : Redmine 3.1.x - 3.4.x, 4.0.x or later * 1.2.2 : Redmine 2.0.x - 3.4.x ## License