diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-13 16:22:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-04-13 16:22:55 +0000 |
commit | 0329094f015bcc2036fc1a2545253b8e187ee794 (patch) | |
tree | 5a567aa9129358b572d83784357d1992018ca196 /lib | |
parent | e64443571552e46fa1ecc34833e6f765b816a837 (diff) | |
download | redmine-0329094f015bcc2036fc1a2545253b8e187ee794.tar.gz redmine-0329094f015bcc2036fc1a2545253b8e187ee794.zip |
Include macro can include a page of another project wiki using !{{include(projectname:Foo)}} (#1052).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1350 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/wiki_formatting/macros.rb | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index f27ea98b9..0848aee4e 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -77,21 +77,24 @@ module Redmine content_tag('dl', out) end - desc "Include a wiki page. Example:\n\n !{{include(Foo)}}" + desc "Include a wiki page. Example:\n\n !{{include(Foo)}}\n\nor to include a page of a specific project wiki:\n\n !{{include(projectname:Foo)}}" macro :include do |obj, args| - if @project && !@project.wiki.nil? - page = @project.wiki.find_page(args.first) - if page && page.content - @included_wiki_pages ||= [] - raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title) - @included_wiki_pages << page.title - out = textilizable(page.content, :text, :attachments => page.attachments) - @included_wiki_pages.pop - out - else - raise "Page #{args.first} doesn't exist" - end + project = @project + title = args.first.to_s + if title =~ %r{^([^\:]+)\:(.*)$} + project_identifier, title = $1, $2 + project = Project.find_by_identifier(project_identifier) || Project.find_by_name(project_identifier) end + raise 'Unknow project' unless project && User.current.allowed_to?(:view_wiki_pages, project) + raise 'No wiki for this project' unless !project.wiki.nil? + page = project.wiki.find_page(title) + raise "Page #{args.first} doesn't exist" unless page && page.content + @included_wiki_pages ||= [] + raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.title) + @included_wiki_pages << page.title + out = textilizable(page.content, :text, :attachments => page.attachments) + @included_wiki_pages.pop + out end end end |