Ticket #197: qwiki-titles.diff

File qwiki-titles.diff, 2.6 KB (added by sjamaan, 14 years ago)

Add titles to "view" pages

  • qwiki.scm

     
    5858
    5959(import chicken scheme)
    6060(use extras files posix ports data-structures srfi-1 srfi-13 srfi-14
    61      intarweb uri-common spiffy sxml-transforms
     61     intarweb uri-common spiffy sxml-transforms sxpath
    6262     wiki-parse qwiki-sxml doctype
    6363     ;; There should be a way to parameterize the versioning implementation
    6464     qwiki-svn)
     
    297297    (if (file-exists? source-file)
    298298        (if rev
    299299            (send-content ; Do not store if old rev
    300              (qwiki-sxml-page-template
    301               (call-with-input-revision
    302                source-file rev wiki-parse)))
     300             (let* ((sxml (call-with-input-revision source-file rev wiki-parse))
     301                    (title ((sxpath '(// (Section 1) *text*)) (cons 'root sxml))))
     302               (qwiki-sxml-page-template
     303                sxml `((title . ,(sprintf "~A (historical revision ~A)"
     304                                          (if (null? title)
     305                                              path
     306                                              (car title))
     307                                          rev))))))
    303308            (begin
    304309              (when (or (not (file-exists? html-path))
    305310                        (file-newer? source-file html-path))
     
    312317
    313318;; Generate new cached HTML file
    314319(define (regenerate-html-file! path page)
    315   (let ((html-file (make-pathname (qwiki-web-path) (path->html-filename path))))
     320  (let* ((html-file (make-pathname (qwiki-web-path) (path->html-filename path)))
     321         (title ((sxpath '(// (Section 1) *text*)) (cons 'root page))))
    316322    (with-output-to-path html-file
    317323      (lambda ()
    318         (let ((content (qwiki-sxml-page-template page)))
     324        (let ((content (qwiki-sxml-page-template
     325                        page `((title . ,(if (null? title)
     326                                             path
     327                                             (car title)))))))
    319328          (output-xml content (qwiki-transformation-steps content)))))))
    320329
    321330(define (qwiki-update-file! path)
  • qwiki.meta

     
    11((synopsis "qwiki - the quick wiki")
    22 (depends matchable wiki-parse intarweb uri-common spiffy (doctype "1.2")
    3           (sxml-transforms "1.4") multidoc (svn-client "0.11") estraier-client)
     3          (sxml-transforms "1.4") multidoc (svn-client "0.11") estraier-client
     4          sxpath)
    45 (author "Peter Bex")
    56 (category www)
    67 (license "BSD")