Przeglądaj źródła

Sketch of the new design.

Brit Butler 13 lat temu
rodzic
commit
c795b1bd59
4 zmienionych plików z 47 dodań i 27 usunięć
  1. 1 1
      coleslaw.asd
  2. 17 6
      src/coleslaw.lisp
  3. 29 0
      src/git.lisp
  4. 0 20
      src/packages.lisp

+ 1 - 1
coleslaw.asd

@@ -5,7 +5,7 @@
5 5
   :license "BSD"
6 6
   :author "Brit Butler <redline6561@gmail.com>"
7 7
   :pathname "src/"
8
-  :depends-on (:closure-template :cl-fad :local-time :alexandria)
8
+  :depends-on (:closure-template :iolib.os :local-time :alexandria)
9 9
   :serial t
10 10
   :components ((:file "packages")
11 11
                (:file "coleslaw")

+ 17 - 6
src/coleslaw.lisp

@@ -1,11 +1,5 @@
1 1
 (in-package :coleslaw)
2 2
 
3
-(defgeneric start-coleslaw (&rest options)
4
-  (:documentation "Start the coleslaw server with any specified OPTIONS."))
5
-
6
-(defgeneric stop-coleslaw (&rest options)
7
-  (:documentation "Stop the coleslaw server with any specified OPTIONS."))
8
-
9 3
 (defparameter *storage* nil
10 4
   "A db-spec for postmodern or a hash-table cache. It is expected that
11 5
 *storage* has methods for each Generic Function in coleslaw implemented.")
@@ -15,3 +9,20 @@
15 9
 
16 10
 (defgeneric set-credentials (name credentials)
17 11
   (:documentation "Store the given CREDENTIALS in *storage* under NAME."))
12
+
13
+(defun load-config ()
14
+  nil)
15
+
16
+(defun exit-handler ()
17
+  nil)
18
+
19
+(defun compile-blog ()
20
+  nil)
21
+
22
+(defun main ()
23
+  (load-config)
24
+  (unwind-protect
25
+       (loop do (if (blog-update-p)
26
+                    (compile-blog)
27
+                    (sleep 600)))
28
+    (exit-handler)))

+ 29 - 0
src/git.lisp

@@ -0,0 +1,29 @@
1
+(in-package :coleslaw)
2
+
3
+;; TODO:
4
+; Replace hardcoded paths (repo, .deploy) with *config*?
5
+; blog-update-p would be thing to make a generic in a plugin.
6
+
7
+(defun last-commit ()
8
+  "Retrieve the SHA1 hash of the most recent blog commit."
9
+  (multiple-value-bind (pid stdout stderr)
10
+      (iolib.os:with-current-directory "/home/redline/projects/coleslaw/"
11
+        (iolib.os:run-program "git" '("log" "-n 1")))
12
+    (cl-ppcre:scan-to-strings "[0-9a-f]{40}" stdout)))
13
+
14
+(defun last-published ()
15
+  "Retrieve the SHA1 hash of the most recent published blog."
16
+  (with-open-file (in "/home/redline/.coleslaw"
17
+                      :if-does-not-exist :create)
18
+    (read-line in nil)))
19
+
20
+(defun (setf last-published) (new-val)
21
+  (with-open-file (out "/home/redline/.coleslaw"
22
+                       :direction :output
23
+                       :if-exists :supersede
24
+                       :if-does-not-exist :create)
25
+    (write-line new-val out)))
26
+
27
+(defun blog-update-p ()
28
+  "Returns a non-nil value if the blog needs to be regenerated."
29
+  (mismatch (last-commit) (last-published)))

+ 0 - 20
src/packages.lisp

@@ -2,8 +2,6 @@
2 2
   (:use :cl :closure-template)
3 3
   (:export ;; coleslaw-core
4 4
            #:*storage*
5
-           #:start-coleslaw
6
-           #:stop-coleslaw
7 5
            #:get-credentials
8 6
            #:set-credentials
9 7
 
@@ -28,24 +26,6 @@
28 26
            #:post-content
29 27
            #:post-aliases
30 28
 
31
-           ;; comments
32
-           #:make-comment
33
-           #:add-comment
34
-           #:remove-comment
35
-           #:render-comments
36
-           #:find-comments
37
-
38
-           #:author-name
39
-           #:author-url
40
-           #:author-ip
41
-
42
-           #:comment-id
43
-           #:comment-post
44
-           #:comment-author
45
-           #:comment-timestamp
46
-           #:comment-content
47
-           #:comment-parent
48
-
49 29
            ;; indices
50 30
            #:make-index
51 31
            #:add-to-index