diff --git a/badpklblog.cgi b/badpklblog.cgi new file mode 100755 index 0000000..f03db4e --- /dev/null +++ b/badpklblog.cgi @@ -0,0 +1,15 @@ +#!/usr/bin/pkl eval +function template(body: String): String = "\(body)
Served by \(read?("env:SERVER_SOFTWARE") ?? "a web server") and badpklblog." + +function loadPost(name: String): String = "

" + name.replaceAll("_", " ") + "

" + read("file:../posts/\(name).post").text ?? "Error in loading." + +function loadIndex(): String = "

Blog Listing

" + +header = "Content-Type: text/html\r\n\r\n" +b = read?("env:QUERY_STRING") ?? "" +xb = b.replaceAll("%20", " ") +result = if (xb == "") template(loadIndex()) else template(loadPost(xb.replaceAll(" ", "_"))) + +output { + text = header + result +}