[Initial admin backend clinton@unknownlamer.org**20081209063550] hunk ./beesknees.asd 19 - :depends-on (:ucw :elephant :md5 + :depends-on (:ucw :elephant :md5 :ucw-forms hunk ./src/packages.lisp 2 - (:use :cl :ucw :ucw-core) + (:use :cl :ucw :ucw-core :ucw-forms :org.unknownlamer.golgonooza.forms) + (:import-from :arnesi :when-bind) hunk ./src/packages.lisp 13 + #:bee-admin-window hunk ./src/packages.lisp 18 + #:bee-admin-pane hunk ./src/web-admin.lisp 3 +(defcomponent bee-admin-pane (tabbed-pane) + ()) hunk ./src/web-admin.lisp 6 +(define-html-form weblog-entry-editor () + ((title (string-field :input-size 80 + :validators (make-validators 'not-empty-validator))) + (body (textarea-field :rows 30 :cols 80))) + ((entry :initarg :entry :accessor edited-entry :initform nil))) + +(defmethod initialize-instance :after ((editor weblog-entry-editor) &rest keys) + (declare (ignore keys)) + (when-bind entry (edited-entry editor) + (with-slots (title body) + editor + (setf (value title) (beesknees.weblog:entry-title entry) + (value body) (beesknees.weblog:entry-body entry))))) + +(defaction process-form ((editor weblog-entry-editor)) + (elephant:ensure-transaction () + (let ((entry (or (edited-entry editor) + (make-instance 'beesknees.weblog:weblog-entry + :posted (get-universal-time) + :author (session-user))))) + (with-slots (title body) + editor + (setf (beesknees.weblog:entry-title entry) (value title) + (beesknees.weblog:entry-body entry) (value body))) + (answer entry)))) + +(defcomponent weblog-admin (composite-container) + () + (:default-initargs + :contents `((new . ,(make-instance 'weblog-entry-editor))))) + +(defcomponent bee-admin-window (bee-window) + () + (:default-initargs + :body (make-instance 'bee-admin-pane + :current-component-key 'weblog + :contents `((weblog . ,(make-instance 'weblog-admin))))))