git.fiddlerwoaroof.com
linkblog-to-rss.lisp
27854db8
 ;;;; linkblog-to-rss-puller.lisp
aede7e69
 
27854db8
 (in-package #:linkblog-to-rss-puller)
aede7e69
 
27854db8
 ;;; "linkblog-to-rss-puller" goes here. Hacks and glory await!
aede7e69
 
 
27854db8
 (defconstant +feed-url+ "http://linkblog-to-rss.com/feed/atom")
aede7e69
 
 (defparameter *feed-data* (alimenta.pull-feed:pull-feed +feed-url+ :type :atom))
 
 (defparameter *feed-items* (alimenta:items *feed-data*))
 
 (defparameter *items-content* (mapcar #'alimenta:content *feed-items*))
 
 (defparameter *item-links*
   (loop for content in *items-content*
         for item in *feed-items*
         nconcing (coerce
                    (remove-if
                      (fw.lu:destructuring-lambda ((url . text))
                        (let ((text (string-trim '(#\Space #\Newline) (or (car text) ""))))
                          (or
                            (string-equal url "#" :end1 1)
                            (string-equal url "/" :end1 1)
                            (string-equal text "")
27854db8
                            (string-equal url  #1="http://linkblog-to-rss.com" :end1 (length #1#)))))
aede7e69
                      (lquery:$ (initialize content) "a" (combine (attr "href") (text))
                                                                  (map-apply 
                                                                    (lambda (url text)
                                                                      (list url text
                                                                            (slot-value item 'alimenta:date))))))
                    'list)))
 
 (defparameter *new-feed* (make-instance 'alimenta.atom::atom-feed
                                         :title "BP Links"
                                         :link "http://example.com/nowhere"
                                         :authors (list "Big Pulpit")
                                         :description "A Description"
                                         :items nil))
 
 (defmethod slot-missing (class (instance (eql *new-feed*)) slot-name operation &optional new-value)
   (format t "~&SLOT MISSING: ~A ~A ~A ~A ~A" class instance slot-name operation new-value)
        )
 
 (defparameter *id* 0)
 (loop for (url text date) in *item-links*
       do (alimenta::add-item-to-feed *new-feed*
                                      :next-id (lambda (tmp) (incf *id*))
                                      :title text 
                                      :link url
                                      :date date 
                                      :content "")
 
       )