From a0cfae1bc5fee0866915d9865bedf80fd313b025 Mon Sep 17 00:00:00 2001 From: threeoh6000 Date: Sun, 11 Feb 2024 17:10:48 +0000 Subject: [PATCH] add code --- badpklblog.cgi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 badpklblog.cgi 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 +}