Skip to content

Commit

Permalink
Merge pull request #72 from onozaty/develop/2.8.0
Browse files Browse the repository at this point in the history
Develop 2.8.0
  • Loading branch information
onozaty authored Nov 24, 2020
2 parents 4de1ad3 + ec827ba commit a0502b6
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
* 「Bottom of issue form」 : チケットの入力欄の下部。<br>
チケットの入力欄は、トラッカーやステータスを変えると再構成されますが、「Bottom of issue form」を指定しておくと再構成された際に再度実行されるので、入力欄に対する処理はこれを指定すると便利です。
* 「Bottom of issue detail」 : チケットの詳細表示の下部。
* 「Bottom of all pages」 : 全てのページの末尾(HTML body内で一番下の部分)。

該当ページにコードの挿入位置に該当する箇所が無かった場合、コードは埋め込まれません。たとえば、「Path pattern」と「Project pattern」の設定が無く、全ページが対象となっても、「Insertion position」に「Bottom of issue detail」を指定していると、チケットの詳細表示画面でしかコードが実行されないことになります。

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ If the project pattern was set, the code will not be inserted if the current pro
* "Bottom of issue form"<br>
Issue input fields are reconstructed when trackers or statuses are changed. If "Bottom of issue form" is specified, it will be executed again when reconstructed.
* "Bottom of issue detail"
* "Bottom of all pages" (Last in HTML body)

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 there are no "Path pattern" and "Project pattern" settings and all pages are targeted, if "Bottom of issue detail" is specified for "Insertion position", it will be executed only on the issue detail page.
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Vagrant.configure("2") do |config|
config.vm.box = "onozaty/redmine-4.1"
config.vm.network "private_network", ip: "192.168.33.10"

config.vm.synced_folder ".", "/var/lib/redmine/plugins/view_customize", mount_options: ['dmode=777','fmode=755']
config.vm.synced_folder ".", "/var/lib/redmine/plugins/view_customize", create: true, mount_options: ['dmode=755','fmode=655']

config.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
Expand Down
4 changes: 3 additions & 1 deletion app/models/view_customize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ class ViewCustomize < ActiveRecord::Base
}

INSERTION_POSITION_HTML_HEAD = "html_head"
INSERTION_POSITION_HTML_BOTTOM = "html_bottom"
INSERTION_POSITION_ISSUE_FORM = "issue_form"
INSERTION_POSITION_ISSUE_SHOW = "issue_show"

@@insertion_positions = {
:label_insertion_position_html_head => INSERTION_POSITION_HTML_HEAD,
:label_insertion_position_issue_form => INSERTION_POSITION_ISSUE_FORM,
:label_insertion_position_issue_show => INSERTION_POSITION_ISSUE_SHOW
:label_insertion_position_issue_show => INSERTION_POSITION_ISSUE_SHOW,
:label_insertion_position_html_bottom => INSERTION_POSITION_HTML_BOTTOM
}

def customize_types
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ en:
label_css: "CSS"
label_html: "HTML"
label_insertion_position_html_head: "Head of all pages"
label_insertion_position_html_bottom: "Bottom of all pages"
label_insertion_position_issue_form: "Bottom of issue form"
label_insertion_position_issue_show: "Bottom of issue detail"
field_path_pattern: "Path pattern"
Expand Down
1 change: 1 addition & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ja:
label_css: "CSS"
label_html: "HTML"
label_insertion_position_html_head: "全ページのヘッダ"
label_insertion_position_html_bottom: "全ページの末尾"
label_insertion_position_issue_form: "チケット入力欄の下"
label_insertion_position_issue_show: "チケット詳細の下"
field_path_pattern: "パスのパターン"
Expand Down
3 changes: 2 additions & 1 deletion config/locales/zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ zh:
label_javascript: "JavaScript"
label_css: "CSS"
label_html: "HTML"
label_insertion_position_html_head: "所有页面的head标签"
label_insertion_position_html_head: "所有页面的头部"
label_insertion_position_html_bottom: "所有页面的底部"
label_insertion_position_issue_form: "问题(issue)表单底部"
label_insertion_position_issue_show: "问题(issue)详情页面"
field_path_pattern: "路径表达式"
Expand Down
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name 'View Customize plugin'
author 'onozaty'
description 'View Customize plugin for Redmine'
version '2.7.0'
version '2.8.0'
url 'https://github.com/onozaty/redmine-view-customize'
author_url 'https://github.com/onozaty'

Expand Down
4 changes: 4 additions & 0 deletions lib/view_customize/view_hook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def view_layouts_base_html_head(context={})
return html
end

def view_layouts_base_body_bottom(context={})
return "\n" + create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_HTML_BOTTOM)
end

def view_issues_form_details_bottom(context={})

return "\n" + create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_FORM)
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/view_customizes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,14 @@ view_customize_008:
customize_type: css
comments: ""
project_pattern: onlinestore
view_customize_009:
id: 9
path_pattern: /issues$
code: code_009
is_enabled: true
is_private: false
author_id: 1
insertion_position: html_bottom
customize_type: javascript
comments: comment_009
project_pattern: ""
20 changes: 19 additions & 1 deletion test/unit/view_customize_view_hook_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@ def test_view_layouts_base_html_head

end

def test_view_layouts_base_body_bottom

User.current = User.find(1)

expected = <<HTML
<!-- view customize id:9 -->
<script type=\"text/javascript\">
//<![CDATA[
code_009
//]]>
</script>
HTML

html = @hook.view_layouts_base_body_bottom({:request => Request.new("/issues"), :project => @project_ecookbook})
assert_equal expected, html
end

def test_view_issues_form_details_bottom

User.current = User.find(1)
Expand All @@ -106,7 +124,7 @@ def test_view_issues_form_details_bottom
HTML

html = @hook.view_issues_form_details_bottom({:request => Request.new("/issues/new"), :project => @project_ecookbook})
assert_match expected, html
assert_equal expected, html

end

Expand Down

0 comments on commit a0502b6

Please sign in to comment.