feat: update HTTP handlers for shelf model
This commit is contained in:
@@ -403,11 +403,11 @@ Set by test harnesses that only need the model functions.")
|
||||
|
||||
(defservlet index text/html (path query request)
|
||||
(let* ((books (spine-books))
|
||||
(filter (cadr (assoc "filter" query))))
|
||||
(shelf-filter (cadr (assoc "shelf" query))))
|
||||
(if books
|
||||
(insert (spine-render "index.mustache"
|
||||
(spine-index-model books filter (cadr (assoc "id" query)))))
|
||||
(insert (spine-render-empty-state)))))
|
||||
(spine-index-model books shelf-filter (cadr (assoc "id" query)))))
|
||||
(insert (spine-render-empty-state))))
|
||||
|
||||
(defun httpd/add (proc uri-path query request)
|
||||
"Handle /add: GET shows form, POST creates a book."
|
||||
@@ -417,7 +417,7 @@ Set by test harnesses that only need the model functions.")
|
||||
(spine-add-book
|
||||
:title (cadr (assoc "title" query))
|
||||
:author (cadr (assoc "author" query))
|
||||
:category (cadr (assoc "category" query))
|
||||
:shelf (cadr (assoc "shelf" query))
|
||||
:format (cadr (assoc "format" query))
|
||||
:isbn (cadr (assoc "isbn" query))
|
||||
:cover (cadr (assoc "cover" query))
|
||||
@@ -430,17 +430,18 @@ Set by test harnesses that only need the model functions.")
|
||||
(let* ((books (spine-books))
|
||||
(model (if books
|
||||
(spine-add-form-model books)
|
||||
(ht ("app_title" "spine")))))
|
||||
(ht ("app_title" "spine" "shelves" '())))))
|
||||
(insert (spine-render "add.mustache" model)))))))
|
||||
|
||||
|
||||
(defun httpd/edit (proc uri-path query request)
|
||||
"Handle /edit: GET shows prompt page, POST processes actions.
|
||||
Query params:
|
||||
id - book ID
|
||||
action - status | note | rating
|
||||
value - target status / rating value (for status/rating actions)
|
||||
action - note | rating
|
||||
text - note text (for note action)
|
||||
date - optional date string (for note/read actions)"
|
||||
date - optional date string (for note action)
|
||||
value - rating value (for rating action)"
|
||||
(let ((method (caar request))
|
||||
(id (cadr (assoc "id" query)))
|
||||
(action (cadr (assoc "action" query)))
|
||||
@@ -452,8 +453,6 @@ Query params:
|
||||
(cond
|
||||
((equal action "note")
|
||||
(spine-add-note id text date))
|
||||
((equal action "status")
|
||||
(spine-set-status id value))
|
||||
((equal action "rating")
|
||||
(spine-set-rating id value)))
|
||||
(httpd-redirect proc (format "/index?id=%s" id) 303))
|
||||
|
||||
Reference in New Issue
Block a user