Formatting
This commit is contained in:
parent
59a7ffea0b
commit
b030b6d4d6
3 changed files with 26 additions and 14 deletions
|
@ -25,7 +25,9 @@ class CLI:
|
|||
return CLI.watch(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def generate(base_dir: str = "site", output_dir: str = "_dist", production: bool = False):
|
||||
def generate(
|
||||
base_dir: str = "site", output_dir: str = "_dist", production: bool = False
|
||||
):
|
||||
base_dir = Path(base_dir)
|
||||
output_dir = Path(output_dir)
|
||||
html_dir = output_dir / "html"
|
||||
|
@ -76,10 +78,7 @@ class CLI:
|
|||
import http.server
|
||||
|
||||
if os.path.exists(output_dir):
|
||||
rprint(
|
||||
WARN_LEADER
|
||||
+ f"clobbering {output_dir}"
|
||||
)
|
||||
rprint(WARN_LEADER + f"clobbering {output_dir}")
|
||||
|
||||
def run():
|
||||
if os.path.exists(output_dir):
|
||||
|
@ -100,7 +99,12 @@ class CLI:
|
|||
|
||||
run()
|
||||
|
||||
server = http.server.HTTPServer(("127.0.0.1", 8000), lambda a, b, c: http.server.SimpleHTTPRequestHandler(a, b, c, directory=Path(output_dir) / "html"))
|
||||
server = http.server.HTTPServer(
|
||||
("127.0.0.1", 8000),
|
||||
lambda a, b, c: http.server.SimpleHTTPRequestHandler(
|
||||
a, b, c, directory=Path(output_dir) / "html"
|
||||
),
|
||||
)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
|
||||
rprint(INFO_LEADER + f"Listening on http://127.0.0.1:8000")
|
||||
|
|
|
@ -10,10 +10,15 @@ def get_latest_commit_hash(base_dir: Path | str) -> str:
|
|||
.strip()
|
||||
)
|
||||
|
||||
|
||||
def get_latest_commit_datetime(base_dir: Path | str) -> datetime.datetime:
|
||||
# See https://git-scm.com/docs/pretty-formats for info about the format string
|
||||
return datetime.datetime.fromtimestamp(int(
|
||||
subprocess.check_output("git show --no-patch --format=%ct HEAD".split(" "), cwd=base_dir)
|
||||
.decode()
|
||||
.strip()
|
||||
))
|
||||
return datetime.datetime.fromtimestamp(
|
||||
int(
|
||||
subprocess.check_output(
|
||||
"git show --no-patch --format=%ct HEAD".split(" "), cwd=base_dir
|
||||
)
|
||||
.decode()
|
||||
.strip()
|
||||
)
|
||||
)
|
||||
|
|
|
@ -304,7 +304,8 @@ def blog(base_dir: Path, output_dir: Path, jinja_env: Environment, site_config:
|
|||
"canonicalURL": "/blog/tags/",
|
||||
"showAside": True,
|
||||
},
|
||||
"tags": list(sorted(filter(lambda x: x.description is not None, tags))) + list(sorted(filter(lambda x: x.description is None, tags))),
|
||||
"tags": list(sorted(filter(lambda x: x.description is not None, tags)))
|
||||
+ list(sorted(filter(lambda x: x.description is None, tags))),
|
||||
}
|
||||
)
|
||||
f.write(r)
|
||||
|
@ -449,9 +450,11 @@ def caddy_config(
|
|||
|
||||
def compress_png(output_dir: Path):
|
||||
pngcrush_exe: str | None = shutil.which("pngcrush")
|
||||
|
||||
|
||||
if pngcrush_exe is None:
|
||||
rprint(WARN_LEADER + "cannot find pngcrush executable, skipping PNG compression")
|
||||
rprint(
|
||||
WARN_LEADER + "cannot find pngcrush executable, skipping PNG compression"
|
||||
)
|
||||
return
|
||||
|
||||
for image in itertools.chain(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue