Skip to content

Instantly share code, notes, and snippets.

@justinmayer
Created December 10, 2012 21:50
Show Gist options
  • Select an option

  • Save justinmayer/4253687 to your computer and use it in GitHub Desktop.

Select an option

Save justinmayer/4253687 to your computer and use it in GitHub Desktop.

Revisions

  1. justinmayer created this gist Dec 10, 2012.
    40 changes: 40 additions & 0 deletions fabfile.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    from fabric.api import *
    import os
    import fabric.contrib.project as project

    # Local path configuration (can be absolute or relative to fabfile)
    env.theme = 'themes/your-theme'
    env.deploy_path = '/absolute/path/for/generated/output'

    # Remote server configuration
    prod = 'username@server.example.com:22'
    dest_path = '/home/username/web/yoursite/'

    DEPLOY_PATH = env.deploy_path

    def clean():
    if os.path.isdir(DEPLOY_PATH):
    local('rm -rf {deploy_path}'.format(**env))

    def gen():
    local('pelican -t {theme} -s local.py'.format(**env))

    def serve():
    local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))

    def reserve():
    gen()
    serve()

    def preview():
    local('pelican -t {theme} -s production.py'.format(**env))

    @hosts(prod)
    def publish():
    local('pelican -t {theme} -s production.py'.format(**env))
    project.rsync_project(
    remote_dir=dest_path.rstrip('/') + '/',
    local_dir=DEPLOY_PATH.rstrip('/') + '/',
    delete=True
    )
    clean()