mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Invoke: Make settings file name handling more DRY
Instead of repeating hard-coded 'pelicanconf.py' values throughout Invoke's task.py template, assign default settings file names to variables, and use those variables where applicable.
This commit is contained in:
parent
5525a9021e
commit
4b5610175f
1 changed files with 9 additions and 6 deletions
|
|
@ -10,12 +10,15 @@ from invoke.util import cd
|
||||||
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
|
from pelican.server import ComplexHTTPRequestHandler, RootedHTTPServer
|
||||||
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file
|
from pelican.settings import DEFAULT_CONFIG, get_settings_from_file
|
||||||
|
|
||||||
|
SETTINGS_FILE_BASE = 'pelicanconf.py'
|
||||||
SETTINGS = {}
|
SETTINGS = {}
|
||||||
SETTINGS.update(DEFAULT_CONFIG)
|
SETTINGS.update(DEFAULT_CONFIG)
|
||||||
LOCAL_SETTINGS = get_settings_from_file('pelicanconf.py')
|
LOCAL_SETTINGS = get_settings_from_file(SETTINGS_FILE_BASE)
|
||||||
SETTINGS.update(LOCAL_SETTINGS)
|
SETTINGS.update(LOCAL_SETTINGS)
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
|
'settings_base': SETTINGS_FILE_BASE,
|
||||||
|
'settings_publish': 'publishconf.py',
|
||||||
# Output path. Can be absolute or relative to tasks.py. Default: 'output'
|
# Output path. Can be absolute or relative to tasks.py. Default: 'output'
|
||||||
'deploy_path': SETTINGS['OUTPUT_PATH'],
|
'deploy_path': SETTINGS['OUTPUT_PATH'],
|
||||||
{% if ssh %}
|
{% if ssh %}
|
||||||
|
|
@ -48,17 +51,17 @@ def clean(c):
|
||||||
@task
|
@task
|
||||||
def build(c):
|
def build(c):
|
||||||
"""Build local version of site"""
|
"""Build local version of site"""
|
||||||
c.run('pelican -s pelicanconf.py')
|
c.run('pelican -s {settings_base}'.format(**CONFIG))
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def rebuild(c):
|
def rebuild(c):
|
||||||
"""`build` with the delete switch"""
|
"""`build` with the delete switch"""
|
||||||
c.run('pelican -d -s pelicanconf.py')
|
c.run('pelican -d -s {settings_base}'.format(**CONFIG))
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def regenerate(c):
|
def regenerate(c):
|
||||||
"""Automatically regenerate site upon file modification"""
|
"""Automatically regenerate site upon file modification"""
|
||||||
c.run('pelican -r -s pelicanconf.py')
|
c.run('pelican -r -s {settings_base}'.format(**CONFIG))
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def serve(c):
|
def serve(c):
|
||||||
|
|
@ -84,7 +87,7 @@ def reserve(c):
|
||||||
@task
|
@task
|
||||||
def preview(c):
|
def preview(c):
|
||||||
"""Build production version of site"""
|
"""Build production version of site"""
|
||||||
c.run('pelican -s publishconf.py')
|
c.run('pelican -s {settings_publish}'.format(**CONFIG))
|
||||||
|
|
||||||
@task
|
@task
|
||||||
def livereload(c):
|
def livereload(c):
|
||||||
|
|
@ -115,7 +118,7 @@ def cf_upload(c):
|
||||||
@task
|
@task
|
||||||
def publish(c):
|
def publish(c):
|
||||||
"""Publish to production via rsync"""
|
"""Publish to production via rsync"""
|
||||||
c.run('pelican -s publishconf.py')
|
c.run('pelican -s {settings_publish}'.format(**CONFIG))
|
||||||
c.run(
|
c.run(
|
||||||
'rsync --delete --exclude ".DS_Store" -pthrvz -c '
|
'rsync --delete --exclude ".DS_Store" -pthrvz -c '
|
||||||
'{} {production}:{dest_path}'.format(
|
'{} {production}:{dest_path}'.format(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue