소스 검색

Add twitter meta-data to posts

  This depends on a pending change to add-injection
Javier Olaechea 10 년 전
부모
커밋
47a17508e8
2개의 변경된 파일24개의 추가작업 그리고 1개의 파일을 삭제
  1. 22 0
      plugins/twitter-summary-card.lisp
  2. 2 1
      src/packages.lisp

+ 22 - 0
plugins/twitter-summary-card.lisp

@@ -0,0 +1,22 @@
1
+(defpackage :coleslaw-twitter-summary-card
2
+  (:use :cl)
3
+  (:export #:enable))
4
+
5
+(in-package :coleslaw-twitter-summary-card)
6
+
7
+(defun summary-card (post twitter-handle)
8
+  "TODO: Figure if and how to include twitter:url meta property."
9
+  (format nil "<meta property=\"twitter:card\" content=\"summary\" />
10
+~@[<meta property=\"twitter:author\" content=~A />~]
11
+<meta property=\"twitter:title\" content=~A />
12
+<meta property=\"twitter:description\" content=~A />"
13
+          twitter-handle
14
+          (title-of post)
15
+          (content-text post)))
16
+
17
+(defun enable (&key twitter-handle)
18
+  (add-injection
19
+   (lambda (x)
20
+     (when (typep x 'post)
21
+       (summary-card x twitter-handle)))
22
+                 :head))

+ 2 - 1
src/packages.lisp

@@ -39,4 +39,5 @@
39 39
            #:purge-all
40 40
            #:add-document
41 41
            #:delete-document
42
-           #:write-document))
42
+           #:write-document
43
+           #:content-text))