diff --git a/.buildpacks b/.buildpacks new file mode 100644 index 0000000..9b12f2c --- /dev/null +++ b/.buildpacks @@ -0,0 +1,3 @@ +https://github.com/heroku/heroku-buildpack-nodejs +https://github.com/heroku/heroku-buildpack-python +https://github.com/RealOrangeOne/heroku-buildpack-make diff --git a/Makefile b/Makefile index cde58f5..a508387 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ -ENV=env/bin NODE_BIN=node_modules/.bin -PELICAN=$(ENV)/pelican +PELICAN=pelican BASEDIR=$(PWD) OUTPUTDIR=$(BASEDIR)/output @@ -32,9 +31,9 @@ clean: rm -rf $(PLUGINS_DIR)/* -install: env node_modules pelican_plugins +install: node_modules pelican_plugins -pelican_plugins: env +pelican_plugins: rm -rf $(PLUGINS_DIR) || "No existing extensions" git clone --recursive https://github.com/getpelican/pelican-plugins $(PLUGINS_DIR) || "Git Fail" @echo ">> Hotfixing..." @@ -43,9 +42,9 @@ pelican_plugins: env env: pyvenv env - $(ENV)/pip install -r requirements.txt + pip install -r requirements.txt -node_modules: env +node_modules: npm install @@ -54,9 +53,9 @@ test: lint spellcheck 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)/pelicanconf.py $(FLAKE8_IGNORE) + flake8 $(BASEDIR)/plugins/ $(FLAKE8_IGNORE) + flake8 $(BASEDIR)/scripts/ $(FLAKE8_IGNORE) + flake8 $(BASEDIR)/pelicanconf.py $(FLAKE8_IGNORE) spellcheck: $(NODE_BIN)/mdspell --en-gb -ranx theme/templates/**/*.* theme/templates/*.* diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..063b78f --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm start diff --git a/etc/environments/development/procfile b/etc/environments/development/procfile index 765d951..063b78f 100644 --- a/etc/environments/development/procfile +++ b/etc/environments/development/procfile @@ -1 +1 @@ -web: bash scripts/server.sh +web: npm start diff --git a/package.json b/package.json index e4340c0..8bce3f0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": " Source code for TheOrangeOne.net", "scripts": { "build-js": "./scripts/build-js.sh", - "build-scss": "./scripts/build-scss.sh" + "build-scss": "./scripts/build-scss.sh", + "start": "node scripts/server.js" }, "repository": { "type": "git", @@ -13,6 +14,7 @@ "dependencies": { "animate.css": "=3.5.1", "bootstrap-sass": "=3.3.6", + "express": "=4.13.3", "font-awesome": "=4.6.1", "jquery": "=2.2.3", "jquery.easing": "=1.3.2", diff --git a/scripts/server.js b/scripts/server.js new file mode 100644 index 0000000..e4c3588 --- /dev/null +++ b/scripts/server.js @@ -0,0 +1,37 @@ +const express = require('express'); + +const PORT = process.env.PORT; +const serveDir = __dirname + '/../output'; + +const directory = /\/$/; +const allFiles = /.*/; + +const expressConfig = { + dotfiles: 'deny', + index: false, + redirect: true +}; + +const app = express(); + +app.use(function (request, response, next) { + // If path is directory then serve index.html + if (directory.exec(request.url)) { + request.url += '/index.html'; + } + next(); +}); + +app.use( + express.static(serveDir, expressConfig) +); + +// Cannot find any file +app.use( + allFiles, express.static(serveDir + '/.404.html', expressConfig) +); + +const server = app.listen(PORT, function () { + const serverPort = server.address().port; + console.log('Server started on port ' + serverPort); +}); 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