mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add fabfile generation to pelican-quickstart
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.
This commit is contained in:
parent
e32c893aa1
commit
30192b2318
3 changed files with 133 additions and 11 deletions
|
|
@ -193,10 +193,10 @@ needed by Pelican.
|
|||
else:
|
||||
CONF['default_pagination'] = False
|
||||
|
||||
mkfile = ask('Do you want to generate a Makefile to easily manage your website?', bool, True)
|
||||
automation = ask('Do you want to generate a Fabfile/Makefile to automate generation and publishing?', bool, True)
|
||||
develop = ask('Do you want an auto-reload & simpleHTTP script to assist with theme and site development?', bool, True)
|
||||
|
||||
if mkfile:
|
||||
if automation:
|
||||
if ask('Do you want to upload your website using FTP?', answer=bool, default=False):
|
||||
CONF['ftp_host'] = ask('What is the hostname of your FTP server?', str_compat, CONF['ftp_host'])
|
||||
CONF['ftp_user'] = ask('What is your username on that server?', str_compat, CONF['ftp_user'])
|
||||
|
|
@ -243,7 +243,15 @@ needed by Pelican.
|
|||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
|
||||
if mkfile:
|
||||
if automation:
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'fabfile.py'), 'w', 'utf-8') as fd:
|
||||
for line in get_template('fabfile.py'):
|
||||
template = string.Template(line)
|
||||
fd.write(template.safe_substitute(CONF))
|
||||
fd.close()
|
||||
except OSError as e:
|
||||
print('Error: {0}'.format(e))
|
||||
try:
|
||||
with codecs.open(os.path.join(CONF['basedir'], 'Makefile'), 'w', 'utf-8') as fd:
|
||||
mkfile_template_name = 'Makefile'
|
||||
|
|
|
|||
47
pelican/tools/templates/fabfile.py.in
Normal file
47
pelican/tools/templates/fabfile.py.in
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
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
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue