def filter_stream(self, req, method, filename, stream, data): if filename == 'browser.html' and req.method == 'GET': # we can only work from the 'dir' view at the moment if data.get('file'): return stream # TODO check that contextmenu's InternalNameHolder is enabled, as our js needs it? add_stylesheet(req, 'sourcesharer/filebox.css') add_javascript(req, 'sourcesharer/filebox.js') # Render the filebox template for stream insertion # TODO introduce a new interface to allow putting extra buttons into this filebox? tmpl = TemplateLoader(self.get_templates_dirs()).load('filebox.html') filebox = tmpl.generate(href=req.href, reponame=data['reponame'] or '', rev=data['rev'], files=[]) # Wrap and float dirlist table, add filebox div # TODO change the id names, left/right seems a bit generic to assume we can have to ourselves stream |= Transformer('//table[@id="dirlist"]').wrap(tag.div(id="outer",style="clear:both")).wrap(tag.div(id="left")) stream |= Transformer('//div[@id="outer"]').append(tag.div(filebox, id="right")) is_svn_repo = False if 'repos' in data: is_svn_repo = isinstance(data.get('repos'), (SvnCachedRepository, SubversionRepository)) or False if is_svn_repo: add_ctxtnav(req, tag.a(_(tag.i(class_="fa fa-envelope-o")), " Send", href="", title=_("Send selected files"), id='share-files', class_='alt-button share-files-multiple'), category='ctxtnav', order=10) return stream