aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-03-04 15:53:21 -0600
committerColin Okay <okay@toyful.space>2022-03-04 15:53:21 -0600
commita9a5e994b2434921c7bd1f6466b3a0c1f1cd0b6b (patch)
treeaf9e6a1e3f3ba132a04689c580f2b27198af6039 /src
parent3dc20a35736e42c516fcf27e05e1cc3429ff0d85 (diff)
added support for oneliner names
Diffstat (limited to 'src')
-rw-r--r--src/main.lisp22
1 files 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)))