##// END OF EJS Templates
replace Mailer deliver syntax to Rails3 style at reminders method of mailer model...
replace Mailer deliver syntax to Rails3 style at reminders method of mailer model git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9662 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9453:ba5a052c8ca8
r9479:804864beca1c
Show More
application_helper.rb
1195 lines | 44.5 KiB | text/x-ruby | RubyLexer
/ app / helpers / application_helper.rb
Toshi MARUYAMA
Ruby 1.9: add "encoding: utf-8" header at application_helper.rb...
r7683 # encoding: utf-8
#
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 # Redmine - project management software
Jean-Philippe Lang
Copyright update....
r9453 # Copyright (C) 2006-2012 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# 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.
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # 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.
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # 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
Makes wiki text formatter pluggable....
r1953 require 'forwardable'
Jean-Philippe Lang
Escape back_url field value (#2320)....
r2123 require 'cgi'
Jean-Philippe Lang
File viewer for attached text files....
r1506
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 module ApplicationHelper
Jean-Philippe Lang
Added wiki macros support. 2 builtin macros are defined: hello_world (sample macro that displays the arguments) and macro_list (display the list of installed macros)....
r884 include Redmine::WikiFormatting::Macros::Definitions
Jean-Philippe Lang
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 include Redmine::I18n
Jean-Philippe Lang
Changes ApplicationHelper#gravatar_for_mail to #avatar that takes a User or a String (less code in views)....
r1998 include GravatarHelper::PublicMethods
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953 extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # Return true if user is authorized for controller/action, otherwise false
Jean-Philippe Lang
Merged 0.6 branch into trunk....
r663 def authorize_for(controller, action)
User.current.allowed_to?({:controller => controller, :action => action}, @project)
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
# Display a link if user is authorized
Eric Davis
Change link_to_if_authorized to allow url paths. (Fixes #6195)...
r3950 #
# @param [String] name Anchor text (passed to link_to)
Eric Davis
Revert part of r4064....
r4143 # @param [Hash] options Hash params. This will checked by authorize_for to see if the user is authorized
Eric Davis
Change link_to_if_authorized to allow url paths. (Fixes #6195)...
r3950 # @param [optional, Hash] html_options Options passed to link_to
# @param [optional, Hash] parameters_for_method_reference Extra parameters for link_to
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
Eric Davis
Revert part of r4064....
r4143 link_to(name, options, html_options, *parameters_for_method_reference) if authorize_for(options[:controller] || params[:controller], options[:action])
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Adds posts quoting functionality (#1825)....
r1771 # Display a link to remote if user is authorized
def link_to_remote_if_authorized(name, options = {}, html_options = nil)
url = options[:url] || {}
link_to_remote(name, options, html_options) if authorize_for(url[:controller] || params[:controller], url[:action])
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Jean-Philippe Lang
Fixes ApplicationHelper#link_to_user...
r2910 # Displays a link to user's account page if active
Jean-Philippe Lang
Makes logged-in username in topbar linking to (#2291)....
r2107 def link_to_user(user, options={})
Jean-Philippe Lang
User groups branch merged....
r2755 if user.is_a?(User)
Jean-Philippe Lang
Fixes ApplicationHelper#link_to_user...
r2910 name = h(user.name(options[:format]))
if user.active?
link_to name, :controller => 'users', :action => 'show', :id => user
else
name
end
Jean-Philippe Lang
User groups branch merged....
r2755 else
Jean-Philippe Lang
Fixes ApplicationHelper#link_to_user...
r2910 h(user.to_s)
Jean-Philippe Lang
User groups branch merged....
r2755 end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 # Displays a link to +issue+ with its subject.
# Examples:
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712 #
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 # link_to_issue(issue) # => Defect #6: This is the subject
# link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
# link_to_issue(issue, :subject => false) # => Defect #6
Jean-Philippe Lang
Roadmap: sort issues by project and prepend project name if different (#4373)....
r3049 # link_to_issue(issue, :project => true) # => Foo - Defect #6
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 #
Jean-Philippe Lang
Add a time tracking block for 'My page' (#615)....
r1245 def link_to_issue(issue, options={})
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 title = nil
subject = nil
if options[:subject] == false
title = truncate(issue.subject, :length => 60)
else
subject = issue.subject
if options[:truncate]
subject = truncate(subject, :length => options[:truncate])
end
end
Toshi MARUYAMA
html_escape issue fields...
r6206 s = link_to "#{h(issue.tracker)} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 :class => issue.css_classes,
:title => title
Jean-Philippe Lang
Missing html_safe....
r8354 s << h(": #{subject}") if subject
s = h("#{issue.project} - ") + s if options[:project]
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 s
Jean-Philippe Lang
Added link_to_issue helper....
r428 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Appends the filename to the attachment url so that clients that ignore content-disposition http header get the real filename (#1649)....
r1669 # Generates a link to an attachment.
# Options:
# * :text - Link text (default to attachment filename)
# * :download - Force download (default: false)
def link_to_attachment(attachment, options={})
text = options.delete(:text) || attachment.filename
action = options.delete(:download) ? 'download' : 'show'
Toshi MARUYAMA
fix attachment link has get parameter :class (#10602)...
r9193 opt_only_path = {}
opt_only_path[:only_path] = (options[:only_path] == false ? false : true)
Toshi MARUYAMA
delete :only_path option from link_to options at application_helper link_to_attachment (#10602)...
r9194 options.delete(:only_path)
Toshi MARUYAMA
code layout clean up link_to_attachment of application helper...
r7736 link_to(h(text),
{:controller => 'attachments', :action => action,
Toshi MARUYAMA
fix attachment link has get parameter :class (#10602)...
r9193 :id => attachment, :filename => attachment.filename}.merge(opt_only_path),
Toshi MARUYAMA
code layout clean up link_to_attachment of application helper...
r7736 options)
Jean-Philippe Lang
Appends the filename to the attachment url so that clients that ignore content-disposition http header get the real filename (#1649)....
r1669 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Eric Davis
Added the revision title to any revision links....
r3102 # Generates a link to a SCM revision
# Options:
# * :text - Link text (default to the formatted revision)
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 def link_to_revision(revision, repository, options={})
if repository.is_a?(Project)
repository = repository.repository
end
Eric Davis
Added the revision title to any revision links....
r3102 text = options.delete(:text) || format_revision(revision)
Toshi MARUYAMA
Changing revision label and identifier at SCM adapter level (#3724, #6092)...
r4493 rev = revision.respond_to?(:identifier) ? revision.identifier : revision
Toshi MARUYAMA
code layout clean up application helper "link_to_revision" method...
r7913 link_to(
h(text),
Jean-Philippe Lang
Adds support for multiple repositories per project (#779)....
r8530 {:controller => 'repositories', :action => 'revision', :id => repository.project, :repository_id => repository.identifier_param, :rev => rev},
Toshi MARUYAMA
code layout clean up application helper "link_to_revision" method...
r7913 :title => l(:label_revision_id, format_revision(revision))
)
Eric Davis
Added the revision title to any revision links....
r3102 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Moves link_to_message to ApplicationHelper to make it available to redmine links....
r4640 # Generates a link to a message
def link_to_message(message, options={}, html_options = nil)
link_to(
h(truncate(message.subject, :length => 60)),
{ :controller => 'messages', :action => 'show',
:board_id => message.board_id,
:id => message.root,
:r => (message.parent_id && message.id),
:anchor => (message.parent_id ? "message-#{message.id}" : nil)
}.merge(options),
html_options
)
end
Eric Davis
Added the revision title to any revision links....
r3102
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 # Generates a link to a project if active
# Examples:
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712 #
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 # link_to_project(project) # => link to the specified project overview
# 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, {}, :class => "project") # => html options with default url (project overview)
#
def link_to_project(project, options={}, html_options = nil)
if project.active?
url = {:controller => 'projects', :action => 'show', :id => project}.merge(options)
link_to(h(project), url, html_options)
else
h(project)
end
end
Jean-Philippe Lang
Added toggle_link helper....
r429 def toggle_link(name, id, options={})
onclick = "Element.toggle('#{id}'); "
onclick << (options[:focus] ? "Form.Element.focus('#{options[:focus]}'); " : "this.blur(); ")
onclick << "return false;"
link_to(name, "#", :onclick => onclick)
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def image_to_function(name, function, html_options = {})
html_options.symbolize_keys!
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986 tag(:input, html_options.merge({
:type => "image", :src => image_path(name),
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 }))
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Added a link to add a new category when creating or editing an issue....
r642 def prompt_to_remote(name, text, param, url, html_options = {})
html_options[:onclick] = "promptToRemote('#{text}', '#{param}', '#{url_for(url)}'); return false;"
link_to name, {}, html_options
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 def format_activity_title(text)
Jean-Philippe Lang
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 h(truncate_single_line(text, :length => 100))
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 def format_activity_day(date)
date == Date.today ? l(:label_today).titleize : format_date(date)
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 def format_activity_description(text)
Toshi MARUYAMA
Rails3: helper: html_safe for "format_activity_description" method...
r7915 h(truncate(text.to_s, :length => 120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')
).gsub(/[\r\n]+/, "<br />").html_safe
Jean-Philippe Lang
Fixed: Roadmap crashes when a version has a due date > 2037....
r1885 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Version sharing (#465) + optional inclusion of subprojects in the roadmap view (#2666)....
r3009 def format_version_name(version)
if version.project == @project
h(version)
else
h("#{version.project} - #{version}")
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Fixed: Roadmap crashes when a version has a due date > 2037....
r1885 def due_date_distance_in_words(date)
if date
l((date < Date.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(Date.today, date))
end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Adds an option to #render_page_hierarchy to add timestamp titles....
r4979 def render_page_hierarchy(pages, node=nil, options={})
Jean-Philippe Lang
Extends child_pages macro to display child pages based on page parameter (#1975)....
r2051 content = ''
if pages[node]
content << "<ul class=\"pages-hierarchy\">\n"
pages[node].each do |page|
content << "<li>"
Eric Davis
Refactor: use :id instead of :page when linking to Wiki Pages...
r4182 content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title},
Jean-Philippe Lang
Adds an option to #render_page_hierarchy to add timestamp titles....
r4979 :title => (options[:timestamp] && page.updated_on ? l(:label_updated_time, distance_of_time_in_words(Time.now, page.updated_on)) : nil))
content << "\n" + render_page_hierarchy(pages, page.id, options) if pages[page.id]
Jean-Philippe Lang
Extends child_pages macro to display child pages based on page parameter (#1975)....
r2051 content << "</li>\n"
end
content << "</ul>\n"
end
Toshi MARUYAMA
Rails3: helper: use html_safe at render_page_hierarchy of ApplicationHelper...
r7464 content.html_safe
Jean-Philippe Lang
Extends child_pages macro to display child pages based on page parameter (#1975)....
r2051 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Moves flash messages rendering to a helper method....
r2221 # Renders flash messages
def render_flash_messages
s = ''
flash.each do |k,v|
Jean-Philippe Lang
Adds an id to the flash message divs (#9034)....
r9395 s << content_tag('div', v.html_safe, :class => "flash #{k}", :id => "flash_#{k}")
Jean-Philippe Lang
Moves flash messages rendering to a helper method....
r2221 end
Toshi MARUYAMA
Rails3: use String#html_safe for render_flash_messages() at ApplicationHelper....
r6356 s.html_safe
Jean-Philippe Lang
Moves flash messages rendering to a helper method....
r2221 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Refactoring of tabs rendering....
r2757 # Renders tabs and their content
def render_tabs(tabs)
if tabs.any?
render :partial => 'common/tabs', :locals => {:tabs => tabs}
else
content_tag 'p', l(:label_no_data), :class => "nodata"
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 # Renders the project quick-jump box
def render_project_jump_box
Jean-Philippe Lang
Skip memberships query for anonymous user....
r5338 return unless User.current.logged?
Jean-Philippe Lang
Saves an extra SQL query on each request....
r5033 projects = User.current.memberships.collect(&:project).compact.uniq
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 if projects.any?
s = '<select onchange="if (this.value != \'\') { window.location = this.value; }">' +
Jean-Philippe Lang
Sets the current project as the default value of project jump box (#4053)....
r2845 "<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
Jean-Philippe Lang
Fixes project shortcut combo....
r2802 '<option value="" disabled="disabled">---</option>'
Jean-Philippe Lang
Sets the current project as the default value of project jump box (#4053)....
r2845 s << project_tree_options_for_select(projects, :selected => @project) do |p|
Jean-Philippe Lang
Fixed that the project jump box does not preserve current tab after r2304....
r2310 { :value => url_for(:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item) }
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 end
s << '</select>'
Toshi MARUYAMA
Rails3: use String#html_safe for render_project_jump_box() at ApplicationHelper....
r6357 s.html_safe
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 def project_tree_options_for_select(projects, options = {})
s = ''
project_tree(projects) do |project, level|
Toshi MARUYAMA
Rails3: html_safe for project_tree_options_for_select method in application helper...
r8891 name_prefix = (level > 0 ? ('&nbsp;' * 2 * level + '&#187; ').html_safe : '')
Eric Davis
Allow multiple selected projects in #project_tree_options_for_select...
r3411 tag_options = {:value => project.id}
if project == options[:selected] || (options[:selected].respond_to?(:include?) && options[:selected].include?(project))
tag_options[:selected] = 'selected'
else
tag_options[:selected] = nil
end
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 tag_options.merge!(yield(project)) if block_given?
s << content_tag('option', name_prefix + h(project), tag_options)
end
Toshi MARUYAMA
Rails3: use String#html_safe for project_tree_options_for_select() at ApplicationHelper....
r6358 s.html_safe
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 # Yields the given block for each project with its level in the tree
Eric Davis
Refactor: move method to model with compatibility wrapper...
r4168 #
# Wrapper for Project#project_tree
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 def project_tree(projects, &block)
Eric Davis
Refactor: move method to model with compatibility wrapper...
r4168 Project.project_tree(projects, &block)
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds projects association on tracker form (#2578)....
r2333 def project_nested_ul(projects, &block)
s = ''
if projects.any?
ancestors = []
projects.sort_by(&:lft).each do |project|
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul>\n"
else
ancestors.pop
s << "</li>"
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712 while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
Jean-Philippe Lang
Adds projects association on tracker form (#2578)....
r2333 ancestors.pop
s << "</ul></li>\n"
end
end
s << "<li>"
s << yield(project).to_s
ancestors << project
end
s << ("</li></ul>\n" * ancestors.size)
end
Toshi MARUYAMA
Rails3: use String#html_safe for project_nested_ul() at ApplicationHelper....
r6359 s.html_safe
Jean-Philippe Lang
Adds projects association on tracker form (#2578)....
r2333 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
User groups branch merged....
r2755 def principals_check_box_tags(name, principals)
s = ''
Jean-Philippe Lang
Sort the list of users to add to a group or project (#4150)....
r2890 principals.sort.each do |principal|
Jean-Philippe Lang
User groups branch merged....
r2755 s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
end
Toshi MARUYAMA
Rails3: use String#html_safe for principals_check_box_tags() at ApplicationHelper....
r6360 s.html_safe
Jean-Philippe Lang
User groups branch merged....
r2755 end
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper....
r6347
Jean-Philippe Lang
Adds a optgroup for groups in users/groups select tags....
r6187 # Returns a string for users/groups option tags
def principals_options_for_select(collection, selected=nil)
s = ''
Jean-Philippe Lang
Adds a <<me>> option at the top of the assignee drop-down (#1102)....
r8568 if collection.include?(User.current)
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 s << content_tag('option', "<< #{l(:label_me)} >>".html_safe, :value => User.current.id)
Jean-Philippe Lang
Adds a <<me>> option at the top of the assignee drop-down (#1102)....
r8568 end
Jean-Philippe Lang
Adds a optgroup for groups in users/groups select tags....
r6187 groups = ''
collection.sort.each do |element|
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected)
(element.is_a?(Group) ? groups : s) << %(<option value="#{element.id}"#{selected_attribute}>#{h element.name}</option>)
end
unless groups.empty?
s << %(<optgroup label="#{h(l(:label_group_plural))}">#{groups}</optgroup>)
end
Toshi MARUYAMA
Rails3: view: html_safe for principals_options_for_select in ApplicationHelper...
r9328 s.html_safe
Jean-Philippe Lang
Adds a optgroup for groups in users/groups select tags....
r6187 end
Jean-Philippe Lang
Extends child_pages macro to display child pages based on page parameter (#1975)....
r2051
Jean-Philippe Lang
Fixed: changesets titles should not be multiline in atom feeds (#1356)....
r1477 # Truncates and returns the string as a single line
def truncate_single_line(string, *args)
Jean-Philippe Lang
Fixed error on repository when there are no comments in a changeset (#4126)....
r2869 truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ')
Jean-Philippe Lang
Fixed: changesets titles should not be multiline in atom feeds (#1356)....
r1477 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds text formatting to documents index (#202)....
r3488 # Truncates at line break after 250 characters or options[:length]
def truncate_lines(string, options={})
length = options[:length] || 250
if string.to_s =~ /\A(.{#{length}}.*?)$/m
"#{$1}..."
else
string
end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Removes spaces in versions anchors....
r8440 def anchor(text)
text.to_s.gsub(' ', '_')
end
Jean-Philippe Lang
Adds date range filter and pagination on time entries detail view (closes #434)....
r1159 def html_hours(text)
Toshi MARUYAMA
Rails3: use String#html_hours for principals_check_box_tags() at ApplicationHelper....
r6361 text.gsub(%r{(\d+)\.(\d+)}, '<span class="hours hours-int">\1</span><span class="hours hours-dec">.\2</span>').html_safe
Jean-Philippe Lang
Adds date range filter and pagination on time entries detail view (closes #434)....
r1159 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Changes issue history headings....
r2092 def authoring(created, author, options={})
Toshi MARUYAMA
Rails3: use String#html_hours for authoring() at ApplicationHelper....
r6362 l(options[:label] || :label_added_time_by, :author => link_to_user(author), :age => time_tag(created)).html_safe
Jean-Philippe Lang
Adds issue last update timestamp (#3565)....
r2703 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds issue last update timestamp (#3565)....
r2703 def time_tag(time)
text = distance_of_time_in_words(Time.now, time)
if @project
Jean-Baptiste Barth
Fix links to activity pages broken with r4047. #6392...
r3978 link_to(text, {:controller => 'activities', :action => 'index', :id => @project, :from => time.to_date}, :title => format_time(time))
Jean-Philippe Lang
Adds issue last update timestamp (#3565)....
r2703 else
content_tag('acronym', text, :title => format_time(time))
end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
Rails3: prevent double rendering file view and annotate on Rails 3.0.11 and Rails 3.1.3...
r8868 def syntax_highlight_lines(name, content)
lines = []
syntax_highlight(name, content).each_line { |line| lines << line }
lines
end
Jean-Philippe Lang
File viewer for attached text files....
r1506 def syntax_highlight(name, content)
Jean-Philippe Lang
Extract CodeRay calls to Redmine::SyntaxHighlighting (#2985)....
r3470 Redmine::SyntaxHighlighting.highlight_by_filename(content, name)
Jean-Philippe Lang
File viewer for attached text files....
r1506 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Fixes "source:" links URLs (r1617)....
r1626 def to_path_param(path)
Toshi MARUYAMA
scm: fix git and mercurial branch list box action...
r9429 str = path.to_s.split(%r{[/\\]}).select{|p| !p.blank?}.join("/")
str.blank? ? nil : str
Jean-Philippe Lang
Fixes "source:" links URLs (r1617)....
r1626 end
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 def pagination_links_full(paginator, count=nil, options={})
Jean-Philippe Lang
Added pagination on wiki page history....
r568 page_param = options.delete(:page_param) || :page
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 per_page_links = options.delete(:per_page_links)
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 url_param = params.dup
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
html = ''
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 if paginator.current.previous
Toshi MARUYAMA
replace &#171; and &#187; at app/helpers/application_helper.rb to hexadecimal UTF-8 strings (#4796)....
r6292 # \xc2\xab(utf-8) = &#171;
html << link_to_content_update(
"\xc2\xab " + l(:label_previous),
url_param.merge(page_param => paginator.current.previous)) + ' '
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 html << (pagination_links_each(paginator, options) do |n|
Jean-Philippe Lang
Makes all pagination-like links use #link_to_content_update (#5138)....
r5181 link_to_content_update(n.to_s, url_param.merge(page_param => n))
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end || '')
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 if paginator.current.next
Toshi MARUYAMA
replace &#171; and &#187; at app/helpers/application_helper.rb to hexadecimal UTF-8 strings (#4796)....
r6292 # \xc2\xbb(utf-8) = &#187;
html << ' ' + link_to_content_update(
(l(:label_next) + " \xc2\xbb"),
url_param.merge(page_param => paginator.current.next))
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 unless count.nil?
Jean-Philippe Lang
Adds pagination to forum messages (#4664)....
r3259 html << " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})"
if per_page_links != false && links = per_page_links(paginator.items_per_page)
html << " | #{links}"
end
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Toshi MARUYAMA
Rails3: use String#html_hours for pagination_links_full() at ApplicationHelper....
r6363 html.html_safe
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 def per_page_links(selected=nil)
links = Setting.per_page_options_array.collect do |n|
Jean-Philippe Lang
Makes all pagination-like links use #link_to_content_update (#5138)....
r5181 n == selected ? n : link_to_content_update(n, params.merge(:per_page => n))
Jean-Philippe Lang
New setting added to specify how many objects should be displayed on most paginated lists....
r1013 end
links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Resourcified trackers....
r7768 def reorder_links(name, url, method = :post)
Toshi MARUYAMA
code layout clean up of app/helpers/application_helper.rb...
r7466 link_to(image_tag('2uparrow.png', :alt => l(:label_sort_highest)),
url.merge({"#{name}[move_to]" => 'highest'}),
Jean-Philippe Lang
Resourcified trackers....
r7768 :method => method, :title => l(:label_sort_highest)) +
Toshi MARUYAMA
code layout clean up of app/helpers/application_helper.rb...
r7466 link_to(image_tag('1uparrow.png', :alt => l(:label_sort_higher)),
url.merge({"#{name}[move_to]" => 'higher'}),
Jean-Philippe Lang
Resourcified trackers....
r7768 :method => method, :title => l(:label_sort_higher)) +
Toshi MARUYAMA
code layout clean up of app/helpers/application_helper.rb...
r7466 link_to(image_tag('1downarrow.png', :alt => l(:label_sort_lower)),
url.merge({"#{name}[move_to]" => 'lower'}),
Jean-Philippe Lang
Resourcified trackers....
r7768 :method => method, :title => l(:label_sort_lower)) +
Toshi MARUYAMA
code layout clean up of app/helpers/application_helper.rb...
r7466 link_to(image_tag('2downarrow.png', :alt => l(:label_sort_lowest)),
url.merge({"#{name}[move_to]" => 'lowest'}),
Jean-Philippe Lang
Resourcified trackers....
r7768 :method => method, :title => l(:label_sort_lowest))
Jean-Philippe Lang
Trackers controller refactoring....
r2462 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Add breadcrumb nav for the forums (#892)....
r1284 def breadcrumb(*args)
Jean-Philippe Lang
Wiki page hierarchy (#528). Parent page can be assigned on Rename screen....
r1689 elements = args.flatten
Toshi MARUYAMA
Rails3: replace &#187; of breadcrumb() at ApplicationHelper to hexadecimal UTF-8 strings and use String#html_safe....
r6399 elements.any? ? content_tag('p', (args.join(" \xc2\xbb ") + " \xc2\xbb ").html_safe, :class => 'breadcrumb') : nil
Jean-Philippe Lang
Add breadcrumb nav for the forums (#892)....
r1284 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds an helper to render other formats download links....
r2331 def other_formats_links(&block)
Jean-Philippe Lang
Strings as html safe....
r7767 concat('<p class="other-formats">'.html_safe + l(:label_export_to))
Jean-Philippe Lang
Adds an helper to render other formats download links....
r2331 yield Redmine::Views::OtherFormatsBuilder.new(self)
Jean-Philippe Lang
Strings as html safe....
r7767 concat('</p>'.html_safe)
Jean-Philippe Lang
Adds an helper to render other formats download links....
r2331 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 def page_header_title
if @project.nil? || @project.new_record?
h(Setting.app_title)
else
b = []
Jean-Philippe Lang
Skip a count query....
r5337 ancestors = (@project.root? ? [] : @project.ancestors.visible.all)
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 if ancestors.any?
root = ancestors.shift
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 b << link_to_project(root, {:jump => current_menu_item}, :class => 'root')
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 if ancestors.size > 2
Toshi MARUYAMA
Rails3: helper: replace &#8230; of page_header_title at ApplicationHelper to hexadecimal UTF-8 strings...
r7462 b << "\xe2\x80\xa6"
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 ancestors = ancestors[-2, 2]
end
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 b += ancestors.collect {|p| link_to_project(p, {:jump => current_menu_item}, :class => 'ancestor') }
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 end
b << h(@project)
Toshi MARUYAMA
Rails3: helper: use html_safe at page_header_title of ApplicationHelper...
r7467 b.join(" \xc2\xbb ").html_safe
Jean-Philippe Lang
Adds (a maximum of 3) links to project ancestors in the page title (#2788)....
r2423 end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Slight improvements to the browser views....
r1019 def html_title(*args)
if args.empty?
Jean-Philippe Lang
Moved the project name after the item in the html title (#9593)....
r7722 title = @html_title || []
Toshi MARUYAMA
backed out r6350 (#9252, #4796)...
r7126 title << @project.name if @project
Jean-Philippe Lang
Moved the project name after the item in the html title (#9593)....
r7722 title << Setting.app_title unless Setting.app_title == title.last
Jean-Philippe Lang
Small fix to HTML title....
r2850 title.select {|t| !t.blank? }.join(' - ')
Jean-Philippe Lang
Slight improvements to the browser views....
r1019 else
@html_title ||= []
@html_title += args
end
Jean-Philippe Lang
Removed @html_title assignments in controllers....
r704 end
Jean-Philippe Lang
Added some accesskeys:...
r793
Eric Davis
Added css classes to the HTML body based on the theme, controller, and action. #819...
r3797 # Returns the theme, controller name, and action as css classes for the
# HTML body.
def body_css_classes
css = []
if theme = Redmine::Themes.theme(Setting.ui_theme)
css << 'theme-' + theme.name
end
Jean-Philippe Lang
Use controller_name and action_name instead of params....
r8898 css << 'controller-' + controller_name
css << 'action-' + action_name
Eric Davis
Added css classes to the HTML body based on the theme, controller, and action. #819...
r3797 css.join(' ')
end
Jean-Philippe Lang
Added some accesskeys:...
r793 def accesskey(s)
Jean-Philippe Lang
Added a 'New issue' link in the main menu (accesskey 7)....
r1067 Redmine::AccessKeys.key_for s
Jean-Philippe Lang
Added some accesskeys:...
r793 end
Jean-Philippe Lang
Added wiki macros support. 2 builtin macros are defined: hello_world (sample macro that displays the arguments) and macro_list (display the list of installed macros)....
r884 # Formats text according to system settings.
# 2 ways to call this method:
# * with a String: textilizable(text, options)
# * with an object and one of its attribute: textilizable(issue, :description, options)
def textilizable(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
case args.size
when 1
Jean-Philippe Lang
Adds child_pages macro for wiki pages (#528)....
r1690 obj = options[:object]
Jean-Philippe Lang
Fixes:...
r1147 text = args.shift
Jean-Philippe Lang
Added wiki macros support. 2 builtin macros are defined: hello_world (sample macro that displays the arguments) and macro_list (display the list of installed macros)....
r884 when 2
obj = args.shift
Jean-Philippe Lang
Adds a setting to cache textile rendering (off by default)....
r3258 attr = args.shift
text = obj.send(attr).to_s
Jean-Philippe Lang
Added wiki macros support. 2 builtin macros are defined: hello_world (sample macro that displays the arguments) and macro_list (display the list of installed macros)....
r884 else
raise ArgumentError, 'invalid arguments to textilizable'
end
Jean-Philippe Lang
Fixes:...
r1147 return '' if text.blank?
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 project = options[:project] || @project || (obj && obj.respond_to?(:project) ? obj.project : nil)
only_path = options.delete(:only_path) == false ? false : true
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 text = Redmine::WikiFormatting.to_html(Setting.text_formatting, text, :object => obj, :attribute => attr)
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 @parsed_headings = []
Jean-Philippe Lang
Fixed: {{toc}} uses identical anchors for subsections with the same name (#8194)....
r8751 @heading_anchors = {}
Jean-Philippe Lang
Fixes section edit links when text includes pre/code tag (#2222)....
r7715 @current_section = 0 if options[:edit_section_links]
Jean-Philippe Lang
Fixed: wrong section edit links when a heading contains inline code (#10199)....
r8721
parse_sections(text, project, obj, attr, only_path, options)
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 text = parse_non_pre_blocks(text) do |text|
Jean-Philippe Lang
Fixed: wrong section edit links when a heading contains inline code (#10199)....
r8721 [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links, :parse_macros].each do |method_name|
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 send method_name, text, project, obj, attr, only_path, options
end
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 end
Jean-Philippe Lang
Fixed: wrong section edit links when a heading contains inline code (#10199)....
r8721 parse_headings(text, project, obj, attr, only_path, options)
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 if @parsed_headings.any?
replace_toc(text, @parsed_headings)
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
html_safe for Rails3...
r8151 text.html_safe
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 def parse_non_pre_blocks(text)
s = StringScanner.new(text)
tags = []
parsed = ''
while !s.eos?
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im)
text, full_tag, closing, tag = s[1], s[2], s[3], s[4]
if tags.empty?
yield text
end
parsed << text
if tag
if closing
if tags.last == tag.downcase
tags.pop
end
else
tags << tag.downcase
end
parsed << full_tag
end
end
Jean-Philippe Lang
Close unclosed pre/code tags (#4265)....
r3476 # Close any non closing tags
while tag = tags.pop
parsed << "</#{tag}>"
end
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 parsed
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 def parse_inline_attachments(text, project, obj, attr, only_path, options)
Jean-Philippe Lang
Added Redmine::WikiFormatting module and tests for wiki links....
r688 # when using an image link, try to use an attachment, if possible
Jean-Philippe Lang
Optimization: load attachments when needed....
r3467 if options[:attachments] || (obj && obj.respond_to?(:attachments))
Toshi MARUYAMA
move logic to use latest image file attachment to class method for common use (#3261)...
r7788 attachments = options[:attachments] || obj.attachments
Toshi MARUYAMA
fix inconsistent image filename extensions (#9638)...
r7771 text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712 filename, ext, alt, alttext = $1.downcase, $2, $3, $4
Jean-Philippe Lang
Added Redmine::WikiFormatting module and tests for wiki links....
r688 # search for the picture in attachments
Toshi MARUYAMA
move logic to use latest image file attachment to class method for common use (#3261)...
r7788 if found = Attachment.latest_attach(attachments, filename)
image_url = url_for :only_path => only_path, :controller => 'attachments',
:action => 'download', :id => found
Jean-Philippe Lang
Moves attachments parsing after textile parsing so that:...
r3139 desc = found.description.to_s.gsub('"', '')
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
end
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 "src=\"#{image_url}\"#{alt}"
Jean-Philippe Lang
Added Redmine::WikiFormatting module and tests for wiki links....
r688 else
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 m
Jean-Philippe Lang
Added Redmine::WikiFormatting module and tests for wiki links....
r688 end
end
end
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 # Wiki links
#
# Examples:
# [[mypage]]
# [[mypage|mytext]]
# wiki links can refer other project wikis, using project name or identifier:
# [[project:]] -> wiki starting page
# [[project:|mytext]]
# [[project:mypage]]
# [[project:mypage|mytext]]
def parse_wiki_links(text, project, obj, attr, only_path, options)
text.gsub!(/(!)?(\[\[([^\]\n\|]+)(\|([^\]\n\|]+))?\]\])/) do |m|
Jean-Philippe Lang
Textilized project descriptions on project list and home page....
r645 link_project = project
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 esc, all, page, title = $1, $2, $3, $5
if esc.nil?
if page =~ /^([^\:]+)\:(.*)$/
Jean-Philippe Lang
Allow non-unique names for projects (#630)....
r4277 link_project = Project.find_by_identifier($1) || Project.find_by_name($1)
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 page = $2
title ||= $1 if page.blank?
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 if link_project && link_project.wiki
Jean-Philippe Lang
Adds support for wiki links with anchor (#1647)....
r1697 # extract anchor
anchor = nil
if page =~ /^(.+?)\#(.+)$/
page, anchor = $1, $2
end
Etienne Massip
Make sure that anchor names generated for headings fully match wiki links (#7215)....
r7443 anchor = sanitize_anchor_name(anchor) if anchor.present?
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 # check if page exists
wiki_page = link_project.wiki.find_page(page)
Etienne Massip
Use local links in wiki pages when possible (#3276)....
r7438 url = if anchor.present? && wiki_page.present? && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && obj.page == wiki_page
"##{anchor}"
else
case options[:wiki_links]
Etienne Massip
Fix generation of blank local link when no title is specified in wiki link....
r7440 when :local; "#{page.present? ? Wiki.titleize(page) : ''}.html" + (anchor.present? ? "##{anchor}" : '')
Etienne Massip
Prepend page title to anchor in single page wiki HTML export to make links more unique....
r7442 when :anchor; "##{page.present? ? Wiki.titleize(page) : title}" + (anchor.present? ? "_#{anchor}" : '') # used for single-file wiki export
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 else
Eric Davis
Refactor: convert WikiController to a REST resource...
r4189 wiki_page_id = page.present? ? Wiki.titleize(page) : nil
Jean-Philippe Lang
Option to set parent automatically for new wiki pages (#3108)....
r8135 parent = wiki_page.nil? && obj.is_a?(WikiContent) && obj.page && project == link_project ? obj.page.title : nil
url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
:id => wiki_page_id, :anchor => anchor, :parent => parent)
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 end
Etienne Massip
Use local links in wiki pages when possible (#3276)....
r7438 end
Etienne Massip
Html safe wiki page title....
r7796 link_to(title.present? ? title.html_safe : h(page), url, :class => ('wiki-page' + (wiki_page ? '' : ' new')))
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 else
# project or wiki doesn't exist
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 all
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Improved Redmine links:...
r703 else
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 all
Jean-Philippe Lang
Improved Redmine links:...
r703 end
Jean-Philippe Lang
Wiki links can now refer other project wikis, using this syntax:...
r637 end
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 # Redmine links
#
# Examples:
# Issues:
# #52 -> Link to issue #52
# Changesets:
# r52 -> Link to revision 52
# commit:a85130f -> Link to scmid starting with a85130f
# Documents:
# document#17 -> Link to document with id 17
# document:Greetings -> Link to the document with title "Greetings"
# document:"Some document" -> Link to the document with title "Some document"
# Versions:
# version#3 -> Link to version with id 3
# version:1.0.0 -> Link to version named "1.0.0"
# version:"1.0 beta 2" -> Link to version named "1.0 beta 2"
# Attachments:
# attachment:file.zip -> Link to the attachment of the current object named file.zip
# Source files:
# source:some/file -> Link to the file located at /some/file in the project's repository
# source:some/file@52 -> Link to the file's revision 52
# source:some/file#L120 -> Link to line 120 of the file
# source:some/file@52#L120 -> Link to line 120 of the file's revision 52
# export:some/file -> Force the download of the file
Jean-Philippe Lang
Adds support for cross project Redmine links (#7409)....
r4638 # Forum messages:
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 # message#1218 -> Link to message with id 1218
Jean-Philippe Lang
Adds support for cross project Redmine links (#7409)....
r4638 #
# Links can refer other objects from other projects, using project identifier:
# identifier:r52
# identifier:document:"Some document"
# identifier:version:1.0.0
# identifier:source:some/file
Jean-Philippe Lang
Extract parsing of inline attachments, wiki links and redmine links....
r3474 def parse_redmine_links(text, project, obj, attr, only_path, options)
Jean-Philippe Lang
Adds support for "Magic links" to notes (#2715)....
r8757 text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $1, $2, $3, $4, $5, $10, $11, $8 || $12 || $18, $14 || $19, $15, $17
Jean-Philippe Lang
Added Redmine::WikiFormatting module and tests for wiki links....
r688 link = nil
Jean-Philippe Lang
Adds support for cross project Redmine links (#7409)....
r4638 if project_identifier
project = Project.visible.find_by_identifier(project_identifier)
end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 if esc.nil?
if prefix.nil? && sep == 'r'
Jean-Philippe Lang
Adds support for multiple repositories to redmine links (#779)....
r8574 if project
repository = nil
if repo_identifier
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
else
repository = project.repository
end
# project.changesets.visible raises an SQL error because of a double join on repositories
if repository && (changeset = Changeset.visible.find_by_repository_id_and_revision(repository.id, identifier))
link = link_to(h("#{project_prefix}#{repo_prefix}r#{identifier}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.revision},
:class => 'changeset',
:title => truncate_single_line(changeset.comments, :length => 100))
end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
elsif sep == '#'
Jean-Philippe Lang
Fixed: Pound (#) followed by number with leading zero (0) removes leading zero when rendered in wiki (#4872)....
r3337 oid = identifier.to_i
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 case prefix
when nil
Jean-Philippe Lang
Add view_issues permission (#3187)....
r2925 if issue = Issue.visible.find_by_id(oid, :include => :status)
Jean-Philippe Lang
Adds support for "Magic links" to notes (#2715)....
r8757 anchor = comment_id ? "note-#{comment_id}" : nil
link = link_to("##{oid}", {:only_path => only_path, :controller => 'issues', :action => 'show', :id => oid, :anchor => anchor},
Jean-Philippe Lang
Clean up ticket auto links....
r2927 :class => issue.css_classes,
Jean-Philippe Lang
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 :title => "#{truncate(issue.subject, :length => 100)} (#{issue.status.name})")
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
when 'document'
Jean-Philippe Lang
Adds visible scope to redmine links queries....
r4639 if document = Document.visible.find_by_id(oid)
Jean-Philippe Lang
Fixes:...
r1147 link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
:class => 'document'
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
when 'version'
Jean-Philippe Lang
Adds visible scope to redmine links queries....
r4639 if version = Version.visible.find_by_id(oid)
Jean-Philippe Lang
Fixes:...
r1147 link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
:class => 'version'
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Adds links to forum messages using message#id syntax (#1756)....
r1728 when 'message'
Jean-Philippe Lang
Adds visible scope to redmine links queries....
r4639 if message = Message.visible.find_by_id(oid, :include => :parent)
Jean-Philippe Lang
Moves link_to_message to ApplicationHelper to make it available to redmine links....
r4640 link = link_to_message(message, {:only_path => only_path}, :class => 'message')
Jean-Philippe Lang
Adds links to forum messages using message#id syntax (#1756)....
r1728 end
Jean-Philippe Lang
Wiki links for news and forums (#9600)....
r7720 when 'forum'
if board = Board.visible.find_by_id(oid)
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
:class => 'board'
end
when 'news'
if news = News.visible.find_by_id(oid)
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
:class => 'news'
end
Jean-Philippe Lang
Adds projects links (#4812)....
r3308 when 'project'
if p = Project.visible.find_by_id(oid)
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 link = link_to_project(p, {:only_path => only_path}, :class => 'project')
Jean-Philippe Lang
Adds projects links (#4812)....
r3308 end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
elsif sep == ':'
# removes the double quotes if any
Jean-Philippe Lang
Fixed: Pound (#) followed by number with leading zero (0) removes leading zero when rendered in wiki (#4872)....
r3337 name = identifier.gsub(%r{^"(.*)"$}, "\\1")
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 case prefix
when 'document'
Jean-Philippe Lang
Adds visible scope to redmine links queries....
r4639 if project && document = project.documents.visible.find_by_title(name)
Jean-Philippe Lang
Fixes:...
r1147 link = link_to h(document.title), {:only_path => only_path, :controller => 'documents', :action => 'show', :id => document},
:class => 'document'
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
when 'version'
Jean-Philippe Lang
Adds visible scope to redmine links queries....
r4639 if project && version = project.versions.visible.find_by_name(name)
Jean-Philippe Lang
Fixes:...
r1147 link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
:class => 'version'
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Wiki links for news and forums (#9600)....
r7720 when 'forum'
if project && board = project.boards.visible.find_by_name(name)
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
:class => 'board'
end
when 'news'
if project && news = project.news.visible.find_by_title(name)
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
:class => 'news'
end
Jean-Philippe Lang
Adds support for multiple repositories to redmine links (#779)....
r8574 when 'commit', 'source', 'export'
if project
repository = nil
if name =~ %r{^(([a-z0-9\-]+)\|)(.+)$}
repo_prefix, repo_identifier, name = $1, $2, $3
repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
else
repository = project.repository
end
if prefix == 'commit'
if repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%"]))
link = link_to h("#{project_prefix}#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :repository_id => repository.identifier_param, :rev => changeset.identifier},
:class => 'changeset',
:title => truncate_single_line(h(changeset.comments), :length => 100)
end
else
if repository && User.current.allowed_to?(:browse_repository, project)
name =~ %r{^[/\\]*(.*?)(@([0-9a-f]+))?(#(L\d+))?$}
path, rev, anchor = $1, $3, $5
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:controller => 'repositories', :action => 'entry', :id => project, :repository_id => repository.identifier_param,
:path => to_path_param(path),
:rev => rev,
:anchor => anchor,
:format => (prefix == 'export' ? 'raw' : nil)},
:class => (prefix == 'export' ? 'source download' : 'source')
end
end
repo_prefix = nil
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 when 'attachment'
Jean-Philippe Lang
Optimization: load attachments when needed....
r3467 attachments = options[:attachments] || (obj && obj.respond_to?(:attachments) ? obj.attachments : nil)
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 if attachments && attachment = attachments.detect {|a| a.filename == name }
Jean-Philippe Lang
Fixes:...
r1147 link = link_to h(attachment.filename), {:only_path => only_path, :controller => 'attachments', :action => 'download', :id => attachment},
:class => 'attachment'
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Adds projects links (#4812)....
r3308 when 'project'
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 link = link_to_project(p, {:only_path => only_path}, :class => 'project')
Jean-Philippe Lang
Adds projects links (#4812)....
r3308 end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Improved Redmine links:...
r703 end
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 end
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 (leading + (link || "#{project_prefix}#{prefix}#{repo_prefix}#{sep}#{identifier}#{comment_suffix}"))
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 HEADING_RE = /(<h(1|2|3|4)( [^>]+)?>(.+?)<\/h(1|2|3|4)>)/i unless const_defined?(:HEADING_RE)
def parse_sections(text, project, obj, attr, only_path, options)
return unless options[:edit_section_links]
text.gsub!(HEADING_RE) do
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 heading = $1
Jean-Philippe Lang
Fixes section edit links when text includes pre/code tag (#2222)....
r7715 @current_section += 1
if @current_section > 1
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 content_tag('div',
Jean-Philippe Lang
Fixes section edit links when text includes pre/code tag (#2222)....
r7715 link_to(image_tag('edit.png'), options[:edit_section_links].merge(:section => @current_section)),
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 :class => 'contextual',
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 :title => l(:button_edit_section)) + heading.html_safe
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 else
Jean-Philippe Lang
Fixed escaping issues in #textilizable with Rails 3.1....
r8865 heading
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 end
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 # Headings and TOC
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 # Adds ids and links to headings unless options[:headings] is set to false
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 def parse_headings(text, project, obj, attr, only_path, options)
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 return if options[:headings] == false
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 text.gsub!(HEADING_RE) do
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 level, attrs, content = $2.to_i, $3, $4
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 item = strip_tags(content).strip
Etienne Massip
Make sure that anchor names generated for headings fully match wiki links (#7215)....
r7443 anchor = sanitize_anchor_name(item)
Etienne Massip
Prepend page title to anchor in single page wiki HTML export to make links more unique....
r7442 # used for single-file wiki export
anchor = "#{obj.page.title}_#{anchor}" if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version))
Jean-Philippe Lang
Fixed: {{toc}} uses identical anchors for subsections with the same name (#8194)....
r8751 @heading_anchors[anchor] ||= 0
idx = (@heading_anchors[anchor] += 1)
if idx > 1
anchor = "#{anchor}-#{idx}"
end
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 @parsed_headings << [level, anchor, item]
Jean-Philippe Lang
Use names instead of ids for wiki anchors (#6905)....
r5015 "<a name=\"#{anchor}\"></a>\n<h#{level} #{attrs}>#{content}<a href=\"##{anchor}\" class=\"wiki-anchor\">&para;</a></h#{level}>"
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 MACROS_RE = /
(!)? # escaping
(
\{\{ # opening tag
([\w]+) # macro name
(\(([^\}]*)\))? # optional arguments
\}\} # closing tag
)
/x unless const_defined?(:MACROS_RE)
# Macros substitution
def parse_macros(text, project, obj, attr, only_path, options)
text.gsub!(MACROS_RE) do
esc, all, macro = $1, $2, $3.downcase
args = ($5 || '').split(',').each(&:strip)
if esc.nil?
begin
exec_macro(macro, obj, args)
rescue => e
"<div class=\"flash error\">Error executing the <strong>#{macro}</strong> macro (#{e})</div>"
end || all
else
all
end
end
end
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 TOC_RE = /<p>\{\{([<>]?)toc\}\}<\/p>/i unless const_defined?(:TOC_RE)
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Fixed: partial toc when text contains pre tags (#7172)....
r4464 # Renders the TOC with given headings
def replace_toc(text, headings)
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 text.gsub!(TOC_RE) do
if headings.empty?
''
else
div_class = 'toc'
div_class << ' right' if $1 == '>'
div_class << ' left' if $1 == '<'
Jean-Philippe Lang
Render TOC as nested lists (#1857)....
r4263 out = "<ul class=\"#{div_class}\"><li>"
root = headings.map(&:first).min
current = root
started = false
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 headings.each do |level, anchor, item|
Jean-Philippe Lang
Render TOC as nested lists (#1857)....
r4263 if level > current
out << '<ul><li>' * (level - current)
elsif level < current
out << "</li></ul>\n" * (current - level) + "</li><li>"
elsif started
out << '</li><li>'
end
out << "<a href=\"##{anchor}\">#{item}</a>"
current = level
started = true
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 end
Jean-Philippe Lang
Render TOC as nested lists (#1857)....
r4263 out << '</li></ul>' * (current - root)
out << '</li></ul>'
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 end
end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Added wiki diff....
r580 # Same as Rails' simple_format helper without using paragraphs
def simple_format_without_paragraph(text)
text.to_s.
gsub(/\r\n?/, "\n"). # \r\n and \r -> \n
gsub(/\n\n+/, "<br /><br />"). # 2+ newline -> 2 br
Toshi MARUYAMA
Rails3: helper: use html_safe at simple_format_without_paragraph of ApplicationHelper...
r7465 gsub(/([^\n]\n)(?=[^\n])/, '\1<br />'). # 1 newline -> br
html_safe
Jean-Philippe Lang
Added wiki diff....
r580 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def lang_options_for_select(blank=true)
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986 (blank ? [["(auto)", ""]] : []) +
Jean-Philippe Lang
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def label_tag_for(name, option_tags = nil, options = {})
label_text = l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) + (options.delete(:required) ? @template.content_tag("span", " *", :class => "required"): "")
content_tag("label", label_text)
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Makes labelled_tabular_form_for accept different signatures....
r7780 def labelled_tabular_form_for(*args, &proc)
Jean-Philippe Lang
Use #labelled_form_for instead of #labelled_tabular_form_for....
r8021 ActiveSupport::Deprecation.warn "ApplicationHelper#labelled_tabular_form_for is deprecated and will be removed in Redmine 1.5. Use #labelled_form_for instead."
Jean-Philippe Lang
Makes labelled_tabular_form_for accept different signatures....
r7780 args << {} unless args.last.is_a?(Hash)
options = args.last
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 options[:html] ||= {}
Jean-Philippe Lang
Adds an optional description to attachments....
r1166 options[:html][:class] = 'tabular' unless options[:html].has_key?(:class)
Jean-Philippe Lang
Renamed TabularFormBuilder to Redmine::Views::LabelledFormBuilder....
r8023 options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
Jean-Philippe Lang
Makes labelled_tabular_form_for accept different signatures....
r7780 form_for(*args, &proc)
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
View cleanup....
r7819 def labelled_form_for(*args, &proc)
args << {} unless args.last.is_a?(Hash)
options = args.last
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 if args.first.is_a?(Symbol)
options.merge!(:as => args.shift)
end
Jean-Philippe Lang
Renamed TabularFormBuilder to Redmine::Views::LabelledFormBuilder....
r8023 options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
Jean-Philippe Lang
View cleanup....
r7819 form_for(*args, &proc)
end
Jean-Philippe Lang
Removed TabularFormBuilder references in views....
r8022 def labelled_fields_for(*args, &proc)
args << {} unless args.last.is_a?(Hash)
options = args.last
Jean-Philippe Lang
Renamed TabularFormBuilder to Redmine::Views::LabelledFormBuilder....
r8023 options.merge!({:builder => Redmine::Views::LabelledFormBuilder})
Jean-Philippe Lang
Removed TabularFormBuilder references in views....
r8022 fields_for(*args, &proc)
end
def labelled_remote_form_for(*args, &proc)
args << {} unless args.last.is_a?(Hash)
options = args.last
Jean-Philippe Lang
Merged #merge! calls....
r9393 options.merge!({:builder => Redmine::Views::LabelledFormBuilder, :remote => true})
Toshi MARUYAMA
helper: replace remote_form_for to form_for at labelled_remote_form_for...
r9390 form_for(*args, &proc)
Jean-Philippe Lang
Removed TabularFormBuilder references in views....
r8022 end
Jean-Philippe Lang
Adds a helper for displaying validation error messages....
r8897 def error_messages_for(*objects)
html = ""
objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
errors = objects.map {|o| o.errors.full_messages}.flatten
if errors.any?
html << "<div id='errorExplanation'><ul>\n"
errors.each do |error|
html << "<li>#{h error}</li>\n"
end
html << "</ul></div>\n"
end
html.html_safe
end
Jean-Philippe Lang
Redirected user to where he is coming from after logging hours (#1062)....
r1339 def back_url_hidden_field_tag
Jean-Philippe Lang
Redirect user to the previous page after logging in (#1679)....
r1686 back_url = params[:back_url] || request.env['HTTP_REFERER']
Jean-Philippe Lang
Do not escape back_url twice when login fails....
r2212 back_url = CGI.unescape(back_url.to_s)
Toshi MARUYAMA
Fix duplicated 'back_url' IDs...
r9130 hidden_field_tag('back_url', CGI.escape(back_url), :id => nil) unless back_url.blank?
Jean-Philippe Lang
Redirected user to where he is coming from after logging hours (#1062)....
r1339 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def check_all_links(form_name)
link_to_function(l(:button_check_all), "checkAll('#{form_name}', true)") +
Toshi MARUYAMA
Rails3: use String#html_safe for check_all_links() at ApplicationHelper....
r6369 " | ".html_safe +
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986 link_to_function(l(:button_uncheck_all), "checkAll('#{form_name}', false)")
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Roadmap progress bars now differentiate the progress due to closed issues from the open issues progress (2 different colors)....
r941 def progress_bar(pcts, options={})
pcts = [pcts, pcts] unless pcts.is_a?(Array)
Jean-Philippe Lang
Fixed roadmap progress display error (#4255)....
r2968 pcts = pcts.collect(&:round)
Jean-Philippe Lang
Roadmap progress bars now differentiate the progress due to closed issues from the open issues progress (2 different colors)....
r941 pcts[1] = pcts[1] - pcts[0]
pcts << (100 - pcts[1] - pcts[0])
Jean-Philippe Lang
Roadmap: more accurate completion percentage calculation (done ratio of open issues is now taken into account)....
r895 width = options[:width] || '100px;'
legend = options[:legend] || ''
content_tag('table',
content_tag('tr',
Toshi MARUYAMA
Rails3: use String#html_safe for progress_bar() at ApplicationHelper....
r6370 (pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed') : ''.html_safe) +
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done') : ''.html_safe) +
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo') : ''.html_safe)
), :class => 'progress', :style => "width: #{width};").html_safe +
content_tag('p', legend, :class => 'pourcent').html_safe
Jean-Philippe Lang
Roadmap: more accurate completion percentage calculation (done ratio of open issues is now taken into account)....
r895 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds an helper for displaying the 'checked' image....
r3486 def checked_image(checked=true)
if checked
image_tag 'toggle_check.png'
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds an helper for creating the context menu....
r3428 def context_menu(url)
unless @context_menu_included
content_for :header_tags do
javascript_include_tag('context_menu') +
stylesheet_link_tag('context_menu')
end
Eric Davis
Add RTL support to the context menu. #6012...
r3900 if l(:direction) == 'rtl'
content_for :header_tags do
stylesheet_link_tag('context_menu_rtl')
end
end
Jean-Philippe Lang
Adds an helper for creating the context menu....
r3428 @context_menu_included = true
end
javascript_tag "new ContextMenu('#{ url_for(url) }')"
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def calendar_for(field_id)
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300 include_calendar_headers_tags
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 image_tag("calendar.png", {:id => "#{field_id}_trigger",:class => "calendar-trigger"}) +
javascript_tag("Calendar.setup({inputField : '#{field_id}', ifFormat : '%Y-%m-%d', button : '#{field_id}_trigger' });")
end
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300
def include_calendar_headers_tags
unless @calendar_headers_tags_included
@calendar_headers_tags_included = true
content_for :header_tags do
Eric Davis
Added a setting to configure the day that week start on (Monday or Sunday). (#4363)...
r3052 start_of_week = case Setting.start_of_week.to_i
when 1
'Calendar._FD = 1;' # Monday
when 7
'Calendar._FD = 0;' # Sunday
Jean-Philippe Lang
Adds support for saturday as the first week day (#7097)....
r5108 when 6
'Calendar._FD = 6;' # Saturday
Eric Davis
Added a setting to configure the day that week start on (Monday or Sunday). (#4363)...
r3052 else
'' # use language
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300 javascript_include_tag('calendar/calendar') +
Jean-Philippe Lang
Fixed: Calendar popup broken by i18n refactoring (#3168)....
r2591 javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") +
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712 javascript_tag(start_of_week) +
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300 javascript_include_tag('calendar/calendar-setup') +
stylesheet_link_tag('calendar')
end
end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Restores support for :plugin support to stylesheet_link_tag and javascript_include_tag helpers....
r9376 # Overrides Rails' stylesheet_link_tag with themes and plugins support.
# Examples:
# stylesheet_link_tag('styles') # => picks styles.css from the current theme or defaults
# stylesheet_link_tag('styles', :plugin => 'foo) # => picks styles.css from plugin's assets
#
def stylesheet_link_tag(*sources)
options = sources.last.is_a?(Hash) ? sources.pop : {}
plugin = options.delete(:plugin)
sources = sources.map do |source|
if plugin
"/plugin_assets/#{plugin}/stylesheets/#{source}"
elsif current_theme && current_theme.stylesheets.include?(source)
current_theme.stylesheet_path(source)
else
source
end
end
super sources, options
end
Jean-Philippe Lang
Makes image_tag pick the image from the current theme if it exists....
r9378 # Overrides Rails' image_tag with themes and plugins support.
Jean-Philippe Lang
Adds support for :plugin option to image_tag helper....
r9377 # Examples:
Jean-Philippe Lang
Makes image_tag pick the image from the current theme if it exists....
r9378 # image_tag('image.png') # => picks image.png from the current theme or defaults
Jean-Philippe Lang
Adds support for :plugin option to image_tag helper....
r9377 # image_tag('image.png', :plugin => 'foo) # => picks image.png from plugin's assets
#
def image_tag(source, options={})
if plugin = options.delete(:plugin)
source = "/plugin_assets/#{plugin}/images/#{source}"
Jean-Philippe Lang
Makes image_tag pick the image from the current theme if it exists....
r9378 elsif current_theme && current_theme.images.include?(source)
source = current_theme.image_path(source)
Jean-Philippe Lang
Adds support for :plugin option to image_tag helper....
r9377 end
super source, options
end
Jean-Philippe Lang
Restores support for :plugin support to stylesheet_link_tag and javascript_include_tag helpers....
r9376 # Overrides Rails' javascript_include_tag with plugins support
# Examples:
# javascript_include_tag('scripts') # => picks scripts.js from defaults
# javascript_include_tag('scripts', :plugin => 'foo) # => picks scripts.js from plugin's assets
#
def javascript_include_tag(*sources)
options = sources.last.is_a?(Hash) ? sources.pop : {}
if plugin = options.delete(:plugin)
sources = sources.map do |source|
if plugin
"/plugin_assets/#{plugin}/javascripts/#{source}"
else
source
end
end
end
super sources, options
end
Jean-Philippe Lang
Application layout refactored....
r736 def content_for(name, content = nil, &block)
@has_content ||= {}
@has_content[name] = true
super(name, content, &block)
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Application layout refactored....
r736 def has_content?(name)
(@has_content && @has_content[name]) || false
end
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper....
r6347
Jean-Philippe Lang
Fixed that sidebar with hook content only should not be hidden....
r9415 def sidebar_content?
has_content?(:sidebar) || view_layouts_base_sidebar_hook_response.present?
end
def view_layouts_base_sidebar_hook_response
@view_layouts_base_sidebar_hook_response ||= call_hook(:view_layouts_base_sidebar)
end
Jean-Philippe Lang
Do not show 'Send information' checkbox if email delivery is not configured....
r6047 def email_delivery_enabled?
!!ActionMailer::Base.perform_deliveries
end
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953
Jean-Philippe Lang
Changes ApplicationHelper#gravatar_for_mail to #avatar that takes a User or a String (less code in views)....
r1998 # Returns the avatar image tag for the given +user+ if avatars are enabled
# +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>')
def avatar(user, options = { })
Eric Davis
Added an option to turn user Gravatars on or off...
r1970 if Setting.gravatar_enabled?
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default})
Jean-Philippe Lang
Changes ApplicationHelper#gravatar_for_mail to #avatar that takes a User or a String (less code in views)....
r1998 email = nil
if user.respond_to?(:mail)
email = user.mail
elsif user.to_s =~ %r{<(.+?)>}
email = $1
end
return gravatar(email.to_s.downcase, options) unless email.blank? rescue nil
Eric Davis
Rewrite the Gantt chart. #6276...
r3958 else
''
Eric Davis
Added an option to turn user Gravatars on or off...
r1970 end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Etienne Massip
Make sure that anchor names generated for headings fully match wiki links (#7215)....
r7443 def sanitize_anchor_name(anchor)
anchor.gsub(%r{[^\w\s\-]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
end
Jean-Philippe Lang
Warning on leaving a page with unsaved content in textarea (#2910)....
r4780 # Returns the javascript tags that are included in the html layout head
def javascript_heads
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 tags = javascript_include_tag('prototype', 'effects', 'dragdrop', 'controls', 'rails', 'application')
Jean-Philippe Lang
Warning on leaving a page with unsaved content in textarea (#2910)....
r4780 unless User.current.pref.warn_on_leaving_unsaved == '0'
Toshi MARUYAMA
Rails3: use String#html_safe for javascript_heads() at ApplicationHelper....
r6374 tags << "\n".html_safe + javascript_tag("Event.observe(window, 'load', function(){ new WarnLeavingUnsaved('#{escape_javascript( l(:text_warn_on_leaving_unsaved) )}'); });")
Jean-Philippe Lang
Warning on leaving a page with unsaved content in textarea (#2910)....
r4780 end
tags
end
Eric Davis
Added an option to turn user Gravatars on or off...
r1970
Eric Davis
Add a favicon link with support for suburi. #3301...
r3780 def favicon
Toshi MARUYAMA
Rails3: use String#html_safe for favicon in ApplicationHelper....
r6346 "<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />".html_safe
Eric Davis
Add a favicon link with support for suburi. #3301...
r3780 end
Jean-Philippe Lang
Adds noindex,noarchive robots meta tag on form pages (#7582)....
r5323
def robot_exclusion_tag
Toshi MARUYAMA
Rails3: helper: html_safe for robot_exclusion_tag...
r7847 '<meta name="robots" content="noindex,follow,noarchive" />'.html_safe
Jean-Philippe Lang
Adds noindex,noarchive robots meta tag on form pages (#7582)....
r5323 end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Makes some attributes optional in API response to get faster/lightweight responses....
r4372 # Returns true if arg is expected in the API response
def include_in_api_response?(arg)
unless @included_in_api_response
param = params[:include]
@included_in_api_response = param.is_a?(Array) ? param.collect(&:to_s) : param.to_s.split(',')
@included_in_api_response.collect!(&:strip)
end
@included_in_api_response.include?(arg.to_s)
end
Eric Davis
Add a favicon link with support for suburi. #3301...
r3780
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 # Returns options or nil if nometa param or X-Redmine-Nometa header
# was set in the request
def api_meta(options)
if params[:nometa].present? || request.headers['X-Redmine-Nometa']
# compatibility mode for activeresource clients that raise
# an error when unserializing an array with attributes
nil
else
options
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953 private
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Makes wiki text formatter pluggable....
r1953 def wiki_helper
helper = Redmine::WikiFormatting.helper_for(Setting.text_formatting)
extend helper
return self
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Makes all pagination-like links use #link_to_content_update (#5138)....
r5181 def link_to_content_update(text, url_params = {}, html_options = {})
Jean-Philippe Lang
Changes pagination links to non-AJAX requests (#5138)....
r5182 link_to(text, url_params, html_options)
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 end
Jean-Philippe Lang
Initial commit...
r2 end