From a2ed63ca802ee109c1b70ceec56cf874875c37af Mon Sep 17 00:00:00 2001 From: s-ol Date: Thu, 30 Jan 2020 12:13:34 +0100 Subject: fix static rendering --- build/render_all.moon | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'build') diff --git a/build/render_all.moon b/build/render_all.moon index b09957e..57406be 100644 --- a/build/render_all.moon +++ b/build/render_all.moon @@ -7,26 +7,49 @@ add '?.server' add '?/init' add '?/init.server' +-- usage: +-- moon render_all.moon [STORE] [output] [startpath] +{ store, output, startpath } = arg + require 'mmm' -import Fileder from require 'mmm.mmmfs.fileder' +import Fileder, dir_base from require 'mmm.mmmfs.fileder' import get_store from require 'mmm.mmmfs.stores' -import render from require 'mmm.mmmfs.layout' --- usage: --- moon render_all.moon [STORE] [startpath] -{ store, startpath } = arg +export UNSAFE, STATIC, BROWSER + +UNSAFE = true +STATIC = { + spit: (path, val) -> + path = "#{output}/#{path}" + os.execute "mkdir -p '#{dir_base path}'" + with io.open path, 'w' + \write val + \close! +} -export STATIC -STATIC = true +require 'mmm.mmmfs' store = get_store store -tree = Fileder store -tree = tree\walk startpath if startpath +root = Fileder store +BROWSER = :root + +print "rendering to #{output}" + +style_url = (root\walk '/static/style')\gett 'URL -> text/css' +hljs_url = (root\walk '/static/highlight-pack')\gett 'URL -> text/javascript' +STATIC.style = "" +STATIC.scripts = " + + " + +tree = root\walk startpath or '' for fileder in coroutine.wrap tree\iterate print "rendering '#{fileder.path}'..." - os.execute "mkdir -p 'out/#{fileder.path}'" - with io.open "out/#{fileder.path}/index.html", 'w' - \write render (fileder\get 'text/html'), fileder - \close! + ok, val = pcall fileder.gett, fileder, 'text/html' + if not ok + warn "WARN: couldn't render #{fileder}:" + warn val + + STATIC.spit "#{fileder.path}/index.html", val -- cgit v1.2.3