Package trac :: Package web :: Module chrome :: Class Chrome

Class Chrome

source code

    object --+    
             |    
core.Component --+
                 |
                Chrome

Web site chrome assembly manager.

Chrome is everything that is not actual page content.

Nested Classes

Inherited from core.Component: __metaclass__

Instance Methods
 
mainnav(...)
Configures the main navigation bar, which by default contains //Wiki//, //Timeline//, //Roadmap//, //Browse Source//, //View Tickets//, //New Ticket//, //Search// and //Admin//.
source code
 
metanav(...)
Configures the meta navigation entries, which by default are //Login//, //Logout//, //Preferences//, ''!Help/Guide'' and //About Trac//.
source code
 
get_system_info(self) source code
 
environment_created(self)
Create the environment templates directory.
source code
 
environment_needs_upgrade(self) source code
 
upgrade_environment(self) source code
 
match_request(self, req) source code
 
process_request(self, req) source code
 
get_permission_actions(self)
EMAIL_VIEW permission allows for showing email addresses even if [trac] show_email_addresses is false.
source code
 
get_htdocs_dirs(self) source code
 
get_templates_dirs(self) source code
 
get_wiki_syntax(self) source code
 
get_link_resolvers(self) source code
 
get_all_templates_dirs(self)
Return a list of the names of all known templates directories.
source code
 
prepare_request(self, req, handler=None)
Prepare the basic chrome data for the request.
source code
 
get_icon_data(self, req) source code
 
get_logo_data(self, href, abs_href=None) source code
 
populate_data(self, req, data) source code
 
load_template(self, filename, method=None)
Retrieve a Template and optionally preset the template data.
source code
 
render_template(self, req, filename, data, content_type=None, fragment=False, iterable=False, method=None)
Render the filename using the data for the context.
source code
 
get_interface_customization_files(self)
Returns a dictionary containing the lists of files present in the site and shared templates and htdocs directories.
source code
 
iterable_content(self, stream, method, **kwargs)
Generate an iterable object which iterates str instances from the given stream instance.
source code
 
author_email(self, author, email_map)
Returns the author email from the email_map if author doesn't look like an email address.
source code
 
authorinfo(self, req, author, email_map=None, resource=None)
Format a username to HTML.
source code
 
author_class(self, req, author) source code
 
authorinfo_short(self, author) source code
 
cc_list(self, cc_field)
Split a CC: value in a list of addresses.
source code
 
format_author(self, req, author, resource=None, show_email=None)
Format a username in plain text.
source code
 
format_emails(self, context, value, sep=', ')
Normalize a list of e-mails and obfuscate them if needed.
source code
 
get_email_map(self)
Get the email addresses of all known users.
source code
 
add_textarea_grips(self, req)
Make <textarea class="trac-resizable"> fields resizable if enabled by configuration.
source code
 
add_wiki_toolbars(self, req)
Add wiki toolbars to <textarea class="wikitext"> fields.
source code
 
add_auto_preview(self, req)
Setup auto-preview for <textarea> fields.
source code
 
add_jquery_ui(self, req)
Add a reference to the jQuery UI script and link the stylesheet.
source code

Inherited from core.Component: __repr__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods

Inherited from core.Component: implements

Class Variables
  required = True
  is_valid_default_handler = False
  shared_templates_dir = <PathOption [inherit] 'templates_dir'>
  shared_htdocs_dir = <PathOption [inherit] 'htdocs_dir'>
  auto_reload = <BoolOption [trac] 'auto_reload'>
  genshi_cache_size = <IntOption [trac] 'genshi_cache_size'>
  htdocs_location = <Option [trac] 'htdocs_location'>
  jquery_location = <Option [trac] 'jquery_location'>
  jquery_ui_location = <Option [trac] 'jquery_ui_location'>
  jquery_ui_theme_location = <Option [trac] 'jquery_ui_theme_loc...
  logo_link = <Option [header_logo] 'link'>
  logo_src = <Option [header_logo] 'src'>
  logo_alt = <Option [header_logo] 'alt'>
  logo_width = <IntOption [header_logo] 'width'>
  logo_height = <IntOption [header_logo] 'height'>
  show_email_addresses = <BoolOption [trac] 'show_email_addresses'>
  show_full_names = <BoolOption [trac] 'show_full_names'>
  never_obfuscate_mailto = <BoolOption [trac] 'never_obfuscate_m...
  show_ip_addresses = <BoolOption [trac] 'show_ip_addresses'>
  resizable_textareas = <BoolOption [trac] 'resizable_textareas'>
  wiki_toolbars = <BoolOption [trac] 'wiki_toolbars'>
  auto_preview_timeout = <FloatOption [trac] 'auto_preview_timeo...
  default_dateinfo_format = <ChoiceOption [trac] 'default_datein...
  use_chunked_encoding = <BoolOption [trac] 'use_chunked_encoding'>
  templates = None
hash(x)
  html_doctype = ('html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'h...
Properties
  navigation_contributors
List of components that implement ~trac.web.chrome.INavigationContributor
  template_providers
List of components that implement ~trac.web.chrome.ITemplateProvider
  stream_filters
List of components that implement ~trac.web.api.ITemplateStreamFilter

Inherited from object: __class__

Method Details

mainnav(...)

source code 

Configures the main navigation bar, which by default contains //Wiki//, //Timeline//, //Roadmap//, //Browse Source//, //View Tickets//, //New Ticket//, //Search// and //Admin//.

The label, href, and order attributes can be specified. Entries can be disabled by setting the value of the navigation item to disabled.

The following example renames the link to WikiStart to //Home//, links the //View Tickets// entry to a specific report and disables the //Search// entry. {{{#!ini [mainnav] wiki.label = Home tickets.href = /report/24 search = disabled }}}

See TracNavigation for more details.

metanav(...)

source code 

Configures the meta navigation entries, which by default are //Login//, //Logout//, //Preferences//, ''!Help/Guide'' and //About Trac//. The allowed attributes are the same as for [mainnav]. Additionally, a special entry is supported - logout.redirect is the page the user sees after hitting the logout button. For example:

{{{#!ini [metanav] logout.redirect = wiki/Logout }}}

See TracNavigation for more details.

prepare_request(self, req, handler=None)

source code 
Prepare the basic chrome data for the request.
Parameters:
  • req - the request object
  • handler - the IRequestHandler instance that is processing the request

load_template(self, filename, method=None)

source code 

Retrieve a Template and optionally preset the template data.

Also, if the optional method argument is set to 'text', a NewTextTemplate instance will be created instead of a MarkupTemplate.

render_template(self, req, filename, data, content_type=None, fragment=False, iterable=False, method=None)

source code 

Render the filename using the data for the context.

The content_type argument is used to choose the kind of template used (NewTextTemplate if 'text/plain', MarkupTemplate otherwise), and tweak the rendering process. Doctype for 'text/html' can be specified by setting the html_doctype attribute (default is XHTML_STRICT)

The rendering method (xml, xhtml or text) may be specified and is inferred from the content_type if not specified.

When fragment is specified, the (filtered) Genshi stream is returned.

When iterable is specified, the content as an iterable instance which is generated from filtered Genshi stream is returned.

iterable_content(self, stream, method, **kwargs)

source code 
Generate an iterable object which iterates str instances from the given stream instance.
Parameters:
  • method - the serialization method; can be either "xml", "xhtml", "html", "text", or a custom serializer class

authorinfo(self, req, author, email_map=None, resource=None)

source code 

Format a username to HTML.

Calls Chrome.format_author to format the username, and wraps the formatted username in a span with class trac-author, trac-author-anonymous or trac-author-none.

Parameters:
  • req - the Request object.
  • author - the author string to be formatted.
  • email_map - dictionary mapping usernames to email addresses.
  • resource - optional Resource object for EMAIL_VIEW fine-grained permissions checks.

format_author(self, req, author, resource=None, show_email=None)

source code 

Format a username in plain text.

If [trac] show_email_addresses is False, email addresses will be obfuscated when the user doesn't have EMAIL_VIEW (for the resource) and the optional parameter show_email is None. Returns translated anonymous or none, when the author string is anonymous or evaluates to False, respectively.

Parameters:
  • req - a Request or RenderingContext object.
  • author - the author string to be formatted.
  • resource - an optional Resource object for performing fine-grained permission checks for EMAIL_VIEW.
  • show_email - an optional parameter that allows explicit control of e-mail obfuscation.

format_emails(self, context, value, sep=', ')

source code 
Normalize a list of e-mails and obfuscate them if needed.
Parameters:
  • context - the context in which the check for obfuscation should be done
  • value - a string containing a comma-separated list of e-mails
  • sep - the separator to use when rendering the list again

Class Variable Details

jquery_ui_theme_location

Value:
<Option [trac] 'jquery_ui_theme_location'>

never_obfuscate_mailto

Value:
<BoolOption [trac] 'never_obfuscate_mailto'>

auto_preview_timeout

Value:
<FloatOption [trac] 'auto_preview_timeout'>

default_dateinfo_format

Value:
<ChoiceOption [trac] 'default_dateinfo_format'>

html_doctype

Value:
('html',
 '-//W3C//DTD XHTML 1.0 Strict//EN',
 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd')

Property Details

navigation_contributors

List of components that implement ~trac.web.chrome.INavigationContributor
Get Method:
unreachable.extensions(component) - Return a list of components that declare to implement the extension point interface.

template_providers

List of components that implement ~trac.web.chrome.ITemplateProvider
Get Method:
unreachable.extensions(component) - Return a list of components that declare to implement the extension point interface.

stream_filters

List of components that implement ~trac.web.api.ITemplateStreamFilter
Get Method:
unreachable.extensions(component) - Return a list of components that declare to implement the extension point interface.