Changeset 2651
- Timestamp:
- 03/04/08 12:43:58 (10 months ago)
- Files:
-
- trunk/bknr/modules/text/article-handlers.lisp (modified) (5 diffs)
- trunk/bknr/modules/text/article-tags.lisp (modified) (7 diffs)
- trunk/bknr/modules/text/article.lisp (modified) (1 diff)
- trunk/bknr/modules/text/blog-handlers.lisp (modified) (1 diff)
- trunk/bknr/modules/text/blog.lisp (modified) (2 diffs)
- trunk/bknr/modules/text/package.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bknr/modules/text/article-handlers.lisp
r2424 r2651 25 25 26 26 (defclass edit-article-handler (edit-object-handler) 27 ()) 28 29 (defmethod object-handler-get-object ((handler edit-article-handler)) 30 (find-store-object (parse-url) :class 'article)) 27 () 28 (:default-initargs :object-class 'article)) 31 29 32 30 (defmethod handle-object-form ((handler edit-article-handler) … … 36 34 37 35 (defmethod handle-object-form ((handler edit-article-handler) 38 (action (eql :save)) article) 36 (action (eql :save)) 37 (article article)) 39 38 (with-query-params (subject text) 40 (if article 41 (progn (change-slot-values article 'subject subject 'text text) 42 (index-article article)) 43 (setf article (make-object 'article 44 :author (bknr-session-user) 45 :subject subject 46 :text text))) 47 (redirect (edit-object-url article)))) 39 (with-transaction (:update-article) 40 (setf (article-text article) text 41 (article-subject article) subject)) 42 (index-article article)) 43 (redirect (edit-object-url article))) 44 45 (defmethod handle-object-form ((handler edit-article-handler) 46 (action (eql :save)) 47 (article (eql nil))) 48 (with-query-params (subject text) 49 (redirect (edit-object-url (make-object 'article 50 :author (bknr-session-user) 51 :subject subject 52 :text text))))) 48 53 49 54 ;;; snippets … … 52 57 53 58 (defclass edit-snippet-handler (edit-object-handler) 54 ()) 55 56 (defmethod object-handler-get-object ((handler edit-snippet-handler)) 57 (find-store-object (parse-url) :class 'snippet)) 59 () 60 (:default-initargs :object-class 'snippet)) 58 61 59 62 (defmethod handle-object-form ((handler edit-snippet-handler) … … 67 70 68 71 (defmethod handle-object-form ((handler edit-snippet-handler) 69 (action (eql :delete)) snippet) 70 (when snippet 71 (delete-object snippet)) 72 action (snippet (eql nil))) 72 73 (redirect "/edit-snippet")) 73 74 74 75 (defmethod handle-object-form ((handler edit-snippet-handler) 75 (action (eql :remove-keywords)) snippet) 76 (if snippet 77 (let ((keywords (keywords-from-query-param-list (query-param-list "keyword")))) 78 (store-object-remove-keywords snippet 'keywords keywords) 79 (redirect (edit-object-url snippet))) 80 (redirect "/edit-snippet"))) 76 (action (eql :delete)) (snippet snippet)) 77 (delete-object snippet) 78 (call-next-method)) 81 79 82 80 (defmethod handle-object-form ((handler edit-snippet-handler) 83 (action (eql :add-keywords)) snippet) 84 (if snippet 85 (let ((keywords (keywords-from-query-param-list (query-param-list "keyword")))) 86 (store-object-add-keywords snippet 'keywords keywords) 87 (redirect (edit-object-url snippet))) 88 (redirect "/edit-snippet"))) 81 (action (eql :remove-keywords)) (snippet snippet)) 82 (let ((keywords (keywords-from-query-param-list (query-param-list "keyword")))) 83 (store-object-remove-keywords snippet 'keywords keywords) 84 (redirect (edit-object-url snippet)))) 89 85 90 86 (defmethod handle-object-form ((handler edit-snippet-handler) 91 (action (eql :save)) snippet) 92 (if snippet 93 (with-query-params (subject text layout) 94 (unless subject (setf subject "")) 95 (let ((expires (parse-date-field "expiration"))) 96 (change-slot-values snippet 'subject subject 'text text 97 'expires expires 'layout (make-keyword-from-string layout)) 98 (index-article snippet) 99 (redirect (edit-object-url snippet)))) 100 (redirect "/edit-snippet"))) 87 (action (eql :add-keywords)) (snippet snippet)) 88 (let ((keywords (keywords-from-query-param-list (query-param-list "keyword")))) 89 (store-object-add-keywords snippet 'keywords keywords) 90 (redirect (edit-object-url snippet)))) 91 92 (defmethod handle-object-form ((handler edit-snippet-handler) 93 (action (eql :save)) (snippet snippet)) 94 (with-query-params (subject text layout) 95 (unless subject (setf subject "")) 96 (let ((expires (parse-date-field "expiration"))) 97 (with-transaction (:update-snippet) 98 (setf (article-subject snippet) subject 99 (article-text snippet) text 100 (snippet-expires snippet) expires 101 (snippet-layout snippet) (make-keyword-from-string layout))) 102 (index-article snippet) 103 (redirect (edit-object-url snippet))))) 101 104 102 105 (defmethod handle-object-form ((handler edit-snippet-handler) … … 112 115 :layout (make-keyword-from-string layout) 113 116 :expires expires))) 114 (if snippet 115 (redirect (edit-object-url snippet)) 116 (redirect "/edit-snippet")))))) 117 (redirect (edit-object-url snippet)))))) trunk/bknr/modules/text/article-tags.lisp
r2430 r2651 5 5 (defun article-blog-headline (article) 6 6 (html ((:div :class "headline") 7 (:princ-safe (or (article-subject article) "")) 7 ((:span :class "subject") 8 (:princ-safe (or (article-subject article) ""))) 8 9 " " 9 10 ((:span :class "date") … … 14 15 (html ((:span :class "author") (:princ-safe (user-login (article-author article))))))))) 15 16 16 (define-bknr-tag article (&key id (class " textbox_3"))17 (define-bknr-tag article (&key id (class "article")) 17 18 (let ((article (when id (find-store-object id :class 'article)))) 18 19 (html ((:div :class class) 19 20 (unless (string-equal (article-subject article) "") 20 ;; XXX der hier folgende dispatch auf den css-klassennamen ist mehr als unhygienisch. 21 ;; article-blog-headline gibt datum/uhrzeit/autor mit aus. 22 (if (find class '("textbox_shop" "textbox_2") :test #'string-equal) 23 (html ((:div :class "inhead") 24 (:princ-safe (article-subject article)) 25 ": ")) 26 (article-blog-headline article))) 21 (article-blog-headline article)) 27 22 (when (article-text article) 28 (html (:princ (article-html-text article)))))) 29 (unless (user-has-flag *user* :locked) 30 (user-has-read-article article *user*)))) 23 (html 24 ((:div :class "text") 25 (:princ (article-text article))))))) 26 (unless (user-has-flag (bknr-session-user) :locked) 27 (user-has-read-article article (bknr-session-user))))) 31 28 32 29 (define-bknr-tag wiki-article (&key id (edit-url "/edit-wiki")) … … 58 55 (define-bknr-tag article-form (&key id) 59 56 (let ((article (when id (find-store-object id :class 'article)))) 60 (html ((:form :method "post") 61 (when article 62 (html ((:input :type "hidden" :name "article-id" :value (store-object-id article))))) 63 (:table (:tr (:td "subject") 64 (:td ((:input :type "text" :size "50" :name "subject" 65 :value (if article 66 (article-subject article) 67 ""))))) 68 (:tr (:td "message") 69 (:td ((:textarea :name "text" :rows "15" :cols "60") 70 (if article 71 (html (:princ (article-text article))) 72 (html " "))))) 73 (:tr (:td (submit-button "save" "save")))))))) 57 (html 58 ((:script :language "JavaScript") "initEditor();") 59 ((:form :method "post") 60 (when article 61 (html ((:input :type "hidden" :name "article-id" :value (store-object-id article))))) 62 (:table (:tr (:td "subject") 63 (:td ((:input :type "text" :size "50" :name "subject" 64 :value (if article 65 (article-subject article) 66 ""))))) 67 (:tr (:td "message") 68 (:td ((:textarea :name "text" :rows "15" :cols "60") 69 (if article 70 (html (:princ (article-text article))) 71 (html " "))))) 72 (:tr (:td (submit-button "save" "save")))))))) 74 73 75 74 (define-bknr-tag wiki-article-form (&key id keyword) … … 162 161 (progn (unless suppress-title 163 162 (html (:h3 (:princ-safe (blog-name blog))) 164 (html (when (admin-p *user*)163 (html (when (admin-p (bknr-session-user)) 165 164 (html-edit-link blog)) 166 ((:a :href (format nil "/ blog-rss/~a" name))167 " rss "))))165 ((:a :href (format nil "/rss/~a" name)) 166 (:princ " rss "))))) 168 167 (loop for article in (sort (copy-list (blog-articles blog)) 169 168 #'> :key #'article-time) 170 do (if (and (not (equal "anonymous" (user-login *user*)))171 (article-read article *user*))169 do (if (and (not (equal "anonymous" (user-login (bknr-session-user)))) 170 (article-read article (bknr-session-user))) 172 171 (html ((:div :class "textbox_3") 173 172 ((:a :href (object-url article)) … … 179 178 (let ((url (format nil "/blog/~A" (blog-name blog)))) 180 179 (html (:h3 (:princ-safe (blog-name blog))) 181 (when (admin-p *user*)180 (when (admin-p (bknr-session-user)) 182 181 (html-edit-link blog)) 183 ((:a :href (format nil "/ blog-rss/~A" (blog-name blog)))184 "rss") " "182 ((:a :href (format nil "/rss/~A" (blog-name blog))) 183 "rss") 185 184 ((:a :href (format nil "/search-blog/~A" (blog-name blog))) 186 185 "search") … … 194 193 :show-seconds nil))) 195 194 (dolist (article (sort (cdr grouped-article) #'> :key #'article-time)) 196 (if (and (not (equal "anonymous" (user-login *user*)))197 (article-read article *user*))195 (if (and (not (equal "anonymous" (user-login (bknr-session-user)))) 196 (article-read article (bknr-session-user))) 198 197 (html ((:div :class "textbox_3") 199 198 ((:a :href (object-url article)) … … 212 211 (let* ((page (parse-integer (or (query-param "page") "0"))) 213 212 (num-pages (ceiling (/ (length (session-value :blog-search-results)) 10))) 214 (results (subseq (session-value :blog-search-results)215 (* page 10)216 (* (1+ page) 10))))213 (results (subseq* (session-value :blog-search-results) 214 (* page 10) 215 (* (1+ page) 10)))) 217 216 (when results 218 217 (html (:h3 "Results for \"" (:princ-safe (session-value :blog-search)) "\":")) trunk/bknr/modules/text/article.lisp
r2417 r2651 5 5 (time :update :initform (get-universal-time)) 6 6 (subject :update :initform "") 7 (text : read:initform "")7 (text :update :initform "") 8 8 (read-by :update :initform nil) 9 9 (search-vector :update :initform nil)) trunk/bknr/modules/text/blog-handlers.lisp
r2424 r2651 123 123 (handle-form handler t))) 124 124 125 (define-bknr-webserver-module blog 126 ("/blog" blog-handler) 127 ("/edit-blog" edit-blog-handler) 128 ("/edit-article" edit-article-handler) 129 ("/search-blog" search-blog-handler)) trunk/bknr/modules/text/blog.lisp
r1542 r2651 1 1 (in-package :bknr.text) 2 2 3 (define-persistent-class blog-article (article )3 (define-persistent-class blog-article (article rss-item) 4 4 ((keywords :read :initform nil 5 :index-type hash-list-index))) 5 :index-type hash-list-index) 6 (blog :update :initform nil))) 6 7 7 (define-persistent-class blog () 8 ((name :read 9 :index-type string-unique-index 10 :index-reader blog-with-name 11 :index-values all-blogs) 12 8 (defmethod rss-item-channel ((article blog-article)) 9 (blog-article-blog article)) 10 11 (define-persistent-class blog (rss-channel) 12 ((bknr.rss::name :read 13 :index-type string-unique-index 14 :index-reader blog-with-name 15 :index-values all-blogs) 13 16 (articles :update :initform nil) 14 17 (owners :update :initform nil))) 18 19 (defmethod rss-channel-items ((blog blog)) 20 (blog-articles blog)) 15 21 16 22 (defmethod print-object ((object blog) stream) … … 27 33 (pushnew (blog-owners blog) owner)) 28 34 29 (deftransaction blog-add-article (blog blog-article) 30 (setf (slot-value blog 'articles) 31 (push blog-article (slot-value blog 'articles)))) 35 (deftransaction blog-add-article (blog article) 36 (setf (blog-article-blog article) blog) 37 (push article (blog-articles blog))) 38 39 (defmethod rss-item-title ((article article)) 40 (article-subject article)) 41 42 (defmethod rss-item-description ((article article)) 43 (article-text article)) 44 45 (defmethod rss-item-pub-date ((article article)) 46 (article-time article)) trunk/bknr/modules/text/package.lisp
r2417 r2651 15 15 :bknr.datastore 16 16 :bknr.impex 17 :xhtml-generator) 17 :xhtml-generator 18 :alexandria) 19 (:shadowing-import-from :bknr.indices array-index) 18 20 (:shadowing-import-from :cl-interpol quote-meta-chars) 19 21 (:export
