git.fiddlerwoaroof.com
Raw Blame History
(in-package :fwoar.rss-reader)

(defclass rss-reader-route ()
  ())

(defmethod araneus:view :around ((route rss-reader-route) model)
  "basic html and javascript for our app, as well as an invocation of
the hook that pulls in CSS"

  (ecase model
    (:full
     (spinneret:with-html-string
       (:doctype)
       (:html
        (:head
         (:script :src "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"
                  :defer "defer")
         (:script :src
                  "https://cdnjs.cloudflare.com/ajax/libs/intercooler-js/1.2.2/intercooler.min.js"
                  :defer "defer")
         (:meta :name "intercoolerjs:use-data-prefix"
                :content "true"/)
         (:style
          (apply 'lass:compile-and-write
                 (araneus:styles route))))
        (:body
         (call-next-method)))))
    (:partial
     (spinneret:with-html-string
       (call-next-method)))))

(defmethod araneus:styles append ((route rss-reader-route))
  "CSS Reset"

  '((*
     :margin 0
     :padding 0
     :font-family "\"Lato\", sans"
     :box-sizing border-box)              
    ((:or pre code)
     :font-family "\"Source Code Pro\", monospace")
    (body
     :font-size 12pt)
    ((:or h1 h2 h3 h4 h5 h6)
     :font-size 1.6rem)
    ((:or ul ol)
     :padding-left 2rem)))

(defclass homepage (rss-reader-route fwoar.default-layout:default-layout)
  ())

(defmethod fwoar.default-layout:border-color ((layout rss-reader-route))
  "#BDE0F3")

(defmethod araneus:controller ((route homepage) params &key)
  (format t "~&~s~%" params)
  (if (equal (serapeum:assocdr "ic-request" params
                               :test 'equal)
             "true")
      :partial
      :full))

(defmethod araneus:view ((route homepage) model)
  (let ((content "home content"))
    (ecase model
      (:full (fwoar.rss-reader.ui:homepage content))
      (:partial (spinneret:with-html
                  (:raw (with-output-to-string (s)
                          (cl-markdown:markdown content
                                                :stream s))))))))

(araneus:define-controller other (_)
  (values))
(araneus:define-view other (_)
  "<h2>???</h2>")