Support proof-of-concept blog
After some toil, I have a working proof-of-concept blog. The idea is simple: write blog posts in markdown and store the posts in the `./posts` directory. Then use the server and `pandoc` to convert these markdown files into HTML at request time. I'm using nix to package everything together. It's far from perfect, but it works at the moment, which is encouraging.
This commit is contained in:
parent
2e3bb0435f
commit
6108f8df01
3 changed files with 16 additions and 10 deletions
|
@ -1,23 +1,24 @@
|
|||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
nixpkgs ? import <nixpkgs> {},
|
||||
depot ? import <depot> {},
|
||||
universe ? import <universe> {},
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
injectedPosts = pkgs.writeText "posts.lisp" ''
|
||||
injectedPosts = nixpkgs.writeText "posts.lisp" ''
|
||||
(in-package #:server)
|
||||
(setq *path-to-posts* "${./posts}")
|
||||
'';
|
||||
injectedExecutables = pkgs.writeText "executables.lisp" ''
|
||||
injectedExecutables = nixpkgs.writeText "executables.lisp" ''
|
||||
(in-package #:server)
|
||||
(setq *pandoc-bin* "${pkgs.pandoc}/bin/pandoc")
|
||||
(setq *pandoc-bin* "${nixpkgs.pandoc}/bin/pandoc")
|
||||
'';
|
||||
in depot.nix.buildLisp.program {
|
||||
name = "server";
|
||||
deps = with depot.third_party.lisp; [
|
||||
deps = with depot.third_party.lisp; with universe.third_party.lisp; [
|
||||
hunchentoot
|
||||
cl-arrows
|
||||
];
|
||||
srcs = [
|
||||
./src/server.lisp
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(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)
|
||||
|
||||
|
@ -9,7 +10,9 @@
|
|||
;; Nix-injected dependencies
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defvar *path-to-posts* "/tmp"
|
||||
;; 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")
|
||||
|
@ -21,7 +24,7 @@
|
|||
(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 t))
|
||||
:output :string))
|
||||
|
||||
;; TODO: Figure out how to handle this with Nix.
|
||||
(defvar *posts* (uiop:directory-files *path-to-posts*)
|
||||
|
@ -29,8 +32,7 @@
|
|||
|
||||
(hunchentoot:define-easy-handler
|
||||
(get-latest :uri "/latest") ()
|
||||
(print (parameter "name"))
|
||||
(uiop:read-file-string (car *posts*)))
|
||||
(render-post (concatenate 'string *path-to-posts* "/" "test.md")))
|
||||
|
||||
(hunchentoot:define-easy-handler
|
||||
(get-posts :uri "/posts") ()
|
||||
|
|
|
@ -15,8 +15,11 @@ let
|
|||
|
||||
readTree' = import /home/wpcarro/depot/nix/readTree {};
|
||||
|
||||
# TODO: Find a better way to expose entire monorepo without introducing
|
||||
# "infinite recursion".
|
||||
localPkgs = readTree: {
|
||||
third_party = readTree ./third_party;
|
||||
blog = readTree ./blog;
|
||||
third_party = readTree ./third_party;
|
||||
};
|
||||
in fix(self: {
|
||||
config = config self;
|
||||
|
|
Loading…
Reference in a new issue