mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #2526 from johnfraney/livereload
Add livereload invoke task. Fixes #1326
This commit is contained in:
commit
c61665b85d
2 changed files with 26 additions and 0 deletions
|
|
@ -146,6 +146,12 @@ http://localhost:8000/::
|
||||||
|
|
||||||
invoke serve
|
invoke serve
|
||||||
|
|
||||||
|
To serve the generated site with automatic browser reloading every time a
|
||||||
|
change is detected, first ``pip install livereload``, then use the
|
||||||
|
following command::
|
||||||
|
|
||||||
|
invoke livereload
|
||||||
|
|
||||||
If during the ``pelican-quickstart`` process you answered "yes" when asked
|
If during the ``pelican-quickstart`` process you answered "yes" when asked
|
||||||
whether you want to upload your site via SSH, you can use the following command
|
whether you want to upload your site via SSH, you can use the following command
|
||||||
to publish your site via rsync over SSH::
|
to publish your site via rsync over SSH::
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,12 @@ import datetime
|
||||||
from invoke import task
|
from invoke import task
|
||||||
from invoke.util import cd
|
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
|
||||||
|
|
||||||
|
SETTINGS = {}
|
||||||
|
SETTINGS.update(DEFAULT_CONFIG)
|
||||||
|
LOCAL_SETTINGS = get_settings_from_file('pelicanconf.py')
|
||||||
|
SETTINGS.update(LOCAL_SETTINGS)
|
||||||
|
|
||||||
CONFIG = {
|
CONFIG = {
|
||||||
# Local path configuration (can be absolute or relative to tasks.py)
|
# Local path configuration (can be absolute or relative to tasks.py)
|
||||||
|
|
@ -80,6 +86,20 @@ def preview(c):
|
||||||
"""Build production version of site"""
|
"""Build production version of site"""
|
||||||
c.run('pelican -s publishconf.py')
|
c.run('pelican -s publishconf.py')
|
||||||
|
|
||||||
|
@task
|
||||||
|
def livereload(c):
|
||||||
|
"""Automatically reload browser tab upon file modification."""
|
||||||
|
from livereload import Server
|
||||||
|
build(c)
|
||||||
|
server = Server()
|
||||||
|
deploy_path = CONFIG['deploy_path']
|
||||||
|
content_path = SETTINGS['PATH']
|
||||||
|
content_file_extensions = ['.md', '.rst']
|
||||||
|
for file_extension in content_file_extensions:
|
||||||
|
content_blob = '{0}/**/*{1}'.format(content_path, file_extension)
|
||||||
|
server.watch(content_blob, lambda: build(c))
|
||||||
|
server.serve(root=deploy_path)
|
||||||
|
|
||||||
{% if cloudfiles %}
|
{% if cloudfiles %}
|
||||||
@task
|
@task
|
||||||
def cf_upload(c):
|
def cf_upload(c):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue