Skip to content

Commit b8dc04a

Browse files
author
Massimo Rossello
committed
Support for redmine 2.3.x
1 parent fc15ba5 commit b8dc04a

31 files changed

+288
-96
lines changed

README.rdoc

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
This is the Redmine(Project manage system) plug-in which adds the feature of the glossary.
44

5+
Ported to and tested on 2.3.x Redmine branch.
6+
Care has been taken to keep compatibility with 1.4.x, but not tested!
7+
58
== The Use
69

710
* Management of technical terms in a system analysis phase
@@ -10,21 +13,21 @@ This is the Redmine(Project manage system) plug-in which adds the feature of the
1013
* Management of naming examples in a coding
1114

1215

13-
== Gegging a plugin package
16+
== Getting a plugin package
1417

1518
{SourceForge.JP}[http://sourceforge.jp/projects/rp-glossary/releases/]
1619

1720

18-
== Installation and Setup
21+
== Installation and Setup (redmine 2.x)
1922

2023
cf. http://www.redmine.org/wiki/1/Plugins
2124

22-
1. Extends the dawnloaded package in vender/plugins directory.
25+
1. Put the downloaded package in the /plugins directory.
2326
2. run the following command to upgrade your database.
24-
rake db:migrate_plugins RAILS_ENV=production
27+
rake redmine:plugins:migrate RAILS_ENV=production
2528
3. Restart Redmine WEB server.
2629
4. Set permissions of glossary plugin in "Administration" -> "Roles and permissions"
27-
5. Open the setting page of projects you need, check the "Glossray" module
30+
5. Open the setting page of projects you need, check the "Glossary" module
2831
6. If you need, select items to make hidden in plugin setting page.
2932

3033
== Usage
@@ -36,9 +39,9 @@ For the details of the usage, see the following page.
3639
* http://www.r-labs.org/projects/rp-glossary/wiki/UsageEn
3740

3841

39-
== Quesion or Proposal
42+
== Question or Proposal
4043

41-
If you find a bug(Defect) or hava a Proposal, create a new issue.
44+
If you find a bug(Defect) or have a Proposal, create a new issue.
4245
http://www.r-labs.org/projects/rp-glossary/issues
4346

4447
If you quest about this plugin, write the forum.

app/controllers/glossary_controller.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ def preview
9696
def edit
9797
@term_categories = TermCategory.find(:all, :conditions => "project_id = #{@project.id}", :order => "position")
9898

99-
if request.post?
99+
if request.post? || request.put?
100100
@term.attributes = params[:term]
101101
@term.updater_id = User.current.id
102102
if @term.save
103103
attach_files(@term, params[:attachments])
104104
flash[:notice] = l(:notice_successful_update)
105-
redirect_to(:controller => 'glossary', :action => 'show',
106-
:project_id => @project, :id => @term.id)
105+
redirect_to(:controller => 'glossary', :action => 'show',
106+
:project_id => @project, :id => @term.id)
107107
return
108108
end
109109
end

app/controllers/term_categories_controller.rb

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ class TermCategoriesController < ApplicationController
77
before_filter :find_project, :authorize
88
before_filter :retrieve_glossary_style, :only => [:index]
99

10-
verify :method => :post, :only => :destroy
11-
verify :mothod => :post, :only => :change_order
12-
1310
helper :glossary
1411
include GlossaryHelper
1512
helper :glossary_styles

app/helpers/glossary_helper.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ def tokenize_by_space(str)
6767

6868

6969
def updated_by(updated, author)
70-
l(:label_updated_time_by,
71-
:author => link_to_user(author), :age => time_tag(updated)).html_safe
70+
l(:label_updated_time_by, :author => link_to_user(author), :age => time_tag(updated)).html_safe
7271
end
7372

7473
end

app/helpers/glossary_port_helper.rb

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
11
module GlossaryPortHelper
22

33

4-
def glossary_csvout(csv, ic, ary)
4+
#def glossary_csvout(csv, ic, ary)
5+
def glossary_csvout(csv, ary)
56
csv << ary.collect {|c|
67
begin
7-
ic.iconv(c.to_s)
8+
#ic.iconv(c.to_s)
9+
Redmine::CodesetUtil.from_utf8(c.to_s, l(:general_csv_encoding))
810
rescue
911
c.to_s
1012
end
1113
}
1214
end
1315

1416
def glossary_to_csv(terms)
15-
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
17+
#ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
1618
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
1719
# csv header fields
1820
headers = Term.export_params.collect {|prm|
1921
label_param(prm)
2022
}
2123

22-
glossary_csvout(csv, ic, headers)
24+
#glossary_csvout(csv, ic, headers)
25+
glossary_csvout(csv, headers)
2326

2427
# csv lines
2528
terms.each do |term|
2629
fields = Term.export_params.collect {|prm|
2730
term.param_to_s(prm)
2831
}
29-
glossary_csvout(csv, ic, fields)
32+
#glossary_csvout(csv, ic, fields)
33+
glossary_csvout(csv, fields)
3034
end
3135
end
3236
export
@@ -36,7 +40,7 @@ def glossary_to_csv(terms)
3640
def glossary_from_csv(portinfo, projid)
3741
line_count = 0
3842
begin
39-
ic = Iconv.new('UTF-8', portinfo.in_encoding)
43+
#ic = Iconv.new('UTF-8', portinfo.in_encoding)
4044

4145
raise l(:error_file_none) if (!portinfo.import_file)
4246
FCSV::parse(portinfo.import_file) { |row|
@@ -47,7 +51,8 @@ def glossary_from_csv(portinfo, projid)
4751
name = row[portinfo.param_col('name')]
4852
raise sprintf(l(:error_no_name), t("label.name")) unless name
4953

50-
name = ic.iconv(name)
54+
#name = ic.iconv(name)
55+
name = Redmine::CodesetUtil.to_utf8(name, portinfo.in_encoding)
5156
term = Term.find(:first,
5257
:conditions => ["project_id = #{projid} AND name = :name",
5358
{:name=>name}])
@@ -61,7 +66,8 @@ def glossary_from_csv(portinfo, projid)
6166
for col in 0 ... row.size
6267
prm = portinfo.col_param(col)
6368
next unless prm
64-
val = ic.iconv(row[col].to_s)
69+
#val = ic.iconv(row[col].to_s)
70+
name = Redmine::CodesetUtil.to_utf8(row[col].to_s, portinfo.in_encoding)
6571
case prm
6672
when 'name'
6773
when 'category'

app/helpers/glossary_styles_helper.rb

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def search_index_table(ary, sepcnt, proj, search_index_type = nil)
3737
str += '</td>'
3838
end
3939
str += '</tr></table>'
40+
str.html_safe
4041
end
4142

4243
def search_params

app/models/term.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -111,38 +111,38 @@ def self.find_for_macro(tname, proj, all_project = false)
111111
end
112112

113113
def self.default_show_params
114-
['name_cn', 'name_fr', 'name_en', 'tech_en', 'rubi', 'abbr_whole', 'datatype', 'codename', 'project', 'category']
114+
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename', 'project', 'category']
115115
end
116116

117117
def self.default_searched_params
118-
['name', 'name_en', 'name_cn', 'name_fr', 'tech_en', 'abbr_whole', 'datatype', 'codename', 'description']
118+
['name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'description']
119119
end
120120

121121
def self.default_sort_params
122-
['id', 'name', 'name_en', 'name_cn', 'name_fr', 'tech_en', 'abbr_whole', 'datatype', 'codename', 'project', 'category',
122+
['id', 'name', 'name_en', 'abbr_whole', 'datatype', 'codename', 'project', 'category',
123123
'datetime']
124124
end
125125

126126
def self.hidable_params
127-
['name_en', 'name_cn', 'name_fr', 'tech_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
127+
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
128128
end
129129

130130
def self.setting_params
131-
['name_en', 'name_cn', 'name_fr', 'tech_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
131+
['name_en', 'rubi', 'abbr_whole', 'datatype', 'codename']
132132
end
133133

134134
def self.export_params
135135
['id','project',
136-
'name', 'name_en', 'name_cn', 'name_fr', 'tech_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
136+
'name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
137137
'author', 'updater', 'created_on', 'updated_on',
138138
'description']
139139
end
140140

141141
def self.import_params
142-
['name', 'name_en', 'name_cn', 'name_fr', 'tech_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
142+
['name', 'name_en', 'rubi', 'abbr_whole', 'category', 'datatype', 'codename',
143143
'description']
144144
end
145145

146146

147147

148-
end
148+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<h3 class="title"><%=l(:label_term_category_new)%></h3>
2+
3+
<% form = labelled_form_for @category, :as => :category, :url => { :action => 'add_term_category', :project_id => @project }, :html => {:class => 'tabular'} do |f| %>
4+
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
5+
<p class="buttons">
6+
<%= submit_tag l(:button_create), :name => nil %>
7+
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %>
8+
</p>
9+
<% end %>
10+
<%= form if Rails::VERSION::MAJOR >= 3 %>

app/views/glossary/_form.html.erb

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,20 @@
99

1010
<div class="splitcontentleft">
1111
<p><%= f.select :category_id, (@term_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
12-
<%= prompt_to_remote(l(:label_term_category_new),
13-
l(:label_term_category_new), 'category[name]',
14-
{:controller => 'glossary', :action => 'add_term_category', :project_id => @project},
12+
<% if Rails::VERSION::MAJOR >= 3 %>
13+
<%= link_to(l(:label_term_category_new),
14+
{:controller => 'glossary', :action => 'add_term_category', :project_id => @project.id },
15+
:category => 'category[name]',
16+
:class => 'icon icon-add',
17+
:tabindex => 199,
18+
:method => 'get',
19+
:remote => true) if authorize_for('glossary', 'add_term_category') %></p>
20+
<% else %>
21+
<%= prompt_to_remote(l(:label_term_category_new),
22+
l(:label_term_category_new), 'category[name]',
23+
{:controller => 'glossary', :action => 'add_term_category', :project_id => @project },
1524
:class => 'icon icon-add', :tabindex => 199) if authorize_for('glossary', 'add_term_category') %></p>
25+
<% end %>
1626
</div>
1727
<p><%= f.text_area :description, :label=>t('label.description'),
1828
:cols => 60,

app/views/glossary/_index_in_category.html.erb

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
<% for prm in @show_params %>
1717
<td><%=h term.value(prm) %></td>
1818
<% end %>
19-
<td><%=h truncate(term.description, :length=>50) %></td>
20-
<td align="right">
21-
<% if term.project_id == @project.id %>
19+
<!--td><%=h truncate(term.description, :length=>50) %></td-->
20+
<td><%=textilizable term.description %></td>
21+
<td align="right" width="40px">
22+
<% if term.project_id == @project.id %>
2223
<%= link_to_if_authorized(image_tag('edit.png'), {:action => 'edit', :project_id => @project, :id => term}, :title => l(:button_edit)) %>
2324
<%= link_to_if_authorized(image_tag('delete.png'), {:action => 'destroy', :project_id => @project, :id => term}, :confirm => l(:text_are_you_sure), :method => :post, :title => l(:button_delete)) %>
2425
<% end %>
@@ -27,4 +28,4 @@
2728
<% end %>
2829
</tbody>
2930
</table>
30-
<br />
31+
<br />

app/views/glossary/_sidebar.html.erb

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
<%= link_to_if_authorized(l(:button_clear), {:controller => 'glossary', :action => 'index_clear', :project_id => @project}, :class => 'icon icon-reload') %>
3838
</div>
3939
<% end %>
40-
4140
<%= search_index_table(l(:index_ary_en), l(:index_ary_en_sep_cnt), @project, 'en') %>
4241
<br />
4342
<%= search_index_table(l(:index_ary), l(:index_ary_sep_cnt), @project) %>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<h2><%=l(:label_term_category_new)%></h2>
2+
3+
<% form = labelled_form_for @category, :as => :category, :url => { :action => 'add_term_category', :project_id => @project }, :html => {:class => 'tabular'} do |f| %>
4+
<%= render :partial => 'term_categories/form', :locals => { :f => f } %>
5+
<%= submit_tag l(:button_create) %>
6+
<% end %>
7+
<%= form if Rails::VERSION::MAJOR >= 3 %>
8+
9+
<% html_title(l(:glossary_title)) -%>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'glossary/add_term_category_modal') %>');
2+
showModal('ajax-modal', '600px');

app/views/glossary/edit.html.erb

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
<h2><%= l(:label_term) %> #<%= @term.id %></h2>
22

3-
<% labelled_tabular_form_for :term, @term,
3+
<% form = labelled_form_for @term, :as => :term,
44
:url => {:action => 'edit', :project_id => @project, :id => @term},
5-
:html => {:multipart => true, :id => 'term-form'} do |f| %>
5+
:html => {:class => 'tabular', :multipart => true, :id => 'term-form'} do |f| %>
66
<%= error_messages_for 'term' %>
77
<div class="box">
88
<%= render :partial => 'glossary/form', :locals => {:f => f} %>
99
</div>
1010
<%= submit_tag l(:button_edit) %>
11-
<%= link_to_remote l(:label_preview),
12-
{ :url => { :controller => 'glossary', :action => 'preview', :project_id => @project },
13-
:method => 'post',
14-
:update => 'preview',
15-
:with => "Form.serialize('term-form')",
16-
:complete => "Element.scrollTo('preview')"
17-
}, :accesskey => accesskey(:preview) %>
11+
<% if Rails::VERSION::MAJOR >= 3 %>
12+
<%= preview_link({:controller => 'glossary', :action => 'preview', :project_id => @project.id },
13+
"term-form",
14+
"preview") %>
15+
<% else %>
16+
<%= link_to_remote l(:label_preview),
17+
{ :url => { :controller => 'glossary', :action => 'preview', :project_id => @project },
18+
:method => 'post',
19+
:update => 'preview',
20+
:with => "Form.serialize('term-form')",
21+
:complete => "Element.scrollTo('preview')"
22+
}, :accesskey => accesskey(:preview) %>
23+
<% end %>
1824
<% end %>
25+
<%= form if Rails::VERSION::MAJOR >= 3 %>
1926

2027
<div id="preview" class="wiki"></div>
2128

app/views/glossary/import_csv.html.erb

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<h2><%=h l(:label_glossary_import_csv) %> </h2>
22

33

4-
<% form_tag({:controller => 'glossary', :action => 'import_csv_exec', :project_id=>@project},
4+
<% form = form_tag({:controller => 'glossary', :action => 'import_csv_exec', :project_id=>@project},
55
{:multipart => true}) do %>
66

77
<%= l(:label_csv_file) %>
@@ -52,5 +52,6 @@
5252

5353
<%= submit_tag(l(:label_import)) %>
5454
<% end %>
55+
<%= form if Rails::VERSION::MAJOR >= 3 %>
5556

5657
<% html_title(l(:glossary_title)) -%>

app/views/glossary/move_all.html.erb

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<%= simple_format(l(:error_no_movement_project)) %>
88
</div>
99
<% else %>
10-
<% form_tag({:project_id => @project}, :id => 'move_all_form') do %>
10+
<% form = form_tag({:project_id => @project}, :id => 'move_all_form') do %>
1111

1212
<div class="box tabular">
1313
<p><label for="new_project_id"><%=l(:label_movement_project)%>:</label>
@@ -17,5 +17,6 @@
1717
</div>
1818
<%= submit_tag l(:button_move) %>
1919
<% end %>
20+
<%= form if Rails::VERSION::MAJOR >= 3 %>
2021
<% end %>
2122

0 commit comments

Comments
 (0)