[Initial threaded commenting frontend clinton@unknownlamer.org**20090327202017 Ignore-this: 24612622331c4099ca88c1e81bcc4a0c * Minor source movement (web-frontend.lisp was too large to navigate easily anymore) * Very very primitive frontend for commenting ] hunk ./beesknees.asd 18 - (:file "web-frontend" :depends-on ("packages" "web-common")) + (:file "frontend-weblog" :depends-on ("packages" "web-common")) + (:file "web-frontend" :depends-on ("packages" "web-common" + "frontend-weblog")) addfile ./src/frontend-weblog.lisp hunk ./src/frontend-weblog.lisp 1 +(in-package :beesknees.web) + +(defcomponent bee-blog (golgonooza:query-ranged-view-mixin + golgonooza-db:elephant-query-view-mixin + golgonooza:query-view + bee-widget) + () + (:default-initargs + :index-class 'beesknees.weblog:weblog-entry + :index-slot 'beesknees.weblog::posted + :reverse t)) + +(defmethod golgonooza:render-query-view-result ((entry weblog-entry) + (list bee-blog)) + (<:div :class "bee-blog-entry" + (<:h1 :class "title" (<:as-html (entry-title entry))) + (<:h2 :class "author-date" + (<:format "By ~A on ~A" + (beesknees.auth:username (entry-author entry)) + (metatilities:date-and-time-string + (entry-posted entry)))) + (<:p :class "body " + (cl-markdown:markdown (entry-body entry) + :stream yaclml:*yaclml-stream* + :format :html)))) +(defcomponent bee-paged-blog (bee-stylable-page + golgonooza:query-paged-view-mixin bee-blog) + ()) + +(defvar *archive-page* nil) + +;; Store the page offset as if it the blog were sorted normally +;; instead of reversed so that bookmarks will always point to (more or +;; less) the same page even if the archive ends up with more items +(defmethod update-url ((c bee-paged-blog) uri) + (when *archive-page* + (append-path-to-uri uri (format nil "pages/blog/~A" + (- (golgonooza:page-count c) + *archive-page*)))) + uri) + +(define-html-form comment-entry () + ((title (string-field :input-size 40 + :validators (make-validators 'not-empty-validator))) + (author (string-field :input-size 40 + :validators (make-validators 'not-empty-validator))) + (body (textarea-field :rows 10 :cols 40))) + ((comment-parent :initarg :comment-parent :accessor comment-parent))) + +(defaction process-form ((ce comment-entry)) + (let ((res (with-slots (title author body comment-parent) + ce + (make-instance 'beesknees.weblog::weblog-comment + :parent comment-parent + :title (value title) + :author (value author) + :body (value body) + :posted (get-universal-time))))) + (answer res))) + +(defcomponent weblog-entry-view (html-block-element-mixin) + ((entry :initarg :entry :accessor weblog-entry))) + +(defmethod render ((e weblog-entry-view)) + (labels ((render-comment (comment) + (<:li + (<:div :class "comment-header" + (<:h1 (<:ah (beesknees.weblog::comment-title comment))) + (<:h2 (<:format "By ~A on ~A" + (beesknees.weblog::comment-author comment) + (metatilities:date-and-time-string + (beesknees.weblog::comment-posted comment))))) + (<:p :class "comment-body" + (<:ah (beesknees.weblog::comment-body comment))) + (