miniblog

Miniblog: A command-line static blog system in Common Lisp
Log | Files | Refs | README | LICENSE

commit be82e21617332349bd4033d4156527010f7c2e0f
parent bacd99dcb980281b7a575763510c61e092e881d0
Author: Decay <decaydjk@tilde.town>
Date:   Sun, 20 Sep 2020 02:50:09 +0000

Fixing a bug when adding pages

Didn't like adding top-level pages (ie those with no parent node)

Diffstat:
Msrc/miniblog.lisp | 37+++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/miniblog.lisp b/src/miniblog.lisp @@ -251,29 +251,30 @@ (defmethod add-entry ((entry-type (eql :page)) uri regen) (or (when-let* ((uri-components (str:split "/" uri)) - (name (car (last uri-components))) - (parent-path (butlast uri-components)) - (parent-id (miniblog.content:get-page-id-by-path - parent-path - (miniblog.db:get-pages)))) - (if-let ((text (miniblog.edit:edit-text))) - (let* ((post (miniblog.edit:get-title-and-content text)) - (title (nth 0 post)) - (content (nth 1 post)) - (new-entry (miniblog.db:add-page - name - (or title "Untitled") - content - :parent parent-id - :username (get-username)))) - (if (or regen (= (length uri-components) 1)) + (name (car (last uri-components)))) + (let* ((parent-path (butlast uri-components)) + (parent-id (if parent-path + (miniblog.content:get-page-id-by-path parent-path + (miniblog.db:get-pages)) + 0))) + (if-let ((text (miniblog.edit:edit-text))) + (let* ((post (miniblog.edit:get-title-and-content text)) + (title (nth 0 post)) + (content (nth 1 post)) + (new-entry (miniblog.db:add-page + name + (or title "Untitled") + content + :parent parent-id + :username (get-username)))) + (if (or regen (= (length uri-components) 1)) (regenerate-all) (regenerate-page-and-parent-and-children parent-path (getf new-entry :id) (miniblog.db:get-pages)))) - (format t "Abandoning page...~%")) + (format t "Abandoning page...~%"))) t) - (format t "Invalid page name ~a~%" uri))) + (format t "Invalid page name ~a~%" uri))) (defun date-format (datetime) (funcall (miniblog.format:make-long-date-formatter *blog-timezone*) datetime))