def process_request(self, req): from tractags.api import TagEngine from trac.web.chrome import add_stylesheet add_stylesheet(req, 'tags/css/tractags.css') pagename = req.args.get('page', 'WikiStart') action = req.args.get('action', 'view') engine = TagEngine(self.env) wikitags = engine.tagspace.wiki tags = list(wikitags.get_tags([pagename])) tags.sort() if action == 'edit': req.hdf['tags'] = req.args.get('tags', ', '.join(tags)) elif action == 'view': hdf_tags = [] for tag in tags: href, title = engine.get_tag_link(tag) hdf_tags.append({'name': tag, 'href': href, 'title': title}) req.hdf['tags'] = hdf_tags result = WikiModule.process_request(self, req) if result is None: return None if result[0] == 'wiki.cs': return 'tagswiki.cs', None return result
def _prepare_wiki(self, req): from tractags.api import TagEngine page = req.path_info[6:] or 'WikiStart' engine = TagEngine(self.env) wikitags = engine.tagspace.wiki tags = list(wikitags.get_tags(page)) tags.sort() action = req.args.get('action', 'view') if action == 'edit': req.hdf['tags'] = req.args.get('tags', ', '.join(tags)) elif action == 'view': hdf_tags = [] for tag in tags: href, title = engine.get_tag_link(tag) hdf_tags.append({'name': tag, 'href': href, 'title': title}) req.hdf['tags'] = hdf_tags
def tag_data(): engine = TagEngine(self.env) for t in tags: href, title = engine.get_tag_link(t) yield t, href, title