Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#!/usr/bin/env lua5.1 -- (find-angg "LUA/lstoindexhtml.lua") -- (find-blogme3 "lstoindexhtml.lua") -- (find-angg ".zshrc" "lstoindexhtml_lua_maybe") -- (find-angg ".zshrc" "lstoindexhtml_lua_dirs") str=string; strfind=str.find; format=str.format; gsub=str.gsub; strlen=str.len; strrep=str.rep; strsub=str.sub; tinsert=table.insert -- lines={}; for line in io.lines() do tinsert(lines, line) end -- (find-es "lua5" "io.read") lines = splitlines(io.read("*a")) -- the output of an "ls -lAF" main = function (lines, dir) local _, __, nonfname = strfind(lines[2], "^(.* )[^ ]*$") local dots = strrep(".", strlen(nonfname)) local myre = "("..dots..")([^ */=@|]*)(.*)" local prin = print -- local output = {} -- if outfile and outfile ~= "" then -- prin = function (str) table.insert(output, str.."\n") end -- end prin "<html>" prin "<!-- Generated by http://angg.twu.net/LUA/lstoindexhtml.lua -->" prin("<head><title>"..(dir or "").."</title>") if fileexists(".favicon.png") then prin('<link rel="shortcut icon" href=".favicon.png" />') end prin("</head>") prin "<body>" prin "<pre>" for i=2,#lines do local _, __, l, fname, r = strfind(lines[i], myre) prin(format("%s<a href=\"%s\">%s</a>%s", l, fname, fname, r)) end prin "</pre>" prin "</body>" prin "</html>" end main(lines, ...) -- (find-zsh0 "cd /tmp/; lstoindexhtml_lua_maybe /tmp/") --[[ * (eepitch-shell) * (eepitch-kill) * (eepitch-shell) cd ~/TH/L/ for i in $(find .* * -type d | sort); do cd ~/TH/L/$i; lstoindexhtml_lua_maybe $i/ done * (eepitch-lua51) * (eepitch-kill) * (eepitch-lua51) dofile "lstoindexhtml.lua" --]]