Changeset 15909 in project


Ignore:
Timestamp:
09/15/09 23:07:22 (10 years ago)
Author:
sjamaan
Message:

Add page-action/global-action hooks
Add a start for the qwiki search page

Location:
release/4/qwiki/trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • release/4/qwiki/trunk/qwiki.scm

    r15504 r15909  
    4646   qwiki-extensions
    4747   qwiki-output-driver
    48    )
     48   qwiki-global-action-handlers
     49   qwiki-page-action-handlers
     50   send-content)
    4951
    5052(import chicken scheme)
     
    287289
    288290;;; Request dispatching
    289 (define action-handlers
    290   `((edit    . ,qwiki-edit)
    291     (show    . ,qwiki-show)
    292     (history . ,qwiki-history)))
     291(define qwiki-page-action-handlers
     292  (make-parameter
     293   `((edit    . ,qwiki-edit)
     294     (show    . ,qwiki-show)
     295     (history . ,qwiki-history))))
     296
     297(define qwiki-global-action-handlers
     298  (make-parameter (list)))
    293299
    294300(define (read-request-data req)
     
    313319  (ensure-latest-sources!)
    314320  (let ((uri (request-uri (current-request))))
    315     (if (any impossible-filename? (cdr (uri-path uri))) ; assumed to be absolute
    316         (begin
    317           (read-request-data (current-request))
    318           (send-status 404 "Not found"))
    319         (let* ((action (string->symbol
    320                         (alist-ref 'action (uri-query uri) eq? "show")))
    321                (handler (alist-ref action action-handlers eq? qwiki-show)))
    322           (handler (normalize-path (relative-uri-path uri))
    323                    (current-request))))))
     321    (cond
     322     ((find (lambda (a)
     323              (equal? (uri-path uri) (list '/ (->string (car a)))))
     324            (qwiki-global-action-handlers))
     325      => (lambda (handler)
     326           ((cdr handler) (current-request))))
     327     ((any impossible-filename? (cdr (uri-path uri))) ; assumed to be absolute
     328      (read-request-data (current-request))
     329      (send-status 404 "Not found"))
     330     (else (let* ((action (string->symbol
     331                           (alist-ref 'action (uri-query uri) eq? "show")))
     332                  (handler (alist-ref action
     333                                      (qwiki-page-action-handlers)
     334                                      eq? qwiki-show)))
     335             (handler (normalize-path (relative-uri-path uri))
     336                      (current-request)))))))
    324337
    325338(define (qwiki-render-file file)
Note: See TracChangeset for help on using the changeset viewer.