From fd4c4107ac01af465d8334b1e8fa31e746ced2cf Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 15 Dec 2015 11:56:37 +0000 Subject: [PATCH] Remove Flask Assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit’s parent introduces a Node-based way of managing front end assets. Nothing else is needed in the app, specifically not Flask Assets. Flask itself automatically routes requests for `domain.tld/static/*` to the files in `app/static`. This also removes all the Ruby stuff. --- Gemfile | 2 -- Gemfile.lock | 13 --------- Procfile | 2 +- app.py | 2 -- app/__init__.py | 73 ------------------------------------------------ requirements.txt | 3 +- 6 files changed, 2 insertions(+), 93 deletions(-) delete mode 100644 Gemfile delete mode 100644 Gemfile.lock diff --git a/Gemfile b/Gemfile deleted file mode 100644 index e46ea120f..000000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source 'https://rubygems.org' -gem 'sass' diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index bb229915d..000000000 --- a/Gemfile.lock +++ /dev/null @@ -1,13 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - sass (3.4.19) - -PLATFORMS - ruby - -DEPENDENCIES - sass - -BUNDLED WITH - 1.10.6 diff --git a/Procfile b/Procfile index 33594db01..bd846ba9a 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: python app.py runserver \ No newline at end of file +web: python app.py runserver diff --git a/app.py b/app.py index e69af42b5..dc26c70cc 100644 --- a/app.py +++ b/app.py @@ -1,8 +1,6 @@ import os -from flask.ext import assets from flask.ext.script import Manager, Server from flask_migrate import Migrate, MigrateCommand -from webassets.filter import get_filter from app import create_app, db diff --git a/app/__init__.py b/app/__init__.py index e875a3bc1..498230fe3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -73,84 +73,11 @@ def init_app(app): if key in os.environ: app.config[key] = convert_to_boolean(os.environ[key]) - init_asset_environment(app) - @app.context_processor def inject_global_template_variables(): return {'asset_path': '/static/'} -def init_asset_environment(app): - env = assets.Environment(app) - - # Tell flask-assets where to look for our sass files. - env.load_path = [ - os.path.join(os.path.dirname(__file__), 'assets'), - os.path.join(os.path.dirname(__file__), 'assets/stylesheets'), - os.path.join(os.path.dirname(__file__), 'assets/stylesheets/stylesheets/govuk_frontend_toolkit'), - os.path.join(os.path.dirname(__file__), 'assets/stylesheets/govuk_template'), - os.path.join(os.path.dirname(__file__), 'assets/stylesheets/views'), - os.path.join(os.path.dirname(__file__), 'assets/stylesheets/components'), - ] - - scss = get_filter('scss', as_output=True) - - env.register( - 'css_all', - assets.Bundle( - 'main.scss', - filters='scss', - output='stylesheets/css_all.css' - ) - ) - - env.register( - 'css_govuk-template', - assets.Bundle( - 'govuk_template/govuk-template.scss', - filters='scss', - output='stylesheets/govuk-template.css', - depends='*.scss' - ) - ) - - env.register( - 'css_govuk-template-ie6', - assets.Bundle( - 'govuk_template/govuk-template-ie6.scss', - filters='scss', - output='stylesheets/govuk-template-ie6.css' - ) - ) - - env.register( - 'css_govuk-template-ie7', - assets.Bundle( - 'govuk_template/govuk-template-ie7.scss', - filters='scss', - output='stylesheets/govuk-template-ie7.css' - ) - ) - - env.register( - 'css_govuk-template-ie8', - assets.Bundle( - 'govuk_template/govuk-template-ie8.scss', - filters='scss', - output='stylesheets/govuk-template-ie8.css' - ) - ) - - env.register( - 'css_govuk-template-print', - assets.Bundle( - 'govuk_template/govuk-template-print.scss', - filters='scss', - output='stylesheets/govuk-template-print.css' - ) - ) - - def convert_to_boolean(value): if isinstance(value, string_types): if value.lower() in ['t', 'true', 'on', 'yes', '1']: diff --git a/requirements.txt b/requirements.txt index aaa53cebc..42b66ee5a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ Flask==0.10.1 Flask-Script==2.0.5 -Flask-Assets==0.11 Flask-Migrate==1.3.1 Flask-SQLAlchemy==2.0 psycopg2==2.6.1 @@ -10,4 +9,4 @@ Flask-WTF==0.11 Flask-Login==0.2.11 Flask-Bcrypt==0.6.2 -git+https://github.com/alphagov/notify-api-client.git@0.1.4#egg=notify-api-client==0.1.4 \ No newline at end of file +git+https://github.com/alphagov/notify-api-client.git@0.1.4#egg=notify-api-client==0.1.4