• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python chrome.add_ctxtnav函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中trac.web.chrome.add_ctxtnav函数的典型用法代码示例。如果您正苦于以下问题:Python add_ctxtnav函数的具体用法?Python add_ctxtnav怎么用?Python add_ctxtnav使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了add_ctxtnav函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: process_request

    def process_request(self, req):
        req.perm.assert_permission('STRACTISTICS_VIEW')
        add_stylesheet(req, 'hw/css/stractistics.css')
        add_script(req, 'hw/javascript/swfobject.js')
        add_script(req, 'hw/javascript/prototype.js')
        add_script(req, 'hw/javascript/js-ofc-library/ofc.js')
        add_script(req, 'hw/javascript/js-ofc-library/data.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/area.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/bar.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/line.js')
        add_script(req, 'hw/javascript/js-ofc-library/charts/pie.js')
        add_script(req, 'hw/javascript/chart_reports.js')

        add_ctxtnav(req, 'Project Reports', req.href.stractistics("/project_reports"))
        add_ctxtnav(req, 'User Reports', req.href.stractistics("/user_reports"))

        #Reading options from trac.ini
        config = read_config_options(self.env.config)

        db = self.env.get_db_cnx()
        module = req.args.get('module', None)
        if module is not None and module == 'user_reports':
            template, data = user_reports(req, config, db)
        else:
            template, data = global_reports(req, config, db)
        data['json'] = {
            'repository_activity': json.dumps(data['repository_activity'].get_data()),
            'ticket_activity': json.dumps(data['ticket_activity'].get_data()),
            'wiki_activity': json.dumps(data['wiki_activity'].get_data()),
        }
        return template, data, None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py


示例2: _process_list

    def _process_list(self, req, query, data, start_date, period):
        calendar = TicketCalendar(self.env, req)
        events = calendar.get_list_events(data['tickets'], start_date, period)
        data['ticketcalendar'] = {
            'events': events,
            'last_week': calendar.get_list_href(query,
                                                start_date - timedelta(days=7),
                                                period + 7),
            'next_week': calendar.get_list_href(query, start_date, period + 7),
            'create_ticket': calendar._create_ticket_item,
            'create_milestone': calendar._create_milestone_item,
        }
        data['title'] = _('Ticket Calendar (List view)')
        data['macro'] = \
            '[[TicketCalendar(type=list,duration=%s,query=%s,order=%s%s)]]' % (
            '%s/P%dD' % (start_date.strftime('%Y-%m-%d'), period),
            calendar.build_query_string(query.constraints),
            query.order,
            query.desc and ',desc=1' or '')

        add_ctxtnav(req, _('Calendar view'),
                    calendar.get_box_href(query, get_today(req.tz)))
        add_ctxtnav(req, _('List view'))

        return 'ticketcalendar_calendar.html', data, None
开发者ID:KKBOX,项目名称:trac-ticket-calendar-plugin,代码行数:25,代码来源:web_ui.py


示例3: render_bookmarker

    def render_bookmarker(self, req):
        if 'action' in req.args and \
                req.args['action'] in self.nonbookmarkable_actions:
            return

        resource = self._get_resource_uri(req)
        bookmark = self.get_bookmark(req, resource)

        if bookmark:
            class_ = 'bookmark_on'
            title = 'Delete Bookmark'
            href = req.href.bookmark('delete', resource)
        else:
            class_ = 'bookmark_off'
            title = 'Bookmark this page'
            href = req.href.bookmark('add', resource)
        anchor = tag.a(u'\u200b', id='bookmark_this', class_=class_,
                       title=title, href=href, data_list=req.href.bookmark())
        req.chrome.setdefault('ctxtnav', []).insert(0, anchor)

        add_script(req, 'bookmark/js/tracbookmark.js')
        add_stylesheet(req, 'bookmark/css/tracbookmark.css')

        menu = self._get_bookmarks_menu(req)
        item = tag.span(tag.a('Bookmarks', href=req.href.bookmark()),
                        menu, id='bookmark_menu')
        add_ctxtnav(req, item)
开发者ID:lkraav,项目名称:trachacks,代码行数:27,代码来源:__init__.py


示例4: process_request

    def process_request(self, req):
        """Process the request."""

        id = int(req.args.get('id'))

        req.perm('ticket', id).require('TICKET_VIEW')

        if 'TICKET_REMINDER_MODIFY' not in req.perm and \
                'TICKET_ADMIN' not in req.perm:
            raise PermissionError('TICKET_REMINDER_MODIFY',
                                  req.perm._resource, self.env)

        ticket = Ticket(self.env, id)

        if 'cancel' in req.args:
            req.redirect(get_resource_url(self.env, ticket.resource, req.href))

        ticket_name = get_resource_name(self.env, ticket.resource)
        ticket_url = get_resource_url(self.env, ticket.resource, req.href)
        add_link(req, 'up', ticket_url, ticket_name)
        add_ctxtnav(req, _('Back to %(ticket)s', ticket=ticket_name),
                    ticket_url)

        add_stylesheet(req, 'ticketreminder/css/ticketreminder.css')

        if req.args['action'] == "addreminder":
            return self._process_add(req, ticket)
        elif req.args['action'] == "deletereminder":
            return self._process_delete(req, ticket)
        else:
            raise ValueError('Unknown action "%s"' % (req.args['action'],))
开发者ID:trac-hacks,项目名称:trac-ticketreminder,代码行数:31,代码来源:api.py


示例5: _render_history

    def _render_history(self, req, page):
        """Extract the complete history for a given page.

        This information is used to present a changelog/history for a given
        page.
        """
        if not page.exists:
            raise TracError(_("Page %(name)s does not exist", name=page.name))

        data = self._page_data(req, page, 'history')

        history = []
        for version, date, author, comment, ipnr in page.get_history():
            history.append({
                'version': version,
                'date': date,
                'author': author,
                'comment': comment,
                'ipnr': ipnr
            })
        data.update({
            'history': history,
            'resource': page.resource,
            'can_edit_comment': 'WIKI_ADMIN' in req.perm(page.resource)
        })
        add_ctxtnav(req, _("Back to %(wikipage)s", wikipage=page.name),
                    req.href.wiki(page.name))
        return 'history_view.html', data, None
开发者ID:pkdevbox,项目名称:trac,代码行数:28,代码来源:web_ui.py


示例6: post_process_request

    def post_process_request(self, req, template, data, content_type):
        """Adds a 'Lint' context navigation menu item in source view and
           links to the annotation in report summary.
        """
        if not 'BUILD_VIEW' in req.perm:
            return template, data, content_type
        resource = data and data.get('context') \
                        and data.get('context').resource or None
        if not resource or not isinstance(resource, Resource):
            pass
        elif resource.realm == 'source' and data.get('file') \
                    and not req.args.get('annotate') == 'lint':
            add_ctxtnav(req, 'Lint',
                    title='Annotate file with lint result '
                          'data (if available)',
                    href=req.href.browser(resource.id,
                        annotate='lint', rev=data.get('rev')))

        elif resource.realm == 'build' and data.get('build', {}).get('steps'):
            # in report summary, set link to lint annotation
            steps = data['build']['steps']
            rev = data['build']['rev']
            for step in steps:
                for report in step.get('reports', []):
                    if report.get('category') != 'lint':
                        continue
                    for item in report.get('data', {}).get('data', []):
                        href = item.get('href')
                        if not href or 'annotate' in href:
                            continue
                        sep = ('?' in href) and '&' or '?'
                        param = {'rev': rev, 'annotate': 'lint'}
                        href = href + sep + unicode_urlencode(param)
                        item['href'] = href + '#Lint1'
        return template, data, content_type
开发者ID:lkraav,项目名称:trachacks,代码行数:35,代码来源:lintannotator.py


示例7: render_reviewlink

    def render_reviewlink(self, req):
        #add_stylesheet(req, 'icucodetools/css/icuxtn.css')

        els = []

        ticket_mgr = TicketManager(self.compmgr)

        db = self.env.get_db_cnx()
        repos = self.env.get_repository()
        if not repos:
            raise TracError("Could not get repository for %s" % (req.authname))

        revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket'])

        if not revs:
            str = 'No commits.'
            li = tag.li(str)
            els.append(li)
        else:
            str = ' %d commits.' % len(revs)
            href = req.href.review(req.args['ticket'])
            a = tag.a('Review', href=href)
            li = tag.li(a + str)
            els.append(li)            
        
        ul = tag.ul(els, class_='review')
        className = ''
        title = "Reviews"
        add_ctxtnav(req, tag.span(tag.object(ul), id='icureview', title=title, class_=className))
开发者ID:icu-project,项目名称:icu-tools,代码行数:29,代码来源:review.py


示例8: render_voter

    def render_voter(self, req):
        resource = self.normalise_resource(req.path_info)

        count = self.get_vote_counts(resource)

        add_stylesheet(req, 'fivestarvote/css/fivestarvote.css')

        names = ['', 'one', 'two', 'three', 'four', 'five']
        els = []
        percent = 0
        if count[2] > 0:
            percent = count[2] * 20

        str = "Currently %s/5 stars." % count[2]
        sign = '%'
        style = "width: %s%s" % (percent, sign)
        li = tag.li(str, class_='current-rating', style=style)
        els.append(li)
        for i in range(1, 6):
            className = "item %s-star" % names[i]
            href = "#"
            if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
                href = req.href.fivestarvote(i, resource)
                add_script(req, 'fivestarvote/js/fivestarvote.js', mimetype='text/javascript')
            a = tag.a(i, href=href, class_=className)
            li = tag.li(a)
            els.append(li)
        
        ul = tag.ul(els, class_='star-rating')
        className = ''
        if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
            className = 'active'
        title = "Current Vote: %s users voted for a total of %s" % (count[1], count[0]) 
        add_ctxtnav(req, tag.span(tag.object(ul), id='fivestarvotes', title=title, class_=className))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:34,代码来源:__init__.py


示例9: filter_stream

    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
开发者ID:CGI-define-and-primeportal,项目名称:trac-plugin-sourcesharing,代码行数:30,代码来源:sourcesharer.py


示例10: post_process_request

    def post_process_request(self, req, template, data, content_type):
        if 'BLOG_VIEW' not in req.perm:
            return (template, data, content_type)

        if '_blog_watch_message_' in req.session:
            add_notice(req, req.session['_blog_watch_message_'])
            del req.session['_blog_watch_message_']

        if req.authname == "anonymous":
            return (template, data, content_type)

        # FullBlogPlugin sets the blog_path arg in pre_process_request
        name = req.args.get('blog_path')
        if not name:
            return (template, data, content_type)

        klass = self.__class__.__name__

        attrs = SubscriptionAttribute.find_by_sid_class_and_target(
            self.env, req.session.sid, req.session.authenticated, klass, name)
        if attrs:
            add_ctxtnav(req, tag.a(_('Unwatch This'),
                href=req.href.blog_watch(name)))
        else:
            add_ctxtnav(req, tag.a(_('Watch This'),
                href=req.href.blog_watch(name)))

        return (template, data, content_type)
开发者ID:csnover,项目名称:TracAnnouncer,代码行数:28,代码来源:announce.py


示例11: post_process_request

	def post_process_request(self, req, template, data, content_type):
		from mastertickets.model import TicketLinks
		if req.path_info.startswith('/ticket'):
			ticket_id = req.path_info[8:]
			links = TicketLinks(self.env, ticket_id)
			if len(links.blocked_by) > 0:
				depgraph_href = req.href.depgraph(ticket_id)
			else:
				depgraph_href = None
			add_ctxtnav(req, "Dependency Graph", depgraph_href,
						"Dependency Graph")
		if req.path_info.startswith('/query'):
			query = {}
			percent_enc = re.compile('\%[0-9a-fA-F]')
			for line in data['query'].to_string().splitlines():
				if '=' in line:
					if line.startswith('query:?'):
						line = line[7:]
					line = re.sub(percent_enc, self._unescape, line)
					key, value = line.split('=')
					if key in query:
						query[key].append(value)
					else:
						query[key] = [value]

			add_ctxtnav(req, tag.a('Dependency Graph',
							href=req.href('depgraph', **query)))

		return template, data, content_type
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:web_ui.py


示例12: post_process_request

 def post_process_request(self, req, template, data, content_type):
     env = self.env
     page = req.path_info
     realm, resource_id = resource_from_page(env, page)
     # break (recursive) search for form in forms realm
     if tfpageRE.match(page) == None and resource_id is not None:
         if page == '/wiki' or page == '/wiki/':
             page = '/wiki/WikiStart'
         form = Form(env, realm, resource_id)
         if 'FORM_VIEW' in req.perm(form.resource):
             if len(form.siblings) == 0:
                 # no form record found for this parent resource
                 href = req.href.form()
                 return (template, data, content_type)
             elif form.resource.id is not None:
                 # single form record found
                 href = req.href.form(form.resource.id)
             else:
                 # multiple form records found
                 href = req.href.form(action='select', realm=realm,
                                      resource_id=resource_id)
             add_ctxtnav(req, _("Form details"), href=href,
                         title=_("Review form data"))
     elif page.startswith('/form') and not resource_id == '':
         form = Form(env, form_id=resource_id)
         parent = form.resource.parent
         if len(form.siblings) > 1:
             href = req.href.form(action='select', realm=parent.realm,
                                  resource_id=parent.id)
             add_ctxtnav(req, _("Back to forms list"), href=href)
     return (template, data, content_type)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:31,代码来源:web_ui.py


示例13: post_process_request

 def post_process_request(self, req, template, data, content_type):
     if req.perm.has_permission('REVTREE_VIEW'):
         url_parts = filter(None, req.path_info.split(u'/'))
         if url_parts and (url_parts[0] in self.contexts):
             add_ctxtnav(req, 'Revtree' % self.contexts, 
                         href=req.href.revtree())
     return (template, data, content_type)
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:7,代码来源:web_ui.py


示例14: post_process_request

 def post_process_request(self, req, template, data, content_type):
     ticket_id = req.args.get('id')
     if template == 'ticket.html' and ticket_id:
         ticket_url = req.abs_href('ticket', ticket_id)
         fs_url = u'http://www.freedomsponsors.org/core/issue/sponsor?trackerURL=%s' % ticket_url
         text = u'Sponsor #%s in FreedomSponsors.org!' % ticket_id
         add_ctxtnav(req, tag.a(text, href=fs_url, target='_blank'))
     return template, data, content_type
开发者ID:freedomsponsors,项目名称:freedomsponsors-trac-plugin,代码行数:8,代码来源:freedomsponsors_trac.py


示例15: post_process_request

    def post_process_request(self, req, template, data, content_type):
        add_script(req, 'datasaver/datasaver.js')
        if req.locale is not None: 
 	    add_script(req, 'datasaver/lang_js/%s.js' % req.locale)
        add_stylesheet(req, 'datasaver/datasaver.css')
        add_ctxtnav(req, tag.a(_('Restore Form') , id='datasaver_restorer',
                    href='javascript:datasaver_restore()'))
        return (template, data, content_type)
开发者ID:KKBOX,项目名称:trac-data-saver-plugin,代码行数:8,代码来源:datasaver.py


示例16: post_process_request

 def post_process_request(self, req, template, data, content_type):
     if (req.path_info.startswith('/wiki') or req.path_info == '/') and \
             data and 'page' in data:
         page = data['page']
         perm = req.perm(page.resource)
         if 'WIKI_CREATE' in perm or 'WIKI_ADMIN' in perm:
             href = req.href('wikicreate')
             add_ctxtnav(req, _('Create'), href)
     return template, data, content_type
开发者ID:kzhamaji,项目名称:TracWikiCtxtNavPlugin,代码行数:9,代码来源:wikicreate.py


示例17: post_process_request

    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type
            tkt = data['ticket']
            links = TicketLinks(self.env, tkt)
            
            for i in links.blocked_by:
                if Ticket(self.env, i)['status'] != 'closed':
                    add_script(req, 'mastertickets/disable_resolve.js')
                    break

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, 'Depgraph', req.href.depgraph(tkt.id))
            
            for change in data.get('changes', {}):
                if not change.has_key('fields'):
                    continue
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        if field_data['new'].strip():
                            new = set([int(n) for n in field_data['new'].split(',')])
                        else:
                            new = set()
                        if field_data['old'].strip():
                            old = set([int(n) for n in field_data['old'].split(',')])
                        else:
                            old = set()
                        add = new - old
                        sub = old - new
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(add)]))
                            )
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
                            )
                            elms.append(u' removed')
                        field_data['rendered'] = elms
            
        #add a link to generate a dependency graph for all the tickets in the milestone
        if req.path_info.startswith('/milestone/'):
            if not data:
                return template, data, content_type
            milestone=data['milestone']
            add_ctxtnav(req, 'Depgraph', req.href.depgraph('milestone', milestone.name))


        return template, data, content_type
开发者ID:pierrejean-coudert,项目名称:trac-mastertickets,代码行数:56,代码来源:web_ui.py


示例18: render_watcher

 def render_watcher(self, req):
     if not self.ctxtnav_names:
         return
     realm, target = self.path_info_to_realm_target(req.path_info)
     sess = req.session
     if self.is_watching(sess.sid, sess.authenticated, realm, target):
         action_name = len(self.ctxtnav_names) >= 2 and self.ctxtnav_names[1] or "Unwatch This"
     else:
         action_name = len(self.ctxtnav_names) and self.ctxtnav_names[0] or "Watch This"
     add_ctxtnav(req, tag.a(_(action_name), href=req.href.watch(realm, target)))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:10,代码来源:subscribers.py


示例19: post_process_request

    def post_process_request(self, req, template, data, content_type):
        if req.path_info.startswith('/ticket/'):
            # In case of an invalid ticket, the data is invalid
            if not data:
                return template, data, content_type
            tkt = data['ticket']
            self.pm.check_component_enabled(self, pid=tkt.pid)
            links = TicketLinks(self.env, tkt)

            # Add link to depgraph if needed
            if links:
                add_ctxtnav(req, _('Depgraph'), req.href.depgraph(get_resource_url(self.env, tkt.resource)))

            for change in data.get('changes', {}):
                if not change.has_key('fields'):
                    continue
                for field, field_data in change['fields'].iteritems():
                    if field in self.fields:
                        vals = {}
                        for i in ('new', 'old'):
                            if isinstance(field_data[i], basestring):
                                val = field_data[i].strip()
                            else:
                                val = ''
                            if val:
                                vals[i] = set([int(n) for n in val.split(',')])
                            else:
                                vals[i] = set()
                        add = vals['new'] - vals['old']
                        sub = vals['old'] - vals['new']
                        elms = tag()
                        if add:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(add)]))
                            )
                            elms.append(u' added')
                        if add and sub:
                            elms.append(u'; ')
                        if sub:
                            elms.append(
                                tag.em(u', '.join([unicode(n) for n in sorted(sub)]))
                            )
                            elms.append(u' removed')
                        field_data['rendered'] = elms

        #add a link to generate a dependency graph for all the tickets in the milestone
        if req.path_info.startswith('/milestone/'):
            if not data or not 'milestone' in data:
                return template, data, content_type
            milestone=data['milestone']
            self.pm.check_component_enabled(self, pid=milestone.pid)
            add_ctxtnav(req, _('Depgraph'), req.href.depgraph(get_resource_url(self.env, milestone.resource)))


        return template, data, content_type
开发者ID:lexqt,项目名称:EduTracMasterTickets,代码行数:55,代码来源:web_ui.py


示例20: post_process_request

    def post_process_request(self, req, template, data, content_type):

        if req.path_info.startswith('/wiki') or req.path_info == '/':
            action = req.args.get('action', 'view')

            if action == 'view' and data and 'page' in data:
                page = data['page']
                if 'WIKI_MODIFY' in req.perm:
                    href = req.href.wiki(page.name, action='edit')
                    add_ctxtnav(req, _('Edit'), href)
        return template, data, content_type
开发者ID:kzhamaji,项目名称:TracWikiCtxtNavPlugin,代码行数:11,代码来源:wikiedit.py



注:本文中的trac.web.chrome.add_ctxtnav函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python chrome.add_link函数代码示例发布时间:2022-05-27
下一篇:
Python api.Request类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap