From 40653e5c18fd442b82d94efe6071419830f781b1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 9 Jan 2017 22:14:38 +0000 Subject: [PATCH 01/53] Start removing Makefile --- .gitignore | 1 - .gitmodules | 7 +++ Makefile | 64 +------------------------ circle.yml | 16 ------- package.json | 4 ++ pelican_plugins | 1 + config/pelicanconf.py => pelicanconf.py | 6 +-- 7 files changed, 17 insertions(+), 82 deletions(-) create mode 100644 .gitmodules create mode 160000 pelican_plugins rename config/pelicanconf.py => pelicanconf.py (96%) diff --git a/.gitignore b/.gitignore index 0e1697c..198208d 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,6 @@ target/ # Pelican stuff output/ theme/static/build/ -pelican_plugins/ theme/static/src/scss/pygment.css deploy/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..9f659f8 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,7 @@ +[submodule "plugins/pelican-jinja2content"] + path = plugins/pelican-jinja2content + url = https://github.com/RealOrangeOne/pelican-jinja2content + +[submodule "pelican_plugins"] + path = pelican_plugins + url = https://github.com/getpelican/pelican-plugins diff --git a/Makefile b/Makefile index cad9b58..bbe9683 100644 --- a/Makefile +++ b/Makefile @@ -6,75 +6,15 @@ PELICAN=$(ENV)/pelican OUTPUTDIR=$(BASEDIR)/output PLUGINS_DIR=$(BASEDIR)/pelican_plugins DEPLOY_DIR=$(BASEDIR)/deploy -CONFIG_FILE=$(BASEDIR)/config/pelicanconf.py - -FLAKE8_IGNORE=--ignore=E128,E501,E401,E402 +CONFIG_FILE=$(BASEDIR)/pelicanconf.py build: install rm -rf $(OUTPUTDIR)/* - @echo ">> Building static data..." - mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img - cp -R node_modules/font-awesome/fonts theme/static/build/ - npm run build-js - npm run build-scss @echo ">> Building pelican..." $(PELICAN) -o $(OUTPUTDIR) -vs $(CONFIG_FILE) mv $(OUTPUTDIR)/assets/robots.txt $(OUTPUTDIR) cp -R $(OUTPUTDIR)/assets/* $(OUTPUTDIR)/static rm -rf $(OUTPUTDIR)/assets -clean: - rm -rf $(OUTPUTDIR)/* - rm -rf $(BASEDIR)/env/ - rm -rf $(BASEDIR)/node_modules/ - rm -rf $(PLUGINS_DIR)/* - -install: env node_modules pelican_plugins - -pelican_plugins: env - rm -rf $(PLUGINS_DIR) || "No existing extensions" - git clone --recursive https://github.com/getpelican/pelican-plugins $(PLUGINS_DIR) || "Git Fail" - @echo ">> Hotfixing..." - rm -rf $(PLUGINS_DIR)/pelican-jinja2content - git clone https://github.com/RealOrangeOne/pelican-jinja2content -b patch-1 --depth=1 $(PLUGINS_DIR)/pelican-jinja2content - -env: - pyvenv env - $(ENV)/pip install -r requirements.txt --upgrade - -node_modules: - npm install - - -test: unittest lint spellcheck securitycheck - -unittest: - $(ENV)/nose2 --verbose - -lint: - $(NODE_BIN)/eslint 'theme/static/src/js/' - $(NODE_BIN)/sass-lint -vqc .sass-lint.yml - $(ENV)/flake8 $(BASEDIR)/plugins/ $(FLAKE8_IGNORE) - $(ENV)/flake8 $(BASEDIR)/scripts/ $(FLAKE8_IGNORE) - $(ENV)/flake8 $(BASEDIR)/config/ $(FLAKE8_IGNORE) - $(ENV)/flake8 $(BASEDIR)/tests/ $(FLAKE8_IGNORE) - $(ENV)/yamllint config/config.yml - -spellcheck: - $(NODE_BIN)/mdspell --en-gb -ranx theme/templates/**/*.* theme/templates/*.* - $(NODE_BIN)/mdspell --en-gb -ranx content/**/*.md content/*.md content/**/*.html content/*.html - -securitycheck: - $(NODE_BIN)/nsp check - $(ENV)/bandit -r plugins/ config/ tests/ - - -upload: - git clone https://github.com/RealOrangeOne/host-container.git $(DEPLOY_DIR) - cp -rf $(OUTPUTDIR)/. $(DEPLOY_DIR)/site/ - @cd $(DEPLOY_DIR) && git remote add dokku $(DEPLOY_URL) && git add . && git commit -m "add files" && git push -f dokku master --quiet - rm -rf $(DEPLOY_DIR) - - -.PHONY: build clean test lint install upload +install: env node_modules diff --git a/circle.yml b/circle.yml index 1db10c7..07aa909 100644 --- a/circle.yml +++ b/circle.yml @@ -7,19 +7,3 @@ machine: BUILD_PRODUCTION: true NODE_ENV: production NPM_CONFIG_PRODUCTION: false - -dependencies: - pre: - - make -B - -test: - override: - - make test - -deployment: - production: - branch: master - commands: - - git config --global user.email "git@theorangeone.net" - - git config --global user.name "TheOrangeOne" - - make upload diff --git a/package.json b/package.json index c55595a..1ce2a79 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,10 @@ "version": "4.0.0", "description": " Source code for TheOrangeOne.net", "scripts": { + "postinstall": "npm run create-build-dirs && npm run copy-fonts && npm run build", + "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img", + "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", + "build": "npm run build-scss && npm run build-js", "build-js": "./scripts/build-js.sh", "build-scss": "./scripts/build-scss.sh" }, diff --git a/pelican_plugins b/pelican_plugins new file mode 160000 index 0000000..6cd5a60 --- /dev/null +++ b/pelican_plugins @@ -0,0 +1 @@ +Subproject commit 6cd5a608b45fdc21bb11ed1f72a151cdb71c1169 diff --git a/config/pelicanconf.py b/pelicanconf.py similarity index 96% rename from config/pelicanconf.py rename to pelicanconf.py index 41c225a..431a585 100644 --- a/config/pelicanconf.py +++ b/pelicanconf.py @@ -10,11 +10,11 @@ from config import settings AUTHOR = settings.author SITENAME = settings.site_name SITEURL = settings.url -PATH = '../content' +PATH = 'content' TIMEZONE = settings.timezone DEFAULT_LANG = settings.language PAGE_PATHS = ["pages"] -THEME = "../theme" +THEME = "theme" THEME_STATIC_DIR = "static" THEME_STATIC_PATHS = ["static/build"] STATIC_PATHS = ["assets"] @@ -61,7 +61,7 @@ FEED_ATOM = 'feed.atom' FEED_DOMAIN = SITEURL # Setup plugins -PLUGIN_PATHS = ["../pelican_plugins", "../plugins"] +PLUGIN_PATHS = ["plugins", "pelican_plugins"] PLUGINS = settings.pelican_plugins if BUILD_PRODUCTION: From 0a1f2fb82550c53ffb2a974fe49d6fb06a5aef57 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 9 Jan 2017 22:23:34 +0000 Subject: [PATCH 02/53] Fix submodule --- .gitmodules | 9 +++++---- plugins/pelican-jinja2content | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) create mode 160000 plugins/pelican-jinja2content diff --git a/.gitmodules b/.gitmodules index 9f659f8..df26d6b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,8 @@ -[submodule "plugins/pelican-jinja2content"] - path = plugins/pelican-jinja2content - url = https://github.com/RealOrangeOne/pelican-jinja2content - [submodule "pelican_plugins"] path = pelican_plugins url = https://github.com/getpelican/pelican-plugins + +[submodule "plugins/pelican-jinja2content"] + path = plugins/pelican-jinja2content + url = https://github.com/RealOrangeOne/pelican-jinja2content.git + branch = patch-1 diff --git a/plugins/pelican-jinja2content b/plugins/pelican-jinja2content new file mode 160000 index 0000000..b85a789 --- /dev/null +++ b/plugins/pelican-jinja2content @@ -0,0 +1 @@ +Subproject commit b85a789402e4d115510118189136aaa19b39bcc2 From 6e964e14c818cb49488b006ada468d1fa20cf150 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 08:42:54 +0000 Subject: [PATCH 03/53] Add build script --- circle.yml | 4 ++++ scripts/build | 5 +++++ scripts/server.sh | 4 ---- 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100755 scripts/build delete mode 100755 scripts/server.sh diff --git a/circle.yml b/circle.yml index 07aa909..3c3e99a 100644 --- a/circle.yml +++ b/circle.yml @@ -7,3 +7,7 @@ machine: BUILD_PRODUCTION: true NODE_ENV: production NPM_CONFIG_PRODUCTION: false + +dependencies: + pre: + - scripts/build diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..59c0c22 --- /dev/null +++ b/scripts/build @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +export PATH=env/bin:${PATH} + +pelican -o output/ -v diff --git a/scripts/server.sh b/scripts/server.sh deleted file mode 100755 index f09ca56..0000000 --- a/scripts/server.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -cd output/ -python3 -m pelican.server $PORT From 1a36597517f81c075ab56312de636fbcf88ca68b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 08:58:55 +0000 Subject: [PATCH 04/53] Remove old procfile --- etc/environments/development/procfile | 1 - 1 file changed, 1 deletion(-) delete mode 100644 etc/environments/development/procfile diff --git a/etc/environments/development/procfile b/etc/environments/development/procfile deleted file mode 100644 index 765d951..0000000 --- a/etc/environments/development/procfile +++ /dev/null @@ -1 +0,0 @@ -web: bash scripts/server.sh From c1443de20af46d0cd3bfab3ee4132aa6fa66ffb3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 08:59:05 +0000 Subject: [PATCH 05/53] Add post-build scripts --- config/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.yml b/config/config.yml index 9f71cda..22cdbef 100644 --- a/config/config.yml +++ b/config/config.yml @@ -13,6 +13,7 @@ pelican_plugins: - metatags - autopages - screenfetch + - post_build sitemap_format: xml From 3a9427912bc4e93b10858405a14371a59f64cefc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 09:09:30 +0000 Subject: [PATCH 06/53] Add static build script --- config/config.yml | 1 + plugins/post_build.py | 15 +++++++++++++++ plugins/static_build.py | 11 +++++++++++ 3 files changed, 27 insertions(+) create mode 100644 plugins/post_build.py create mode 100644 plugins/static_build.py diff --git a/config/config.yml b/config/config.yml index 22cdbef..40ff73d 100644 --- a/config/config.yml +++ b/config/config.yml @@ -14,6 +14,7 @@ pelican_plugins: - autopages - screenfetch - post_build + - static_build sitemap_format: xml diff --git a/plugins/post_build.py b/plugins/post_build.py new file mode 100644 index 0000000..cfcd372 --- /dev/null +++ b/plugins/post_build.py @@ -0,0 +1,15 @@ +from pelican import signals +import os + + +OUTPUT_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'output') + + +def post_build(*args, **kwargs): + os.system("mv {0}/assets/robots.txt {0}".format(OUTPUT_PATH)) + os.system("cp -R {0}/assets/* {0}/static".format(OUTPUT_PATH)) + os.system("rm -rf {0}/assets".format(OUTPUT_PATH)) + + +def register(): + signals.finalized.connect(post_build) diff --git a/plugins/static_build.py b/plugins/static_build.py new file mode 100644 index 0000000..2908bab --- /dev/null +++ b/plugins/static_build.py @@ -0,0 +1,11 @@ +from pelican import signals +import os + + +def static_build(*args, **kwargs): + os.system('npm run build-js') + os.system('npm run build-scss') + + +def register(): + signals.static_generator_init.connect(static_build) From 969cac950311c1e09fbeef9b85470abec929222d Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 09:18:58 +0000 Subject: [PATCH 07/53] Add test script --- circle.yml | 5 +++++ scripts/test | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 scripts/test diff --git a/circle.yml b/circle.yml index 3c3e99a..6679a9f 100644 --- a/circle.yml +++ b/circle.yml @@ -11,3 +11,8 @@ machine: dependencies: pre: - scripts/build + + +test: + override: + - scripts/test diff --git a/scripts/test b/scripts/test new file mode 100644 index 0000000..9783554 --- /dev/null +++ b/scripts/test @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +export PATH=env/bin:${PATH} +export PATH=node_modules/.bin:${PATH} + +FLAKE8_IGNORE=--ignore=E128,E501,E401,E402 + +set -e + +nose2 --verbose + +eslint 'theme/static/src/js/' + +sass-lint -vqc .sass-lint.yml + +flake8 plugins/ $FLAKE8_IGNORE +flake8 scripts/ $FLAKE8_IGNORE +flake8 config/ $FLAKE8_IGNORE +flake8 tests/ $FLAKE8_IGNORE + +yamllint config/config.yml + +mdspell --en-gb -ranx theme/templates/**/*.* theme/templates/*.* +mdspell --en-gb -ranx content/**/*.md content/*.md content/**/*.html content/*.html + +nsp check + +bandit -r plugins/ config/ tests/ From 39140e63e7ff18b05450a5b641126bf24e75652b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 09:20:39 +0000 Subject: [PATCH 08/53] Remove short build script --- circle.yml | 2 +- scripts/build | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100755 scripts/build diff --git a/circle.yml b/circle.yml index 6679a9f..bcb01b8 100644 --- a/circle.yml +++ b/circle.yml @@ -10,7 +10,7 @@ machine: dependencies: pre: - - scripts/build + - pelican -v test: diff --git a/scripts/build b/scripts/build deleted file mode 100755 index 59c0c22..0000000 --- a/scripts/build +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -export PATH=env/bin:${PATH} - -pelican -o output/ -v From e05468aec297781734919d37800296f18db119df Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 13:01:41 +0000 Subject: [PATCH 09/53] Build after install --- circle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circle.yml b/circle.yml index bcb01b8..d953f8e 100644 --- a/circle.yml +++ b/circle.yml @@ -9,7 +9,7 @@ machine: NPM_CONFIG_PRODUCTION: false dependencies: - pre: + post: - pelican -v From 8524599e3887131c222002ff75879e61716c0884 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 14:00:21 +0000 Subject: [PATCH 10/53] Dont build on postinstall --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 1ce2a79..c2204e1 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,9 @@ "version": "4.0.0", "description": " Source code for TheOrangeOne.net", "scripts": { - "postinstall": "npm run create-build-dirs && npm run copy-fonts && npm run build", + "postinstall": "npm run create-build-dirs && npm run copy-fonts", "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img", "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", - "build": "npm run build-scss && npm run build-js", "build-js": "./scripts/build-js.sh", "build-scss": "./scripts/build-scss.sh" }, From 8692dbbbefdcc06d94e629d90eba6d31193e7f06 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 17:14:07 +0000 Subject: [PATCH 11/53] Add submodules for circle --- circle.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/circle.yml b/circle.yml index d953f8e..fac9bee 100644 --- a/circle.yml +++ b/circle.yml @@ -8,6 +8,11 @@ machine: NODE_ENV: production NPM_CONFIG_PRODUCTION: false +checkout: + post: + - git submodule sync + - git submodule update --init --recursive + dependencies: post: - pelican -v From 2abbfb49ecbbacd173bb57e85fc3a9de25e7c133 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 17:52:42 +0000 Subject: [PATCH 12/53] Move static build into pelican. refactor later --- package.json | 4 +--- plugins/static_build.py | 21 ++++++++++++++++++-- scripts/build-js.sh | 44 ----------------------------------------- scripts/build-scss.sh | 23 --------------------- scripts/test | 0 5 files changed, 20 insertions(+), 72 deletions(-) delete mode 100755 scripts/build-js.sh delete mode 100755 scripts/build-scss.sh mode change 100644 => 100755 scripts/test diff --git a/package.json b/package.json index c2204e1..8acd4cd 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,7 @@ "scripts": { "postinstall": "npm run create-build-dirs && npm run copy-fonts", "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img", - "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", - "build-js": "./scripts/build-js.sh", - "build-scss": "./scripts/build-scss.sh" + "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/" }, "repository": { "type": "git", diff --git a/plugins/static_build.py b/plugins/static_build.py index 2908bab..ace1520 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -1,11 +1,28 @@ from pelican import signals import os +import sh +NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production' def static_build(*args, **kwargs): - os.system('npm run build-js') - os.system('npm run build-scss') + if NODE_PRODUCTION: + print('Building Production...') + sh.mkdir('-p', 'theme/static/build/js/lib') + os.system('uglifyjs node_modules/bootstrap-sass/assets/javascripts/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/lib/bootstrap.js') + os.system('uglifyjs theme/static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/libs.js') + sh.rm('-rf', 'theme/static/build/js/lib') + os.system('uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/jquery.js') + os.system('browserify -t [ babelify --presets [ es2015 react ] ] theme/static/src/js/app.js -o theme/static/build/js/app.js') + os.system('uglifyjs theme/static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/app.js') + print('JS built!') + + os.system('pygmentize -S github -f html -a .highlight > theme/static/src/scss/pygment.css') + os.system('npm run build-scss') + os.system('node-sass theme/static/src/scss/index.scss theme/static/build/css/index.css --source-map-embed') + os.system('postcss -u autoprefixer -o theme/static/build/css/index.css theme/static/build/css/index.css') + os.system('cleancss -d --s0 -o theme/static/build/css/index.css theme/static/build/css/index.css') + print('SCSS Built!') def register(): signals.static_generator_init.connect(static_build) diff --git a/scripts/build-js.sh b/scripts/build-js.sh deleted file mode 100755 index 2071800..0000000 --- a/scripts/build-js.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ "$NODE_ENV" = "production" ] -then - echo ">>> WARNING: Building in Production Mode!" -fi - -mkdir -p theme/static/build/js/lib - -if [ "$NODE_ENV" = "production" ] -then - echo ">> Compressing Libraries..." - uglifyjs node_modules/bootstrap-sass/assets/javascripts/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/lib/bootstrap.js - uglifyjs theme/static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/libs.js -else - echo ">> Building Libraries..." - cp node_modules/bootstrap-sass/assets/javascripts/bootstrap.js theme/static/build/js/lib/bootstrap.js - uglifyjs theme/static/build/js/lib/* --screw-ie8 --stats --keep-fnames -o theme/static/build/js/libs.js -fi - -rm -rf theme/static/build/js/lib - -if [ "$NODE_ENV" = "production" ] -then - echo ">> Compressing jQuery..." - uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/jquery.js -else - echo ">> Building jQuery..." - cp node_modules/jquery/dist/jquery.js theme/static/build/js/jquery.js -fi - - -echo ">> Building Application JS..." -browserify -t [ babelify --presets [ es2015 react ] ] theme/static/src/js/app.js -o theme/static/build/js/app.js - -if [ "$NODE_ENV" = "production" ] -then - echo ">> Compressing Application..." - uglifyjs theme/static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/app.js -fi - -echo "> JS Built!" diff --git a/scripts/build-scss.sh b/scripts/build-scss.sh deleted file mode 100755 index 164454a..0000000 --- a/scripts/build-scss.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash - -set -e - -if [ "$NODE_ENV" = "production" ] -then - echo ">>> WARNING: Building in Production Mode!" -fi - -echo ">> Generating Pygments styles..." -env/bin/pygmentize -S github -f html -a .highlight > theme/static/src/scss/pygment.css - -echo ">> Building SCSS..." -node-sass theme/static/src/scss/index.scss theme/static/build/css/index.css --source-map-embed - -echo ">> Post-Processing..." -postcss -u autoprefixer -o theme/static/build/css/index.css theme/static/build/css/index.css - -if [ "$NODE_ENV" = "production" ] -then - echo ">> Compressing CSS..." - cleancss -d --s0 -o theme/static/build/css/index.css theme/static/build/css/index.css -fi diff --git a/scripts/test b/scripts/test old mode 100644 new mode 100755 From f0056675938562a17964b2c3ab00531817bf939e Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 10 Jan 2017 22:14:11 +0000 Subject: [PATCH 13/53] Update static build --- plugins/static_build.py | 67 +++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/plugins/static_build.py b/plugins/static_build.py index ace1520..f8f1682 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -1,28 +1,63 @@ from pelican import signals import os -import sh +import subprocess +import logging + +logger = logging.getLogger(__file__) NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production' + +def flatten_list(array): + res = [] + for el in array: + if isinstance(el, (list, tuple)): + res.extend(flatten_list(el)) + continue + res.append(el) + return res + + +def run_command(detail, args, use_system=False): + logger.info(detail + '...') + if use_system: + exit_code = os.system(' '.join(flatten_list(args))) + if exit_code: + exit(exit_code) + else: + subprocess.run(flatten_list(args), check=True) + + +def node_bin(exec): + return os.path.join('node_modules', '.bin', exec) + + def static_build(*args, **kwargs): if NODE_PRODUCTION: - print('Building Production...') + logger.info('Building Production...') + UGLIFY_ARGS = ['--compress', '--screw-ie8', '--define', '--stats', '--keep-fnames'] + else: + UGLIFY_ARGS = [] - sh.mkdir('-p', 'theme/static/build/js/lib') - os.system('uglifyjs node_modules/bootstrap-sass/assets/javascripts/bootstrap.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/lib/bootstrap.js') - os.system('uglifyjs theme/static/build/js/lib/* --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/libs.js') - sh.rm('-rf', 'theme/static/build/js/lib') - os.system('uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/jquery.js') - os.system('browserify -t [ babelify --presets [ es2015 react ] ] theme/static/src/js/app.js -o theme/static/build/js/app.js') - os.system('uglifyjs theme/static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o theme/static/build/js/app.js') - print('JS built!') + run_command('Building Bootstrap', [node_bin('uglifyjs'), 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', UGLIFY_ARGS , '-o', 'theme/static/build/js/bootstrap.js']) + run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js']) + run_command('Building Application', [ + node_bin('browserify'), + '-t', '[', 'babelify', '--presets', '[', 'es2015', 'react', ']', ']', + 'theme/static/src/js/app.js', + '-o', 'theme/static/build/js/app.js' + ]) + run_command('Compressing Application', [node_bin('uglifyjs'), 'theme/static/build/js/app.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/app.js']) + + logger.info('JS built!') + + run_command('Building Pygments Style', ['pygmentize', '-S', 'github', '-f', 'html', '-a', '.highlight', '>', 'theme/static/src/scss/pygment.css'], True) + run_command('Building Styles', [node_bin('node-sass'), 'theme/static/src/scss/index.scss', 'theme/static/build/css/index.css', '--source-map-embed']) + run_command('Prefixing Styles', [node_bin('postcss'), '-u', 'autoprefixer', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) + run_command('Compressing Styles', [node_bin('cleancss'), '-d', '--s0', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) + + logger.info('SCSS Built!') - os.system('pygmentize -S github -f html -a .highlight > theme/static/src/scss/pygment.css') - os.system('npm run build-scss') - os.system('node-sass theme/static/src/scss/index.scss theme/static/build/css/index.css --source-map-embed') - os.system('postcss -u autoprefixer -o theme/static/build/css/index.css theme/static/build/css/index.css') - os.system('cleancss -d --s0 -o theme/static/build/css/index.css theme/static/build/css/index.css') - print('SCSS Built!') def register(): signals.static_generator_init.connect(static_build) From 40b0dd1286caaf54b3269e98d6b2a1da920abcbc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 08:37:45 +0000 Subject: [PATCH 14/53] Speed up build --- plugins/static_build.py | 8 +++++--- theme/templates/base.html | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/static_build.py b/plugins/static_build.py index f8f1682..eedc36a 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -47,17 +47,19 @@ def static_build(*args, **kwargs): 'theme/static/src/js/app.js', '-o', 'theme/static/build/js/app.js' ]) - run_command('Compressing Application', [node_bin('uglifyjs'), 'theme/static/build/js/app.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/app.js']) logger.info('JS built!') run_command('Building Pygments Style', ['pygmentize', '-S', 'github', '-f', 'html', '-a', '.highlight', '>', 'theme/static/src/scss/pygment.css'], True) run_command('Building Styles', [node_bin('node-sass'), 'theme/static/src/scss/index.scss', 'theme/static/build/css/index.css', '--source-map-embed']) - run_command('Prefixing Styles', [node_bin('postcss'), '-u', 'autoprefixer', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) - run_command('Compressing Styles', [node_bin('cleancss'), '-d', '--s0', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) logger.info('SCSS Built!') + if NODE_PRODUCTION: + run_command('Compressing Application', [node_bin('uglifyjs'), 'theme/static/build/js/app.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/app.js']) + run_command('Prefixing Styles', [node_bin('postcss'), '-u', 'autoprefixer', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) + run_command('Compressing Styles', [node_bin('cleancss'), '-d', '--s0', '-o', 'theme/static/build/css/index.css', 'theme/static/build/css/index.css']) + def register(): signals.static_generator_init.connect(static_build) diff --git a/theme/templates/base.html b/theme/templates/base.html index 845daa8..246a66a 100644 --- a/theme/templates/base.html +++ b/theme/templates/base.html @@ -31,7 +31,7 @@ {% include "extras/footer.html" %} - + From 96f27d1b5266577eab9641be86fa715807e6ef86 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 08:38:32 +0000 Subject: [PATCH 15/53] I dont need react --- package.json | 1 - plugins/static_build.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8acd4cd..a0d09e5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,6 @@ "devDependencies": { "autoprefixer": "=6.5.0", "babel-preset-es2015": "=6.13.2", - "babel-preset-react": "=6.11.1", "babelify": "=7.3.0", "browserify": "=13.1.0", "clean-css": "=3.4.20", diff --git a/plugins/static_build.py b/plugins/static_build.py index eedc36a..c8dc760 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -43,7 +43,7 @@ def static_build(*args, **kwargs): run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js']) run_command('Building Application', [ node_bin('browserify'), - '-t', '[', 'babelify', '--presets', '[', 'es2015', 'react', ']', ']', + '-t', '[', 'babelify', '--presets', '[', 'es2015', ']', ']', 'theme/static/src/js/app.js', '-o', 'theme/static/build/js/app.js' ]) From 7aafe6a19fbdbc215ec57523f1a523a0dfeebec8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 08:46:42 +0000 Subject: [PATCH 16/53] Remove babel, fix lint --- package.json | 5 +---- plugins/static_build.py | 1 - theme/static/src/js/app.js | 8 ++++---- theme/static/src/js/creative/creative.js | 2 +- theme/static/src/js/creative/index.js | 6 +++--- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index a0d09e5..d4a3e73 100644 --- a/package.json +++ b/package.json @@ -23,13 +23,10 @@ }, "devDependencies": { "autoprefixer": "=6.5.0", - "babel-preset-es2015": "=6.13.2", - "babelify": "=7.3.0", "browserify": "=13.1.0", "clean-css": "=3.4.20", "eslint": "=1.5.0", - "eslint-config": "git://github.com/dabapps/eslint-config.git", - "eslint-plugin-react": "=3.4.2", + "eslint-config": "git://github.com/dabapps/eslint-config.git#1.1.4", "markdown-spellcheck": "=0.11.0", "node-sass": "=3.8.0", "nsp": "=2.6.1", diff --git a/plugins/static_build.py b/plugins/static_build.py index c8dc760..53f34b6 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -43,7 +43,6 @@ def static_build(*args, **kwargs): run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js']) run_command('Building Application', [ node_bin('browserify'), - '-t', '[', 'babelify', '--presets', '[', 'es2015', ']', ']', 'theme/static/src/js/app.js', '-o', 'theme/static/build/js/app.js' ]) diff --git a/theme/static/src/js/app.js b/theme/static/src/js/app.js index adfebec..938fc04 100644 --- a/theme/static/src/js/app.js +++ b/theme/static/src/js/app.js @@ -1,9 +1,9 @@ -import './creative'; -import ansi_up from 'ansi_up'; +require('./creative'); +var ansi_up = require('ansi_up'); $('.image').each(function () { // setup div-image hybrids - const ele = $(this); + var ele = $(this); if (ele.data('image')) { ele.css('background-image', 'url(' + ele.data('image') + ')'); } else { @@ -12,6 +12,6 @@ $('.image').each(function () { // setup div-image hybrids }); $('.ansi-up').each(function () { - const ele = $(this); + var ele = $(this); ele.html(ansi_up.ansi_to_html(ele.html())); }); diff --git a/theme/static/src/js/creative/creative.js b/theme/static/src/js/creative/creative.js index da1676c..17868c7 100644 --- a/theme/static/src/js/creative/creative.js +++ b/theme/static/src/js/creative/creative.js @@ -6,7 +6,7 @@ // jQuery for page scrolling feature - requires jQuery Easing plugin $('a.page-scroll').bind('click', function(event) { - const anchor = $(this); + var anchor = $(this); $('html, body').stop().animate( { scrollTop: ($(anchor.attr('href')).offset().top - 50) diff --git a/theme/static/src/js/creative/index.js b/theme/static/src/js/creative/index.js index 43b0721..80d3f7c 100644 --- a/theme/static/src/js/creative/index.js +++ b/theme/static/src/js/creative/index.js @@ -1,6 +1,6 @@ -import 'jquery.easing'; -import './creative'; +require('jquery.easing'); +require('./creative'); -import WOW from 'wow.js'; +var WOW = require('wow.js'); new WOW().init(); From 28e210237dd613a66aa496b83a5d1456655cf0a6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 08:54:32 +0000 Subject: [PATCH 17/53] Add server --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d4a3e73..87a0151 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "postinstall": "npm run create-build-dirs && npm run copy-fonts", "create-build-dirs": "mkdir -p theme/static/build/js/lib theme/static/build/fonts theme/static/build/css theme/static/build/img", - "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/" + "copy-fonts": "cp -R node_modules/font-awesome/fonts theme/static/build/", + "start": "tstatic output/" }, "repository": { "type": "git", @@ -18,6 +19,7 @@ "font-awesome": "=4.6.3", "jquery": "=2.2.3", "jquery.easing": "=1.3.2", + "tstatic": "git://github.com/RealOrangeOne/tstatic", "underscore": "=1.8.3", "wow.js": "=1.2.0" }, From 5336e189beba088e6001c2331ca19fb39badafc3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 09:03:15 +0000 Subject: [PATCH 18/53] Fix lint --- .eslintrc | 4 ++-- package.json | 3 +-- theme/static/src/js/app.js | 2 ++ theme/static/src/js/creative/creative.js | 1 + theme/static/src/js/creative/index.js | 2 ++ 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0fa2039..b63cb78 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,6 +1,6 @@ { - "extends": "./node_modules/eslint-config/.eslintrc", + "extends": "eslint-config-dabapps/base/.eslintrc", "globals": { - $: true + "$": true } } diff --git a/package.json b/package.json index 87a0151..a8156ae 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "autoprefixer": "=6.5.0", "browserify": "=13.1.0", "clean-css": "=3.4.20", - "eslint": "=1.5.0", - "eslint-config": "git://github.com/dabapps/eslint-config.git#1.1.4", + "eslint-config": "git://github.com/dabapps/eslint-config.git#2.0.4", "markdown-spellcheck": "=0.11.0", "node-sass": "=3.8.0", "nsp": "=2.6.1", diff --git a/theme/static/src/js/app.js b/theme/static/src/js/app.js index 938fc04..9347cf1 100644 --- a/theme/static/src/js/app.js +++ b/theme/static/src/js/app.js @@ -1,3 +1,5 @@ +'use strict'; + require('./creative'); var ansi_up = require('ansi_up'); diff --git a/theme/static/src/js/creative/creative.js b/theme/static/src/js/creative/creative.js index 17868c7..9cddbf2 100644 --- a/theme/static/src/js/creative/creative.js +++ b/theme/static/src/js/creative/creative.js @@ -3,6 +3,7 @@ * Code licensed under the Apache License v2.0. * For details, see http://www.apache.org/licenses/LICENSE-2.0. */ +'use strict'; // jQuery for page scrolling feature - requires jQuery Easing plugin $('a.page-scroll').bind('click', function(event) { diff --git a/theme/static/src/js/creative/index.js b/theme/static/src/js/creative/index.js index 80d3f7c..82e60fa 100644 --- a/theme/static/src/js/creative/index.js +++ b/theme/static/src/js/creative/index.js @@ -1,3 +1,5 @@ +'use strict'; + require('jquery.easing'); require('./creative'); From 82007f996896a3d4c4bf52c03368feae8a5274e9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 09:03:49 +0000 Subject: [PATCH 19/53] Fix lint --- plugins/static_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/static_build.py b/plugins/static_build.py index 53f34b6..4e7e339 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -39,7 +39,7 @@ def static_build(*args, **kwargs): else: UGLIFY_ARGS = [] - run_command('Building Bootstrap', [node_bin('uglifyjs'), 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', UGLIFY_ARGS , '-o', 'theme/static/build/js/bootstrap.js']) + run_command('Building Bootstrap', [node_bin('uglifyjs'), 'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/bootstrap.js']) run_command('Building jQuery', [node_bin('uglifyjs'), 'node_modules/jquery/dist/jquery.js', UGLIFY_ARGS, '-o', 'theme/static/build/js/jquery.js']) run_command('Building Application', [ node_bin('browserify'), From 1625c976d0a16b21f5b3c3b1df9b846fee4fae47 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 09:20:19 +0000 Subject: [PATCH 20/53] Update submodule --- plugins/pelican-jinja2content | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pelican-jinja2content b/plugins/pelican-jinja2content index b85a789..9fd2b74 160000 --- a/plugins/pelican-jinja2content +++ b/plugins/pelican-jinja2content @@ -1 +1 @@ -Subproject commit b85a789402e4d115510118189136aaa19b39bcc2 +Subproject commit 9fd2b74989b49d73338e5a3c72e668156dca5376 From e416ae704d78067af379683966818ddf55564572 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Wed, 11 Jan 2017 22:11:25 +0000 Subject: [PATCH 21/53] use simply git syntax and update node --- circle.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/circle.yml b/circle.yml index fac9bee..e0f81bc 100644 --- a/circle.yml +++ b/circle.yml @@ -2,7 +2,7 @@ machine: python: version: 3.5.1 node: - version: 5.11.1 + version: 6.9.4 environment: BUILD_PRODUCTION: true NODE_ENV: production diff --git a/package.json b/package.json index a8156ae..7d08214 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "font-awesome": "=4.6.3", "jquery": "=2.2.3", "jquery.easing": "=1.3.2", - "tstatic": "git://github.com/RealOrangeOne/tstatic", + "tstatic": "RealOrangeOne/tstatic", "underscore": "=1.8.3", "wow.js": "=1.2.0" }, @@ -27,7 +27,7 @@ "autoprefixer": "=6.5.0", "browserify": "=13.1.0", "clean-css": "=3.4.20", - "eslint-config": "git://github.com/dabapps/eslint-config.git#2.0.4", + "eslint-config": "dabapps/eslint-config.git#2.0.4", "markdown-spellcheck": "=0.11.0", "node-sass": "=3.8.0", "nsp": "=2.6.1", From c78f77b9f0e663ffddbeb3dbb8680289fb8cf07b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 09:00:01 +0000 Subject: [PATCH 22/53] Fix post build commands and refactor --- plugins/post_build.py | 13 ++++++++++--- plugins/static_build.py | 26 +------------------------- plugins/utils.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 28 deletions(-) create mode 100644 plugins/utils.py diff --git a/plugins/post_build.py b/plugins/post_build.py index cfcd372..cffc47f 100644 --- a/plugins/post_build.py +++ b/plugins/post_build.py @@ -1,14 +1,21 @@ from pelican import signals import os +from plugins.utils import run_command OUTPUT_PATH = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'output') def post_build(*args, **kwargs): - os.system("mv {0}/assets/robots.txt {0}".format(OUTPUT_PATH)) - os.system("cp -R {0}/assets/* {0}/static".format(OUTPUT_PATH)) - os.system("rm -rf {0}/assets".format(OUTPUT_PATH)) + run_command('Copying Robots.txt', [ + 'mv', os.path.join(OUTPUT_PATH, 'assets', 'robots.txt'), OUTPUT_PATH + ]) + run_command('Copying Assets', [ + 'cp', '-R', os.path.join(OUTPUT_PATH, 'assets', '*'), os.path.join(OUTPUT_PATH, 'static') + ], True) + run_command('Remove Old Assets', [ + 'rm', '-rf', os.path.join(OUTPUT_PATH, 'assets') + ]) def register(): diff --git a/plugins/static_build.py b/plugins/static_build.py index 4e7e339..8606595 100644 --- a/plugins/static_build.py +++ b/plugins/static_build.py @@ -1,6 +1,6 @@ from pelican import signals import os -import subprocess +from plugins.utils import node_bin, run_command import logging logger = logging.getLogger(__file__) @@ -8,30 +8,6 @@ logger = logging.getLogger(__file__) NODE_PRODUCTION = os.environ.get('NODE_ENV') == 'production' -def flatten_list(array): - res = [] - for el in array: - if isinstance(el, (list, tuple)): - res.extend(flatten_list(el)) - continue - res.append(el) - return res - - -def run_command(detail, args, use_system=False): - logger.info(detail + '...') - if use_system: - exit_code = os.system(' '.join(flatten_list(args))) - if exit_code: - exit(exit_code) - else: - subprocess.run(flatten_list(args), check=True) - - -def node_bin(exec): - return os.path.join('node_modules', '.bin', exec) - - def static_build(*args, **kwargs): if NODE_PRODUCTION: logger.info('Building Production...') diff --git a/plugins/utils.py b/plugins/utils.py new file mode 100644 index 0000000..11e3c6f --- /dev/null +++ b/plugins/utils.py @@ -0,0 +1,28 @@ +import subprocess +import logging +import os + + +logger = logging.getLogger(__file__) + + +def flatten_list(array): + res = [] + for el in array: + if isinstance(el, (list, tuple)): + res.extend(flatten_list(el)) + continue + res.append(el) + return res + + +def run_command(detail, args, wrap=False): + if wrap: + run_command('', ['bash', '-c', ' '.join(flatten_list(args))]) + else: + logger.info(detail + '...') + subprocess.run(flatten_list(args), check=True) + + +def node_bin(exec): + return os.path.join('node_modules', '.bin', exec) From d5c4cb6928c8a3bd025a448a024168efd91538c6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 09:13:30 +0000 Subject: [PATCH 23/53] Update jinja2 content to fix securiry --- plugins/pelican-jinja2content | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pelican-jinja2content b/plugins/pelican-jinja2content index 9fd2b74..8133378 160000 --- a/plugins/pelican-jinja2content +++ b/plugins/pelican-jinja2content @@ -1 +1 @@ -Subproject commit 9fd2b74989b49d73338e5a3c72e668156dca5376 +Subproject commit 81333781964a57d5f590730d0ba419377f0ff022 From 3eb19eb250dc681cdc8621d2c89e7ee416a28896 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 09:21:04 +0000 Subject: [PATCH 24/53] Silence warning on use of subprocess --- plugins/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/utils.py b/plugins/utils.py index 11e3c6f..01fc3fe 100644 --- a/plugins/utils.py +++ b/plugins/utils.py @@ -1,4 +1,4 @@ -import subprocess +import subprocess # nosec import logging import os From c055732d7222b78b9bdc307b583bcba000b9997c Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 09:24:36 +0000 Subject: [PATCH 25/53] Upgrade things --- requirements.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index ac1dced..7dad2d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -bandit==1.1.0 -flake8==3.0.4 -fontawesome_markdown==0.2.5 +bandit==1.3.0 +flake8==3.2.1 +fontawesome_markdown==0.2.6 git+https://github.com/ryneeverett/python-markdown-comments.git -gitpython==2.0.8 +gitpython==2.1.1 iso8601==0.1.11 markdown==2.6.7 nose2==0.6.5 @@ -10,7 +10,7 @@ pelican-minify==0.9 pelican==3.6.3 pyembed-markdown==1.1.0 pygments-style-github==0.4 -python-resize-image==1.1.3 +python-resize-image==1.1.10 pyyaml==3.12 -sh==1.11 -yamllint==1.4.1 +sh==1.12.9 +yamllint==1.6.0 From c5880674348e9c7204f0ebb864bba42ebec8c5a7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 09:27:16 +0000 Subject: [PATCH 26/53] Check python deps for security --- requirements.txt | 1 + scripts/test | 2 ++ 2 files changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 7dad2d9..ca5f090 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,5 +12,6 @@ pyembed-markdown==1.1.0 pygments-style-github==0.4 python-resize-image==1.1.10 pyyaml==3.12 +safety==0.5.1 sh==1.12.9 yamllint==1.6.0 diff --git a/scripts/test b/scripts/test index 9783554..703cb8c 100755 --- a/scripts/test +++ b/scripts/test @@ -25,4 +25,6 @@ mdspell --en-gb -ranx content/**/*.md content/*.md content/**/*.html content/*.h nsp check +safety check + bandit -r plugins/ config/ tests/ From ab962889486efbe847389388d9d8e0bd420f72e9 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 12 Jan 2017 14:00:51 +0000 Subject: [PATCH 27/53] Fix version number --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ca5f090..a66f9e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ pelican-minify==0.9 pelican==3.6.3 pyembed-markdown==1.1.0 pygments-style-github==0.4 -python-resize-image==1.1.10 +python-resize-image==1.1.3 pyyaml==3.12 safety==0.5.1 sh==1.12.9 From 049f4152cc68cda382a98654dbf19ac6e6e1828f Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 08:55:25 +0000 Subject: [PATCH 28/53] Upgrade pelican and internalise plugin --- .gitmodules | 5 ----- pelicanconf.py | 23 ++++++++++++------- plugins/pelican-jinja2content | 1 - plugins/pelican-jinja2content.py | 38 ++++++++++++++++++++++++++++++++ requirements.txt | 2 +- 5 files changed, 54 insertions(+), 15 deletions(-) delete mode 160000 plugins/pelican-jinja2content create mode 100644 plugins/pelican-jinja2content.py diff --git a/.gitmodules b/.gitmodules index df26d6b..5246012 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,3 @@ [submodule "pelican_plugins"] path = pelican_plugins url = https://github.com/getpelican/pelican-plugins - -[submodule "plugins/pelican-jinja2content"] - path = plugins/pelican-jinja2content - url = https://github.com/RealOrangeOne/pelican-jinja2content.git - branch = patch-1 diff --git a/pelicanconf.py b/pelicanconf.py index 431a585..8e49039 100644 --- a/pelicanconf.py +++ b/pelicanconf.py @@ -81,14 +81,15 @@ MINIFY = { from fontawesome_markdown import FontAwesomeExtension from pyembed.markdown import PyEmbedMarkdown from mkdcomments import CommentsExtension -MD_EXTENSIONS = [ - FontAwesomeExtension(), - PyEmbedMarkdown(), - CommentsExtension(), - 'codehilite(css_class=highlight)', - 'extra' -] - +MARKDOWN = { + 'extensions': [ + FontAwesomeExtension(), + PyEmbedMarkdown(), + CommentsExtension(), + 'codehilite(css_class=highlight)', + 'extra' + ] +} # Setup jinja2 filters from plugins import filters JINJA_FILTERS = { @@ -96,3 +97,9 @@ JINJA_FILTERS = { "category_find": filters.category_find, "limit": filters.limit } + +JINJA_ENVIRONMENT = { + 'trim_blocks': True, + 'lstrip_blocks': True, + 'extensions': {} +} diff --git a/plugins/pelican-jinja2content b/plugins/pelican-jinja2content deleted file mode 160000 index 8133378..0000000 --- a/plugins/pelican-jinja2content +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 81333781964a57d5f590730d0ba419377f0ff022 diff --git a/plugins/pelican-jinja2content.py b/plugins/pelican-jinja2content.py new file mode 100644 index 0000000..304435f --- /dev/null +++ b/plugins/pelican-jinja2content.py @@ -0,0 +1,38 @@ +import os + +from pelican import signals +from pelican import contents + +from jinja2 import Environment, ChoiceLoader, FileSystemLoader + + +def execjinja2(instance): + if type(instance) in (contents.Article, contents.Page): + base_path = os.path.dirname(os.path.abspath(__file__)) + jinja2_env = Environment( + loader=ChoiceLoader([ + FileSystemLoader( + os.path.join(base_path, instance.settings['THEME'], 'templates') + ), + FileSystemLoader( + os.path.join(base_path, instance.settings['PATH']) + ) + ]), + **instance.settings['JINJA_ENVIRONMENT'], + ) + + jinja2_env.filters.update(instance.settings['JINJA_FILTERS']) + + jinja2_template = jinja2_env.from_string(instance._content) + + kwargs = instance._context + if type(instance) is contents.Article: + kwargs['article'] = instance + elif type(instance) is contents.Page: + kwargs['page'] = instance + + instance._content = jinja2_template.render(**kwargs) + + +def register(): + signals.content_object_init.connect(execjinja2) diff --git a/requirements.txt b/requirements.txt index a66f9e2..46136b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ iso8601==0.1.11 markdown==2.6.7 nose2==0.6.5 pelican-minify==0.9 -pelican==3.6.3 +pelican==3.7.1 pyembed-markdown==1.1.0 pygments-style-github==0.4 python-resize-image==1.1.3 From 967d390ce77749e8b6d06b030bf2d00eb7672df4 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 08:58:23 +0000 Subject: [PATCH 29/53] Ignore autoescape, breaks pelican --- plugins/pelican-jinja2content.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pelican-jinja2content.py b/plugins/pelican-jinja2content.py index 304435f..2aad33e 100644 --- a/plugins/pelican-jinja2content.py +++ b/plugins/pelican-jinja2content.py @@ -9,7 +9,7 @@ from jinja2 import Environment, ChoiceLoader, FileSystemLoader def execjinja2(instance): if type(instance) in (contents.Article, contents.Page): base_path = os.path.dirname(os.path.abspath(__file__)) - jinja2_env = Environment( + jinja2_env = Environment( # nosec loader=ChoiceLoader([ FileSystemLoader( os.path.join(base_path, instance.settings['THEME'], 'templates') From 1692ea745145ab4bae97aea453f61183b85f35dc Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 09:07:12 +0000 Subject: [PATCH 30/53] Make instance globally accessible --- plugins/pelican-jinja2content.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/pelican-jinja2content.py b/plugins/pelican-jinja2content.py index 2aad33e..0600a43 100644 --- a/plugins/pelican-jinja2content.py +++ b/plugins/pelican-jinja2content.py @@ -30,6 +30,7 @@ def execjinja2(instance): kwargs['article'] = instance elif type(instance) is contents.Page: kwargs['page'] = instance + kwargs['instance'] = instance # avoid using outside common elements instance._content = jinja2_template.render(**kwargs) From f1bf129f4632efae5eca1b0794220857d7a99b52 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 09:19:04 +0000 Subject: [PATCH 31/53] Update packages --- .sass-lint.yml | 1 + package.json | 22 +++++++++++----------- requirements.txt | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.sass-lint.yml b/.sass-lint.yml index 38af2b8..503b76e 100644 --- a/.sass-lint.yml +++ b/.sass-lint.yml @@ -56,6 +56,7 @@ rules: force-pseudo-nesting: 0 force-element-nesting: 0 placeholder-in-extend: 0 + no-url-domains: 0 nesting-depth: - 2 - diff --git a/package.json b/package.json index 7d08214..15e3a17 100644 --- a/package.json +++ b/package.json @@ -16,23 +16,23 @@ "animate.css": "=3.5.2", "ansi_up": "=1.3.0", "bootstrap-sass": "=3.3.7", - "font-awesome": "=4.6.3", - "jquery": "=2.2.3", - "jquery.easing": "=1.3.2", + "font-awesome": "=4.7.0", + "jquery": "=3.1.1", + "jquery.easing": "=1.4.1", "tstatic": "RealOrangeOne/tstatic", "underscore": "=1.8.3", - "wow.js": "=1.2.0" + "wow.js": "=1.2.2" }, "devDependencies": { - "autoprefixer": "=6.5.0", - "browserify": "=13.1.0", - "clean-css": "=3.4.20", + "autoprefixer": "=6.6.1", + "browserify": "=13.3.0", + "clean-css": "=3.4.23", "eslint-config": "dabapps/eslint-config.git#2.0.4", "markdown-spellcheck": "=0.11.0", - "node-sass": "=3.8.0", - "nsp": "=2.6.1", + "node-sass": "=4.3.0", + "nsp": "=2.6.2", "postcss-cli": "=2.6.0", - "sass-lint": "=1.9.1", - "uglify-js": "=2.7.3" + "sass-lint": "=1.10.2", + "uglify-js": "=2.7.5" } } diff --git a/requirements.txt b/requirements.txt index 46136b4..bd55614 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -bandit==1.3.0 +bandit==1.4.0 flake8==3.2.1 fontawesome_markdown==0.2.6 git+https://github.com/ryneeverett/python-markdown-comments.git From 4a32c6259804ab30515cb5d7b0cb51c2aff23e20 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 Jan 2017 13:36:51 +0000 Subject: [PATCH 32/53] Use instance in header --- theme/templates/extras/header.html | 4 ++-- theme/templates/extras/page-header.html | 6 ------ theme/templates/page.html | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 theme/templates/extras/page-header.html diff --git a/theme/templates/extras/header.html b/theme/templates/extras/header.html index fdd06bc..f1538a7 100644 --- a/theme/templates/extras/header.html +++ b/theme/templates/extras/header.html @@ -1,6 +1,6 @@ -