Пример #1
0
def register_assets(app):
  _css_files = ["css/base.css", "css/app.css"]
  for module in LOADED_MODULES:
    for fname in get_files_from_module(module, "css", "css"):
      _css_files.append("api_v1_" + module + "/css/" + fname)

  css_all = Bundle(
      *_css_files,
      filters="cssmin",
      output="css/app.min.css"
  )

  _js_files = list(get_files_in_directory("js/develop", ".js", excludes=["app.min.js", "app.js"]))
  for module in LOADED_MODULES:
    for fname in get_files_from_module(module, "js", "js"):
      _js_files.append("api_v1_" + module + "/js/" + fname)

  js_all = Bundle("js/develop/app.js", *_js_files, filters="uglifyjs", output="js/app.min.js")

  assets.init_app(app)
  # work around bug https://github.com/miracle2k/flask-assets/issues/54
  assets.app = app
  assets.auto_build = app.debug
  assets.debug = app.debug
  assets.register("js_all", js_all)
  assets.register("css_all", css_all)
  if not app.debug:
    partials_template = '<script id="{path}" type="text/ng-template">{content}</script>'
    global _partials
    _partials = ""
    for module in LOADED_MODULES:
      for fname in get_files_from_module(module, "partials", "html"):
        # TODO: look at this hack.
        with app.test_request_context():
          path = url_for("api_v1_" + module + ".static", filename="partials/" + fname)

        with open(os.path.join(APP_FOLDER, "projecto", "apiv1", module, "static", "partials", fname)) as g:
          content = g.read()
        _partials += partials_template.format(path=path, content=content)

    css_all.build()
    js_all.build()
Пример #2
0
assets = Environment(app)
assets.url = app.static_url_path

css_all = Bundle(
    'css/*.css',
    filters='cssmin',
    output='dist/css_all.css'
)

js_all = Bundle(
    'js/vendor/jquery-1.11.0.min.js',  # order matters
    'js/vendor/*.js', 'js/*.js',
    filters='jsmin',
    output='dist/js_all.js'
)

assets.register('js_all', js_all)
assets.register('css_all', css_all)

assets.add(js_all)
assets.add(css_all)

js_all.build()
css_all.build()


from views import *

if __name__ == '__main__':
    app.run()
Пример #3
0
logger = app.logger

################ ASSETS MANAGEMENT ################
# right now just minification and concatenation

assets = Environment(app)
assets.url = app.static_url_path

css_all = Bundle('css/*.css', filters='cssmin', output='dist/css_all.css')

js_all = Bundle(
    'js/vendor/jquery-1.11.0.min.js',  # order matters
    'js/vendor/*.js',
    'js/*.js',
    filters='jsmin',
    output='dist/js_all.js')

assets.register('js_all', js_all)
assets.register('css_all', css_all)

assets.add(js_all)
assets.add(css_all)

js_all.build()
css_all.build()

from views import *

if __name__ == '__main__':
    app.run()
Пример #4
0
    output='css/app.min.css'
)
assets.register('css_all', css)

scripts = ['js/develop/app.js']
for root, subdir, fnames in os.walk('static/js/develop'):
    for filename in fnames:
        if filename.endswith('.js') and filename != 'app.js':
            # get rid of te 'static/'
            scripts.append(os.path.join(root, filename)[7:])

js = Bundle(*scripts, filters='uglifyjs', output='js/app.min.js')
assets.register('js_all', js)

if not app.debug:
    css.build()
    js.build()

# Sets up the angular partials
PARTIALS = u''
if not app.debug:
    inline_partial = unicode("""
    <script id="{path}" type="text/ng-template">
    {content}
    </script>
    """)
    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')
Пример #5
0
    TEMPLATES_AUTO_RELOAD = True
)

assets = Environment(app)
assets.url = app.static_url_path


# for development
# Don't cache otherwise it won't build every time
assets.cache = False
assets.manifest = False
app.config['ASSETS_DEBUG'] = True

scss = Bundle('style.scss', filters='pyscss', output='all.css')
assets.register('scss_all', scss)
scss.build()

js_files = ['js/mustache.js', 'mustache/mustache-loader.js', 'js/mui.js', 'js/main.js']
js = Bundle(*js_files, filters='jsmin', output='packed.js')
assets.register('js_all', js)
js.build()

assets.init_app(app)


global case_bucket
case_bucket = None

def create_celery_app():
    """Create a Celery app instance."""
    app = create_app()
Пример #6
0
             filters='cssmin',
             output='css/app.min.css')
assets.register('css_all', css)

scripts = ['js/develop/app.js']
for root, subdir, fnames in os.walk('static/js/develop'):
    for filename in fnames:
        if filename.endswith('.js') and filename != 'app.js':
            # get rid of te 'static/'
            scripts.append(os.path.join(root, filename)[7:])

js = Bundle(*scripts, filters='uglifyjs', output='js/app.min.js')
assets.register('js_all', js)

if not app.debug:
    css.build()
    js.build()

# Sets up the angular partials
PARTIALS = u''
if not app.debug:
    inline_partial = unicode("""
    <script id="{path}" type="text/ng-template">
    {content}
    </script>
    """)
    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')