From dd2635dfd9fb0062e65c90b5e4f436528cb9e8a3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 13 May 2016 21:13:23 +0100 Subject: [PATCH] Install pelican --- .gitignore | 4 ++ build | 4 +- develop_server.sh | 103 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- pelicanconf.py | 35 ++++++++++++++++ publishconf.py | 17 ++++++++ requirements.txt | 1 + 7 files changed, 162 insertions(+), 4 deletions(-) create mode 100755 develop_server.sh create mode 100644 pelicanconf.py create mode 100644 publishconf.py diff --git a/.gitignore b/.gitignore index 05c02c9..6f5d702 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ docs/_build/ # PyBuilder target/ + +srv.pid +pelican.pid +output/ diff --git a/build b/build index 26cc685..ffbf404 100755 --- a/build +++ b/build @@ -12,8 +12,6 @@ nvm use set -e pyvenv env -env/bin/pip install -r requirements.txt --upgrade - +env/bin/pip install -r requirements.txt npm install -npm run build $@ diff --git a/develop_server.sh b/develop_server.sh new file mode 100755 index 0000000..ae8f29e --- /dev/null +++ b/develop_server.sh @@ -0,0 +1,103 @@ +#!/usr/bin/env bash +## +# This section should match your Makefile +## +PY=${PY:-python3} +PELICAN=${PELICAN:-pelican} +PELICANOPTS= + +BASEDIR=$(pwd) +INPUTDIR=$BASEDIR/content +OUTPUTDIR=$BASEDIR/output +CONFFILE=$BASEDIR/pelicanconf.py + +### +# Don't change stuff below here unless you are sure +### + +SRV_PID=$BASEDIR/srv.pid +PELICAN_PID=$BASEDIR/pelican.pid + +function usage(){ + echo "usage: $0 (stop) (start) (restart) [port]" + echo "This starts Pelican in debug and reload mode and then launches" + echo "an HTTP server to help site development. It doesn't read" + echo "your Pelican settings, so if you edit any paths in your Makefile" + echo "you will need to edit your settings as well." + exit 3 +} + +function alive() { + kill -0 $1 >/dev/null 2>&1 +} + +function shut_down(){ + PID=$(cat $SRV_PID) + if [[ $? -eq 0 ]]; then + if alive $PID; then + echo "Stopping HTTP server" + kill $PID + else + echo "Stale PID, deleting" + fi + rm $SRV_PID + else + echo "HTTP server PIDFile not found" + fi + + PID=$(cat $PELICAN_PID) + if [[ $? -eq 0 ]]; then + if alive $PID; then + echo "Killing Pelican" + kill $PID + else + echo "Stale PID, deleting" + fi + rm $PELICAN_PID + else + echo "Pelican PIDFile not found" + fi +} + +function start_up(){ + local port=$1 + echo "Starting up Pelican and HTTP server" + shift + $PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS & + pelican_pid=$! + echo $pelican_pid > $PELICAN_PID + cd $OUTPUTDIR + $PY -m pelican.server $port & + srv_pid=$! + echo $srv_pid > $SRV_PID + cd $BASEDIR + sleep 1 + if ! alive $pelican_pid ; then + echo "Pelican didn't start. Is the Pelican package installed?" + return 1 + elif ! alive $srv_pid ; then + echo "The HTTP server didn't start. Is there another service using port" $port "?" + return 1 + fi + echo 'Pelican and HTTP server processes now running in background.' +} + +### +# MAIN +### +[[ ($# -eq 0) || ($# -gt 2) ]] && usage +port='' +[[ $# -eq 2 ]] && port=$2 + +if [[ $1 == "stop" ]]; then + shut_down +elif [[ $1 == "restart" ]]; then + shut_down + start_up $port +elif [[ $1 == "start" ]]; then + if ! start_up $port; then + shut_down + fi +else + usage +fi diff --git a/package.json b/package.json index c669901..69b3182 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "devDependencies": { "babel-preset-es2015": "=6.1.18", - "babel-preset-react": "=6.1.18w", + "babel-preset-react": "=6.1.18", "babelify": "=7.3.0", "browserify": "=13.0.1", "clean-css": "=3.4.12", diff --git a/pelicanconf.py b/pelicanconf.py new file mode 100644 index 0000000..2b63ae0 --- /dev/null +++ b/pelicanconf.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +AUTHOR = 'Jake Howard' +SITENAME = 'TheOrangeOne' +SITEURL = '' + +PATH = 'content' + +TIMEZONE = 'Europe/London' + +DEFAULT_LANG = 'en' + +# Feed generation is usually not desired when developing +FEED_ALL_ATOM = None +CATEGORY_FEED_ATOM = None +TRANSLATION_FEED_ATOM = None +AUTHOR_FEED_ATOM = None +AUTHOR_FEED_RSS = None + +# Blogroll +LINKS = (('Pelican', 'http://getpelican.com/'), + ('Python.org', 'http://python.org/'), + ('Jinja2', 'http://jinja.pocoo.org/'), + ('You can modify those links in your config file', '#'),) + +# Social widget +SOCIAL = (('You can add links in your config file', '#'), + ('Another social link', '#'),) + +DEFAULT_PAGINATION = 15 + +# Uncomment following line if you want document-relative URLs when developing +#RELATIVE_URLS = True diff --git a/publishconf.py b/publishconf.py new file mode 100644 index 0000000..36be258 --- /dev/null +++ b/publishconf.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- # +from __future__ import unicode_literals + +# This file is only used if you use `make publish` or +# explicitly specify it as your config file. + +import os +import sys +sys.path.append(os.curdir) +from pelicanconf import * + +SITEURL = 'http://theorangeone.net' +RELATIVE_URLS = False + +FEED_ALL_ATOM = 'feeds/all.atom.xml' +CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml' diff --git a/requirements.txt b/requirements.txt index 14b2285..adf6df4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ coverage==4.0.3 colorama==0.3.6 flake8==2.5.0 +markdown==2.6.6 pelican==3.6.3