--require 'luarocks.require' require 'table' require 'os' require 'string' require 'cosmo' require 'lfs' require 'extattr' require 'blutils' require 'templates' local root_dir = '/usr/local/www/bluedino.net/www' local downloads_dir = root_dir .. '/downloads' local suppress_file = blutils.suppress_file local breadcrumbs = blutils.breadcrumbs local toc = blutils.toc local function list_item() local d = lfs.dir(downloads_dir) local f = '' while (f) do repeat f = d() until not f or suppress_file(f) if not f then break end local path = downloads_dir .. '/' .. tostring(f) local item = extattr.get(path, 'name') or f local description = extattr.get(path, 'description') or 'Description not available.' cosmo.yield { item = item, file = f, description = description } end end local content_template = [=[ ]=] function handle(r) local date = os.date('%c', lfs.attributes(root_dir .. '/talks/index.lua', 'modification')) local content = cosmo.fill(content_template, { list_item = list_item }) local html_str = cosmo.fill(templates.main, {date = date, content = content, breadcrumbs = breadcrumbs { 'Downloads' }, title = 'BlueDino Downloads', page_title = 'BlueDino.Net', sidebar_content = toc{ 'Downloads', { url = '../talks/', name = 'Talks' }, { url = '../related/', name = 'Related Sites' }, },}) r.content_type = 'text/html' r:puts(html_str) end