diff --git a/.gitignore b/.gitignore index 77383f0..ec85c36 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ # Created by https://www.toptal.com/developers/gitignore/api/python,flask # Edit at https://www.toptal.com/developers/gitignore?templates=python,flask +### GOV.UK Frontend ### +app/static* + ### Flask ### instance/* !instance/.gitignore diff --git a/CHANGEOG.md b/CHANGEOG.md index 296664a..78ce9e7 100644 --- a/CHANGEOG.md +++ b/CHANGEOG.md @@ -4,10 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/matthew-shaw/govuk-frontend-jinja-example/compare/0.2.0...master) +## [Unreleased](https://github.com/matthew-shaw/govuk-frontend-jinja-example/compare/0.3.0...master) + +## [0.3.0](https://github.com/matthew-shaw/govuk-frontend-jinja-example/releases/tag/0.3.0) - 25/06/2020 ### Added +- Script to pull down [GOV.UK Frontend](https://github.com/alphagov/govuk-frontend/) to the app's `static` directory +- Set asset paths to get static CSS, JS and image content - `Procfile` and `gunicorn` requirements to deploy to Heroku ## [0.2.0](https://github.com/matthew-shaw/govuk-frontend-jinja-example/releases/tag/0.2.0) - 18/06/2020 diff --git a/Procfile b/Procfile index 93f040b..207a3e9 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: gunicorn app:app --log-file - \ No newline at end of file +web: ./build.sh; gunicorn app:app --log-file - \ No newline at end of file diff --git a/app/__init__.py b/app/__init__.py index 8052693..16355fa 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,7 +1,7 @@ from flask import Flask from jinja2 import ChoiceLoader, PackageLoader, PrefixLoader -app = Flask(__name__) +app = Flask(__name__, static_url_path='/assets') app.jinja_loader = ChoiceLoader([ PackageLoader('app'), diff --git a/app/templates/index.html b/app/templates/index.html index 2e45fae..dcc3211 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -28,6 +28,20 @@ {%- from 'govuk_frontend_jinja/components/accordion/macro.html' import govukAccordion -%} {%- from 'govuk_frontend_jinja/components/tag/macro.html' import govukTag -%} +{% set assetPath = url_for('static', filename='').rstrip('/') %} + +{% block head %} + + +{% endblock %} + +{% block bodyEnd %} + + + + +{% endblock %} + {% block content %}
diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c4c5851 --- /dev/null +++ b/build.sh @@ -0,0 +1,6 @@ +curl -L https://github.com/alphagov/govuk-frontend/releases/download/v3.7.0/release-v3.7.0.zip > govuk_frontend.zip +rm -rf app/static +unzip -o govuk_frontend.zip -d app/static +mv app/static/assets/* app/static +rm -rf app/static/assets +rm -rf govuk_frontend.zip \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..75c9a81 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[flake8] +exclude = venv +max-line-length = 120 \ No newline at end of file