diff of 0e97649aa168f82b587347f5a74a400805c027f0

0e97649aa168f82b587347f5a74a400805c027f0
diff --git a/resources/js/murja-helper.js b/resources/js/murja-helper.js
deleted file mode 100644
index 85aa286..0000000
--- a/resources/js/murja-helper.js
+++ /dev/null
@@ -1,80 +0,0 @@
-var app = Elm.Main.init({
-    node: document.getElementById("app")
-});
-app.ports.alert.subscribe( (prompt) => {
-    window.alert(prompt);
-});
-
-app.ports.prompt.subscribe( (prompt) => {
-    let value = window.prompt(prompt);
-    app.ports.tags.send(value);
-});
-
-app.ports.reallySetupAce.subscribe( (content) => {
-    let editor = ace.edit("editor-post-content");
-
-    if(!editor) {
-	alert("Didn't find ace");
-	return;
-    }
-
-    editor.setKeyboardHandler("ace/keyboard/emacs");
-    editor.session.setValue(content);
-    editor.on('change', event => {
-     	let value = editor.getSession().getValue();
-	app.ports.aceStateUpdate.send(value);
-    });
-});
-
-app.ports.addImgToAce.subscribe(img_id => {
-    let editor = ace.edit("editor-post-content");
-
-    if (editor) {
-	editor.insert('<img src="/api/pictures/' + img_id +'" />');
-
-    } else alert("Didn't find ace editor");
-});
-
-Object.defineProperty(HTMLElement.prototype, "dangerouslySetInnerHTML", {
-    get () {
-        return this.innerHTML
-    },
-    set (value) {
-        this.innerHTML = value
-    }
-});
-
-app.ports.showPreviousPostsModal.subscribe(_ => {
-    document.getElementById('previouslyModal').showModal();
-});
-
-app.ports.showPreviousPostPreviewModal.subscribe(_ => {
-    document.getElementById('previewPreviouslyModal').showModal();
-});
-
-app.ports.showModal.subscribe(id => {
-    document.getElementById(id).showModal();
-});
-
-app.ports.closePreviousPostsModal.subscribe(_ => {
-    document.querySelectorAll('dialog').forEach(dialog => {
-	dialog.close();
-    });
-});
-
-app.ports.createExcerpt.subscribe(([textarea_id, feed_id]) => {
-    let txt = document.getElementById(textarea_id)
-    
-    if ( !txt ) {
-	alert(`Didn't find textarea with id ${textarea_id}`);
-	return;
-    }
-
-    let start = txt.selectionStart;
-    let finish = txt.selectionEnd;
-    
-    let selectedText = txt.value.substring(start, finish);
-    app.ports.excerptCreated.send([selectedText, feed_id]);
-});
-
-    
diff --git a/src/local-lib/halisql.lisp b/src/local-lib/halisql.lisp
index b936650..4ec7a3f 100644
--- a/src/local-lib/halisql.lisp
+++ b/src/local-lib/halisql.lisp
@@ -102,7 +102,7 @@
 				     ,(if (not (string= "" returns))
 					  (let ((*read-eval* nil))
 					    (when *log*
-					      (format t "returns: ~a~%" (prin1-to-string returns)))
+					      (log:info "returns: ~a~%" (prin1-to-string returns)))
 					    (read-from-string (string-upcase returns)))
 					  (if (equalp fn 'postmodern:query)
 					      :rows
@@ -110,32 +110,16 @@
 
 		       `(defun ,(intern (string-upcase name)) ,params
 			  (when *log* 
-			    (format t "running ~a~%" ,sql))
+			    (log:info "running ~a~%" ,sql))
 			  (handler-case
 			      ,(if (equalp count "single")
 				   `(first (first ,f))
 				     f)
 			    (error (e)
-			      (format t "caught error in ~a~%~a~%" (quote ,(intern (string-upcase name)))
+			      (log:error "caught error in ~a~%~a~%" (quote ,(intern (string-upcase name)))
 				      e)
 			      e)))))))
        '(,@(->> queries
 	     (mapcar (lambda (query)
 		       (let ((meta (query-meta query)))
 			 (intern (string-upcase (first (gethash "name" meta))))))))))))
-
-
-;; (macroexpand-1  '
-;;  (defqueries "user-routes.sql"))
-
-
-;; (pichunter.std:with-db
-;;     (postmodern:with-schema (:pichunter)
-
-;; (do-something-stupid-with-users "feuer" "TESTI" (pichunter.std:sha-512 "passu")
-;;   3
-;;   (pichunter.std:sha-512 "passu"))))
-
-
-
-  
diff --git a/src/main.lisp b/src/main.lisp
index 5408b45..d0a5847 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -13,7 +13,7 @@
   (hunchentoot:stop *server*))
 
 (defun start-server (&key (port 3010))
-  (format t "Starting murja server~%")
+  (log:info "Starting murja server~%")
   (with-db
       (migrate))
   (let ((server (make-instance 'easy-routes:easy-routes-acceptor :port port)))    
@@ -21,7 +21,7 @@
       (setf *server* server))
     
     (hunchentoot:start server)
-    (format t "Started murja server on ~a ~%" port)
+    (log:info "Started murja server on ~a ~%" port)
     server))
 
 (defun main (&key (port 3010))
diff --git a/src/middleware/auth.lisp b/src/middleware/auth.lisp
index 6dc4b81..f1d39b8 100644
--- a/src/middleware/auth.lisp
+++ b/src/middleware/auth.lisp
@@ -70,6 +70,7 @@
 								  :user-id user-id))
 	      "not authorized")))))
 
+;; this is used in murja.routes.media-routes and murja.routes.post-routes, but this (and the previous @authenticated middleware) is obviously deprecated and will hopefully disappear one of these years
 (defun @can? (next ability)
   (if (and *user*
 	   (member ability 
@@ -116,31 +117,30 @@
 	      (if require-authentication
 		  (progn 
 		    (setf (hunchentoot:return-code*) 401)
-		    (log:warn "assert-ownership-username failed for ~a" username-cookie)
+		    (log:warn "assert-ownership-username failed for ~a (~a)" username-cookie (hunchentoot:host))
 		    "not authorized")
 		  (progn
-		    (format t "no auth required~%")
+		    (log:info "no auth required on ~a~%" (hunchentoot:host))
 		    (funcall next)))))
-	(progn (format t "löydetäänköhän me ~a~%" user-id)
-	       (if user-id
-		   (let ((user (murja.model.user:get-user user-id)))
-		     (if (and user
-			      (string= (hunchentoot:session-value :logged-in-username)
-				       (user-username user)))
-			 (let ((*user* user)
-			       (*session-key* session-cookie))
-			   (funcall next))
-			 (if require-authentication 
-			     (progn
-			       (setf (hunchentoot:return-code*) 401)
-			       "not authorized")
-			     (funcall next))))
-		   (if (not require-authentication)
-		       (funcall next)		
-		       (progn
-			 (setf (hunchentoot:return-code*) 401)
-			 (log:warn "failed auth at @authenticated, ~a" (list :retries retries
-									     :session-cookie session-cookie
-									     :username-cookie username-cookie
-									     :user-id user-id))
-			 "not authorized")))))))
+	(if user-id
+	    (let ((user (murja.model.user:get-user user-id)))
+	      (if (and user
+		       (string= (hunchentoot:session-value :logged-in-username)
+				(user-username user)))
+		  (let ((*user* user)
+			(*session-key* session-cookie))
+		    (funcall next))
+		  (if require-authentication 
+		      (progn
+			(setf (hunchentoot:return-code*) 401)
+			"not authorized")
+		      (funcall next))))
+	    (if (not require-authentication)
+		(funcall next)		
+		(progn
+		  (setf (hunchentoot:return-code*) 401)
+		  (log:warn "failed auth at @authenticated, ~a" (list :retries retries
+								      :session-cookie session-cookie
+								      :username-cookie username-cookie
+								      :user-id user-id))
+		  "not authorized"))))))
diff --git a/src/middleware/db.lisp b/src/middleware/db.lisp
index ca0c828..8cc9a45 100644
--- a/src/middleware/db.lisp
+++ b/src/middleware/db.lisp
@@ -37,7 +37,6 @@
 
 (defmacro with-db (&rest body)
   `(destructuring-bind (&key db username password host port) (db-config)
-     (format t "Connecting to db ~a ~%" (list db username "$password" host :port port))
      (with-connection (list db username password host :port port)
        ,@body)))
 
@@ -45,12 +44,12 @@
   (with-db
       (handler-bind ((cl-postgres:database-socket-error
 		     (lambda (c)
-		       (format t "Socket error from db: ~a~%" c)
+		       (log:error "Socket error from db: ~a~%" c)
 		       (setf (hunchentoot:return-code*) 500)
 		       (return-from @transaction "Internal Server Error")))
 		     (cl-postgres:database-error
 		       (lambda (c)
-			 (format t "Error from db: ~a~%" c)
+			 (log:error "Error from db: ~a~%" c)
 			 (setf (hunchentoot:return-code*) 500)
 			 (return-from @transaction "Internal Server Error"))))
 	(with-transaction (:repeatable-read-rw)
@@ -61,12 +60,12 @@
   (with-db
       (handler-bind ((cl-postgres:database-socket-error
 		       (lambda (c)
-			 (format t "Socket error from db: ~a~%" c)
+			 (log:error "Socket error from db: ~a~%" c)
 			 (setf (hunchentoot:return-code*) 500)
 			 (return-from @db "Internal Server Error")))
 		     (cl-postgres:database-error
 		       (lambda (c)
-			 (format t "Error from db: ~a~%" c)
+			 (log:error "Error from db: ~a~%" c)
 			 (setf (hunchentoot:return-code*) 500)
 			 (return-from @db "Internal Server Error"))))
 	(let* ((murja.settings:*settings* (murja.settings:get-settings)))
diff --git a/src/model/post.lisp b/src/model/post.lisp
index 4aa10f6..0e16e4e 100644
--- a/src/model/post.lisp
+++ b/src/model/post.lisp
@@ -112,7 +112,7 @@ ORDER BY p.created_at DESC" :lists)))
   (setf (tags p) (coerce (parse (tags p)) 'list))
 
   (unless (previouslies p)
-    (format t "ERROR previouslies were nil. Have you forgotten to join them to your posts?~%"))
+    (log:error "ERROR previouslies were nil. Have you forgotten to join them to your posts?~%"))
 
   (if (equalp "[null]" (previouslies p))
       (setf (previouslies p) nil)
diff --git a/src/routes/login-routes.lisp b/src/routes/login-routes.lisp
index 0a3043e..2c452c2 100644
--- a/src/routes/login-routes.lisp
+++ b/src/routes/login-routes.lisp
@@ -55,45 +55,6 @@
 						    (gethash "domain" settings))
 					  :same-site "Strict"))
 
-(defroute post-login ("/api/login/login" :method :post :decorators (@test-now @transaction @json)) ()
-  (let* ((body (hunchentoot:raw-post-data :force-text t))
-	 (body-params (parse body))
-	 (username (gethash "username" body-params))
-	 (password (gethash "password" body-params))
-	 (user-row (murja.users.user-db:select-user-by-login username (sha-512 password))))
-    (if (and user-row
-	     (string= (gethash "username" user-row) username))
-	(let ((settings (murja.routes.settings-routes:get-settings))
-	      (murja.middleware.auth:*user* (murja.users.user-db:get-user-by-id (gethash "userid" user-row))))
-	  (multiple-value-bind (session-key max-age) (get-session-key username)
-	    (if session-key
-	      (let ((murja.middleware.auth:*session-key* session-key))
-		
-		(set-session-value :logged-in-username username)
-		(set-session-value :logged-in-user-id (gethash "userid" user-row))
-		
-		(set-session-cookies username session-key max-age settings)
-	        
-		(stringify user-row))
-	      (progn
-		(log:error "~a tried to log-in but get-session-key didn't return a session key. This happening signifies a bug" username)
-		(setf (hunchentoot:return-code*) 500)
-		"catastrophic error"))))
-
-	(progn 
-	  (setf (hunchentoot:return-code*) 401)
-	  "not authorized"))))
-
-(defroute api-session ("/api/login/session" :method :get :decorators (@test-now
-								      @transaction
-								      @json
-								      @authenticated)) ()
-  (if *user*
-      (com.inuoe.jzon:stringify (murja.users.user-db:get-session-user-by-id (gethash "id" *user*)))
-      (progn
-	(setf (hunchentoot:return-code*) 401)
-	nil)))
-
 (defun save-initial-data-dump (username nickname password domain blog_title rss_title rss_link rss_description rss_lang rss_email)
   (user-db:register-user username nickname "" password)
   (user-db:cast-only-user-as-admin)
@@ -144,11 +105,11 @@
 		(set-session-value :logged-in-user-id (gethash "userid" user-row))
 		
 		(set-session-cookies username session-key max-age settings)
-		(format t "Login successfully~%"))
+		(log:info "~a logged in successfully~%" username))
 	      (progn
 		(log:error "~a tried to log-in but get-session-key didn't return a session key. This happening signifies a bug" username)))))
 
-	(log:error "not authorized"))
+	(log:error "~a not authorized" username))
 
     (let ((referer (hunchentoot:header-in* "referer")))
       (hunchentoot:redirect referer))))
diff --git a/src/routes/media-routes.lisp b/src/routes/media-routes.lisp
index 5dd93ea..6bf2e71 100644
--- a/src/routes/media-routes.lisp
+++ b/src/routes/media-routes.lisp
@@ -11,6 +11,7 @@
 
 (in-package :murja.routes.media-routes)
 
+;; called from murja.view.admin.components.dnd-script
 (defroute post-pic ("/api/pictures" :method :post
 				    :decorators (@transaction
 						 @authenticated
@@ -27,20 +28,8 @@
 	      (caar result))
 	(stringify response)))))
 
-(defroute all-pics ("/api/pictures/list/all" :method :get
-					     :decorators (@transaction
-							  @authenticated
-							  (@can? "create-post"))) ()
-    (let ((pics (list-pictures)))
-      (if pics
-	  (stringify pics)
-	  "[]")))
-      
-(defroute referencing-route ("/api/pictures/referencing/:guid" :method :get
-							       :decorators (@transaction
-									    @authenticated)) ()
-  (stringify (select-referencing-posts* guid)))
 
+;; probably called by every blog post containing pictures 
 (defroute picture-route ("/api/pictures/:guid" :method :get
 					       :decorators (@transaction)) ()
   (let* ((pic-result (coerce (get-media guid) 'list))
@@ -55,6 +44,7 @@
 	    (format nil "inline; filename=~a" (gethash "name" pic)))
       (gethash "data" pic))))
 
+;; I don't think this is called anywhere, but I'm not atm able to improvise a regexp that would make sure it's not 
 (defroute delete-pic ("/api/pictures" :method :delete
 				      :decorators (@transaction
 						   @authenticated
diff --git a/src/routes/post-routes.lisp b/src/routes/post-routes.lisp
index 952bfd9..cc6eab2 100644
--- a/src/routes/post-routes.lisp
+++ b/src/routes/post-routes.lisp
@@ -12,107 +12,35 @@
 
 (in-package :murja.routes.post-routes)
 
-(defroute title-routes ("/api/posts/titles" :method :get
-					    :decorators (@json @transaction)) ()
-  (let ((titles (or (get-titles-by-year) #())))
-    (stringify titles)))
-
-(defroute manager-title-routes ("/api/posts/all-titles" :method :get
-							:decorators (@json @transaction @authenticated (@can? "edit-post"))) ()
-  
-  (let ((titles (get-titles-by-year :allow-hidden? t)))
-    (stringify (or titles #()))))    
-
-(defroute get-page-route ("/api/posts/page/:page" :method :get
-						  :decorators (@json @transaction))
-    (&path (page 'integer))
-  (let* ((settings (get-settings))
-	 (page-size (gethash "recent-post-count" settings)))
-    (let* ((id page)
-	   (posts (or (murja.posts.post-db:get-page page page-size) #()))
-	   (last-page? (zerop (length (murja.posts.post-db:get-page (1+ page) page-size))))
-	   (result (make-hash-table)))
-      (setf (gethash "id" result) id)
-      (setf (gethash "posts" result) posts)
-      (setf (gethash "last-page?" result) last-page?)
-
-      (com.inuoe.jzon:stringify result))))
-
-(defroute hidden-post ("/api/posts/post/:id/allow-hidden/:hidden" :method :get
-								  :decorators (@json
-									       @transaction
-									       @authenticated
-									       (@can? "edit-post"))) ()
+;; TODO redo excerpts in feed reader?
+
+;; (defvar *excerpt-html-template*
+;; " <blockquote class=\"excerpt\">
+;;   <header>
+;;     <a href=~s> ~s says...</a>
+;;   </header>
+;;   ~a 
+;; </blockquote> ")
+
+;; (defroute create-excerpt ("/api/posts/excerpt/:feed-item-id" :method :post
+;; 					       :decorators (@json
+;; 							    @transaction
+;; 							    @authenticated
+;; 							    (@can? "create-post"))) ()
+;;   (let* ((creator-id (gethash "id" *user*))
+;; 	 (name-and-url (first
+;; 			(coerce
+;; 			 (murja.rss.reader-db:get-feed-name-and-url feed-item-id creator-id)
+;; 			 'list)))
+;; 	 (name (gethash "name" name-and-url))
+;; 	 (url (gethash "url" name-and-url))
+;; 	 (excerpt (hunchentoot:raw-post-data :force-text t)))
+;;     (prin1-to-string (caar (murja.posts.post-db:insert-post "New title"
+;; 							    (format nil *excerpt-html-template*
+;; 								    url name excerpt)
+;; 							    creator-id "[]" t nil)))))
   
-  (let* ((show-hidden? (string= hidden "true"))
-	 (post (get-post id :allow-hidden? show-hidden?)))
-    (when post
-      (log:info "returning post (hidden allowed? ~a) { ~{~a~%~} }~%" hidden (alexandria:hash-table-alist post))
-      (stringify post))))
-
-(defroute get-post-version-route ("/api/posts/post/:id/version/:version" :method :get
-								   :decorators (@json
-										@transaction)) ()
-  (let ((post (get-post-version id version)))
-    (if post 
-	(stringify post)
-	(progn
-	  (setf (hunchentoot:return-code*) 404)
-	  ""))))
-
-(defroute unhidden-post ("/api/posts/post/:id" :method :get :decorators (@json
-									 @transaction)) ()
-  (let* ((post (get-post id)))
-    (if post
-	(progn 
-	  (log:info "returning unhidden post { ~{~a~%~} }~%" (alexandria:hash-table-alist post))
-	  (stringify post))
-	(progn
-	  (setf (hunchentoot:return-code*) 404)
-	  ""))))
-
-(defroute tagged-posts-route ("/api/posts/tagged/:tag" :method :get
-						       :decorators (@json
-								    @transaction)) ()
-  (when (and (not (string= tag "hidden"))
-	     (not (string= tag "unlisted")))
-    (stringify (murja.posts.post-db:get-tagged tag :allow-hidden? nil))))
-
-(defroute create-empty-post-route ("/api/posts/new_post" :method :post
-							 :decorators (@json
-								      @transaction
-								      @authenticated
-								      (@can? "create-post"))) ()
-  (let ((creator-id (gethash "id" *user*)))
-    (prin1-to-string (caar (murja.posts.post-db:insert-post "New title" "New post" creator-id "[]" t nil)))))
-
-(defvar *excerpt-html-template*
-" <blockquote class=\"excerpt\">
-  <header>
-    <a href=~s> ~s says...</a>
-  </header>
-  ~a 
-</blockquote> ")
-
-(defroute create-excerpt ("/api/posts/excerpt/:feed-item-id" :method :post
-					       :decorators (@json
-							    @transaction
-							    @authenticated
-							    (@can? "create-post"))) ()
-  (let* ((creator-id (gethash "id" *user*))
-	 (name-and-url (first
-			(coerce
-			 (murja.rss.reader-db:get-feed-name-and-url feed-item-id creator-id)
-			 'list)))
-	 (name (gethash "name" name-and-url))
-	 (url (gethash "url" name-and-url))
-	 (excerpt (hunchentoot:raw-post-data :force-text t)))
-    (prin1-to-string (caar (murja.posts.post-db:insert-post "New title"
-							    (format nil *excerpt-html-template*
-								    url name excerpt)
-							    creator-id "[]" t nil)))))
-  
-
+;; this is actually called in murja.view.admin.components.previouslies-script
 (defroute search-prev ("/api/posts/search-previously" :method :post
 						      :decorators (@json
 								   @transaction
@@ -120,28 +48,3 @@
 								   (@can? "create-post"))) ()
   (let* ((search-body (hunchentoot:raw-post-data :force-text t)))
     (stringify (murja.posts.post-db:search-posts search-body))))
-
-(defroute post-update-route ("/api/posts/post" :method :put 
-					       :decorators (@json
-							    @transaction
-							    @authenticated
-							    (@can? "edit-post"))) ()
-  (let* ((request-body (parse (hunchentoot:raw-post-data :force-text t)))
-	 (content (gethash "content" request-body))
-	 (title (gethash "title" request-body))
-	 (tags (stringify
-		(or (remove-if (partial #'string= "")
-			       (coerce 
-				(gethash "tags" request-body) 'list))
-		    #())))
-	 (post-id (gethash "id" request-body))
-	 (previously-links (coerce (gethash "previously" request-body) 'list))
-	 (hidden (gethash "hidden" request-body))
-	 (unlisted (gethash "unlisted" request-body)))
-    (log:info "updating post ~d" post-id)
-
-    (murja.posts.post-db:update-post title content tags hidden unlisted post-id)
-    (dolist (link previously-links)
-      (let ((id (gethash "id" link)))
-	(murja.posts.post-db:link-previously post-id id)))
-    ""))
diff --git a/src/routes/root-routes.lisp b/src/routes/root-routes.lisp
index a8990b4..ab49942 100644
--- a/src/routes/root-routes.lisp
+++ b/src/routes/root-routes.lisp
@@ -45,105 +45,17 @@
 		     "Don't know how to transform file of type ~a to a mime type"
 		     (file-type condition)))))
 
-(defun path->mime (path)
-  (let ((type (pathname-type path)))
-    (cond ((string= type "js") "text/javascript")
-	  ((string= type "css") "text/css")
-	  (t (error 'unknown-mime :file-type type)))))
-
 (defun get-resource (file)
-  (format t "Trying to GET ~a~%" file)
-  (let ((path (gethash file *allowed-resources*)))
-    (if path
-	(let ((source (lisp-fixup:slurp-utf-8 path)))
-	  (setf (hunchentoot:content-type*) (path->mime path))
-	  source)
-	(progn
-	  (setf (hunchentoot:return-code*) 404)
-	  ""))))
+  ;; there are not other resources beside murja.css anymore, and I'd love to get rid of it too
+  (when (equalp file "murja.css")
+    (let ((path (gethash file *allowed-resources*)))
+      (if path
+	  (let ((source (lisp-fixup:slurp-utf-8 path)))
+	    (setf (hunchentoot:content-type*) "text/css")
+	    source)
+	  (progn
+	    (setf (hunchentoot:return-code*) 404)
+	    "")))))
 
 (defroute resources ("/resources/:file" :method :get) ()
   (get-resource file))
-
-;; (defroute resources ("/resources/:file" :method :get) ()
-;;   (get-resource file))
-
-(defun @check-if-initial (next)
-  (if (user-db:no-users?)
-      (progn
-	(setf (hunchentoot:return-code*) 302)
-	(setf (hunchentoot:header-out :location) "/initial-setup")
-	"")
-      (funcall next)))
-
-(defvar *root* 
-  "<!DOCTYPE html>
-<html xmlns:of=\"http://ogp.me/ns#\"
-      xmlns:fb=\"http://www.facebook.com/2008/fbml\">
-  <head>
-    <link href=\"/resources/murja.css\" rel=\"stylesheet\" type=\"text/css\">
-    <script src=\"https://unpkg.com/ace-custom-element@latest/dist/index.min.js\" type=\"module\"></script>
-    <meta charset=\"UTF-8\" />
-    <script src=\"/resources/murja.js\"></script>
-  </head>
-  <body>
-    <div id=\"app\" />
-    <script src=\"/resources/murja-helper.js\"></script>
-  </body>
-</html>")
-
-;; (defroute root ("/" :method :get
-;; 		    :decorators (murja.middleware.db:@transaction
-;; 				 @check-if-initial)) ()
-;;   *root*)
-
-;; (defroute spurasdasdasd ("/blog/initial-setup" :method :get) ()
-;;   *root*)
-
-;; (defroute root-blg ("/blog/" :method :get
-;; 			     :decorators (murja.middleware.db:@transaction
-;; 					  @check-if-initial)) ()
-;;   *root*)
-
-;; (defroute root-blg-new ("/blog/new_post" :method :get) ()
-;;   *root*)
-
-;; (defroute root-blg-newer ("/blog/new_post/" :method :get) ()
-;;   *root*)
-
-;; (defroute mediamgr ("/blog/mediamanager" :method :get) ()
-;;   *root*)
-
-;; (defroute postmgr ("/blog/postadmin" :method :get) ()
-;;   *root*)
-
-
-;; (defroute post-view ("/blog/post/:id" :method :get) ()
-;;   *root*)
-
-;; (defroute edit ("/blog/post/edit/:id" :method :get) ()
-;;   *root*)
-
-;; (defroute root-blg-2 ("/blog/tags/:tag" :method :get) ()
-;;   *root*)
-
-;; (defroute sdkfpsokopfs ("/blog/post/:post/version/:ver" :method :get) ()
-;;   *root*)
-
-;; (defroute ddddddd ("/blog/settings" :method :get) ()
-;;   *root*)
-
-;; (defroute asjdisdjfiosd ("/blog/logs" :method :get) ()
-;;   *root*)
-
-;; (defroute aesdfg ("/blog/settings" :method :get) ()
-;;   *root*)
-
-
-;; (defroute ddddddd1234 ("/blog/page/:page" :method :get) ()
-;;   *root*)
-
-;; (defroute sdfdsfopsf ("/blog/feeds" :method :get) ()
-;;   *root*)
-
-;; (defroute kgvfokgf ("/blog/usersettings" :method :get) () *root*)
diff --git a/src/routes/rss-reader-routes.lisp b/src/routes/rss-reader-routes.lisp
index efa9902..c2800f9 100644
--- a/src/routes/rss-reader-routes.lisp
+++ b/src/routes/rss-reader-routes.lisp
@@ -1,62 +1,11 @@
 (defpackage murja.routes.rss-reader-routes
   (:use :cl)
   (:import-from :easy-routes :defroute)
-  (:import-from :com.inuoe.jzon :stringify :parse)
   (:import-from :murja.middleware.db :@transaction)
-  (:import-from :murja.middleware.auth :@authenticated :*user* :@can?)
-  (:import-from :murja.middleware.json :@json)
-  (:import-from :murja.rss.reader-db :update-feeds :get-user-feeds :subscribe-to-feed))
+  (:import-from :murja.rss.reader-db :update-feeds))
 
 (in-package :murja.routes.rss-reader-routes)
 
-(defroute user-feeds-route ("/api/user/feeds"
-			    :method :get
-			    :decorators (@json
-					 @transaction
-					 @authenticated))
-    (&get archived)
-  (let ((archived (string= archived "archived")))
-    (assert (not (null *user*)))
-    (assert (not (null (gethash "id" *user*))))
-    
-    (let ((feeds (or (get-user-feeds (gethash "id" *user*) archived) #())))
-      (com.inuoe.jzon:stringify feeds))))
-
-(defroute updater-metadata ("/api/user/feeds/meta" :method :get
-						   :decorators (@json
-								@transaction
-								@authenticated)) ()
-  (let ((result (make-hash-table :test 'equal)))
-    (setf (gethash "last-update-timestamps" result)
-	  (or murja.rss.reader-db:*updates*
-	      #()))
-    (com.inuoe.jzon:stringify result)))
-
-(defroute user-feeds-saving ("/api/user/feeds"
-			     :method :post
-			     :decorators (@transaction @authenticated)) ()
-  (let* ((request-body (parse (hunchentoot:raw-post-data :force-text t)))
-	(name (gethash "name" request-body))
-	(url (gethash "url" request-body)))
-    (assert (not (null *user*)))
-    (subscribe-to-feed name url *user*)
-    (setf (hunchentoot:return-code*) 204)
-    ""))
-
-(defroute mark-as-read ("/api/user/feeds/:feed-id/:item-id/mark-read" :method :post
-								      :decorators (@transaction
-										   @authenticated)) ()
-  (murja.rss.reader-db:mark-as-read item-id feed-id (gethash "id" *user*))
-  (setf (hunchentoot:return-code*) 204)
-  "")
-
-(defroute delete-feed ("/api/user/feeds/:feed-id" :method :delete
-						  :decorators (@transaction
-							       @authenticated)) ()
-  (murja.rss.reader-db:delete-feed feed-id (gethash "id" *user*))
-  (setf (hunchentoot:return-code*) 204)
-  "")
-
 ;; This will be called by cron/curl
 (defroute update-feeds-rotue ("/api/rss/update" :method :get
 						:decorators (@transaction)) ()
diff --git a/src/routes/rss-routes.lisp b/src/routes/rss-routes.lisp
index 1018b02..a2d15ce 100644
--- a/src/routes/rss-routes.lisp
+++ b/src/routes/rss-routes.lisp
@@ -4,7 +4,7 @@
   (:import-from :murja.posts.post-db :get-page)
   (:import-from :murja.routes.settings-routes :get-settings)
   (:import-from :murja.middleware.db :@transaction)
-  (:import-from :murja.middleware.auth :@authenticated :*user* :@can?))
+  (:import-from :murja.middleware.auth :@authenticated :*user*))
 
 (in-package :murja.routes.rss-routes)
 
diff --git a/src/routes/settings-routes.lisp b/src/routes/settings-routes.lisp
index fc9c771..d22bc50 100644
--- a/src/routes/settings-routes.lisp
+++ b/src/routes/settings-routes.lisp
@@ -4,7 +4,7 @@
   (:import-from :lisp-fixup :partial)
   (:import-from :com.inuoe.jzon :stringify :parse)
   (:import-from :binding-arrows :->>)
-  (:import-from :murja.middleware.auth :@authenticated :*user* :@can?)
+  (:import-from :murja.middleware.auth :@authenticated :*user*)
   (:import-from :murja.middleware.json :@json)
   (:import-from :murja.middleware.db :@transaction)
   (:import-from :easy-routes :defroute)
@@ -29,17 +29,3 @@
 
 (defun update-setting (k v)
   (postmodern:execute "INSERT INTO blog.Settings (key, value) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET value = excluded.value" k (stringify v)))
-
-(defroute update-setting-route ("/api/settings/client-settings" :method :put 
-							  :decorators (@transaction
-								       @json
-								       @authenticated
-								       (@can? "update-settings"))) ()
-  (let ((req (alexandria:hash-table-alist
-	      (parse (hunchentoot:raw-post-data :force-text t)))))
-    (dolist (p req)
-      (destructuring-bind (k . v) p
-	(format t "execute returned for ~a => ~a: ~a~%" k v
-		(update-setting k v))))
-    (setf (hunchentoot:return-code*) 204)
-    ""))
diff --git a/src/routes/user-editor.lisp b/src/routes/user-editor.lisp
index c5b785d..757a787 100644
--- a/src/routes/user-editor.lisp
+++ b/src/routes/user-editor.lisp
@@ -5,7 +5,7 @@
   (:import-from :lisp-fixup :sha-512)
   (:import-from :murja.middleware.db :@transaction)
   (:import-from :murja.middleware.json :@json)
-  (:import-from :murja.middleware.auth :@authenticated :@can? :*user*)
+  (:import-from :murja.middleware.auth :@authenticated :*user*)
   (:import-from :murja.media.media-db :insert-media)
   (:import-from :com.inuoe.jzon :stringify :parse)
   (:import-from :easy-routes :defroute)
@@ -16,6 +16,8 @@
 
 (in-package :murja.routes.user-editor)
 
+;; TODO redo with spinneret
+
 (defun can-save-user? (user-id old-password)
   (and *user*
        (equalp (gethash "id" *user*)
@@ -26,55 +28,55 @@
   (let ((symbol-str (str:downcase (format nil "~s" symbol))))
     `(setf (gethash ,symbol-str ,map) ,symbol)))
 
-(defroute submit-user ("/api/user/submit" :method :post
-					  :decorators (@transaction
-						       @authenticated
-						       @json)) ()
-  (bind-json (nickname username img_location id old-password) (new-password) (hunchentoot:raw-post-data :force-text t)
-    (if (can-save-user? id old-password)
-	(let* ((user (user-db:get-user-by-id id)))
-	  (patch user nickname)
-	  (patch user username)
+;; (defroute submit-user ("/api/user/submit" :method :post
+;; 					  :decorators (@transaction
+;; 						       @authenticated
+;; 						       @json)) ()
+;;   (bind-json (nickname username img_location id old-password) (new-password) (hunchentoot:raw-post-data :force-text t)
+;;     (if (can-save-user? id old-password)
+;; 	(let* ((user (user-db:get-user-by-id id)))
+;; 	  (patch user nickname)
+;; 	  (patch user username)
 
-	  (when (and new-password
-		     (not (string= new-password "")))	    
-	    (setf (gethash "password" user)
-		  (sha-512 new-password)))
+;; 	  (when (and new-password
+;; 		     (not (string= new-password "")))	    
+;; 	    (setf (gethash "password" user)
+;; 		  (sha-512 new-password)))
 
-	  (user-db:patch-user user)
-	  (setf (hunchentoot:return-code*) 204)
+;; 	  (user-db:patch-user user)
+;; 	  (setf (hunchentoot:return-code*) 204)
 
-	  (multiple-value-bind (session-key max-age) (login:get-session-key username)
-	    (login:set-session-cookies username session-key max-age (settings:get-settings))
-	    (murja.session:set-session-value :logged-in-username username))
+;; 	  (multiple-value-bind (session-key max-age) (login:get-session-key username)
+;; 	    (login:set-session-cookies username session-key max-age (settings:get-settings))
+;; 	    (murja.session:set-session-value :logged-in-username username))
 	  
-	  "")
+;; 	  "")
 
-	(progn
-	  (log:warn "can-save-user? failed due to ~a" (cond
-							((not *user*) "*user* failing")
-							((not (equalp (gethash "id" *user*)
-								      id))
-							 (format nil "id ~a != ~a" (gethash "id" *user*)
-								 id))
-							((not (user-db:search-with-id-and-pwd* id (sha-512 old-password)))
-							 "password lookup failing")))
-	  (setf (hunchentoot:return-code*) 500)
-	  ""))))
+;; 	(progn
+;; 	  (log:warn "can-save-user? failed due to ~a" (cond
+;; 							((not *user*) "*user* failing")
+;; 							((not (equalp (gethash "id" *user*)
+;; 								      id))
+;; 							 (format nil "id ~a != ~a" (gethash "id" *user*)
+;; 								 id))
+;; 							((not (user-db:search-with-id-and-pwd* id (sha-512 old-password)))
+;; 							 "password lookup failing")))
+;; 	  (setf (hunchentoot:return-code*) 500)
+;; 	  ""))))
 
-(defroute submit-profile-pic ("/api/pictures/profile" :method :post
-						      :decorators (@transaction
-								   @authenticated
-								   @json))
-    (&post file)
+;; (defroute submit-profile-pic ("/api/pictures/profile" :method :post
+;; 						      :decorators (@transaction
+;; 								   @authenticated
+;; 								   @json))
+;;     (&post file)
 
-  (with-keys ("id" "username") *user*
-    (destructuring-bind (tmp-file filename mime) file
-      (when (str:starts-with? "image/" mime)
-	(log:info "Changing profile pic of ~a to ~a" username filename)
-	(let* ((bytes (lisp-fixup:slurp-bytes tmp-file))
-	       (result (insert-media filename bytes))
-	       (img-id (caar result)))
+;;   (with-keys ("id" "username") *user*
+;;     (destructuring-bind (tmp-file filename mime) file
+;;       (when (str:starts-with? "image/" mime)
+;; 	(log:info "Changing profile pic of ~a to ~a" username filename)
+;; 	(let* ((bytes (lisp-fixup:slurp-bytes tmp-file))
+;; 	       (result (insert-media filename bytes))
+;; 	       (img-id (caar result)))
 
-	  (user-db:patch-user-img* (format nil "/api/pictures/~a" img-id) id)
-	  (stringify (hash (:id img-id))))))))
+;; 	  (user-db:patch-user-img* (format nil "/api/pictures/~a" img-id) id)
+;; 	  (stringify (hash (:id img-id))))))))
diff --git a/src/view/admin/logs.lisp b/src/view/admin/logs.lisp
index e48d14f..98235f6 100644
--- a/src/view/admin/logs.lisp
+++ b/src/view/admin/logs.lisp
@@ -9,9 +9,7 @@
 (defroute post-logs-groups ("/api/logs/groups" :method :post
 					       :decorators (murja.middleware.db:@db
 							    murja.middleware.auth:@ssr-authenticated)) ()
-  (format t "Congraz on finding the REAL post-logs-groups~%")
   (let ((form (lisp-fixup:formdata->hashmap (hunchentoot:raw-post-data :force-text t))))
-    (log:info "Trying to save ~a~%" (alexandria:hash-table-alist form))
     ;;(postmodern:execute "DELETE FROM blog.log_group;")
 
     (postmodern:execute "INSERT INTO blog.log_group (name, alarmy) VALUES ($1, $2) ON CONFLICT DO NOTHING"
diff --git a/src/view/admin/new-post.lisp b/src/view/admin/new-post.lisp
index 039cc84..6ef1720 100644
--- a/src/view/admin/new-post.lisp
+++ b/src/view/admin/new-post.lisp
@@ -3,7 +3,7 @@
   ;; (:import-from :murja.model.post :article :post-title)
   (:import-from :murja.middleware.db :@transaction :@db)
   (:import-from :murja.routes.login-routes :formdata->hashmap)
-  (:import-from :murja.middleware.auth :@authenticated :@ssr-authenticated :*user* :@can?)
+  (:import-from :murja.middleware.auth :@authenticated :@ssr-authenticated :*user*)
   (:import-from :murja.model.user :user-id )
   (:import-from :murja.view.components.tabs :deftab)
   (:import-from :murja.posts.post-db :insert-post)
@@ -29,7 +29,7 @@
 	(let ((post-id
 		;; TODO wrap these stupid sql-wrappers with something that unbinds values automatically
 		(caar (insert-post "New post" "New title" (user-id *user*) "[]" t t))))
-	  (format t "A new post with id ~d should now exist~%" post-id)
+	  (log:info "A new post with id ~d should now exist~%" post-id)
 	  (hunchentoot:redirect (format nil "/blog/post/editor/~d" post-id)))
 	"no can do")))
 
@@ -57,9 +57,12 @@
 	(setf (post-unlisted? post) (equalp "on" (gethash "unlisted" form)))
 	(setf (tags post) (gethash "tags" form))
 
-	(format t "Form: ~a~%" (alexandria:hash-table-plist form))
+	;; if this app was running on a host with more than 1 user, this log would be kind of bad
+	;; but as it's only me and I have previously lost posts due to programming errors in editor,
+	;; let's keep these logs for now
+	(log:info "Form: ~a~%" (alexandria:hash-table-plist form))
 
-	(format t "Post: ~a~%" post)
+	(log:info "Post: ~a~%" post)
 
 	(postmodern:update-dao post)
 
diff --git a/src/view/components/root.lisp b/src/view/components/root.lisp
index 0d99c40..e2cdcbe 100644
--- a/src/view/components/root.lisp
+++ b/src/view/components/root.lisp
@@ -88,7 +88,5 @@
 			     (sidebar/new-post)
 			     (loginform/user-widget)
 			     (sidebar-tree)
-			     (if *inject-to-sidebar*
-				 (progn (format t "*inject-to-sidebar* is something~%")
-					(funcall *inject-to-sidebar*))
-				 (format t "*inject-to-sidebar* is nothing~%"))))))))))
+			     (when *inject-to-sidebar*
+			       (funcall *inject-to-sidebar*))))))))))