a757a586 |
(in-package :cl-user)
|
d5d31282 |
(ql:quickload :clack)
(ql:quickload :ningle )
(ql:quickload :araneus)
(ql:quickload :spinneret)
(ql:quickload :lass)
(defun get-css ()
(lass:compile-and-write
`(*
:padding "0px"
:margin "0px")
|
93a579ec |
|
d5d31282 |
`(body
:box-sizing "border-box"
:font-family sans-serif
|
93a579ec |
:background "#888")
|
d5d31282 |
`(header
:border-bottom "thin solid black"
:width "100%"
:text-align center
:margin-bottom "2em"
:padding "1em")
|
93a579ec |
`(div.articles
|
a757a586 |
:display "block"
|
93a579ec |
:flex-flow "row"
:flex-wrap "wrap-reverse"
:align-items "baseline"
:justify-content "space-around"
:align-content "space-between"
|
a757a586 |
|
93a579ec |
)
|
d5d31282 |
`(article
:padding "1em"
:border "4px double #888"
|
93a579ec |
:vertical-align "middle"
|
a757a586 |
:width "100%"
|
d5d31282 |
:overflow "hidden"
:min-height "4em"
|
93a579ec |
:background "#aaa"
|
a757a586 |
(div.title
:float "left"
:width "50%")
(a.link
:float "left"
:clear "left"
:width "50%")
(div.content
:margin-top "-3em"
:padding-right "5em"
:float "right"
:width "50%")
|
d5d31282 |
)
))
|
d7a60d2b |
(defmethod araneus:view ((name (eql 'root)) (item alimenta:item))
|
93a579ec |
(with-slots ((title alimenta:title) (link alimenta:link) (content alimenta:content)) item
|
cd914c16 |
(spinneret:with-html
(:article
(:div.title title)
|
93a579ec |
(:a.link :href link link)
(:div.content (:raw content))))))
|
cd914c16 |
(defmethod araneus:view ((name (eql 'root)) (feed alimenta:feed))
(with-slots ((title alimenta:title) (link alimenta:link)) feed
(spinneret:with-html
(:header
(:h1.feed-title title)
(:a.feed-link link)))))
|
d5d31282 |
(defmethod araneus:view :around ((name (eql 'root)) (feed alimenta:feed))
(with-slots ((title alimenta:title) (items alimenta::items)) feed
(spinneret:with-html-string
(:html
(:head (:title title))
(:style
:type "text/css"
(get-css))
(:body
(:main
(call-next-method)
|
93a579ec |
(:div.articles
(loop for item in items
do (araneus:view 'root item)))))))))
|
d5d31282 |
(araneus:define-controller root (params)
|
a757a586 |
(declare (optimize (debug 3)))
(let* ((url "http://reddit.com/r/prolog.rss")
|
d5d31282 |
(feed (alimenta.pull-feed::fetch-doc-from-url url)))
|
93a579ec |
(alimenta:to-feed feed :feed-link url)))
|
d5d31282 |
|
bcca8a9c |
(araneus:define-view feed-to-atom (feed)
`(200
(:content-type "application/xml+atom")
(,(concatenate 'string
"<?xml version=\"1.0\"?>"
|
a757a586 |
(plump:serialize (alimenta:generate-xml feed :atom)
|
bcca8a9c |
nil)))))
(araneus:define-view feed-to-rss (feed)
`(200
(:content-type "application/xml+rss")
(,(concatenate 'string
"<?xml version=\"1.0\"?>"
|
a757a586 |
(plump:serialize (alimenta:generate-xml feed :rss)
|
bcca8a9c |
nil)))))
|
a757a586 |
(defparameter *app* (make-instance 'ningle:<app>))
|
d5d31282 |
(araneus:defroutes *app*
|
bcca8a9c |
(("/") (araneus:as-route 'root))
(("/.rss") (araneus::compose-route (root) feed-to-rss))
(("/.atom") (araneus::compose-route (root) feed-to-atom)))
|
d5d31282 |
|
a757a586 |
(defparameter *handler* (clack:clackup *app* :port 9091 ))
|