changeset 564:6aefd777e2dd

ListPages: list_type of content introduced. It renders the selected pages content instead of the page titles.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 07 Jun 2011 08:35:12 +0200
parents de89a01a1bc2
children 03bb9b27aca8
files data/plugin/macro/ListPages.py
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/data/plugin/macro/ListPages.py	Fri Apr 08 09:34:23 2011 +0200
+++ b/data/plugin/macro/ListPages.py	Tue Jun 07 08:35:12 2011 +0200
@@ -14,6 +14,7 @@
 
 import re
 from MoinMoin import search, wikiutil
+from MoinMoin.Page import Page
 
 def _subpage(pagename):
     """
@@ -23,7 +24,7 @@
     segments = pagename.split('/')
     return segments[-1]
 
-def macro_ListPages(macro, search_term=u'.+', list_type=("number_list", "bullet_list"),
+def macro_ListPages(macro, search_term=u'.+', list_type=("number_list", "bullet_list", "content"),
                     link=("pagename", "subpage"), reverse=False):
     """
     lists pages
@@ -56,7 +57,8 @@
              ret = [''.join([f.listitem(1),
                    f.url(1, href=page.url(macro.request, escape=0)),
                    _subpage(page.page_name),
-                   f.url(0)]) for page in pageobjs]   
+                   f.url(0)]) for page in pageobjs]
+
         ret.sort()
         if reverse:
             ret.reverse()
@@ -64,6 +66,18 @@
             ret = ''.join([f.number_list(1), ''.join(ret), f.number_list(0)])
         if list_type == "bullet_list":
             ret = ''.join([f.bullet_list(1), ''.join(ret), f.bullet_list(0)])
+
+        if list_type == "content":
+            pagenames = [page.page_name for page in pageobjs]
+            pagenames.sort()
+            if reverse:
+                pagenames.reverse()
+            for pagename in pagenames:
+                macro.request.page = Page(macro.request, pagename)
+                # renders selected pages content 
+                Page(macro.request, pagename).send_page(emit_headers=False, content_only=True)
+            ret = ""
+
     except ValueError:
         # same error as in MoinMoin/action/fullsearch.py, keep it that way!
         ret = ''.join([macro.formatter.text('<<PageList('),