diff options
-rw-r--r-- | web/view/markdown.scm | 19 | ||||
-rwxr-xr-x | web/webserver.scm | 10 |
2 files changed, 14 insertions, 15 deletions
diff --git a/web/view/markdown.scm b/web/view/markdown.scm index 59eb8b8..e6d595d 100644 --- a/web/view/markdown.scm +++ b/web/view/markdown.scm @@ -56,15 +56,15 @@ (br) (br)))) -(define (fetch-file repo query_path) - (let* ( (abs_path (string-append repo "/" query_path))) - (if (file-exists? abs_path) (let* ((full_path (canonicalize-path abs_path)) - (content (call-with-input-file full_path get-string-all)) +(define (fetch-file repo query-path) + (let* ( (abs-path (string-append repo "/" query-path))) + (if (file-exists? abs-path) (let* ((full-path (canonicalize-path abs-path)) + (content (call-with-input-file full-path get-string-all)) (commit-sha (get-latest-commit-sha1 repo))) - `(("file_path" . ,query_path) + `(("file_path" . ,query-path) ("content" . ,content) ("hash" . ,commit-sha)) - ) (throw 'file-error (string-append "the file path " abs_path " does not exists"))))) + ) (throw 'file-error (string-append "the file path " abs-path " does not exists"))))) (define (git-invoke repo-path . args) (apply system* "git" "-C" repo-path args)) @@ -80,10 +80,9 @@ commit-sha)) (define* (commit-file repo file-path content commit-message username email #:optional (prev-commit "")) - (if (string=? prev-commit (get-latest-commit-sha1 repo)) - #t - (throw 'system-error (format #f "Commits do no match.Please pull in latest changes for current * ~a * and prev * ~a * " - (get-latest-commit-sha1 repo) prev-commit))) + (unless (string=? prev-commit (get-latest-commit-sha1 repo)) + (throw 'system-error (format #f "Commits do no match.Please pull in latest changes for current * ~a * and prev * ~a * " + (get-latest-commit-sha1 repo) prev-commit))) (if (is-repo? repo) (match (file-exists? (string-append repo "/" file-path)) (#t diff --git a/web/webserver.scm b/web/webserver.scm index 0dcb5f8..ded9997 100755 --- a/web/webserver.scm +++ b/web/webserver.scm @@ -129,10 +129,10 @@ otherwise search for set/group data" (lambda (port) (format port "~a" "foo")))) -(define (build-json-response status_code json) +(define (build-json-response status-code json) (list (build-response - #:code status_code + #:code status-code #:headers `((content-type . (application/json)))) (lambda (port) (scm->json json port)))) @@ -157,9 +157,9 @@ otherwise search for set/group data" (define (edit-file-handler repo request) (catch 'file-error (lambda () - (let* ((params (decode-query (uri-query (request-uri request)))) (query_path (assoc-ref params 'file_path))) - (if query_path - (build-json-response 400 (fetch-file repo query_path)) + (let* ((params (decode-query (uri-query (request-uri request)))) (query-path (assoc-ref params 'file_path))) + (if query-path + (build-json-response 400 (fetch-file repo query-path)) (throw 'file-error (string-append "Please provide a valid file path in the query"))))) (lambda (key . args) (let ((msg (car args))) (build-json-response 400 `(("error" . ,key) ("msg" . ,msg))))))) |