diff options
author | Ronan Collobert <ronan@collobert.com> | 2014-02-13 21:22:15 +0400 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2014-02-13 21:22:15 +0400 |
commit | cb44055037f8cf7e07838e8043ddd4f892cf3557 (patch) | |
tree | 9a290f552e7a4c19cfd6fa0994e3612242f6432b | |
parent | d4b6a8fad6494475e8604047bedeaec6bf91c946 (diff) |
removed search.lua
-rw-r--r-- | search.lua | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/search.lua b/search.lua deleted file mode 100644 index a95d03f..0000000 --- a/search.lua +++ /dev/null @@ -1,69 +0,0 @@ --------------------------------------------------------------------------------- --- search in help --- that file defines all the tools and goodies to allow search --------------------------------------------------------------------------------- -local entries = {} - -paths.install_dok = paths.concat(paths.install_html, '..', 'dok') -paths.install_dokmedia = paths.concat(paths.install_html, '..', 'dokmedia') - -local function html2entries(html, package, file) - local dnext = html:gfind('<div.->(.-)</div>') - for div in dnext do - local next = div:gfind('<h%d><a.->%s+(.-)%s+</a></h%d><a.-></a>\n<a name="(.-)"></a>\n(.-)$') - for title,link,body in next do - link = package .. '/' .. file:gsub('.txt','.html') .. '#' .. link - body = body:gsub('<img.->','') - entries.global = entries.global or {} - table.insert(entries.global, {title, link, body}) - entries[package] = entries[package] or {} - table.insert(entries[package], {title, '../' .. link, body}) - end - end - return entries -end - -local function install(entries, dir) - local vars = {} - for i,entry in ipairs(entries) do - table.insert(vars, 's[' .. (i-1) .. '] = "' - .. table.concat(entry, '^~^'):gsub('"','\\"'):gsub('\n',' ') .. '";') - end - local array = table.concat(vars, '\n') - array = array:gsub('%%','PERCENTFUCK') - local f = paths.concat(paths.install_html, paths.basename(dir), 'jse_form.js') - if paths.filep(f) then - local js = io.open(f):read('*all') - js = js:gsub('// SEARCH_ARRAY //', array) - js = js:gsub('PERCENTFUCK','%') - local w = io.open(f,'w') - w:write(js) - w:close() - end -end - -function dok.installsearch() - print('-- parsing dok files to build search index') - for package in paths.files(paths.install_dok) do - if package ~= '.' and package ~= '..' then - local dir = paths.concat(paths.install_dok, package) - for file in paths.files(dir) do - if file ~= '.' and file ~= '..' then - print('-+ parsing file: ' .. paths.concat(dir,file)) - local path = paths.concat(dir, file) - local f = io.open(path) - if f then - local content = f:read('*all') - local html = dok.dok2html(content) - local entries = html2entries(html, package, file) - end - end - end - end - end - for package,entries in pairs(entries) do - print('-+ installing search for package: ' .. package) - if package == 'global' then package = '.' end - install(entries, package) - end -end |