本文整理汇总了Python中tractags.api.TagEngine.get_tag_link方法的典型用法代码示例。如果您正苦于以下问题:Python TagEngine.get_tag_link方法的具体用法?Python TagEngine.get_tag_link怎么用?Python TagEngine.get_tag_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tractags.api.TagEngine
的用法示例。
在下文中一共展示了TagEngine.get_tag_link方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import get_tag_link [as 别名]
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
示例2: render_listtags
# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import get_tag_link [as 别名]
def render_listtags(self, req, *tags, **kwargs):
""" List tags. For backwards compatibility, can accept a list of tags.
This will simply call ListTagged. Optional keyword arguments are
tagspace=wiki, tagspaces=(wiki, ticket, ...) and shownames=true. """
if tags:
# Backwards compatibility
return self.render_listtagged(req, *tags, **kwargs)
page = self._current_page(req)
engine = TagEngine(self.env)
showpages = kwargs.get('showpages', None) or kwargs.get('shownames', 'false')
if 'tagspace' in kwargs:
tagspaces = [kwargs['tagspace']]
else:
tagspaces = kwargs.get('tagspaces', []) or \
list(TagEngine(self.env).tagspaces)
out = StringIO()
out.write('<ul class="listtags">\n')
tag_details = {}
for tag, names in sorted(engine.get_tags(tagspaces=tagspaces, detailed=True).iteritems()):
href, title = engine.get_tag_link(tag)
htitle = wiki_to_oneliner(title, self.env)
out.write('<li><a href="%s" title="%s">%s</a> %s <span class="tagcount">(%i)</span>' % (href, title, tag, htitle, len(names)))
if showpages == 'true':
out.write('\n')
out.write(self.render_listtagged(req, tag, tagspaces=tagspaces))
out.write('</li>\n')
out.write('</ul>\n')
return out.getvalue()
示例3: _wiki_view
# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import get_tag_link [as 别名]
def _wiki_view(self, req, stream):
tags = self._page_tags(req)
if not tags:
return stream
engine = TagEngine(self.env)
add_stylesheet(req, 'tags/css/tractags.css')
li = []
for tag in tags:
href, title = engine.get_tag_link(tag)
li.append(T.li(T.a(title=title, href=href)(tag), ' '))
insert = T.ul(class_='tags')(T.lh('Tags'), li)
return stream | Transformer('//div[@class="buttons"]').before(insert)
示例4: _prepare_wiki
# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import get_tag_link [as 别名]
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
示例5: render_listtags
# 需要导入模块: from tractags.api import TagEngine [as 别名]
# 或者: from tractags.api.TagEngine import get_tag_link [as 别名]
def render_listtags(self, req, *tags, **kwargs):
""" List all tags.
||'''Argument'''||'''Description'''||
||`tagspace=<tagspace>`||Specify the tagspace the macro should operate on.||
||`tagspaces=(<tagspace>,...)`||Specify a set of tagspaces the macro should operate on.||
||`shownames=true|false`||Whether to show the objects that tags appear on ''(long)''.||
"""
if tags:
# Backwards compatibility
return self.render_listtagged(req, *tags, **kwargs)
page = self._current_page(req)
engine = TagEngine(self.env)
showpages = kwargs.get('showpages', None) or kwargs.get('shownames', 'false')
if 'tagspace' in kwargs:
tagspaces = [kwargs['tagspace']]
else:
tagspaces = kwargs.get('tagspaces', []) or \
list(TagEngine(self.env).tagspaces)
out = StringIO()
out.write('<ul class="listtags">\n')
tag_details = {}
for tag, names in sorted(engine.get_tags(tagspaces=tagspaces, detailed=True).iteritems()):
href, title = engine.get_tag_link(tag)
htitle = wiki_to_oneliner(title, self.env)
out.write('<li><a href="%s" title="%s">%s</a> %s <span class="tagcount">(%i)</span>' % (href, title, tag, htitle, len(names)))
if showpages == 'true':
out.write('\n')
out.write(self.render_listtagged(req, tag, tagspaces=tagspaces))
out.write('</li>\n')
out.write('</ul>\n')
return out.getvalue()