aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.lisp81
1 files changed, 42 insertions, 39 deletions
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)))
+