annotate data/plugin/macro/CollectLists.py @ 353:51772c48c3eb

CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 05 Feb 2009 08:38:49 +0100
parents 2b139cd6c4d7
children 8b431b302c79
rev   line source
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - macro to collect data from definition lists from subpages pages
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4 into a databrowser widget table
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6 <<CollectLists>>
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
7 will create a table column for every subpage of the current page and fills in
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
8 the data from each key value pair
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 optional you can give the template page the definition list page depends on
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 or the column_heading. In the latter case the order is used. Also it can optionally use
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 another pagename. By setting optional a parser one can use e.g. wikimarkup. By
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 filter_selection you can optional use the filter method of the databrowser widget.
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
13 By using a different filter_column_value than '', eg. name:: Cohen you get only rows shown where that
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
14 name was found.
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
16 @copyright: 2006 by michael cohen <scudette@users.sourceforge.net> (PageDicts)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17 @copyright: 2008-2009 by MoinMoin:ReimarBauer (completly rewritten)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 @license: GNU GPL, see COPYING for details.
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 """
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20 import re
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 from MoinMoin import wikiutil
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 from MoinMoin.Page import Page
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 from MoinMoin.util.dataset import TupleDataset, Column
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 from MoinMoin.wikidicts import Dict
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 from MoinMoin.widget.browser import DataBrowserWidget
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 Dependencies = ["pages"]
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
29 def macro_CollectLists(macro, pagename=unicode,
349
33cb55aaa955 CollectLists: keyword align introduced
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 348
diff changeset
30 align=("left", "center", "right"),
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
31 column_heading=u'', template=u'',
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
32 transpose=False,
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
33 filter_column_value=u'',
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34 parser=u'text_moin_wiki',
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 filter_selection=u'NeverExistingDefaultFilter'):
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
37 """
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38 currently we don't support transpose together with filter_selection
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39 """
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 request = macro.request
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 formatter = macro.formatter
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 try:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 WikiParser = wikiutil.importPlugin(request.cfg, 'parser', parser, function="Parser")
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45 except wikiutil.PluginMissingError:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 WikiParser = None
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 if not pagename:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
49 pagename = formatter.page.page_name
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
50
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
51 if filter_column_value and ':: ' in filter_column_value:
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
52 filter_key, filter_word = filter_column_value.split('::')
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
53 filter_key = filter_key.strip()
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
54 filter_word = filter_word.strip()
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
55 else:
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
56 # Don't filter if syntax was wrong
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
57 filter_column_value = u''
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
58
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59 needle = '^%s/(.*)' % pagename
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 filterfn = re.compile(needle).search
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
61 pages = request.rootpage.getPageList(exists=1, filter=filterfn)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62 if not pages:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 return ""
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 # only one level of subpages is used (no Template pages)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 filterfn = request.cfg.cache.page_template_regexact.search
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 templates = request.rootpage.getPageList(filter=filterfn)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 subpages = [page for page in pages if page not in templates]
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 if subpages:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69 subpages.sort()
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 # use selection and order
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 if column_heading:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73 column_heading_keys = [key.strip() for key in column_heading.split(',')]
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 # use keys from template page
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
75 elif Page(request, template).exists():
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76 page = Page(request, template)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 page_dict = Dict(request, template)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
78 column_heading_keys = page_dict.keys()
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79 else:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 # fallback use the keys of the first subpage
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
81 page = Page(request, subpages[0])
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
82 page_dict = Dict(request, subpages[0])
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 column_heading_keys = page_dict.keys()
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
85 data = TupleDataset()
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86 data.columns = []
349
33cb55aaa955 CollectLists: keyword align introduced
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 348
diff changeset
87 data.columns.extend([Column(pagename.strip('/'), label=pagename.strip('/'), align=align)])
351
402214f6607c CollectLists: flagged not to use transpose with filter_pattern. removing of a column isn't implemented yet.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 350
diff changeset
88 # may be transpose should be moved into the databrowser widget
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89 if transpose:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
90 data.addRow([pagename.strip('/')] + column_heading_keys)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
91
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 for name in subpages:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
93 page = Page(request, name)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 page_dict = Dict(request, name)
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
95 if filter_column_value and page_dict.get(filter_key, '') != filter_word:
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
96 continue
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
97 row = []
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
98 keep = False
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 for key in column_heading_keys:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 if key in page_dict.keys():
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 value = page_dict.get(key, '')
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 if WikiParser:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103 # xxx check how our brand new Image class solves this
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 if parser == u'text_moin_wiki':
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 value = value.replace('attachment:', 'attachment:%s/' % name)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 row.append((wikiutil.renderText(request, WikiParser, value), wikiutil.escape(value, 1)))
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 else:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
108 row.append((wikiutil.escape(value, 1), wikiutil.escape(value, 1)))
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 else:
347
a701beab4b9c CollectLists: empty cells fixed
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 346
diff changeset
110 row.append('')
346
c8f59d078d98 CollectLists: support more than only one level
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 345
diff changeset
111 parent, child = name.split('/', 1)
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
112 link = page.link_to(request, text="/%s" % child)
353
51772c48c3eb CollectLists: replaced filter_pattern by filter_column_value. You can preselect rows to show up only if a key value pair is equal to a given definition e.g. filter_column_value=project:: 1.7-extensions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 352
diff changeset
113 data.addRow([link] + row)
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 if transpose:
349
33cb55aaa955 CollectLists: keyword align introduced
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 348
diff changeset
115 data.columns.extend([Column(link, label=link, align=align)])
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
116
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 if transpose:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
118 data.data = map(None, zip(*data.data))
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 data.data = data.data[1:]
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 else:
350
2eda7e0194e5 CollectLists: flagged not to use transpose with filter_selection
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 349
diff changeset
121 if filter_selection and not transpose:
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 filtercols = filter_selection.split(',')
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
123 for key in column_heading_keys:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 key = key.strip()
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 if key in filtercols:
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 data.columns.append(Column(key, autofilter=(key in filtercols)))
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
127 else:
349
33cb55aaa955 CollectLists: keyword align introduced
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 348
diff changeset
128 data.columns.extend([Column(key, label=key, align=align)])
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
129
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 table = DataBrowserWidget(request)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 table.setData(data)
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 html = ''.join(table.format(method='GET'))
352
2b139cd6c4d7 CollectLists: verified sortable.js and extended comment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 351
diff changeset
133 # seems to work together with
2b139cd6c4d7 CollectLists: verified sortable.js and extended comment
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 351
diff changeset
134 # http://moinmo.in/FeatureRequests/SortableTables?action=AttachFile&do=view&target=common.js.patch
345
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 # html = html.replace('id="dbw.table"', 'class="sortable" id="dbw.table"')
630b3cfb01dc CollectLists: macro to collect data from definition lists from subpages pages into a databrowser widget table.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136 return html