diff options
author | William Carroll <wpcarro@gmail.com> | 2020-01-29T14·29+0000 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-01-29T14·29+0000 |
commit | fb9380ba268b3cd27372acadb87b14cc96163374 (patch) | |
tree | f65d7fc8d8726499165a0949af39afd1abc8118c /universe/blog/src | |
parent | 15110e6de9f85537c7847267caa35fa068aea001 (diff) | |
parent | 8ad51b24dd8719840aac47134835ea25cfe1b0b8 (diff) |
Add 'universe/' from commit '8ad51b24dd8719840aac47134835ea25cfe1b0b8'
git-subtree-dir: universe git-subtree-mainline: 15110e6de9f85537c7847267caa35fa068aea001 git-subtree-split: 8ad51b24dd8719840aac47134835ea25cfe1b0b8
Diffstat (limited to 'universe/blog/src')
-rw-r--r-- | universe/blog/src/index.html | 16 | ||||
-rw-r--r-- | universe/blog/src/server.lisp | 49 |
2 files changed, 65 insertions, 0 deletions
diff --git a/universe/blog/src/index.html b/universe/blog/src/index.html new file mode 100644 index 000000000000..a9d9cf7eaa25 --- /dev/null +++ b/universe/blog/src/index.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta name="description" content="Showcase of AI bots at DeepMind" /> + <link rel="stylesheet" href="/index.css"> + <title>AI Showcase</title> + <script data-ad-client="ca-pub-6018268443649487" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> + </head> + <body> + <noscript>You need to enable JavaScript to run this app.</noscript> + <h1>Welcome</h1> + <p>To my blog!</p> + </body> +</html> diff --git a/universe/blog/src/server.lisp b/universe/blog/src/server.lisp new file mode 100644 index 000000000000..ad8169fa1af9 --- /dev/null +++ b/universe/blog/src/server.lisp @@ -0,0 +1,49 @@ +(in-package #:cl-user) +(defpackage #:server + (:documentation "Robot condemned to a life of admin work for my blog.") + (:use #:cl) + (:import-from #:cl-arrows #:->>) + (:export :main)) +(in-package #:server) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Nix-injected dependencies +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;; TODO: Wrap this in an assert or ensure that there's a trailing slash so it's +;; treated as a directory. +(defvar *path-to-posts* "/tmp/" + "File path pointing to the posts directory.") + +(defvar *pandoc-bin* "/usr/bin/pandoc") + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Library +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun render-post (path) + "Render the markdown file stored at PATH to HTML using pandoc." + (uiop:run-program (list *pandoc-bin* path "--to" "html") + :output :string)) + +;; TODO: Figure out how to handle this with Nix. +(defvar *posts* (uiop:directory-files *path-to-posts*) + "List of the paths to the blog posts.") + +(hunchentoot:define-easy-handler + (get-latest :uri "/latest") () + (render-post (concatenate 'string *path-to-posts* "/" "test.md"))) + +(hunchentoot:define-easy-handler + (get-posts :uri "/posts") () + "Working!") + +(defun main () + "This is the main entrypoint for our application." + (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242)) + (print "Listing on port 4242...") + (sb-thread:join-thread + (find-if (lambda (th) + (string= (sb-thread:thread-name th) + "hunchentoot-listener-*:4242")) + (sb-thread:list-all-threads)))) |