@@ -0,0 +1,86 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
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 | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require 'redmine/scm/adapters/bazaar_adapter' | |||
|
19 | ||||
|
20 | class Repository::Bazaar < Repository | |||
|
21 | attr_protected :root_url | |||
|
22 | validates_presence_of :url | |||
|
23 | ||||
|
24 | def scm_adapter | |||
|
25 | Redmine::Scm::Adapters::BazaarAdapter | |||
|
26 | end | |||
|
27 | ||||
|
28 | def self.scm_name | |||
|
29 | 'Bazaar' | |||
|
30 | end | |||
|
31 | ||||
|
32 | def entries(path=nil, identifier=nil) | |||
|
33 | entries = scm.entries(path, identifier) | |||
|
34 | if entries | |||
|
35 | entries.each do |e| | |||
|
36 | next if e.lastrev.revision.blank? | |||
|
37 | c = Change.find(:first, | |||
|
38 | :include => :changeset, | |||
|
39 | :conditions => ["#{Change.table_name}.revision = ? and #{Changeset.table_name}.repository_id = ?", e.lastrev.revision, id], | |||
|
40 | :order => "#{Changeset.table_name}.revision DESC") | |||
|
41 | if c | |||
|
42 | e.lastrev.identifier = c.changeset.revision | |||
|
43 | e.lastrev.name = c.changeset.revision | |||
|
44 | e.lastrev.author = c.changeset.committer | |||
|
45 | end | |||
|
46 | end | |||
|
47 | end | |||
|
48 | end | |||
|
49 | ||||
|
50 | def fetch_changesets | |||
|
51 | scm_info = scm.info | |||
|
52 | if scm_info | |||
|
53 | # latest revision found in database | |||
|
54 | db_revision = latest_changeset ? latest_changeset.revision : 0 | |||
|
55 | # latest revision in the repository | |||
|
56 | scm_revision = scm_info.lastrev.identifier.to_i | |||
|
57 | if db_revision < scm_revision | |||
|
58 | logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug? | |||
|
59 | identifier_from = db_revision + 1 | |||
|
60 | while (identifier_from <= scm_revision) | |||
|
61 | # loads changesets by batches of 200 | |||
|
62 | identifier_to = [identifier_from + 199, scm_revision].min | |||
|
63 | revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true) | |||
|
64 | transaction do | |||
|
65 | revisions.reverse_each do |revision| | |||
|
66 | changeset = Changeset.create(:repository => self, | |||
|
67 | :revision => revision.identifier, | |||
|
68 | :committer => revision.author, | |||
|
69 | :committed_on => revision.time, | |||
|
70 | :scmid => revision.scmid, | |||
|
71 | :comments => revision.message) | |||
|
72 | ||||
|
73 | revision.paths.each do |change| | |||
|
74 | Change.create(:changeset => changeset, | |||
|
75 | :action => change[:action], | |||
|
76 | :path => change[:path], | |||
|
77 | :revision => change[:revision]) | |||
|
78 | end | |||
|
79 | end | |||
|
80 | end unless revisions.nil? | |||
|
81 | identifier_from = identifier_to + 1 | |||
|
82 | end | |||
|
83 | end | |||
|
84 | end | |||
|
85 | end | |||
|
86 | end |
@@ -0,0 +1,204 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
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 | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require 'redmine/scm/adapters/abstract_adapter' | |||
|
19 | ||||
|
20 | module Redmine | |||
|
21 | module Scm | |||
|
22 | module Adapters | |||
|
23 | class BazaarAdapter < AbstractAdapter | |||
|
24 | ||||
|
25 | # Bazaar executable name | |||
|
26 | BZR_BIN = "bzr" | |||
|
27 | ||||
|
28 | # Get info about the repository | |||
|
29 | def info | |||
|
30 | cmd = "#{BZR_BIN} revno #{target('')}" | |||
|
31 | info = nil | |||
|
32 | shellout(cmd) do |io| | |||
|
33 | if io.read =~ %r{^(\d+)$} | |||
|
34 | info = Info.new({:root_url => url, | |||
|
35 | :lastrev => Revision.new({ | |||
|
36 | :identifier => $1 | |||
|
37 | }) | |||
|
38 | }) | |||
|
39 | end | |||
|
40 | end | |||
|
41 | return nil if $? && $?.exitstatus != 0 | |||
|
42 | info | |||
|
43 | rescue Errno::ENOENT => e | |||
|
44 | return nil | |||
|
45 | end | |||
|
46 | ||||
|
47 | # Returns the entry identified by path and revision identifier | |||
|
48 | # or nil if entry doesn't exist in the repository | |||
|
49 | def entry(path=nil, identifier=nil) | |||
|
50 | path ||= '' | |||
|
51 | parts = path.split(%r{[\/\\]}).select {|p| !p.blank?} | |||
|
52 | if parts.size > 0 | |||
|
53 | parent = parts[0..-2].join('/') | |||
|
54 | entries = entries(parent, identifier) | |||
|
55 | entries ? entries.detect {|e| e.name == parts.last} : nil | |||
|
56 | end | |||
|
57 | end | |||
|
58 | ||||
|
59 | # Returns an Entries collection | |||
|
60 | # or nil if the given path doesn't exist in the repository | |||
|
61 | def entries(path=nil, identifier=nil) | |||
|
62 | path ||= '' | |||
|
63 | entries = Entries.new | |||
|
64 | cmd = "#{BZR_BIN} ls -v --show-ids" | |||
|
65 | cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0 | |||
|
66 | cmd << " #{target(path)}" | |||
|
67 | shellout(cmd) do |io| | |||
|
68 | prefix = "#{url}/#{path}".gsub('\\', '/') | |||
|
69 | logger.debug "PREFIX: #{prefix}" | |||
|
70 | re = %r{^V\s+#{Regexp.escape(prefix)}(\/?)([^\/]+)(\/?)\s+(\S+)$} | |||
|
71 | io.each_line do |line| | |||
|
72 | next unless line =~ re | |||
|
73 | entries << Entry.new({:name => $2.strip, | |||
|
74 | :path => ((path.empty? ? "" : "#{path}/") + $2.strip), | |||
|
75 | :kind => ($3.blank? ? 'file' : 'dir'), | |||
|
76 | :size => nil, | |||
|
77 | :lastrev => Revision.new(:revision => $4.strip) | |||
|
78 | }) | |||
|
79 | end | |||
|
80 | end | |||
|
81 | return nil if $? && $?.exitstatus != 0 | |||
|
82 | logger.debug("Found #{entries.size} entries in the repository for #{target(path)}") if logger && logger.debug? | |||
|
83 | entries.sort_by_name | |||
|
84 | rescue Errno::ENOENT => e | |||
|
85 | raise CommandFailed | |||
|
86 | end | |||
|
87 | ||||
|
88 | def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={}) | |||
|
89 | path ||= '' | |||
|
90 | identifier_from = 'last:1' unless identifier_from and identifier_from.to_i > 0 | |||
|
91 | identifier_to = 1 unless identifier_to and identifier_to.to_i > 0 | |||
|
92 | revisions = Revisions.new | |||
|
93 | cmd = "#{BZR_BIN} log -v --show-ids -r#{identifier_to.to_i}..#{identifier_from} #{target(path)}" | |||
|
94 | shellout(cmd) do |io| | |||
|
95 | revision = nil | |||
|
96 | parsing = nil | |||
|
97 | io.each_line do |line| | |||
|
98 | if line =~ /^----/ | |||
|
99 | revisions << revision if revision | |||
|
100 | revision = Revision.new(:paths => [], :message => '') | |||
|
101 | parsing = nil | |||
|
102 | else | |||
|
103 | next unless revision | |||
|
104 | ||||
|
105 | if line =~ /^revno: (\d+)$/ | |||
|
106 | revision.identifier = $1.to_i | |||
|
107 | elsif line =~ /^committer: (.+)$/ | |||
|
108 | revision.author = $1.strip | |||
|
109 | elsif line =~ /^revision-id:(.+)$/ | |||
|
110 | revision.scmid = $1.strip | |||
|
111 | elsif line =~ /^timestamp: (.+)$/ | |||
|
112 | revision.time = Time.parse($1).localtime | |||
|
113 | elsif line =~ /^(message|added|modified|removed|renamed):/ | |||
|
114 | parsing = $1 | |||
|
115 | elsif line =~ /^ (.+)$/ | |||
|
116 | if parsing == 'message' | |||
|
117 | revision.message << "#{$1}\n" | |||
|
118 | else | |||
|
119 | if $1 =~ /^(.*)\s+(\S+)$/ | |||
|
120 | path = $1.strip | |||
|
121 | revid = $2 | |||
|
122 | case parsing | |||
|
123 | when 'added' | |||
|
124 | revision.paths << {:action => 'A', :path => "/#{path}", :revision => revid} | |||
|
125 | when 'modified' | |||
|
126 | revision.paths << {:action => 'M', :path => "/#{path}", :revision => revid} | |||
|
127 | when 'removed' | |||
|
128 | revision.paths << {:action => 'D', :path => "/#{path}", :revision => revid} | |||
|
129 | when 'renamed' | |||
|
130 | new_path = path.split('=>').last | |||
|
131 | revision.paths << {:action => 'M', :path => "/#{new_path.strip}", :revision => revid} if new_path | |||
|
132 | end | |||
|
133 | end | |||
|
134 | end | |||
|
135 | else | |||
|
136 | parsing = nil | |||
|
137 | end | |||
|
138 | end | |||
|
139 | end | |||
|
140 | revisions << revision if revision | |||
|
141 | end | |||
|
142 | return nil if $? && $?.exitstatus != 0 | |||
|
143 | revisions | |||
|
144 | rescue Errno::ENOENT => e | |||
|
145 | raise CommandFailed | |||
|
146 | end | |||
|
147 | ||||
|
148 | def diff(path, identifier_from, identifier_to=nil, type="inline") | |||
|
149 | path ||= '' | |||
|
150 | if identifier_to | |||
|
151 | identifier_to = identifier_to.to_i | |||
|
152 | else | |||
|
153 | identifier_to = identifier_from.to_i - 1 | |||
|
154 | end | |||
|
155 | cmd = "#{BZR_BIN} diff -r#{identifier_to}..#{identifier_from} #{target(path)}" | |||
|
156 | diff = [] | |||
|
157 | shellout(cmd) do |io| | |||
|
158 | io.each_line do |line| | |||
|
159 | diff << line | |||
|
160 | end | |||
|
161 | end | |||
|
162 | #return nil if $? && $?.exitstatus != 0 | |||
|
163 | DiffTableList.new diff, type | |||
|
164 | rescue Errno::ENOENT => e | |||
|
165 | raise CommandFailed | |||
|
166 | end | |||
|
167 | ||||
|
168 | def cat(path, identifier=nil) | |||
|
169 | cmd = "#{BZR_BIN} cat" | |||
|
170 | cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0 | |||
|
171 | cmd << " #{target(path)}" | |||
|
172 | cat = nil | |||
|
173 | shellout(cmd) do |io| | |||
|
174 | io.binmode | |||
|
175 | cat = io.read | |||
|
176 | end | |||
|
177 | return nil if $? && $?.exitstatus != 0 | |||
|
178 | cat | |||
|
179 | rescue Errno::ENOENT => e | |||
|
180 | raise CommandFailed | |||
|
181 | end | |||
|
182 | ||||
|
183 | def annotate(path, identifier=nil) | |||
|
184 | cmd = "#{BZR_BIN} annotate --all" | |||
|
185 | cmd << " -r#{identifier.to_i}" if identifier && identifier.to_i > 0 | |||
|
186 | cmd << " #{target(path)}" | |||
|
187 | blame = Annotate.new | |||
|
188 | shellout(cmd) do |io| | |||
|
189 | author = nil | |||
|
190 | identifier = nil | |||
|
191 | io.each_line do |line| | |||
|
192 | next unless line =~ %r{^(\d+) ([^|]+)\| (.*)$} | |||
|
193 | blame.add_line($3.rstrip, Revision.new(:identifier => $1.to_i, :author => $2.strip)) | |||
|
194 | end | |||
|
195 | end | |||
|
196 | return nil if $? && $?.exitstatus != 0 | |||
|
197 | blame | |||
|
198 | rescue Errno::ENOENT => e | |||
|
199 | raise CommandFailed | |||
|
200 | end | |||
|
201 | end | |||
|
202 | end | |||
|
203 | end | |||
|
204 | end |
@@ -1,83 +1,87 | |||||
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 to_utf8(str) |
|
28 | def to_utf8(str) | |
29 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii |
|
29 | return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii | |
30 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) |
|
30 | @encodings ||= Setting.repositories_encodings.split(',').collect(&:strip) | |
31 | @encodings.each do |encoding| |
|
31 | @encodings.each do |encoding| | |
32 | begin |
|
32 | begin | |
33 | return Iconv.conv('UTF-8', encoding, str) |
|
33 | return Iconv.conv('UTF-8', encoding, str) | |
34 | rescue Iconv::Failure |
|
34 | rescue Iconv::Failure | |
35 | # do nothing here and try the next encoding |
|
35 | # do nothing here and try the next encoding | |
36 | end |
|
36 | end | |
37 | end |
|
37 | end | |
38 | str |
|
38 | str | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def repository_field_tags(form, repository) |
|
41 | def repository_field_tags(form, repository) | |
42 | method = repository.class.name.demodulize.underscore + "_field_tags" |
|
42 | method = repository.class.name.demodulize.underscore + "_field_tags" | |
43 | send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) |
|
43 | send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def scm_select_tag(repository) |
|
46 | def scm_select_tag(repository) | |
47 | container = [[]] |
|
47 | container = [[]] | |
48 | REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} |
|
48 | REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]} | |
49 | select_tag('repository_scm', |
|
49 | select_tag('repository_scm', | |
50 | options_for_select(container, repository.class.name.demodulize), |
|
50 | options_for_select(container, repository.class.name.demodulize), | |
51 | :disabled => (repository && !repository.new_record?), |
|
51 | :disabled => (repository && !repository.new_record?), | |
52 | :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") |
|
52 | :onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)") | |
53 | ) |
|
53 | ) | |
54 | end |
|
54 | end | |
55 |
|
55 | |||
56 | def with_leading_slash(path) |
|
56 | def with_leading_slash(path) | |
57 | path ||= '' |
|
57 | path ||= '' | |
58 | path.starts_with?("/") ? "/#{path}" : path |
|
58 | path.starts_with?("/") ? "/#{path}" : path | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def subversion_field_tags(form, repository) |
|
61 | def subversion_field_tags(form, repository) | |
62 | content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) + |
|
62 | content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) + | |
63 | '<br />(http://, https://, svn://, file:///)') + |
|
63 | '<br />(http://, https://, svn://, file:///)') + | |
64 | content_tag('p', form.text_field(:login, :size => 30)) + |
|
64 | content_tag('p', form.text_field(:login, :size => 30)) + | |
65 | content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', |
|
65 | content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', | |
66 | :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), |
|
66 | :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), | |
67 | :onfocus => "this.value=''; this.name='repository[password]';", |
|
67 | :onfocus => "this.value=''; this.name='repository[password]';", | |
68 | :onchange => "this.name='repository[password]';")) |
|
68 | :onchange => "this.name='repository[password]';")) | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def darcs_field_tags(form, repository) |
|
71 | def darcs_field_tags(form, repository) | |
72 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) |
|
72 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def mercurial_field_tags(form, repository) |
|
75 | def mercurial_field_tags(form, repository) | |
76 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) |
|
76 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?))) | |
77 | end |
|
77 | end | |
78 |
|
78 | |||
79 | def cvs_field_tags(form, repository) |
|
79 | def cvs_field_tags(form, repository) | |
80 | content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + |
|
80 | content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) + | |
81 | content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) |
|
81 | content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?)) | |
82 | end |
|
82 | end | |
|
83 | ||||
|
84 | def bazaar_field_tags(form, repository) | |||
|
85 | content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?))) | |||
|
86 | end | |||
83 | end |
|
87 | end |
@@ -1,18 +1,18 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <% form_tag do %> |
|
2 | <% form_tag({:action => 'revision', :id => @project}) do %> | |
3 |
|
|
3 | <%= l(:label_revision) %>: <%= text_field_tag 'rev', @rev, :size => 5 %> | |
4 |
<%= submit_tag 'OK' %> |
|
4 | <%= submit_tag 'OK' %> | |
5 | <% end %> |
|
5 | <% end %> | |
6 | </div> |
|
6 | </div> | |
7 |
|
7 | |||
8 | <h2><%= l(:label_revision_plural) %></h2> |
|
8 | <h2><%= l(:label_revision_plural) %></h2> | |
9 |
|
9 | |||
10 | <%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%> |
|
10 | <%= render :partial => 'revisions', :locals => {:project => @project, :path => '', :revisions => @changesets, :entry => nil }%> | |
11 |
|
11 | |||
12 | <p><%= pagination_links_full @changeset_pages %> |
|
12 | <p><%= pagination_links_full @changeset_pages %> | |
13 | [ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]</p> |
|
13 | [ <%= @changeset_pages.current.first_item %> - <%= @changeset_pages.current.last_item %> / <%= @changeset_count %> ]</p> | |
14 |
|
14 | |||
15 | <% content_for :header_tags do %> |
|
15 | <% content_for :header_tags do %> | |
16 | <%= stylesheet_link_tag "scm" %> |
|
16 | <%= stylesheet_link_tag "scm" %> | |
17 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> |
|
17 | <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> | |
18 | <% end %> |
|
18 | <% end %> |
@@ -1,105 +1,105 | |||||
1 | require 'redmine/access_control' |
|
1 | require 'redmine/access_control' | |
2 | require 'redmine/menu_manager' |
|
2 | require 'redmine/menu_manager' | |
3 | require 'redmine/mime_type' |
|
3 | require 'redmine/mime_type' | |
4 | require 'redmine/themes' |
|
4 | require 'redmine/themes' | |
5 | require 'redmine/plugin' |
|
5 | require 'redmine/plugin' | |
6 |
|
6 | |||
7 | begin |
|
7 | begin | |
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
8 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) | |
9 | rescue LoadError |
|
9 | rescue LoadError | |
10 | # RMagick is not available |
|
10 | # RMagick is not available | |
11 | end |
|
11 | end | |
12 |
|
12 | |||
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs ) |
|
13 | REDMINE_SUPPORTED_SCM = %w( Subversion Darcs Mercurial Cvs Bazaar ) | |
14 |
|
14 | |||
15 | # Permissions |
|
15 | # Permissions | |
16 | Redmine::AccessControl.map do |map| |
|
16 | Redmine::AccessControl.map do |map| | |
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true |
|
17 | map.permission :view_project, {:projects => [:show, :activity]}, :public => true | |
18 | map.permission :search_project, {:search => :index}, :public => true |
|
18 | map.permission :search_project, {:search => :index}, :public => true | |
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member |
|
19 | map.permission :edit_project, {:projects => [:settings, :edit]}, :require => :member | |
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
20 | map.permission :select_project_modules, {:projects => :modules}, :require => :member | |
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member |
|
21 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy]}, :require => :member | |
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member |
|
22 | map.permission :manage_versions, {:projects => [:settings, :add_version], :versions => [:edit, :destroy]}, :require => :member | |
23 |
|
23 | |||
24 | map.project_module :issue_tracking do |map| |
|
24 | map.project_module :issue_tracking do |map| | |
25 | # Issue categories |
|
25 | # Issue categories | |
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member |
|
26 | map.permission :manage_categories, {:projects => [:settings, :add_issue_category], :issue_categories => [:edit, :destroy]}, :require => :member | |
27 | # Issues |
|
27 | # Issues | |
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], |
|
28 | map.permission :view_issues, {:projects => [:changelog, :roadmap], | |
29 | :issues => [:index, :changes, :show, :context_menu], |
|
29 | :issues => [:index, :changes, :show, :context_menu], | |
30 | :queries => :index, |
|
30 | :queries => :index, | |
31 | :reports => :issue_report}, :public => true |
|
31 | :reports => :issue_report}, :public => true | |
32 | map.permission :add_issues, {:projects => :add_issue} |
|
32 | map.permission :add_issues, {:projects => :add_issue} | |
33 | map.permission :edit_issues, {:projects => :bulk_edit_issues, |
|
33 | map.permission :edit_issues, {:projects => :bulk_edit_issues, | |
34 | :issues => [:edit, :destroy_attachment]} |
|
34 | :issues => [:edit, :destroy_attachment]} | |
35 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
|
35 | map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} | |
36 | map.permission :add_issue_notes, {:issues => :add_note} |
|
36 | map.permission :add_issue_notes, {:issues => :add_note} | |
37 | map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin |
|
37 | map.permission :change_issue_status, {:issues => :change_status}, :require => :loggedin | |
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin |
|
38 | map.permission :move_issues, {:projects => :move_issues}, :require => :loggedin | |
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
39 | map.permission :delete_issues, {:issues => :destroy}, :require => :member | |
40 | # Queries |
|
40 | # Queries | |
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member |
|
41 | map.permission :manage_public_queries, {:queries => [:new, :edit, :destroy]}, :require => :member | |
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin |
|
42 | map.permission :save_queries, {:queries => [:new, :edit, :destroy]}, :require => :loggedin | |
43 | # Gantt & calendar |
|
43 | # Gantt & calendar | |
44 | map.permission :view_gantt, :projects => :gantt |
|
44 | map.permission :view_gantt, :projects => :gantt | |
45 | map.permission :view_calendar, :projects => :calendar |
|
45 | map.permission :view_calendar, :projects => :calendar | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | map.project_module :time_tracking do |map| |
|
48 | map.project_module :time_tracking do |map| | |
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin |
|
49 | map.permission :log_time, {:timelog => :edit}, :require => :loggedin | |
50 | map.permission :view_time_entries, :timelog => [:details, :report] |
|
50 | map.permission :view_time_entries, :timelog => [:details, :report] | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
53 | map.project_module :news do |map| |
|
53 | map.project_module :news do |map| | |
54 | map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member |
|
54 | map.permission :manage_news, {:projects => :add_news, :news => [:edit, :destroy, :destroy_comment]}, :require => :member | |
55 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
55 | map.permission :view_news, {:news => [:index, :show]}, :public => true | |
56 | map.permission :comment_news, {:news => :add_comment} |
|
56 | map.permission :comment_news, {:news => :add_comment} | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
59 | map.project_module :documents do |map| |
|
59 | map.project_module :documents do |map| | |
60 | map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin |
|
60 | map.permission :manage_documents, {:projects => :add_document, :documents => [:edit, :destroy, :add_attachment, :destroy_attachment]}, :require => :loggedin | |
61 | map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] |
|
61 | map.permission :view_documents, :projects => :list_documents, :documents => [:show, :download] | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | map.project_module :files do |map| |
|
64 | map.project_module :files do |map| | |
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin |
|
65 | map.permission :manage_files, {:projects => :add_file, :versions => :destroy_file}, :require => :loggedin | |
66 | map.permission :view_files, :projects => :list_files, :versions => :download |
|
66 | map.permission :view_files, :projects => :list_files, :versions => :download | |
67 | end |
|
67 | end | |
68 |
|
68 | |||
69 | map.project_module :wiki do |map| |
|
69 | map.project_module :wiki do |map| | |
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
70 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member | |
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
71 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member | |
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
72 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member | |
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] |
|
73 | map.permission :view_wiki_pages, :wiki => [:index, :history, :diff, :special] | |
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] |
|
74 | map.permission :edit_wiki_pages, :wiki => [:edit, :preview, :add_attachment, :destroy_attachment] | |
75 | end |
|
75 | end | |
76 |
|
76 | |||
77 | map.project_module :repository do |map| |
|
77 | map.project_module :repository do |map| | |
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member |
|
78 | map.permission :manage_repository, {:repositories => [:edit, :destroy]}, :require => :member | |
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
79 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] | |
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
80 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] | |
81 | end |
|
81 | end | |
82 |
|
82 | |||
83 | map.project_module :boards do |map| |
|
83 | map.project_module :boards do |map| | |
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
84 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member | |
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
85 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true | |
86 | map.permission :add_messages, {:messages => [:new, :reply]} |
|
86 | map.permission :add_messages, {:messages => [:new, :reply]} | |
87 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
87 | map.permission :edit_messages, {:messages => :edit}, :require => :member | |
88 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
88 | map.permission :delete_messages, {:messages => :destroy}, :require => :member | |
89 | end |
|
89 | end | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
92 | # Project menu configuration |
|
92 | # Project menu configuration | |
93 | Redmine::MenuManager.map :project_menu do |menu| |
|
93 | Redmine::MenuManager.map :project_menu do |menu| | |
94 | menu.push :label_overview, :controller => 'projects', :action => 'show' |
|
94 | menu.push :label_overview, :controller => 'projects', :action => 'show' | |
95 | menu.push :label_activity, :controller => 'projects', :action => 'activity' |
|
95 | menu.push :label_activity, :controller => 'projects', :action => 'activity' | |
96 | menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap' |
|
96 | menu.push :label_roadmap, :controller => 'projects', :action => 'roadmap' | |
97 | menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id |
|
97 | menu.push :label_issue_plural, { :controller => 'issues', :action => 'index' }, :param => :project_id | |
98 | menu.push :label_news_plural, { :controller => 'news', :action => 'index' }, :param => :project_id |
|
98 | menu.push :label_news_plural, { :controller => 'news', :action => 'index' }, :param => :project_id | |
99 | menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents' |
|
99 | menu.push :label_document_plural, :controller => 'projects', :action => 'list_documents' | |
100 | menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
100 | menu.push :label_wiki, { :controller => 'wiki', :action => 'index', :page => nil }, :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } | |
101 | menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? } |
|
101 | menu.push :label_board_plural, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, :if => Proc.new { |p| p.boards.any? } | |
102 | menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files' |
|
102 | menu.push :label_attachment_plural, :controller => 'projects', :action => 'list_files' | |
103 | menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
103 | menu.push :label_repository, { :controller => 'repositories', :action => 'show' }, :if => Proc.new { |p| p.repository && !p.repository.new_record? } | |
104 | menu.push :label_settings, :controller => 'projects', :action => 'settings' |
|
104 | menu.push :label_settings, :controller => 'projects', :action => 'settings' | |
105 | end |
|
105 | end |
General Comments 0
You need to be logged in to leave comments.
Login now