From d7cfe6672dcfb561a12f60091751362d0309226e Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:33:24 +0100 Subject: [PATCH 1/9] flake8 config --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 setup.cfg 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 From fa79fe9102903a12650216b546445df1074dd14d Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:34:02 +0100 Subject: [PATCH 2/9] pull down govuk frontend assets --- build.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..a22f500 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +curl -L https://github.com/alphagov/govuk-frontend/releases/download/v3.7.0/release-v3.7.0.zip > govuk_frontend.zip +unzip -o govuk_frontend.zip -d app/static +rm govuk_frontend.zip \ No newline at end of file From d9a5403e1c51773fc7fe9232117e3b7e7af2d382 Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:34:13 +0100 Subject: [PATCH 3/9] ignore static assets --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) 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 From 3aa9994ea62f41176dab4324e7c6e0dad8ed4c6e Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:35:19 +0100 Subject: [PATCH 4/9] change static url path --- app/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'), From da145b88810e32ddb1318a91a3c4b7a78f6bee4f Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:35:39 +0100 Subject: [PATCH 5/9] set assetPath, CSS & JS paths --- app/templates/index.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/templates/index.html b/app/templates/index.html index 2e45fae..9442849 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='assets').rstrip('/') %} + +{% block head %} + + +{% endblock %} + +{% block bodyEnd %} + + + + +{% endblock %} + {% block content %}
From 1479b683cf51c6857f20463c19c100a460e0a74e Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 12:38:51 +0100 Subject: [PATCH 6/9] run build script on start --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 2244873f93ffbe7316cd1785315a39b9374b4f7a Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 13:07:43 +0100 Subject: [PATCH 7/9] move assets to static --- build.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index a22f500..c4c5851 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +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 -rm govuk_frontend.zip \ No newline at end of file +mv app/static/assets/* app/static +rm -rf app/static/assets +rm -rf govuk_frontend.zip \ No newline at end of file From 4543ab9cf99f4328720407f9605f20565c4f3f4f Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 13:07:57 +0100 Subject: [PATCH 8/9] change asset dir --- app/templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/index.html b/app/templates/index.html index 9442849..dcc3211 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -28,7 +28,7 @@ {%- 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='assets').rstrip('/') %} +{% set assetPath = url_for('static', filename='').rstrip('/') %} {% block head %} From d96e36ae2c23056c51e76bd2368c329107aa0ab2 Mon Sep 17 00:00:00 2001 From: Matt Shaw Date: Thu, 25 Jun 2020 13:48:20 +0100 Subject: [PATCH 9/9] 0.3.0 --- CHANGEOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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