Skip to content

Instantly share code, notes, and snippets.

@justinmayer
Created December 10, 2012 21:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save justinmayer/4253687 to your computer and use it in GitHub Desktop.
Save justinmayer/4253687 to your computer and use it in GitHub Desktop.
Example fabfile for publishing Pelican sites via Fabric
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment