Skip to content

Commit

Permalink
Add makesite: A simple static site generator
Browse files Browse the repository at this point in the history
  • Loading branch information
sunainapai committed Mar 17, 2018
0 parents commit 62d0aa1
Show file tree
Hide file tree
Showing 31 changed files with 1,631 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[report]
exclude_lines =
if __name__ == '__main__':
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
_site
*.pyc
__pycache__
.coverage
htmlcov
*.sw?
.DS_Store
venv
19 changes: 19 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"

install:
- pip install commonmark coverage coveralls

script:
- python -m unittest discover -bv
- coverage run --branch --source=. -m unittest discover -bv
- coverage report -m

after_success:
- coveralls
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)
=====================
Copyright (c) 2018 Sunaina Pai

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
Loading

0 comments on commit 62d0aa1

Please sign in to comment.