Patch #11332 ยป file.diff
| lib/redmine/wiki_formatting/macros.rb (working copy) | ||
|---|---|---|
|
|
||
|
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|
|
||
|
page = Wiki.find_page(args.first.to_s, :project => @project)
|
||
|
parts = args.first.to_s.split('?')
|
||
|
version = parts[1] ? parts[1].scan(/\d+/)[0].to_i : nil
|
||
|
page = Wiki.find_page(parts[0], :project => @project)
|
||
|
raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
|
||
|
@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, :headings => false)
|
||
|
out = textilizable(page.content_for_version(version), :text, :attachments => page.attachments, :headings => false)
|
||
|
@included_wiki_pages.pop
|
||
|
out
|
||
|
end
|
||