123456789101112131415161718192021222324252627 |
- local header = "<div id=\"preamble\" class=\"status\">\n <div id=\"banner\">\n <h1><a href=\"/home.html\">Kevin \"The Nuclear\" Bloom</a></h1>\n <hr />\n <div id=\"navit\">\n <a href=\"/contact.html\">Contact</a>\n \n <a href=\"/blog.html\">Blog</a>\n \n <a href=\"/projects.html\">Projects</a>\n \n <a href=\"/about-me.html\">About Me</a>\n </div>\n </div>\n</div>\n"
- local footer = "<div id=\"footer\">\n <hr />\n <p>\n <a href=\"https://anybrowser.org/campaign/\">\n <img src=\"/img/any-browser.png\" alt=\"Viewable with any browser! No JS, no cookies, no bullshit!\"/></a>\n \n <a href=\"http://validator.w3.org/check?uri=nuclearkev.org\"><img\n src=\"http://www.w3.org/Icons/valid-xhtml10\" alt=\"Valid XHTML 1.0 Strict\" height=\"31\" width=\"88\" /></a>\n \n <a href=\"http://NetBSD.org/\"><img\n src=\"https://www.netbsd.org/images/powered-by-NetBSD.png\" alt=\"NetBSD\" width=\"88\" /></a>\n </p>\n <p>\n Copyright \194\169 2017-2022 Kevin \"The Nuclear\" Bloom\n </p>\n</div>\n"
- local function top_stuff(title)
- return ("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n<head>\n" .. title .. "<link rel=\"shortcut icon\" type=\"image/png\" href=\"/img/guy-in-space.png\"/>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n<meta name=\"generator\" content=\"Org mode\" />\n<meta name=\"author\" content=\"Kevin "The Nuclear" Bloom\" />\n<meta http-equiv=\"cache-control\" content=\"no-cache, must-revalidate, post-check=0, pre-check=0\" />\n<meta http-equiv=\"cache-control\" content=\"max-age=0\" />\n<meta http-equiv=\"expires\" content=\"0\" />\n<meta http-equiv=\"expires\" content=\"Tue, 01 Jan 1980 1:00:00 GMT\" />\n<meta http-equiv=\"pragma\" content=\"no-cache\" />\n<link rel='stylesheet' href='/styles/main.2.css' />\n</head>\n")
- end
- local function drop(s, ind)
- return string.sub(s, ind)
- end
- local function take(s, ind)
- return string.sub(s, 1, ind)
- end
- local function substring_between(s, fir, lst)
- local fir_pos = string.find(s, fir)
- local up_to_fir = drop(s, fir_pos)
- local lst_pos = string.find(up_to_fir, lst)
- return take(up_to_fir, lst_pos)
- end
- local function generate_page(file_name)
- local file_port = io.open(file_name, "r")
- local full_file = file_port:read("*a")
- local title = (substring_between(full_file, "<title>", "</title>") .. "/title>\n")
- local body = drop(substring_between(full_file, "<body>", "\n</body>"), 7)
- file_port:close()
- return print((top_stuff(title) .. "<body>\n" .. header .. body .. footer .. "</body>\n" .. "</html>"))
- end
- return generate_page(arg[1])
|