aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2019-10-09 11:15:23 +0000
committers-ol <s-ol@users.noreply.github.com>2019-10-09 11:15:23 +0000
commit762d3a849bfc8b730a66ce0679d9190e578b96cc (patch)
treed04af9c174fb7f8487b1c65d965930cecbd9fdc6
parentadd lfs driver, spec (diff)
downloadmmm-762d3a849bfc8b730a66ce0679d9190e578b96cc.tar.gz
mmm-762d3a849bfc8b730a66ce0679d9190e578b96cc.zip
thin out build folder
-rw-r--r--build/render_all.moon9
-rw-r--r--build/server.moon3
-rw-r--r--build/util.moon53
-rw-r--r--mmm/mmmfs/fileder.moon38
4 files changed, 42 insertions, 61 deletions
diff --git a/build/render_all.moon b/build/render_all.moon
index 259346b..2a16a5f 100644
--- a/build/render_all.moon
+++ b/build/render_all.moon
@@ -8,17 +8,15 @@ add '?/init'
add '?/init.server'
require 'mmm'
-import tohtml from require 'mmm.component'
-import Browser from require 'mmm.mmmfs.browser'
+import load_tree from require 'mmm.mmmfs.fileder'
import render from require 'mmm.mmmfs.layout'
import SQLStore from require 'mmm.mmmfs.drivers.sql'
-import load_tree from require 'build.util'
-- usage:
-- moon render_all.moon [db.sqlite3] [startpath]
{ file, startpath } = arg
-export BROWSER, STATIC
+export STATIC
STATIC = true
tree = load_tree SQLStore :file
@@ -28,7 +26,6 @@ for fileder in coroutine.wrap tree\iterate
print "rendering '#{fileder.path}'..."
os.execute "mkdir -p 'out/#{fileder.path}'"
- BROWSER = Browser fileder
with io.open "out/#{fileder.path}/index.html", 'w'
- \write render (tohtml BROWSER), fileder
+ \write render (fileder\get 'text/html'), fileder
\close!
diff --git a/build/server.moon b/build/server.moon
index 8fb0615..b28073e 100644
--- a/build/server.moon
+++ b/build/server.moon
@@ -9,8 +9,7 @@ add '?/init.server'
require 'mmm'
-import dir_base, load_tree from require 'build.util'
-import Key from require 'mmm.mmmfs.fileder'
+import Key, dir_base, load_tree from require 'mmm.mmmfs.fileder'
import SQLStore from require 'mmm.mmmfs.drivers.sql'
import decodeURI from require 'http.util'
diff --git a/build/util.moon b/build/util.moon
deleted file mode 100644
index 92450c7..0000000
--- a/build/util.moon
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'lfs'
-import Fileder, Key from require 'mmm.mmmfs.fileder'
-
-get_path = (root) ->
- cwd = lfs.currentdir!
- path = ''
-
- while root\find '^%.%./'
- root = root\match '^%.%./(.*)'
- cwd, trimmed = cwd\match '(.*)(/[^/]+)$'
- path = trimmed .. path
-
- path
-
--- split filename into dirname + basename
-dir_base = (path) ->
- dir, base = path\match '(.-)([^/]-)$'
- if dir and #dir > 0
- dir = dir\sub 1, #dir - 1
-
- dir, base
-
-load_tree = (store, root='') ->
- fileders = setmetatable {},
- __index: (path) =>
- with val = Fileder {}
- .path = path
- rawset @, path, val
-
- root = fileders[root]
- root.facets['name: alpha'] = ''
- for fn, ft in store\list_facets root.path
- val = store\load_facet root.path, fn, ft
- root.facets[Key fn, ft] = val
-
- for path in store\list_all_fileders root.path
- fileder = fileders[path]
-
- parent, name = dir_base path
- fileder.facets['name: alpha'] = name
- table.insert fileders[parent].children, fileder
-
- for fn, ft in store\list_facets path
- val = store\load_facet path, fn, ft
- fileder.facets[Key fn, ft] = val
-
- root
-
-{
- :get_path
- :dir_base
- :load_tree
-}
diff --git a/mmm/mmmfs/fileder.moon b/mmm/mmmfs/fileder.moon
index 87dad78..2472933 100644
--- a/mmm/mmmfs/fileder.moon
+++ b/mmm/mmmfs/fileder.moon
@@ -182,7 +182,45 @@ class Fileder
__tostring: => "Fileder:#{@path}"
+-- split filename into dirname + basename
+dir_base = (path) ->
+ dir, base = path\match '(.-)([^/]-)$'
+ if dir and #dir > 0
+ dir = dir\sub 1, #dir - 1
+
+ dir, base
+
+-- load tree from a driver instance
+-- optionally load subtree starting at 'root' path
+load_tree = (store, root='') ->
+ fileders = setmetatable {},
+ __index: (path) =>
+ with val = Fileder {}
+ .path = path
+ rawset @, path, val
+
+ root = fileders[root]
+ root.facets['name: alpha'] = ''
+ for fn, ft in store\list_facets root.path
+ val = store\load_facet root.path, fn, ft
+ root.facets[Key fn, ft] = val
+
+ for path in store\list_all_fileders root.path
+ fileder = fileders[path]
+
+ parent, name = dir_base path
+ fileder.facets['name: alpha'] = name
+ table.insert fileders[parent].children, fileder
+
+ for fn, ft in store\list_facets path
+ val = store\load_facet path, fn, ft
+ fileder.facets[Key fn, ft] = val
+
+ root
+
{
:Key
:Fileder
+ :dir_base
+ :load_tree
}