From ae7af1d696997f1194007c3a6859cd564557f403 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 20 Jun 2019 08:08:48 +0200 Subject: [PATCH 1/4] Remove redundant vars in Invoke livereload task --- pelican/tools/templates/tasks.py.jinja2 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 95164354..0e1fad7a 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -95,13 +95,12 @@ def livereload(c): from livereload import Server build(c) server = Server() - deploy_path = CONFIG['deploy_path'] - content_path = SETTINGS['PATH'] + # Watch content source files content_file_extensions = ['.md', '.rst'] - for file_extension in content_file_extensions: - content_blob = '{0}/**/*{1}'.format(content_path, file_extension) + for extension in content_file_extensions: + content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension) server.watch(content_blob, lambda: build(c)) - server.serve(root=deploy_path) + server.serve(root=CONFIG['deploy_path']) {% if cloudfiles %} @task From c8b0b52d4e8f76bfd9bd59cb0a6bb4cf0d697b5c Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 20 Jun 2019 08:12:14 +0200 Subject: [PATCH 2/4] Use port settings in Invoke livereload task Instead of using LiveReload's default port 5500, use the existing `port` value from the task's CONFIG dictionary, which defaults to 8000. --- pelican/tools/templates/tasks.py.jinja2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 0e1fad7a..7922aa9a 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -100,7 +100,8 @@ def livereload(c): for extension in content_file_extensions: content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension) server.watch(content_blob, lambda: build(c)) - server.serve(root=CONFIG['deploy_path']) + # Serve output path on configured port + server.serve(port=CONFIG['port'], root=CONFIG['deploy_path']) {% if cloudfiles %} @task From cf2275c3be307d4061be892524621e146811d8fd Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 20 Jun 2019 08:18:00 +0200 Subject: [PATCH 3/4] Add settings file to Invoke livereload watch list --- pelican/tools/templates/tasks.py.jinja2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 7922aa9a..45c8768d 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -95,6 +95,8 @@ def livereload(c): from livereload import Server build(c) server = Server() + # Watch the base settings file + server.watch(CONFIG['settings_base'], lambda: build(c)) # Watch content source files content_file_extensions = ['.md', '.rst'] for extension in content_file_extensions: From a4cecd2d0c719beab52fa86b2bc5b7a9ddaa1659 Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Thu, 20 Jun 2019 08:30:04 +0200 Subject: [PATCH 4/4] Add theme templates, CSS, JS to Invoke livereload task --- pelican/tools/templates/tasks.py.jinja2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pelican/tools/templates/tasks.py.jinja2 b/pelican/tools/templates/tasks.py.jinja2 index 45c8768d..a800b79b 100644 --- a/pelican/tools/templates/tasks.py.jinja2 +++ b/pelican/tools/templates/tasks.py.jinja2 @@ -102,6 +102,13 @@ def livereload(c): for extension in content_file_extensions: content_blob = '{0}/**/*{1}'.format(SETTINGS['PATH'], extension) server.watch(content_blob, lambda: build(c)) + # Watch the theme's templates and static assets + theme_path = SETTINGS['THEME'] + server.watch('{}/templates/*.html'.format(theme_path), lambda: build(c)) + static_file_extensions = ['.css', '.js'] + for extension in static_file_extensions: + static_file = '{0}/static/**/*{1}'.format(theme_path, extension) + server.watch(static_file, lambda: build(c)) # Serve output path on configured port server.serve(port=CONFIG['port'], root=CONFIG['deploy_path'])