aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-14 14:08:50 -0600
committerColin Okay <okay@toyful.space>2022-02-14 14:08:50 -0600
commit6ee1bbd755b4d69e7b600c10149ebb2d5f58cf5b (patch)
tree933455342cf170a71c6bb5fa58d734172a56130f
parent45388d006b15f02553ced7684f67f8718c992814 (diff)
temporarily keeping client code here too
-rw-r--r--clpmfile2
-rw-r--r--clpmfile.lock77
-rw-r--r--src/main.lisp81
3 files changed, 114 insertions, 46 deletions
diff --git a/clpmfile b/clpmfile
index decfbc8..09cc3ee 100644
--- a/clpmfile
+++ b/clpmfile
@@ -4,6 +4,7 @@
(:source "quicklisp" :url "https://beta.quicklisp.org/dist/quicklisp.txt" :type :quicklisp)
(:asd "oneliners.api.asd")
+(:asd "oneliners.api-client.asd")
(:github "lazybones"
:path "cbeo/lazybones"
@@ -16,3 +17,4 @@
(:github "lazybones-client"
:path "cbeo/lazybones-client"
:branch "main")
+
diff --git a/clpmfile.lock b/clpmfile.lock
index da11900..24e5b48 100644
--- a/clpmfile.lock
+++ b/clpmfile.lock
@@ -9,6 +9,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:sources
+(:implicit-file :type :file-system :system-files ("oneliners.api-client.asd"))
(:implicit-file :type :file-system :system-files ("oneliners.api.asd"))
(:implicit-vcs :type :vcs :projects
(("lazybones-client" :github :path "cbeo/lazybones-client")))
@@ -28,6 +29,7 @@
(:project :name "lazybones-client" :branch "main" :source :implicit-vcs)
(:project :name "lambda-riffs" :branch "master" :source :implicit-vcs)
(:project :name "lazybones" :branch "master" :source :implicit-vcs)
+(:asd-file :name "oneliners.api-client.asd")
(:asd-file :name "oneliners.api.asd")
@@ -44,12 +46,14 @@
("bordeaux-threads"))
("cffi" :version "2021-04-11" :source "quicklisp" :systems
("cffi" "cffi-grovel" "cffi-toolchain"))
+("chipz" :version "2021-08-07" :source "quicklisp" :systems ("chipz"))
("chunga" :version "2020-04-27" :source "quicklisp" :systems ("chunga"))
("cl+ssl" :version "2021-12-30" :source "quicklisp" :systems ("cl+ssl"))
("cl-annot" :version "2015-06-08" :source "quicklisp" :systems ("cl-annot"))
("cl-base64" :version "2020-10-16" :source "quicklisp" :systems ("cl-base64"))
("cl-change-case" :version "2021-04-11" :source "quicklisp" :systems
("cl-change-case"))
+("cl-cookie" :version "2019-10-07" :source "quicklisp" :systems ("cl-cookie"))
("cl-fad" :version "2021-01-24" :source "quicklisp" :systems ("cl-fad"))
("cl-interpol" :version "2020-12-20" :source "quicklisp" :systems
("cl-interpol"))
@@ -59,8 +63,12 @@
("cl-syntax" :version "2015-04-07" :source "quicklisp" :systems
("cl-syntax" "cl-syntax-annot"))
("cl-unicode" :version "2021-02-28" :source "quicklisp" :systems ("cl-unicode"))
+("cl-utilities" :version "2010-10-07" :source "quicklisp" :systems
+ ("cl-utilities"))
("closer-mop" :version "2021-12-30" :source "quicklisp" :systems ("closer-mop"))
+("dexador" :version "2021-12-09" :source "quicklisp" :systems ("dexador"))
("dissect" :version "2021-05-31" :source "quicklisp" :systems ("dissect"))
+("fast-http" :version "2019-10-07" :source "quicklisp" :systems ("fast-http"))
("fast-io" :version "2020-09-25" :source "quicklisp" :systems ("fast-io"))
("flexi-streams" :version "2021-08-07" :source "quicklisp" :systems
("flexi-streams"))
@@ -77,14 +85,20 @@
:systems ("lazybones-client"))
("lisp-namespace" :version "2021-10-21" :source "quicklisp" :systems
("lisp-namespace"))
+("local-time" :version "2021-01-24" :source "quicklisp" :systems ("local-time"))
("md5" :version "2021-06-30" :source "quicklisp" :systems ("md5"))
("named-readtables" :version "2021-12-09" :source "quicklisp" :systems
("named-readtables"))
+("oneliners.api-client.asd" :version :newest :source :implicit-file :systems
+ ("oneliners.api-client"))
("oneliners.api.asd" :version :newest :source :implicit-file :systems
("oneliners.api" "oneliners.api/tests"))
("proc-parse" :version "2019-08-13" :source "quicklisp" :systems ("proc-parse"))
+("quri" :version "2021-06-30" :source "quicklisp" :systems ("quri"))
("rfc2388" :version "2018-08-31" :source "quicklisp" :systems ("rfc2388"))
("rove" :version "2021-12-09" :source "quicklisp" :systems ("rove"))
+("smart-buffer" :version "2021-10-21" :source "quicklisp" :systems
+ ("smart-buffer"))
("split-sequence" :version "2021-05-31" :source "quicklisp" :systems
("split-sequence"))
("static-vectors" :version "2021-06-30" :source "quicklisp" :systems
@@ -97,6 +111,8 @@
("trivial-garbage"))
("trivial-gray-streams" :version "2021-01-24" :source "quicklisp" :systems
("trivial-gray-streams"))
+("trivial-mimes" :version "2020-07-15" :source "quicklisp" :systems
+ ("trivial-mimes"))
("trivial-types" :version "2012-04-07" :source "quicklisp" :systems
("trivial-types"))
("trivial-utf-8" :version "2021-12-09" :source "quicklisp" :systems
@@ -104,6 +120,7 @@
("unit-test" :version "2012-05-20" :source "quicklisp" :systems ("unit-test"))
("usocket" :version "2019-12-27" :source "quicklisp" :systems ("usocket"))
("uuid" :version "2020-07-15" :source "quicklisp" :systems ("uuid"))
+("xsubseq" :version "2017-08-30" :source "quicklisp" :systems ("xsubseq"))
("yason" :version "2019-12-27" :source "quicklisp" :systems ("yason"))
@@ -114,12 +131,16 @@
:reverse-dependencies
("alexandria" ((:system :name "yason") (:system :name "alexandria"))
((:system :name "static-vectors") (:system :name "alexandria"))
+ ((:system :name "quri") (:system :name "alexandria"))
((:system :name "proc-parse") (:system :name "alexandria"))
((:system :name "lisp-namespace") (:system :name "alexandria"))
((:system :name "lazybones") (:system :name "alexandria"))
((:system :name "hunchentoot") (:system :name "alexandria"))
((:system :name "fast-io") (:system :name "alexandria"))
+ ((:system :name "fast-http") (:system :name "alexandria"))
+ ((:system :name "dexador") (:system :name "alexandria"))
((:system :name "cl-fad") (:system :name "alexandria"))
+ ((:system :name "cl-cookie") (:system :name "alexandria"))
((:system :name "cl-annot") (:system :name "alexandria"))
((:system :name "cl+ssl") (:system :name "alexandria"))
((:system :name "cffi-grovel") (:system :name "alexandria"))
@@ -129,8 +150,11 @@
((:system :name "bknr.datastore") (:system :name "alexandria"))
((:system :name "babel") (:system :name "alexandria")))
-("babel" ((:system :name "proc-parse") (:system :name "babel"))
+("babel" ((:system :name "quri") (:system :name "babel"))
+ ((:system :name "proc-parse") (:system :name "babel"))
((:system :name "jonathan") (:system :name "babel"))
+ ((:system :name "fast-http") (:system :name "babel"))
+ ((:system :name "dexador") (:system :name "babel"))
((:system :name "cffi") (:system :name "babel")))
("bknr-datastore"
@@ -143,6 +167,7 @@
("bordeaux-threads" ((:system :name "rove") (:system :name "bordeaux-threads"))
((:system :name "ironclad") (:system :name "bordeaux-threads"))
((:system :name "hunchentoot") (:system :name "bordeaux-threads"))
+ ((:system :name "dexador") (:system :name "bordeaux-threads"))
((:system :name "cl-fad") (:system :name "bordeaux-threads"))
((:system :name "cl+ssl") (:system :name "bordeaux-threads"))
((:system :name "bknr.utils") (:system :name "bordeaux-threads")))
@@ -154,17 +179,24 @@
((:system :name "cffi-grovel") (:system :name "cffi"))
((:system :name "cffi-grovel") (:system :name "cffi-toolchain")))
-("chunga" ((:system :name "hunchentoot") (:system :name "chunga")))
+("chipz" ((:system :name "dexador") (:system :name "chipz")))
-("cl+ssl" ((:system :name "hunchentoot") (:system :name "cl+ssl")))
+("chunga" ((:system :name "hunchentoot") (:system :name "chunga"))
+ ((:system :name "dexador") (:system :name "chunga")))
+
+("cl+ssl" ((:system :name "hunchentoot") (:system :name "cl+ssl"))
+ ((:system :name "dexador") (:system :name "cl+ssl")))
("cl-annot" ((:system :name "jonathan") (:system :name "cl-annot"))
((:system :name "cl-syntax-annot") (:system :name "cl-annot")))
-("cl-base64" ((:system :name "hunchentoot") (:system :name "cl-base64")))
+("cl-base64" ((:system :name "hunchentoot") (:system :name "cl-base64"))
+ ((:system :name "dexador") (:system :name "cl-base64")))
("cl-change-case" ((:system :name "str") (:system :name "cl-change-case")))
+("cl-cookie" ((:system :name "dexador") (:system :name "cl-cookie")))
+
("cl-fad" ((:system :name "hunchentoot") (:system :name "cl-fad")))
("cl-interpol" ((:system :name "bknr.utils") (:system :name "cl-interpol"))
@@ -176,8 +208,10 @@
((:system :name "lazybones") (:system :name "cl-ppcre"))
((:system :name "jonathan") (:system :name "cl-ppcre"))
((:system :name "hunchentoot") (:system :name "cl-ppcre"))
+ ((:system :name "dexador") (:system :name "cl-ppcre"))
((:system :name "cl-unicode") (:system :name "cl-ppcre"))
((:system :name "cl-ppcre-unicode") (:system :name "cl-ppcre"))
+ ((:system :name "cl-cookie") (:system :name "cl-ppcre"))
((:system :name "cl-change-case") (:system :name "cl-ppcre"))
((:system :name "cl-change-case") (:system :name "cl-ppcre-unicode"))
((:system :name "bknr.utils") (:system :name "cl-ppcre")))
@@ -191,15 +225,24 @@
("cl-unicode" ((:system :name "cl-ppcre-unicode") (:system :name "cl-unicode"))
((:system :name "cl-interpol") (:system :name "cl-unicode")))
+("cl-utilities" ((:system :name "quri") (:system :name "cl-utilities"))
+ ((:system :name "fast-http") (:system :name "cl-utilities")))
+
("closer-mop" ((:system :name "lazybones") (:system :name "closer-mop"))
((:system :name "bknr.indices") (:system :name "closer-mop"))
((:system :name "bknr.datastore") (:system :name "closer-mop")))
+("dexador" ((:system :name "oneliners.api-client") (:system :name "dexador")))
+
("dissect" ((:system :name "rove") (:system :name "dissect")))
-("fast-io" ((:system :name "jonathan") (:system :name "fast-io")))
+("fast-http" ((:system :name "dexador") (:system :name "fast-http")))
+
+("fast-io" ((:system :name "jonathan") (:system :name "fast-io"))
+ ((:system :name "dexador") (:system :name "fast-io")))
("flexi-streams"
+ ((:system :name "smart-buffer") (:system :name "flexi-streams"))
((:system :name "hunchentoot") (:system :name "flexi-streams"))
((:system :name "cl+ssl") (:system :name "flexi-streams"))
((:system :name "bknr.utils") (:system :name "flexi-streams")))
@@ -230,6 +273,8 @@
("lisp-namespace"
((:system :name "lazybones") (:system :name "lisp-namespace")))
+("local-time" ((:system :name "cl-cookie") (:system :name "local-time")))
+
("md5" ((:system :name "hunchentoot") (:system :name "md5"))
((:system :name "bknr.utils") (:system :name "md5")))
@@ -237,17 +282,27 @@
((:system :name "cl-syntax") (:system :name "named-readtables"))
((:system :name "cl-interpol") (:system :name "named-readtables")))
+("oneliners.api-client.asd" (t (:asd-file :name "oneliners.api-client.asd")))
+
("oneliners.api.asd"
((:system :name "oneliners.api/tests") (:system :name "oneliners.api"))
(t (:asd-file :name "oneliners.api.asd")))
-("proc-parse" ((:system :name "jonathan") (:system :name "proc-parse")))
+("proc-parse" ((:system :name "jonathan") (:system :name "proc-parse"))
+ ((:system :name "fast-http") (:system :name "proc-parse"))
+ ((:system :name "cl-cookie") (:system :name "proc-parse")))
+
+("quri" ((:system :name "dexador") (:system :name "quri"))
+ ((:system :name "cl-cookie") (:system :name "quri")))
("rfc2388" ((:system :name "hunchentoot") (:system :name "rfc2388")))
("rove" ((:system :name "oneliners.api/tests") (:system :name "rove")))
-("split-sequence" ((:system :name "usocket") (:system :name "split-sequence")))
+("smart-buffer" ((:system :name "fast-http") (:system :name "smart-buffer")))
+
+("split-sequence" ((:system :name "usocket") (:system :name "split-sequence"))
+ ((:system :name "quri") (:system :name "split-sequence")))
("static-vectors" ((:system :name "fast-io") (:system :name "static-vectors")))
@@ -255,6 +310,7 @@
((:system :name "hunchentoot") (:system :name "trivial-backtrace")))
("trivial-features"
+ ((:system :name "dexador") (:system :name "trivial-features"))
((:system :name "cl+ssl") (:system :name "trivial-features"))
((:system :name "cffi") (:system :name "trivial-features"))
((:system :name "babel") (:system :name "trivial-features")))
@@ -266,9 +322,12 @@
((:system :name "rove") (:system :name "trivial-gray-streams"))
((:system :name "flexi-streams") (:system :name "trivial-gray-streams"))
((:system :name "fast-io") (:system :name "trivial-gray-streams"))
+ ((:system :name "dexador") (:system :name "trivial-gray-streams"))
((:system :name "cl+ssl") (:system :name "trivial-gray-streams"))
((:system :name "chunga") (:system :name "trivial-gray-streams")))
+("trivial-mimes" ((:system :name "dexador") (:system :name "trivial-mimes")))
+
("trivial-types" ((:system :name "jonathan") (:system :name "trivial-types"))
((:system :name "cl-syntax") (:system :name "trivial-types")))
@@ -278,9 +337,13 @@
("unit-test" ((:system :name "bknr.datastore") (:system :name "unit-test")))
("usocket" ((:system :name "hunchentoot") (:system :name "usocket"))
+ ((:system :name "dexador") (:system :name "usocket"))
((:system :name "cl+ssl") (:system :name "usocket")))
("uuid" ((:system :name "oneliners.api") (:system :name "uuid")))
+("xsubseq" ((:system :name "smart-buffer") (:system :name "xsubseq"))
+ ((:system :name "fast-http") (:system :name "xsubseq")))
+
("yason" ((:system :name "bknr.datastore") (:system :name "yason")))
diff --git a/src/main.lisp b/src/main.lisp
index 3c9092d..57cf74d 100644
--- a/src/main.lisp
+++ b/src/main.lisp
@@ -260,7 +260,8 @@
;;; ROUTE VARIABLE AND PARAMATER PARSERS
(defun an-int (string)
- "An Integer")
+ "An Integer"
+ (parse-integer string))
(defun a-csl (s)
"A list of strings separated by commas. e.g. \"foo,bar,goo\""
@@ -281,25 +282,22 @@
(defendpoint* :get "/search" ((commands a-csl)
(keywords a-csl )
(limit an-int)
- (page a-page-key)
+ (pagekey a-page-key)
(nextpage a-boolean)
(notflagged a-boolean)
(onlyaudited a-boolean))
- (:content-type "application/json")
+ ()
"A search endpoint returning a JSON encoded array of Oneliner Entries.
**Note**: either command or keywords are required.
"
(cond
- ;; if page is incluced, ignore everything, fetch the next page,
- ;; and return it.
- (page
+ (pagekey ; return page if present.
(to-json (fetch-next-page page)))
- ;; otherwise one of command keywords are required
- ((or commands keywords)
+ ((or commands keywords) ; else search for oneliners
(let* ((limit
- (or limit 10)) ; default-limit, should probably be configurable.
+ (or limit 10)) ;TODO: no magic numbers
(results
(query-oneliners :commands commands
:keywords keywords
@@ -313,19 +311,19 @@
:page (make-next-page limit (nthcdr limit results))
:oneliners limited-results)
(list :oneliners limited-results)))))
- ;; if neither command nor keywords were supplied, return a 400
- (t
+
+ (t ; else responde with 400
(http-err 400))))
-(defendpoint* :put "/oneliner/:oneliner object-with-id:" () (:auth t)
- "Updates a oneliner entry in the wiki database."
- (cond
- (oneliner
- (update-oneliner (request-contributor)
- oneliner
- (lzb:request-body))
- "true")
- (t (http-err 404))))
+;; (defendpoint* :put "/oneliner/:oneliner object-with-id:" () (:auth t)
+;; "Updates a oneliner entry in the wiki database."
+;; (cond
+;; (oneliner
+;; (update-oneliner (request-contributor)
+;; oneliner
+;; (lzb:request-body))
+;; "true")
+;; (t (http-err 404))))
(defendpoint* :post "/oneliner" () (:auth t)
"Adds a new oneliner entry to the wiki database."
@@ -333,8 +331,8 @@
"{}" ; dummy implementation
(http-err 400)))
-(defendpoint* :post "/auth" () ()
- "Requests an authorization token")
+;; (defendpoint* :post "/auth" () ()
+;; "Requests an authorization token")
;;; HELPERS
@@ -421,27 +419,32 @@ names. NAME must be a symbol or a string."
(reduce #'intersection (mapcar #'oneliners-by-command commands)))
(defun query-oneliners (&key commands keywords notflagged onlyaudited)
- (if commands
- (remove-if-not
- #$(and (not (and notflagged (flagged-by $ol)))
- (or (not onlyaudited) (audited-by $ol))
- (or (null keywords) (oneliner-mentions-any $ol keywords)))
- (oneliners-with-all-commands command))
- (remove-if-not
- #$(and (not (and notflagged (flagged-by $ol)))
- (or (not onlyaudited) (audited-by $ol)))
- (oneliners-from-keywords keywords))))
-
-(defun oneliners-from-keywords (keywords)
- (error "TBD"))
+ (print "in query-oneliners")
+ (print (list :commands commands :keywords keywords :notflagged notflagged :onlyaudited onlyaudited))
+ nil)
+
+;; (defun query-oneliners (&key commands keywords notflagged onlyaudited)
+;; (if commands
+;; (remove-if-not
+;; #$(and (not (and notflagged (flagged-by $ol)))
+;; (or (not onlyaudited) (audited-by $ol))
+;; (or (null keywords) (oneliner-mentions-any $ol keywords)))
+;; (oneliners-with-all-commands command))
+;; (remove-if-not
+;; #$(and (not (and notflagged (flagged-by $ol)))
+;; (or (not onlyaudited) (audited-by $ol)))
+;; (oneliners-from-keywords keywords))))
+
+;; (defun oneliners-from-keywords (keywords)
+;; (error "TBD"))
(defun to-json (thing)
(let ((jonathan:*false-value* :false)
(jonathan:*null-value* :null))
(jonathan:to-json thing)))
-(defun request-contributor ()
- (a:when-let (access (access-by-token (lzb:request-cookie +auth-cookie-name+)))
- (api-contributor access)))
-
+;; (defun request-contributor ()
+;; (a:when-let (access (access-by-token (lzb:request-cookie +auth-cookie-name+)))
+;; (api-contributor access)))
+