kaka.farm

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit d5629dc0771191860eaf4c00321002501b71defd
parent 1e01379416565d044dfc2866260f5b9a2e27c7ba
Author: Yuval Langer <yuval.langer@gmail.com>
Date:   Sat, 16 Jun 2018 20:37:40 +0300

Move `make dev` command into its own Python script

Diffstat:
MMakefile | 23++++++-----------------
Apelican_development_server.py | 29+++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,43 +1,32 @@ .PHONY: build build: pipenv run pelican \ + --delete-output-directory \ --ignore-cache \ -s pelican_publication_configuration.py .PHONY: kaka.farm kaka.farm: pipenv run pelican \ - --ignore-cache \ --delete-output-directory \ + --ignore-cache \ -s pelican_publication_configuration.py rsync \ - --progress \ - --verbose \ --archive \ --delete-after \ + --progress \ + --verbose \ output/ \ blog.kakafarm:/var/www/kaka-farm-blog/ .PHONY: gitlab gitlab: pipenv run pelican \ + --delete-output-directory \ --ignore-cache \ -s pelican_gitlab_configuration.py .PHONY: dev dev: - pipenv run pelican \ - --ignore-cache \ - --verbose \ - -s pelican_development_configuration.py \ - ; \ - pipenv run pelican \ - --autoreload \ - --ignore-cache \ - --verbose \ - -s pelican_development_configuration.py \ - & \ - cd output \ - ; \ - python3 -m http.server --bind localhost 8000 + pipenv run python pelican_development_server.py diff --git a/pelican_development_server.py b/pelican_development_server.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + + +from http.server import HTTPServer, SimpleHTTPRequestHandler +from os import chdir +from subprocess import PIPE, Popen + + +def main(): + with Popen( + [ + "pelican", + "--delete-output-directory", + "--autoreload", + "--ignore-cache", + "--verbose", + "-s", "pelican_development_configuration.py", + ], + stdout=PIPE, + ): + chdir("output") + server = HTTPServer( + ("127.0.0.1", 8000), + SimpleHTTPRequestHandler, + ) + server.serve_forever() + + +main()