diff of 83d2a79e70e2056d4d417f7b6213a498bb0455f3

83d2a79e70e2056d4d417f7b6213a498bb0455f3
diff --git a/resources/js/newui.js b/resources/js/newui.js
index 13ec8d6..5953d9c 100644
--- a/resources/js/newui.js
+++ b/resources/js/newui.js
@@ -43,11 +43,15 @@ window.addEventListener('DOMContentLoaded', _ => {
     });
 });
 
-function send(event) {
+function send(event, param) {
     console.log(`Calling ${event}`);
     if(!session_id) { alert('Session id is damaged'); return; }
     if(!checkOpen()) { handleClosed(); return; }
+
+    let json = JSON.stringify({ sessionid: session_id, 
+				call: event,
+				param: param});
+    socket.send(json);
     
-    socket.send(`sessionid:${session_id};CALL:${event}`);
     console.log(`Called ${event}`);
 }
diff --git a/src/murja-newui/newui.lisp b/src/murja-newui/newui.lisp
index 9e150ce..724ad9f 100644
--- a/src/murja-newui/newui.lisp
+++ b/src/murja-newui/newui.lisp
@@ -48,18 +48,15 @@
 
 (defparameter *current-ws* nil)
 (defmethod hunchensocket:text-message-received ((session ui-session) user message)
-  (let* ((split-msg (str:split #\; message))
-	 (sessionid (get-msg-param split-msg "sessionid"))
-	 (call-dst (get-msg-param split-msg "CALL")))
-	 
-				
-  
-    (format t "~a called ~a~%" (uid user) message)
-    (loop for peer in (hunchensocket:clients session)
-	  when (and (equalp (uid user) (uid peer))
-		    (equalp (prin1-to-string (uid peer)) sessionid))
-            do (let ((*current-ws* peer))
-		 (call-event sessionid call-dst)))))
+  (murja.json:bind-json (sessionid call) (param)
+			message 
+			
+			(format t "~a called ~a~%" (uid user) message)
+			(loop for peer in (hunchensocket:clients session)
+			      when (and (equalp (uid user) (uid peer))
+					(equalp (prin1-to-string (uid peer)) sessionid))
+				do (let ((*current-ws* peer))
+				     (call-event sessionid call param)))))
 
 (defparameter *server* nil)
 ;;(hunchentoot:stop *server*)
@@ -181,7 +178,7 @@
     (format out *component-format-string* tag attrs children)))
 
 (defmethod print-object ((e event) out)
-  (format out "send('~a'); ~a /*post-js*/; return false;" (generated-js-id e) (post-js e)))
+  (format out "send('~a', window.event.target.value); ~a /*post-js*/; return false;" (generated-js-id e) (post-js e)))
 ;; (with-slots (generated-js-id closure) e
 ;;   (format out "#<generated-js-id: ~a, closure: ~a>" generated-js-id (function-lambda-expression closure))))
 
@@ -251,13 +248,13 @@
 
 
 
-(defun call-event (sessionid call-dst)
+(defun call-event (sessionid call-dst param)
   (declare (ignore sessionid))
   (let* ((fn (gethash call-dst *js-identifiers-in-scope*)))
     (with-slots (closure) fn
       (murja.middleware.db:with-db
 	  (format t "Calling ~a~%" fn)
-	(funcall closure)))))
+	(funcall closure param)))))
 
 (defun @newui (next)
   (render (funcall next)))
diff --git a/src/views/blog-list-posts.lisp b/src/views/blog-list-posts.lisp
index be19e51..0091557 100644
--- a/src/views/blog-list-posts.lisp
+++ b/src/views/blog-list-posts.lisp
@@ -9,7 +9,7 @@
 			 :require-login t
 			 :title "Manage posts"
 			 :needed-abilities (list "edit-post"))
-  (let ((titles (postmodern:query "SELECT title, created_at, tags, unlisted, hidden
+  (let ((titles (postmodern:query "SELECT id, title, created_at, tags, unlisted, hidden
 FROM blog.Post
 ORDER BY created_at DESC" :array-hash))) ;; :array-hash due to me not caring enough to model this blog.Post Light as a clos class
 	  
@@ -36,7 +36,7 @@ ORDER BY created_at DESC" :array-hash))) ;; :array-hash due to me not caring eno
 				   (c :input (:type "checkbox"
 					      :unchecked)))
 			       "Unlisted"))
-			 (c :a (:href "/") "Edit")
+			 (c :a (:href (format nil "/blog/post/~a/edit" (gethash "id" title))) "Edit")
 			 (component :div (:class "post-admin-title")
 				    (concatenate 'list
 						 (list (c :h3 () "Tags"))
diff --git a/src/views/blog-post-editor.lisp b/src/views/blog-post-editor.lisp
new file mode 100644
index 0000000..36319a0
--- /dev/null
+++ b/src/views/blog-post-editor.lisp
@@ -0,0 +1,30 @@
+(defpackage murja.views.blog-post-editor
+  (:use :cl :murja.newui.dispatcher :murja.newui)
+  (:export :editor)
+  (:local-nicknames (:json :com.inuoe.jzon))
+  (:local-nicknames (:modelpost :murja.models.post)))
+
+(in-package :murja.views.blog-post-editor)
+
+(defun editor (post)
+  (with-state ((title (modelpost:post-title post))
+	       (content (modelpost:article post))) ()
+      (c :div ()
+       (c :input (:type "text"
+		  :name "title"
+		  :oninput (e (lambda (value) (format t "new title is ~s ~%" value)))
+		  :value title))
+       (c :textarea (:name "content"
+		     :oninput (e (lambda (value) (format t "oninput called with text value ~s~%" value ))))
+	  content)
+       (c :button (:onclick (e (lambda () (format t "Toimiiko edes tää?~%")))) "Click me"))))
+
+
+
+(deftab /blog/post/edit (:route "/blog/post/:id/edit"
+			 :require-login t
+			 :captured-route-params (id)
+			 :needed-abilities (list "edit-post")
+			 :subtab t)
+  (let ((post (modelpost:get-post id :allow-hidden? t)))
+    (editor post)))