From 064c3c9326ab915a23fc535e992255892dc869ee Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sun, 24 Jun 2007 06:20:17 +0000 Subject: [PATCH] scribble: add toc on each HTML page svn: r6725 original commit: a6cff46fae5702de4034bfed1184343cf1b218b7 --- collects/scribble/html-render.ss | 63 +++++++++++++++++++------------- collects/scribble/scribble.css | 31 +++++++++++++++- 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 5f6b924e..ea2dcc25 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -65,7 +65,40 @@ ;; ---------------------------------------- (define/public (render-toc-view d ht) - null) + (let-values ([(top mine) + (let loop ([d d][mine d]) + (let ([p (collected-info-parent (part-collected-info d))]) + (if p + (loop p d) + (values d mine))))]) + `((div ((class "tocview")) + (div ((class "tocviewtitle")) + (a ((href "index.html") + (class "tocviewlink")) + ,@(render-content (part-title-content top) d ht))) + (div nbsp) + (div + ((class "tocviewlist")) + ,@(map (lambda (p) + `(div + ((class "tocviewitem")) + (a ((href ,(let ([dest (lookup p ht `(part ,(part-tag p)))]) + (format "~a~a~a" + (from-root (car dest) + (get-dest-directory)) + (if (caddr dest) + "" + "#") + (if (caddr dest) + "" + `(part ,(part-tag p)))))) + (class ,(if (eq? p mine) + "tocviewselflink" + "tocviewlink"))) + ,@(format-number (collected-info-number (part-collected-info p)) + '((tt nbsp))) + ,@(render-content (part-title-content p) d ht)))) + (part-parts top))))))) (define/public (render-one-part d ht fn number) (parameterize ([current-output-file fn]) @@ -81,8 +114,8 @@ (type "text/css") (href "scribble.css") (title "default")))) - (body (div ((class "main")) ,@(render-part d ht)) - ,@(render-toc-view d ht)))]) + (body ,@(render-toc-view d ht) + (div ((class "main")) ,@(render-part d ht))))]) (install-file scribble-css) (xml:write-xml/content (xml:xexpr->xml xpr))))) @@ -267,8 +300,7 @@ (class % (inherit render-one render-one-part - render-content - lookup) + render-content) (define/override (get-suffix) #"") @@ -288,27 +320,6 @@ (error "file name too long (need a tag):" fn)) fn)) - #; - (define/override (render-toc-view d ht) - (let-values ([(top mine) - (let loop ([d d][mine d]) - (let ([p (collected-info-parent (part-collected-info d))]) - (if p - (loop p d) - (values d mine))))]) - `((div ((class "tocview")) - (div ((class "tocviewtitle")) - ,@(render-content (part-title-content top) d ht)) - (ul - ((class "tocviewlist")) - ,@(map (lambda (p) - `(li (a ((href ,(let ([dest (lookup p ht `(part ,(part-tag p)))]) - (from-root (car dest) - (get-dest-directory)))) - (class "tocviewlink")) - ,@(render-content (part-title-content p) d ht)))) - (part-parts top))))))) - (define/override (collect ds fns) (super collect ds (map (lambda (fn) (build-path fn "index.html")) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index c383615a..baf1058e 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -5,7 +5,7 @@ font-family: Times; text-align: center; width: 35em; - margin-left: auto; + margin-left: 13em; margin-right: auto; } @@ -38,6 +38,35 @@ border: 0.5em solid #F5F5DC; } + .tocview { + position: relative; + float: left; + width: 10em; + margin: 0em 0em 0em -12em; + text-align: left; + background-color: #ddffdd; + } + + .tocviewtitle { + font-size: 80%; + font-weight: bold; + margin: 0.2em 0.2em 0.2em 0.2em; + } + + .tocviewlist { + font-size: 80%; + margin: 0.2em 0.2em 0.2em 0.2em; + } + + .tocviewitem { + margin-left: 1em; + text-indent: -1em; + } + + .tocviewlink { + text-decoration: none; + } + .leftindent { margin-left: 1em; margin-right: 0em;