Project

General

Profile

Patch #2174 » macros.rb.patch

Jan Topiński, 2008-11-13 10:44

View differences:

lib/redmine/wiki_formatting/macros.rb (kopia robocza)
content_tag('dl', out)
end
desc "Displays a list of child pages."
desc "Displays page name and list of child pages. When no parameter is given only current page child pages are displayed. Example:\n\n !{{child_pages(Foo)}}\n\nresults in:\n \n* [[Foo]]\n** [[bar 1]]\n** [[bar 2]]\n\nwhile:\n\n !{{child_pages}}\n\nwill result on page [[Foo]] with:\n\n** [[bar 1]]\n** [[bar 2]]"
macro :child_pages do |obj, args|
raise 'This macro applies to wiki pages only.' unless obj.is_a?(WikiContent)
render_page_hierarchy(obj.page.descendants.group_by(&:parent_id), obj.page.id)
if args.size > 0 then
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)
#collect descendants and root
pages = (page.descendants+[page]).group_by(&:parent_id)
render_page_hierarchy(pages, page.parent_id)
else
raise 'This macro applies to wiki pages only.' unless obj.is_a?(WikiContent)
page = obj.page
#retain orginal rendering without root page
render_page_hierarchy(page.descendants.group_by(&:parent_id), page.id)
end
end
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)}}"
(2-2/2)