(in-package :kira) (defclass blog-entry (post groups-mixin) ((specified-time :accessor specified-time :initarg :specified-time :initform nil) (music :accessor music :initarg :music :initform nil) (categories :accessor categories :initarg :categories :initform '()))) (defun posted-time (post) (or (when (typep post 'blog-entry) (specified-time post)) (creation-time post))) (defcollection blog ((entity blog-mixin)) (cached-collection entity 'blog :descending t :start *now*)) (defhandler (:blogs) (:title "Recent Blog Entries") (:collection (blog *root*))) (define-feed (:blogs) (:collection (blog *root*))) (define-feed ((person person)) (:collection (blog person))) (defmethod render-in-style ((post blog-entry) (style (eql 'header))) (if (eq *section* (creator post t)) (html (:b (render-title post)) " / " (render-date (posted-time post))) (call-next-method))) (defmethod lines ((post blog-entry)) (collecting (whereas ((uri (external-uri post)) (host (uri-host uri)) (guid (guid post))) (collect (cons "Syndicated" (html-output "from " ((:a :title guid) uri host))))) (whereas ((groups (groups post))) (collect (cons "Groups" (html-output (:links groups))))) (whereas ((categories (categories post))) (collect (cons "Categories" (html-output (:links categories))))) (whereas ((music (music post))) (collect (cons "Music" (html-output (render-inline-markup music))))))) (defmethod render-editor :after ((post blog-entry)) (html (:field "Music" (text-field 'music post)) (:whereas ((creator (creator post))) (:whereas ((groups (groups creator))) (:fieldset "Groups" (collection-field 'groups post groups :multiple t))) (:whereas ((categories (categories creator))) (:fieldset "Categories" (collection-field 'categories post categories :multiple t)))))) (defmethod update-instance-from-query progn ((post blog-entry)) (setf-accessors-from-query post music (groups collection) (categories collection))) (defmethod watched-slots append ((post blog-entry)) '(specified-time groups categories)) (define-update-methods ((post blog-entry)) (update-instances (groups post) post) (update-instances (categories post) post)) (define-update-methods instance ((entity blog-mixin) (post blog-entry)) (unless (and (eq entity *root*) (not (creator post))) (update-map (blog entity) (posted-time post) post :unique nil))) (defclass category (node blog-mixin breadcrumb-mixin) ()) (defhandler ((category category)) (:collection (blog category))) (defmethod render-editor ((category category)) (html (:field "Title" (text-field 'title category)))) (defmethod watched-slots append ((category category)) '(title)) (define-update-methods ((category category)) (update-map (categories (creator category)) (title category) category :unique nil))