From ff82cc48c3898dd75256ab6ee0542b04d9aba3ca Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 23 Nov 2009 22:56:28 +0000 Subject: [PATCH 01/10] Scribble HTML renderer: mark internal links with 'extra-internal-attribs' svn: r17018 original commit: 1dd2109909937385c3783a6e49bb16af09b8f097 --- collects/scribble/html-render.ss | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 2932141d..fcef5642 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -43,6 +43,8 @@ ,@(map (lambda (x) (if (string? x) x (format "~a" x))) body) "\n")))) +(define (extra-internal-attribs) null) + (define-runtime-path scribble-css "scribble.css") (define-runtime-path scribble-style-css "scribble-style.css") (define-runtime-path scribble-prefix-html "scribble-prefix.html") @@ -359,7 +361,8 @@ `((a ([href ,(dest->url (resolve-get t ri (car (part-tags t))))] [class ,(if (or (eq? t d) (and show-mine? (memq t toc-chain))) "tocviewselflink" - "tocviewlink")]) + "tocviewlink")] + ,@(extra-internal-attribs)) ,@(render-content (or (part-title-content t) '("???")) d ri))) (format-number (collected-info-number (part-collected-info t ri)) '(nbsp)))) @@ -528,7 +531,8 @@ ,(cond [(part? p) "tocsubseclink"] [any-parts? "tocsubnonseclink"] - [else "tocsublink"])]) + [else "tocsublink"])] + ,@(extra-internal-attribs)) ,@(render-content (if (part? p) (or (part-title-content p) @@ -987,7 +991,8 @@ [else ;; Normal link: (dest->url dest)])) - ,@(attribs)] + ,@(attribs) + ,@(extra-internal-attribs)] ,@(if (empty-content? (element-content e)) (render-content (strip-aux (dest-title dest)) part ri) (render-content (element-content e) part ri)))) From d1fb3165976ceef63f200c27c61c49b70127e4a0 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 02:17:53 +0000 Subject: [PATCH 02/10] add attribute value for internal links svn: r17020 original commit: 37a1ada7a2661e38b44a595610f1ada30f8968e7 --- collects/scribble/html-render.ss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index fcef5642..fcbe1009 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -43,7 +43,7 @@ ,@(map (lambda (x) (if (string? x) x (format "~a" x))) body) "\n")))) -(define (extra-internal-attribs) null) +(define (extra-internal-attribs) '([pltdoc "x"])) (define-runtime-path scribble-css "scribble.css") (define-runtime-path scribble-style-css "scribble-style.css") From f164cbb789a862dc8654b0eface7e916ad89df59 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 06:45:26 +0000 Subject: [PATCH 03/10] url parameter utilities svn: r17026 original commit: cdf940fedd38a817f6a4ee02a245058942599b60 --- collects/scribble/scribble-common.js | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index bfd8711f..1db79c96 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -1,5 +1,7 @@ // Common functionality for PLT documentation pages +// Cookies -------------------------------------------------------------------- + function GetCookie(key, def) { if (document.cookie.length <= 0) return def; var i, cookiestrs = document.cookie.split(/; */); @@ -36,6 +38,38 @@ function GotoPLTRoot(ver, relative) { return false; } +// URL Parameters ------------------------------------------------------------- + +// In the following functions, the `name' argument is assumed to be simple in +// that it doesn't contain anything that isn't plain text in a regexp. (This +// is because I don't know if there's a JS `regexp-quote' thing). Also, the +// output value from the Get functions and the input value to the Set functions +// is not decoded/encoded. Note that `SetArgInURL' mutates the string. + +function GetArgFromString(str, name) { + var rx = new RegExp("(?:^|[;&])"+name+"=([^&;]*)(?:[;&]|$)"); + return rx.test(str) && RegExp.$1; +} + +function SetArgInString(str, name, val) { + if (str.length == 0) return name + "=" + val; + var rx = new RegExp("^((?:|.*[;&])"+name+"=)(?:[^&;]*)([;&].*|)$"); + if (rx.test(str)) return RegExp.$1 + val + RegExp.$2; + else return name + "=" + val + "&" + str; +} + +function GetArgFromURL(url, name) { + if (!url.href.search(/\?([^#]*)(?:#|$)/)) return false; + return GetArgFromString(RegExp.$1, name); +} + +function SetArgInURL(url, name, val) { // note: mutates the string + url.href.search(/^([^?#]*)(?:\?([^#]*))?(#.*)?$/); + url.href = RegExp.$1 + "?" + SetArgInString(RegExp.$2,name,val) + RegExp.$3; +} + +// Utilities ------------------------------------------------------------------ + normalize_rxs = [/\/\/+/g, /\/\.(\/|$)/, /\/[^\/]*\/\.\.(\/|$)/]; function NormalizePath(path) { var tmp, i; @@ -44,6 +78,8 @@ function NormalizePath(path) { return path; } +// Interactions --------------------------------------------------------------- + function DoSearchKey(event, field, ver, top_path) { var val = field.value; if (event && event.keyCode == 13) { From dc3ada6fdc80944ba30d4d09545c5a72ce3ec587 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 06:50:02 +0000 Subject: [PATCH 04/10] use escape/unescape on the value strings svn: r17027 original commit: d94903ec535ded18f1e889356c261b792323ff5c --- collects/scribble/scribble-common.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index 1db79c96..e5304172 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -42,16 +42,18 @@ function GotoPLTRoot(ver, relative) { // In the following functions, the `name' argument is assumed to be simple in // that it doesn't contain anything that isn't plain text in a regexp. (This -// is because I don't know if there's a JS `regexp-quote' thing). Also, the -// output value from the Get functions and the input value to the Set functions -// is not decoded/encoded. Note that `SetArgInURL' mutates the string. +// is because JS doesn't have a `regexp-quote', easy to hack but not needed +// here). Also, the output value from the Get functions and the input value to +// the Set functions is decoded/encoded. Note that `SetArgInURL' mutates the +// string in the url object. function GetArgFromString(str, name) { var rx = new RegExp("(?:^|[;&])"+name+"=([^&;]*)(?:[;&]|$)"); - return rx.test(str) && RegExp.$1; + return rx.test(str) && unescape(RegExp.$1); } function SetArgInString(str, name, val) { + val = escape(val); if (str.length == 0) return name + "=" + val; var rx = new RegExp("^((?:|.*[;&])"+name+"=)(?:[^&;]*)([;&].*|)$"); if (rx.test(str)) return RegExp.$1 + val + RegExp.$2; From 6ca3facd598f9e0e973f99735476acfc9d7b25d4 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 09:11:09 +0000 Subject: [PATCH 05/10] Make it possible to register multiple onload handlers. (Needed because all pages must have an onload, and the search page needs an additional initialization function.) svn: r17032 original commit: 142d33d67f3e7e67e5c613fbbb81beb842b299ba --- collects/scribble/html-render.ss | 4 ++-- collects/scribble/scribble-common.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index fcbe1009..1e36b257 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -611,8 +611,8 @@ (list style-file) style-extra-files)) ,(scribble-js-contents script-file (lookup-path script-file alt-paths))) - (body ((id ,(or (extract-part-body-id d ri) - "scribble-plt-scheme-org"))) + (body ([id ,(or (extract-part-body-id d ri) + "scribble-plt-scheme-org")]) ,@(render-toc-view d ri) (div ([class "maincolumn"]) (div ([class "main"]) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index e5304172..4ff914dc 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -80,6 +80,10 @@ function NormalizePath(path) { return path; } +// `noscript' is problematic in some browsers (always renders as a +// block), use this hack instead (does not always work!) +// document.write(""); + // Interactions --------------------------------------------------------------- function DoSearchKey(event, field, ver, top_path) { @@ -100,6 +104,13 @@ function TocviewToggle(glyph,id) { glyph.innerHTML = expand ? "▼" : "►"; } -// `noscript' is problematic in some browsers (always renders as a -// block), use this hack instead (does not always work!) -// document.write(""); +// Page Init ------------------------------------------------------------------ + +// Note: could make a function that inspects and uses window.onload to chain to +// a previous one, but this file needs to be required first anyway, since it +// contains utilities for all other files. +var on_load_funcs = []; +function AddOnLoad(fun) { on_load_funcs.push(fun); } +window.onload = function() { + for (var i=0; i Date: Tue, 24 Nov 2009 12:33:15 +0000 Subject: [PATCH 06/10] A `lang' parameter gets carried through the pages. svn: r17037 original commit: 825a47dfefde43fb64dc29266c4ed6cdf971f0f9 --- collects/scribble/scribble-common.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index 4ff914dc..4695375d 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -97,7 +97,7 @@ function DoSearchKey(event, field, ver, top_path) { return true; } -function TocviewToggle(glyph,id) { +function TocviewToggle(glyph, id) { var s = document.getElementById(id).style; var expand = s.display == "none"; s.display = expand ? "block" : "none"; @@ -114,3 +114,19 @@ function AddOnLoad(fun) { on_load_funcs.push(fun); } window.onload = function() { for (var i=0; i Date: Tue, 24 Nov 2009 13:34:12 +0000 Subject: [PATCH 07/10] CSS for the langindicator widget svn: r17038 original commit: 62c744613b126f48c810997a80e6b307cd58a83e --- collects/scribble/scribble.css | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/collects/scribble/scribble.css b/collects/scribble/scribble.css index c610d0dc..cb71c09c 100644 --- a/collects/scribble/scribble.css +++ b/collects/scribble/scribble.css @@ -77,14 +77,14 @@ table td { padding: 0.25em 0 0.25em 0; } -.navsettop { - margin-bottom: 1.5em; - border-bottom: 2px solid #e0e0c0; +.navsettop { + margin-bottom: 1.5em; + border-bottom: 2px solid #e0e0c0; } -.navsetbottom { - margin-top: 2em; - border-top: 2px solid #e0e0c0; +.navsetbottom { + margin-top: 2em; + border-top: 2px solid #e0e0c0; } .navleft { @@ -119,6 +119,18 @@ table td { vertical-align: middle; } +#langindicator { + position: fixed; + background-color: #c6f; + color: #000; + font-family: monospace; + font-weight: bold; + padding: 2px 10px; + display: none; + right: 0; + bottom: 0; +} + /* ---------------------------------------- */ /* Version */ @@ -224,11 +236,11 @@ table td { padding-left: 0.8em; } .tocviewsublist { - margin-bottom: 1em; + margin-bottom: 1em; } -.tocviewsublist table, +.tocviewsublist table, .tocviewsublistonly table, -.tocviewsublisttop table, +.tocviewsublisttop table, .tocviewsublistbottom table { font-size: 75%; } @@ -411,4 +423,4 @@ i { .author { display: inline; white-space: nowrap; -} \ No newline at end of file +} From 5190646f366dc3d4c02aa98be3d7485ca68a0358 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 13:37:04 +0000 Subject: [PATCH 08/10] use the langindicator when there's a lang parameter svn: r17039 original commit: bd1ba85221eaa7a31a72672af3d998e84f8b5f21 --- collects/scribble/scribble-common.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/collects/scribble/scribble-common.js b/collects/scribble/scribble-common.js index 4695375d..13b1dfa0 100644 --- a/collects/scribble/scribble-common.js +++ b/collects/scribble/scribble-common.js @@ -127,6 +127,11 @@ function PropagateLangInLink(a) { AddOnLoad(function(){ if (!cur_plt_lang) return; + var indicator = document.getElementById("langindicator"); + if (indicator) { + indicator.innerHTML = cur_plt_lang; + indicator.style.display = "block"; + } var links = document.getElementsByTagName("a"); for (var i=0; i Date: Tue, 24 Nov 2009 13:38:15 +0000 Subject: [PATCH 09/10] add the indicator div svn: r17040 original commit: 210ef8c4f1d843ba746aa28806703ed61a2997c8 --- collects/scribble/html-render.ss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 1e36b257..246cb59d 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -620,7 +620,8 @@ (render-version d ri)) ,@(navigation d ri #t) ,@(render-part d ri) - ,@(navigation d ri #f))))))))))) + ,@(navigation d ri #f))) + (div ([id "langindicator"]) nbsp))))))))) (define/private (part-parent d ri) (collected-info-parent (part-collected-info d ri))) From 37ad00fc1bea7aff2e7296d300b8473f03a9012f Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Tue, 24 Nov 2009 14:17:48 +0000 Subject: [PATCH 10/10] Remove `extra-internal-attribs' and just use the value directly. (Renaming it is the same as renaming a variable anyway.) Add the attribute to the navigation links. svn: r17041 original commit: 7feecb4d2cd43e9407c70beff5a61f3333eebe35 --- collects/scribble/html-render.ss | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss index 246cb59d..0acb2aff 100644 --- a/collects/scribble/html-render.ss +++ b/collects/scribble/html-render.ss @@ -43,8 +43,6 @@ ,@(map (lambda (x) (if (string? x) x (format "~a" x))) body) "\n")))) -(define (extra-internal-attribs) '([pltdoc "x"])) - (define-runtime-path scribble-css "scribble.css") (define-runtime-path scribble-style-css "scribble-style.css") (define-runtime-path scribble-prefix-html "scribble-prefix.html") @@ -362,7 +360,7 @@ [class ,(if (or (eq? t d) (and show-mine? (memq t toc-chain))) "tocviewselflink" "tocviewlink")] - ,@(extra-internal-attribs)) + [pltdoc "x"]) ,@(render-content (or (part-title-content t) '("???")) d ri))) (format-number (collected-info-number (part-collected-info t ri)) '(nbsp)))) @@ -532,7 +530,7 @@ [(part? p) "tocsubseclink"] [any-parts? "tocsubnonseclink"] [else "tocsublink"])] - ,@(extra-internal-attribs)) + [pltdoc "x"]) ,@(render-content (if (part? p) (or (part-title-content p) @@ -710,6 +708,7 @@ (make-target-url url) (make-attributes `([title . ,(if title* (string-append label " to " title*) label)] + [pltdoc . "x"] ,@more))))) (define top-link (titled-url @@ -993,7 +992,7 @@ ;; Normal link: (dest->url dest)])) ,@(attribs) - ,@(extra-internal-attribs)] + [pltdoc "x"]] ,@(if (empty-content? (element-content e)) (render-content (strip-aux (dest-title dest)) part ri) (render-content (element-content e) part ri))))