640 |
640 |
# identifier:version:1.0.0
|
641 |
641 |
# identifier:source:some/file
|
642 |
642 |
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
643 |
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
|
643 |
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-_]+):)?(attachment|document|version|forum|news|message|project|commit|source|export|user)?(((#)|((([a-z0-9\-]+)\|)?(r)))((\d+)((#note)?-(\d+))?)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]][^A-Za-z0-9_/])|,|\s|\]|<|$)}) do |m|
|
644 |
644 |
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
645 |
645 |
link = nil
|
646 |
646 |
if project_identifier
|
... | ... | |
691 |
691 |
if p = Project.visible.find_by_id(oid)
|
692 |
692 |
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
693 |
693 |
end
|
|
694 |
when 'user'
|
|
695 |
if u = User.find_by_id(oid)
|
|
696 |
link = link_to_user(u)
|
|
697 |
end
|
694 |
698 |
end
|
695 |
699 |
elsif sep == ':'
|
696 |
700 |
# removes the double quotes if any
|
... | ... | |
743 |
747 |
if p = Project.visible.find(:first, :conditions => ["identifier = :s OR LOWER(name) = :s", {:s => name.downcase}])
|
744 |
748 |
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
745 |
749 |
end
|
|
750 |
when 'user'
|
|
751 |
if u = User.find_by_login(name)
|
|
752 |
link = link_to_user(u)
|
|
753 |
end
|
746 |
754 |
end
|
747 |
755 |
end
|
748 |
756 |
end
|