diff --git a/.gitignore b/.gitignore index c53652a..07d8e89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ *.pyc *.log output -tests/.cache/ \ No newline at end of file +tests/.cache/ +.venv +.direnv diff --git a/README.adoc b/README.adoc index f397ab1..d9a4b65 100644 --- a/README.adoc +++ b/README.adoc @@ -329,14 +329,13 @@ attila and start a new theme. Did you liked this theme? Pay my bills and support new features. -https://gratipay.com/~arulrajnet/[image:https://img.shields.io/gratipay/user/arulrajnet.svg?maxAge=2592000[Gratipay]] - -https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XYLX6LG2THL2J[image:https://img.shields.io/badge/paypal-donate-yellow.svg?maxAge=2592000[PayPal]] +https://github.com/sponsors/arulrajnet/[image:https://img.shields.io/github/sponsors/arulrajnet?style=for-the-badge[GitHub Sponsors]] [[copyright-license]] == Copyright & License Copyright (c) 2015-2016 Peter Amende - Released under The MIT License. + Copyright (c) 2016 Arulraj V - Released under The MIT License. Some background images used from diff --git a/fabfile.py b/fabfile.py deleted file mode 100644 index 8e65c3e..0000000 --- a/fabfile.py +++ /dev/null @@ -1,76 +0,0 @@ -from fabric.api import * -import fabric.contrib.project as project -import os -import shutil -import sys -import SocketServer - -from pelican.server import ComplexHTTPRequestHandler - -# Local path configuration (can be absolute or relative to fabfile) -env.deploy_path = 'output' -DEPLOY_PATH = env.deploy_path - -# Remote server configuration -production = 'root@localhost:22' -dest_path = '/var/www' - -# Rackspace Cloud Files configuration settings -env.cloudfiles_username = 'my_rackspace_username' -env.cloudfiles_api_key = 'my_rackspace_api_key' -env.cloudfiles_container = 'my_cloudfiles_container' - -# Github Pages configuration -env.github_pages_branch = "gh-pages" - -# Port for `serve` -PORT = 8000 - -def clean(): - """Remove generated files""" - if os.path.isdir(DEPLOY_PATH): - shutil.rmtree(DEPLOY_PATH) - os.makedirs(DEPLOY_PATH) - -def build(): - """Build local version of site""" - local('asciidoctor -D {deploy_path} *.adoc'.format(**env)) - local('cp *.png {deploy_path}'.format(**env)) - local('mv {deploy_path}/README.html {deploy_path}/index.html'.format(**env)) - -def rebuild(): - """`clean` then `build`""" - clean() - build() - -def serve(): - """Serve site at http://localhost:8000/""" - os.chdir(env.deploy_path) - - class AddressReuseTCPServer(SocketServer.TCPServer): - allow_reuse_address = True - - server = AddressReuseTCPServer(('', PORT), ComplexHTTPRequestHandler) - - sys.stderr.write('Serving on port {0} ...\n'.format(PORT)) - server.serve_forever() - -def reserve(): - """`build`, then `serve`""" - build() - serve() - -def cf_upload(): - """Publish to Rackspace Cloud Files""" - rebuild() - with lcd(DEPLOY_PATH): - local('swift -v -A https://auth.api.rackspacecloud.com/v1.0 ' - '-U {cloudfiles_username} ' - '-K {cloudfiles_api_key} ' - 'upload -c {cloudfiles_container} .'.format(**env)) - -def gh_pages(): - """Publish to GitHub Pages""" - rebuild() - local("ghp-import -b {github_pages_branch} {deploy_path}".format(**env)) - local("git push origin {github_pages_branch}".format(**env)) \ No newline at end of file diff --git a/screenshot.png b/screenshot.png index 0ca7d3a..5ae3079 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..e32a90d --- /dev/null +++ b/tasks.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- + +import os +import shutil +import sys +import datetime + +from invoke import task +from invoke.main import program +from invoke.util import cd +from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer + +''' +To use this + +virtualenv .venv +source .venv/bin/activate +pip3 install invoke pelican ghp-import +invoke build +invoke serve +invoke gh-pages +''' + +OPEN_BROWSER_ON_SERVE = False + +CONFIG = { + # Output path. Can be absolute or relative to tasks.py. Default: 'output' + 'deploy_path': 'output', + # Github Pages configuration + 'github_pages_branch': 'gh-pages', + 'commit_message': "'Publish site on {}'".format(datetime.date.today().isoformat()), + # Host and port for `serve` + 'host': 'localhost', + 'port': 8000, +} + +@task +def clean(c): + """Remove generated files""" + if os.path.isdir(CONFIG['deploy_path']): + shutil.rmtree(CONFIG['deploy_path']) + os.makedirs(CONFIG['deploy_path']) + +@task +def build(c): + """Build local version of site""" + c.run('asciidoctor -D {deploy_path} *.adoc'.format(**CONFIG)) + c.run('cp *.png {deploy_path}'.format(**CONFIG)) + c.run('mv {deploy_path}/README.html {deploy_path}/index.html'.format(**CONFIG)) + +@task +def serve(c): + """Serve site at http://$HOST:$PORT/ (default is localhost:8000)""" + + class AddressReuseTCPServer(RootedHTTPServer): + allow_reuse_address = True + + server = AddressReuseTCPServer( + CONFIG['deploy_path'], + (CONFIG['host'], CONFIG['port']), + ComplexHTTPRequestHandler) + + if OPEN_BROWSER_ON_SERVE: + # Open site in default browser + import webbrowser + webbrowser.open("http://{host}:{port}".format(**CONFIG)) + + sys.stderr.write('Serving at {host}:{port} ...\n'.format(**CONFIG)) + server.serve_forever() + +@task +def reserve(c): + """`build`, then `serve`""" + build(c) + serve(c) + +@task +def gh_pages(c): + """Publish to GitHub Pages""" + build(c) + c.run('ghp-import -b {github_pages_branch} ' + '-m "{commit_message}" ' + '{deploy_path} -p'.format(**CONFIG))