Skip to content

Commit a0502b6

Browse files
authored
Merge pull request #72 from onozaty/develop/2.8.0
Develop 2.8.0
2 parents 4de1ad3 + ec827ba commit a0502b6

File tree

11 files changed

+45
-5
lines changed

11 files changed

+45
-5
lines changed

README.ja.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ bundle exec rake redmine:plugins:migrate RAILS_ENV=production
5454
* 「Bottom of issue form」 : チケットの入力欄の下部。<br>
5555
チケットの入力欄は、トラッカーやステータスを変えると再構成されますが、「Bottom of issue form」を指定しておくと再構成された際に再度実行されるので、入力欄に対する処理はこれを指定すると便利です。
5656
* 「Bottom of issue detail」 : チケットの詳細表示の下部。
57+
* 「Bottom of all pages」 : 全てのページの末尾(HTML body内で一番下の部分)。
5758

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

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ If the project pattern was set, the code will not be inserted if the current pro
5555
* "Bottom of issue form"<br>
5656
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.
5757
* "Bottom of issue detail"
58+
* "Bottom of all pages" (Last in HTML body)
5859

5960
If there is no part corresponding to the insertion position of the code on the page, the code is not insert.
6061
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.

Vagrantfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Vagrant.configure("2") do |config|
22
config.vm.box = "onozaty/redmine-4.1"
33
config.vm.network "private_network", ip: "192.168.33.10"
44

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

77
config.vm.provider "virtualbox" do |vb|
88
vb.memory = "1024"

app/models/view_customize.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ class ViewCustomize < ActiveRecord::Base
1919
}
2020

2121
INSERTION_POSITION_HTML_HEAD = "html_head"
22+
INSERTION_POSITION_HTML_BOTTOM = "html_bottom"
2223
INSERTION_POSITION_ISSUE_FORM = "issue_form"
2324
INSERTION_POSITION_ISSUE_SHOW = "issue_show"
2425

2526
@@insertion_positions = {
2627
:label_insertion_position_html_head => INSERTION_POSITION_HTML_HEAD,
2728
:label_insertion_position_issue_form => INSERTION_POSITION_ISSUE_FORM,
28-
:label_insertion_position_issue_show => INSERTION_POSITION_ISSUE_SHOW
29+
:label_insertion_position_issue_show => INSERTION_POSITION_ISSUE_SHOW,
30+
:label_insertion_position_html_bottom => INSERTION_POSITION_HTML_BOTTOM
2931
}
3032

3133
def customize_types

config/locales/en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ en:
88
label_css: "CSS"
99
label_html: "HTML"
1010
label_insertion_position_html_head: "Head of all pages"
11+
label_insertion_position_html_bottom: "Bottom of all pages"
1112
label_insertion_position_issue_form: "Bottom of issue form"
1213
label_insertion_position_issue_show: "Bottom of issue detail"
1314
field_path_pattern: "Path pattern"

config/locales/ja.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ja:
88
label_css: "CSS"
99
label_html: "HTML"
1010
label_insertion_position_html_head: "全ページのヘッダ"
11+
label_insertion_position_html_bottom: "全ページの末尾"
1112
label_insertion_position_issue_form: "チケット入力欄の下"
1213
label_insertion_position_issue_show: "チケット詳細の下"
1314
field_path_pattern: "パスのパターン"

config/locales/zh.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ zh:
77
label_javascript: "JavaScript"
88
label_css: "CSS"
99
label_html: "HTML"
10-
label_insertion_position_html_head: "所有页面的head标签"
10+
label_insertion_position_html_head: "所有页面的头部"
11+
label_insertion_position_html_bottom: "所有页面的底部"
1112
label_insertion_position_issue_form: "问题(issue)表单底部"
1213
label_insertion_position_issue_show: "问题(issue)详情页面"
1314
field_path_pattern: "路径表达式"

init.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
name 'View Customize plugin'
44
author 'onozaty'
55
description 'View Customize plugin for Redmine'
6-
version '2.7.0'
6+
version '2.8.0'
77
url 'https://github.com/onozaty/redmine-view-customize'
88
author_url 'https://github.com/onozaty'
99

lib/view_customize/view_hook.rb

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ def view_layouts_base_html_head(context={})
1616
return html
1717
end
1818

19+
def view_layouts_base_body_bottom(context={})
20+
return "\n" + create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_HTML_BOTTOM)
21+
end
22+
1923
def view_issues_form_details_bottom(context={})
2024

2125
return "\n" + create_view_customize_html(context, ViewCustomize::INSERTION_POSITION_ISSUE_FORM)

test/fixtures/view_customizes.yml

+11
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,14 @@ view_customize_008:
8686
customize_type: css
8787
comments: ""
8888
project_pattern: onlinestore
89+
view_customize_009:
90+
id: 9
91+
path_pattern: /issues$
92+
code: code_009
93+
is_enabled: true
94+
is_private: false
95+
author_id: 1
96+
insertion_position: html_bottom
97+
customize_type: javascript
98+
comments: comment_009
99+
project_pattern: ""

test/unit/view_customize_view_hook_test.rb

+19-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ def test_view_layouts_base_html_head
9595

9696
end
9797

98+
def test_view_layouts_base_body_bottom
99+
100+
User.current = User.find(1)
101+
102+
expected = <<HTML
103+
104+
<!-- view customize id:9 -->
105+
<script type=\"text/javascript\">
106+
//<![CDATA[
107+
code_009
108+
//]]>
109+
</script>
110+
HTML
111+
112+
html = @hook.view_layouts_base_body_bottom({:request => Request.new("/issues"), :project => @project_ecookbook})
113+
assert_equal expected, html
114+
end
115+
98116
def test_view_issues_form_details_bottom
99117

100118
User.current = User.find(1)
@@ -106,7 +124,7 @@ def test_view_issues_form_details_bottom
106124
HTML
107125

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

111129
end
112130

0 commit comments

Comments
 (0)