Author:
Hash:
Timestamp:
+12 -1 +/-4 browse
Kevin Schoon [me@kevinschoon.com]
104f33adb45c3fa5c19aa6be183f83cc92fc7332
Thu, 27 Nov 2025 11:26:03 +0000 (2 days ago)
| 1 | diff --git a/build.py b/build.py |
| 2 | index a1a875c..bf615b9 100755 |
| 3 | --- a/build.py |
| 4 | +++ b/build.py |
| 5 | @@ -1,5 +1,6 @@ |
| 6 | #!/usr/bin/env python |
| 7 | |
| 8 | + import os |
| 9 | import pathlib |
| 10 | import subprocess |
| 11 | |
| 12 | @@ -7,6 +8,10 @@ import yaml |
| 13 | |
| 14 | import ninja_syntax |
| 15 | |
| 16 | + DEVMODE="" |
| 17 | + |
| 18 | + if os.environ.get("DEVMODE"): |
| 19 | + DEVMODE = "-devmode" |
| 20 | |
| 21 | def _nth(n): |
| 22 | return f"$$(echo $in | cut -d' ' -f{n})" |
| 23 | @@ -18,6 +23,7 @@ def _render_rule(w: ninja_syntax.Writer, name, link): |
| 24 | " ".join( |
| 25 | [ |
| 26 | "./render.py", |
| 27 | + DEVMODE, |
| 28 | "-stylesheet", |
| 29 | "gen/main.css", |
| 30 | "-template", |
| 31 | diff --git a/index.html.jinja b/index.html.jinja |
| 32 | index 7b4c84a..7f7094b 100644 |
| 33 | --- a/index.html.jinja |
| 34 | +++ b/index.html.jinja |
| 35 | @@ -22,7 +22,7 @@ |
| 36 | </body> |
| 37 | {% if devmode %} |
| 38 | <script> |
| 39 | - const socket = new WebSocket("ws://localhost:8080/ws") |
| 40 | + const socket = new WebSocket("{{devmode_websocket_addr}}") |
| 41 | socket.addEventListener("open", (event) => { |
| 42 | console.log("connected to server", event); |
| 43 | }); |
| 44 | diff --git a/render.py b/render.py |
| 45 | index c0419b7..eefbd0d 100755 |
| 46 | --- a/render.py |
| 47 | +++ b/render.py |
| 48 | @@ -12,6 +12,8 @@ import yaml |
| 49 | from bs4 import BeautifulSoup |
| 50 | from jinja2 import Environment, FunctionLoader |
| 51 | |
| 52 | + DEVMODE_WEBSOCKET_ADDR = "ws://localhost:8888/ws" |
| 53 | + |
| 54 | |
| 55 | def _load_sitemap(path, current_path): |
| 56 | by_name = dict() |
| 57 | @@ -131,6 +133,7 @@ def generate(template, content_path, stylesheet, link, sitemap, devmode=False): |
| 58 | "sitemap": sitemap, |
| 59 | "tree": tree, |
| 60 | "devmode": devmode, |
| 61 | + "devmode_websocket_addr": DEVMODE_WEBSOCKET_ADDR, |
| 62 | "current_time": datetime.now(), |
| 63 | } |
| 64 | ) |
| 65 | diff --git a/scripts/watch.sh b/scripts/watch.sh |
| 66 | index f3ea585..c4267a4 100755 |
| 67 | --- a/scripts/watch.sh |
| 68 | +++ b/scripts/watch.sh |
| 69 | @@ -3,6 +3,8 @@ |
| 70 | # the actual command we want to run each time any file changes in the project |
| 71 | BUILD_CMD="$@" |
| 72 | |
| 73 | + export DEVMODE="yes" |
| 74 | + |
| 75 | ./server.py & |
| 76 | |
| 77 | server_pid="$!" |