lgen.lua

Wed, 08 Dec 2021 23:32:16 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Wed, 08 Dec 2021 23:32:16 +0200
changeset 40
458b3ce6e2f2
parent 35
2f927eae429b
child 42
260f867d46c0
permissions
-rw-r--r--

highlight.js changes update


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...')

local 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