git.fiddlerwoaroof.com
feed-index-utils.lisp
84e2df5d
 (in-package :alimenta.feed-archive)
 
 (defclass feed-index ()
   ((%pull-time :initarg :pull-time :reader pull-time)
    ;; Why this slot? Won't the references duplicate this?
    (%feed-references :initarg :references :reader references)))
 
 (defclass feed-reference ()
   ((%url :initarg :url :reader url)
    (%title :initarg :title :reader title :initform nil)
    (%path :initarg :path :reader path :initform nil)))
 
 (defun make-feed-index (pull-time references)
   (make-instance 'feed-index
e3a39cd6
                  :pull-time pull-time
                  :references (copy-seq references)))
84e2df5d
 
 (defun make-feed-reference (url &rest feed-data &key title path)
   (declare (ignore title path))
   (apply #'make-instance 'feed-reference
e3a39cd6
          :url url
          feed-data))
84e2df5d
 
1cc6bbe6
 (defun directory-of (pathname)
   (make-pathname :directory (pathname-directory pathname)))
 
84e2df5d
 (defmethod yason:encode-slots progn ((object feed-reference))
   (let ((title (title object))
e3a39cd6
         (path (path object)))
6a6d9288
     (format *error-output* "~&title: ~s path: ~s~%" title (directory-of path))
84e2df5d
     (yason:encode-object-element "url" (url object))
     (when title
       (yason:encode-object-element "title" title))
     (when path
1cc6bbe6
       (yason:encode-object-element "path" (directory-of path)))))
84e2df5d
 
 (defmethod yason:encode-slots progn ((object feed-index))
   (with-accessors ((pull-time pull-time) (references references)) object
     (yason:encode-object-element "pull-time" (local-time:format-timestring nil pull-time))
     (yason:with-object-element ("feeds")
       (yason:with-array ()
e3a39cd6
         (mapcar 'yason:encode-object references)))))