diff options
author | Sunaina Pai <sunainapai.in@gmail.com> | 2018-03-17 14:45:21 +0530 |
---|---|---|
committer | Sunaina Pai <sunainapai.in@gmail.com> | 2018-03-17 14:45:21 +0530 |
commit | 62d0aa159fc046a27bed47e337d787a08f4687d0 (patch) | |
tree | c1162f14377890c290d2ad114b3892cbb9848975 /Makefile |
Add makesite: A simple static site generator
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c00a218 --- /dev/null +++ b/Makefile @@ -0,0 +1,73 @@ +site: + ./makesite.py + +serve: site + cd _site && python -m SimpleHTTPServer 2> /dev/null || python3 -m http.server + +venv2: + virtualenv ~/.venv/makesite + echo . ~/.venv/makesite/bin/activate > venv + . ./venv && pip install commonmark coverage + +venv: FORCE + python3 -m venv ~/.venv/makesite + echo . ~/.venv/makesite/bin/activate > venv + . ./venv && pip install commonmark coverage + +test: FORCE + . ./venv && python -m unittest -bv + +coverage: + . ./venv && coverage run --branch --source=. -m unittest discover -bv; : + . ./venv && coverage report -m + . ./venv && coverage html + +clean: + find . -name "__pycache__" -exec rm -r {} + + find . -name "*.pyc" -exec rm {} + + rm -rf .coverage htmlcov + +REV = cat /tmp/rev.txt +example: + # + # Remove existing output directories. + rm -rf _site /tmp/_site + # + # Create params.json for makesite-demo. + echo '{ "base_path": "/makesite-demo", "site_url":' \ + '"https://tmug.github.io/makesite-demo" }' > params.json + # + # Generate the website. + . ./venv && ./makesite.py + rm params.json + # + # Get current commit ID. + git rev-parse --short HEAD > /tmp/rev.txt + # + # Write a README for makesite-demo repository. + echo makesite.py demo > _site/README.md + echo ================ >> _site/README.md + echo This is the HTML/CSS source of an example static >> _site/README.md + echo website auto-generated with [sunainapai/makesite][makesite] >> _site/README.md + echo "([$$($(REV))][commit])". >> _site/README.md + echo >> _site/README.md + echo Visit "<https://tmug.github.io/makesite-demo>" to >> _site/README.md + echo view the example website. >> _site/README.md + echo >> _site/README.md + echo [makesite]: https://github.com/sunainapai/makesite >> _site/README.md + echo [commit]: https://github.com/sunainapai/makesite/commit/$$($(COMMIT)) >> _site/README.md + echo [demo]: https://tmug.github.io/makesite-demo >> _site/README.md + # + # Publish makesite-demo. + mv _site /tmp + cd /tmp/_site && git init + cd /tmp/_site && git add . + cd /tmp/_site && git commit -m "Auto-generated with sunainapai/makesite - $$($(REV))" + cd /tmp/_site && git remote add origin https://github.com/tmug/makesite-demo.git + cd /tmp/_site && git log + cd /tmp/_site && git push -f origin master + +loc: + grep -vE '^[[:space:]]*#|^[[:space:]]*$$' makesite.py | wc -l + +FORCE: |