Skip to content

Commit 4995ee9

Browse files
committed
add 'no-navigation style property and revise "PLT root" strategy
1 parent b7f361e commit 4995ee9

File tree

4 files changed

+65
-16
lines changed

4 files changed

+65
-16
lines changed

scribble-doc/scribblings/scribble/base.scrbl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ path, it is converted to a string using
9191
@racket[module-path-prefix->string]. Similarly, if @racket[tag-prefix]
9292
is a hash table with @racket['tag-prefix] mapped to a module path,
9393
then it is replaced with a hash table where @racket['tag-prefix] is
94-
mapped to a string.
94+
mapped to a string. When @racket[tag-prefix] as a hash table is
95+
used for the main part in a document rendered by @exec{raco setup},
96+
@exec{raco setup} uses some keys to configure the document's
97+
rendering; see @racket[scribblings] in @secref[#:doc '(lib
98+
"scribblings/raco/raco.scrbl") "setup-info"] for more information.
9599

96100
The @racket[vers] argument is propagated to the @racket[title-decl]
97101
structure. Use @racket[""] as @racket[vers] to suppress version
@@ -729,7 +733,8 @@ the section hyperlink's resolution in HTML is potentially delayed; see
729733
element?]{
730734

731735
Like @racket[secref] for the document's implicit @racket["top"]
732-
tag. Use this function to refer to a whole manual instead of
736+
tag that @exec{raco setup} adds to every document that it renders.
737+
Use this function to refer to a whole manual instead of
733738
@racket[secref], in case a special style in the future is used for
734739
manual titles.
735740

scribble-doc/scribblings/scribble/core.scrbl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,9 @@ each key in the table, the value in the table is merged with the
370370
context from enclosing parts. A value is merged by adding the key and
371371
value to the accumulation if the key is not yet present, or by
372372
@racket[cons]ing the new value to the context's current value when the
373-
key is present. Use @racket[current-part-context-accumulation] during
373+
key is present. For example, the key @racket['index-extras] is used
374+
to merge with an @racket[index-desc] within a discovered @racket[index-element].
375+
Use @racket[current-part-context-accumulation] during
374376
the @techlink{collect pass} or @techlink{resolve pass} to retrieve the
375377
value that has been accumulated from enclosing parts.
376378

@@ -390,7 +392,11 @@ The @racket[tag-prefix] field determines the optional @techlink{tag
390392
prefix} for the part and/or @techlink{part context} accumulation. When
391393
@racket[tag-prefix] is a hash table, the value associated with the
392394
@racket['tag-prefix] key is used as the tag prefix when the value
393-
is a string.
395+
is a string. When @racket[tag-prefix] as a hash table is
396+
used for the main part in a document rendered by @exec{raco setup},
397+
@exec{raco setup} uses recognizes some keys to configure the document's
398+
rendering; see @racket[scribblings] in @secref[#:doc '(lib
399+
"scribblings/raco/raco.scrbl") "setup-info"] for more information.
394400

395401
The @racket[tags] indicates a list of @techlink{tags} that each link
396402
to the section. Normally, @racket[tags] should be a non-empty list, so
@@ -480,6 +486,11 @@ The recognized @tech{style properties} are as follows:
480486
document, causes the HTML output to not include an ``on this
481487
page'' margin box.}
482488

489+
@item{@indexed-racket['no-navigation] --- As a @tech{style property}
490+
for the main part of a rendered page, causes the HTML output to
491+
not include ``top,'' ``up,'', ``prev,'' and ``next'' controls
492+
if they would otherwise apply.}
493+
483494
@item{@indexed-racket['no-header-controls] --- Suppresses link and
484495
link-information icons (if any) as part of a section header in
485496
HTML output.}
@@ -590,7 +601,8 @@ The @racket[parts] field contains sub-parts.
590601
#:changed "1.27" @elem{Added @racket['no-toc+aux] support.}
591602
#:changed "1.54" @elem{Changed @racket[tag-prefix] field to allow a
592603
@tech{part context} hash table.}
593-
#:changed "1.57" @elem{Added @racket['no-header-controls] support.}]}
604+
#:changed "1.57" @elem{Added @racket['no-header-controls] support.}
605+
#:changed "1.59" @elem{Added @racket['no-navigation] support.}]}
594606

595607

596608
@defstruct[paragraph ([style style?] [content content?])]{

scribble-lib/scribble/html-render.rkt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@
239239
[placeholder ,emptylabel]
240240
[title "Enter a search string to search the manuals"]
241241
[onkeypress ,(format "return DoSearchKey(event, this, ~s, ~s);"
242-
(version) top-path)])))))
242+
(get-installation-name) top-path)])))))
243243
(define search-box (make-search-box "../"))
244244
(define top-search-box (make-search-box ""))
245245

@@ -290,6 +290,7 @@
290290
;; user start page). If it's a path, then it's also
291291
;; used for the "top" link on the page.
292292
[up-path #f]
293+
[search-up-path up-path]
293294
[script-path #f]
294295
[script-file #f]
295296
[search-box? #f])
@@ -1029,7 +1030,7 @@
10291030
"up" (if (path? up-path)
10301031
(url->string* (path->url up-path))
10311032
"../index.html")
1032-
`[onclick . ,(format "return GotoPLTRoot(\"~a\");" (version))]))
1033+
`[onclick . ,(format "return GotoPLTRoot(\"~a\");" (get-installation-name))]))
10331034
(define tocset-toggle
10341035
(make-element "tocsettoggle"
10351036
(list
@@ -1041,14 +1042,15 @@
10411042
'([title . "show/hide table of contents"]
10421043
[onclick . "TocsetToggle();"]))))
10431044
"contents"))))
1045+
(define no-nav? (and (memq 'no-navigation (style-properties (part-style d))) #t))
10441046
(define navleft
10451047
`(span ([class "navleft"])
10461048
,@(if search-box?
1047-
(list (if up-path search-box top-search-box))
1049+
(list (if search-up-path search-box top-search-box))
10481050
(list `(div ([class "nosearchform"]))))
10491051
,@(render
10501052
sep-element
1051-
(and up-path (make-element top-link top-content))
1053+
(and up-path (not no-nav?) (make-element top-link top-content))
10521054
tocset-toggle
10531055
;; sep-element
10541056
;; (make-element
@@ -1060,7 +1062,7 @@
10601062
;; (make-link-element #f index-content (car (part-tags/nonempty index))))
10611063
)))
10621064
(define navright
1063-
(if (not (or parent up-path next))
1065+
(if (or (not (or parent up-path next)) no-nav?)
10641066
""
10651067
`(span ([class "navright"])
10661068
,@(render

scribble-lib/scribble/scribble-common.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
// Page Parameters ------------------------------------------------------------
44

5+
var plt_root_as_query = false;
6+
57
function GetURL() {
68
return new URL(location);
79
}
@@ -19,16 +21,20 @@ function GetPageArg(key, def) {
1921
}
2022

2123
function MergePageArgsIntoLink(a) {
22-
if (GetPageArgs().size === 0 || !a.dataset.pltdoc) return;
24+
if ((GetPageArgs().size === 0 || !a.dataset.pltdoc) && !plt_root_as_query) return;
2325
a.href = MergePageArgsIntoUrl(a.href);
2426
}
2527

2628
function MergePageArgsIntoUrl(href) {
2729
const url = new URL(href, window.location.href);
2830
for (const [key, val] of GetPageArgs()) {
31+
if (key[0] == "q") continue; // use "q" to mean "don't propagate automatcially"
2932
if (url.searchParams.has(key)) continue;
3033
url.searchParams.append(key, val)
3134
}
35+
if (plt_root_as_query && !url.searchParams.has("PLT_Root")) {
36+
url.searchParams.append("PLT_Root", plt_root_as_query);
37+
}
3238
return url.href;
3339
}
3440

@@ -72,28 +78,52 @@ function SetCookie(key, val) {
7278

7379
// note that this always stores a directory name, ending with a "/"
7480
function SetPLTRoot(ver, relative) {
75-
var root = location.protocol + "//" + location.host
76-
+ NormalizePath(location.pathname.replace(/[^\/]*$/, relative));
77-
SetCookie("PLT_Root."+ver, root);
81+
var root = location.protocol + "//" + location.host
82+
+ NormalizePath(location.pathname.replace(/[^\/]*$/, relative));
83+
if (location.protocol == "file:") {
84+
// local storage or cookies are not going to work in modern browsers,
85+
// so add a query parameter to all URLs
86+
plt_root_as_query=root
87+
} else {
88+
SetCookie("PLT_Root."+ver, root);
89+
}
7890
}
7991

8092
// adding index.html works because of the above
8193
function GotoPLTRoot(ver, relative) {
94+
var famroot = (GetPageArg("fam", false) ? GetPageArg("famroot", false) : false)
8295
var u = GetRootPath(ver);
83-
if (u == null) return true; // no cookie: use plain up link
96+
if (u == null) {
97+
// no cookie: use plain up link
98+
if (famroot) {
99+
location = MergePageArgsIntoUrl("../" + famroot + "/index.html");
100+
return false;
101+
}
102+
return true;
103+
}
84104
// the relative path is optional, default goes to the toplevel start page
85105
if (!relative) relative = "index.html";
86-
location = u + relative;
106+
if (relative == "index.html" && famroot) {
107+
relative = famroot + "/index.html";
108+
}
109+
location = MergePageArgsIntoUrl(u + relative);
87110
return false;
88111
}
89112

90113
function GetRootPath(ver) {
91114
var u = GetCookie("PLT_Root."+ver, null);
92115
if (u != null)
93116
return u;
117+
118+
// via query argument? (especially for `file://` URLs)
119+
u = GetPageArg("PLT_Root", null)
120+
if (u != null)
121+
return u;
122+
94123
// use root specified by local-redirect wrapper, if present
95124
if (typeof user_doc_root != "undefined")
96125
return user_doc_root;
126+
97127
return null;
98128
}
99129

0 commit comments

Comments
 (0)