commit 4b14761f296e50d080007f15ac57a0137b0ba50b
parent 3a464717531b4a9d084eb3c11d4aaf5aabb32aa1
Author: Sam Tobin-Hochstadt <samth@racket-lang.org>
Date: Wed, 25 Nov 2009 02:30:41 +0000
checkpoint
svn: r17054
original commit: e3bafbe298688ec0efe47a09254492f93027fa71
Diffstat:
5 files changed, 111 insertions(+), 21 deletions(-)
diff --git a/collects/scribble/doc/lang/reader.ss b/collects/scribble/doc/lang/reader.ss
@@ -8,4 +8,6 @@
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
+ [(drscheme:toolbar-buttons)
+ (dynamic-require 'scribble/tools/drscheme-buttons 'drscheme-buttons)]
[else defval])))
diff --git a/collects/scribble/html-render.ss b/collects/scribble/html-render.ss
@@ -359,7 +359,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")]
+ [pltdoc "x"])
,@(render-content (or (part-title-content t) '("???")) d ri)))
(format-number (collected-info-number (part-collected-info t ri))
'(nbsp))))
@@ -528,7 +529,8 @@
,(cond
[(part? p) "tocsubseclink"]
[any-parts? "tocsubnonseclink"]
- [else "tocsublink"])])
+ [else "tocsublink"])]
+ [pltdoc "x"])
,@(render-content
(if (part? p)
(or (part-title-content p)
@@ -607,8 +609,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"])
@@ -616,7 +618,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)))
@@ -705,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
@@ -987,7 +991,8 @@
[else
;; Normal link:
(dest->url dest)]))
- ,@(attribs)]
+ ,@(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))))
diff --git a/collects/scribble/manual/lang/reader.ss b/collects/scribble/manual/lang/reader.ss
@@ -10,6 +10,8 @@ scribble/manual/lang
(case key
[(color-lexer)
(dynamic-require 'syntax-color/scribble-lexer 'scribble-inside-lexer)]
+ [(drscheme:toolbar-buttons)
+ (dynamic-require 'scribble/tools/drscheme-buttons 'drscheme-buttons)]
[else (default key defval)]))
(require (prefix-in scribble: "../../reader.ss"))
diff --git 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,40 @@ 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 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) && 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;
+ 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 +80,12 @@ 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("<style>mynoscript { display:none; }</style>");
+
+// Interactions ---------------------------------------------------------------
+
function DoSearchKey(event, field, ver, top_path) {
var val = field.value;
if (event && event.keyCode == 13) {
@@ -55,13 +97,41 @@ 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";
glyph.innerHTML = expand ? "▼" : "►";
}
-// `noscript' is problematic in some browsers (always renders as a
-// block), use this hack instead (does not always work!)
-// document.write("<style>mynoscript { display:none; }</style>");
+// 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<on_load_funcs.length; i++) on_load_funcs[i]();
+};
+
+var cur_plt_lang = GetArgFromURL(location,"lang");
+
+function PropagateLangInLink(a) {
+ // the attribute's value doesn't matter
+ if (cur_plt_lang
+ && a.attributes["pltdoc"] && a.attributes["pltdoc"].value != ""
+ && !GetArgFromURL(a,"lang"))
+ SetArgInURL(a, "lang", cur_plt_lang);
+}
+
+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<links.length; i++) PropagateLangInLink(links[i]);
+ });
diff --git 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
+}