1 from fabric.api import *
2 import fabric.contrib.project as project
8 from pelican.server import ComplexHTTPRequestHandler
10 # Local path configuration (can be absolute or relative to fabfile)
11 env.deploy_path = 'output'
12 DEPLOY_PATH = env.deploy_path
14 # Remote server configuration
15 production = 'root@localhost:22'
16 dest_path = '/var/www'
18 # Rackspace Cloud Files configuration settings
19 env.cloudfiles_username = 'my_rackspace_username'
20 env.cloudfiles_api_key = 'my_rackspace_api_key'
21 env.cloudfiles_container = 'my_cloudfiles_container'
23 # Github Pages configuration
24 env.github_pages_branch = "gh-pages"
30 """Remove generated files"""
31 if os.path.isdir(DEPLOY_PATH):
32 shutil.rmtree(DEPLOY_PATH)
33 os.makedirs(DEPLOY_PATH)
36 """Build local version of site"""
37 local('pelican -s pelicanconf.py')
40 """`clean` then `build`"""
45 """Automatically regenerate site upon file modification"""
46 local('pelican -r -s pelicanconf.py')
49 """Serve site at http://localhost:8000/"""
50 os.chdir(env.deploy_path)
52 class AddressReuseTCPServer(SocketServer.TCPServer):
53 allow_reuse_address = True
55 server = AddressReuseTCPServer(('', PORT), ComplexHTTPRequestHandler)
57 sys.stderr.write('Serving on port {0} ...\n'.format(PORT))
58 server.serve_forever()
61 """`build`, then `serve`"""
66 """Build production version of site"""
67 local('pelican -s publishconf.py')
70 """Publish to Rackspace Cloud Files"""
72 with lcd(DEPLOY_PATH):
73 local('swift -v -A https://auth.api.rackspacecloud.com/v1.0 '
74 '-U {cloudfiles_username} '
75 '-K {cloudfiles_api_key} '
76 'upload -c {cloudfiles_container} .'.format(**env))
80 """Publish to production via rsync"""
81 local('pelican -s publishconf.py')
82 project.rsync_project(
85 local_dir=DEPLOY_PATH.rstrip('/') + '/',
91 """Publish to GitHub Pages"""
93 local("ghp-import -b {github_pages_branch} {deploy_path}".format(**env))
94 local("git push origin {github_pages_branch}".format(**env))