scm: code clean up repositories_helper.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4990 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-03-03 03:30:10 +00:00
parent c3e8fc5f1a
commit bc09628249
1 changed files with 12 additions and 11 deletions

View File

@ -25,13 +25,13 @@ module RepositoriesHelper
revision.to_s revision.to_s
end end
end end
def truncate_at_line_break(text, length = 255) def truncate_at_line_break(text, length = 255)
if text if text
text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...') text.gsub(%r{^(.{#{length}}[^\n]*)\n.+$}m, '\\1...')
end end
end end
def render_properties(properties) def render_properties(properties)
unless properties.nil? || properties.empty? unless properties.nil? || properties.empty?
content = '' content = ''
@ -41,7 +41,7 @@ module RepositoriesHelper
content_tag('ul', content, :class => 'properties') content_tag('ul', content, :class => 'properties')
end end
end end
def render_changeset_changes def render_changeset_changes
changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change| changes = @changeset.changes.find(:all, :limit => 1000, :order => 'path').collect do |change|
case change.action case change.action
@ -75,10 +75,10 @@ module RepositoriesHelper
render_changes_tree(tree[:s]) render_changes_tree(tree[:s])
end end
def render_changes_tree(tree) def render_changes_tree(tree)
return '' if tree.nil? return '' if tree.nil?
output = '' output = ''
output << '<ul>' output << '<ul>'
tree.keys.sort.each do |file| tree.keys.sort.each do |file|
@ -115,14 +115,14 @@ module RepositoriesHelper
output << '</ul>' output << '</ul>'
output output
end end
def to_utf8(str) def to_utf8(str)
return str if str.blank? return str if str.blank?
if str.respond_to?(:force_encoding) if str.respond_to?(:force_encoding)
str.force_encoding('UTF-8') str.force_encoding('UTF-8')
else else
# TODO: # TODO:
# Japanese Shift_JIS(CP932) is not compatible with ASCII. # Japanese Shift_JIS(CP932) is not compatible with ASCII.
# UTF-7 and Japanese ISO-2022-JP are 7bits clean. # UTF-7 and Japanese ISO-2022-JP are 7bits clean.
return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii return str if /\A[\r\n\t\x20-\x7e]*\Z/n.match(str) # for us-ascii
end end
@ -192,10 +192,11 @@ module RepositoriesHelper
:disabled => (repository && !repository.root_url.blank?)) + :disabled => (repository && !repository.root_url.blank?)) +
'<br />(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') + '<br />(file:///, http://, https://, svn://, svn+[tunnelscheme]://)') +
content_tag('p', form.text_field(:login, :size => 30)) + content_tag('p', form.text_field(:login, :size => 30)) +
content_tag('p', form.password_field(:password, :size => 30, :name => 'ignore', content_tag('p', form.password_field(
:value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)), :password, :size => 30, :name => 'ignore',
:onfocus => "this.value=''; this.name='repository[password]';", :value => ((repository.new_record? || repository.password.blank?) ? '' : ('x'*15)),
:onchange => "this.name='repository[password]';")) :onfocus => "this.value=''; this.name='repository[password]';",
:onchange => "this.name='repository[password]';"))
end end
def darcs_field_tags(form, repository) def darcs_field_tags(form, repository)