def post_process_request(self, req, template, data, content_type): # pidCrypt add_script(req, "hw/js/pidcrypt/pidcrypt.js", "text/javascript") add_script(req, "hw/js/pidcrypt/pidcrypt_util.js", "text/javascript") add_script(req, "hw/js/pidcrypt/md5.js", "text/javascript") add_script(req, "hw/js/pidcrypt/aes_core.js", "text/javascript") add_script(req, "hw/js/pidcrypt/aes_cbc.js", "text/javascript") add_script(req, "hw/js/pidcrypt/asn1.js", "text/javascript") add_script(req, "hw/js/pidcrypt/jsbn.js", "text/javascript") add_script(req, "hw/js/pidcrypt/rng.js", "text/javascript") add_script(req, "hw/js/pidcrypt/prng4.js", "text/javascript") add_script(req, "hw/js/pidcrypt/rsa.js", "text/javascript") add_script(req, "hw/js/pidcrypt/certparser.js", "text/javascript") # Vex add_script(req, "hw/js/vex.combined.min.js", "text/javascript") add_stylesheet(req, "hw/css/vex.css", "text/css") add_stylesheet(req, "hw/css/vex-theme-default.css", "text/css") add_stylesheet(req, "hw/css/cryptdata-password.css", "text/css") # Plugin code add_script(req, "hw/js/cryptdata-password.js", "text/javascript") # Private key p = Popen(["more", self.private_key_path], stdout=PIPE) key = p.communicate()[0] add_meta(req, key, None, "private_key_encoded") return (template, data, content_type)
def post_process_request(self, req, template, data, content_type): # pidCrypt add_script(req, "hw/js/pidcrypt/pidcrypt.js", "text/javascript") add_script(req, "hw/js/pidcrypt/pidcrypt_util.js", "text/javascript") add_script(req, "hw/js/pidcrypt/md5.js", "text/javascript") add_script(req, "hw/js/pidcrypt/aes_core.js", "text/javascript") add_script(req, "hw/js/pidcrypt/aes_cbc.js", "text/javascript") add_script(req, "hw/js/pidcrypt/asn1.js", "text/javascript") add_script(req, "hw/js/pidcrypt/jsbn.js", "text/javascript") add_script(req, "hw/js/pidcrypt/rng.js", "text/javascript") add_script(req, "hw/js/pidcrypt/prng4.js", "text/javascript") add_script(req, "hw/js/pidcrypt/rsa.js", "text/javascript") add_script(req, "hw/js/pidcrypt/certparser.js", "text/javascript") # Vex add_script(req, "hw/js/vex.combined.min.js", "text/javascript") add_stylesheet(req, "hw/css/vex.css", "text/css") add_stylesheet(req, "hw/css/vex-theme-default.css", "text/css") add_stylesheet(req, "hw/css/cryptdata-password.css", "text/css") # Plugin code add_script(req, "hw/js/cryptdata-password.js", "text/javascript") # Private key cmd = "more %s" % self.private_key_path f = os.popen(cmd) key = f.read().rstrip() add_meta(req, key, None, "private_key_encoded") return (template, data, content_type)
def post_process_request(self, req, template, data, content_type): # send trac project name. # insert a meta tag to trac site. trac_project_name = self.config.get("project", "name") add_meta(req, name="TracProjectTitle", content=trac_project_name) # add javascript add_script(req, 'replacelogo/js/replacelogo.js') return template, data, content_type
def test_add_meta(self): req = Request(href=Href('/trac.cgi')) add_meta(req, 'Jim Smith', name='Author', scheme='test', lang='en-us') add_meta(req, 'Tue, 20 Aug 1996 14:25:27 GMT', http_equiv='Expires') metas = req.chrome['metas'] self.assertEqual(2, len(metas)) meta = metas[0] self.assertEqual('Jim Smith', meta['content']) self.assertEqual('Author', meta['name']) self.assertEqual('test', meta['scheme']) self.assertEqual('en-us', meta['lang']) self.assertEqual('en-us', meta['xml:lang']) meta = metas[1] self.assertEqual('Tue, 20 Aug 1996 14:25:27 GMT', meta['content']) self.assertEqual('Expires', meta['http-equiv'])
def post_process_request(self, req, template, data, content_type): get = self.env.config.get for link in self.links: rel = get(self.section, link + '.rel') href = get(self.section, link + '.href') title = get(self.section, link + '.title') mimetype = get(self.section, link + '.type') classname = get(self.section, link + '.class') if rel and href: add_link(req, rel, href, title or None, mimetype or None, classname or None) for stylesheet in self.stylesheets: filename = get( self.section, stylesheet + '.filename', unicode(self.default_style_base) + stylesheet + '.css') mimetype = get(self.section, stylesheet + '.mimetype', 'text/css') if filename: add_stylesheet(req, filename, mimetype) for script in self.scripts: filename = get(self.section, script + '.filename', unicode(self.default_script_base) + script + '.js') mimetype = get(self.section, script + '.mimetype', 'text/javascript') if filename: add_script(req, filename, mimetype) for meta in self.metas: http_equiv = get(self.section, meta + '.http_equiv', None) name = get(self.section, meta + '.name', meta) scheme = get(self.section, meta + '.scheme', None) lang = get(self.section, meta + '.lang', self.default_meta_lang) content = get(self.section, meta + '.content', u'') if http_equiv or name or scheme: try: add_meta(req, content, http_equiv, name, scheme, lang) except: pass return (template, data, content_type)
def post_process_request(self, req, template, data, content_type): get = self.env.config.get for link in self.links: rel = get(self.section, link + '.rel' ) href = get(self.section, link + '.href' ) title = get(self.section, link + '.title' ) mimetype = get(self.section, link + '.type' ) classname = get(self.section, link + '.class' ) if rel and href: add_link(req, rel, href, title or None, mimetype or None, classname or None) for stylesheet in self.stylesheets: filename = get(self.section, stylesheet + '.filename', unicode(self.default_style_base) + stylesheet + '.css' ) mimetype = get(self.section, stylesheet + '.mimetype', 'text/css') if filename: add_stylesheet(req, filename, mimetype) for script in self.scripts: filename = get(self.section, script + '.filename', unicode(self.default_script_base) + script + '.js' ) mimetype = get(self.section, script + '.mimetype', 'text/javascript') if filename: add_script(req, filename, mimetype) for meta in self.metas: http_equiv = get(self.section, meta + '.http_equiv', None ) name = get(self.section, meta + '.name', meta ) scheme = get(self.section, meta + '.scheme', None ) lang = get(self.section, meta + '.lang', self.default_meta_lang ) content = get(self.section, meta + '.content', u'' ) if http_equiv or name or scheme: try: add_meta(req, content, http_equiv, name, scheme, lang) except: pass return (template, data, content_type)
def post_process_request(self, req, template, data, content_type): """Post process request filter. Removes all trac provided css if required""" #if "TRAC_ADMIN" in req.perm: # add_ctxtnav(req, "Admin", "#", "Admin") add_meta(req, "width=device-width", http_equiv=None, name="viewport", scheme=None, lang=None) if self.is_active_theme: add_stylesheet(req, 'theme/css/foundation.css') add_stylesheet(req, 'theme/css/foundation-icons.css') add_stylesheet(req, 'theme/css/zurb_browser.css') add_stylesheet(req, 'theme/css/zurb_milestone.css') add_stylesheet(req, 'theme/css/zurb_tickets.css') add_stylesheet(req, 'theme/css/zurb_admin_um.css') add_script(req, 'theme/js/custom.modernizr.js') add_script(req, 'theme/js/foundation.min.js') #add_script(req, 'theme/js/jquery.js') #add_script(req, 'theme/js/zepto.js') #add_script(req, 'theme/js/jquery.js') # if data no has the key page means that am not on a wiki page, initialize value o page in "" if not data.has_key('page'): data['page'] = "" #if template is using user manager plugin... if template == "admin_um.html": if data['user_manager'].has_key('panel'): if data['user_manager']['panel'] == "account": data['user_manager'][ 'template'] = "zurb_admin_um_account.html" elif data['user_manager']['panel'] == "permissions": data['user_manager'][ 'template'] = "zurb_admin_um_permissions.html" elif data['user_manager']['panel'] == "profile": data['user_manager'][ 'template'] = "zurb_admin_um_profile.html" if template is None and data is None and sys.exc_info() == (None, None, None): return template, data, content_type links = req.chrome.get('links', {}) #replace favicon if appropriate if self.env.project_icon == 'common/trac.ico': bh_icon = 'theme/img/bh.ico' new_icon = { 'href': req.href.chrome(bh_icon), 'type': get_mimetype(bh_icon) } if links.get('icon'): links.get('icon')[0].update(new_icon) if links.get('shortcut icon'): links.get('shortcut icon')[0].update(new_icon) if self.disable_all_trac_css and self.is_active_theme: if self.disable_all_trac_css: stylesheets = links.get('stylesheet', []) if stylesheets: path = req.base_path + '/chrome/common/css/' _iter = ([ss, ss.get('href', '')] for ss in stylesheets) links['stylesheet'] = [ ss for ss, href in _iter if not href.startswith(path) or href.rsplit('/', 1)[-1] in self.ZURB_KEEP_CSS ] template, modifier = self.ZURB_TEMPLATE_MAP.get( template, (template, None)) if modifier is not None: modifier = getattr(self, modifier) modifier(req, template, data, content_type, self.is_active_theme) # if is_active_theme and data is not None: # data['responsive_layout'] = self.env.config.getbool( # 'bloodhound', 'responsive_layout', 'true') return template, data, content_type
def post_process_request(self, req, template, data, content_type): """Post process request filter. Removes all trac provided css if required""" #if "TRAC_ADMIN" in req.perm: # add_ctxtnav(req, "Admin", "#", "Admin") add_meta(req, "width=device-width", http_equiv=None, name="viewport", scheme=None, lang=None) if self.is_active_theme: add_stylesheet(req, 'theme/css/foundation.css') add_stylesheet(req, 'theme/css/foundation-icons.css') add_stylesheet(req, 'theme/css/zurb_browser.css') add_stylesheet(req, 'theme/css/zurb_milestone.css') add_stylesheet(req, 'theme/css/zurb_tickets.css') add_stylesheet(req, 'theme/css/zurb_admin_um.css') add_script(req, 'theme/js/custom.modernizr.js') add_script(req, 'theme/js/foundation.min.js') #add_script(req, 'theme/js/jquery.js') #add_script(req, 'theme/js/zepto.js') #add_script(req, 'theme/js/jquery.js') # if data no has the key page means that am not on a wiki page, initialize value o page in "" if not data.has_key('page'): data['page'] = ""; #if template is using user manager plugin... if template=="admin_um.html": if data['user_manager'].has_key('panel'): if data['user_manager']['panel'] == "account": data['user_manager']['template'] = "zurb_admin_um_account.html" elif data['user_manager']['panel'] == "permissions": data['user_manager']['template'] = "zurb_admin_um_permissions.html" elif data['user_manager']['panel'] == "profile": data['user_manager']['template'] = "zurb_admin_um_profile.html" if template is None and data is None and sys.exc_info() == (None, None, None): return template, data, content_type links = req.chrome.get('links',{}) #replace favicon if appropriate if self.env.project_icon == 'common/trac.ico': bh_icon = 'theme/img/bh.ico' new_icon = {'href': req.href.chrome(bh_icon), 'type': get_mimetype(bh_icon)} if links.get('icon'): links.get('icon')[0].update(new_icon) if links.get('shortcut icon'): links.get('shortcut icon')[0].update(new_icon) if self.disable_all_trac_css and self.is_active_theme: if self.disable_all_trac_css: stylesheets = links.get('stylesheet',[]) if stylesheets: path = req.base_path + '/chrome/common/css/' _iter = ([ss, ss.get('href', '')] for ss in stylesheets) links['stylesheet'] = [ss for ss, href in _iter if not href.startswith(path) or href.rsplit('/', 1)[-1] in self.ZURB_KEEP_CSS] template, modifier = self.ZURB_TEMPLATE_MAP.get( template, (template, None)) if modifier is not None: modifier = getattr(self, modifier) modifier(req, template, data, content_type, self.is_active_theme) # if is_active_theme and data is not None: # data['responsive_layout'] = self.env.config.getbool( # 'bloodhound', 'responsive_layout', 'true') return template, data, content_type