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