forked from github/pelican
This commit adds optional fabfile.py generation during the pelican-quickstart process. Reasons include: * "make" is cumbersome to install on Windows * Fabric runs in any Python environment * fabfile is just Python and thus more flexible and extensible This is an initial implementation and does not currently provide as many upload options as its Makefile counterpart. Refs #584.
47 lines
1 KiB
Python
47 lines
1 KiB
Python
from fabric.api import *
|
|
import fabric.contrib.project as project
|
|
import os
|
|
|
|
# Local path configuration (can be absolute or relative to fabfile)
|
|
env.deploy_path = 'output'
|
|
|
|
# Remote server configuration
|
|
production = '$ssh_user@$ssh_host:$ssh_port'
|
|
dest_path = '$ssh_target_dir'
|
|
|
|
DEPLOY_PATH = env.deploy_path
|
|
|
|
def clean():
|
|
if os.path.isdir(DEPLOY_PATH):
|
|
local('rm -rf {deploy_path}'.format(**env))
|
|
local('mkdir {deploy_path}'.format(**env))
|
|
|
|
def build():
|
|
local('pelican -s pelicanconf.py')
|
|
|
|
def rebuild():
|
|
clean()
|
|
build()
|
|
|
|
def regenerate():
|
|
local('pelican -r -s pelicanconf.py')
|
|
|
|
def serve():
|
|
local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
|
|
|
|
def reserve():
|
|
build()
|
|
serve()
|
|
|
|
def preview():
|
|
local('pelican -s publishconf.py')
|
|
|
|
@hosts(production)
|
|
def publish():
|
|
local('pelican -s publishconf.py')
|
|
project.rsync_project(
|
|
remote_dir=dest_path,
|
|
exclude=".DS_Store",
|
|
local_dir=DEPLOY_PATH.rstrip('/') + '/',
|
|
delete=True
|
|
)
|