| Revision 2591,
1.1 KB
checked in by moschny, 8 years ago
(diff) |
|
Adding conf and wiki-macros directories
|
| Line | |
|---|
| 1 | """ |
|---|
| 2 | Inserts an alphabetic list of sub-wiki pages into the output. |
|---|
| 3 | A sub-wiki page is a page that is is deeper in the hierachy than the current page. e.g. if the current page is People, the this will return a list of all wiki entries that start with "People/" |
|---|
| 4 | |
|---|
| 5 | Accepts a prefix string as parameter: if provided, only pages with names that |
|---|
| 6 | start with the prefix are included in the resulting list. If this parameter is |
|---|
| 7 | omitted, all pages are listed. |
|---|
| 8 | """ |
|---|
| 9 | |
|---|
| 10 | from StringIO import StringIO |
|---|
| 11 | |
|---|
| 12 | def execute(hdf, args, env): |
|---|
| 13 | db = env.get_db_cnx() |
|---|
| 14 | cursor = db.cursor() |
|---|
| 15 | |
|---|
| 16 | prefix = None |
|---|
| 17 | if args: |
|---|
| 18 | prefix = args.replace('\'', '\'\'') |
|---|
| 19 | else : |
|---|
| 20 | prefix = hdf.getValue('wiki.page_name', '') + '/' |
|---|
| 21 | |
|---|
| 22 | sql = 'SELECT DISTINCT name FROM wiki ' |
|---|
| 23 | if prefix: |
|---|
| 24 | sql += 'WHERE name LIKE \'%s%%\' ' % prefix |
|---|
| 25 | sql += 'ORDER BY name' |
|---|
| 26 | cursor.execute(sql) |
|---|
| 27 | |
|---|
| 28 | buf = StringIO() |
|---|
| 29 | buf.write('<ul>') |
|---|
| 30 | while 1: |
|---|
| 31 | row = cursor.fetchone() |
|---|
| 32 | if row == None: |
|---|
| 33 | break |
|---|
| 34 | buf.write('<li><a href="%s">' % env.href.wiki(row[0])) |
|---|
| 35 | buf.write(row[0]) |
|---|
| 36 | buf.write('</a></li>\n') |
|---|
| 37 | buf.write('</ul>') |
|---|
| 38 | |
|---|
| 39 | return buf.getvalue() |
|---|
Note: See
TracBrowser
for help on using the repository browser.