Пример #1
0
  def test_excluded_urls(self):
    app = Flask(__name__)
    appcache = Appcache(app)

    appcache.add_excluded_urls("/static/develop")
    appcache.add_urls("/static/develop/js.js")
    self.assertEquals(0, len(appcache.urls))

    appcache.add_urls("/static/js.js")
    self.assertEquals(1, len(appcache.urls))

    app = Flask(__name__)
    appcache = Appcache(app)

    appcache.add_excluded_urls("/static/ignored")
    appcache.add_folder("test_ignore", base="/static")
    urls = list(appcache.urls)
    self.assertEquals(1, len(urls))
    self.assertEquals("/static/not_ignored", urls[0])
Пример #2
0
    def test_excluded_urls(self):
        app = Flask(__name__)
        appcache = Appcache(app)

        appcache.add_excluded_urls("/static/develop")
        appcache.add_urls("/static/develop/js.js")
        self.assertEquals(0, len(appcache.urls))

        appcache.add_urls("/static/js.js")
        self.assertEquals(1, len(appcache.urls))

        app = Flask(__name__)
        appcache = Appcache(app)

        appcache.add_excluded_urls("/static/ignored")
        appcache.add_folder("test_ignore", base="/static")
        urls = list(appcache.urls)
        self.assertEquals(1, len(urls))
        self.assertEquals("/static/not_ignored", urls[0])
Пример #3
0
    """)
    for root, subdir, fnames in os.walk('static/partials'):
        for filename in fnames:
            if filename.endswith('.html'):
                with open(os.path.join(root, filename)) as f:
                    content = f.read().decode('utf-8')
                    content = unicode(content)

                PARTIALS += inline_partial.format(path=('/static/partials/' +
                                                        filename),
                                                  content=content)

# Sets up Appcache
appcache = Appcache(app)
if app.debug:
    appcache.add_excluded_urls('/static/js/app.min.js',
                               '/static/css/app.min.css')
else:
    appcache.add_excluded_urls('/static/js/develop')
    appcache.add_excluded_urls('/static/css/develop')
    appcache.add_excluded_urls('/static/partials')

appcache.add_excluded_urls('/static/js/tests')
appcache.add_excluded_urls('/static/.webassets-cache')
appcache.add_folder('static')
appcache.add_urls('/meta.js', '/')


@app.before_request
def before_request():
    app.jinja_env.globals['partials'] = PARTIALS
Пример #4
0
    """)
    for root, subdir, fnames in os.walk('static/partials'):
        for filename in fnames:
            if filename.endswith('.html'):
                with open(os.path.join(root, filename)) as f:
                    content = f.read().decode('utf-8')
                    content = unicode(content)

                PARTIALS += inline_partial.format(path=('/static/partials/' +
                                                        filename),
                                                  content=content)

# Sets up Appcache
appcache = Appcache(app)
if app.debug:
    appcache.add_excluded_urls('/static/js/app.min.js',
                               '/static/css/app.min.css')
else:
    appcache.add_excluded_urls('/static/js/develop')
    appcache.add_excluded_urls('/static/css/develop')
    appcache.add_excluded_urls('/static/partials')

appcache.add_excluded_urls('/static/js/tests')
appcache.add_excluded_urls('/static/.webassets-cache')
appcache.add_folder('static')
appcache.add_urls('/meta.js', '/')


@app.before_request
def before_request():
    app.jinja_env.globals['partials'] = PARTIALS