remove trailing white-spaces from application helper source.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5832 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fb41e3dab4
commit
c42fdcd26a
@ -63,7 +63,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Displays a link to +issue+ with its subject.
|
# Displays a link to +issue+ with its subject.
|
||||||
# Examples:
|
# Examples:
|
||||||
#
|
#
|
||||||
# link_to_issue(issue) # => Defect #6: This is the subject
|
# link_to_issue(issue) # => Defect #6: This is the subject
|
||||||
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
|
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
|
||||||
# link_to_issue(issue, :subject => false) # => Defect #6
|
# link_to_issue(issue, :subject => false) # => Defect #6
|
||||||
@ -80,7 +80,7 @@ module ApplicationHelper
|
|||||||
subject = truncate(subject, :length => options[:truncate])
|
subject = truncate(subject, :length => options[:truncate])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
|
s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
|
||||||
:class => issue.css_classes,
|
:class => issue.css_classes,
|
||||||
:title => title
|
:title => title
|
||||||
s << ": #{h subject}" if subject
|
s << ": #{h subject}" if subject
|
||||||
@ -109,7 +109,7 @@ module ApplicationHelper
|
|||||||
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
link_to(text, {:controller => 'repositories', :action => 'revision', :id => project, :rev => rev},
|
||||||
:title => l(:label_revision_id, format_revision(revision)))
|
:title => l(:label_revision_id, format_revision(revision)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a link to a message
|
# Generates a link to a message
|
||||||
def link_to_message(message, options={}, html_options = nil)
|
def link_to_message(message, options={}, html_options = nil)
|
||||||
link_to(
|
link_to(
|
||||||
@ -126,7 +126,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Generates a link to a project if active
|
# Generates a link to a project if active
|
||||||
# Examples:
|
# Examples:
|
||||||
#
|
#
|
||||||
# link_to_project(project) # => link to the specified project overview
|
# link_to_project(project) # => link to the specified project overview
|
||||||
# link_to_project(project, :action=>'settings') # => link to project settings
|
# link_to_project(project, :action=>'settings') # => link to project settings
|
||||||
# link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options
|
# link_to_project(project, {:only_path => false}, :class => "project") # => 3rd arg adds html options
|
||||||
@ -160,15 +160,15 @@ module ApplicationHelper
|
|||||||
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
|
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
|
||||||
link_to name, {}, html_options
|
link_to name, {}, html_options
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_title(text)
|
def format_activity_title(text)
|
||||||
h(truncate_single_line(text, :length => 100))
|
h(truncate_single_line(text, :length => 100))
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_day(date)
|
def format_activity_day(date)
|
||||||
date == Date.today ? l(:label_today).titleize : format_date(date)
|
date == Date.today ? l(:label_today).titleize : format_date(date)
|
||||||
end
|
end
|
||||||
|
|
||||||
def format_activity_description(text)
|
def format_activity_description(text)
|
||||||
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
|
h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')).gsub(/[\r\n]+/, "<br />")
|
||||||
end
|
end
|
||||||
@ -180,7 +180,7 @@ module ApplicationHelper
|
|||||||
h("#{version.project} - #{version}")
|
h("#{version.project} - #{version}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def due_date_distance_in_words(date)
|
def due_date_distance_in_words(date)
|
||||||
if date
|
if date
|
||||||
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
|
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
|
||||||
@ -202,7 +202,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
content
|
content
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders flash messages
|
# Renders flash messages
|
||||||
def render_flash_messages
|
def render_flash_messages
|
||||||
s = ''
|
s = ''
|
||||||
@ -211,7 +211,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders tabs and their content
|
# Renders tabs and their content
|
||||||
def render_tabs(tabs)
|
def render_tabs(tabs)
|
||||||
if tabs.any?
|
if tabs.any?
|
||||||
@ -220,7 +220,7 @@ module ApplicationHelper
|
|||||||
content_tag 'p', l(:label_no_data), :class => "nodata"
|
content_tag 'p', l(:label_no_data), :class => "nodata"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders the project quick-jump box
|
# Renders the project quick-jump box
|
||||||
def render_project_jump_box
|
def render_project_jump_box
|
||||||
return unless User.current.logged?
|
return unless User.current.logged?
|
||||||
@ -236,7 +236,7 @@ module ApplicationHelper
|
|||||||
s
|
s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_tree_options_for_select(projects, options = {})
|
def project_tree_options_for_select(projects, options = {})
|
||||||
s = ''
|
s = ''
|
||||||
project_tree(projects) do |project, level|
|
project_tree(projects) do |project, level|
|
||||||
@ -252,14 +252,14 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Yields the given block for each project with its level in the tree
|
# Yields the given block for each project with its level in the tree
|
||||||
#
|
#
|
||||||
# Wrapper for Project#project_tree
|
# Wrapper for Project#project_tree
|
||||||
def project_tree(projects, &block)
|
def project_tree(projects, &block)
|
||||||
Project.project_tree(projects, &block)
|
Project.project_tree(projects, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_nested_ul(projects, &block)
|
def project_nested_ul(projects, &block)
|
||||||
s = ''
|
s = ''
|
||||||
if projects.any?
|
if projects.any?
|
||||||
@ -270,7 +270,7 @@ module ApplicationHelper
|
|||||||
else
|
else
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</li>"
|
s << "</li>"
|
||||||
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
|
||||||
ancestors.pop
|
ancestors.pop
|
||||||
s << "</ul></li>\n"
|
s << "</ul></li>\n"
|
||||||
end
|
end
|
||||||
@ -283,20 +283,20 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
def principals_check_box_tags(name, principals)
|
def principals_check_box_tags(name, principals)
|
||||||
s = ''
|
s = ''
|
||||||
principals.sort.each do |principal|
|
principals.sort.each do |principal|
|
||||||
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
|
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
|
||||||
end
|
end
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncates and returns the string as a single line
|
# Truncates and returns the string as a single line
|
||||||
def truncate_single_line(string, *args)
|
def truncate_single_line(string, *args)
|
||||||
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Truncates at line break after 250 characters or options[:length]
|
# Truncates at line break after 250 characters or options[:length]
|
||||||
def truncate_lines(string, options={})
|
def truncate_lines(string, options={})
|
||||||
length = options[:length] || 250
|
length = options[:length] || 250
|
||||||
@ -314,7 +314,7 @@ module ApplicationHelper
|
|||||||
def authoring(created, author, options={})
|
def authoring(created, author, options={})
|
||||||
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created))
|
l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created))
|
||||||
end
|
end
|
||||||
|
|
||||||
def time_tag(time)
|
def time_tag(time)
|
||||||
text = distance_of_time_in_words(Time.now, time)
|
text = distance_of_time_in_words(Time.now, time)
|
||||||
if @project
|
if @project
|
||||||
@ -345,7 +345,7 @@ module ApplicationHelper
|
|||||||
html << (pagination_links_each(paginator, options) do |n|
|
html << (pagination_links_each(paginator, options) do |n|
|
||||||
link_to_content_update(n.to_s, url_param.merge(page_param => n))
|
link_to_content_update(n.to_s, url_param.merge(page_param => n))
|
||||||
end || '')
|
end || '')
|
||||||
|
|
||||||
if paginator.current.next
|
if paginator.current.next
|
||||||
html << ' ' + link_to_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
html << ' ' + link_to_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next))
|
||||||
end
|
end
|
||||||
@ -359,14 +359,14 @@ module ApplicationHelper
|
|||||||
|
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
def per_page_links(selected=nil)
|
def per_page_links(selected=nil)
|
||||||
links = Setting.per_page_options_array.collect do |n|
|
links = Setting.per_page_options_array.collect do |n|
|
||||||
n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
|
n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
|
||||||
end
|
end
|
||||||
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
|
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def reorder_links(name, url)
|
def reorder_links(name, url)
|
||||||
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
|
link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)), url.merge({"#{name}[move_to]" => 'highest'}), :method => :post, :title => l(:label_sort_highest)) +
|
||||||
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
|
link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)), url.merge({"#{name}[move_to]" => 'higher'}), :method => :post, :title => l(:label_sort_higher)) +
|
||||||
@ -378,13 +378,13 @@ module ApplicationHelper
|
|||||||
elements = args.flatten
|
elements = args.flatten
|
||||||
elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil
|
elements.any? ? content_tag('p', args.join(' » ') + ' » ', :class => 'breadcrumb') : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def other_formats_links(&block)
|
def other_formats_links(&block)
|
||||||
concat('<p class="other-formats">' + l(:label_export_to))
|
concat('<p class="other-formats">' + l(:label_export_to))
|
||||||
yield Redmine::Views::OtherFormatsBuilder.new(self)
|
yield Redmine::Views::OtherFormatsBuilder.new(self)
|
||||||
concat('</p>')
|
concat('</p>')
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_header_title
|
def page_header_title
|
||||||
if @project.nil? || @project.new_record?
|
if @project.nil? || @project.new_record?
|
||||||
h(Setting.app_title)
|
h(Setting.app_title)
|
||||||
@ -457,21 +457,21 @@ module ApplicationHelper
|
|||||||
only_path = options.delete(:only_path) == false ? false : true
|
only_path = options.delete(:only_path) == false ? false : true
|
||||||
|
|
||||||
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
|
text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr) { |macro, args| exec_macro(macro, obj, args) }
|
||||||
|
|
||||||
@parsed_headings = []
|
@parsed_headings = []
|
||||||
text = parse_non_pre_blocks(text) do |text|
|
text = parse_non_pre_blocks(text) do |text|
|
||||||
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_headings].each do |method_name|
|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_headings].each do |method_name|
|
||||||
send method_name, text, project, obj, attr, only_path, options
|
send method_name, text, project, obj, attr, only_path, options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @parsed_headings.any?
|
if @parsed_headings.any?
|
||||||
replace_toc(text, @parsed_headings)
|
replace_toc(text, @parsed_headings)
|
||||||
end
|
end
|
||||||
|
|
||||||
text
|
text
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_non_pre_blocks(text)
|
def parse_non_pre_blocks(text)
|
||||||
s = StringScanner.new(text)
|
s = StringScanner.new(text)
|
||||||
tags = []
|
tags = []
|
||||||
@ -500,13 +500,13 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
parsed
|
parsed
|
||||||
end
|
end
|
||||||
|
|
||||||
def parse_inline_attachments(text, project, obj, attr, only_path, options)
|
def parse_inline_attachments(text, project, obj, attr, only_path, options)
|
||||||
# when using an image link, try to use an attachment, if possible
|
# when using an image link, try to use an attachment, if possible
|
||||||
if options[:attachments] || (obj && obj.respond_to?(:attachments))
|
if options[:attachments] || (obj && obj.respond_to?(:attachments))
|
||||||
attachments = nil
|
attachments = nil
|
||||||
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
|
||||||
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
filename, ext, alt, alttext = $1.downcase, $2, $3, $4
|
||||||
attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse
|
attachments ||= (options[:attachments] || obj.attachments).sort_by(&:created_on).reverse
|
||||||
# search for the picture in attachments
|
# search for the picture in attachments
|
||||||
if found = attachments.detect { |att| att.filename.downcase == filename }
|
if found = attachments.detect { |att| att.filename.downcase == filename }
|
||||||
@ -569,7 +569,7 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Redmine links
|
# Redmine links
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
@ -692,14 +692,14 @@ module ApplicationHelper
|
|||||||
leading + (link || "#{project_prefix}#{prefix}#{sep}#{identifier}")
|
leading + (link || "#{project_prefix}#{prefix}#{sep}#{identifier}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
HEADING_RE = /<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>/i unless const_defined?(:HEADING_RE)
|
HEADING_RE = /<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>/i unless const_defined?(:HEADING_RE)
|
||||||
|
|
||||||
# Headings and TOC
|
# Headings and TOC
|
||||||
# Adds ids and links to headings unless options[:headings] is set to false
|
# Adds ids and links to headings unless options[:headings] is set to false
|
||||||
def parse_headings(text, project, obj, attr, only_path, options)
|
def parse_headings(text, project, obj, attr, only_path, options)
|
||||||
return if options[:headings] == false
|
return if options[:headings] == false
|
||||||
|
|
||||||
text.gsub!(HEADING_RE) do
|
text.gsub!(HEADING_RE) do
|
||||||
level, attrs, content = $1.to_i, $2, $3
|
level, attrs, content = $1.to_i, $2, $3
|
||||||
item = strip_tags(content).strip
|
item = strip_tags(content).strip
|
||||||
@ -708,9 +708,9 @@ module ApplicationHelper
|
|||||||
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">¶</a></h#{level}>"
|
"<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">¶</a></h#{level}>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
|
TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
|
||||||
|
|
||||||
# Renders the TOC with given headings
|
# Renders the TOC with given headings
|
||||||
def replace_toc(text, headings)
|
def replace_toc(text, headings)
|
||||||
text.gsub!(TOC_RE) do
|
text.gsub!(TOC_RE) do
|
||||||
@ -793,13 +793,13 @@ module ApplicationHelper
|
|||||||
), :class => 'progress', :style => "width: #{width};") +
|
), :class => 'progress', :style => "width: #{width};") +
|
||||||
content_tag('p', legend, :class => 'pourcent')
|
content_tag('p', legend, :class => 'pourcent')
|
||||||
end
|
end
|
||||||
|
|
||||||
def checked_image(checked=true)
|
def checked_image(checked=true)
|
||||||
if checked
|
if checked
|
||||||
image_tag 'toggle_check.png'
|
image_tag 'toggle_check.png'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_menu(url)
|
def context_menu(url)
|
||||||
unless @context_menu_included
|
unless @context_menu_included
|
||||||
content_for :header_tags do
|
content_for :header_tags do
|
||||||
@ -852,10 +852,10 @@ module ApplicationHelper
|
|||||||
else
|
else
|
||||||
'' # use language
|
'' # use language
|
||||||
end
|
end
|
||||||
|
|
||||||
javascript_include_tag('calendar/calendar') +
|
javascript_include_tag('calendar/calendar') +
|
||||||
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
|
javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
|
||||||
javascript_tag(start_of_week) +
|
javascript_tag(start_of_week) +
|
||||||
javascript_include_tag('calendar/calendar-setup') +
|
javascript_include_tag('calendar/calendar-setup') +
|
||||||
stylesheet_link_tag('calendar')
|
stylesheet_link_tag('calendar')
|
||||||
end
|
end
|
||||||
@ -888,7 +888,7 @@ module ApplicationHelper
|
|||||||
''
|
''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the javascript tags that are included in the html layout head
|
# Returns the javascript tags that are included in the html layout head
|
||||||
def javascript_heads
|
def javascript_heads
|
||||||
tags = javascript_include_tag(:defaults)
|
tags = javascript_include_tag(:defaults)
|
||||||
@ -905,7 +905,7 @@ module ApplicationHelper
|
|||||||
def robot_exclusion_tag
|
def robot_exclusion_tag
|
||||||
'<meta name="robots" content="noindex,follow,noarchive" />'
|
'<meta name="robots" content="noindex,follow,noarchive" />'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns true if arg is expected in the API response
|
# Returns true if arg is expected in the API response
|
||||||
def include_in_api_response?(arg)
|
def include_in_api_response?(arg)
|
||||||
unless @included_in_api_response
|
unless @included_in_api_response
|
||||||
@ -927,7 +927,7 @@ module ApplicationHelper
|
|||||||
options
|
options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def wiki_helper
|
def wiki_helper
|
||||||
@ -935,7 +935,7 @@ module ApplicationHelper
|
|||||||
extend helper
|
extend helper
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
def link_to_content_update(text, url_params = {}, html_options = {})
|
def link_to_content_update(text, url_params = {}, html_options = {})
|
||||||
link_to(text, url_params, html_options)
|
link_to(text, url_params, html_options)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user