def filter_stream(self, req, method, filename, stream, data): """ Add Site Admin link to user header area. """ home_perm = PermissionCache(HomeProject().get_env(), username=req.authname) if 'USER_AUTHOR' not in home_perm and 'USER_CREATE' not in home_perm: return stream # Add following link into user header trans = Transformer('//div[@id="login_link"]/a[@class="author"]')\ .after(tag.a('Site admin', href="#", class_="site_admin"))\ .after(tag.span('|', class_="sep")) return stream | trans
def filter_stream(self, req, method, filename, stream, data): """ Adds project follower information in project summary block:: Followers: You and 1 other Followers: You and 10 others Followers: 10 """ # Filter only the summary table wiki macro if filename != 'multiproject_summary.html': return stream # Load project and followers info project = Project.get(self.env) watchers, is_watching = self._get_status(req, project.id) # By default show only the number status = tag.span(watchers) # Show link to user preferences if is_watching: status = tag.a('You', href=req.href('../home/prefs/following')) # And others? watchers -= 1 if watchers: status += ngettext(" and %(count)s other", " and %(count)s others", watchers, count=watchers) # Add following information into project summary block trans = Transformer('//div[@class="summary"]/table').append( tag.tr( tag.th('Followers:'), tag.td(status) ) ) return stream | trans