Ejemplo n.º 1
0
def _setup_env(app='', debug=True, cache=True):
    """Setup the webassets environment."""
    if app:
        app_path = path.join('..', '..', app, 'static')
        env = Environment(path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
                          path.join(BASE_LOCATION, '..'))
    else:
        app_path = path.join('..', 'static')
        env = Environment(path.join(INPUT_FILES, '..', '..', 'skel', 'assets'),
                          path.join(BASE_LOCATION))

    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config[
            'CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_skel(app_path, env, debug)

    #css
    _bundle_3rd_party_css(app_path, env, debug)

    #images
    _bundle_images(app, env, is_skel=True)

    return env
Ejemplo n.º 2
0
    def test_url_and_directory(self):
        """The url and directory options are a bit special, because they
        are so essential.
        """

        # An environment can be constructed without given url or directory.
        env = Environment()
        # But then accessing them will fail, and with it most operations.
        assert_raises(EnvironmentError, getattr, env, 'url')
        assert_raises(EnvironmentError, getattr, env, 'directory')

        # Test constructing the environment with values for url and directory
        env = Environment('foo', 'bar')
        assert env.directory == 'foo'
        assert env.url == 'bar'
Ejemplo n.º 3
0
def create_assets_env(generator):
    """Define the assets environment and pass it to the generator."""

    theme_static_dir = generator.settings['THEME_STATIC_DIR']
    assets_src = os.path.join(generator.output_path, theme_static_dir)
    generator.env.assets_environment = Environment(assets_src,
                                                   theme_static_dir)

    if 'ASSET_CONFIG' in generator.settings:
        for item in generator.settings['ASSET_CONFIG']:
            generator.env.assets_environment.config[item[0]] = item[1]

    if 'ASSET_BUNDLES' in generator.settings:
        for name, args, kwargs in generator.settings['ASSET_BUNDLES']:
            generator.env.assets_environment.register(name, *args, **kwargs)

    if logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG":
        generator.env.assets_environment.debug = True

    if 'ASSET_SOURCE_PATHS' in generator.settings:
        # the default load path gets overridden if additional paths are
        # specified, add it back
        generator.env.assets_environment.append_path(assets_src)
        for path in generator.settings['ASSET_SOURCE_PATHS']:
            full_path = os.path.join(generator.theme, path)
            generator.env.assets_environment.append_path(full_path)
Ejemplo n.º 4
0
def compileJavascript():
    environment = Environment('vendor/bootstrap/js/', 'javascript')
    output = '../../../codemitts/resources/static/javascript/bootstrap.js'
    bootstrap_javascript_bundle = Bundle('*', output=output)
    environment.register('bootstrap_javascript_bundle',
                         bootstrap_javascript_bundle)
    environment['bootstrap_javascript_bundle'].urls()
Ejemplo n.º 5
0
def webassets_init():
    global env

    static_path = get_webassets_path()

    public = config.get(u'ckan.base_public_folder')

    public_folder = os.path.abspath(
        os.path.join(os.path.dirname(__file__), u'..', public))

    base_path = os.path.join(public_folder, u'base')

    env = Environment()
    env.directory = static_path
    env.debug = asbool(config.get(u'debug', False))
    env.url = u'/webassets/'

    add_public_path(base_path, u'/base/')

    logger.debug(u'Base path {0}'.format(base_path))
    create_library(u'vendor', os.path.join(base_path, u'vendor'))

    create_library(u'base', os.path.join(base_path, u'javascript'))

    create_library(u'datapreview', os.path.join(base_path, u'datapreview'))

    create_library(u'css', os.path.join(base_path, u'css'))
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
def _setup_env(debug=True, cache=True):
    """Setup the webassets environment."""
    env = Environment(INPUT_FILES, OUTPUT_FILES)
    # We use underscore's templates by default.
    env.config['JST_COMPILER'] = '_.template'
    if debug:
        env.config['CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'WHITESPACE_ONLY'
        env.manifest = False
    else:
        env.config[
            'CLOSURE_COMPRESSOR_OPTIMIZATION'] = 'ADVANCED_OPTIMIZATIONS'

    env.debug = False
    env.cache = cache

    #javascript
    _bundle_app_jsts(env, debug)
    _bundle_app_coffee(env, debug)
    _bundle_3rd_party_js(env, debug)

    #css
    _bundle_app_less(env, debug)
    _bundle_3rd_party_css(env, debug)

    #images
    _bundle_images(env)

    return env
Ejemplo n.º 8
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()
Ejemplo n.º 9
0
def create_assets_env(generator):
    """Define the assets environment and pass it to the generator."""

    theme_static_dir = generator.settings["THEME_STATIC_DIR"]
    assets_destination = os.path.join(generator.output_path, theme_static_dir)
    generator.env.assets_environment = Environment(assets_destination,
                                                   theme_static_dir)

    if "ASSET_CONFIG" in generator.settings:
        for item in generator.settings["ASSET_CONFIG"]:
            generator.env.assets_environment.config[item[0]] = item[1]

    if "ASSET_BUNDLES" in generator.settings:
        for name, args, kwargs in generator.settings["ASSET_BUNDLES"]:
            generator.env.assets_environment.register(name, *args, **kwargs)

    if "ASSET_DEBUG" in generator.settings:
        generator.env.assets_environment.debug = generator.settings[
            "ASSET_DEBUG"]
    elif logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG":
        generator.env.assets_environment.debug = True

    for path in generator.settings[
            "THEME_STATIC_PATHS"] + generator.settings.get(
                "ASSET_SOURCE_PATHS", []):
        full_path = os.path.join(generator.theme, path)
        generator.env.assets_environment.append_path(full_path)
Ejemplo n.º 10
0
    def make_webassets_env_from_config(self, options, config):
        settings = {}
        settings.update(options)
        settings.update(
            coerce_config(
                config, 'webassets.', {
                    'debug': asbool,
                    'auto_build': asbool,
                    'manifest': self.string_or_bool,
                    'url_expire': asbool,
                    'cache': self.string_or_bool,
                    'load_path': aslist
                }))

        static_files_path = config['paths']['static_files']
        asset_dir = settings.pop('base_dir', static_files_path)

        asset_url = settings.pop('base_url', '/')
        if not asset_url.startswith('/'):
            if urlparse(asset_url).scheme == '':
                asset_url = '/' + asset_url

        assets_env = Environment(asset_dir, asset_url, **settings)

        bundles = self.options.get('bundles', {})
        for name, value in bundles.items():
            if isinstance(value, Bundle):
                assets_env.register(name, value)
            else:
                # If it's not a bundle consider it a loader
                assets_env.register(value.load_bundles())

        return assets_env
Ejemplo n.º 11
0
 def test_initial_values_override_defaults(self):
     """[Bug] If a dict of initial values are passed to the
     environment, they override any defaults the environment might
     want to set.
     """
     env = Environment(None, None, debug='foo')
     assert env.debug == 'foo'
Ejemplo n.º 12
0
    def test_options(self):
        """Test option declaration.
        """
        class TestFilter(Filter):
            options = {
                'attr1': 'ATTR1',
                'attr2': ('secondattr', 'ATTR2'),
                'attr3': (False, 'ATTR3'),
                'attr4': ('attr4', False),
            }

        # Test __init__ arguments
        assert TestFilter(attr1='foo').attr1 == 'foo'
        assert TestFilter(secondattr='foo').attr2 == 'foo'
        assert_raises(TypeError, TestFilter, attr3='foo')
        assert TestFilter(attr4='foo').attr4 == 'foo'

        # Test config vars
        env = Environment(None, None)
        env.config['attr1'] = 'bar'
        env.config['attr4'] = 'bar'
        f = TestFilter()
        f.env = env
        f.setup()
        assert f.attr1 == 'bar'
        assert f.attr4 is None  # Was configured to not support env
Ejemplo n.º 13
0
    def get_assets_bottom_js_env(self, code_path, output_path):
        """ The directory structure of assets is:
            output_path
                static
                    css
                    js
        """
        output_path = os.path.join(output_path, 'static')
        assets_env = Environment(output_path, '/static', debug=self.args.debug)
        assets_env.config['compass_config'] = {
            'additional_import_paths':
            [os.path.join(code_path, 'scss-mixins')],
            #'sass_options': "cache: False", ??? i can't get it.
            'http_path': "/static",
        }

        bottom_js_list = []
        if "bottom_js" in self.config.data:
            bottom_js_list = self.config.data["bottom_js"]
            if bottom_js_list and len(bottom_js_list):
                bottom_js = Bundle(*bottom_js_list,
                                   filters='rjsmin',
                                   output='bottom.js')
                assets_env.register('bottom_js', bottom_js)

        return assets_env
Ejemplo n.º 14
0
    def get_assets_css_env(self, code_path, output_path):
        """ The directory structure of assets is:
            output_path
                static
                    css
                    js
        """
        output_path = os.path.join(output_path, 'static')
        assets_env = Environment(output_path, '/static', debug=self.args.debug)

        assets_env.config['compass_config'] = {
            'additional_import_paths':
            [os.path.join(code_path, 'scss-mixins')],
            #'sass_options': "cache: False", ??? i can't get it.
            'http_path': "/static",
        }

        css_list = []
        scss_list = []

        if "css_or_scss" in self.config.data:
            for filename in self.config.data["css_or_scss"]:
                if self.args.verbose:
                    print('Adding filename: %s' % (filename))
                ext = os.path.splitext(filename)[1]
                if ext == '.scss':
                    scss_list.append(filename)
                elif ext == '.css':
                    css_list.append(filename)
                else:
                    raise Exception(
                        'Bad extension: is %s instead of css/scss' % ext)

        if len(css_list) or len(scss_list):
            css_bundle = Bundle(*css_list)

            scss_bundle = []
            for scss_file in scss_list:
                if self.args.verbose:
                    print('Processing filename: %s' % (scss_file))
                try:
                    xxx = Bundle(
                        scss_file,
                        filters='compass',
                        output=scss_file + '.css',
                    )
                    scss_bundle.append(xxx)
                except Exception as error:
                    print("ERROR processing filename '%s': %s" %
                          (scss_file, error))

            css = Bundle(css_bundle,
                         *scss_bundle,
                         filters='cssutils,cssrewrite',
                         output='packed.css')
            assets_env.register('css', css)

        return assets_env
Ejemplo n.º 15
0
    def setup(self):
        self.dir_created = tempfile.mkdtemp()
        self.m = Environment(self.dir_created, '')
        # Unless we explicitly test it, we don't want to use the cache
        # during testing.
        self.m.cache = False

        # Some generic files to be used by simple tests
        self.create_files(self.default_files)
Ejemplo n.º 16
0
def create_assets_env(generator):
    """Define the assets environment and pass it to the generator."""

    assets_url = 'theme/'
    assets_src = os.path.join(generator.output_path, 'theme')
    generator.env.assets_environment = Environment(assets_src, assets_url)

    logger = logging.getLogger(__name__)
    if logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG":
        generator.env.assets_environment.debug = True
Ejemplo n.º 17
0
def includeme(config):
    """pyramid include. declare the add_thumb_view"""
    here = os.path.dirname(__file__)
    settings = config.registry.settings

    config_dir = settings.get('garasu_webassets.config', '{}/configs'.format(here))
    LOG.debug(config_dir)
    # config_dir = AssetResolver(None).resolve(config_dir).abspath()
    asset_dir = settings.get('garasu_webassets.assets', '{}/assets'.format(here))
    LOG.debug(asset_dir)
    # asset_dir = AssetResolver(None).resolve(asset_dir).abspath()

    env = Environment(directory=asset_dir, url=settings['garasu_webassets.url'])
    env.manifest = settings['garasu_webassets.manifest']
    env.debug = asbool(settings['garasu_webassets.debug'])
    env.cache = asbool(settings['garasu_webassets.cache'])
    env.auto_build = asbool(settings['garasu_webassets.auto_build'])

    def text(value):
        if type(value) is six.binary_type:
            return value.decode('utf-8')
        else:
            return value

    def yaml_stream(fname, mode):
        if path.exists(fname):
            return open(fname, mode)
        raise FileNotFoundError

    fin = fileinput.input('/'.join([config_dir, settings['garasu_webassets.bundles']]),
                          openhook=yaml_stream)
    with closing(fin):
        lines = [text(line).rstrip() for line in fin]

    stream_yaml = six.StringIO('\n'.join(lines))
    loader = YAMLLoader(stream_yaml)
    result = loader.load_bundles()
    env.register(result)

    # for item in env:
    #     LOG.debug(item.output)
    #     path_file = '/'.join([public_dir, item.output])
    #     src_file = '/'.join([asset_dir, item.output])
    #     shutil.copy(src_file, path_file)

    def _get_assets(request, *args, **kwargs):
        bundle = Bundle(*args, **kwargs)
        with bundle.bind(env):
            urls = bundle.urls()
        return urls
    config.add_request_method(_get_assets, 'web_assets')

    def _get_assets_env(request):
        return env
    config.add_request_method(_get_assets_env, 'web_env', reify=True)
Ejemplo n.º 18
0
    def get_template_namespace(self):
        _ = super(BaseHandler, self).get_template_namespace()

        self.assets = Environment(
            os.path.join(os.path.dirname(__file__), '../static'), '/static')
        css_all = Bundle('css/bootstrap.min.css',
                         'css/material.min.css',
                         Bundle('css/schoolcms.css',
                                'css/dropdown.css',
                                filters='cssmin'),
                         'outdatedbrowser/outdatedbrowser.min.css',
                         output='dict/plugin.min.css')
        js_all = Bundle(Bundle('outdatedbrowser/outdatedbrowser.min.js',
                               'react-0.13.2/react-with-addons.min.js',
                               'js/jquery-2.1.3.min.js',
                               'js/bootstrap.min.js',
                               'js/react-bootstrap.min.js',
                               'js/react-mini-router.min.js',
                               'js/marked.min.js',
                               'js/material.min.js',
                               'js/isMobile.min.js',
                               'js/moment-with-locales.min.js',
                               'js/dropdown.js',
                               filters='jsmin'),
                        Bundle('schoolcms/init.jsx',
                               'schoolcms/mixin/*.jsx',
                               'schoolcms/component/*.jsx',
                               'schoolcms/page/*.jsx',
                               filters=('react', 'jsmin')),
                        output='dict/plugin.min.js')
        self.assets.register('css_all', css_all)
        self.assets.register('js_all', js_all)

        _['css_urls'] = self.assets['css_all'].urls()
        _['js_urls'] = self.assets['js_all'].urls()
        _['system_name'] = options.system_name
        _['SERVER_DEBUG'] = options.server_debug
        _['ip'] = self.request.remote_ip
        _['system_version'] = system_version
        _['_host'] = self.request.host
        _['_protocol'] = self.request.protocol

        if self.current_user:
            groups = GroupList.get_user_groups(self.current_user.key,
                                               self.sql_session)
        else:
            groups = []
        _['current_user'] = self.current_user.to_dict(
        ) if self.current_user else None
        _['current_groups'] = groups

        # Call this to set the cookie
        self.xsrf_token

        return _
Ejemplo n.º 19
0
    def test_jinja2_config(self):
        app_config = self.basic_valid_app_config.copy()
        dict_loader = DictLoader({})
        app_config.update({"jinja2": {"loader": dict_loader,
                                      "use_webassets": True}})

        webassets_env = Environment("/tmp", "/")
        webassets_env.register("js", "dummy.js", "dummy2.js", output="dummy.js")
        config = BlueberryPyConfiguration(app_config=app_config,
                                          webassets_env=webassets_env)
        self.assertEqual(config.jinja2_config, {"loader": dict_loader})
Ejemplo n.º 20
0
    def test_use_webassets(self):
        app_config = self.basic_valid_app_config.copy()
        app_config.update({"jinja2": {"use_webassets": True,
                                      "loader": DictLoader({})}})
        self.assertRaisesRegexp(BlueberryPyNotConfiguredError,
                                "Webassets configuration not found.",
                                callable_obj=BlueberryPyConfiguration,
                                app_config=app_config)

        webassets_env = Environment("/tmp", "/")
        self.assertRaisesRegexp(BlueberryPyNotConfiguredError,
                                "No bundles found in webassets env.",
                                callable_obj=BlueberryPyConfiguration,
                                app_config=app_config,
                                webassets_env=webassets_env)

        webassets_env = Environment("/tmp", "/")
        webassets_env.register("js", "dummy.js", "dummy2.js", output="dummy.js")
        config = BlueberryPyConfiguration(app_config=app_config,
                                          webassets_env=webassets_env)
        self.assertTrue(config.use_webassets)
Ejemplo n.º 21
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()
Ejemplo n.º 22
0
    def test_append_load_path(self):
        env = Environment()
        assert env.load_path == []

        env.append_path('foo', '/foo')
        assert env.load_path == ['foo']
        assert env.url_mapping == {'foo': '/foo'}

        # Works without path
        env.append_path('bar')
        assert env.load_path == ['foo', 'bar']
        assert env.url_mapping == {'foo': '/foo'}
 def setUp(self):
     res = dirname(__file__)+'/resources/'
     self.env = Environment(dirname(__file__)+"/out", '/media-prefix')
     self.env.cache = False
     self.env.manifest = False
     
     self.env.append_path(res+"assets", "/")
     self.env.append_path(res+"vendor", "/vendors")
     
     self.env.append_path(res, None)
     
     self.env.config["compass_bin"] = "/home/arkus/.gem/ruby/1.9.1/bin/compass"
     self.env.config["vendor_path"] = "vendor"
Ejemplo n.º 24
0
def create_assets_env(generator):
    """Define the assets environment and pass it to the generator."""

    assets_url = 'theme/'
    assets_src = os.path.join(generator.output_path, 'theme')
    generator.env.assets_environment = Environment(assets_src, assets_url)

    if 'ASSET_CONFIG' in generator.settings:
        for item in generator.settings['ASSET_CONFIG']:
            generator.env.assets_environment.config[item[0]] = item[1]

    if logging.getLevelName(logger.getEffectiveLevel()) == "DEBUG":
        generator.env.assets_environment.debug = True
Ejemplo n.º 25
0
    def load_environment(self):
        """Load an ``Environment`` instance defined in the YAML file.

        Expects the following format::

            directory: ../static
            url: /media
            debug: True
            updater: timestamp

            bundles:
                bundle-name:
                    filters: sass,cssutils
                    output: cache/default.css
                    contents:
                        - css/jquery.ui.calendar.css
                        - css/jquery.ui.slider.css
        """
        f, filename = self._open()
        try:
            obj = self.yaml.load(f) or {}

            # construct the environment
            if not 'url' in obj or not 'directory' in obj:
                raise LoaderError('"url" and "directory" must be defined')
            directory = obj['directory']
            if filename:
                # If we know the location of the file, make sure that the
                # paths included are considered relative to the file location.
                directory = path.normpath(
                    path.join(path.dirname(filename), directory))
            env = Environment(directory, obj['url'])

            # load environment settings
            for setting in (
                    'debug',
                    'cache',
                    'updater',
                    'expire',
            ):
                if setting in obj:
                    setattr(env, setting, obj[setting])

            # load bundles
            bundles = self._get_bundles(obj.get('bundles', {}))
            for name, bundle in bundles.iteritems():
                env.register(name, bundle)

            return env
        finally:
            f.close()
Ejemplo n.º 26
0
    def test_getconfig_os_env_types(self):
        """Test type conversion for values read from the environment.
        """
        m = Environment(None, None)
        f = Filter()
        f.set_environment(m)
        get_config = f.get_config

        with os_environ_sandbox():
            os.environ['foo'] = 'one,two\,three'
            assert get_config(env='foo', type=list) == ['one', 'two,three']

            # Make sure the split is not applied to env config values
            m.config['foo'] = 'one,two\,three'
            assert get_config(setting='foo', type=list) == 'one,two\,three'
Ejemplo n.º 27
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()
Ejemplo n.º 28
0
 def _setup_assets(self):
     config = Config.getInstance()
     url_base_path = urlparse(config.getBaseURL()).path
     output_dir = os.path.join(config.getHtdocsDir(), 'static', 'assets',
                               'plugins', self.name)
     output_url = '{}/static/assets/plugins/{}'.format(
         url_base_path, self.name)
     static_dir = os.path.join(self.root_path, 'static')
     static_url = '{}/static/plugins/{}'.format(url_base_path, self.name)
     self.assets = Environment(output_dir,
                               output_url,
                               debug=config.getDebug())
     self.assets.append_path(output_dir, output_url)
     self.assets.append_path(static_dir, static_url)
     configure_pyscss(self.assets)
     self.register_assets()
Ejemplo n.º 29
0
    def __init__(self, rh):
        config = Config.getInstance()
        self._rh = rh
        self._locTZ = ""

        self._asset_env = Environment(config.getHtdocsDir(), '/')

        # This is done in order to avoid the problem sending the error report because the DB is not connected.
        if DBMgr.getInstance().isConnected():
            info = HelperMaKaCInfo.getMaKaCInfoInstance()
            self._asset_env.debug = info.isDebugActive()

        # register existing assets
        assets.register_all_js(self._asset_env)

        #store page specific CSS and JS
        self._extraCSS = []
        self._extraJS = []
Ejemplo n.º 30
0
def main():
    my_env = Environment(directory='static', url='/static')

    #
    # The js for every pge
    all_js = Bundle(
        Bundle(*vendor_js),
        Bundle('coffee/common.coffee', filters='coffeescript'),
        # filters='jsmin',
        output='all.js')
    my_env.register('all_js', all_js)

    #
    # Per-page coffee
    page_bundles = []
    for file in os.listdir(os.path.join(os.path.abspath('.'),
                                        'static/coffee')):
        if file.endswith('.coffee') and not file.startswith(
                '#') and file != 'common.coffee':
            bundle_name = file.split('.')[0]
            bundle = Bundle(os.path.join('coffee', file),
                            filters='coffeescript',
                            output='%s.js' % bundle_name)
            my_env.register(bundle_name, bundle)
            page_bundles.append(bundle_name)

    #
    # CSS for every page
    all_css = Bundle(
        Bundle(*vendor_css
               # filters='cssmin'
               ),
        output='all.css')
    my_env.register('all_css', all_css)

    for js_url in my_env['all_js'].urls():
        print(js_url)

    for css_url in my_env['all_css'].urls():
        print(css_url)

    for page_bundle in page_bundles:
        for url in my_env[page_bundle].urls():
            print(url)