|
@ -17,6 +17,21 @@ |
|
|
(close-output-port conf) |
|
|
(close-output-port conf) |
|
|
(new-config path))) |
|
|
(new-config path))) |
|
|
|
|
|
|
|
|
|
|
|
(define valid-config-keys |
|
|
|
|
|
; The list of all valid configuration keys |
|
|
|
|
|
; i.e. what you can put on the left side of an = in your config |
|
|
|
|
|
(list |
|
|
|
|
|
"password" |
|
|
|
|
|
"username" |
|
|
|
|
|
"url" |
|
|
|
|
|
"blog-location")) |
|
|
|
|
|
|
|
|
|
|
|
(define (valid-key? key) |
|
|
|
|
|
; Check if a key is in the list of valid ones |
|
|
|
|
|
(memv |
|
|
|
|
|
(curry equal? key) |
|
|
|
|
|
valid-config-keys)) |
|
|
|
|
|
|
|
|
(define (new-config path) |
|
|
(define (new-config path) |
|
|
(with-handlers |
|
|
(with-handlers |
|
|
([exn:fail:filesystem:errno? (curry create-config path)]) |
|
|
([exn:fail:filesystem:errno? (curry create-config path)]) |
|
@ -29,14 +44,12 @@ |
|
|
#:unless (string=? line "")) |
|
|
#:unless (string=? line "")) |
|
|
(match (map string-trim |
|
|
(match (map string-trim |
|
|
(string-split line "=")) |
|
|
(string-split line "=")) |
|
|
[(list "password" password) |
|
|
[(list key val) |
|
|
(hash-set! config 'password password)] |
|
|
(cond |
|
|
[(list "username" username) |
|
|
[(valid-key? key) (hash-set! config (string->symbol key) val)] |
|
|
(hash-set! config 'username username)] |
|
|
[else |
|
|
[(list "url" url) |
|
|
(error |
|
|
(hash-set! config 'url url)] |
|
|
(format "Invalid configuration line: ~a" val))])])) |
|
|
[val (error |
|
|
|
|
|
(format "Invalid configuration line: ~a" val))])) |
|
|
|
|
|
(curry hash-ref config)))) |
|
|
(curry hash-ref config)))) |
|
|
|
|
|
|
|
|
; The current list of commits (as a dynamically scoped name) |
|
|
; The current list of commits (as a dynamically scoped name) |
|
@ -246,7 +259,10 @@ |
|
|
key |
|
|
key |
|
|
val))) |
|
|
val))) |
|
|
|
|
|
|
|
|
(parameterize ([current-commits (get-commits)]) |
|
|
;(parameterize ([current-commits (get-commits)]) |
|
|
|
|
|
|
|
|
|
|
|
; Run when a commit of one or more posts occurs |
|
|
|
|
|
(define (commit-posts) |
|
|
(for ([post (get-files)]) |
|
|
(for ([post (get-files)]) |
|
|
(match (git-href post #f) |
|
|
(match (git-href post #f) |
|
|
[#f |
|
|
[#f |
|
@ -258,3 +274,11 @@ |
|
|
(let ([post-id (commit->post-id post commit-id)]) |
|
|
(let ([post-id (commit->post-id post commit-id)]) |
|
|
(git-set! post post-id) |
|
|
(git-set! post post-id) |
|
|
(handle-post post post-id))]))) |
|
|
(handle-post post post-id))]))) |
|
|
|
|
|
|
|
|
|
|
|
(provide |
|
|
|
|
|
git-href |
|
|
|
|
|
git-set! |
|
|
|
|
|
commit-posts |
|
|
|
|
|
new-config |
|
|
|
|
|
get-commits |
|
|
|
|
|
current-commits) |
|
|