Something went wrong. Try again.
static-site-generator blogging hypertext ocaml
Something went wrong. Try again.
1.7 kB · 49 lines
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 $ forester init > /dev/null
$ echo 'fake png' > assets/pic.png
$ cat > trees/index.tree << EOF > \title{HTTP server test} > \<html:img>[src]{\route-asset{assets/pic.png}}{} > EOF $ forester start --no-browser & Forester is running on http://localhost:8080 $ SERVER_PID=$! $ curl -s --retry 5 --retry-connrefused http://localhost:8080 > response.html $ cat response.html | grep -Fo 'HTTP server test' HTTP server test HTTP server test HTTP server test HTTP server test HTTP server test $ tr '\n' ' ' < response.html | grep -Fo '<img xmlns:html="http://www.w3.org/1999/xhtml" src="/preview/' <img xmlns:html="http://www.w3.org/1999/xhtml" src="/preview/
$ curl -s http://localhost:8080/preview/index/ | tr '\n' ' ' | grep -oE '<meta property="og:image" [^>]*>' <meta property="og:image" content="http://localhost:8080/og-image.png">
The json manifest is available:
$ curl -s http://localhost:8080/forest.json | grep -Fo '"title":"HTTP server test"' "title":"HTTP server test"
Links in the manifest are routed to preview: $ curl -s http://localhost:8080/forest.json | grep -Fo '/preview/index/' /preview/index/
The docs are routed like any other foreign forest
$ curl -s --retry 5 --retry-connrefused http://localhost:8080/preview/foreign/forester-notes.org/index/ | grep -o "maintained by" maintained by maintained by
Assets are available: $ curl -s -H "Hx-Request: true" http://localhost:8080/home > home.html $ ASSET_SRC=$(grep -oE '/preview/[a-z0-9]+\.png' home.html) $ curl -s http://localhost:8080$ASSET_SRC fake png $ curl -s -o /dev/null -w '%{content_type}\n' http://localhost:8080$ASSET_SRC image/png
$ kill $SERVER_PID $ wait $SERVER_PID 2>/dev/null || true