diff --git a/src/.init.lua b/src/.init.lua
index 1888f5a..08a569e 100644
--- a/src/.init.lua
+++ b/src/.init.lua
@@ -18,6 +18,7 @@ app = require("soakbean") {
cache = { items = {} },
plugin = {},
opts = {},
+ forkpids = {},
cmd={
help = {file="cmd/help.lua", info="display all possible flags"},
server = {file="cmd/server.lua", info="starts the webserver"},
@@ -68,7 +69,6 @@ print = function(...) Log(kLogInfo, ... or "''") end -- nice redbean logging fro
app.url['^/data'] = '/data.lua' -- setup custom file endpoint
app.url['^/$'] = '/page/index.lua'
-app.url['^/experiences[/]?$'] = '/page/experiences.lua'
app.url['^/admin[/]?$'] = '/page/admin/index.lua'
app.get('^/design[/]?$', util.pagerender('page/design.html'))
@@ -85,19 +85,33 @@ end)
app --
.use( require("middleware/httpauth")() )
+.use( function(req,res,next)
+ local diskpath = app.opts.plugin_diskscan_dir
+ local urlpath = GetPath()
+ print( urlpath .. " => " .. diskpath)
+ foreach( app.cache.items, function(k,v)
+ print(v.path)
+ --local itempath = v.path:gsub("^.","")
+ --if itempath:sub(0,#diskpath) == diskpath then
+ -- local _, nslashes = itempath:gsub("/","")
+ -- local _, diskslashes = diskpath:gsub("/","")
+ -- if nslashes == diskslashes + 1 then
+ -- print("slashes = " .. nslashes .. " => " .. diskslashes)
+ -- table.insert(items,v)
+ -- end
+ --end
+ end)
+end)
.use( require("json").middleware() ) -- try plug'n'play json API middleware
.use( app.router( app.url ) ) -- try url router
.use( app.response() ) -- try serve app response (if any)
.use( function(req,next) Route() end) -- fallback default redbean fileserver
app.on('init', function()
- if assert(unix.fork()) == 0 then
- app.plugin.diskscan.scan(app.opts.plugin_diskscan_dir)
- print_r(app.cache)
- --os.execute("ls ; sleep 5")
- print("ok")
- --local ok, headers, body = Fetch('http://127.0.0.1:8080/test')
- end
+ --if assert(unix.fork()) == 0 then
+ -- local ok, headers, body = Fetch('http://127.0.0.1:8080/test')
+ -- print_r({ok=ok,header=headers,body=body})
+ --end
end)
function OnHttpRequest() app.run() end
@@ -105,3 +119,7 @@ function OnHttpRequest() app.run() end
OnServerStart = function()
app.init() -- this triggers init event
end
+
+OnServerStop = function()
+ print("todo: kill threads")
+end
diff --git a/src/page/experiences.html b/src/page/dir.html
similarity index 100%
rename from src/page/experiences.html
rename to src/page/dir.html
diff --git a/src/page/dir.lua b/src/page/dir.lua
new file mode 100644
index 0000000..16f4b66
--- /dev/null
+++ b/src/page/dir.lua
@@ -0,0 +1,35 @@
+local util = require("util")
+local tile = require('page/partial/tile')
+
+--if not app.cache['experiences.html'] and util.count(app.cache.items) > 0 then
+-- print("processing! " .. util.count(app.cache.items) .. " items")
+-- app.cache['experiences.html'] = util.memoize(
+-- function()
+-- local data = util.merge({tiles=''},{ opts = app.opts })
+-- foreach(app.cache.items, function(k,v)
+-- data.tiles = data.tiles .. tile( util.flatten(v,"item") )
+-- end)
+-- local html = util.template( LoadAsset("page/experiences.html"),data)
+-- return html
+-- end,
+-- 60*5 -- re-run every 5 mins (otherwise return cache)
+-- )
+--end
+
+
+
+if util.count(app.cache.items) == 0 then
+ SetStatus(200)
+ SetHeader('Content-Type', 'text/html; charset=utf-8')
+ local html = util.template( [[
+ ${header}
+
+