summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Andy Wingo2008-02-12 23:09:55 +0100
committerGravatar Andy Wingo2008-02-12 23:09:55 +0100
commit8c52717d5dab16eb628b823ffad914d44761459b (patch)
tree519a5823096d5b7164c6f520330173cfe7554f9c /src
parentda58b954769ecfda8c167fe4644d26ce7e974f0b (diff)
downloadtekuti-8c52717d5dab16eb628b823ffad914d44761459b.tar.gz
tekuti-8c52717d5dab16eb628b823ffad914d44761459b.zip
redo reindexing to be more erlangy
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tekuti66
1 files changed, 38 insertions, 28 deletions
diff --git a/src/tekuti b/src/tekuti
index c3dccfa..2873ff6 100755
--- a/src/tekuti
+++ b/src/tekuti
@@ -39,33 +39,43 @@ exec guile $GUILE_FLAGS -l $0 -e main "$@"
(tekuti mod-lisp)
(tekuti web))
-(define (handle-request headers post-data)
- (let ((heads (fetch-heads `(posts . ,reindex-posts)
- `(categories . ,reindex-categories))))
- (let-headers
- headers ((method "method") (path "url"))
- (url-relative-path-case
- method path
- ((POST admin new-post)
- (unimplemented 'new-post))
- ((POST admin modify-post)
- (unimplemented 'modify-post))
- ((POST admin new-comment)
- (unimplemented 'new-comment))
- ((POST admin delete-comment)
- (unimplemented 'delete-comment))
- ((POST admin delete-post)
- (unimplemented 'delete-post))
- ((GET)
- (unimplemented 'index))
- ((GET archives year? month? day? post?)
- (unimplemented 'archives))
- ((GET debug)
- (page-debug headers))
- ((POST search)
- (unimplemented 'search))
- (else (page-not-found path))))))
-
+(define (handle-request headers post-data index)
+ (let-headers headers ((method "method") (path "url"))
+ (url-relative-path-case
+ method path
+ ((POST admin new-post)
+ (unimplemented 'new-post))
+ ((POST admin modify-post)
+ (unimplemented 'modify-post))
+ ((POST admin new-comment)
+ (unimplemented 'new-comment))
+ ((POST admin delete-comment)
+ (unimplemented 'delete-comment))
+ ((POST admin delete-post)
+ (unimplemented 'delete-post))
+ ((GET)
+ (unimplemented 'index))
+ ((GET archives year? month? day? post?)
+ (unimplemented 'archives))
+ ((GET debug)
+ (page-debug headers))
+ ((POST search)
+ (unimplemented 'search))
+ (else (page-not-found path)))))
+
+(define (maybe-reindex old-master old-index)
+ (let ((master (git-rev-parse "master")))
+ (values
+ master
+ (if (equal? master old-master)
+ old-index
+ (acons 'master master
+ (map (lambda (k reindex)
+ (cons k (reindex master)))
+ (list 'posts 'categories)
+ (list reindex-posts reindex-categories)))))))
+
(define (main args)
(ensure-git-repo)
- (event-loop handle-request))
+ (event-loop handle-request maybe-reindex))
+