Export title-of, author-of, and find-content-by-path. Cleanup twitter plugin.
This commit is contained in:
parent
3264848cde
commit
7326e31479
5 changed files with 25 additions and 17 deletions
|
@ -15,7 +15,7 @@
|
|||
(in-package :coleslaw-static-pages)
|
||||
|
||||
(defclass page (content)
|
||||
((title :initarg :title :reader page-title)
|
||||
((title :initarg :title :reader title-of)
|
||||
(url :initarg :url :reader page-url)))
|
||||
|
||||
(defmethod initialize-instance :after ((object page) &key)
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
|
||||
(defpackage :coleslaw-twitter
|
||||
(:use :cl)
|
||||
(:import-from :coleslaw
|
||||
:*config*
|
||||
:deploy
|
||||
:get-updated-files
|
||||
:page-url
|
||||
:plugin-conf-error)
|
||||
(:import-from :coleslaw #:*config*
|
||||
#:deploy
|
||||
#:get-updated-files
|
||||
#:find-content-by-path
|
||||
#:title-of
|
||||
#:author-of
|
||||
#:page-url
|
||||
#:plugin-conf-error)
|
||||
(:export #:enable))
|
||||
|
||||
(in-package :coleslaw-twitter)
|
||||
|
@ -20,8 +22,8 @@
|
|||
coleslaw:post and returns the tweet content.")
|
||||
|
||||
(defvar *tweet-format-dsl-mapping*
|
||||
'((:title . coleslaw::post-title)
|
||||
(:author . coleslaw::post-author)))
|
||||
'((:title . title-of)
|
||||
(:author . author-of)))
|
||||
|
||||
(define-condition malformed-tweet-format (error)
|
||||
((item :initarg :item :reader item))
|
||||
|
@ -87,7 +89,7 @@ coleslaw:post and returns the tweet content.")
|
|||
|
||||
(defun tweet-new-post (file)
|
||||
"Retrieve content matching FILE from in memory DB and publish it."
|
||||
(let ((post (coleslaw::find-content-by-path file)))
|
||||
(let ((post (find-content-by-path file)))
|
||||
(chirp:statuses/update (%format-post 0 post))))
|
||||
|
||||
(defun %format-post (offset post)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
(defclass index ()
|
||||
((slug :initarg :slug :reader index-slug)
|
||||
(title :initarg :title :reader index-title)
|
||||
(title :initarg :title :reader title-of)
|
||||
(content :initarg :content :reader index-content)))
|
||||
|
||||
(defmethod render ((object index) &key prev next)
|
||||
|
|
|
@ -10,14 +10,20 @@
|
|||
(:export #:main
|
||||
#:preview
|
||||
#:*config*
|
||||
;; Core Classes
|
||||
#:content
|
||||
#:post
|
||||
#:index
|
||||
;; Content Helpers
|
||||
#:title-of
|
||||
#:author-of
|
||||
#:find-content-by-path
|
||||
;; Plugin API + Theming
|
||||
#:plugin-conf-error
|
||||
#:render-text
|
||||
#:add-injection
|
||||
#:theme-fn
|
||||
#:get-updated-files
|
||||
#:plugin-conf-error
|
||||
#:theme-fn
|
||||
;; The Document Protocol
|
||||
#:add-document
|
||||
#:find-all
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
(in-package :coleslaw)
|
||||
|
||||
(defclass post (content)
|
||||
((title :initform nil :initarg :title :accessor post-title)
|
||||
(author :initform nil :initarg :author :accessor post-author)
|
||||
((title :initform nil :initarg :title :accessor title-of)
|
||||
(author :initform nil :initarg :author :accessor author-of)
|
||||
(format :initform nil :initarg :format :accessor post-format)))
|
||||
|
||||
(defmethod initialize-instance :after ((object post) &key)
|
||||
(with-accessors ((title post-title)
|
||||
(author post-author)
|
||||
(with-accessors ((title title-of)
|
||||
(author author-of)
|
||||
(format post-format)
|
||||
(text content-text)) object
|
||||
(setf (content-slug object) (slugify title)
|
||||
|
|
Loading…
Add table
Reference in a new issue