lgen.lua

Sun, 06 Aug 2023 14:32:25 +0300

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 06 Aug 2023 14:32:25 +0300
changeset 42
260f867d46c0
parent 35
2f927eae429b
permissions
-rw-r--r--

Preliminary breadcrumb support


local lgen={}
local lgen_path=string.gsub(arg[0], "(.*)/[^/]*", "%1");
if lgen_path~=nil then
    package.path=package.path .. ';' .. lgen_path .. '/?.lua'
end

-- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2
-- This is required by the "obsolete" ltp module
local CE = require('compat_env')
_G.setfenv = CE.setfenv
_G.getfenv = CE.getfenv

local scan=require('scan')
local handlers=require('handlers')
-- globally add missing stuff 
local luaext=require('luaext')
local lfs=require('lfs')
local path=require('mypath')

--
-- Main
--

if #arg < 3 then
    error("Usage: lgen src tmpl dst")
end

local src = arg[1]
local tmpl = arg[2]
local dst = arg[3]

print('Scan...')

hierarchy = scan.scan(src)


local env={
    paths={
        src=src,
        dst=dst,
        tmpl=tmpl,
        lgen_location=lgen_path,
    },
    pages={
    },
}
    
    
-- Pitäisi env konstruoida. polun perusteella.
scan.map(hierarchy, function(f) handlers.choose(f, env) end)

print('Phase 1...')
scan.map(hierarchy, function(f) handlers.phase1(f, env) end)
print('Phase 2...')
scan.map(hierarchy, function(f) handlers.phase2(f, env) end,
                    function(d) 
                        --log.log("Make path "..path.join(dst, d).."\n")
                        --lfs.mkdir(path.join(dst, d))
                    end)
--print('Phase 3...')
--scan.map(hierarchy, function(f) handlers.phase3(f, env) end)

mercurial