|
281 | 281 | extract-version |
282 | 282 | extract-authors |
283 | 283 | extract-pretitle |
| 284 | + extend-part-context |
284 | 285 | link-render-style-at-element) |
285 | 286 | (inherit-field prefix-file style-file style-extra-files image-preferences) |
286 | 287 |
|
|
1025 | 1026 | `([title . ,(if title* (string-append label " to " title*) label)] |
1026 | 1027 | [data-pltdoc . "x"] |
1027 | 1028 | ,@more))))) |
| 1029 | + (define no-nav? (and (memq 'no-navigation (style-properties (part-style d))) #t)) |
| 1030 | + (define family-nav? (and (memq 'family-navigation (style-properties (part-style d))) #t)) |
| 1031 | + (define fam (and family-nav? |
| 1032 | + (or (search-extras (hash-ref (extend-part-context d) 'index-extras #hasheq()) 'language-family) |
| 1033 | + '("Racket")))) |
| 1034 | + (define (wrap-family c) |
| 1035 | + (if family-nav? |
| 1036 | + `((div ([style "display: none;"] |
| 1037 | + [class "family-navigation"] |
| 1038 | + [data-familynav ,(string-join fam ",")]) |
| 1039 | + ,@c)) |
| 1040 | + c)) |
1028 | 1041 | (define top-link |
1029 | 1042 | (titled-url |
1030 | | - "up" (if (path? up-path) |
1031 | | - (url->string* (path->url up-path)) |
1032 | | - "../index.html") |
1033 | | - `[onclick . ,(format "return GotoPLTRoot(\"~a\");" (get-installation-name))])) |
| 1043 | + "up" (cond |
| 1044 | + [(path? up-path) (url->string* (path->url up-path))] |
| 1045 | + [up-path "../index.html"] |
| 1046 | + [else "index.html"]) |
| 1047 | + `[onclick . ,(format "return GotoPLTRoot(\"~a\", \"index.html\", \"~a\");" |
| 1048 | + (get-installation-name) |
| 1049 | + (if up-path |
| 1050 | + "../" |
| 1051 | + ""))])) |
1034 | 1052 | (define tocset-toggle |
1035 | 1053 | (make-element "tocsettoggle" |
1036 | 1054 | (list |
|
1042 | 1060 | '([title . "show/hide table of contents"] |
1043 | 1061 | [onclick . "TocsetToggle();"])))) |
1044 | 1062 | "contents")))) |
1045 | | - (define no-nav? (and (memq 'no-navigation (style-properties (part-style d))) #t)) |
1046 | 1063 | (define navleft |
1047 | 1064 | `(span ([class "navleft"]) |
1048 | 1065 | ,@(if search-box? |
1049 | 1066 | (list (if search-up-path search-box top-search-box)) |
1050 | 1067 | (list `(div ([class "nosearchform"])))) |
1051 | | - ,@(render |
1052 | | - sep-element |
1053 | | - (and up-path (not no-nav?) (make-element top-link top-content)) |
1054 | | - tocset-toggle |
1055 | | - ;; sep-element |
1056 | | - ;; (make-element |
1057 | | - ;; (if parent (make-target-url "index.html" #f) "nonavigation") |
1058 | | - ;; contents-content) |
1059 | | - ;; sep-element |
1060 | | - ;; (if (or (not index) (eq? d index)) |
1061 | | - ;; (make-element "nonavigation" index-content) |
1062 | | - ;; (make-link-element #f index-content (car (part-tags/nonempty index)))) |
1063 | | - ))) |
| 1068 | + ,@(wrap-family |
| 1069 | + (render |
| 1070 | + sep-element |
| 1071 | + (and (or up-path family-nav?) (not no-nav?) (make-element top-link top-content)) |
| 1072 | + tocset-toggle |
| 1073 | + ;; sep-element |
| 1074 | + ;; (make-element |
| 1075 | + ;; (if parent (make-target-url "index.html" #f) "nonavigation") |
| 1076 | + ;; contents-content) |
| 1077 | + ;; sep-element |
| 1078 | + ;; (if (or (not index) (eq? d index)) |
| 1079 | + ;; (make-element "nonavigation" index-content) |
| 1080 | + ;; (make-link-element #f index-content (car (part-tags/nonempty index)))) |
| 1081 | + )))) |
1064 | 1082 | (define navright |
1065 | | - (if (or (not (or parent up-path next)) no-nav?) |
1066 | | - "" |
1067 | | - `(span ([class "navright"]) |
1068 | | - ,@(render |
1069 | | - ;; put space here for text browsers and to avoid an Opera issue |
1070 | | - sep-element |
1071 | | - (make-element |
1072 | | - (cond [(not parent) "nonavigation"] |
1073 | | - [prev (titled-url "backward" prev '[rel . "prev"])] |
1074 | | - [else (titled-url "backward" "index.html" '[rel . "prev"] |
1075 | | - #:title-from |
1076 | | - (and (part? parent) parent))]) |
1077 | | - prev-content) |
1078 | | - sep-element |
1079 | | - (make-element |
1080 | | - (cond |
1081 | | - [(and (part? parent) (toc-part? parent ri) |
1082 | | - (part-parent parent ri)) |
1083 | | - (titled-url "up" parent)] |
1084 | | - [parent (titled-url "up" "index.html" #:title-from parent)] |
1085 | | - ;; up-path = #t => go up to the start page, using |
1086 | | - ;; cookies to get to the user's version of it (see |
1087 | | - ;; scribblings/main/private/utils for the code that |
1088 | | - ;; creates these cookies.) |
1089 | | - [(eq? #t up-path) top-link] |
1090 | | - [up-path (titled-url "up" up-path)] |
1091 | | - [else "nonavigation"]) |
1092 | | - up-content) |
1093 | | - sep-element |
1094 | | - (make-element |
1095 | | - (if next (titled-url "forward" next '[rel . "next"]) "nonavigation") |
1096 | | - next-content))))) |
| 1083 | + (if (or (not (or parent up-path next family-nav?)) no-nav?) |
| 1084 | + "" |
| 1085 | + `(span ([class "navright"]) |
| 1086 | + ,@(wrap-family |
| 1087 | + (render |
| 1088 | + ;; put space here for text browsers and to avoid an Opera issue |
| 1089 | + sep-element |
| 1090 | + (make-element |
| 1091 | + (cond [(not parent) "nonavigation"] |
| 1092 | + [prev (titled-url "backward" prev '[rel . "prev"])] |
| 1093 | + [else (titled-url "backward" "index.html" '[rel . "prev"] |
| 1094 | + #:title-from |
| 1095 | + (and (part? parent) parent))]) |
| 1096 | + prev-content) |
| 1097 | + sep-element |
| 1098 | + (make-element |
| 1099 | + (cond |
| 1100 | + [(and (part? parent) (toc-part? parent ri) |
| 1101 | + (part-parent parent ri)) |
| 1102 | + (titled-url "up" parent)] |
| 1103 | + [parent |
| 1104 | + (titled-url "up" "index.html" #:title-from parent)] |
| 1105 | + ;; up-path = #t => go up to the start page using |
| 1106 | + ;; query or cookies to get to the user's version of it (see |
| 1107 | + ;; scribblings/main/private/utils for the code that |
| 1108 | + ;; creates these cookies.) |
| 1109 | + [(or (eq? #t up-path) family-nav?) |
| 1110 | + top-link] |
| 1111 | + [up-path (titled-url "up" up-path)] |
| 1112 | + [else "nonavigation"]) |
| 1113 | + up-content) |
| 1114 | + sep-element |
| 1115 | + (make-element |
| 1116 | + (if next (titled-url "forward" next '[rel . "next"]) "nonavigation") |
| 1117 | + next-content)))))) |
1097 | 1118 | (define navbar |
1098 | 1119 | `(div ([class ,(if top? "navsettop" "navsetbottom")]) |
1099 | 1120 | ,navleft ,navright nbsp)) ; need nbsp to make the navset bg visible |
|
2167 | 2188 | (string-append "file://" (path->string p)) |
2168 | 2189 | (url->string (path->url p)))) |
2169 | 2190 | (url->string (path->url p)))) |
| 2191 | + |
| 2192 | +(define (search-extras extras-tree key) |
| 2193 | + (cond |
| 2194 | + [(hash? extras-tree) (hash-ref extras-tree key #f)] |
| 2195 | + [(pair? extras-tree) (or (search-extras (car extras-tree) key) |
| 2196 | + (search-extras (cdr extras-tree) key))] |
| 2197 | + [else #f])) |
0 commit comments