コード例 #1
0
    def run(self):
        from webassets import Bundle
        from webassets import Environment
        from webassets.script import CommandLineEnvironment

        css = Bundle('curious/src/css/app.css',
                     output='curious/dist/curious.css')
        js = Bundle('curious/src/js/*.js', output='curious/dist/curious.js')
        jsm = Bundle('curious/src/js/*.js',
                     filters='jsmin',
                     output='curious/dist/curious.min.js')
        jst = Bundle('curious/src/html/*.html',
                     filters='jst',
                     output='curious/dist/curious_jst.js')

        assets_env = Environment('./curious/static')
        assets_env.cache = self.cache_dir
        assets_env.register('css', css)
        assets_env.register('js', js)
        assets_env.register('jsmin', jsm)
        assets_env.register('jst', jst)

        log = logging.getLogger('webassets')
        log.addHandler(logging.StreamHandler())
        log.setLevel(logging.DEBUG)

        cmdenv = CommandLineEnvironment(assets_env, log)
        cmdenv.build()
コード例 #2
0
def main():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    call(["coffee", "-c", "src/tambur.coffee"])
    call(["coffee", "-c", "src/tambur_publisher.coffee"])

    env = Environment('.', '/static')
    jsonjs = Bundle(
            'deps/json2.js', filters='yui_js', output='out/json2.min.js')
    sockjs = Bundle(
            'deps/web_socket.js', filters='yui_js', output='out/web_socket.min.js')
    tamburjs = Bundle(
            'deps/swfobject.js',
            'src/tambur.js', output='out/tambur.js')
    tamburminjs = Bundle(
            'deps/swfobject.js',
            'src/tambur.js', filters='yui_js', output='out/tambur.min.js')
    publishjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', output='out/tambur_pub.js')
    publishminjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js')
    env.register('tambur.js', tamburjs)
    env.register('tambur.min.js', tamburminjs)
    env.register('tambur_pub.js', publishjs)
    env.register('tambur_pub.min.js', publishminjs)
    env.register('json2.js', jsonjs)
    env.register('web_socket.js', sockjs)
    cmdenv = CommandLineEnvironment(env, log)
    cmdenv.build()
コード例 #3
0
 def _build_webassets(self):
     # Set up a logger
     log = logging.getLogger('webassets')
     log.addHandler(logging.StreamHandler())
     log.setLevel(logging.DEBUG)
     cmdenv = CommandLineEnvironment(self.webassets_env, log)
     cmdenv.build()
コード例 #4
0
ファイル: assets.py プロジェクト: tamburio/tambur.js
def main():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    call(["coffee", "-c", "src/tambur.coffee"])
    call(["coffee", "-c", "src/tambur_publisher.coffee"])

    env = Environment('.', '/static')
    tamburjs = Bundle(
            'deps/sockjs-0.3.js',
            'src/tambur.js', output='out/tambur.js')
    tamburminjs = Bundle(
            'deps/sockjs-0.3.js',
            'src/tambur.js', filters='yui_js', output='out/tambur.min.js')
    publishjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', output='out/tambur_pub.js')
    publishminjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js')
    env.register('tambur.js', tamburjs)
    env.register('tambur.min.js', tamburminjs)
    env.register('tambur_pub.js', publishjs)
    env.register('tambur_pub.min.js', publishminjs)
    cmdenv = CommandLineEnvironment(env, log)
    cmdenv.build()
コード例 #5
0
ファイル: __init__.py プロジェクト: gharp/Ubiqu-Ity
 def _build_webassets(self):
     # Set up a logger
     log = logging.getLogger('webassets')
     log.addHandler(logging.StreamHandler())
     log.setLevel(logging.DEBUG)
     cmdenv = CommandLineEnvironment(self.webassets_env, log)
     cmdenv.build()
コード例 #6
0
def build_assets():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #7
0
ファイル: static.py プロジェクト: rossjones/udata
def static(path, input):
    '''Compile and collect static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    if exists(path):
        print('"{0}" directory already exists and will be erased'.format(path))
        if input and not prompt_bool('Are you sure'):
            exit(-1)

    cmdenv = CommandLineEnvironment(assets, log)
    # cmdenv.clean()
    cmdenv.build(production=True)

    print('Deleting static directory {0}'.format(path))
    shutil.rmtree(path)

    print('Copying assets into "{0}"'.format(path))
    shutil.copytree(assets.directory, path)

    for prefix, source in manager.app.config['STATIC_DIRS']:
        print('Copying %s to %s', source, prefix)
        destination_path = join(path, prefix)
        if not exists(destination_path):
            makedirs(destination_path)
        for filename in iglob(join(source, '*')):
            print(filename)
            if isdir(filename):
                continue
            shutil.copy(filename, destination_path)
        # shutil.copy(static_dir, path)

    print('Done')
コード例 #8
0
ファイル: kulfon.py プロジェクト: nukomeet/kulfon
def js():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.WARNING)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #9
0
ファイル: cli.py プロジェクト: mardix/Mocha
def build_assets(app):
    from webassets.script import CommandLineEnvironment
    assets_env = app.jinja_env.assets_environment
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)
    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #10
0
    def run(self):
        assets_env = get_webassets_env({
            'debug': False,
            'static_files_dir': STATIC,
        })

        cmdenv = CommandLineEnvironment(assets_env, log)
        cmdenv.build()

        self.copy_assets()
コード例 #11
0
def gen_static():
    # Setup a logger
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)
    assets_env = Environment()
    assets_env.directory = "static/"
    assets_env.debug = True
    assets_env.register(bundles)
    cmdenv = CommandLineEnvironment(assets_env, log)
    # This would also work
    cmdenv.build()
コード例 #12
0
ファイル: cli.py プロジェクト: mardix/flask-magic
def build_assets(mod):
    from webassets.script import CommandLineEnvironment

    module = import_module(mod, True)
    assets_env = module.app.jinja_env.assets_environment

    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #13
0
ファイル: cli.py プロジェクト: mardix/webportfolio
def _buildassets(app):

    from webassets.script import CommandLineEnvironment

    module = get_app_serve_module(app)
    assets_env = module.app.jinja_env.assets_environment

    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #14
0
def scss_compile(static_path):
    webassets = Environment()
    webassets.directory = static_path
    webassets.url = static_path
    webassets.register('css_all', css_all)
    #webassets.manifest = 'cache' if not app.debug else False
    webassets.manifest = False
    webassets.cache = False
    webassets.debug = False
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)
    cmdenv = CommandLineEnvironment(webassets, log)
    # This would also work
    cmdenv.build()
コード例 #15
0
def init_app(app):
    """
    Initilize assets.
    :param app:
    """
    if app.debug:
        webassets = Environment(app)
        webassets.url = app.static_url_path
        webassets.register('css_all', css_all)
        webassets.manifest = False
        webassets.cache = False
        webassets.debug = False
        webassets.cache = not app.debug
        webassets.debug = app.debug
        log = logging.getLogger('webassets')
        log.addHandler(logging.StreamHandler())
        log.setLevel(logging.DEBUG)
        cmdenv = CommandLineEnvironment(webassets, log)
        cmdenv.build()
コード例 #16
0
ファイル: commands.py プロジェクト: gitter-badger/cada
def static(path, input):
    '''Compile and collect static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        print('"{0}" directory already exists and will be erased'.format(path))
        if input and not prompt_bool('Are you sure'):
            exit(-1)
        shutil.rmtree(path)

    print('Copying assets into "{0}"'.format(path))
    shutil.copytree(assets.directory, path)

    print('Done')
コード例 #17
0
ファイル: commands.py プロジェクト: pborreli/cada
def static(path, input):
    '''Compile and collect static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        print('"{0}" directory already exists and will be erased'.format(path))
        if input and not prompt_bool('Are you sure'):
            exit(-1)
        shutil.rmtree(path)

    print('Copying assets into "{0}"'.format(path))
    shutil.copytree(assets.directory, path)

    print('Done')
コード例 #18
0
ファイル: commands.py プロジェクト: psorianom/cada
def static(path, no_input):
    '''Compile and collect static files into path'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        warning('{0} directory already exists and will be {1}', white(path), white('erased'))
        if not no_input and not click.confirm('Are you sure'):
            exit_with_error()
        shutil.rmtree(path)

    echo('Copying assets into {0}', white(path))
    shutil.copytree(assets.directory, path)

    success('Done')
コード例 #19
0
ファイル: commands.py プロジェクト: etalab/cada
def static(path, no_input):
    '''Compile and collect static files into path'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build()

    if exists(path):
        warning('{0} directory already exists and will be {1}', white(path), white('erased'))
        if not no_input and not click.confirm('Are you sure'):
            exit_with_error()
        shutil.rmtree(path)

    echo('Copying assets into {0}', white(path))
    shutil.copytree(assets.directory, path)

    success('Done')
コード例 #20
0
def bundle(**kwargs):
    """
    Webassets bundle management.

    usage: blueberrypy bundle [options]

    Before you can use this command to bundle up your Web assets, you should
    have created either a project skeleton using the 'create' command or
    provided a configuration directory using the global option -c --config_dir.

    options:
      -h, --help                                show this help message and exit
      -C ENV_VAR_NAME, --env-var ENV_VAR_NAME   add the given config from
                                                environment variable name
                                                [default: BLUEBERRYPY_CONFIG]
      -b, --build                               build the asset bundles
      -w, --watch                               automatically rebuild the
                                                asset bundles upon changes in
                                                the static directory
      -c, --clean                               delete the generated asset bundles

    """

    config = BlueberryPyConfiguration(config_dir=kwargs.get('config_dir'),
                                      env_var_name=kwargs.get('env_var'))

    assets_env = config.webassets_env
    if not assets_env:
        raise BlueberryPyNotConfiguredError("Webassets configuration not found.")

    from webassets.script import CommandLineEnvironment
    assets_cli = CommandLineEnvironment(assets_env, logger)

    if kwargs.get("build"):
        try:
            assets_cli.build()
        except AttributeError:
            assets_cli.rebuild()
    elif kwargs.get("watch"):
        assets_cli.watch()
    elif kwargs.get("clean"):
        assets_cli.clean()
コード例 #21
0
ファイル: static.py プロジェクト: guillo-w/udata
def build():
    '''Compile static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    # Override some local config
    current_app.config['DEBUG'] = False
    current_app.config['ASSETS_DEBUG'] = False
    current_app.config['REQUIREJS_RUN_IN_DEBUG'] = True

    cmdenv = CommandLineEnvironment(theme.assets, log)
    cmdenv.build(production=True)

    print('Performing require.js optimization')
    buildfile = join(theme.assets.directory, 'js', 'app.build.js')
    # bust = 'pragmas.bust={0}'.format(time.time())
    params = ['r.js', '-o', buildfile]
    subprocess.call(params)

    print('Done')
コード例 #22
0
ファイル: static.py プロジェクト: pombredanne/udata
def build():
    '''Compile static files'''
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    # Override some local config
    current_app.config['DEBUG'] = False
    current_app.config['ASSETS_DEBUG'] = False
    current_app.config['REQUIREJS_RUN_IN_DEBUG'] = True

    cmdenv = CommandLineEnvironment(assets, log)
    cmdenv.build(production=True)

    print('Performing require.js optimization')
    buildfile = join(assets.directory, 'js', 'app.build.js')
    # bust = 'pragmas.bust={0}'.format(time.time())
    params = ['r.js', '-o', buildfile]
    subprocess.call(params)

    print('Done')
コード例 #23
0
ファイル: assets.py プロジェクト: slavah/tambur.js
def main():
    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    env = Environment('.', '/static')
    jsonjs = Bundle(
            'deps/json2.js', filters='yui_js', output='out/json2.min.js')
    sockjs = Bundle(
            'deps/web_socket.js', filters='yui_js', output='out/web_socket.min.js')
    tamburjs = Bundle(
            'deps/swfobject.js',
            'src/tambur_comet_fallback.js',
            'src/tambur_connection.js',
            'src/tambur_logger.js',
            'src/tambur_utils.js',
            'src/tambur_stream.js', output='out/tambur.js')
    tamburminjs = Bundle(
            'deps/swfobject.js',
            'src/tambur_comet_fallback.js',
            'src/tambur_connection.js',
            'src/tambur_logger.js',
            'src/tambur_utils.js',
            'src/tambur_stream.js', filters='yui_js', output='out/tambur.min.js')
    publishjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', output='out/tambur_pub.js')
    publishminjs = Bundle(
            'deps/sha1.js',
            'deps/oauth.js',
            'src/tambur_publisher.js', filters='yui_js', output='out/tambur_pub.min.js')
    env.register('tambur.js', tamburjs)
    env.register('tambur.min.js', tamburminjs)
    env.register('tambur_pub.js', publishjs)
    env.register('tambur_pub.min.js', publishminjs)
    env.register('json2.js', jsonjs)
    env.register('web_socket.js', sockjs)
    cmdenv = CommandLineEnvironment(env, log)
    cmdenv.build()
コード例 #24
0
ファイル: gen.py プロジェクト: PyConChina/PyConChina2016
def _init_webassets(debug=False, generate=False):
    assets_env = Environment(directory=SITE_ASSET_DIR,
                             url=SITE_ASSET_URL_PREFIX,
                             cache=WEBASSETS_CACHE_DIR,
                             load_path=[SITE_ASSET_SRC_DIR])
    assets_env.debug = debug

    js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js')
    css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css')

    assets_env.register('app_js', js)
    assets_env.register('app_css', css)

    cmd = CommandLineEnvironment(assets_env, log)

    if generate:
        cmd.build()
        return assets_env

    Process(target=lambda: cmd.watch()).start()

    return assets_env
コード例 #25
0
ファイル: gen.py プロジェクト: s270987763/PyConChina2016
def _init_webassets(debug=False, generate=False):
    assets_env = Environment(directory=SITE_ASSET_DIR,
                             url=SITE_ASSET_URL_PREFIX,
                             cache=WEBASSETS_CACHE_DIR,
                             load_path=[SITE_ASSET_SRC_DIR])
    assets_env.debug = debug

    js = Bundle('js/*.js', filters='uglifyjs', output='js/app.js')
    css = Bundle('sass/*.scss', filters='scss,cssmin', output='css/app.css')

    assets_env.register('app_js', js)
    assets_env.register('app_css', css)

    cmd = CommandLineEnvironment(assets_env, log)

    if generate:
        cmd.build()
        return assets_env

    Process(target=lambda: cmd.watch()).start()

    return assets_env
コード例 #26
0
ファイル: setup.py プロジェクト: benjiec/curious
  def run(self):
    from webassets import Bundle
    from webassets import Environment
    from webassets.script import CommandLineEnvironment

    css = Bundle('curious/src/css/app.css', output='curious/dist/curious.css')
    js = Bundle('curious/src/js/*.js', output='curious/dist/curious.js')
    jsmin = Bundle('curious/src/js/*.js', filters='jsmin', output='curious/dist/curious.min.js')
    jst = Bundle('curious/src/html/*.html', filters='jst', output='curious/dist/curious_jst.js')

    assets_env = Environment('./curious/static')
    assets_env.cache = self.cache_dir
    assets_env.register('css', css)
    assets_env.register('js', js)
    assets_env.register('jsmin', jsmin)
    assets_env.register('jst', jst)

    log = logging.getLogger('webassets')
    log.addHandler(logging.StreamHandler())
    log.setLevel(logging.DEBUG)

    cmdenv = CommandLineEnvironment(assets_env, log)
    cmdenv.build()
コード例 #27
0
ファイル: command.py プロジェクト: wyuenho/blueberrypy
def bundle(**kwargs):
    """
    Webassets bundle management.

    usage: blueberrypy bundle [options]

    Before you can use this command to bundle up your Web assets, you should
    have created either a project skeleton using the 'create' command or
    provided a configuration directory using the global option -c --config_dir.

    options:
      -h, --help   show this help message and exit
      -b, --build  build the asset bundles
      -w, --watch  automatically rebuild the asset bundles upon changes in the
                   static directory
      -c, --clean  delete the generated asset bundles

    """

    config = BlueberryPyConfiguration(config_dir=kwargs.get("config_dir"))

    assets_env = config.webassets_env
    if not assets_env:
        raise BlueberryPyNotConfiguredError("Webassets configuration not found.")

    from webassets.script import CommandLineEnvironment
    assets_cli = CommandLineEnvironment(assets_env, logger)

    if kwargs.get("build"):
        try:
            assets_cli.build()
        except AttributeError:
            assets_cli.rebuild()
    elif kwargs.get("watch"):
        assets_cli.watch()
    elif kwargs.get("clean"):
        assets_cli.clean()
コード例 #28
0
ファイル: skel_assets.py プロジェクト: lyddonb/gae-skeleton
def build(app='', debug=True, cache=True):
    env = _setup_env(app, debug, cache)
    log = _load_logger()
    cmdenv = CommandLineEnvironment(env, log)

    cmdenv.build()
コード例 #29
0
ファイル: __init__.py プロジェクト: gregersn/whathappened
def build():
    """Build bundles."""
    cmdenv = CommandLineEnvironment(current_app.jinja_env.assets_environment, logger)
    cmdenv.build()
コード例 #30
0
import logging
from os import makedirs, path

from webassets.script import CommandLineEnvironment
from cunhajacaiu import assets
from cunhajacaiu.settings import STATIC_PATH

for dir in ('css', 'js'):
    makedirs(path.join(path.abspath(STATIC_PATH), dir), exist_ok=True)

log = logging.getLogger('webassets')
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)

cli = CommandLineEnvironment(assets, log)
cli.build()
コード例 #31
0
ファイル: pack_js.py プロジェクト: ardinor/mojibake
import logging

from webassets import Environment
from webassets import Bundle
from webassets.script import CommandLineEnvironment

# Bundle and minify the javascript
# Since Flask isn't serving the JS this needs to be done here
# before the static files are pulled down on nginx
# Kind of not the way I was hoping to handle this

log = logging.getLogger('webassets')
log.addHandler(logging.StreamHandler())
log.setLevel(logging.DEBUG)

env = Environment('mojibake/static', '/static')
js = Bundle('js/jquery.min.js',
            'js/jquery-ui.custom.js',
            'js/skel.min.js',
            'js/skel-panels.min.js',
            'js/init.js',
            'js/mojibake.js',
            filters='jsmin',
            output='js/packed.js')
env.register('js_all', js)

# From the docs
# https://webassets.readthedocs.org/en/latest/script.html
cmdenv = CommandLineEnvironment(env, log)
cmdenv.build()
コード例 #32
0
def build(app='', debug=True, cache=True):
    env = _setup_env(app, debug, cache)
    log = _load_logger()
    cmdenv = CommandLineEnvironment(env, log)

    cmdenv.build()
コード例 #33
0
def compile():
    """Compile assets."""

    log = logging.getLogger(__name__)
    cmd = CommandLineEnvironment(get_env(), log)
    cmd.build()
コード例 #34
0
ファイル: assets.py プロジェクト: user419/sandstorm-radicale
                    metavar='command',
                    default='build',
                    help='build, watch or clean')
args = parser.parse_args()

# Setup a logger
log = logging.getLogger('webassets')
log.addHandler(logging.StreamHandler())
log.setLevel(logging.__dict__[args.loglevel])

loader = PythonLoader('webassets_config')
assets_env = loader.load_environment()
assets_env.debug = args.debug

cmdenv = CommandLineEnvironment(assets_env, log)
cmdenv.build()

if args.debug:
    print("The following files are produced by assets pipeline:")
    print(assets_env['js'].urls())
    print(assets_env['css'].urls())

if args.command != 'build':
    cmdenv.invoke(args.command, {})

if args.reference:
    index = open(args.reference_tmpl, 'r')
    index_contents = index.read()
    index.close()

    js_prepped = [
コード例 #35
0
def compile():
    """Compile assets."""

    log = logging.getLogger(__name__)
    cmd = CommandLineEnvironment(get_env(), log)
    cmd.build()
コード例 #36
0
ファイル: commands.py プロジェクト: TheNixNinja/rsvp-python
def compile():
    assets_cle = CommandLineEnvironment(current_app.assets, current_app.logger)
    assets_cle.build()