##// END OF EJS Templates
Project is required....
Project is required. git-svn-id: http://svn.redmine.org/redmine/trunk@15935 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15535:ef45304817e9
r15553:7cce582c14a0
Show More
application_helper.rb
1374 lines | 50.1 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
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 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
Replaces the classic_pagination plugin with a simple pagination module....
r10797 include Redmine::Pagination::Helper
Jean-Philippe Lang
Require password re-entry for sensitive actions (#19851)....
r13951 include Redmine::SudoMode::Helper
Jean-Philippe Lang
Don't reopen ApplicationHelper (#20507)....
r14313 include Redmine::Themes::Helper
Jean-Philippe Lang
Include helper instead of patching (#20508)....
r14311 include Redmine::Hook::Helper
Jean-Philippe Lang
Limits the schemes that project homepage can use (#22925)....
r15050 include Redmine::Helpers::URL
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
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]))
Jean-Philippe Lang
Adds links to locked users when current user is admin....
r10462 if user.active? || (User.current.admin? && user.logged?)
Jean-Philippe Lang
Use named route....
r10463 link_to name, user_path(user), :class => user.css_classes
Jean-Philippe Lang
Fixes ApplicationHelper#link_to_user...
r2910 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
Makes related issues available for display and filtering on the issue list (#3239, #3265)....
r10303 # link_to_issue(issue, :subject => false, :tracker => false) # => #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
Jean-Philippe Lang
Makes related issues available for display and filtering on the issue list (#3239, #3265)....
r10303 text = options[:tracker] == false ? "##{issue.id}" : "#{issue.tracker} ##{issue.id}"
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 if options[:subject] == false
Toshi MARUYAMA
Rails4: replace ActionView::Helpers::TextHelper#truncate by String#truncate at ApplicationHelper#link_to_issue...
r12556 title = issue.subject.truncate(60)
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 else
subject = issue.subject
Toshi MARUYAMA
Rails4: replace ActionView::Helpers::TextHelper#truncate by String#truncate at ApplicationHelper#link_to_issue...
r12556 if truncate_length = options[:truncate]
subject = subject.truncate(truncate_length)
Jean-Philippe Lang
Refactoring ApplicationHelper#link_to_issue....
r2926 end
end
Jean-Philippe Lang
Fixed that links for relations in notifications do not include hostname (#15677)....
r12140 only_path = options[:only_path].nil? ? true : options[:only_path]
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 s = link_to(text, issue_url(issue, :only_path => only_path),
Toshi MARUYAMA
code format clean up ApplicationHelper#link_to_issue...
r12533 :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
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 route_method = options.delete(:download) ? :download_named_attachment_url : :named_attachment_url
Jean-Philippe Lang
Add named routes for attachments and use route helpers in #link_to_attachment....
r10957 html_options = options.slice!(:only_path)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 options[:only_path] = true unless options.key?(:only_path)
Jean-Philippe Lang
Add named routes for attachments and use route helpers in #link_to_attachment....
r10957 url = send(route_method, attachment, attachment.filename, options)
link_to text, url, html_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},
Jean-Philippe Lang
Adds p/n access keys for previous/next links (#18692)....
r13412 :title => l(:label_revision_id, format_revision(revision)),
:accesskey => options[:accesskey]
Toshi MARUYAMA
code layout clean up application helper "link_to_revision" method...
r7913 )
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(
Toshi MARUYAMA
Rails4: replace ActionView::Helpers::TextHelper#truncate by String#truncate at ApplicationHelper#link_to_message...
r12559 message.subject.truncate(60),
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 board_message_url(message.board_id, message.parent_id || message.id, {
Jean-Philippe Lang
Moves link_to_message to ApplicationHelper to make it available to redmine links....
r4640 :r => (message.parent_id && message.id),
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 :anchor => (message.parent_id ? "message-#{message.id}" : nil),
:only_path => true
Jean-Philippe Lang
Use route helper in #link_to_message....
r10956 }.merge(options)),
Jean-Philippe Lang
Moves link_to_message to ApplicationHelper to make it available to redmine links....
r4640 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, {: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)
Jean-Philippe Lang
Ability to close projects (read-only) (#3640)....
r9700 if project.archived?
Jean-Philippe Lang
Use route helper in #link_to_project....
r10954 h(project.name)
else
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link_to project.name,
project_url(project, {:only_path => true}.merge(options)),
html_options
Jean-Philippe Lang
Use route helper in #link_to_project....
r10954 end
end
# Generates a link to a project settings if active
def link_to_project_settings(project, options={}, html_options=nil)
if project.active?
link_to project.name, settings_project_path(project, options), html_options
elsif project.archived?
h(project.name)
else
link_to project.name, project_path(project, options), html_options
Jean-Baptiste Barth
Refactor: added link_to_project helper to handle links to projects...
r3810 end
end
Jean-Philippe Lang
Restores commits reverted when rails-4.1 branch was merged (#18174)....
r13122 # Generates a link to a version
def link_to_version(version, options = {})
return '' unless version && version.is_a?(Version)
options = {:title => format_date(version.effective_date)}.merge(options)
link_to_if version.visible?, format_version_name(version), version_path(version), options
end
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 # Helper that formats object for html or text rendering
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 def format_object(object, html=true, &block)
if block_given?
object = yield object
end
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 case object.class.name
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 when 'Array'
object.map {|o| format_object(o, html)}.join(', ').html_safe
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 when 'Time'
format_time(object)
when 'Date'
format_date(object)
when 'Fixnum'
object.to_s
when 'Float'
sprintf "%.2f", object
when 'User'
html ? link_to_user(object) : object.to_s
when 'Project'
html ? link_to_project(object) : object.to_s
when 'Version'
Jean-Philippe Lang
Restores commits reverted when rails-4.1 branch was merged (#18174)....
r13122 html ? link_to_version(object) : object.to_s
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 when 'TrueClass'
l(:general_text_Yes)
when 'FalseClass'
l(:general_text_No)
when 'Issue'
object.visible? && html ? link_to_issue(object) : "##{object.id}"
Jean-Philippe Lang
Adds file custom field format (#6719)....
r15535 when 'Attachment'
html ? link_to_attachment(object, :download => true) : object.filename
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 when 'CustomValue', 'CustomFieldValue'
if object.custom_field
f = object.custom_field.format.formatted_custom_value(self, object, html)
if f.nil? || f.is_a?(String)
f
else
Jean-Philippe Lang
Fixed that Link custom fields are not displayed as links on the issue list (#16496)....
r12779 format_object(f, html, &block)
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 end
else
object.value.to_s
end
Jean-Philippe Lang
Extract generic formatting options to an helper....
r12087 else
html ? h(object) : object.to_s
end
end
Jean-Philippe Lang
Ability to delete a version from a wiki page history (#10852)....
r10493 def wiki_page_path(page, options={})
url_for({:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title}.merge(options))
end
Jean-Philippe Lang
Displays thumbnails of attached images of the issue view (#1006)....
r9750 def thumbnail_tag(attachment)
Jean-Philippe Lang
Adds a named route for thumbnails and use route helper in #thumbnail_tag....
r10958 link_to image_tag(thumbnail_path(attachment)),
named_attachment_path(attachment, attachment.filename),
Jean-Philippe Lang
Displays thumbnails of attached images of the issue view (#1006)....
r9750 :title => attachment.filename
end
Jean-Philippe Lang
Added toggle_link helper....
r429 def toggle_link(name, id, options={})
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 onclick = "$('##{id}').toggle(); "
onclick << (options[:focus] ? "$('##{options[:focus]}').focus(); " : "this.blur(); ")
Jean-Philippe Lang
Added toggle_link helper....
r429 onclick << "return false;"
link_to(name, "#", :onclick => onclick)
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Don't truncate activity titles (#23575)....
r15476 # Used to format item titles on the activity view
Jean-Philippe Lang
Display latest user's activity on account/show view....
r2064 def format_activity_title(text)
Jean-Philippe Lang
Don't truncate activity titles (#23575)....
r15476 text
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)
Jean-Philippe Lang
Fixed time zone issues introduced by r9719 (#10996)....
r9543 date == User.current.today ? l(:label_today).titleize : format_date(date)
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_description(text)
Toshi MARUYAMA
Rails4: replace ActionView::Helpers::TextHelper#truncate by String#truncate at ApplicationHelper#format_activity_description...
r12560 h(text.to_s.truncate(120).gsub(%r{[\r\n]*<(pre|code)>.*$}m, '...')
Toshi MARUYAMA
Rails3: helper: html_safe for "format_activity_description" method...
r7915 ).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)
Jean-Philippe Lang
Restored project name as version prefix when different (#19348)....
r13726 if version.project == @project
Toshi MARUYAMA
replace tabs to spaces at app/helpers/application_helper.rb...
r11190 h(version)
Jean-Philippe Lang
Version sharing (#465) + optional inclusion of subprojects in the roadmap view (#2666)....
r3009 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
Jean-Philippe Lang
Replace Date.today with User.current.today (#22320)....
r14997 l((date < User.current.today ? :label_roadmap_overdue : :label_roadmap_due_in), distance_of_date_in_words(User.current.today, date))
Jean-Philippe Lang
Fixed: Roadmap crashes when a version has a due date > 2037....
r1885 end
end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Extract code to render nested listed of projects in an helper (#11539)....
r10005 # Renders a tree of projects as a nested set of unordered lists
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
Jean-Philippe Lang
Adds a single controller for users and groups memberships and support for adding multiple projects at once (#11702)....
r13116 def render_project_nested_lists(projects, &block)
Jean-Philippe Lang
Extract code to render nested listed of projects in an helper (#11539)....
r10005 s = ''
if projects.any?
ancestors = []
original_project = @project
Jean-Philippe Lang
Removed duplicated helper (#11539)....
r10008 projects.sort_by(&:lft).each do |project|
Jean-Philippe Lang
Extract code to render nested listed of projects in an helper (#11539)....
r10005 # set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
s << "</ul></li>\n"
end
end
classes = (ancestors.empty? ? 'root' : 'child')
s << "<li class='#{classes}'><div class='#{classes}'>"
Jean-Philippe Lang
Adds a single controller for users and groups memberships and support for adding multiple projects at once (#11702)....
r13116 s << h(block_given? ? capture(project, &block) : project.name)
Jean-Philippe Lang
Extract code to render nested listed of projects in an helper (#11539)....
r10005 s << "</div>\n"
ancestors << project
end
s << ("</li></ul>\n" * ancestors.size)
@project = original_project
end
s.html_safe
end
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>"
Jean-Philippe Lang
Wiki page versions routes cleanup....
r10476 content << link_to(h(page.pretty_title), {:controller => 'wiki', :action => 'show', :project_id => page.project, :id => page.title, :version => nil},
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
Jean-Philippe Lang
Show tabs for existing custom field types only and adds a view for choosing the type when adding a new custom field....
r12574 def render_tabs(tabs, selected=params[:tab])
Jean-Philippe Lang
Refactoring of tabs rendering....
r2757 if tabs.any?
Jean-Philippe Lang
Show tabs for existing custom field types only and adds a view for choosing the type when adding a new custom field....
r12574 unless tabs.detect {|tab| tab[:name] == selected}
selected = nil
end
selected ||= tabs.first[:name]
render :partial => 'common/tabs', :locals => {:tabs => tabs, :selected_tab => selected}
Jean-Philippe Lang
Refactoring of tabs rendering....
r2757 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
Use query with custom select for faster rendering of the project drop-down (#19102)....
r13621 projects = User.current.projects.active.select(:id, :name, :identifier, :lft, :rgt).to_a
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 if projects.any?
Etienne Massip
Code cleanup....
r9716 options =
("<option value=''>#{ l(:label_jump_to_a_project) }</option>" +
'<option value="" disabled="disabled">---</option>').html_safe
options << project_tree_options_for_select(projects, :selected => @project) do |p|
{ :value => project_path(:id => p, :jump => current_menu_item) }
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 end
Etienne Massip
Code cleanup....
r9716
Jean-Philippe Lang
Responsive layout for mobile devices (#19097)....
r14435 content_tag( :span, nil, :class => 'jump-box-arrow') +
Etienne Massip
Code cleanup....
r9716 select_tag('project_quick_jump_box', options, :onchange => 'if (this.value != \'\') { window.location = this.value; }')
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 = {})
Jean-Philippe Lang
Let the new time_entry form be submitted without project (#17954)....
r13058 s = ''.html_safe
Jean-Philippe Lang
Adds a :copy_issues permission (#18855)....
r13603 if blank_text = options[:include_blank]
if blank_text == true
blank_text = '&nbsp;'.html_safe
end
s << content_tag('option', blank_text, :value => '')
Jean-Philippe Lang
Let the new time_entry form be submitted without project (#17954)....
r13058 end
Jean-Philippe Lang
Merged nested projects branch. Removes limit on subproject nesting (#594)....
r2302 project_tree(projects) do |project, level|
Etienne Massip
Code cleanup....
r9716 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
Adds pagination to admin project list....
r15373 def project_tree(projects, options={}, &block)
Project.project_tree(projects, options, &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
User groups branch merged....
r2755 def principals_check_box_tags(name, principals)
s = ''
Jean-Philippe Lang
Adds "sorted" scope to Principal and User and sort users/groups properly....
r11029 principals.each do |principal|
Jean-Philippe Lang
Don't generate duplicate ids....
r11114 s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } #{h principal}</label>\n"
Jean-Philippe Lang
User groups branch merged....
r2755 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
Label should be escaped....
r9928 s << content_tag('option', "<< #{l(:label_me)} >>", :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|
Jean-Philippe Lang
Preserve field values on bulk edit failure (#13943)....
r11557 selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected
Jean-Philippe Lang
Adds a optgroup for groups in users/groups select tags....
r6187 (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
Preserve field values on bulk edit failure (#13943)....
r11557 def option_tag(name, text, value, selected=nil, options={})
content_tag 'option', value, options.merge(:value => value, :selected => (value == selected))
end
Toshi MARUYAMA
Rails4: add ApplicationHelper#truncate_single_line_raw method replacing truncate_single_line...
r12555 def truncate_single_line_raw(string, length)
Jean-Philippe Lang
Prevents calling #truncate on nil....
r13515 string.to_s.truncate(length).gsub(%r{[\r\n]+}m, ' ')
Toshi MARUYAMA
Rails4: add ApplicationHelper#truncate_single_line_raw method replacing truncate_single_line...
r12555 end
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-Philippe Lang
Use named route....
r13559 link_to(text, project_activity_path(@project, :from => User.current.time_to_date(time)), :title => format_time(time))
Jean-Philippe Lang
Adds issue last update timestamp (#3565)....
r2703 else
Jean-Philippe Lang
Replaced acronym with abbr tags (#15191)....
r12005 content_tag('abbr', text, :title => format_time(time))
Jean-Philippe Lang
Adds issue last update timestamp (#3565)....
r2703 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
Resourcified trackers....
r7768 def reorder_links(name, url, method = :post)
Jean-Philippe Lang
Deprecates unused stuff (#12909)....
r14956 # TODO: remove associated styles from application.css too
ActiveSupport::Deprecation.warn "Application#reorder_links will be removed in Redmine 4."
Jean-Philippe Lang
Improve accessibility for icon-only links by adding hidden text (#21805)....
r14889 link_to(l(:label_sort_highest),
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 url.merge({"#{name}[move_to]" => 'highest'}), :method => method,
:title => l(:label_sort_highest), :class => 'icon-only icon-move-top') +
Jean-Philippe Lang
Improve accessibility for icon-only links by adding hidden text (#21805)....
r14889 link_to(l(:label_sort_higher),
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 url.merge({"#{name}[move_to]" => 'higher'}), :method => method,
:title => l(:label_sort_higher), :class => 'icon-only icon-move-up') +
Jean-Philippe Lang
Improve accessibility for icon-only links by adding hidden text (#21805)....
r14889 link_to(l(:label_sort_lower),
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 url.merge({"#{name}[move_to]" => 'lower'}), :method => method,
:title => l(:label_sort_lower), :class => 'icon-only icon-move-down') +
Jean-Philippe Lang
Improve accessibility for icon-only links by adding hidden text (#21805)....
r14889 link_to(l(:label_sort_lowest),
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 url.merge({"#{name}[move_to]" => 'lowest'}), :method => method,
:title => l(:label_sort_lowest), :class => 'icon-only icon-move-bottom')
Jean-Philippe Lang
Trackers controller refactoring....
r2462 end
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Lists can be reordered with drag and drop (#12909)....
r14954 def reorder_handle(object, options={})
data = {
:reorder_url => options[:url] || url_for(object),
:reorder_param => options[:param] || object.class.name.underscore
}
content_tag('span', '',
Jean-Philippe Lang
Restyles the sort handle(#12909)....
r14958 :class => "sort-handle",
Jean-Philippe Lang
Adds a title on the sort handle (#12909)....
r14960 :data => data,
:title => l(:button_sort))
Jean-Philippe Lang
Lists can be reordered with drag and drop (#12909)....
r14954 end
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
Merged rails-4.1 branch (#14534)....
r13100 ancestors = (@project.root? ? [] : @project.ancestors.visible.to_a)
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
Jean-Philippe Lang
Add additional markup to page_header_title to enable better styling (#21947)....
r14874 b << content_tag(:span, h(@project), class: 'current-project')
if b.size > 1
separator = content_tag(:span, ' &raquo; '.html_safe, class: 'separator')
path = safe_join(b[0..-2], separator) + separator
b = [content_tag(:span, path.html_safe, class: 'breadcrumbs'), b[-1]]
end
safe_join b
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
Toshi MARUYAMA
replace tab to space at ApplicationHelper...
r11844 # Returns a h2 tag and sets the html title with the given arguments
Jean-Philippe Lang
Adds a helper for building h2 tags and setting html_title (#14517)....
r11818 def title(*args)
strings = args.map do |arg|
if arg.is_a?(Array) && arg.size >= 2
link_to(*arg)
else
h(arg.to_s)
end
end
html_title args.reverse.map {|s| (s.is_a?(Array) ? s.first : s).to_s}
content_tag('h2', strings.join(' &#187; ').html_safe)
end
# Sets the html title
# Returns the html title when called without arguments
# Current project name and app_title and automatically appended
# Exemples:
# html_title 'Foo', 'Bar'
# html_title # => 'Foo - Bar - My Project - Redmine'
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
Adds a helper for building h2 tags and setting html_title (#14517)....
r11818 title.reject(&: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
Adds a project specific css class to body (#14767)....
r11940 css << 'project-' + @project.identifier if @project && @project.identifier.present?
Jean-Philippe Lang
Use controller_name and action_name instead of params....
r8898 css << 'controller-' + controller_name
css << 'action-' + action_name
Jean-Philippe Lang
User preference for monospaced / variable-width font in textareas (#23653)....
r15371 if UserPreference::TEXTAREA_FONT_OPTIONS.include?(User.current.pref.textarea_font)
css << "textarea-#{User.current.pref.textarea_font}"
end
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
Pevents duplicate accesskeys (#12684)....
r11524 @used_accesskeys ||= []
key = Redmine::AccessKeys.key_for(s)
return nil if @used_accesskeys.include?(key)
@used_accesskeys << key
key
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)
Jean-Philippe Lang
Use relative URL for thumbnails according to :only_path option (#18119)....
r13075 @only_path = only_path = options.delete(:only_path) == false ? false : true
Jean-Philippe Lang
Email address should be lowercased for gravatar (#2145)....
r1986
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 text = text.dup
macros = catch_macros(text)
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
Macros processing overhaul (#3061, #11633)....
r10026 text = parse_non_pre_blocks(text, obj, macros) do |text|
[:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].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
Macros processing overhaul (#3061, #11633)....
r10026 def parse_non_pre_blocks(text, obj, macros)
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 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
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 inject_macros(text, obj, macros) if macros.any?
else
inject_macros(text, obj, macros, false) if macros.any?
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 end
parsed << text
if tag
if closing
Jean-Philippe Lang
Fixed unsafe call to #casecmp (#20369, #21000)....
r14294 if tags.last && tags.last.casecmp(tag) == 0
Jean-Philippe Lang
Do not parse redmine links inside pre/code tags (#1288)....
r3475 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
Adds support for macro and Redmine links in PDF export (#13051)....
r13562 return if options[:inline_attachments] == false
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
Code cleanup (#12801)....
r10928 attachments = options[:attachments] || []
attachments += obj.attachments if obj.respond_to?(:attachments)
if attachments.present?
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
Jean-Philippe Lang
Attached inline images with non-ascii file name can not be seen when text formatting is Makdown (#19313)....
r13698 if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 image_url = download_named_attachment_url(found, found.filename, :only_path => only_path)
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
Test failure with JRuby 1.7.2 (#12228)....
r11049 identifier, page = $1, $2
link_project = Project.find_by_identifier(identifier) || Project.find_by_name(identifier)
title ||= identifier if page.blank?
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 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
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper...
r11845 url_for(:only_path => only_path, :controller => 'wiki', :action => 'show', :project_id => link_project,
Jean-Philippe Lang
Wiki page versions routes cleanup....
r10476 :id => wiki_page_id, :version => nil, :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-Baptiste Barth
Document project links in ApplicationHelper#parse_redmine_links (#6689)....
r11573 # Projects:
# project:someproject -> Link to project named "someproject"
# project#3 -> Link to project with id 3
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
Wrong redmine link after referencing an object from a different project (#12930)....
r11028 def parse_redmine_links(text, default_project, obj, attr, only_path, options)
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 text.gsub!(%r{<a( [^>]+?)?>(.*?)</a>|([\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|
Jean-Philippe Lang
Fixed that #parse_redmine_links errors when given a link tag without attributes (#19304)....
r14392 tag_content, leading, esc, project_prefix, project_identifier, prefix, repo_prefix, repo_identifier, sep, identifier, comment_suffix, comment_id = $2, $3, $4, $5, $6, $7, $12, $13, $10 || $14 || $20, $16 || $21, $17, $19
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 if tag_content
$&
else
link = nil
project = default_project
if project_identifier
project = Project.visible.find_by_identifier(project_identifier)
end
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
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 if repo_identifier
Jean-Philippe Lang
Adds support for multiple repositories to redmine links (#779)....
r8574 repository = project.repositories.detect {|repo| repo.identifier == repo_identifier}
else
repository = project.repository
end
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 # 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_raw(changeset.comments, 100))
Jean-Philippe Lang
Adds support for multiple repositories to redmine links (#779)....
r8574 end
Jean-Philippe Lang
Merged Git support branch (r1200 to r1226)....
r1222 end
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 elsif sep == '#'
oid = identifier.to_i
case prefix
when nil
if oid.to_s == identifier &&
Jean-Philippe Lang
Code cleanup....
r13215 issue = Issue.visible.find_by_id(oid)
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 anchor = comment_id ? "note-#{comment_id}" : nil
Jean-Philippe Lang
Use named routes....
r13216 link = link_to("##{oid}#{comment_suffix}",
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 issue_url(issue, :only_path => only_path, :anchor => anchor),
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 :class => issue.css_classes,
Jean-Philippe Lang
Adds tracker name to Redmine issue link titles (#13946)....
r14238 :title => "#{issue.tracker.name}: #{issue.subject.truncate(100)} (#{issue.status.name})")
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'document'
if document = Document.visible.find_by_id(oid)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'version'
if version = Version.visible.find_by_id(oid)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(version.name, version_url(version, :only_path => only_path), :class => 'version')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'message'
Jean-Philippe Lang
Code cleanup....
r13215 if message = Message.visible.find_by_id(oid)
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 link = link_to_message(message, {:only_path => only_path}, :class => 'message')
end
when 'forum'
if board = Board.visible.find_by_id(oid)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(board.name, project_board_url(board.project, board, :only_path => only_path), :class => 'board')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'news'
if news = News.visible.find_by_id(oid)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(news.title, news_url(news, :only_path => only_path), :class => 'news')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'project'
if p = Project.visible.find_by_id(oid)
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
Jean-Philippe Lang
Redmine links can be used to link to documents, versions and attachments....
r1050 end
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 elsif sep == ':'
# removes the double quotes if any
name = identifier.gsub(%r{^"(.*)"$}, "\\1")
name = CGI.unescapeHTML(name)
case prefix
when 'document'
if project && document = project.documents.visible.find_by_title(name)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(document.title, document_url(document, :only_path => only_path), :class => 'document')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'version'
if project && version = project.versions.visible.find_by_name(name)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(version.name, version_url(version, :only_path => only_path), :class => 'version')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'forum'
if project && board = project.boards.visible.find_by_name(name)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(board.name, project_board_url(board.project, board, :only_path => only_path), :class => 'board')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
when 'news'
if project && news = project.news.visible.find_by_title(name)
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 link = link_to(news.title, news_url(news, :only_path => only_path), :class => 'news')
Jean-Philippe Lang
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 end
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.where("repository_id = ? AND scmid LIKE ?", repository.id, "#{name}%").first)
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_raw(changeset.comments, 100)
end
else
if repository && User.current.allowed_to?(:browse_repository, project)
name =~ %r{^[/\\]*(.*?)(@([^/\\@]+?))?(#(L\d+))?$}
path, rev, anchor = $1, $3, $5
link = link_to h("#{project_prefix}#{prefix}:#{repo_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => (prefix == 'export' ? 'raw' : 'entry'), :id => project, :repository_id => repository.identifier_param,
:path => to_path_param(path),
:rev => rev,
:anchor => anchor},
:class => (prefix == 'export' ? 'source download' : 'source')
end
end
repo_prefix = nil
end
when 'attachment'
attachments = options[:attachments] || []
attachments += obj.attachments if obj.respond_to?(:attachments)
if attachments && attachment = Attachment.latest_attach(attachments, name)
link = link_to_attachment(attachment, :only_path => only_path, :download => true, :class => 'attachment')
end
when 'project'
if p = Project.visible.where("identifier = :s OR LOWER(name) = :s", :s => name.downcase).first
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
end
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
Fixed that Redmine links should not be parsed inside links (#18301)....
r13214 (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
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
Parse any heading level (#11789)....
r10111 HEADING_RE = /(<h(\d)( [^>]+)?>(.+?)<\/h(\d)>)/i unless const_defined?(:HEADING_RE)
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709
def parse_sections(text, project, obj, attr, only_path, options)
return unless options[:edit_section_links]
text.gsub!(HEADING_RE) do
Jean-Philippe Lang
Don't use implicit variables later (#21593)....
r14755 heading, level = $1, $2
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
Improve accessibility for icon-only links by adding hidden text (#21805)....
r14889 link_to(l(:button_edit_section), options[:edit_section_links].merge(:section => @current_section),
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 :class => 'icon-only icon-edit'),
Jean-Philippe Lang
Don't use implicit variables later (#21593)....
r14755 :class => "contextual heading-#{level}",
Jean-Philippe Lang
Return to section anchor after wiki section edit (#15182)....
r12009 :title => l(:button_edit_section),
:id => "section-#{@current_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
Macros processing overhaul (#3061, #11633)....
r10026 MACROS_RE = /(
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 (!)? # escaping
(
\{\{ # opening tag
([\w]+) # macro name
Jean-Philippe Lang
Let macros optionally accept a block of text (#3061)....
r10027 (\(([^\n\r]*?)\))? # optional arguments
Jean-Philippe Lang
Fixed: New multi-line macros regexp is too eager (#11736)....
r10093 ([\n\r].*?[\n\r])? # optional block of text
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 \}\} # closing tag
)
Jean-Philippe Lang
Let macros optionally accept a block of text (#3061)....
r10027 )/mx unless const_defined?(:MACROS_RE)
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026
MACRO_SUB_RE = /(
\{\{
macro\((\d+)\)
\}\}
Toshi MARUYAMA
fix typo "MACROS_SUB_RE" (#11736)...
r10094 )/x unless const_defined?(:MACRO_SUB_RE)
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 # Extracts macros from text
def catch_macros(text)
macros = {}
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 text.gsub!(MACROS_RE) do
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 all, macro = $1, $4.downcase
if macro_exists?(macro) || all =~ MACRO_SUB_RE
index = macros.size
macros[index] = all
"{{macro(#{index})}}"
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 else
all
end
end
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 macros
end
# Executes and replaces macros in text
def inject_macros(text, obj, macros, execute=true)
text.gsub!(MACRO_SUB_RE) do
all, index = $1, $2.to_i
orig = macros.delete(index)
if execute && orig && orig =~ MACROS_RE
Jean-Philippe Lang
Let macros optionally accept a block of text (#3061)....
r10027 esc, all, macro, args, block = $2, $3, $4.downcase, $6.to_s, $7.try(:strip)
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 if esc.nil?
Jean-Philippe Lang
Let macros optionally accept a block of text (#3061)....
r10027 h(exec_macro(macro, obj, args, block) || all)
Jean-Philippe Lang
Macros processing overhaul (#3061, #11633)....
r10026 else
h(all)
end
elsif orig
h(orig)
else
h(all)
end
end
Jean-Philippe Lang
Wiki: allows single section edit (#2222)....
r7709 end
Jean-Philippe Lang
Fixed: right-aligned table of contents (TOC) not working with markdown (#16236)....
r12714 TOC_RE = /<p>\{\{((<|&lt;)|(>|&gt;))?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
Jean-Philippe Lang
Fixed: right-aligned table of contents (TOC) not working with markdown (#16236)....
r12714 left_align, right_align = $2, $3
Jean-Philippe Lang
Parse any heading level (#11789)....
r10111 # Keep only the 4 first levels
headings = headings.select{|level, anchor, item| level <= 4}
Jean-Philippe Lang
Extract headings and TOC parsing from the textile formatter....
r4262 if headings.empty?
''
else
div_class = 'toc'
Jean-Philippe Lang
Fixed: right-aligned table of contents (TOC) not working with markdown (#16236)....
r12714 div_class << ' right' if right_align
div_class << ' left' if left_align
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
Cache languages names to avoid loading all translations files....
r10617 (blank ? [["(auto)", ""]] : []) + languages_options
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
Jean-Philippe Lang
Adds "New wiki page" link to create a new wiki page (#5536)....
r14964 # Render the error messages for the given objects
Jean-Philippe Lang
Adds a helper for displaying validation error messages....
r8897 def error_messages_for(*objects)
objects = objects.map {|o| o.is_a?(String) ? instance_variable_get("@#{o}") : o}.compact
errors = objects.map {|o| o.errors.full_messages}.flatten
Jean-Philippe Lang
Adds "New wiki page" link to create a new wiki page (#5536)....
r14964 render_error_messages(errors)
end
# Renders a list of error messages
def render_error_messages(errors)
html = ""
if errors.present?
Jean-Philippe Lang
Adds a helper for displaying validation error messages....
r8897 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
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper...
r11845 end
Jean-Philippe Lang
Adds a helper for displaying validation error messages....
r8897
Jean-Philippe Lang
Deprecated :confirm => 'Text' option....
r9754 def delete_link(url, options={})
options = {
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del'
}.merge(options)
link_to l(:button_delete), url, options
end
Jean-Philippe Lang
Adds a helper for preview links....
r9848 def preview_link(url, form, target='preview', options={})
content_tag 'a', l(:label_preview), {
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper...
r11845 :href => "#",
:onclick => %|submitPreview("#{escape_javascript url_for(url)}", "#{escape_javascript form}", "#{escape_javascript target}"); return false;|,
Jean-Philippe Lang
Adds a helper for preview links....
r9848 :accesskey => accesskey(:preview)
}.merge(options)
end
Jean-Philippe Lang
Adds a replacement for deprecated link_to_function helper....
r9909 def link_to_function(name, function, html_options={})
content_tag(:a, name, {:href => '#', :onclick => "#{function}; return false;"}.merge(html_options))
end
Jean-Philippe Lang
Fixed JSON escaping of filters (#11929)....
r10260 # Helper to render JSON in views
def raw_json(arg)
arg.to_json.to_s.gsub('/', '\/').html_safe
end
Jean-Philippe Lang
Do not use escaped back_url param (#11691)....
r10056 def back_url
url = params[:back_url]
if url.nil? && referer = request.env['HTTP_REFERER']
url = CGI.unescape(referer.to_s)
Jean-Philippe Lang
Removes the UTF8 checkmark that prevents redirect from back_url....
r15153 # URLs that contains the utf8=[checkmark] parameter added by Rails are
# parsed as invalid by URI.parse so the redirect to the back URL would
# not be accepted (ApplicationController#validate_back_url would return
# false)
url.gsub!(/(\?|&)utf8=\u2713&?/, '\1')
Jean-Philippe Lang
Do not use escaped back_url param (#11691)....
r10056 end
url
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
Do not use escaped back_url param (#11691)....
r10056 url = back_url
hidden_field_tag('back_url', url, :id => nil) unless 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
Adds (un)check all buttons to select all projects (#11702)....
r13155 def toggle_checkboxes_link(selector)
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 link_to_function '',
Jean-Philippe Lang
Adds (un)check all buttons to select all projects (#11702)....
r13155 "toggleCheckboxesBySelector('#{selector}')",
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 :title => "#{l(:button_check_all)} / #{l(:button_uncheck_all)}",
:class => 'toggle-checkboxes'
Jean-Philippe Lang
Adds (un)check all buttons to select all projects (#11702)....
r13155 end
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
Tooltip on progress bar (#21497)....
r14645 titles = options[:titles].to_a
titles[0] = "#{pcts[0]}%" if titles[0].blank?
Jean-Philippe Lang
Roadmap: more accurate completion percentage calculation (done ratio of open issues is now taken into account)....
r895 legend = options[:legend] || ''
content_tag('table',
content_tag('tr',
Jean-Philippe Lang
Tooltip on progress bar (#21497)....
r14645 (pcts[0] > 0 ? content_tag('td', '', :style => "width: #{pcts[0]}%;", :class => 'closed', :title => titles[0]) : ''.html_safe) +
(pcts[1] > 0 ? content_tag('td', '', :style => "width: #{pcts[1]}%;", :class => 'done', :title => titles[1]) : ''.html_safe) +
(pcts[2] > 0 ? content_tag('td', '', :style => "width: #{pcts[2]}%;", :class => 'todo', :title => titles[2]) : ''.html_safe)
Jean-Philippe Lang
Improved responsiveness for versions and roadmap (#19097)....
r14469 ), :class => "progress progress-#{pcts[0]}").html_safe +
Jean-Philippe Lang
Deprecates Version#*_pourcent in favour of #*_percent (#12724)....
r10883 content_tag('p', legend, :class => 'percent').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
Jean-Philippe Lang
Replace uses of image_tag() with CSS (#21256)....
r14686 @checked_image_tag ||= content_tag(:span, nil, :class => 'icon-only icon-checked')
Jean-Philippe Lang
Adds an helper for displaying the 'checked' image....
r3486 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
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 javascript_tag "contextMenuInit('#{ url_for(url) }')"
Jean-Philippe Lang
Adds an helper for creating the context menu....
r3428 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
Use HTML5 date input fields instead of text fields with jquery ui date pickers (#19468)....
r14993 javascript_tag("$(function() { $('##{field_id}').addClass('date').datepickerFallback(datepickerOptions); });")
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 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
Jean-Philippe Lang
Merged datepicker.js into application.js....
r13370 tags = ''.html_safe
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300 @calendar_headers_tags_included = true
content_for :header_tags do
Jean-Philippe Lang
Code cleanup (#11814)....
r10190 start_of_week = Setting.start_of_week
start_of_week = l(:general_first_day_of_week, :default => '1') if start_of_week.blank?
# Redmine uses 1..7 (monday..sunday) in settings and locales
# JQuery uses 0..6 (sunday..saturday), 7 needs to be changed to 0
start_of_week = start_of_week.to_i % 7
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653 tags << javascript_tag(
Jean-Philippe Lang
Set the first day of week in the date picker according to settings (#11814)....
r10189 "var datepickerOptions={dateFormat: 'yy-mm-dd', firstDay: #{start_of_week}, " +
Toshi MARUYAMA
remove trailing white-spaces from ApplicationHelper...
r11845 "showOn: 'button', buttonImageOnly: true, buttonImage: '" +
Toshi MARUYAMA
show JQuery datepicker today button...
r10108 path_to_image('/images/calendar.png') +
Toshi MARUYAMA
set default issue start/due datepicker from due/start date (#14024)...
r11653 "', showButtonPanel: true, showWeek: true, showOtherMonths: true, " +
"selectOtherMonths: true, changeMonth: true, changeYear: true, " +
"beforeShow: beforeShowDatePicker};")
Jean-Philippe Lang
Use JQuery Datepicker (#11445)....
r9886 jquery_locale = l('jquery.locale', :default => current_language.to_s)
unless jquery_locale == 'en'
Toshi MARUYAMA
rename jQuery Datepicker i18n file name...
r13051 tags << javascript_include_tag("i18n/datepicker-#{jquery_locale}.js")
Eric Davis
Added a setting to configure the day that week start on (Monday or Sunday). (#4363)...
r3052 end
Jean-Philippe Lang
Use JQuery Datepicker (#11445)....
r9886 tags
Jean-Philippe Lang
Move repetitive calendar include code from views into helper (patch #966 by Peter Suschlik)....
r1300 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
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 super *sources, options
Jean-Philippe Lang
Restores support for :plugin support to stylesheet_link_tag and javascript_include_tag helpers....
r9376 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
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 super *sources, options
Jean-Philippe Lang
Restores support for :plugin support to stylesheet_link_tag and javascript_include_tag helpers....
r9376 end
Jean-Philippe Lang
Fixed that sidebar with hook content only should not be hidden....
r9415 def sidebar_content?
Jean-Philippe Lang
Fixed that the sidebar may be displayed empty (#15414)....
r12079 content_for?(:sidebar) || view_layouts_base_sidebar_hook_response.present?
Jean-Philippe Lang
Fixed that sidebar with hook content only should not be hidden....
r9415 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
Use protocol-relative URL for gravatars (#21855)....
r14863 options.merge!(: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
Jean-Philippe Lang
Add avatar and edit link to "My account" page (#5418)....
r13995 # Returns a link to edit user's avatar if avatars are enabled
def avatar_edit_link(user, options={})
if Setting.gravatar_enabled?
Jean-Philippe Lang
Use https links instead of http links in ApplicationHelper#avatar_edit_link and Redmine::Info class methods (#20243)....
r14031 url = "https://gravatar.com"
Jean-Philippe Lang
Add avatar and edit link to "My account" page (#5418)....
r13995 link_to avatar(user, {:title => l(:button_edit)}.merge(options)), url, :target => '_blank'
end
end
Etienne Massip
Make sure that anchor names generated for headings fully match wiki links (#7215)....
r7443 def sanitize_anchor_name(anchor)
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 anchor.gsub(%r{[^\s\-\p{Word}]}, '').gsub(%r{\s+(\-+\s*)?}, '-')
Etienne Massip
Make sure that anchor names generated for headings fully match wiki links (#7215)....
r7443 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
Responsive layout for mobile devices (#19097)....
r14435 tags = javascript_include_tag('jquery-1.11.1-ui-1.11.0-ujs-3.1.4', 'application', 'responsive')
Jean-Philippe Lang
Warning on leaving a page with unsaved content in textarea (#2910)....
r4780 unless User.current.pref.warn_on_leaving_unsaved == '0'
Jean-Philippe Lang
JQuery in, Prototype/Scriptaculous out (#11445)....
r9885 tags << "\n".html_safe + javascript_tag("$(window).load(function(){ 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
Jean-Philippe Lang
Adds #favicon_path and #favicon_url helpers....
r12386 "<link rel='shortcut icon' href='#{favicon_path}' />".html_safe
end
# Returns the path to the favicon
def favicon_path
icon = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
image_path(icon)
end
# Returns the full URL to the favicon
def favicon_url
# TODO: use #image_url introduced in Rails4
path = favicon_path
base = url_for(:controller => 'welcome', :action => 'index', :only_path => false)
base.sub(%r{/+$},'') + '/' + path.sub(%r{^/+},'')
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
Toshi MARUYAMA
fix typos of source comments at ApplicationHelper...
r12796 # an error when deserializing an array with attributes
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 nil
else
options
end
end
Toshi MARUYAMA
remove trailing white-spaces from application helper source....
r5712
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 def generate_csv(&block)
decimal_separator = l(:general_csv_decimal_separator)
encoding = l(:general_csv_encoding)
end
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
Jean-Philippe Lang
Initial commit...
r2 end