[Clean up weblog entry list rendering (act I) clinton@unknownlamer.org**20090429045352 Ignore-this: a57bd23423d97218916655a2607afd13 * Rendering of individual entries in a list is handled by a tal template * Use custom action classes instead of binding specials around links to generate bookmarkable urls ] hunk ./src/frontend-weblog.lisp 15 - (<: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 (golgonooza:query-paged-view-mixin bee-blog) + (render-template *context* "bee-blog-list-entry.tal" + (yaclml:make-standard-tal-environment + `((entry . ,entry)) entry))) + +(defcomponent bee-paged-blog (golgonooza:query-paged-view-mixin + bee-blog) hunk ./src/frontend-weblog.lisp 23 -(defvar *archive-page* nil) -(defvar *weblog-entry-page* nil) +(defclass weblog-archive-page-link (standard-action) + ((page :initarg :page :accessor page :initform nil)) + (:metaclass c2mop:funcallable-standard-class)) + +(defclass weblog-entry-page-link (standard-action) + ((entry :initarg :entry :accessor entry :initform nil)) + (:metaclass c2mop:funcallable-standard-class)) + +(defmethod compute-url ((link weblog-archive-page-link) (c bee-paged-blog)) + ;; 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 + (let ((url (call-next-method))) + (when-bind archive-page (page link) + (append-path-to-uri url (format nil "pages/blog/~A" + (- (golgonooza:page-count c) + archive-page)))) + url)) hunk ./src/frontend-weblog.lisp 42 -;; 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*)))) - (when *weblog-entry-page* - (append-path-to-uri uri (format nil "pages/blog/entry/~A" - *weblog-entry-page*))) - uri) +(defmethod compute-url ((link weblog-entry-page-link) (c bee-blog)) + (let ((url (call-next-method))) + (when-bind entry (entry link) + (append-path-to-uri url (format nil "pages/blog/entry/~D" + (entry-posted entry)))) + url)) hunk ./src/frontend-weblog.lisp 138 +(defun weblog-entry-link (entry) + (make-action (lambda () + (with-call/cc + (call 'weblog-entry-view :entry entry))) + :class 'weblog-entry-page-link + :entry entry)) hunk ./src/frontend-weblog.lisp 145 -(defmethod golgonooza:render-query-view-result :after ((entry weblog-entry) - (list bee-blog)) - (<:div :class "bee-blog-controls" - (let ((*weblog-entry-page* (entry-posted entry))) - ( +

title

+

By author on date

+

+ (cl-markdown:markdown (entry-body $entry) + :stream yaclml:*yaclml-stream* + :format :html) + +

+
+ view full comment +
+