本文整理汇总了Python中trac.web.chrome.add_script函数的典型用法代码示例。如果您正苦于以下问题:Python add_script函数的具体用法?Python add_script怎么用?Python add_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_script函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_admin_request
def process_admin_request(self, req, cat, page, path_info):
# Page locations
req.hdf['tracforge.href'] = {
'prototypes': req.href.admin(cat, page),
'configset': req.href.admin(cat, page, 'configset'),
'new': req.href.admin(cat, page, 'new'),
'htdocs': req.href.chrome('tracforge'),
}
# General stuff
add_stylesheet(req, 'tracforge/css/admin.css')
add_script(req, 'tracforge/js/jquery.js')
req.cat = cat
req.page = page
# Subpage dispatchers
if path_info:
if path_info == 'configset':
return self.process_configset_admin_request(req, cat, page, path_info)
elif path_info == 'new':
return self._show_prototype(req, path_info, action='new')
else:
return self._show_prototype(req, path_info, action='edit')
req.hdf['tracforge.prototypes.tags'] = list(Prototype.select(self.env))
return 'admin_tracforge_prototypes.cs', None
示例2: process_request
def process_request(self, req):
# Create request context.
context = Context.from_request(req)
context.realm = 'screenshots-core'
# Template data dictionary.
req.data = {}
# Get database access.
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Prepare data structure.
req.data['title'] = self.mainnav_title or self.metanav_title
req.data['has_tags'] = self.env.is_component_enabled(
'tracscreenshots.tags.ScreenshotsTags')
# Get action from request and perform them.
actions = self._get_actions(context)
self.log.debug('actions: %s' % (actions,))
template, content_type = self._do_actions(context, actions)
# Add CSS style and JavaScript scripts.
add_stylesheet(req, 'screenshots/css/screenshots.css')
add_script(req, 'screenshots/js/screenshots.js')
# Return template and its data.
db.commit()
return (template + '.html', {'screenshots' : req.data}, content_type)
示例3: post_process_request
def post_process_request(self, req, template, data, content_type):
path = req.path_info
if path.startswith('/ticket/') or path.startswith('/wiki') \
or path.startswith('/attachment/'):
add_script(req, EMBED_PATH_FLOWPLAYER['js'])
add_stylesheet(req, EMBED_PATH_FLOWPLAYER['css'])
return template, data, content_type
示例4: post_process_request
def post_process_request(self, req, template, data, content_type):
self.log.debug("TicketRefsTemplate: post_process_request, %s, %s" % (
req.path_info, template))
if req.path_info.startswith("/ticket/"):
add_stylesheet(req, "ticketref/ticket.css")
add_script(req, "ticketref/ticket.js")
return template, data, content_type
示例5: _render_config_panel
def _render_config_panel(self, req, cat, page):
req.perm.require('SPAM_CONFIG')
filter_system = FilterSystem(self.env)
strategies = []
for strategy in filter_system.strategies:
for variable in dir(strategy):
if variable.endswith('karma_points'):
strategies.append({
'name': strategy.__class__.__name__,
'karma_points': getattr(strategy, variable),
'variable': variable,
'karma_help': gettext(getattr(strategy.__class__,
variable).__doc__)
})
add_script(req, 'spamfilter/adminconfig.js')
return {
'strategies': sorted(strategies, key=lambda x: x['name']),
'min_karma': filter_system.min_karma,
'authenticated_karma': filter_system.authenticated_karma,
'attachment_karma': filter_system.attachment_karma,
'register_karma': filter_system.register_karma,
'trust_authenticated': filter_system.trust_authenticated,
'logging_enabled': filter_system.logging_enabled,
'nolog_obvious': filter_system.nolog_obvious,
'purge_age': filter_system.purge_age,
'spam_monitor_entries_min': self.MIN_PER_PAGE,
'spam_monitor_entries_max': self.MAX_PER_PAGE,
'spam_monitor_entries': self.DEF_PER_PAGE
}
示例6: post_process_request
def post_process_request(self, req, template, data, content_type):
if req.path_info.startswith('/ticket/') or \
req.path_info.startswith('/newticket'):
add_script(req, 'keywordsuggest/jquery.bgiframe.min.js')
add_script(req, 'keywordsuggest/jquery.autocomplete.pack.js')
add_stylesheet(req, 'keywordsuggest/autocomplete.css')
return template, data, content_type
示例7: _do_login
def _do_login(self, req):
# check the referer
referer = req.get_header('Referer')
if referer and not (referer == req.base_url or referer.startswith(req.base_url.rstrip('/')+'/')):
# only redirect to referer if it is from the same site
referer = None
if referer:
req.session['oid.referer'] = referer
if self.default_openid:
req.args['openid_identifier'] = self.default_openid
return self._do_verify(req)
add_stylesheet(req, 'authopenid/css/openid.css')
add_script(req, 'authopenid/js/openid-jquery.js')
return 'openidlogin.html', {
'images': req.href.chrome('authopenid/images') + '/',
'action': req.href.openidverify(),
'message': 'Login using OpenID.',
'signup': self.signup_link,
'whatis': self.whatis_link,
'css_class': 'error',
'providers_regexp': self.providers_regexp,
'custom_provider_name': self.custom_provider_name,
'custom_provider_label': self.custom_provider_label,
'custom_provider_url': self.custom_provider_url,
'custom_provider_image': self.custom_provider_image,
'custom_provider_size': self.custom_provider_size,
}, None
示例8: filter_stream
def filter_stream(self, req, method, filename, stream, data):
selector = ['.user-field']
page_map = {
"ticket.html": ["#field-owner", "#field-reporter"],
"query.html": ["#mods-filters input[name$='_" + field + "']"
for field in ("owner", "reporter")],
"admin_components.html": ["input[name='owner']"],
"taskboard.html": ["input[class='user-field']"]
}
page_map["hours_timeline.html"] = page_map["query.html"]
def _template_filenames():
for plugin in self.extra_templates:
for filename in plugin.get_templates():
yield filename
if filename in page_map:
if filename == "ticket.html":
selector.extend('#field-' + n for n in self._user_fields())
if self.transform_owner_reporter:
selector.extend(page_map[filename])
if filename in page_map or filename in _template_filenames():
self._add_groups_data(req)
add_script_data(req, {'userfieldSelector': ','.join(selector) })
add_script(req, 'userfield/js/userfield.js')
return stream
示例9: projects
def projects(self,req):
add_stylesheet(req, 'cp/css/customers.css')
projects = self.getProjects()
inactive_count = 0
ticketCountP = self.getTicketCountByProject()
projectTimes = self.getProjectTime()
for project in projects:
if ticketCountP.has_key('%s' % project['id']):
project['ticketCount'] = ticketCountP['%s' % project['id']]
else:
project['ticketCount'] = 0
if projectTimes.has_key('%s' % project['id']):
project['totalTime'] = projectTimes['%s' % project['id']]
else:
project['totalTime'] = '0:00'
if project['active'] == 0:
project['class'] = 'inactive'
project['style'] = 'display: none'
inactive_count += 1
customers = self.getCustomers()
url = req.abs_href(req.path_info)
edit = req.perm.has_permission('CUST_EDIT')
data = locals().copy()
data['c_base_url'] = req.href.cust()
data['p_base_url'] = req.href.c_projects()
data['t_base_url'] = req.href.ticket()
del data['self']
del data['projectTimes']
del data['ticketCountP']
add_script(req, 'cp/js/cust.js')
return 'projects.html',data,None
示例10: post_process_request
def post_process_request(self, req, template, data, content_type):
"""Do any post-processing the request might need; typically adding
values to the template `data` dictionary, or changing template or
mime type.
`data` may be update in place.
Always returns a tuple of (template, data, content_type), even if
unchanged.
Note that `template`, `data`, `content_type` will be `None` if:
- called when processing an error page
- the default request handler did not return any result
(Since 0.11)
"""
if template != "query.html":
return (template, data, content_type)
geoticket = self.geoticket()
location = req.args.get("center_location", "").strip()
lat = lon = None
if location:
try:
location, (lat, lon) = geoticket.geolocate(location)
except GeolocationException, e:
add_script(req, "geoticket/js/query_location_filler.js")
add_warning(req, Markup(e.html()))
示例11: _show_regular_page
def _show_regular_page(self, req):
req_data = {}
# Resolve some static data needed on page (categories and project count)
cs = CQDECategoryStore()
all_categories = cs.get_all_categories()
all_contexts = cs.get_contexts()
combined_context_ids, combined_contexts, non_combined_contexts = self.get_combined_contexts(all_contexts)
# Total count of projects and count of projects in categories
direct_category_counts = Projects().get_project_counts_per_category(req.authname)
req_data['direct_category_counts'] = direct_category_counts
req_data['combined_context_ids'] = combined_context_ids
req_data['non_combined_contexts'] = non_combined_contexts
self.set_category_data_into_request_data(all_categories, req_data)
add_stylesheet(req, 'multiproject/css/multiproject.css')
add_script(req, 'multiproject/js/jquery.ba-bbq.js')
add_script(req, 'multiproject/js/explore.js')
return "find.html", {
'top_categories': req_data['top_categories'],
'categories': req_data['root_categories_of_combined_contexts'],
'nonbrowsable_cntxt': req_data['non_empty_non_combined_contexts'],
'selected_tab': self.DEFAULT_TAB,
'tabs': self.TABS}, \
None
示例12: post_process_request
def post_process_request(self, req, template, data, content_type):
# Add Google Map API key using a link tag:
if self.api_key:
add_link (req, rel='google-key', href='', title=self.api_key, classname='google-key')
add_stylesheet (req, 'googlemap/tracgooglemap.css')
add_script (req, 'googlemap/tracgooglemap.js')
return (template, data, content_type)
示例13: render_voter
def render_voter(self, req):
resource = self.normalise_resource(req.path_info)
vote = self.get_vote(req, resource)
up = tag.img(src=req.href.chrome('vote/' + self.image_map[vote][0]),
alt='Up-vote')
down = tag.img(src=req.href.chrome('vote/' + self.image_map[vote][1]),
alt='Down-vote')
if 'VOTE_MODIFY' in req.perm and get_reporter_id(req) != 'anonymous':
down = tag.a(down, id='downvote',
href=req.href.vote('down', resource),
title='Down-vote')
up = tag.a(up, id='upvote', href=req.href.vote('up', resource),
title='Up-vote')
add_script(req, 'vote/js/tracvote.js')
shown = req.session.get('shown_vote_message')
if not shown:
add_notice(req, 'You can vote for resources on this Trac '
'install by clicking the up-vote/down-vote arrows '
'in the context navigation bar.')
req.session['shown_vote_message'] = '1'
body, title = self.format_votes(resource)
votes = tag.span(body, id='votes')
add_stylesheet(req, 'vote/css/tracvote.css')
elm = tag.span(up, votes, down, id='vote', title=title)
req.chrome.setdefault('ctxtnav', []).insert(0, elm)
示例14: process_request
def process_request(self, req):
messages = []
def addMessage(s):
messages.extend([s]);
if not re.search('/Billing', req.path_info):
return None
if req.method == 'POST':
if req.args.has_key('setbillingtime'):
self.set_bill_date(req.authname)
addMessage("All tickets last bill date updated")
mgr = CustomReportManager(self.env, self.log)
req.hdf["billing_info"] = {"messages": messages,
"href": req.href.Billing(),
"report_base_href": req.href.report(),
"reports": mgr.get_reports_by_group("Timing and Estimation Plugin"),
"usermanual_href": req.href.wiki(user_manual_wiki_title),
"usermanual_title": user_manual_title
}
self.set_request_billing_dates(req)
add_stylesheet(req, "Billing/billingplugin.css")
add_script(req, "Billing/linkifyer.js")
return 'billing.cs', 'text/html'
示例15: process_downloads
def process_downloads(self, context):
# Clear data for next request.
self.data = {}
# Get database access.
db = self.env.get_db_cnx()
context.cursor = db.cursor()
# Get request mode
modes = self._get_modes(context)
self.log.debug('modes: %s' % modes)
# Perform mode actions
self._do_action(context, modes)
# Fill up HDF structure and return template
self.data['authname'] = context.req.authname
self.data['time'] = format_datetime(datetime.now(utc))
self.data['realm'] = context.resource.realm
# Add CSS styles
add_stylesheet(context.req, 'common/css/wiki.css')
add_stylesheet(context.req, 'downloads/css/downloads.css')
add_stylesheet(context.req, 'downloads/css/admin.css')
# Add JavaScripts
add_script(context.req, 'common/js/trac.js')
add_script(context.req, 'common/js/wikitoolbar.js')
# Commit database changes and return template and data.
db.commit()
self.env.log.debug(self.data)
return modes[-1] + '.html', {'downloads' : self.data}