Wiki links for news and forums (#9600).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7840 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1bf492c30e
commit
9ac86d4f4e
|
@ -639,7 +639,7 @@ module ApplicationHelper
|
|||
# identifier:version:1.0.0
|
||||
# identifier:source:some/file
|
||||
def parse_redmine_links(text, project, obj, attr, only_path, options)
|
||||
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
||||
text.gsub!(%r{([\s\(,\-\[\>]|^)(!)?(([a-z0-9\-]+):)?(attachment|document|version|forum|news|commit|source|export|message|project)?((#|r)(\d+)|(:)([^"\s<>][^\s<>]*?|"[^"]+?"))(?=(?=[[:punct:]]\W)|,|\s|\]|<|$)}) do |m|
|
||||
leading, esc, project_prefix, project_identifier, prefix, sep, identifier = $1, $2, $3, $4, $5, $7 || $9, $8 || $10
|
||||
link = nil
|
||||
if project_identifier
|
||||
|
@ -676,6 +676,16 @@ module ApplicationHelper
|
|||
if message = Message.visible.find_by_id(oid, :include => :parent)
|
||||
link = link_to_message(message, {:only_path => only_path}, :class => 'message')
|
||||
end
|
||||
when 'forum'
|
||||
if board = Board.visible.find_by_id(oid)
|
||||
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||||
:class => 'board'
|
||||
end
|
||||
when 'news'
|
||||
if news = News.visible.find_by_id(oid)
|
||||
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||||
:class => 'news'
|
||||
end
|
||||
when 'project'
|
||||
if p = Project.visible.find_by_id(oid)
|
||||
link = link_to_project(p, {:only_path => only_path}, :class => 'project')
|
||||
|
@ -695,6 +705,16 @@ module ApplicationHelper
|
|||
link = link_to h(version.name), {:only_path => only_path, :controller => 'versions', :action => 'show', :id => version},
|
||||
:class => 'version'
|
||||
end
|
||||
when 'forum'
|
||||
if project && board = project.boards.visible.find_by_name(name)
|
||||
link = link_to h(board.name), {:only_path => only_path, :controller => 'boards', :action => 'show', :id => board, :project_id => board.project},
|
||||
:class => 'board'
|
||||
end
|
||||
when 'news'
|
||||
if project && news = project.news.visible.find_by_title(name)
|
||||
link = link_to h(news.title), {:only_path => only_path, :controller => 'news', :action => 'show', :id => news},
|
||||
:class => 'news'
|
||||
end
|
||||
when 'commit'
|
||||
if project && project.repository && (changeset = Changeset.visible.find(:first, :conditions => ["repository_id = ? AND scmid LIKE ?", project.repository.id, "#{name}%"]))
|
||||
link = link_to h("#{project_prefix}#{name}"), {:only_path => only_path, :controller => 'repositories', :action => 'revision', :id => project, :rev => changeset.identifier},
|
||||
|
|
|
@ -27,6 +27,9 @@ class Board < ActiveRecord::Base
|
|||
validates_length_of :name, :maximum => 30
|
||||
validates_length_of :description, :maximum => 255
|
||||
|
||||
named_scope :visible, lambda {|*args| { :include => :project,
|
||||
:conditions => Project.allowed_to_condition(args.shift || User.current, :view_messages, *args) } }
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_messages, project)
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
:repositories, :changesets,
|
||||
:trackers, :issue_statuses, :issues, :versions, :documents,
|
||||
:wikis, :wiki_pages, :wiki_contents,
|
||||
:boards, :messages,
|
||||
:boards, :messages, :news,
|
||||
:attachments,
|
||||
:enumerations
|
||||
|
||||
|
@ -163,7 +163,11 @@ RAW
|
|||
version_link = link_to('1.0', {:controller => 'versions', :action => 'show', :id => 2},
|
||||
:class => 'version')
|
||||
|
||||
board_url = {:controller => 'boards', :action => 'show', :id => 2, :project_id => 'ecookbook'}
|
||||
|
||||
message_url = {:controller => 'messages', :action => 'show', :board_id => 1, :id => 4}
|
||||
|
||||
news_url = {:controller => 'news', :action => 'show', :id => 1}
|
||||
|
||||
project_url = {:controller => 'projects', :action => 'show', :id => 'subproject1'}
|
||||
|
||||
|
@ -198,9 +202,15 @@ RAW
|
|||
'source:/some/file.ext#L110' => link_to('source:/some/file.ext#L110', source_url_with_ext.merge(:anchor => 'L110'), :class => 'source'),
|
||||
'source:/some/file@52#L110' => link_to('source:/some/file@52#L110', source_url.merge(:rev => 52, :anchor => 'L110'), :class => 'source'),
|
||||
'export:/some/file' => link_to('export:/some/file', source_url.merge(:format => 'raw'), :class => 'source download'),
|
||||
# forum
|
||||
'forum#2' => link_to('Discussion', board_url, :class => 'board'),
|
||||
'forum:Discussion' => link_to('Discussion', board_url, :class => 'board'),
|
||||
# message
|
||||
'message#4' => link_to('Post 2', message_url, :class => 'message'),
|
||||
'message#5' => link_to('RE: post 2', message_url.merge(:anchor => 'message-5', :r => 5), :class => 'message'),
|
||||
# news
|
||||
'news#1' => link_to('eCookbook first release !', news_url, :class => 'news'),
|
||||
'news:"eCookbook first release !"' => link_to('eCookbook first release !', news_url, :class => 'news'),
|
||||
# project
|
||||
'project#3' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
|
||||
'project:subproject1' => link_to('eCookbook Subproject 1', project_url, :class => 'project'),
|
||||
|
|
Loading…
Reference in New Issue