Skip to content

Commit f4bf47b

Browse files
authored
Merge pull request #30 from onozaty/support-redmine4
Support redmine4
2 parents 13cc455 + 7b41b60 commit f4bf47b

File tree

13 files changed

+50
-34
lines changed

13 files changed

+50
-34
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
gem 'activerecord-compatible_legacy_migration'

README.ja.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010

1111
Redmineのプラグインディレクトリに、このリポジトリを`view_customize`としてクローンします。
1212

13-
cd {RAILS_ROOT}/plugins
14-
git clone https://github.com/onozaty/redmine-view-customize.git view_customize
15-
cd ../
16-
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
13+
```
14+
cd {RAILS_ROOT}/plugins
15+
git clone https://github.com/onozaty/redmine-view-customize.git view_customize
16+
cd ../
17+
bundle install --without development test
18+
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
19+
```
1720

1821
**注意: ディレクトリ名は`view_customize`とする必要があります。ディレクトリ名が異なると、プラグインの実行に失敗します。**
1922

@@ -124,7 +127,8 @@ ViewCustomize = {
124127

125128
## サポートバージョン
126129

127-
* Redmine 2.0.x 以降
130+
* 最新バージョン : Redmine 3.1.x 以降
131+
* 1.2.2 : Redmine 2.0.x から 3.4.x
128132

129133
## ライセンス
130134

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Install the plugin in your Redmine plugins directory, clone this repository as `
1414
cd {RAILS_ROOT}/plugins
1515
git clone https://github.com/onozaty/redmine-view-customize.git view_customize
1616
cd ../
17+
bundle install --without development test
1718
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
1819
```
1920

@@ -130,9 +131,10 @@ For example, to access the user's API key is `ViewCustomize.context.user.apiKey`
130131

131132
* [onozaty/redmine\-view\-customize\-scripts: Script list for "Redmine View Customize Plugin"](https://github.com/onozaty/redmine-view-customize-scripts)
132133

133-
## Redmine 2.0.x or later
134+
## Supported versions
134135

135-
* Redmine 2.0.x or later
136+
* Current version : Redmine 3.1.x or later
137+
* 1.2.2 : Redmine 2.0.x - 3.4.x
136138

137139
## License
138140

app/controllers/view_customizes_controller.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ class ViewCustomizesController < ApplicationController
33

44
layout 'admin'
55

6-
before_filter :require_admin
7-
before_filter :find_view_customize, :except => [:index, :new, :create]
6+
before_action :require_admin
7+
before_action :find_view_customize, :except => [:index, :new, :create]
88

99
helper :sort
1010
include SortHelper
@@ -20,7 +20,7 @@ def new
2020
end
2121

2222
def create
23-
@view_customize = ViewCustomize.new(params[:view_customize])
23+
@view_customize = ViewCustomize.new(view_customize_params)
2424

2525
if @view_customize.save
2626
flash[:notice] = l(:notice_successful_create)
@@ -37,7 +37,7 @@ def edit
3737
end
3838

3939
def update
40-
@view_customize.attributes = params[:view_customize]
40+
@view_customize.attributes = view_customize_params
4141
if @view_customize.save
4242
flash[:notice] = l(:notice_successful_update)
4343
redirect_to view_customize_path(@view_customize.id)
@@ -61,4 +61,8 @@ def find_view_customize
6161
render_404 unless @view_customize
6262
end
6363

64+
def view_customize_params
65+
params.require(:view_customize)
66+
.permit(:path_pattern, :customize_type, :code, :is_enabled, :is_private, :insertion_position, :comments)
67+
end
6468
end
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module ViewCustomizesHelper
22
def highlight_by_language(code, language)
3+
code.gsub!(/(\r\n|\r|\n)/, "\n")
34
("<pre><code class=\"#{language} syntaxhl\">" +
4-
CodeRay.scan(code, language).html(:wrap => :span) +
5+
Redmine::SyntaxHighlighting.highlight_by_language(code, language) +
56
"</code></pre>").html_safe
67
end
78
end

app/models/view_customize.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ class ViewCustomize < ActiveRecord::Base
1010

1111
validate :valid_pattern
1212

13-
attr_protected :id
14-
1513
TYPE_JAVASCRIPT = "javascript"
1614
TYPE_CSS = "css"
1715

app/views/view_customizes/show.html.erb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@
1414

1515
<table class="box view_customize">
1616
<tr>
17-
<th><%=h l(:field_path_pattern) %>:</th>
17+
<th><%=h l(:field_path_pattern) %></th>
1818
<td><%=h @view_customize.path_pattern %></td>
1919
</tr>
2020
<tr>
21-
<th><%=h l(:field_insertion_position) %>:</th>
21+
<th><%=h l(:field_insertion_position) %></th>
2222
<td><%=h l(@view_customize.insertion_position_label) %></td>
2323
</tr>
2424
<tr>
25-
<th><%=h l(:field_customize_type) %>:</th>
25+
<th><%=h l(:field_customize_type) %></th>
2626
<td><%=h l(@view_customize.customize_type_label) %></td>
2727
</tr>
2828
<tr>
29-
<th><%=h l(:field_code) %>:</th>
30-
<td><%= highlight_by_language(
31-
@view_customize.code, @view_customize.is_javascript? ? :js : :css) %></td>
29+
<th><%=h l(:field_code) %></th>
30+
<td><div><%= highlight_by_language(
31+
@view_customize.code, @view_customize.is_javascript? ? :js : :css) %></div></td>
3232
</tr>
3333
<tr>
34-
<th><%=h l(:field_comments) %>:</th>
34+
<th><%=h l(:field_comments) %></th>
3535
<td><%=h @view_customize.comments %></td>
3636
</tr>
3737
<tr>
38-
<th><%=h l(:field_is_enabled) %>:</th>
38+
<th><%=h l(:field_is_enabled) %></th>
3939
<td><%=h @view_customize.is_enabled ? l(:general_text_yes) : l(:general_text_no) %></td>
4040
</tr>
4141
<tr>
42-
<th><%=h l(:field_is_private) %>:</th>
42+
<th><%=h l(:field_is_private) %></th>
4343
<td><%=h @view_customize.is_private ? l(:general_text_yes) : l(:general_text_no) %></td>
4444
</tr>
4545
<tr>
46-
<th><%=h l(:field_author) %>:</th>
46+
<th><%=h l(:field_author) %></th>
4747
<td><%=h @view_customize.author.name unless @view_customize.author == nil %></td>
4848
</tr>
4949
</table>

assets/stylesheets/view_customize.css

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,30 @@ table.view_customize.list tr.private {
2323

2424
table.view_customize.box {
2525
width: 100%;
26+
table-layout: fixed;
2627
}
2728

2829
table.view_customize.box th {
2930
text-align: right;
3031
vertical-align: top;
31-
width: 10%;
32-
padding: 0 10px;
33-
white-space: nowrap;
32+
width: 160px;
33+
padding: 2px 10px 2px 0px;
3434
}
3535

3636
table.view_customize.box td {
3737
vertical-align: top;
38+
padding: 2px;
3839
}
3940

4041
table.view_customize.box td pre {
4142
margin: 0;
4243
padding: 2px 4px;
43-
background-color: #FFFFFF;
44-
border: 1px solid #E4E4E4;
44+
background-color: #fafafa;
45+
border: 1px solid #e2e2e2;
46+
border-radius: 3px;
47+
width: auto;
48+
overflow-x: auto;
49+
overflow-y: hidden;
4550
}
4651

4752
textarea#view_customize_code {

db/migrate/001_create_view_customizes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreateViewCustomizes < ActiveRecord::Migration
1+
class CreateViewCustomizes < ActiveRecord::CompatibleLegacyMigration.migration_class
22
def change
33
create_table :view_customizes do |t|
44
t.string :path_pattern

db/migrate/002_add_column_view_customizes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class AddColumnViewCustomizes < ActiveRecord::Migration
1+
class AddColumnViewCustomizes < ActiveRecord::CompatibleLegacyMigration.migration_class
22
def up
33
add_column :view_customizes, :is_enabled, :boolean, :null => false, :default => true
44
add_column :view_customizes, :is_private, :boolean, :null => false, :default => false

0 commit comments

Comments
 (0)