本文整理汇总了Python中trac.web.chrome.add_stylesheet函数的典型用法代码示例。如果您正苦于以下问题:Python add_stylesheet函数的具体用法?Python add_stylesheet怎么用?Python add_stylesheet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_stylesheet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_for_action
def prepare_for_action(self, req):
add_stylesheet(req, 'pmmm/pmmm.css')
self.is_project_admin = req.perm.has_permission("PROJECT_ADMIN")
self.is_trac_admin = req.perm.has_permission("TRAC_ADMIN")
self.is_dep_admin = req.perm.has_permission("DEPARTMENT_ADMIN")
self.log.debug("User %s is_admin %d" % (req.authname,
self.is_project_admin))
示例2: filter_stream
def filter_stream(self, req, method, filename, stream, data):
filter_ = []
if req.path_info.startswith("/ticket"):
filter_.extend(self._ticket_filter(req, data))
elif req.path_info.startswith("/timeline"):
filter_.extend(self._timeline_filter(req, data))
elif req.path_info.startswith("/browser") or req.path_info.startswith("/changeset"):
filter_.extend(self._browser_filter(req, data))
elif req.path_info.startswith("/log"):
filter_.extend(self._log_filter(req, data))
elif req.path_info.startswith("/search"):
filter_.extend(self._search_filter(req, data))
elif req.path_info.startswith("/report") or req.path_info.startswith("/query"):
filter_.extend(self._report_filter(req, data))
elif req.path_info.startswith("/wiki"):
filter_.extend(self._wiki_filter(req, data))
elif req.path_info.startswith("/attachment"):
filter_.extend(self._attachment_filter(req, data))
if 'attachments' in data and data.get('attachments', {}).get('attachments'):
filter_.extend(self._page_attachments_filter(req, data))
for f in filter_:
if f is not None:
stream |= f
add_stylesheet(req, 'userpictures/userpictures.css')
return stream
示例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: process_request
def process_request(self, req):
from tractags.api import TagEngine
from trac.web.chrome import add_stylesheet
add_stylesheet(req, 'tags/css/tractags.css')
pagename = req.args.get('page', 'WikiStart')
action = req.args.get('action', 'view')
engine = TagEngine(self.env)
wikitags = engine.tagspace.wiki
tags = list(wikitags.get_tags([pagename]))
tags.sort()
if action == 'edit':
req.hdf['tags'] = req.args.get('tags', ', '.join(tags))
elif action == 'view':
hdf_tags = []
for tag in tags:
href, title = engine.get_tag_link(tag)
hdf_tags.append({'name': tag,
'href': href,
'title': title})
req.hdf['tags'] = hdf_tags
result = WikiModule.process_request(self, req)
if result is None:
return None
if result[0] == 'wiki.cs':
return 'tagswiki.cs', None
return result
示例5: process_admin_request
def process_admin_request(self, req, cat, page, path_info):
assert req.perm.has_permission('PROJECT_CREATE')
if page != 'createproj':
raise TracError("Invalid page %s" % page)
# filter out the project-specific arguments and remove the prefix
prefix = 'createproject.'
projkeys = filter(lambda x: x.startswith(prefix), req.args.iterkeys())
args = dict((key[len(prefix):], req.args[key]) for key in projkeys)
if req.method == 'POST':
# handle form submission
(projects_root_url, _) = os.path.split(self.env.project_url)
(projects_root_path, _) = os.path.split(self.env.path)
project_url = os.path.join(projects_root_url, args['dir_name'])
path = os.path.join(projects_root_path, args['dir_name'])
args.setdefault('url', project_url)
args.setdefault('path', path)
new_env = self._do_create_proj(args)
self._add_global_settings(new_env, args)
self._delete_unwanted_files(new_env)
req.redirect(project_url)
args.setdefault('repos_type', 'svn')
# store the input arguments back in the form fields so the user
# can correct errors
for name, val in args.iteritems():
req.hdf[prefix + name] = val
add_stylesheet(req, 'createproj/css/createproj.css')
return 'createproj.cs', None
示例6: expand_macro
def expand_macro(self, formatter, name, args):
req = formatter.req
chrome = Chrome(self.env)
report = ReportModule(self.env)
comma_splitter = re.compile(r'(?<!\\),')
kwargs = {}
for arg in comma_splitter.split(args):
arg = arg.replace(r'\,', ',')
m = re.match(r'\s*[^=]+=', arg)
if m:
kw = arg[:m.end() - 1].strip()
value = arg[m.end():]
if re.match(r'^\$[A-Z]*$', value):
value = req.args.get(value[1:])
kwargs[kw] = value if value!= None else ''
else:
if re.match(r'^\$[A-Z]*$', arg):
arg = req.args.get(arg[1:])
id = int(arg)
req.args = kwargs
req.args['page'] = '1'
template, data, content_type = report._render_view(req, id)
add_stylesheet(req, 'common/css/report.css')
fullpath = ''
if pkg_resources.resource_exists('wikireport', 'WikiReport.html'):
fullpath = pkg_resources.resource_filename('wikireport', 'WikiReport.html')
else:
filepath = os.path.dirname(os.path.abspath( __file__ ))
fullpath = os.path.join(filepath, 'WikiReport.html')
return chrome.render_template(req, fullpath, data, None, fragment=True)
示例7: 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)
示例8: filter_stream
def filter_stream(self, req, method, filename, stream, data):
crumbs = self._get_crumbs(req.session)
if not crumbs:
return stream
add_stylesheet(req, 'breadcrumbs/css/breadcrumbs.css')
li = []
href = req.href(req.base_path)
for crumb in crumbs:
realm, resource = crumb.split('/', 1)
name = resource.replace('_', ' ')
if realm == "ticket":
name = "#" + resource
elif realm != "wiki":
name = "%s:%s" % (realm, name)
link = req.href(realm, resource)
li.append(
tag.li(
tag.a(title=name, href=link,
)(name)
)
)
insert = tag.ul(class_="nav", id="breadcrumbs")(("Breadcrumbs:"), li)
return stream | Transformer('//div[@id="metanav"]/ul').after(insert)
示例9: 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
示例10: expand_macro
def expand_macro(self, formatter, name, content):
req = formatter.req
stats_provider, kwargs, is_preview_with_self = self._parse_macro_content(content, req)
if is_preview_with_self:
# previewing newticket, without a number but with a reference
# to current ticket number; show a helpful message
return tag.div('Progress meter will be inserted here in final ticket')
# Create & execute the query string
qstr = '&'.join(['%s=%s' % item
for item in kwargs.iteritems()])
query = Query.from_string(self.env, qstr, max=0)
try:
constraints = query.constraints[0]
except IndexError:
constraints = query.constraints
# Calculate stats
qres = query.execute(req)
tickets = apply_ticket_permissions(self.env, req, qres)
stats = get_ticket_stats(stats_provider, tickets)
stats_data = query_stats_data(req, stats, constraints)
# ... and finally display them
add_stylesheet(req, 'common/css/roadmap.css')
chrome = Chrome(self.env)
return chrome.render_template(req, 'progressmeter.html', stats_data,
fragment=True)
示例11: render_admin_panel
def render_admin_panel(self, req, cat, page, path_info):
if req.method == 'POST':
self.config.set('theme', 'theme', req.args['theme'].lower())
self.config.save()
req.redirect(req.href.admin(cat, page))
data = {
'themeengine': {
'info': self.system.info.items(),
},
}
theme_name = self.system.theme and self.system.theme['name'] or 'default'
theme_name = theme_name.islower() and theme_name.title() or theme_name
data['themeengine']['current'] = theme_name
index = 0
curtheme = None
for i, (k, v) in enumerate(data['themeengine']['info']):
if k.lower() == theme_name.lower():
index = i
curtheme = v
break
data['themeengine']['current_index'] = index
data['themeengine']['current_theme'] = curtheme
#add_stylesheet(req, 'themeengine/jquery.jcarousel.css')
#add_stylesheet(req, 'themeengine/skins/tango/skin.css')
#add_script(req, 'themeengine/jquery.jcarousel.pack.js')
add_stylesheet(req, 'themeengine/admin.css')
add_script(req, 'themeengine/jcarousellite_1.0.1.js')
return 'admin_theme.html', data
示例12: match_request
def match_request(self, req):
"""
Never Match a request but always load the css, trac seems
to do some caching, so this only happens once per session?
"""
add_stylesheet(req, 'shellexampleHdocs/css/shellexample.css')
return False;
示例13: process_admin_request
def process_admin_request(self, req, cat, page, path_info):
assert req.perm.has_permission('BLOG_ADMIN')
add_stylesheet(req, 'blog/css/blog.css')
add_stylesheet(req, 'common/css/wiki.css')
req.hdf['blogadmin.page'] = page
admin_fields = {
'date_format' : '%x %X',
'page_format' : '%Y/%m/%d/%H.%M',
'default_tag' : 'blog',
'post_size' : 1024,
'history_days' : 30,
'new_blog_link' : 'New Blog Post',
'first_week_day' : 'SUNDAY',
'mark_updated' : 'true',
'nav_link' : 'Blog',
'nav_bar' : 'true',
'macro_blacklist': '',
'rss' : 'true',
}
if req.method == 'POST':
if page == 'defaults':
for field in admin_fields.keys():
self._set_field_value(req, field)
self.env.config.save()
for field, default in admin_fields.items():
self._get_field_value(req, field, default)
req.hdf['blogadmin.docs'] = wiki_to_html(self._get_docs(page),
self.env, req)
return 'blog_admin.cs', None
示例14: 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 == 'ticket.html':
add_stylesheet(req, '%s/css/autocomplete.css' % self.prefix)
add_script(req, '%s/js/autocomplete.js' % self.prefix)
if req.path_info.rstrip() == '/newticket':
add_script_data(req, {'KEYWORDS_AC_PATH': 'ac-keywords'})
else:
add_script_data(req, {'KEYWORDS_AC_PATH': '../ac-keywords'})
add_script(req, '%s/js/autocomplete_ticket_keywords.js' % self.prefix)
return (template, data, content_type)
示例15: process_request
def process_request(self, req):
req.perm.require(self.BILLING_PERMISSION)
messages = []
def addMessage(s):
messages.extend([s]);
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)
data = {};
data["statuses"] = get_statuses(self)
data["reports"] = mgr.get_reports_by_group(CustomReportManager.TimingAndEstimationKey);
#self.log.debug("DEBUG got %s, %s" % (data["reports"], type(data["reports"])));
data["billing_info"] = {"messages": messages,
"href": req.href.Billing(),
"report_base_href": req.href.report(),
"usermanual_href": req.href.wiki(user_manual_wiki_title),
"usermanual_title": user_manual_title }
self.set_request_billing_dates(data)
add_stylesheet(req, "Billing/billingplugin.css")
add_script(req, "Billing/date.js")
add_script(req, "Billing/linkifyer.js")
return 'billing.html', data, None