Skip to content

Commit

Permalink
Merge pull request #38 from cat-in-136/html-customize-type
Browse files Browse the repository at this point in the history
add "Html" customize type
  • Loading branch information
onozaty authored Mar 16, 2019
2 parents d579543 + 53163f8 commit 933bb2e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## 機能

条件に一致した画面に対して、JavaScript、CSSを埋め込むことで、画面をカスタマイズします。
条件に一致した画面に対して、JavaScript、CSS、HTMLを埋め込むことで、画面をカスタマイズします。

## インストール方法

Expand Down Expand Up @@ -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が一覧に表示)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down
8 changes: 7 additions & 1 deletion app/models/view_customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/view_customizes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<tr>
<th><%=h l(:field_code) %></th>
<td><div><%= highlight_by_language(
@view_customize.code, @view_customize.is_javascript? ? :js : :css) %></div></td>
@view_customize.code, @view_customize.customize_type.to_sym) %></div></td>
</tr>
<tr>
<th><%=h l(:field_comments) %></th>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "チケット詳細の下"
Expand Down
2 changes: 2 additions & 0 deletions lib/view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def to_html(view_customize)
html << "<style type=\"text/css\">\n"
html << view_customize.code
html << "\n</style>"
elsif view_customize.is_html?
html << view_customize.code
end

return html
Expand Down

0 comments on commit 933bb2e

Please sign in to comment.