@@ -1,95 +1,98 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require 'coderay' |
|
18 | require 'coderay' | |
19 | require 'coderay/helpers/file_type' |
|
19 | require 'coderay/helpers/file_type' | |
20 | require 'iconv' |
|
20 | require 'iconv' | |
21 |
|
21 | |||
22 | module RepositoriesHelper |
|
22 | module RepositoriesHelper | |
23 | def syntax_highlight(name, content) |
|
23 | def syntax_highlight(name, content) | |
24 | type = CodeRay::FileType[name] |
|
24 | type = CodeRay::FileType[name] | |
25 | type ? CodeRay.scan(content, type).html : h(content) |
|
25 | type ? CodeRay.scan(content, type).html : h(content) | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def format_revision(txt) |
|
28 | def format_revision(txt) | |
29 | txt.to_s[0,8] |
|
29 | txt.to_s[0,8] | |
30 | end |
|
30 | end | |
31 |
|
31 | |||
32 | def to_utf8(str) |
|
32 | def to_utf8(str) | |
33 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii |
|
33 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
34 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) |
|
34 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) | |
35 | @encodings.each do |encoding| |
|
35 | @encodings.each do |encoding| | |
36 | begin |
|
36 | begin | |
37 | return Iconv.conv('UTF-8', encoding, str) |
|
37 | return Iconv.conv('UTF-8', encoding, str) | |
38 | rescue Iconv::Failure |
|
38 | rescue Iconv::Failure | |
39 | # do nothing here and try the next encoding |
|
39 | # do nothing here and try the next encoding | |
40 | end |
|
40 | end | |
41 | end |
|
41 | end | |
42 | str |
|
42 | str | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | def repository_field_tags(form, repository) |
|
45 | def repository_field_tags(form, repository) | |
46 | method = repository.class.name.demodulize.underscore + "_field_tags" |
|
46 | method = repository.class.name.demodulize.underscore + "_field_tags" | |
47 | send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) |
|
47 | send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | def scm_select_tag(repository) |
|
50 | def scm_select_tag(repository) | |
51 | container = [[]] |
|
51 | container = [[]] | |
52 | REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} |
|
52 | REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} | |
53 | select_tag('repository_scm', |
|
53 | select_tag('repository_scm', | |
54 | options_for_select(container, repository.class.name.demodulize), |
|
54 | options_for_select(container, repository.class.name.demodulize), | |
55 | :disabled => (repository && !repository.new_record?), |
|
55 | :disabled => (repository && !repository.new_record?), | |
56 | :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") |
|
56 | :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") | |
57 | ) |
|
57 | ) | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def with_leading_slash(path) |
|
60 | def with_leading_slash(path) | |
61 | path ||= '' |
|
61 | path.to_s.starts_with?('/') ? path : "/#{path}" | |
62 | path.starts_with?('/') ? path : "/#{path}" |
|
62 | end | |
|
63 | ||||
|
64 | def without_leading_slash(path) | |||
|
65 | path.gsub(%r{^/+}, '') | |||
63 | end |
|
66 | end | |
64 |
|
67 | |||
65 | def subversion_field_tags(form, repository) |
|
68 | def subversion_field_tags(form, repository) | |
66 | content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) + |
|
69 | content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) + | |
67 | '<br />(http://, https://, svn://, file:///)') + |
|
70 | '<br />(http://, https://, svn://, file:///)') + | |
68 | content_tag('p', form.text_field(:login, :size => 30)) + |
|
71 | content_tag('p', form.text_field(:login, :size => 30)) + | |
69 | content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', |
|
72 | content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', | |
70 | :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), |
|
73 | :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), | |
71 | :onfocus => "this.value=''; this.name='repository[password]';", |
|
74 | :onfocus => "this.value=''; this.name='repository[password]';", | |
72 | :onchange => "this.name='repository[password]';")) |
|
75 | :onchange => "this.name='repository[password]';")) | |
73 | end |
|
76 | end | |
74 |
|
77 | |||
75 | def darcs_field_tags(form, repository) |
|
78 | def darcs_field_tags(form, repository) | |
76 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) |
|
79 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) | |
77 | end |
|
80 | end | |
78 |
|
81 | |||
79 | def mercurial_field_tags(form, repository) |
|
82 | def mercurial_field_tags(form, repository) | |
80 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
|
83 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) | |
81 | end |
|
84 | end | |
82 |
|
85 | |||
83 | def git_field_tags(form, repository) |
|
86 | def git_field_tags(form, repository) | |
84 | content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
|
87 | content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) | |
85 | end |
|
88 | end | |
86 |
|
89 | |||
87 | def cvs_field_tags(form, repository) |
|
90 | def cvs_field_tags(form, repository) | |
88 | content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + |
|
91 | content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + | |
89 | content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) |
|
92 | content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) | |
90 | end |
|
93 | end | |
91 |
|
94 | |||
92 | def bazaar_field_tags(form, repository) |
|
95 | def bazaar_field_tags(form, repository) | |
93 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) |
|
96 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) | |
94 | end |
|
97 | end | |
95 | end |
|
98 | end |
@@ -1,65 +1,65 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | « |
|
2 | « | |
3 | <% unless @changeset.previous.nil? -%> |
|
3 | <% unless @changeset.previous.nil? -%> | |
4 | <%= link_to l(:label_previous), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.previous.revision %> |
|
4 | <%= link_to l(:label_previous), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.previous.revision %> | |
5 | <% else -%> |
|
5 | <% else -%> | |
6 | <%= l(:label_previous) %> |
|
6 | <%= l(:label_previous) %> | |
7 | <% end -%> |
|
7 | <% end -%> | |
8 | | |
|
8 | | | |
9 | <% unless @changeset.next.nil? -%> |
|
9 | <% unless @changeset.next.nil? -%> | |
10 | <%= link_to l(:label_next), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.next.revision %> |
|
10 | <%= link_to l(:label_next), :controller => 'repositories', :action => 'revision', :id => @project, :rev => @changeset.next.revision %> | |
11 | <% else -%> |
|
11 | <% else -%> | |
12 | <%= l(:label_next) %> |
|
12 | <%= l(:label_next) %> | |
13 | <% end -%> |
|
13 | <% end -%> | |
14 | » |
|
14 | » | |
15 |
|
15 | |||
16 | <% form_tag do %> |
|
16 | <% form_tag do %> | |
17 | <%= text_field_tag 'rev', @rev, :size => 5 %> |
|
17 | <%= text_field_tag 'rev', @rev, :size => 5 %> | |
18 | <%= submit_tag 'OK' %> |
|
18 | <%= submit_tag 'OK' %> | |
19 | <% end %> |
|
19 | <% end %> | |
20 | </div> |
|
20 | </div> | |
21 |
|
21 | |||
22 | <h2><%= l(:label_revision) %> <%= format_revision(@changeset.revision) %></h2> |
|
22 | <h2><%= l(:label_revision) %> <%= format_revision(@changeset.revision) %></h2> | |
23 |
|
23 | |||
24 | <p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> |
|
24 | <p><% if @changeset.scmid %>ID: <%= @changeset.scmid %><br /><% end %> | |
25 | <em><%= @changeset.committer.to_s.split('<').first %>, <%= format_time(@changeset.committed_on) %></em></p> |
|
25 | <em><%= @changeset.committer.to_s.split('<').first %>, <%= format_time(@changeset.committed_on) %></em></p> | |
26 |
|
26 | |||
27 | <%= textilizable @changeset.comments %> |
|
27 | <%= textilizable @changeset.comments %> | |
28 |
|
28 | |||
29 | <% if @changeset.issues.any? %> |
|
29 | <% if @changeset.issues.any? %> | |
30 | <h3><%= l(:label_related_issues) %></h3> |
|
30 | <h3><%= l(:label_related_issues) %></h3> | |
31 | <ul> |
|
31 | <ul> | |
32 | <% @changeset.issues.each do |issue| %> |
|
32 | <% @changeset.issues.each do |issue| %> | |
33 | <li><%= link_to_issue issue %>: <%=h issue.subject %></li> |
|
33 | <li><%= link_to_issue issue %>: <%=h issue.subject %></li> | |
34 | <% end %> |
|
34 | <% end %> | |
35 | </ul> |
|
35 | </ul> | |
36 | <% end %> |
|
36 | <% end %> | |
37 |
|
37 | |||
38 | <h3><%= l(:label_attachment_plural) %></h3> |
|
38 | <h3><%= l(:label_attachment_plural) %></h3> | |
39 | <div style="float:right;"> |
|
39 | <div style="float:right;"> | |
40 | <div class="square action_A"></div> <div style="float:left;"><%= l(:label_added) %> </div> |
|
40 | <div class="square action_A"></div> <div style="float:left;"><%= l(:label_added) %> </div> | |
41 | <div class="square action_M"></div> <div style="float:left;"><%= l(:label_modified) %> </div> |
|
41 | <div class="square action_M"></div> <div style="float:left;"><%= l(:label_modified) %> </div> | |
42 | <div class="square action_D"></div> <div style="float:left;"><%= l(:label_deleted) %> </div> |
|
42 | <div class="square action_D"></div> <div style="float:left;"><%= l(:label_deleted) %> </div> | |
43 | </div> |
|
43 | </div> | |
44 | <p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p> |
|
44 | <p><%= link_to(l(:label_view_diff), :action => 'diff', :id => @project, :path => "", :rev => @changeset.revision) if @changeset.changes.any? %></p> | |
45 | <table class="list"> |
|
45 | <table class="list"> | |
46 | <tbody> |
|
46 | <tbody> | |
47 | <% @changes.each do |change| %> |
|
47 | <% @changes.each do |change| %> | |
48 | <tr class="<%= cycle 'odd', 'even' %>"> |
|
48 | <tr class="<%= cycle 'odd', 'even' %>"> | |
49 | <td><div class="square action_<%= change.action %>"></div> <%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %></td> |
|
49 | <td><div class="square action_<%= change.action %>"></div> <%= change.path %> <%= "(#{change.revision})" unless change.revision.blank? %></td> | |
50 | <td align="right"> |
|
50 | <td align="right"> | |
51 | <% if change.action == "M" %> |
|
51 | <% if change.action == "M" %> | |
52 | <%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => change.path, :rev => @changeset.revision %> |
|
52 | <%= link_to l(:label_view_diff), :action => 'diff', :id => @project, :path => without_leading_slash(change.path), :rev => @changeset.revision %> | |
53 | <% end %> |
|
53 | <% end %> | |
54 | </td> |
|
54 | </td> | |
55 | </tr> |
|
55 | </tr> | |
56 | <% end %> |
|
56 | <% end %> | |
57 | </tbody> |
|
57 | </tbody> | |
58 | </table> |
|
58 | </table> | |
59 | <p class="pagination"><%= pagination_links_full @changes_pages %></p> |
|
59 | <p class="pagination"><%= pagination_links_full @changes_pages %></p> | |
60 |
|
60 | |||
61 | <% content_for :header_tags do %> |
|
61 | <% content_for :header_tags do %> | |
62 | <%= stylesheet_link_tag "scm" %> |
|
62 | <%= stylesheet_link_tag "scm" %> | |
63 | <% end %> |
|
63 | <% end %> | |
64 |
|
64 | |||
65 | <% html_title("#{l(:label_revision)} #{@changeset.revision}") -%> |
|
65 | <% html_title("#{l(:label_revision)} #{@changeset.revision}") -%> |
General Comments 0
You need to be logged in to leave comments.
Login now