|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/usr/bin/env lua50
-- -*- coding: raw-text-unix -*-
-- This is the `blogme2.lua' file of blogme2.
-- It contains one possible "main" for blogme2 - it loads the rest and
-- interprets the command-line args.
-- Author and version: Eduardo Ochs <eduardoochs@gmail.com>, 2006sep04
-- License: GPL.
-- (find-fline "INTERNALS")
-- (find-fline "blogme2-inner.lua")
-- (find-fline "blogme2-middle.lua")
-- (find-fline "blogme2-outer.lua")
-- (find-blogmefile "blogme.lua" "_G[\"lua:\"]")
-- Add the curent directory to LUA_PATH (if in standalone mode).
-- (find-es "lua5" "require")
--
-- -- Lua 5.0 only:
-- LUA_PATH = LUA_PATH or os.getenv("LUA_PATH") or "?;?.lua"
-- do local _, __, arg0path = string.find(arg[0], "^(.*)/[^/]*$")
-- if arg0path then LUA_PATH = LUA_PATH..";"..arg0path.."/?" end
-- end
-- 2006sep04: added code - now this runs on both 5.0 and 5.1
LUA_PATH = LUA_PATH or os.getenv("LUA_PATH") or "?;?.lua"
do local _, __, arg0path = string.find(arg[0], "^(.*)/[^/]*$")
if arg0path then LUA_PATH = LUA_PATH..";"..arg0path.."/?.lua"
if package and package.path then
package.path = arg0path.."/?.lua;"..package.path
end
end
end
-- 2006sep04: removed the ".lua"s to make everything run on 5.1 too
require "edrxlib"
require "blogme2-inner"
require "blogme2-middle"
require "blogme2-outer"
--;;
--;; blogme
--;;
-- htmlize = function (title, body)
-- blogme_output = HTMLIZE(title, body)
-- return ""
-- end
-- setgetargs(vargs2, "htmlize")
blogme_test = function (infname, outfname)
blogme_input_fname = infname
blogme_output_fname = outfname
blogme_input = readfile(blogme_input_fname)
subj, pos = blogme_input, 0
if checkbrackets(blogme_fname) > 0 then
os.exit(1)
end
vparse()
if blogme_output_fname then
writefile(blogme_output_fname, blogme_output)
else
print(blogme_output)
end
end
-- pparse("[AL foo]")
-- PP(arg)
if not library then
local i = 1
local infname, outfname
while i <= getn(arg) do
local a, b = arg[i], arg[i+1]
if a == "-o" then outfname = b; i = i+2
elseif a == "-i" then blogme_test(b, outfname); i = i+2
elseif a == "-p" then relativepathto_prefix = b; i = i+2
elseif a == "-e" then assert(loadstring(b))(); i = i+2
elseif a == "-remote" then LR = R; i = i+1
else print("Unrecognized option: " .. a); os.exit(1)
end
end
end
-- blogme_test("index.blogme", "index.html")
-- (find-fline "index.blogme")
-- (find-fline "~/TH/math-b.blogme")
-- (find-w3m "~/LUA/index.html")
-- (find-fline "~/TH/webcomics.blogme")
-- (find-fline "blogme2-inner.lua")
-- (find-fline "blogme2-middle.lua")
-- (find-fline "blogme2-outer.lua")
-- (find-angg "TH/Files.tcl" "blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/wc.html -i ~/TH/webcomics.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/i.html -i ~/TH/index.blogme")
-- (find-fline "~/TH/index.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/h.html -i ~/TH/heroes.blogme")
-- (find-fline "~/TH/heroes.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/m.html -i ~/TH/math-b.blogme")
-- (find-fline "~/TH/math-b.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/p.html -i ~/TH/personal.blogme")
-- (find-fline "~/TH/personal.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/t.html -i ~/TH/tmp-b.blogme")
-- (find-fline "~/TH/tmp-b.blogme")
-- (find-blogmesh "blogme2.lua -o /tmp/w.html -i ~/TH/webcomics.blogme")
-- (find-fline "~/TH/webcomics.blogme")
-- (find-blogmesh "blogme2-outer.lua -e 'PP(_P)'")