def process_request(self, req): from tractags.macros import TagMacros from tractags.parseargs import parseargs from trac.web.chrome import add_stylesheet add_stylesheet(req, 'tags/css/tractags.css') req.hdf['trac.href.tags'] = self.env.href.tags() if req.path_info == '/tags': index = self.env.config.get('tags', 'index', 'cloud') index_kwargs = {'smallest': 10, 'biggest': 30} _, config_kwargs = parseargs(self.env.config.get('tags', 'index.args', '')) index_kwargs.update(config_kwargs) index_kwargs.update(req.args) if index == 'cloud': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_tagcloud(req, **index_kwargs)) elif index == 'list': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, **index_kwargs)) else: raise TracError("Invalid index style '%s'" % index) else: _, args = parseargs(self.env.config.get('tags', 'listing.args', '')) args.update(req.args) tag = req.path_info[6:] req.hdf['tag.name'] = tag req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, tag, **args)) return 'tags.cs', None
def process_request(self, req): from tractags.macros import TagMacros from tractags.parseargs import parseargs from trac.web.chrome import add_stylesheet req.perm.require('TAGS_VIEW') add_stylesheet(req, 'tags/css/tractags.css') data = {} def update_from_req(args): for k in req.args.keys(): args[k] = unicode(req.args.get(k)) if not req.args.has_key('e') and re.match('^/tags/?$', req.path_info): index = self.env.config.get('tags', 'index', 'cloud') index_kwargs = {'smallest': 10, 'biggest': 30} _, config_kwargs = parseargs( self.env.config.get('tags', 'index.args', '')) index_kwargs.update(config_kwargs) update_from_req(index_kwargs) if index == 'cloud': data['tag_body'] = Markup( TagMacros(self.env).render_tagcloud(req, **index_kwargs)) elif index == 'list': data['tag_body'] = Markup( TagMacros(self.env).render_listtagged(req, **index_kwargs)) else: raise TracError("Invalid index style '%s'" % index) else: _, args = parseargs(self.env.config.get('tags', 'listing.args', '')) if req.args.has_key('e'): expr = req.args.get('e') else: expr = req.path_info[6:] data['tag_title'] = Markup( 'Objects matching the expression <i>%s</i>' % escape(expr)) data['tag_expression'] = expr try: Expression(expr) except Exception, e: data['tag_expression_error'] = unicode(e).replace( ' (line 1)', '') args['expression'] = expr tags = [] update_from_req(args) data['tag_body'] = Markup( TagMacros(self.env).render_listtagged(req, *tags, **args))
def process_request(self, req): from tractags.macros import TagMacros from tractags.parseargs import parseargs from trac.web.chrome import add_stylesheet req.perm.require('TAGS_VIEW') add_stylesheet(req, 'tags/css/tractags.css') data = {} def update_from_req(args): for k in req.args.keys(): args[k] = unicode(req.args.get(k)) if not req.args.has_key('e') and re.match('^/tags/?$', req.path_info): index = self.env.config.get('tags', 'index', 'cloud') index_kwargs = {'smallest': 10, 'biggest': 30} _, config_kwargs = parseargs(self.env.config.get('tags', 'index.args', '')) index_kwargs.update(config_kwargs) update_from_req(index_kwargs) if index == 'cloud': data['tag_body'] = Markup( TagMacros(self.env).render_tagcloud(req, **index_kwargs)) elif index == 'list': data['tag_body'] = Markup( TagMacros(self.env).render_listtagged(req, **index_kwargs)) else: raise TracError("Invalid index style '%s'" % index) else: _, args = parseargs(self.env.config.get('tags', 'listing.args', '')) if req.args.has_key('e'): expr = req.args.get('e') else: expr = req.path_info[6:] data['tag_title'] = Markup('Objects matching the expression <i>%s</i>' % escape(expr)) data['tag_expression'] = expr try: Expression(expr) except Exception, e: data['tag_expression_error'] = unicode(e).replace(' (line 1)', '') args['expression'] = expr tags = [] update_from_req(args) data['tag_body'] = Markup( TagMacros(self.env).render_listtagged(req, *tags, **args))
def _split_macro_args(self, argv): """Return a list of arguments and a dictionary of keyword arguments """ args = [] kwargs = {} if argv: args, kwargs = parseargs(argv) return args, kwargs
def process_request(self, req): from tractags.macros import TagMacros from tractags.parseargs import parseargs from trac.web.chrome import add_stylesheet add_stylesheet(req, 'tags/css/tractags.css') req.hdf['trac.href.tags'] = self.env.href.tags() def update_from_req(args): for k in req.args.keys(): args[str(k)] = str(req.args.get(k)) if re.match('^/tags/?$', req.path_info): index = self.env.config.get('tags', 'index', 'cloud') index_kwargs = {'smallest': 10, 'biggest': 30} _, config_kwargs = parseargs(self.env.config.get('tags', 'index.args', '')) index_kwargs.update(config_kwargs) update_from_req(index_kwargs) if index == 'cloud': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_tagcloud(req, **index_kwargs)) elif index == 'list': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, **index_kwargs)) else: raise TracError("Invalid index style '%s'" % index) else: expression_space = self.env.config.getbool('tags', 'expression_space', 'false') _, args = parseargs(self.env.config.get('tags', 'listing.args', '')) if expression_space: req.hdf['tag.title'] = Markup('Objects matching the expression <i>%s</i>' % req.path_info[6:]) args['expression'] = req.path_info[6:] tags = [] else: req.hdf['tag.title'] = Markup('Objects tagged <i>%s</i>' % req.path_info[6:]) tags = re.split('[,+]', req.path_info[6:]) update_from_req(args) req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, *tags, **args)) return 'tags.cs', None
def process_request(self, req): from tractags.macros import TagMacros from tractags.parseargs import parseargs from trac.web.chrome import add_stylesheet add_stylesheet(req, 'tags/css/tractags.css') req.hdf['trac.href.tags'] = self.env.href.tags() def update_from_req(args): for k in req.args.keys(): args[str(k)] = str(req.args.get(k)) if req.path_info == '/tags': index = self.env.config.get('tags', 'index', 'cloud') index_kwargs = {'smallest': 10, 'biggest': 30} _, config_kwargs = parseargs( self.env.config.get('tags', 'index.args', '')) index_kwargs.update(config_kwargs) update_from_req(index_kwargs) if index == 'cloud': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_tagcloud(req, **index_kwargs)) elif index == 'list': req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, **index_kwargs)) else: raise TracError("Invalid index style '%s'" % index) else: _, args = parseargs(self.env.config.get('tags', 'listing.args', '')) update_from_req(args) tag = req.path_info[6:] tags = tag.split(',') req.hdf['tag.name'] = tag req.hdf['tag.body'] = Markup( TagMacros(self.env).render_listtagged(req, *tags, **args)) return 'tags.cs', None
def _get_params(self, req=None, content=None): tags = [] kwargs = {} if content: tags, kwargs = parseargs(content) elif req: tags = get_env_val('tag', req) kwargs = {} for key in req.args.keys(): if key != 'tag': kwargs[key] = req.args[key] continue if not tags: tags = get_env_val('default_tag', config=self.env.config, section='blog', default='blog', convert=list_val) return tags, kwargs