-
Notifications
You must be signed in to change notification settings - Fork 2
/
tasks.py
81 lines (63 loc) · 1.95 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
from pathlib import Path
import sys
from invoke import run, task
try:
from minchin.releaser import make_release
except ImportError:
print("[WARN] minchin.releaser not installed.")
try:
from pelican.plugins.seafoam.constants import STYLES
except ImportError:
try:
sys.path.insert(0, "pelican/plugins/seafoam")
from constants import STYLES
except ImportError:
STYLES = None
print("[WARN] STYLES list is unavailable. Install package to fix.")
# also requires `lessc` to be installed and available from the commandline
#
# choco install nodejs-lts
# refresh-env
# npm install less -g
# TODO: provide for alternative shell on something other than Windows
p = Path(__file__).parent # directory holding this file
@task
def build(ctx):
"""Compile the theme LESS files to CSS."""
if STYLES is None:
sys.exit("STYLES list is unavailable. Exiting...")
for style in STYLES:
source = p / "css_src" / "less" / f"bootstrap.{style}.less"
dest = (
p
/ "pelican"
/ "plugins"
/ "seafoam"
/ "static"
/ "css"
/ f"bootstrap.{style}.min.css"
)
run(f"lessc {source} > {dest}")
print(f'Seafoam LESS for "{style}" compiled to CSS!')
# TODO -- minimize css!
# consider css-html-js-minify
@task
def test(ctx, carefully=False, verbose=False, debug=False):
"""Generate the test Pelican site."""
config = p / "test" / "pelicanconf.py"
cli_args = ""
if carefully:
cli_args += " --fatal=warnings"
if verbose:
cli_args += " --verbose"
if debug:
cli_args += " --debug"
run(f"pelican -s {config}{cli_args}")
@task
def serve_test(ctx, port="8000"):
"""Serve the generated test site."""
# call using:
# invoke serve_test --port 8001
p4 = p / "test" / "output"
print(p4)
run(f"cd {p4} && start python -m http.server {port}")