Пример #1
0
def _bundle_3rd_party_js(env, debug=False):
    """Combine thrid party js libs into libs.js.

    For debug, they are left uncompressed.  For production the minified
    versions are used.  We suggest using hte vendor supplied minified version
    of each library.
    """
    JSPATH = path.join('js', 'lib')
    if debug:
        all_js = Bundle(
            path.join(JSPATH, 'json2.js'),
            path.join(JSPATH, 'jquery.js'),
            path.join(JSPATH, 'underscore.js'),
            path.join(JSPATH, 'backbone.js'),
            path.join(JSPATH, 'bootstrap.js'),
            path.join(JSPATH, 'leaflet.js'),
            path.join(JSPATH, 'bootstrap-typeahead-improved.js'),
            output=path.join('..', 'static', 'script', 'libs.js')
        )
    else:
        JSPATH = path.join(JSPATH, 'min')
        all_js = Bundle(
            path.join(JSPATH, 'json2.min.js'),
            path.join(JSPATH, 'jquery-min.js'),
            path.join(JSPATH, 'underscore-min.js'),
            path.join(JSPATH, 'backbone-min.js'),
            path.join(JSPATH, 'bootstrap-min.js'),
            path.join(JSPATH, 'leaflet-min.js'),
            path.join(JSPATH, 'bootstrap-typeahead-improved-min.js'),
            output=path.join('..', 'static', 'script', 'libs.js')
        )

    env.add(all_js)
    if debug:
        all_js.build()
Пример #2
0
def _bundle_3rd_party_js(env, debug=False):
    """Combine thrid party js libs into libs.js.

    For debug, they are left uncompressed.  For production the minified
    versions are used.  We suggest using hte vendor supplied minified version
    of each library.
    """
    JSPATH = path.join('js', 'lib')
    if debug:
        all_js = Bundle(path.join(JSPATH, 'json2.js'),
                        path.join(JSPATH, 'jquery.js'),
                        path.join(JSPATH, 'underscore.js'),
                        path.join(JSPATH, 'backbone.js'),
                        path.join(JSPATH, 'bootstrap.js'),
                        path.join(JSPATH, 'leaflet.js'),
                        path.join(JSPATH, 'bootstrap-typeahead-improved.js'),
                        output=path.join('..', 'static', 'script', 'libs.js'))
    else:
        JSPATH = path.join(JSPATH, 'min')
        all_js = Bundle(path.join(JSPATH, 'json2.min.js'),
                        path.join(JSPATH, 'jquery-min.js'),
                        path.join(JSPATH, 'underscore-min.js'),
                        path.join(JSPATH, 'backbone-min.js'),
                        path.join(JSPATH, 'bootstrap-min.js'),
                        path.join(JSPATH, 'leaflet-min.js'),
                        path.join(JSPATH,
                                  'bootstrap-typeahead-improved-min.js'),
                        output=path.join('..', 'static', 'script', 'libs.js'))

    env.add(all_js)
    if debug:
        all_js.build()
Пример #3
0
def _bundle_3rd_party_js(app, env, debug=False):
    """Combine thrid party js libs into libs.js.

    For debug, they are left uncompressed.  For production the minified
    versions are used.  We suggest using hte vendor supplied minified version
    of each library.
    """
    JSPATH = path.join('js', 'lib')

    if debug:
        scripts = ()
        if not scripts:
            return

        all_js = Bundle(
            *scripts,
            output=path.join('..', '..', app, 'static', 'script', 'libs.js')
        )
    else:
        JSPATH = path.join(JSPATH, 'min')

        scripts = ()
        if not scripts:
            return

        all_js = Bundle(
            *scripts,
            output=path.join('..', '..', app, 'static', 'script', 'libs.js')
        )

    env.add(all_js)
    if debug:
        all_js.build()
 def get_bundle_output(self, test_name):
     f = StringIO()
     js = Bundle('scss/%s.scss' % test_name, filters=CompassConnectorFilter, output='%s.css' % test_name)
     self.env.register(test_name, js)
     js.build(output=f)
     
     return f.getvalue()
Пример #5
0
def _bundle_3rd_party_js(app, env, debug=False):
    """Combine thrid party js libs into libs.js.

    For debug, they are left uncompressed.  For production the minified
    versions are used.  We suggest using hte vendor supplied minified version
    of each library.
    """
    JSPATH = path.join('js', 'lib')

    if debug:
        scripts = ()
        if not scripts:
            return

        all_js = Bundle(*scripts,
                        output=path.join('..', '..', app, 'static', 'script',
                                         'libs.js'))
    else:
        JSPATH = path.join(JSPATH, 'min')

        scripts = ()
        if not scripts:
            return

        all_js = Bundle(*scripts,
                        output=path.join('..', '..', app, 'static', 'script',
                                         'libs.js'))

    env.add(all_js)
    if debug:
        all_js.build()
Пример #6
0
    def test(self):
        bundle = Bundle("one.css", "two.css", output="styles.css")
        assets_env = create_assets_env(
            source_dir="./tests/fixtures/bundle", build_dir=self.build_dir, static_url="/", bundles={}
        )
        bundle.build(env=assets_env)

        self.assertTrue("styles.css" in os.listdir(self.build_dir))
Пример #7
0
 def register_tpl_bundle(self, name, *files):
     def noop(_in, out, **kw):
         out.write(_in.read())
     bundle = Bundle(*files, filters=(noop,), output='tpls/{}'.format(name))
     fileName = bundle.resolve_output(self.assets)
     if os.path.isfile(fileName):
         os.remove(fileName)
     bundle.build(self.assets,force=False,disable_cache=True)
     self.assets.register(name, bundle)
def create_and_register_bundles(section, filter, DEPLOY):
    environment = Environment('.')
    for option in config.options(section):
        deps = [v.strip() for v in config.get(section, option).split(',')]
        log.info("%s.%s has dependencies: %s", option, section, deps)
        bndl = Bundle(*deps, filters=filter,
                      output=concat_string([DEPLOY, '/', option, '.', section]))
        environment.register(option, bndl)
        bndlgz = Bundle(*deps, filters=concat_string([filter, ', gzip']),
                      output=concat_string([DEPLOY, '/', option, '.', section, '.gz']))
        environment.register(concat_string([option, 'gz']), bndlgz)
        bndl.build()
        bndlgz.build()
def configure_assets(flask_app):
    assets = Environment(flask_app)
    style_bundle = Bundle(
        'assets/scss/slider.scss',
        filters=
        'pyscss',  # https://webassets.readthedocs.io/en/latest/builtin_filters.html#pyscss
        output='dist/css/slider.min.css',
        extra={'rel': 'stylesheet/css'})
    assets.register('main_styles', style_bundle)
    js_bundle = Bundle(
        'assets/js/slider.js',
        'assets/js/modal.js',
        filters=
        'rjsmin',  # https://webassets.readthedocs.io/en/latest/builtin_filters.html#rjsmin
        output='dist/js/custom.min.js')
    assets.register('main_js', js_bundle)
    style_bundle.build()
    js_bundle.build()
Пример #10
0
def compressFile(f, webFilters):
    filePath = os.path.join(webFolder, f)
    baseName = os.path.basename(filePath)
    prefix = f[0:len(f) - len(baseName)]
    fn = os.path.splitext(baseName)
    newFileName = fn[0] + '.%(version)s' + fn[1]
    env = Environment("")
    env.auto_build = False
    env.url_expire = True
    tmpFile = os.path.join(tempFolder, newFileName)
    env.url_mapping = {tempFolder: ''}
    bundle = Bundle(filePath, filters=webFilters, output=tmpFile)
    env.add(bundle)
    bundle.build()
    vfn = bundle.urls()[0][1:]
    if (vfn.index("?") > 0):
        vfn = vfn[0:vfn.index("?")]

    #print(prefix, vfn)
    zf.write(os.path.join(tempFolder, vfn), prefix + vfn)
    return prefix + vfn
Пример #11
0
#!/usr/bin/env python
from os import path
from webassets import Bundle, Environment

env = Environment(path.join(path.dirname(__file__), 'static'), '/stylesheets')
# App Engine doesn't support automatic rebuilding.
env.auto_build = False
# This file needs to be shipped with your code.
env.manifest = 'file'

bundle = Bundle('in.css', filters="cssmin", output="out.css")
env.add(bundle)


if __name__== "__main__":
    # If this file is called directly, do a manual build.
    bundle.build()
Пример #12
0
 def test_output(self):
     environment = Environment(path.dirname(__file__))
     bundle = Bundle('input.jsx', output='input.js', filters=('react',))
     environment.register('test_bundle', bundle)
     bundle.build()
Пример #13
0
#!/usr/bin/env python
from os import path
from webassets import Bundle, Environment

env = Environment(path.join(path.dirname(__file__), 'static'), '/stylesheets')
# App Engine doesn't support automatic rebuilding.
env.updater = False
# URL expiry not currently supported on App Engine
env.expire = False

bundle = Bundle('in.css', filters="cssmin", output="out.css")
env.add(bundle)


if __name__== "__main__":
    # If this file is called directly, do a manual build.
    bundle.build()
Пример #14
0
    def test(self):
        bundle = Bundle('one.css', 'two.css', output='styles.css')
        assets_env = create_assets_env('./tests/fixtures/bundle', self.build_dir, {})
        bundle.build(env=assets_env)

        self.assertTrue('styles.css' in os.listdir(self.build_dir))