##// END OF EJS Templates
By default, only show statuses that are used by the tracker on the workflow edit view....
By default, only show statuses that are used by the tracker on the workflow edit view. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3188 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r2624:752e263d3a42
r3074:6bf0723d0654
Show More
repositories_helper.rb
182 lines | 7.1 KiB | text/x-ruby | RubyLexer
/ app / helpers / repositories_helper.rb
Jean-Philippe Lang
svn browser merged in trunk...
r103 # redMine - project management software
# Copyright (C) 2006 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Philippe Lang
Default encodings for repository files can now be set in application settings (Admin -> Settings -> Repositories encodings)....
r803 require 'iconv'
Jean-Philippe Lang
Added syntax highlightment for repository files (using CodeRay)....
r638
Jean-Philippe Lang
svn browser merged in trunk...
r103 module RepositoriesHelper
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 def format_revision(txt)
txt.to_s[0,8]
end
Jean-Philippe Lang
Truncate comments on changeset list....
r1898 def truncate_at_line_break(text, length = 255)
if text
text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...')
end
end
Jean-Philippe Lang
Display svn properties in the browser, svn >= 1.5.0 only (#1581)....
r1613 def render_properties(properties)
unless properties.nil? || properties.empty?
content = ''
properties.keys.sort.each do |property|
content << content_tag('li', "<b>#{h property}</b>: <span>#{h properties[property]}</span>")
end
content_tag('ul', content, :class => 'properties')
end
end
Jean-Philippe Lang
Render the commit changes list as a tree (#1896)....
r1868 def render_changeset_changes
changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change|
case change.action
when 'A'
# Detects moved/copied files
if !change.from_path.blank?
change.action = @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
end
change
when 'D'
@changeset.changes.detect {|c| c.from_path == change.path} ? nil : change
else
change
end
end.compact
tree = { }
changes.each do |change|
p = tree
dirs = change.path.to_s.split('/').select {|d| !d.blank?}
dirs.each do |dir|
p[:s] ||= {}
p = p[:s]
p[dir] ||= {}
p = p[dir]
end
p[:c] = change
end
render_changes_tree(tree[:s])
end
def render_changes_tree(tree)
return '' if tree.nil?
output = ''
output << '<ul>'
tree.keys.sort.each do |file|
s = !tree[file][:s].nil?
c = tree[file][:c]
style = 'change'
style << ' folder' if s
style << " change-#{c.action}" if c
text = h(file)
unless c.nil?
path_param = to_path_param(@repository.relative_path(c.path))
text = link_to(text, :controller => 'repositories',
:action => 'entry',
:id => @project,
:path => path_param,
:rev => @changeset.revision) unless s || c.action == 'D'
text << " - #{c.revision}" unless c.revision.blank?
text << ' (' + link_to('diff', :controller => 'repositories',
:action => 'diff',
:id => @project,
:path => path_param,
:rev => @changeset.revision) + ') ' if c.action == 'M'
text << ' ' + content_tag('span', c.from_path, :class => 'copied-from') unless c.from_path.blank?
end
output << "<li class='#{style}'>#{text}</li>"
output << render_changes_tree(tree[file][:s]) if s
end
output << '</ul>'
output
end
Jean-Philippe Lang
Default encodings for repository files can now be set in application settings (Admin -> Settings -> Repositories encodings)....
r803 def to_utf8(str)
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
@encodings ||= Setting.repositories_encodings.split(',').collect(&:strip)
@encodings.each do |encoding|
begin
return Iconv.conv('UTF-8', encoding, str)
rescue Iconv::Failure
# do nothing here and try the next encoding
end
end
str
end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def repository_field_tags(form, repository)
method = repository.class.name.demodulize.underscore + "_field_tags"
Jean-Philippe Lang
Prevent recursive calls to RepositoriesHelper#repository_field_tags (#3226)....
r2588 send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method) && method != 'repository_field_tags'
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Jean-Philippe Lang
Added project module concept....
r714 def scm_select_tag(repository)
Jean-Philippe Lang
Ability to disable unused SCM adapters in application settings....
r1493 scm_options = [["--- #{l(:actionview_instancetag_blank_option)} ---", '']]
REDMINE_SUPPORTED_SCM.each do |scm|
scm_options << ["Repository::#{scm}".constantize.scm_name, scm] if Setting.enabled_scm.include?(scm) || (repository && repository.class.name.demodulize == scm)
end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 select_tag('repository_scm',
Jean-Philippe Lang
Ability to disable unused SCM adapters in application settings....
r1493 options_for_select(scm_options, repository.class.name.demodulize),
Jean-Philippe Lang
Added project module concept....
r714 :disabled => (repository && !repository.new_record?),
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 )
end
def with_leading_slash(path)
Jean-Philippe Lang
Fixed: single file 'View difference' links do not work because of duplicate slashes in url....
r1310 path.to_s.starts_with?('/') ? path : "/#{path}"
end
def without_leading_slash(path)
path.gsub(%r{^/+}, '')
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
def subversion_field_tags(form, repository)
content_tag('p', form.text_field(:url, :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)) +
Jean-Philippe Lang
Accept any svn tunnel scheme in repository URL (#3278)....
r2624 '<br />(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 content_tag('p', form.text_field(:login, :size => 30)) +
Jean-Philippe Lang
Fixed: svn or ldap password can be found in clear text in the html source in editing mode....
r929 content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore',
:value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
:onfocus => "this.value=''; this.name='repository[password]';",
:onchange => "this.name='repository[password]';"))
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 end
Jean-Philippe Lang
Added Darcs basic support....
r570 def darcs_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def mercurial_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
end
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 def git_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Path to .git directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
end
Jean-Philippe Lang
Added basic support for CVS and Mercurial SCMs....
r556 def cvs_field_tags(form, repository)
content_tag('p', form.text_field(:root_url, :label => 'CVSROOT', :size => 60, :required => true, :disabled => !repository.new_record?)) +
content_tag('p', form.text_field(:url, :label => 'Module', :size => 30, :required => true, :disabled => !repository.new_record?))
end
Jean-Philippe Lang
Added Bazaar adapter....
r937
def bazaar_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.new_record?)))
end
Jean-Philippe Lang
Adds Filesystem adapter (patch #1393 by Paul R)....
r1494
def filesystem_field_tags(form, repository)
content_tag('p', form.text_field(:url, :label => 'Root directory', :size => 60, :required => true, :disabled => (repository && !repository.root_url.blank?)))
end
Jean-Philippe Lang
svn browser merged in trunk...
r103 end