Browse Source

Sketch out incremental plugin.

Brit Butler 11 years ago
parent
commit
7c12a9670b
2 changed files with 63 additions and 0 deletions
  1. 47 0
      plugins/incremental.lisp
  2. 16 0
      plugins/parallel.lisp

+ 47 - 0
plugins/incremental.lisp

@@ -0,0 +1,47 @@
1
+(eval-when (:compile-toplevel :load-toplevel)
2
+  (ql:quickload 'cl-store))
3
+
4
+(defpackage :coleslaw-incremental
5
+  (:use :cl)
6
+  (:import-from :coleslaw #:get-updated-files
7
+                          #:find-content-by-path
8
+                          #:write-document)
9
+  (:export #:enable))
10
+
11
+(in-package :coleslaw-incremental)
12
+
13
+;; FIXME: We currently never update the site for config changes.
14
+;; Examples to consider include changing the theme or domain of the site.
15
+
16
+;; NOTE: We're gonna be a bit dirty here and monkey patch. The compilation model
17
+;; still isn't an "exposed" part of Coleslaw. After some experimentation maybe
18
+;; we'll settle on an interface.
19
+
20
+(defvar *changed-content* nil
21
+  "A list of changed content instances to iterate over and write out to disk.")
22
+
23
+(defun coleslaw::load-content ()
24
+  ;; TODO: What if the file doesn't exist?
25
+  (let ((db-file (rel-path (user-homedir-pathname) ".coleslaw.db")))
26
+    (setf coleslaw::*site* (cl-store:restore db-file))
27
+    (loop for (status path) in (get-updated-files)
28
+       do (update-content status path))
29
+    (cl-store:store coleslaw::*site* db-file)))
30
+
31
+(defun update-content (status path)
32
+  (cond ((string= "D" status) (process-change :deleted path))
33
+        ((string= "M" status) (process-change :modified path))
34
+        ((string= "A" status) (process-change :added path))))
35
+
36
+(defgeneric process-change (status path)
37
+  (:documentation "Updates the database as needed for the STATUS change to PATH."))
38
+
39
+(defun coleslaw::compile-blog (staging)
40
+  "lulz. Do it live. DO IT ALL LIVE."
41
+  ;; FIXME: This doesn't cover prev/next links for posts, theme-fn for feeds.
42
+  (mapcar #'write-document *changed-content*))
43
+
44
+;; No-op. We'll be updating in place instead.
45
+(defmethod coleslaw:deploy (staging))
46
+
47
+(defun enable ())

+ 16 - 0
plugins/parallel.lisp

@@ -0,0 +1,16 @@
1
+(eval-when (:compile-toplevel :load-toplevel)
2
+  (ql:quickload 'lparallel))
3
+
4
+(defpackage :coleslaw-parallel
5
+  (:use :cl)
6
+  (:export #:enable))
7
+
8
+(in-package :coleslaw-parallel)
9
+
10
+;; TODO: The bulk of the speedup here should come from parallelizing discover.
11
+;; Publish will also benefit. Whether it's better to spin off threads for each
12
+;; content type/index type or the operations *within* discover/publish is not
13
+;; known, the higher granularity of doing it at the iterating over types level
14
+;; is certainly easier to prototype though.
15
+
16
+(defun enable ())