def expand_macro(self, formatter, name, args): env = formatter.env req = formatter.req arg = args.split('||') duedate = arg[0].strip() summary = arg[1].strip() effort = arg[2].strip() user = req.args['user'] project = req.args['project'] db = env.get_db_cnx() cursor = db.cursor() sql = "SELECT id, owner, summary, description, status FROM ticket WHERE summary=%s" cursor.execute(sql, [summary]) row = cursor.fetchone() if row == None: link = html.A( escape(summary), href= "%s?field_summary=%s&field_type=task&field_duedate=%s&field_effort=%s&field_owner=%s&field_project=%s" % (env.href.newticket(), escape(summary), escape(duedate), escape(effort), escape(user), escape(project))) else: user = row[1] link = html.A("#%s %s" % (row[0], escape(row[2])), href=env.href.ticket(row[0]), class_=row[4]) req.args['effort'] = req.args['effort'] + float(effort) return html.TR(html.TD(escape(user)), html.TD(duedate), html.TD(link), html.TD(effort))
def render_macro(self, req, name, content): from trac.util import sorted from trac.util.html import html as _ interwikis = [] for k in sorted(self.keys()): prefix, url, title = self[k] interwikis.append({ 'prefix': prefix, 'url': url, 'title': title, 'rc_url': self._expand_or_append(url, ['RecentChanges']), 'description': title == prefix and url or title }) return _.TABLE(_.TR(_.TH(_.EM("Prefix")), _.TH(_.EM("Site"))), [ _.TR(_.TD(_.A(w['prefix'], href=w['rc_url'])), _.TD(_.A(w['description'], href=w['url']))) for w in interwikis ], class_="wiki interwiki")
def get_navigation_items(self, req): if req.authname and req.authname != 'anonymous': yield ('metanav', 'login', 'logged in as %s' % req.authname) yield ('metanav', 'logout', html.A('Logout', href=req.href.logout())) else: yield ('metanav', 'login', html.A('Login', href=req.href.login()))
def _format_link(self, formatter, ns, target, label): link, params, fragment = formatter.split_link(target) ids = link.split(':', 2) if len(ids) == 3: parent_type, parent_id, filename = ids else: # FIXME: the formatter should know which object the text being # formatter belongs to parent_type, parent_id = 'wiki', 'WikiStart' if formatter.req: path_info = formatter.req.path_info.split('/', 2) if len(path_info) > 1: parent_type = path_info[1] if len(path_info) > 2: parent_id = path_info[2] filename = link href = formatter.href() try: attachment = Attachment(self.env, parent_type, parent_id, filename) if formatter.req: href = attachment.href(formatter.req) + params return html.A(label, class_='attachment', href=href, title='Attachment %s' % attachment.title) except TracError: return html.A(label, class_='missing attachment', rel='nofollow', href=formatter.href())
def get_navigation_items(self, req): if req.authname and req.authname != 'anonymous': yield ('metanav', 'login', u'%s 登陆' % req.authname) yield ('metanav', 'logout', html.A(u'注销', href=req.href.logout())) else: yield ('metanav', 'login', html.A(u'登陆', href=req.href.login()))
def get_navigation_items(self, req): patchman = self.env[PatchMan] if patchman.is_jenkins_enabled(): self.env.log.debug("Patch manager is enabled.") yield ('mainnav', 'buildstatus', html.A('Build Status', href=req.href.buildstatus())) yield ('mainnav', 'patchmanager', html.A('Patch Manager', href=req.href.patchmanager()))
def get_navigation_items(self, req): if req.authname and req.authname != 'anonymous': yield ('metanav', 'login', u'connecté sous %s' % req.authname) yield ('metanav', 'logout', html.A(u'Déconnexion', href=req.href.logout())) else: yield ('metanav', 'login', html.A(u'Connexion', href=req.href.login()))
def get_navigation_items(self, req): if not req.perm.has_permission('WIKI_VIEW'): return yield ('mainnav', 'wiki', html.A('Home', href=req.href.wiki(), accesskey=1)) yield ('metanav', 'help', html.A('Help/Guide', href=req.href.wiki('TracGuide'), accesskey=6))
def get_navigation_items(self, req): from trac.ticket.report import ReportModule if req.perm.has_permission('TICKET_VIEW') and \ not self.env.is_component_enabled(ReportModule): yield ('mainnav', 'tickets', html.A('View Tickets', href=req.href.query())) elif req.perm.has_permission('TICKET_BATCH_MODIFY'): yield ('mainnav', 'query', html.A('Custom Query', href=req.href.query()))
def _make_ext_link(self, formatter, url, text, target=""): """Formatter._make_ext_link with target attr """ if not url.startswith(formatter._local): return html.A(html.SPAN(text, class_="icon"), class_="ext-link", href=url, target=target or None) else: return html.A(text, href=url, target=target or None) pass
def _format_link(self, formatter, ns, query, label): if query.startswith('?'): return html.A(label, class_='query', href=formatter.href.query() + query.replace(' ', '+')) else: try: query = Query.from_string(formatter.env, query) return html.A(label, href=query.get_href(formatter), # Hack class_='query') except QuerySyntaxError, e: return html.EM('[Error: %s]' % e, class_='error')
def get_navigation_items(self, req): if not req.perm.has_permission('WIKI_VIEW'): return yield ( 'mainnav', 'wiki', # 导航名字 导航地址 html.A('维基', href=req.href.wiki(), accesskey=1)) # 帮助链接为什么会在这里的? yield ('metanav', 'help', html.A(u'帮助', href=req.href.wiki('ZhTracGuide'), accesskey=6))
def generate_prefix(prefix): intertrac = intertracs[prefix] if isinstance(intertrac, basestring): yield html.TR(html.TD(html.B(prefix)), html.TD('Alias pour ', html.B(intertrac))) else: url = intertrac.get('url', '') if url: title = intertrac.get('title', url) yield html.TR(html.TD(html.A(html.B(prefix), href=url + '/timeline')), html.TD(html.A(title, href=url)))
def _format_link(self, formatter, ns, page, label, ignore_missing): page, query, fragment = formatter.split_link(page) href = formatter.href.wiki(page) + fragment if not self.has_page(page): if ignore_missing: return label return html.A(label + '?', href=href, class_='missing wiki', rel='nofollow') else: return html.A(label, href=href, class_='wiki')
def get_navigation_items(self, req): if req.authname and req.authname != 'anonymous': yield ('metanav', 'login', 'logged in as %s' % req.authname) yield ('metanav', 'logout', html.A('Logout', href=self.master_href.logout( referer=req.href(req.path_info)))) else: yield ('metanav', 'login', html.A('Login', href=self.master_href.login( referer=req.href(req.path_info))))
def get_navigation_items(self, req): if req.authname and req.authname != 'anonymous': yield ('metanav', 'login', 'logged in as %s' % req.authname) yield ('metanav', 'logout', html.A('Logout', href=req.href.logout())) else: shortname = os.path.basename(self.env.path) page = req.path_info[1:] or 'wiki/WikiStart' url = 'https://www.emulab.net/gototrac.php3?login=1&wiki=%s&do=%s' % ( shortname, page) yield ('metanav', 'login', html.A('Login', href=url)) pass pass
def render_macro(self, req, name, content): prefix = limit = None if content: argv = [arg.strip() for arg in content.split(',')] if len(argv) > 0: prefix = argv[0] if len(argv) > 1: limit = int(argv[1]) db = self.env.get_db_cnx() cursor = db.cursor() sql = 'SELECT name, ' \ ' max(version) AS max_version, ' \ ' max(time) AS max_time ' \ 'FROM wiki' args = [] if prefix: sql += ' WHERE name LIKE %s' args.append(prefix + '%') sql += ' GROUP BY name ORDER BY max_time DESC' if limit: sql += ' LIMIT %s' args.append(limit) cursor.execute(sql, args) entries_per_date = [] prevdate = None for name, version, time in cursor: date = format_date(time) if date != prevdate: prevdate = date entries_per_date.append((date, [])) entries_per_date[-1][1].append((name, int(version))) wiki = WikiSystem(self.env) return html.DIV( [html.H3(date) + html.UL([html.LI( html.A(wiki.format_page_name(name), href=req.href.wiki(name)), ' ', version > 1 and html.SMALL('(', html.A('diff', href=req.href.wiki(name, action='diff', version=version)), ')') \ or None) for name, version in entries]) for date, entries in entries_per_date])
def render_macro(self, req, name, args): # Args seperated by commas: # prefix,level # # Page Name prefix to search for. # how many 'levels' in the hierarchy to go down. prefix = req.hdf.getValue('wiki.page_name', '') + '/' level = 0 if args: args = args.replace('\'', '\'\'') args = args.split(',') if args[0] != 'None': prefix = args[0] if len(args) > 1 and args[1] != 'None': level = int(args[1]) pages = WikiSystem(self.env).get_pages(prefix) good_pages = [] for p in pages: if level: len_name = p.split('/') if len(len_name) > level+1: continue page = WikiPage(self.env, p) md = self.TITLE_RE.search(page.text) title = '' if md: title = md.group(1) good_pages.append((p, title)) return html.UL([html.LI(html.A(p, title=t, href=req.href.wiki(p)), ' ', t) for p,t in good_pages])
def get_navigation_items(self, req): """ hijack the original Trac's 'New Ticket' handler to ticket template """ if not req.perm.has_permission('TICKET_CREATE'): return yield ('mainnav', 'newticket', html.A(u'New Ticket', href= req.href.newtplticket()))
def get_navigation_items(self, req): if not req.perm.has_permission('TICKET_CREATE'): return yield ('mainnav', 'newticket', html.A(u'Nouveau ticket', href=req.href.newticket(), accesskey=7))
def _format_link(self, formatter, ns, target, label): path, query, fragment = formatter.split_link(target) if query: href = formatter.href.search() + query.replace(' ', '+') else: href = formatter.href.search(q=path) return html.A(label, class_='search', href=href)
def get_navigation_items(self, req): """ hijack the original Trac's 'New Ticket' handler to ticket template """ if not req.perm.has_permission('WIKI_VIEW'): return yield ('mainnav', 'keylist', html.A(u'KeyList', href=req.href.keylist()))
def _format_link(self, formatter, ns, page, label): # copied and modified from trac/wiki/api.py page, query, fragment = formatter.split_link(page) link = False if self.wikisys.has_page(page): link = True elif page[-1] == 's' and self.wikisys.has_page(page[:-1]): # if the page name ends in 's', see if there is a wiki page with the same name minus the 's' # if there is, it will be linked page = page[:-1] link = True href = formatter.href.wiki(page)+fragment if link: return html.A(label, href=href, class_='wiki') else: return html.A(label+'?', href=href, class_='missing wiki', rel='nofollow')
def _format_link(self, formatter, ns, path, label): path, rev, line = get_path_rev_line(path) fragment = '' if line is not None: fragment = '#L%d' % line return html.A(label, class_='source', href=formatter.href.browser(path, rev=rev) + fragment)
def _format_term(self, formatter, ns, target, label): wiki = WikiSystem(self.env) page = self._wiki_prefix + target href = formatter.href.wiki(page) link_label = label if wiki.has_page(page): if not link_label: link_label = self._term_desc(target) return html.A(wiki.format_page_name(link_label), href=href) else: if not link_label: link_label = self._term_ns + ":" + target return html.A(wiki.format_page_name(link_label) + "?", href=href, class_="missing wiki", rel="nofollow")
def linkify_ids(env, req, ids): return Markup(', '.join([ unicode( html.A('#%s' % i, href=req.href.ticket(i), class_='%s ticket' % Ticket(env, i)['status'])) for i in ids ]))
def render_macro(self, req, name, content): prefix = content or None wiki = WikiSystem(self.env) return html.UL([html.LI(html.A(wiki.format_page_name(page), href=req.href.wiki(page))) for page in sorted(wiki.get_pages(prefix))])
def _format_link(self, formatter, ns, target, label): kind, module = 'text', 'stuff' try: kind = 'odd' if int(target) % 2 else 'even' module = 'thing' except ValueError: pass return html.A(label, class_='%s resolver' % kind, href=formatter.href(module, target))
def _format_link(self, formatter, ns, target, label, fullmatch=None): intertrac = formatter.shorthand_intertrac_helper( ns, target, label, fullmatch) if intertrac: return intertrac report, args, fragment = formatter.split_link(target) return html.A(label, href=formatter.href.report(report) + args, class_='report')
def _format_link(self, formatter, ns, target, label, fullmatch=None): intertrac = formatter.shorthand_intertrac_helper(ns, target, label, fullmatch) if intertrac: return intertrac try: cursor = formatter.db.cursor() cursor.execute("SELECT summary,status FROM ticket WHERE id=%s", (str(int(target)),)) row = cursor.fetchone() if row: return html.A(label, class_='%s ticket' % row[1], title=shorten_line(row[0]) + ' (%s)' % row[1], href=formatter.href.ticket(target)) except ValueError: pass return html.A(label, class_='missing ticket', rel='nofollow', href=formatter.href.ticket(target))