Lots of changes to the cmap stuff
This commit is contained in:
+32
-1
@@ -342,6 +342,12 @@ CSS
|
||||
(λ (_session)
|
||||
(json-response (hash 'conceptMaps (list-concept-maps config))))))
|
||||
|
||||
(define (concept-usage-handler config req)
|
||||
(require-role
|
||||
config req 'reader
|
||||
(λ (_session)
|
||||
(json-response (hash 'placements (list-concept-usage config))))))
|
||||
|
||||
(define (request-concept-map-document body)
|
||||
(define document (hash-ref body 'document #f))
|
||||
(unless (hash? document)
|
||||
@@ -400,6 +406,14 @@ CSS
|
||||
(json-response result)
|
||||
(json-error 404 "Concept map version not found")))))
|
||||
|
||||
(define (concept-map-version-delete-handler config req slug version)
|
||||
(require-write-role
|
||||
config req 'editor
|
||||
(lambda (_session)
|
||||
(if (delete-concept-map-version! config slug version)
|
||||
(json-response (hash 'ok #t))
|
||||
(json-error 404 "Concept map history item not found")))))
|
||||
|
||||
(define (concept-map-update-handler config req slug)
|
||||
(require-write-role
|
||||
config req 'editor
|
||||
@@ -414,12 +428,25 @@ CSS
|
||||
(define document (request-concept-map-document body))
|
||||
(define base-version (hash-ref body 'baseVersion ""))
|
||||
(define snapshot? (eq? (hash-ref body 'snapshot #f) #t))
|
||||
(define supplied-save-kind (hash-ref body 'saveKind #f))
|
||||
(define supplied-summary (hash-ref body 'summary "Edited CMap"))
|
||||
(define summary
|
||||
(if (and (string? supplied-summary)
|
||||
(not (string=? (string-trim supplied-summary) "")))
|
||||
(substring supplied-summary 0 (min 500 (string-length supplied-summary)))
|
||||
"Edited CMap"))
|
||||
(define action
|
||||
(cond
|
||||
(snapshot? "snapshot")
|
||||
((member supplied-save-kind '("autosave" "manual" "snapshot"))
|
||||
supplied-save-kind)
|
||||
((not supplied-save-kind)
|
||||
;; Compatibility with the client version from before saveKind was
|
||||
;; explicit. Known automatic summaries must not enter history.
|
||||
(if (member summary '("Automatic save" "Automatisch opgeslagen"))
|
||||
"autosave"
|
||||
"manual"))
|
||||
(else (error 'concept-map-update-handler "invalid save kind"))))
|
||||
(json-response
|
||||
(update-concept-map! config
|
||||
slug
|
||||
@@ -428,7 +455,7 @@ CSS
|
||||
(wiki-user-username (wiki-session-user session))
|
||||
base-version
|
||||
summary
|
||||
(if snapshot? "snapshot" "edit")))))))
|
||||
action))))))
|
||||
|
||||
(define (concept-map-rename-handler config req slug)
|
||||
(require-write-role
|
||||
@@ -998,12 +1025,16 @@ CSS
|
||||
(λ (req) (concept-map-list-handler config req))]
|
||||
[("api" "cmaps") #:method "post"
|
||||
(λ (req) (concept-map-create-handler config req))]
|
||||
[("api" "cmaps" "concept-usage") #:method "get"
|
||||
(λ (req) (concept-usage-handler config req))]
|
||||
[("api" "cmaps" (string-arg)) #:method "get"
|
||||
(λ (req slug) (concept-map-get-handler config req slug))]
|
||||
[("api" "cmaps" (string-arg) "history") #:method "get"
|
||||
(λ (req slug) (concept-map-history-handler config req slug))]
|
||||
[("api" "cmaps" (string-arg) "versions" (string-arg)) #:method "get"
|
||||
(λ (req slug version) (concept-map-version-handler config req slug version))]
|
||||
[("api" "cmaps" (string-arg) "versions" (string-arg)) #:method "delete"
|
||||
(λ (req slug version) (concept-map-version-delete-handler config req slug version))]
|
||||
[("api" "cmaps" (string-arg)) #:method "put"
|
||||
(λ (req slug) (concept-map-update-handler config req slug))]
|
||||
[("api" "cmaps" (string-arg) "rename") #:method "post"
|
||||
|
||||
Reference in New Issue
Block a user