| 21 | | # TODO: Everything until render_macro can be removed once switched to be based on WikiMacroBase |
|---|
| 22 | | implements(IWikiMacroProvider) |
|---|
| 23 | | |
|---|
| 24 | | def get_macros(self): |
|---|
| 25 | | """Yield the name of the macro based on the class name.""" |
|---|
| 26 | | name = self.__class__.__name__ |
|---|
| 27 | | if name.endswith('Macro'): |
|---|
| 28 | | name = name[:-5] |
|---|
| 29 | | yield name |
|---|
| 30 | | |
|---|
| 31 | | def get_macro_description(self, name): |
|---|
| 32 | | """Return the subclass's docstring.""" |
|---|
| 33 | | return inspect.getdoc(self.__class__) |
|---|
| 34 | | |
|---|
| | 24 | TITLE_RE = re.compile(r'=+\s([^=]*)=+') |
|---|
| | 25 | |
|---|
| 73 | | # Get the latest revision only. |
|---|
| 74 | | sql = 'SELECT name,text from wiki where name = \'%s\' order by version desc limit 1' % name |
|---|
| 75 | | cs.execute(sql) |
|---|
| 76 | | while 1: |
|---|
| 77 | | csrow = cs.fetchone() |
|---|
| 78 | | if csrow == None: |
|---|
| 79 | | break |
|---|
| 80 | | name = csrow[0] |
|---|
| 81 | | text = csrow[1] |
|---|
| 82 | | (linktext,title,desc) = self._getinfo(db,name) |
|---|
| 83 | | |
|---|
| 84 | | link = self.env.href.wiki(name) |
|---|
| 85 | | |
|---|
| 86 | | buf.write('<li><a title="%s" href="%s">' % (title,link)) |
|---|
| 87 | | buf.write(linktext) |
|---|
| 88 | | buf.write('</a> %s</li>\n' % desc) |
|---|
| 89 | | buf.write('</ul>') |
|---|
| 90 | | |
|---|
| 91 | | return buf.getvalue() |
|---|
| 92 | | |
|---|
| 93 | | def _getinfo(self, db, name): |
|---|
| 94 | | cs = db.cursor() |
|---|
| 95 | | desc = name |
|---|
| 96 | | # Get the latest revision only. |
|---|
| 97 | | cs.execute('SELECT text from wiki where name = \'%s\' order by version desc limit 1' % name) |
|---|
| 98 | | csrow = cs.fetchone() |
|---|
| 99 | | prefix = '' |
|---|
| 100 | | |
|---|
| 101 | | if csrow != None: |
|---|
| 102 | | text = csrow[0] |
|---|
| 103 | | m = re.search('=+\s([^=]*)=+',text) |
|---|
| 104 | | if m != None: |
|---|
| 105 | | desc = string.strip(m.group(1)) |
|---|
| 106 | | else: |
|---|
| 107 | | prefix = "Create " |
|---|
| 108 | | |
|---|
| 109 | | title = StringIO() |
|---|
| 110 | | title.write("%s%s"%(prefix, desc)) |
|---|
| 111 | | if prefix != '' or desc == name: |
|---|
| 112 | | desc = '' |
|---|
| 113 | | |
|---|
| 114 | | return (name,title.getvalue(),desc) |
|---|
| | 49 | page = WikiPage(self.env, p) |
|---|
| | 50 | md = self.TITLE_RE.search(page.text) |
|---|
| | 51 | title = '' |
|---|
| | 52 | if md: |
|---|
| | 53 | title = md.group(1) |
|---|
| | 54 | good_pages.append((p, title)) |
|---|
| | 55 | return html.UL([html.LI(html.A(t, title=t, href=req.href.wiki(p))) for p,t in good_pages]) |
|---|
| | 56 | |
|---|