Esempio n. 1
0
def add_standard_template_values(template_values):

    # Specify base template based on whether this is a pjax request
    template_values[
        'base_template'] = 'base_pjax.html' if utils.is_pjax_request(
        ) else 'base.html'

    # Authentication information
    # NOTE: This may fall foul of template output caching if used by routes that allow caching.
    if users.is_signed_in():
        template_values['nickname'] = users.get_current_user().nickname()
        template_values['auth_url'] = users.create_google_signout_url()
    else:
        template_values['nickname'] = None
        template_values['auth_url'] = users.create_google_signin_url()

    # Make configuration settings available to templates
    template_values['settings'] = settings
    template_values['route_configs'] = routes.configs

    # Identify local versus deployed
    template_values['is_local'] = utils.is_local()

    # Set defaults for page title and active nav
    nav_title = routes.configs.get().nav_title
    template_values[
        'title'] = nav_title + ' - ' + settings.app_title if nav_title else settings.app_title
    template_values['active_nav'] = routes.configs.get().name

    return template_values
Esempio n. 2
0
def add_standard_template_values(template_values):

    # Specify base template based on whether this is a pjax request
    template_values['base_template'] = 'base_pjax.html' if utils.is_pjax_request() else 'base.html'

    # Authentication information
    # NOTE: This may fall foul of template output caching if used by routes that allow caching.
    if users.is_signed_in():
        template_values['nickname'] = users.get_current_user().nickname()
        template_values['auth_url'] = users.create_google_signout_url()
    else:
        template_values['nickname'] = None
        template_values['auth_url'] = users.create_google_signin_url()

    # Make configuration settings available to templates
    template_values['settings'] = settings
    template_values['route_configs'] = routes.configs

    # Identify local versus deployed
    template_values['is_local'] = utils.is_local()

    # Set defaults for page title and active nav
    nav_title = routes.configs.get().nav_title
    template_values['title'] =  nav_title + ' - ' + settings.app_title if nav_title else settings.app_title
    template_values['active_nav'] = routes.configs.get().name

    return template_values
Esempio n. 3
0
def template_cachekey(routeconfig_name=None, *args):
    """
    Generates a key that is unique to the given or current RouteConfig and whether the request is a PJAX request
    :param routeconfig_name: Name of RouteConfig. Defaults to the current request's RouteConfig
    :type routeconfig_name: str
    :return: The template filename for the given template name.
    """
    return (routeconfig_name or routes.configs.get().name) + '-' + str(utils.is_pjax_request())
Esempio n. 4
0
def template_cachekey(routeconfig_name=None, *args):
    """
    Generates a key that is unique to the given or current RouteConfig and whether the request is a PJAX request
    :param routeconfig_name: Name of RouteConfig. Defaults to the current request's RouteConfig
    :type routeconfig_name: str
    :return: The template filename for the given template name.
    """
    return (routeconfig_name or routes.configs.get().name) + '-' + str(
        utils.is_pjax_request())