本文整理汇总了Python中trac.web.chrome.Chrome.authorinfo方法的典型用法代码示例。如果您正苦于以下问题:Python Chrome.authorinfo方法的具体用法?Python Chrome.authorinfo怎么用?Python Chrome.authorinfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.web.chrome.Chrome
的用法示例。
在下文中一共展示了Chrome.authorinfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_timeline_markup
# 需要导入模块: from trac.web.chrome import Chrome [as 别名]
# 或者: from trac.web.chrome.Chrome import authorinfo [as 别名]
def get_timeline_markup(self, req, call, maxrows=10):
"""
Generates the markup needed when this component is called both
explicitly inside wiki pages and implicitly by the ISideBarBoxProvider.
Note this code uses methods from the trac TimelineModule module.
"""
chrome = Chrome(self.env)
# last 14 days should be enough
stop = datetime.now(req.tz)
start = stop - timedelta(days=50)
# use code from trac/timeline to generate event data
timeline = TimelineModule(self.env)
available_filters, filters = timeline.get_filters(req)
include_authors, exclude_authors = timeline.authors()
events = timeline.get_events(req, start, stop, filters, available_filters,
include_authors, exclude_authors, maxrows)
show_gravatar = self.config.get('avatar','mode').lower() != 'off'
# create the mark up
context = Context.from_request(req)
event_list = tag.ul(class_="timeline-list no-style")
for event in events:
event_title = event['render']('title', context)
event_url = event['render']('url', context)
event_list.append(tag.li(
show_gravatar and tag.img(
src=req.href.avatar(event['author'] if event['author'] else 'anonymous'),
class_="avatar",
) or "",
tag.span(
chrome.authorinfo(req, event['author']),
class_="author"
),
tag.span(
pretty_age(event['date']),
class_="date",
),
tag.div(
tag.i(class_="event-type fa fa-" + event['kind']),
tag.a(
event_title,
href=event_url,
),
class_="event-summary"
),
class_="cf"
))
# if the markup is being generated via ISideBarBoxProvider we don't
# need to add a span3 class
div_classes = "box-sidebar"
if call == "macro":
div_classes += " span3 right"
return tag.div(
tag.h3(
tag.i(
class_="fa fa-calendar"
),
" Recent Project Activity"
),
event_list,
class_=div_classes,
)