603 |
603 |
# identifier:version:1.0.0
|
604 |
604 |
# identifier:source:some/file
|
605 |
605 |
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
606 |
|
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
|
606 |
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|board|news|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
607 |
607 |
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
608 |
608 |
link = nil
|
609 |
609 |
if project_identifier
|
... | ... | |
640 |
640 |
if message = Message.visible.find_by_id(oid, :include => :parent)
|
641 |
641 |
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
642 |
642 |
end
|
|
643 |
when 'board'
|
|
644 |
if board = Board.visible.find_by_id(oid)
|
|
645 |
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
646 |
:class => 'board'
|
|
647 |
end
|
|
648 |
when 'news'
|
|
649 |
if news = News.visible.find_by_id(oid)
|
|
650 |
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
651 |
:class => 'news'
|
|
652 |
end
|
643 |
653 |
when 'project'
|
644 |
654 |
if p = Project.visible.find_by_id(oid)
|
645 |
655 |
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
... | ... | |
659 |
669 |
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
660 |
670 |
:class => 'version'
|
661 |
671 |
end
|
|
672 |
when 'board'
|
|
673 |
if project && board = project.boards.visible.find_by_name(name)
|
|
674 |
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
|
675 |
:class => 'board'
|
|
676 |
end
|
|
677 |
when 'news'
|
|
678 |
if project && news = project.news.visible.find_by_title(name)
|
|
679 |
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
|
680 |
:class => 'news'
|
|
681 |
end
|
662 |
682 |
when 'commit'
|
663 |
683 |
if project && project.repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", project.repository.id, "#{name}%"]))
|
664 |
684 |
link = link_to h("#{project_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|