Ver código fonte

Improve post-url scheme, do taglinks and monthlinks the right way in index template, update coleslaw-static.asd and TODO.

Brit Butler 14 anos atrás
pai
commit
b7e8f78465
7 arquivos alterados com 49 adições e 32 exclusões
  1. 14 10
      TODO
  2. 7 1
      coleslaw-static.asd
  3. 2 0
      plugins/akismet.lisp
  4. 2 12
      static/indices.lisp
  5. 10 7
      static/posts.lisp
  6. 4 0
      static/util.lisp
  7. 10 2
      themes/hyde/index.tmpl

+ 14 - 10
TODO

@@ -3,35 +3,39 @@ Everything.
3 3
 Ideas:
4 4
 -- Replace cl-markdown with 3bmd down the line?
5 5
 -- Use cl-inotify or similar for notifications instead of timers?
6
- -- plugins -> lastfm widget, analytics, rss/atom, disqus, akismet, etc.
7 6
 
8
-;; TODO:
9
-;; consider add-to-index/setf-index, create-index, create-post.
10
-;; then ensure the indices API is okay and GET GOING.
11
-
12
-;;;; DYNAMIC
7
+TODO:
13 8
 
14 9
 ;;;; STATIC
15 10
 ;;;; implement head-inject/body-inject/navigation!
16 11
 ;;;; implement start-coleslaw, stop-coleslaw!
17
-;;;; non-disqus comment support?
18
-;;; indexes
12
+;;;; implement render-site!!!
13
+;;;; implement atom feed. RSS too?
14
+;;;; implement non-disqus comment support?
15
+;;;; What do post update semantics look like? i.e. edit file to change tags.
16
+;;; indices
19 17
 ;; what should it really look like, keeping in mind the API should be mostly
20 18
 ;; identical between the static and dynamic backend?
19
+;; indexes should be id/name, title + posts. rewrite indices to use them.
21 20
 ;;; posts
22 21
 ;; Make find-by-date, post-url not suck.
23 22
 ;; -- re: find-by-date, aside from the subseq+string= grossness, the posts it
24 23
 ;; -- returns are not in reverse chronological order. Fix it!
25
-;; -- re: post-url, escaping is insufficient and there are collisions by title.
26
-;; -- What are alternatives?
24
+;; -- re: post-url, improve escaping.
27 25
 
28 26
 ;;;; PLUGINS
29 27
 ;;;; implement: analytics, crossposting, disqus, mathjax, pygments, recaptcha, s3
28
+;;;; support input or output dirs being git repos + have git hooks?
30 29
 ;;; import
31 30
 ;; add output to HTML files when static-p is true
32 31
 ;; add comment handling ... (when comments ...)
33 32
 ;; support old URLs via use of post-aliases?
34 33
 
34
+;;;; DYNAMIC
35
+;;;; implement the whole damn backend!
36
+;;;; make sure it has an admin interface!
37
+;;;; -- spend two years trying to make it secure without HTTPS+SSL. fail.
38
+
35 39
 ;;;; rendering hooks (pygmentize, xposting) via :around/:before/:after methods
36 40
 ;; get run on rendered html before "storage"
37 41
 ;; xposting may be a rendering hook but may necessitate publishing hooks

+ 7 - 1
coleslaw-static.asd

@@ -5,8 +5,14 @@
5 5
   :maintainer "Brit Butler <redline6561@gmail.com>"
6 6
   :author "Brit Butler <redline6561@gmail.com>"
7 7
   :licence "LLGPL"
8
-  :depends-on (:coleslaw :zs3 :trivial-timers)
8
+  :depends-on (:coleslaw :zs3 :trivial-timers :cl-store)
9 9
   :components ((:module static
10 10
                         :components ((:file "coleslaw")
11
+                                     (:file "comments"
12
+                                            :depends-on ("coleslaw"))
11 13
                                      (:file "posts"
14
+                                            :depends-on ("coleslaw"))
15
+                                     (:file "indices"
16
+                                            :depends-on ("posts"))
17
+                                     (:file "util"
12 18
                                             :depends-on ("coleslaw"))))))

+ 2 - 0
plugins/akismet.lisp

@@ -0,0 +1,2 @@
1
+(in-package :coleslaw)
2
+

+ 2 - 12
static/indices.lisp

@@ -2,21 +2,11 @@
2 2
 
3 3
 (defun monthlinks ()
4 4
   (loop for month in (gethash :months-index *storage*)
5
-     collect (cons (index-url :date month) month) into months
6
-     finally (return
7
-               (pretty-list (mapcar (lambda (consp)
8
-                                      (format nil "<a href=\"~a\">~a</a>"
9
-                                              (car consp) (cdr consp)))
10
-                                    months)))))
5
+     collecting (list :url (index-url :date month) :name month)))
11 6
 
12 7
 (defun taglinks ()
13 8
   (loop for tag in (gethash :tags-index *storage*)
14
-     collect (cons (index-url :tag tag) tag) into tags
15
-     finally (return
16
-               (pretty-list (mapcar (lambda (consp)
17
-                                      (format nil "<a href=\"~a\">~a</a>"
18
-                                              (car consp) (cdr consp)))
19
-                                    tags)))))
9
+     collecting (list :url (index-url :tag tag) :name tag)))
20 10
 
21 11
 (defun index-title (id &optional page)
22 12
   (case id

+ 10 - 7
static/posts.lisp

@@ -43,14 +43,14 @@
43 43
             (push post results)))
44 44
     results))
45 45
 
46
-(defmethod find-by-date (date)
46
+(defmethod find-by-date (year-month)
47 47
   (let ((results nil)
48
-        (year (parse-integer (subseq date 0 4)))
49
-        (month (parse-integer (subseq date 5))))
48
+        (year (parse-integer (subseq year-month 0 4)))
49
+        (month (parse-integer (subseq year-month 5))))
50 50
     (loop for post being the hash-values in (gethash :posts *storage*)
51
-       do (let ((post-date (post-date post)))
52
-            (when (and (= year (local-time:timestamp-year post-date))
53
-                       (= month (local-time:timestamp-month post-date)))
51
+       do (let ((date (post-date post)))
52
+            (when (and (= year (local-time:timestamp-year date))
53
+                       (= month (local-time:timestamp-month date)))
54 54
               (push post results))))
55 55
     results))
56 56
 
@@ -62,4 +62,7 @@
62 62
 (defmethod post-url (id)
63 63
   (flet ((escape (str)
64 64
            (substitute #\- #\Space str)))
65
-    (concatenate 'string *site-root* "/" (escape (post-title (find-post id))))))
65
+    (let ((post (find-post id)))
66
+      (concatenate 'string *site-root* "/"
67
+                   (year-month (post-date post)) "/"
68
+                   (escape (post-title post))))))

+ 4 - 0
static/util.lisp

@@ -6,5 +6,9 @@
6 6
 (defun pretty-list (list)
7 7
   (format nil "~{~A~^, ~}" list))
8 8
 
9
+(defun year-month (date)
10
+  (format nil "~4d-~2,'0d" (local-time:timestamp-year date)
11
+          (local-time:timestamp-month date)))
12
+
9 13
 (defun theme-fn (name)
10 14
   (find-symbol name (theme-package)))

+ 10 - 2
themes/hyde/index.tmpl

@@ -3,12 +3,20 @@
3 3
 {template index}
4 4
 {if $taglinks}
5 5
 <div id="tagsoup">
6
-  <p>This blog covers {$taglinks |noAutoescape}
6
+  <p>This blog covers
7
+    {foreach $taglink in $taglinks}
8
+      <a href="{$taglink.url |noAutoescape}">{$taglink.name}</a>
9
+      {if not isLast($taglink)}, {/if}
10
+    {/foreach}
7 11
 </div>
8 12
 {/if}
9 13
 {if $monthlinks}
10 14
 <div id="monthsoup">
11
-  <p>View posts from {$monthlinks |noAutoescape}
15
+  <p>View posts from
16
+    {foreach $monthlink in $monthlinks}
17
+      <a href="{$monthlink.url |noAutoescape}">{$monthlink.name}</a>
18
+      {if not isLast($monthlink)}, {/if}
19
+    {/foreach}
12 20
 </div>
13 21
 {/if}
14 22
 <h1>{$title}</h1>