add code
This commit is contained in:
parent
181def9f0a
commit
a0cfae1bc5
1 changed files with 15 additions and 0 deletions
15
badpklblog.cgi
Executable file
15
badpklblog.cgi
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/usr/bin/pkl eval
|
||||||
|
function template(body: String): String = "<!DOCTYPE HTML><html><head><style>body { background-color: #DDD06A; }</style></head><body>\(body)<hr/><i>Served by \(read?("env:SERVER_SOFTWARE") ?? "a web server") and badpklblog.</body></html>"
|
||||||
|
|
||||||
|
function loadPost(name: String): String = "<h1>" + name.replaceAll("_", " ") + "</h1>" + read("file:../posts/\(name).post").text ?? "Error in loading."
|
||||||
|
|
||||||
|
function loadIndex(): String = "<h1>Blog Listing</h1><ul>" + read("file:../posts/index").text.replaceAll("£", "<li>").replaceAll("€", "</li>") + "</ul>"
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
Loading…
Reference in a new issue