Beispiel #1
0
 def source_js_url(self, url, **kwargs):
     if not kwargs.pop('relative_path', False):
         url = abs_static_url(url)
     else:
         url = static_url(url)
     script_tag = HTML.script(type='text/javascript', src=url, **kwargs)
     self.data['x-script-tags'].append(script_tag)
     return u''
Beispiel #2
0
 def link_css_url(self, url, **kwargs):
     if not kwargs.pop('relative_path', False):
         url = abs_static_url(url)
     else:
         url = static_url(url)
     link_tag = HTML.link(rel='stylesheet', type='text/css', href=url, **kwargs)
     self.data['x-link-tags'].append(link_tag)
     return u''
Beispiel #3
0
def static_files(app):
    settings = ag.app.settings

    if settings.static_files.enabled:
        # serve static files from static directory (e.g. after copying
        # from the source packages; use static-copy command for that)
        if settings.static_files.location == 'static':
            exported_dirs = {'/' + routing.static_url('/'): settings.dirs.static}
            return SharedDataMiddleware(app, exported_dirs)
        # serve static files from source packages based on hierarchy rules
        return StaticFileServer(app)
    return app
Beispiel #4
0
def static_files(app):
    settings = ag.app.settings

    if settings.static_files.enabled:
        # serve static files from static directory (e.g. after copying
        # from the source packages; use static-copy command for that)
        if settings.static_files.location == 'static':
            exported_dirs = {
                '/' + routing.static_url('/'): settings.dirs.static
            }
            return SharedDataMiddleware(app, exported_dirs)
        # serve static files from source packages based on hierarchy rules
        return StaticFileServer(app)
    return app
Beispiel #5
0
 def __init__(self, app, **kwargs):
     exports = {'/' + routing.static_url('/'): ''}
     SharedDataMiddleware.__init__(self, app, exports, **kwargs)
Beispiel #6
0
 def test_routes(self):
     eq_('http://static.example.com/app/c/styles.css', static_url('app/c/styles.css'))
     eq_('http://static.example.com/app/c/styles.css', static_url('/app/c/styles.css'))
     settings.routing.static_prefix = '/static'
     eq_('/static/app/c/styles.css', static_url('/app/c/styles.css'))
Beispiel #7
0
 def __init__(self, app, **kwargs):
     exports = {'/' + routing.static_url('/'): ''}
     SharedDataMiddleware.__init__(self, app, exports, **kwargs)