Changeset 15967 in project


Ignore:
Timestamp:
09/19/09 15:53:09 (10 years ago)
Author:
sjamaan
Message:

Add central registry hook for wiki file update actions; hook up search

Location:
release/4/qwiki/trunk
Files:
2 edited

Legend:

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

    r15909 r15967  
    3535
    3636(module qwiki-search
    37         (search-install! search-server-uri wiki-page->estraier-doc
    38          add-file-to-index!)
     37        (search-install! search-server-uri wiki-page->estraier-doc)
    3938
    4039(import chicken scheme)
    41 (use data-structures extras srfi-1 intarweb uri-common
     40(use data-structures extras srfi-1 srfi-13 intarweb uri-common
    4241     wiki-parse qwiki qwiki-sxml sxml-transforms estraier-client)
    4342
     
    8685    (values (reverse! contents) attribs)))
    8786
    88 (define (add-file-to-index! file)
    89   (let*-values (((page) (call-with-input-file file wiki-parse))
    90                 ((contents attribs) (wiki-page->estraier-doc page))
    91                 ((attribs) (alist-update! '@uri file attribs)))
     87(define (update-search-entry! path page)
     88  (let*-values (((contents attribs) (wiki-page->estraier-doc page))
     89                ((attribs) (alist-update! '@uri (string-join path "/") attribs)))
    9290    (put-document (search-server-uri) "qwiki" contents attribs)))
     91
     92(define (remove-search-entry! path)
     93  (delete-document (search-server-uri) uri: (string-join path "/")))
    9394
    9495(define search-rules
     
    142143  (qwiki-global-action-handlers (cons `(search . ,search)
    143144                                      (qwiki-global-action-handlers)))
    144   (qwiki-extensions (cons search-rules (qwiki-extensions))))
     145  (qwiki-extensions (cons search-rules (qwiki-extensions)))
     146  (qwiki-update-handlers (cons update-search-entry! (qwiki-update-handlers))))
    145147
    146148)
  • release/4/qwiki/trunk/qwiki.scm

    r15909 r15967  
    4242   qwiki-edit
    4343   qwiki-history
    44    qwiki-render-file
    4544   qwiki-transformation-steps
    4645   qwiki-extensions
     
    4847   qwiki-global-action-handlers
    4948   qwiki-page-action-handlers
     49   qwiki-update-handlers
    5050   send-content)
    5151
     
    7171
    7272(define qwiki-extensions
     73  (make-parameter (list)))
     74
     75(define qwiki-update-handlers
    7376  (make-parameter (list)))
    7477
     
    269272               source-file rev wiki-parse)))
    270273            (begin
    271              (update-html-file! (make-pathname (root-path) html-file)
    272                                 source-file)
     274              (when (or (not (file-exists? html-file))
     275                        (file-newer? source-file html-file))
     276                (update-file! path))
    273277             (send-static-file html-file)))
    274278        (redirect-to-qwiki-page req action: "edit"))))
     
    278282
    279283;; Generate new cached HTML file
    280 (define (update-html-file! html-file source-file #!optional force-update)
    281   (when (or force-update
    282             (not (file-exists? html-file))
    283             (file-newer? source-file html-file))
     284(define (regenerate-html-file! path page)
     285  (let ((html-file (make-pathname (root-path) (path->html-filename path))))
    284286    (with-output-to-path html-file
    285287      (lambda ()
    286         (let ((content (qwiki-sxml-page-template
    287                         (call-with-input-file source-file wiki-parse))))
     288        (let ((content (qwiki-sxml-page-template page)))
    288289          (output-xml content (qwiki-transformation-steps content)))))))
     290
     291(define (update-file! path)
     292  (let* ((source-file (path->source-filename path))
     293         (page (call-with-input-file source-file wiki-parse)))
     294    (for-each (lambda (handler) (handler path page))
     295              (cons regenerate-html-file! (qwiki-update-handlers)))))
    289296
    290297;;; Request dispatching
     
    336343                      (current-request)))))))
    337344
    338 (define (qwiki-render-file file)
    339   (call-with-input-file file
    340     (lambda (input)
    341       (let ((content (qwiki-sxml-page-template (wiki-parse input))))
    342         (output-xml content (qwiki-transformation-steps content))))))
    343 
    344345)
Note: See TracChangeset for help on using the changeset viewer.