Project

General

Profile

Feature #2069 ยป rm2069.patch

Mischa The Evil, 2017-09-17 02:07

View differences:

app/helpers/application_helper.rb (working copy)
# user:jsmith -> Link to user with login jsmith
# @jsmith -> Link to user with login jsmith
# user#2 -> Link to user with id 2
# Files:
# file#1 -> Link to file with id 1
# file:filename.ext -> Link to file with filename "filename.ext"
# file:"filename.ext" -> Link to file with filename "filename.ext"
#
# Links can refer other objects from other projects, using project identifier:
# identifier:r52
......
when 'user'
u = User.visible.where(:id => oid, :type => 'User').first
link = link_to_user(u, :only_path => only_path) if u
when 'file'
if project && file = Attachment.find_by_id(oid)
if (file.container.is_a?(Version) && file.container.project == project) ||
(file.container.is_a?(Project) && file.container == project)
name = file.filename
link = link_to(h(name), { :only_path => only_path, :controller => 'attachments', :action => 'download', :id => file },
:class => 'attachment')
end
end
end
elsif sep == ':'
name = remove_double_quotes(identifier)
......
when 'user'
u = User.visible.where(:login => name, :type => 'User').first
link = link_to_user(u, :only_path => only_path) if u
when 'file'
if project
conditions = "container_type = 'Project' AND container_id = #{project.id}"
if project.versions.any?
conditions = "(#{conditions}) OR "
conditions << "(container_type = 'Version' AND container_id IN (#{project.versions.collect{ |version| version.id }.join(', ')}))"
end
if file = Attachment.where(conditions).find_by_filename(name)
name = file.filename
link = link_to(h(name), { :only_path => only_path, :controller => 'attachments', :action => 'download', :id => file },
:class => 'attachment')
end
end
end
elsif sep == "@"
name = remove_double_quotes(identifier)
......
(?<leading>[\s\(,\-\[\>]|^)
(?<esc>!)?
(?<project_prefix>(?<project_identifier>[a-z0-9\-_]+):)?
(?<prefix>attachment|document|version|forum|news|message|project|commit|source|export|user)?
(?<prefix>attachment|document|version|forum|news|message|project|commit|source|export|user|file)?
(
(
(?<sep1>\#)|
    (1-1/1)