Beispiel #1
0
 def url_for_static(filename, version = None, minify = None, alt = None):
     min = '.min' if (minify is None and app.config['USE_MINIFIED_ASSETS']) or minify else ''
     alt = '' # '-alt' if (alt is None and cache_context.is_alt_statics) or alt else ''
     
     filename = filename % dict(min = min, alt = alt)
     version  = version or app.config['STATIC_VERSION'][0:app.config['VERSION_STRING_LENGTH']]
     version  = str(version).rjust(app.config['VERSION_STRING_LENGTH'], "_")
     
     return static_url(url_for('static', version = version, filename = filename))
Beispiel #2
0
    def static(filename, version = None):
        from flask.helpers import send_from_directory
        r = send_from_directory(app.config['STATIC_DIR'], filename)

        if version and version != app.config['STATIC_VERSION']:
            return redirect(static_url(url_for('static', filename = filename, version = app.config['STATIC_VERSION'])))

        r.headers['Access-Control-Allow-Origin'] = '*'

        return r