-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtasks.py
92 lines (67 loc) · 1.94 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import time
from pathlib import Path
from invoke import run, task
p = Path.cwd()
deploy_path = p / 'output'
# used for the version to be put on the wider internet
publish_path = p / 'output'
def clean(ctx):
print("You'll have to manually delete the output folder")
@task
def build(ctx):
"""Build a local version of the blog."""
ctx.run('pelican -s pelicanconf.py')
@task
def build_debug(ctx):
"""Use debug output to build a local version of the blog."""
ctx.run('pelican -s pelicanconf.py --debug')
@task
def rebuild(ctx):
"""clean and build."""
clean(ctx)
build(ctx)
@task
def regenerate(ctx):
"""Rebuild a local version of the blog if files change."""
ctx.run('start pelican -r -s pelicanconf.py')
@task
def serve(ctx):
"""Serve the local blog output on port 8000."""
ctx.run('cd {} && start python -m http.server'.format(deploy_path))
@task
def serve_on(ctx, port):
"""Serve the local blog output on a port of your choosing."""
ctx.run('cd {} && start python -m http.server {}'.format(deploy_path, port))
@task
def reserve(ctx):
"""build and serve."""
build(ctx)
serve(ctx)
@task
def upload(ctx):
"""publish and then push the result to GitHub."""
publish(ctx)
ctx.run('cd {} && git add -A && git commit -m "[Generated] {}" && git push'\
.format(publish_path, time.strftime("%Y-%m-%d")))
@task
def publish(ctx):
"""Build a publication version of the blog."""
ctx.run('pelican -s publishconf.py')
@task
def publish_carefully(ctx):
"""(Carefully) Build a publication version of the blog.
i.e. fail on any warnings from pelican."""
ctx.run('pelican -s publishconf.py --fatal=warnings')
# Add devsever
# only works on Windows
# need to kill the second window manually
@task
def devserver(ctx):
"""regeneration and serve."""
regenerate(ctx)
serve(ctx)
@task
def test(ctx):
"""Test invoke is working."""
print(run)
ctx.run('dir')