| @@ -29,11 +29,10 @@ import re |
| 29 | import shutil |
29 | import shutil |
| 30 | import subprocess |
30 | import subprocess |
| 31 | import sys |
31 | import sys |
| 32 | from html import escape |
| |
| 33 | from urllib.parse import quote |
| |
| 34 | from datetime import datetime |
32 | from datetime import datetime |
| |
33 | from html import escape |
| 35 | from pathlib import Path |
34 | from pathlib import Path |
| 36 | |
35 | from urllib.parse import quote |
| 37 | |
36 | |
| 38 | SITE_TEMPLATE_VARS = { |
37 | SITE_TEMPLATE_VARS = { |
| 39 | "site_name": "cleberg.net", |
38 | "site_name": "cleberg.net", |
| @@ -45,9 +44,7 @@ SITE_TEMPLATE_VARS = { |
| 45 | def run_ruff(): |
44 | def run_ruff(): |
| 46 | print("Running ruff...") |
45 | print("Running ruff...") |
| 47 | for cmd in [["ruff", "check", "--fix"], ["ruff", "format"]]: |
46 | for cmd in [["ruff", "check", "--fix"], ["ruff", "format"]]: |
| 48 | result = subprocess.run( |
47 | result = subprocess.run(cmd, capture_output=True, text=True, check=False) |
| 49 | cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True |
| |
| 50 | ) |
| |
| 51 | if result.returncode != 0: |
48 | if result.returncode != 0: |
| 52 | print(f"ruff error ({' '.join(cmd)}):") |
49 | print(f"ruff error ({' '.join(cmd)}):") |
| 53 | print(result.stderr, file=sys.stderr) |
50 | print(result.stderr, file=sys.stderr) |
| @@ -300,9 +297,9 @@ def minify_css(src_css, dest_css): |
| 300 | print(f"Minifying CSS: {src_css} → {dest_css}") |
297 | print(f"Minifying CSS: {src_css} → {dest_css}") |
| 301 | result = subprocess.run( |
298 | result = subprocess.run( |
| 302 | ["minify", "-o", str(dest_css), str(src_css)], |
299 | ["minify", "-o", str(dest_css), str(src_css)], |
| 303 | stdout=subprocess.PIPE, |
300 | capture_output=True, |
| 304 | stderr=subprocess.PIPE, |
| |
| 305 | text=True, |
301 | text=True, |
| |
302 | check=False, |
| 306 | ) |
303 | ) |
| 307 | if result.returncode != 0: |
304 | if result.returncode != 0: |
| 308 | print("Error during CSS minification:") |
305 | print("Error during CSS minification:") |
| @@ -314,9 +311,9 @@ def minify_html(src_html, dest_html): |
| 314 | print(f"Minifying HTML: {src_html} → {dest_html}") |
311 | print(f"Minifying HTML: {src_html} → {dest_html}") |
| 315 | result = subprocess.run( |
312 | result = subprocess.run( |
| 316 | ["minify", "-o", str(dest_html), str(src_html)], |
313 | ["minify", "-o", str(dest_html), str(src_html)], |
| 317 | stdout=subprocess.PIPE, |
314 | capture_output=True, |
| 318 | stderr=subprocess.PIPE, |
| |
| 319 | text=True, |
315 | text=True, |
| |
316 | check=False, |
| 320 | ) |
317 | ) |
| 321 | if result.returncode != 0: |
318 | if result.returncode != 0: |
| 322 | print("Error during HTML minification:") |
319 | print("Error during HTML minification:") |
| @@ -333,6 +330,7 @@ def run_emacs_publish(dev_mode=True): |
| 333 | stdout=subprocess.PIPE, |
330 | stdout=subprocess.PIPE, |
| 334 | stderr=subprocess.STDOUT, |
331 | stderr=subprocess.STDOUT, |
| 335 | text=True, |
332 | text=True, |
| |
333 | check=False, |
| 336 | ) |
334 | ) |
| 337 | |
335 | |
| 338 | if result.returncode != 0: |
336 | if result.returncode != 0: |
| @@ -538,9 +536,9 @@ def deploy_to_server(build_dir, server): |
| 538 | print(f"Deploying .build/ → {remote_path}") |
536 | print(f"Deploying .build/ → {remote_path}") |
| 539 | result = subprocess.run( |
537 | result = subprocess.run( |
| 540 | ["rsync", "-r", "--delete-before", f"{build_dir}/", remote_path], |
538 | ["rsync", "-r", "--delete-before", f"{build_dir}/", remote_path], |
| 541 | stdout=subprocess.PIPE, |
539 | capture_output=True, |
| 542 | stderr=subprocess.PIPE, |
| |
| 543 | text=True, |
540 | text=True, |
| |
541 | check=False, |
| 544 | ) |
542 | ) |
| 545 | if result.returncode != 0: |
543 | if result.returncode != 0: |
| 546 | print("Error during rsync deployment:") |
544 | print("Error during rsync deployment:") |