63 lines
1.3 KiB
Raku
Executable File
63 lines
1.3 KiB
Raku
Executable File
#!/usr/bin/pl
|
|
|
|
(struct post
|
|
(title body))
|
|
|
|
;(def element (fn (type) (fn (text) (cat "<" type ">" text "</" type ">"))))
|
|
;(def link (element "link"))
|
|
;(prnl (link "howdy"))
|
|
|
|
(def html (fn (text) (cat "<html>" text "</html>")))
|
|
(def head (fn (text) (cat "<head>" text "</head>")))
|
|
(def body (fn (text) (cat "<body>" text "</body>")))
|
|
(def link (fn (text) (cat "<link " text ">")))
|
|
(def h1 (fn (text) (cat "<h1>" text "</h1>
|
|
")))
|
|
(def h2 (fn (text) (cat "<h2>" text "</h2>")))
|
|
(def p (fn (text) (cat "<p>" text "</p>
|
|
")))
|
|
|
|
|
|
(def htmlize (fn (po) (cat
|
|
(h2 po's title)
|
|
(p po's body))))
|
|
|
|
(def p1 (post "Hey" "This is a post"))
|
|
(def p2 (post "This"
|
|
"Is ALSO a post. And frankly, what a great post! It's so long and flowing,
|
|
and the interpreter won't even instantly crash over it! It's truly astounding
|
|
stuff, when you think about it."
|
|
))
|
|
|
|
(def homepage (fn () (html (cat
|
|
(head (link "rel='stylesheet' href='styles.css'"))
|
|
(body (cat
|
|
(h1 "This is Sage's Blog")
|
|
(htmlize p1)
|
|
(htmlize p2)))))) )
|
|
|
|
(addroute "/" homepage)
|
|
|
|
(addroute "/styles.css" (fn () (
|
|
"html {
|
|
background-color: #ddddff;
|
|
}
|
|
body {
|
|
width: 40%;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
font-size: 200%;
|
|
font-family: sans;
|
|
}
|
|
"
|
|
)))
|
|
|
|
(def PORT 9090)
|
|
(serve PORT)
|
|
(prnl (cat "Hosting server on " PORT ". Press enter to exit."))
|
|
(def repl (fn () (
|
|
(eval (inp))
|
|
(repl)
|
|
)))
|
|
(repl)
|