aboutsummaryrefslogtreecommitdiff
path: root/pyblog
diff options
context:
space:
mode:
authorneodarz <neodarz@neodarz.net>2019-05-26 18:06:28 +0200
committerneodarz <neodarz@neodarz.net>2019-05-26 18:06:28 +0200
commit6a743a7ef8920cca31b833d26a093b84832b0362 (patch)
tree884d24347c2e359a843f699609c9d66d66f487c9 /pyblog
parent8e170c5881d78ae9b46149a7e32bab28749dec40 (diff)
downloadmy_new_personal_website-6a743a7ef8920cca31b833d26a093b84832b0362.tar.xz
my_new_personal_website-6a743a7ef8920cca31b833d26a093b84832b0362.zip
Move preview to external file
Diffstat (limited to 'pyblog')
-rwxr-xr-xpyblog36
1 files changed, 1 insertions, 35 deletions
diff --git a/pyblog b/pyblog
index 98559e50..ceb018d4 100755
--- a/pyblog
+++ b/pyblog
@@ -53,40 +53,6 @@ from generators import generators
from cli import cli
-def preview(args):
- """Serve the blog and auto regenerate upon changes."""
-
- # pylint: disable=unused-argument
-
- server_process = utils.HTTPServerProcess(BUILDDIR)
- server_process.start()
- sys.stderr.write("watching for changes\n")
- sys.stderr.write("send SIGINT to stop\n")
-
- # install a SIGINT handler only for this process
- sigint_raised = False
-
- def sigint_mitigator(signum, frame):
- """Translate SIGINT to setting the sigint_raised flag."""
- nonlocal sigint_raised
- sigint_raised = True
-
- signal.signal(signal.SIGINT, sigint_mitigator)
-
- # Watch and auto-regen.
- # No need to actually implement watch separately, since
- # generate_blog(fresh=False, report_total_errors=False) already
- # watches for modifications and only regens upon changes, and it is
- # completely silent when there's no change.
- while not sigint_raised:
- generators.generate_blog(fresh=False, report_total_errors=False)
- time.sleep(0.5)
-
- sys.stderr.write("\nSIGINT received, cleaning up...\n")
- server_process.join()
- return 0
-
-
def list_posts():
"""List all posts, with date, title, and path to source file.
@@ -315,7 +281,7 @@ def main():
parser_new_post = subparsers.add_parser(
"preview", aliases=["p", "pre"],
description="Serve the blog locally and auto regenerate upon changes.")
- parser_new_post.set_defaults(func=preview)
+ parser_new_post.set_defaults(func=cli.preview)
parser_new_post = subparsers.add_parser(
"deploy", aliases=["d", "dep"],