[Factor weblog-entry-editor and page-editor into markdown-content-editor
clinton@unknownlamer.org**20081216033143] hunk ./src/web-admin.lisp 15
-(define-html-form weblog-entry-editor ()
+(define-html-form image-upload (file-upload-form)
+  ((image (file-upload-field)))
+  ())
+
+(defaction process-form ((form image-upload))
+  (with-slots (image) form
+    (let ((upload-stream
+	   (let ((original-file-name (rfc2388-binary:get-header-attribute
+				      (rfc2388-binary:get-header (value image)
+								 "Content-Disposition")
+				      "filename")))
+	     (open (make-pathname
+		    :directory `(:absolute ,beesknees.site-control::*bee-data-root*
+					   "wwwroot" "img" "uploaded")
+		    :name (pathname-name original-file-name)
+		    :type (pathname-type original-file-name))
+		   :direction :output
+		   :element-type 'unsigned-byte
+		   :if-exists :supersede))))
+      (fad:copy-stream (mime-part-body (value image)) upload-stream)
+      (answer (file-namestring upload-stream)))))
+
+(define-html-form markdown-content-editor ()
+  ((content (textarea-field :rows 30 :cols 80)))
+  ())
+
+(defvar *last-image-upload* nil)
+
+(defmethod render :before ((e markdown-content-editor))
+  (with-slots (content) e
+    (<:div (<ucw:submit :value "Preview" :action (call 'markdown-preview
+						       :text (value content)))
+	   (<ucw:submit
+	    :value "Upload Image"
+	    :action (setf *last-image-upload* (call 'image-upload)))
+	   (<:a :href "http://daringfireball.net/projects/markdown/syntax"
+		:target "_new"
+		(<:as-html "Markdown Syntax Reference"))
+	   (when *last-image-upload*
+	     (<:p (<:ah "To display the image you uploaded insert ")
+		  (<:code (<:format "{image ~S}" *last-image-upload*))
+		  (<:ah " into the document where you want to display it."))
+	     (setf *last-image-upload* nil)))))
+
+
+(define-html-form weblog-entry-editor (markdown-content-editor)
hunk ./src/web-admin.lisp 62
-			:validators (make-validators 'not-empty-validator)))
-   (body (textarea-field :rows 30 :cols 80)))
-  ((entry :initarg :entry :accessor edited-entry :initform nil)))
+			:validators (make-validators 'not-empty-validator))))
+  ((entry :initarg :entry :accessor edited-entry :initform nil))
+  (:default-initargs :field-order '(title content)))
hunk ./src/web-admin.lisp 69
-    (with-slots (title body)
+    (with-slots (title content)
hunk ./src/web-admin.lisp 71
-      (setf (value title) (beesknees.weblog:entry-title entry)
-	    (value body)  (beesknees.weblog:entry-body entry)))))
+      (setf (value title)   (beesknees.weblog:entry-title entry)
+	    (value content) (beesknees.weblog:entry-body entry)))))
hunk ./src/web-admin.lisp 80
-      (with-slots (title body)
+      (with-slots (title content)
hunk ./src/web-admin.lisp 83
-	      (beesknees.weblog:entry-body entry)  (value body)))
+	      (beesknees.weblog:entry-body entry)  (value content)))
hunk ./src/web-admin.lisp 86
-(defmethod render :before ((e weblog-entry-editor))
-  (with-slots (body) e
-    (<:div (<ucw:submit :value "Preview" :action (call 'markdown-preview
-						       :text (value body)))
-	   (<:a :href "http://daringfireball.net/projects/markdown/syntax"
-		:target "_new"
-		(<:as-html "Markdown Syntax Reference")))))
-
hunk ./src/web-admin.lisp 144
-(define-html-form image-upload (file-upload-form)
-  ((image (file-upload-field)))
-  ())
-
-(defaction process-form ((form image-upload))
-  (with-slots (image) form
-    (let ((upload-stream
-	   (let ((original-file-name (rfc2388-binary:get-header-attribute
-				      (rfc2388-binary:get-header (value image)
-								 "Content-Disposition")
-				      "filename")))
-	     (open (make-pathname
-		    :directory `(:absolute ,beesknees.site-control::*bee-data-root*
-					   "wwwroot" "img" "uploaded")
-		    :name (pathname-name original-file-name)
-		    :type (pathname-type original-file-name))
-		   :direction :output
-		   :element-type 'unsigned-byte
-		   :if-exists :supersede))))
-      (fad:copy-stream (mime-part-body (value image)) upload-stream)
-      (answer (file-namestring upload-stream)))))
-
-(define-html-form page-editor ()
+(define-html-form page-editor (markdown-content-editor)
hunk ./src/web-admin.lisp 146
-		       :validators (make-validators 'not-empty-validator)))
-   (content (textarea-field :rows 30 :cols 80 :dom-id "page-edit-area")))
-  ((page :initarg :page :accessor edited-page :initform nil)))
+		       :validators (make-validators 'not-empty-validator))))
+  ((page :initarg :page :accessor edited-page :initform nil))
+  (:default-initargs :field-order '(title content)))
hunk ./src/web-admin.lisp 168
-(defvar *last-image-upload* nil)
-
-(defmethod render :before ((e page-editor))
-  (with-slots (content) e
-    (<:div (<ucw:submit :value "Preview" :action (call 'markdown-preview
-						       :text (value content)))
-	   (<ucw:submit
-	    :value "Upload Image"
-	    :action (setf *last-image-upload* (call 'image-upload)))
-	   (<:a :href "http://daringfireball.net/projects/markdown/syntax"
-		:target "_new"
-		(<:as-html "Markdown Syntax Reference"))
-	   (when *last-image-upload*
-	     (<:p (<:ah "To display the image you uploaded insert ")
-		  (<:code (<:format "{image ~S}" *last-image-upload*))
-		  (<:ah " into the document where you want to display it."))
-	     (setf *last-image-upload* nil)))))
-