def render_macro(self, req, name, args): # Args seperated by commas: # prefix,level # # Page Name prefix to search for. # how many 'levels' in the hierarchy to go down. prefix = req.hdf.getValue('wiki.page_name', '') + '/' level = 0 if args: args = args.replace('\'', '\'\'') args = args.split(',') if args[0] != 'None': prefix = args[0] if len(args) > 1 and args[1] != 'None': level = int(args[1]) pages = WikiSystem(self.env).get_pages(prefix) good_pages = [] for p in pages: if level: len_name = p.split('/') if len(len_name) > level+1: continue page = WikiPage(self.env, p) md = self.TITLE_RE.search(page.text) title = '' if md: title = md.group(1) good_pages.append((p, title)) return html.UL([html.LI(html.A(p, title=t, href=req.href.wiki(p)), ' ', t) for p,t in good_pages])
def render_macro(self, req, name, content): prefix = content or None wiki = WikiSystem(self.env) return html.UL([html.LI(html.A(wiki.format_page_name(page), href=req.href.wiki(page))) for page in sorted(wiki.get_pages(prefix))])
def render_macro(self, req, name, content): search = prefix = limit = skips = None if not content: return html.H2('Need to specify a search') if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) < 1: return html.H2('Need to specify a search') search = argv[0] if len(argv) > 1: prefix = argv[1] if len(argv) > 2: limit = argv[2] if len(argv) > 3: skips = argv[3] db = self.env.get_db_cnx() cursor = db.cursor() sql = 'SELECT name, max_version FROM (' \ 'SELECT name as name, text as text, ' \ ' max(version) AS max_version, ' \ ' max(time) AS max_time ' \ 'FROM wiki ' args = [] if prefix: sql += 'WHERE name LIKE %s' args.append(prefix + '%') if skips: if prefix: sql += ' AND ' sql += 'name != %s' args.append(skips) sql += ' GROUP BY name ORDER BY max_time ASC' if limit: sql += ' LIMIT %s' args.append(limit) sql += ') AS temptable WHERE text LIKE %s' args.append('%' + search + '%') cursor.execute(sql, args) wiki = WikiSystem(self.env) return html.DIV( html.UL([ html.LI( html.A(wiki.format_page_name(name), href=req.href.wiki(name))) for name, version in cursor ]))
def get_timeline_events(self, req, start, stop, filters): if 'changeset' in filters: format = req.args.get('format') wiki_format = self.wiki_format_messages show_files = self.timeline_show_files db = self.env.get_db_cnx() repos = self.env.get_repository(req.authname) for chgset in repos.get_changesets(start, stop): message = chgset.message or '--' if wiki_format: shortlog = wiki_to_oneliner(message, self.env, db, shorten=True) else: shortlog = shorten_line(message) if format == 'rss': title = Markup('Changeset [%s]: %s', chgset.rev, shortlog) href = req.abs_href.changeset(chgset.rev) if wiki_format: message = wiki_to_html(message, self.env, req, db, absurls=True) else: message = html.PRE(message) else: title = Markup('Changeset <em>[%s]</em> by %s', chgset.rev, chgset.author) href = req.href.changeset(chgset.rev) if wiki_format: if self.timeline_long_messages: message = wiki_to_html(message, self.env, req, db, absurls=True) else: message = wiki_to_oneliner(message, self.env, db, shorten=True) else: message = shortlog if show_files and req.perm.has_permission('BROWSER_VIEW'): files = [] for chg in chgset.get_changes(): if show_files > 0 and len(files) >= show_files: files.append(html.LI(Markup('…'))) break files.append(html.LI(html.DIV(class_=chg[2]), chg[0] or '/')) message = html.UL(files, class_="changes") + message yield 'changeset', href, title, chgset.date, chgset.author,\ message
def render_macro(self, req, name, content): prefix = limit = None if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) > 0: prefix = argv[0] if len(argv) > 1: limit = int(argv[1]) db = self.env.get_db_cnx() cursor = db.cursor() sql = 'SELECT name, ' \ ' max(version) AS max_version, ' \ ' max(time) AS max_time ' \ 'FROM wiki' args = [] if prefix: sql += ' WHERE name LIKE %s' args.append(prefix + '%') sql += ' GROUP BY name ORDER BY max_time DESC' if limit: sql += ' LIMIT %s' args.append(limit) cursor.execute(sql, args) entries_per_date = [] prevdate = None for name, version, time in cursor: date = format_date(time) if date != prevdate: prevdate = date entries_per_date.append((date, [])) entries_per_date[-1][1].append((name, int(version))) wiki = WikiSystem(self.env) return html.DIV( [html.H3(date) + html.UL([html.LI( html.A(wiki.format_page_name(name), href=req.href.wiki(name)), ' ', version > 1 and html.SMALL('(', html.A('diff', href=req.href.wiki(name, action='diff', version=version)), ')') \ or None) for name, version in entries]) for date, entries in entries_per_date])