From a9a5e994b2434921c7bd1f6466b3a0c1f1cd0b6b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 4 Mar 2022 15:53:21 -0600 Subject: added support for oneliner names --- src/main.lisp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.lisp b/src/main.lisp index b0031e8..573f622 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -111,6 +111,13 @@ :accessor oneliner :initarg :oneliner :initform (error "Oneliner required")) + (name + :accessor oneliner-name + :initarg :name + :initform nil + :index-type bknr.indices:string-unique-index + :index-reader oneliner-by-name + :documentation "A unique name for this oneliner.") (runstyle :accessor oneliner-runstyle :initarg :runstyle @@ -452,7 +459,7 @@ mentioned in th config file. (a:when-let ((access (access-by-contributor contributor))) (revoke-access access)))) -(defun make-new-oneliner (contributor &key oneliner tags brief explanation runstyle) +(defun make-new-oneliner (contributor &key oneliner tags brief explanation runstyle name) (a:when-let ((ol (db:with-transaction () @@ -462,6 +469,7 @@ mentioned in th config file. :tags tags :oneliner oneliner :brief brief + :name name :runstyle (if runstyle (a:make-keyword runstyle) :auto))))) (bt:with-lock-held (*newest-queue-lock*) (enqueue-qb *newest-queue* ol)))) @@ -486,14 +494,16 @@ mentioned in th config file. (db:with-transaction () (setf (lockedp oneliner) nil)))) -(defun edit-oneliner (ol contributor &key oneliner tags brief explanation runstyle) +(defun edit-oneliner (ol contributor &key oneliner tags brief explanation runstyle name) "Assumes each param, where given, has been validated." (db:with-transaction () (setf (last-edited-by ol) contributor) + (when name + (setf (oneliner-name ol) name)) (when oneliner (setf (oneliner ol) oneliner)) (when tags - (setf (oneliner-tags ol) tags)) + (setf (oneliner-tags ol) (remove-duplicates tags :test #'equal))) (when brief (setf (oneliner-brief ol) brief)) (when explanation @@ -568,8 +578,10 @@ mentioned in th config file. (defun a-oneliner-id (string) - "An id of a oneliner entry " - (a:if-let (oneliner (db:store-object-with-id (parse-integer string))) + "An id or name of a oneliner" + (a:if-let (oneliner (or + (db:store-object-with-id (parse-integer string :junk-allowed t)) + (oneliner-by-name string))) oneliner (http-err 404))) -- cgit v1.2.3