Debian Codegraph @

xslt/mallard/html/mal2html-page.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
3 This program is free software; you can redistribute it and/or modify it under
4 the terms of the GNU Lesser General Public License as published by the Free
5 Software Foundation; either version 2 of the License, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:mal="http://projectmallard.org/1.0/"
19 xmlns:ui="http://projectmallard.org/ui/1.0/"
20 xmlns:uix="http://projectmallard.org/experimental/ui/"
21 xmlns:e="http://projectmallard.org/experimental/"
22 xmlns:exsl="http://exslt.org/common"
23 xmlns:set="http://exslt.org/sets"
24 xmlns:msg="http://projects.gnome.org/yelp/gettext/"
25 xmlns="http://www.w3.org/1999/xhtml"
26 exclude-result-prefixes="mal ui uix e exsl set msg"
27 version="1.0">
28
29 <!--!!==========================================================================
30 Mallard to HTML - Pages
31 Handle pages, sections, and top-level data.
32 @revision[version=3.8 date=2012-11-05 status=final]
33
34 This stylesheet contains templates to process Mallard `page` and `section`
35 elements, including implementations of the interfaces provided by the common
36 {html} stylesheet.
37 -->
38 <xsl:template match="/">
39 <xsl:for-each select="mal:page | mal:stack/mal:page">
40 <xsl:call-template name="html.output"/>
41 </xsl:for-each>
42 </xsl:template>
43
44
45 <!--@@==========================================================================
46 mal2html.editor_mode
47 Add information that's useful to writers and editors.
48 @revision[version=3.8 date=2012-11-05 status=final]
49
50 When this parameter is set to true, these stylesheets will output editorial
51 comments, status markers, and other information that's useful to writers and
52 editors.
53 -->
54 <xsl:param name="mal2html.editor_mode" select="false()"/>
55
56
57 <!--**==========================================================================
58 mal2html.page.about
59 Output the copyrights, credits, and license information at the bottom of a page.
60 @revision[version=3.8 date=2012-11-05 status=final]
61
62 [xsl:params]
63 $node: The top-level `page` element.
64
65 This template outputs copyright information, credits, and license information for
66 the page. By default it is called by the {html.footer.mode} implementation for
67 the `page` element. Information is extracted from the `info` element of $node.
68 -->
69 <xsl:template name="mal2html.page.about">
70 <xsl:param name="node" select="."/>
71 <xsl:variable name="infos" select="$node/mal:info | $node/parent::mal:stack/mal:info"/>
72 <xsl:if test="$infos/mal:credit or $infos/mal:license">
73 <div class="about ui-expander" role="contentinfo">
74 <div class="yelp-data yelp-data-ui-expander" data-yelp-expanded="false"/>
75 <div class="inner">
76 <div class="hgroup">
77 <h2>
78 <span class="title">
79 <xsl:call-template name="l10n.gettext">
80 <xsl:with-param name="msgid" select="'About'"/>
81 </xsl:call-template>
82 </span>
83 </h2>
84 </div>
85 <div class="region">
86 <div class="contents">
87 <xsl:variable name="credits" select="$infos/mal:credit"/>
88 <xsl:variable name="copyrights"
89 select="$credits[contains(concat(' ', @type, ' '), ' copyright ')]
90 [mal:years]"/>
91 <xsl:if test="$copyrights">
92 <div class="copyrights">
93 <xsl:for-each select="$copyrights">
94 <div class="copyright">
95 <xsl:call-template name="l10n.gettext">
96 <xsl:with-param name="msgid" select="'copyright.format'"/>
97 <xsl:with-param name="node" select="."/>
98 <xsl:with-param name="format" select="true()"/>
99 </xsl:call-template>
100 </div>
101 </xsl:for-each>
102 </div>
103 </xsl:if>
104 <xsl:variable name="authors"
105 select="$credits[contains(concat(' ', @type, ' '), ' author ')]"/>
106 <xsl:variable name="editors"
107 select="$credits[contains(concat(' ', @type, ' '), ' editor ')]"/>
108 <xsl:variable name="maintainers"
109 select="$credits[contains(concat(' ', @type, ' '), ' maintainer ')]"/>
110 <xsl:variable name="translators"
111 select="$credits[contains(concat(' ', @type, ' '), ' translator ')]"/>
112 <xsl:variable name="publishers"
113 select="$credits[contains(concat(' ', @type, ' '), ' publisher ')]"/>
114 <!-- others doesn't exclude all copyrights, just credits that are only copyrights -->
115 <xsl:variable name="others"
116 select="set:difference($credits,
117 $authors | $editors | $maintainers | $translators | $publishers)
118 [not(@type = 'copyright' and mal:years)]"/>
119 <xsl:if test="$authors or $editors or $maintainers or
120 $translators or publishers or $others">
121 <div class="credits">
122 <xsl:call-template name="_mal2html.page.about.credits">
123 <xsl:with-param name="class" select="'credits-authors'"/>
124 <xsl:with-param name="title" select="'Written By'"/>
125 <xsl:with-param name="credits" select="$authors"/>
126 </xsl:call-template>
127 <xsl:call-template name="_mal2html.page.about.credits">
128 <xsl:with-param name="class" select="'credits-editors'"/>
129 <xsl:with-param name="title" select="'Edited By'"/>
130 <xsl:with-param name="credits" select="$editors"/>
131 </xsl:call-template>
132 <xsl:call-template name="_mal2html.page.about.credits">
133 <xsl:with-param name="class" select="'credits-maintainers'"/>
134 <xsl:with-param name="title" select="'Maintained By'"/>
135 <xsl:with-param name="credits" select="$maintainers"/>
136 </xsl:call-template>
137 <xsl:call-template name="_mal2html.page.about.credits">
138 <xsl:with-param name="class" select="'credits-translators'"/>
139 <xsl:with-param name="title" select="'Translated By'"/>
140 <xsl:with-param name="credits" select="$translators"/>
141 </xsl:call-template>
142 <xsl:call-template name="_mal2html.page.about.credits">
143 <xsl:with-param name="class" select="'credits-publishers'"/>
144 <xsl:with-param name="title" select="'Published By'"/>
145 <xsl:with-param name="credits" select="$publishers"/>
146 </xsl:call-template>
147 <xsl:call-template name="_mal2html.page.about.credits">
148 <xsl:with-param name="class" select="'credits-other'"/>
149 <xsl:with-param name="title" select="'Other Credits'"/>
150 <xsl:with-param name="credits" select="$others"/>
151 </xsl:call-template>
152 <div class="credits-blank"></div>
153 <div class="credits-blank"></div>
154 </div>
155 </xsl:if>
156 <xsl:for-each select="$infos/mal:license">
157 <div class="license">
158 <div class="title">
159 <span class="title">
160 <xsl:choose>
161 <xsl:when test="starts-with(@href, 'http://creativecommons.org/')">
162 <xsl:call-template name="l10n.gettext">
163 <xsl:with-param name="msgid" select="'Creative Commons'"/>
164 </xsl:call-template>
165 </xsl:when>
166 <xsl:otherwise>
167 <xsl:call-template name="l10n.gettext">
168 <xsl:with-param name="msgid" select="'License'"/>
169 </xsl:call-template>
170 </xsl:otherwise>
171 </xsl:choose>
172 </span>
173 </div>
174 <div class="contents">
175 <xsl:apply-templates mode="mal2html.block.mode"/>
176 </div>
177 </div>
178 </xsl:for-each>
179 </div>
180 </div>
181 </div>
182 </div>
183 </xsl:if>
184 </xsl:template>
185
186 <!--#* _mal2html.page.about.credits -->
187 <xsl:template name="_mal2html.page.about.credits">
188 <xsl:param name="class"/>
189 <xsl:param name="title"/>
190 <xsl:param name="credits"/>
191 <xsl:if test="$credits">
192 <div class="{$class}">
193 <div class="title">
194 <span class="title">
195 <xsl:call-template name="l10n.gettext">
196 <xsl:with-param name="msgid" select="$title"/>
197 </xsl:call-template>
198 </span>
199 </div>
200 <ul class="credits">
201 <xsl:for-each select="$credits">
202 <li>
203 <xsl:apply-templates mode="mal2html.inline.mode" select="mal:name/node()"/>
204 </li>
205 </xsl:for-each>
206 </ul>
207 </div>
208 </xsl:if>
209 </xsl:template>
210
211 <xsl:template mode="l10n.format.mode" match="msg:copyright.years">
212 <xsl:param name="node"/>
213 <xsl:apply-templates mode="mal2html.inline.mode"
214 select="$node/mal:years/node()"/>
215 </xsl:template>
216
217 <xsl:template mode="l10n.format.mode" match="msg:copyright.name">
218 <xsl:param name="node"/>
219 <xsl:apply-templates mode="mal2html.inline.mode"
220 select="$node/mal:name/node()"/>
221 </xsl:template>
222
223
224 <!--**==========================================================================
225 mal2html.page.linktrails
226 Ouput trails of guide links for a page.
227 @revision[version=3.4 date=2011-11-19 status=final]
228
229 [xsl:params]
230 $node: The top-level `page` element.
231
232 This template outputs all of the link trails for the page $node. It gets the
233 trails from $mal.link.linktrails. If the result is non-empty, it outputs a
234 wrapper `div`, sorts the trails, and calls {mal2html.page.linktrails.trail}
235 on each one. Otherwise, it calls the stub template {mal2html.page.linktrails.empty}.
236 -->
237 <xsl:template name="mal2html.page.linktrails">
238 <xsl:param name="node" select="."/>
239 <xsl:variable name="linktrails">
240 <xsl:call-template name="mal.link.linktrails">
241 <xsl:with-param name="node" select="$node"/>
242 </xsl:call-template>
243 </xsl:variable>
244 <xsl:variable name="trailnodes" select="exsl:node-set($linktrails)/*"/>
245 <xsl:choose>
246 <xsl:when test="count($trailnodes) &gt; 0">
247 <div class="trails" role="navigation">
248 <xsl:for-each select="$trailnodes">
249 <xsl:sort select="(.//mal:title[@type='sort'])[1]"/>
250 <xsl:sort select="(.//mal:title[@type='sort'])[2]"/>
251 <xsl:sort select="(.//mal:title[@type='sort'])[3]"/>
252 <xsl:sort select="(.//mal:title[@type='sort'])[4]"/>
253 <xsl:sort select="(.//mal:title[@type='sort'])[5]"/>
254 <xsl:call-template name="mal2html.page.linktrails.trail">
255 <xsl:with-param name="page" select="$node"/>
256 </xsl:call-template>
257 </xsl:for-each>
258 </div>
259 </xsl:when>
260 <xsl:otherwise>
261 <xsl:call-template name="mal2html.page.linktrails.empty">
262 <xsl:with-param name="node" select="$node"/>
263 </xsl:call-template>
264 </xsl:otherwise>
265 </xsl:choose>
266 </xsl:template>
267
268
269 <!--**==========================================================================
270 mal2html.page.linktrails.empty
271 Deprecated stub to output something when no link trails are present.
272 :Stub: true
273 @revision[version=3.20 date=2015-09-17 status=final]
274
275 [xsl:params]
276 $node: The top-level `page` element.
277
278 This template is deprecated. Use {html.linktrails.empty} instead. By default,
279 this template calls {html.linktrails.empty}, passing the $node parameter.
280
281 This template is a stub. It is called by $mal2html.page.linktrails when there
282 are no link trails to output. Some customizations prepend extra site links to
283 link trails. This template allows them to output those links even when no link
284 trails would otherwise be present.
285 -->
286 <xsl:template name="mal2html.page.linktrails.empty">
287 <xsl:param name="node" select="."/>
288 <xsl:call-template name="html.linktrails.empty">
289 <xsl:with-param name="node" select="$node"/>
290 </xsl:call-template>
291 </xsl:template>
292
293
294 <!--**==========================================================================
295 mal2html.page.linktrails.trail
296 Output one trail of guide links.
297 @revision[version=42 date=2021-10-30 status=final]
298
299 [xsl:params]
300 $page: The source element for which an output page is being made.
301 $node: A `link` element from {mal.link.linktrails}.
302
303 This template outputs an HTML `div` element containing all the links in a
304 single link trail. It calls {html.linktrails.prefix} (by way of
305 {mal2html.page.linktrails.trail.prefix}) to output a custom boilerplate prefix,
306 then calls {mal2html.page.linktrails.link} to output the actual links.
307
308 [note .plain]
309 The $page parameter was added in version 42.
310 -->
311 <xsl:template name="mal2html.page.linktrails.trail">
312 <xsl:param name="page" select="."/>
313 <xsl:param name="node" select="."/>
314 <div class="trail">
315 <xsl:call-template name="mal2html.page.linktrails.trail.prefix">
316 <xsl:with-param name="page" select="$page"/>
317 <xsl:with-param name="node" select="$node"/>
318 </xsl:call-template>
319 <xsl:call-template name="mal2html.page.linktrails.link">
320 <xsl:with-param name="page" select="$page"/>
321 <xsl:with-param name="node" select="$node"/>
322 </xsl:call-template>
323 </div>
324 </xsl:template>
325
326
327 <!--**==========================================================================
328 mal2html.page.linktrails.trail.prefix
329 Deprecated stub to output extra content before a link trail.
330 :Stub: true
331 @revision[version=42 date=2021-10-30 status=final]
332
333 [xsl:params]
334 $page: The source element for which an output page is being made.
335 $node: A `link` element from {mal.link.linktrails}.
336
337 This template is deprecated. Use {html.linktrails.prefix} instead. By default,
338 this template calls {html.linktrails.prefix}, passing the $node parameter.
339
340 This template is a stub. It is called by {mal2html.page.linktrails.trail} for
341 each link trail before the normal links are output with
342 {mal2html.page.linktrails.link}. This template is useful for adding extra site
343 links at the beginning of each link trail.
344
345 [note .plain]
346 The $page parameter was added in version 42.
347 -->
348 <xsl:template name="mal2html.page.linktrails.trail.prefix">
349 <xsl:param name="page" select="."/>
350 <xsl:param name="node" select="."/>
351 <xsl:call-template name="html.linktrails.prefix">
352 <xsl:with-param name="page" select="$page"/>
353 <xsl:with-param name="node" select="$node"/>
354 </xsl:call-template>
355 </xsl:template>
356
357
358 <!--**==========================================================================
359 mal2html.page.linktrails.link
360 Output a link and the following links in a link trail.
361 @revision[version=42 date=2021-11-19 status=final]
362
363 [xsl:params]
364 $page: The source element for which an output page is being made.
365 $node: A `link` element from {mal.link.linktrails}.
366 $direction: The text directionality.
367
368 This template is called by {mal2html.page.linktrails.trail} to output the links
369 in a trail. Link trails returned by {mal.link.linktrails} are returned as nested
370 `link` elements. This template takes one of those elements, outputs an HTML `a`
371 element, then calls itself recursively on the child `link` element, if it exists.
372
373 The $direction parameter specifies the current text directionality. If not
374 provided, it is computed automatically with {l10n.direction}. It determines the
375 separators used between links.
376
377 [note .plain]
378 The $page parameter was added in version 42.
379 -->
380 <xsl:template name="mal2html.page.linktrails.link">
381 <xsl:param name="page" select="."/>
382 <xsl:param name="node" select="."/>
383 <xsl:param name="direction">
384 <xsl:call-template name="l10n.direction">
385 <xsl:with-param name="node" select="$page"/>
386 </xsl:call-template>
387 </xsl:param>
388 <a class="trail">
389 <xsl:attribute name="href">
390 <xsl:call-template name="mal.link.target">
391 <xsl:with-param name="xref" select="$node/@xref"/>
392 </xsl:call-template>
393 </xsl:attribute>
394 <xsl:attribute name="title">
395 <xsl:call-template name="mal.link.tooltip">
396 <xsl:with-param name="xref" select="$node/@xref"/>
397 <xsl:with-param name="role" select="'trail guide'"/>
398 </xsl:call-template>
399 </xsl:attribute>
400 <xsl:call-template name="mal.link.content">
401 <xsl:with-param name="node" select="$node"/>
402 <xsl:with-param name="xref" select="$node/@xref"/>
403 <xsl:with-param name="role" select="'trail guide'"/>
404 </xsl:call-template>
405 </a>
406 <xsl:if test="$direction = 'rtl'">
407 <xsl:text>&#x200F;</xsl:text>
408 </xsl:if>
409 <xsl:choose>
410 <xsl:when test="$node/@child = 'section'">
411 <xsl:text>&#x00A0;› </xsl:text>
412 </xsl:when>
413 <xsl:otherwise>
414 <xsl:text>&#x00A0;» </xsl:text>
415 </xsl:otherwise>
416 </xsl:choose>
417 <xsl:if test="$direction = 'rtl'">
418 <xsl:text>&#x200F;</xsl:text>
419 </xsl:if>
420 <xsl:for-each select="$node/mal:link">
421 <xsl:call-template name="mal2html.page.linktrails.link">
422 <xsl:with-param name="page" select="$page"/>
423 <xsl:with-param name="direction" select="$direction"/>
424 </xsl:call-template>
425 </xsl:for-each>
426 </xsl:template>
427
428
429 <!--**==========================================================================
430 mal2html.editor.badge
431 Output a badge for a link showing the revision status of the target.
432 @revision[version=3.8 date=2012-11-05 status=final]
433
434 [xsl:params]
435 $target: The page or section being linked to.
436
437 This template may be called by link formatters to output a badge showing the
438 revision status of the linked-to page or section. It only outputs a badge if
439 {mal2html.editor_mode} is `true`.
440 -->
441 <xsl:template name="mal2html.editor.badge">
442 <xsl:param name="target" select="."/>
443 <xsl:if test="$mal2html.editor_mode">
444 <xsl:variable name="page" select="$target/ancestor-or-self::mal:page[1]"/>
445 <xsl:variable name="date">
446 <xsl:for-each select="$page/mal:info/mal:revision">
447 <xsl:sort select="@date" data-type="text" order="descending"/>
448 <xsl:if test="position() = 1">
449 <xsl:value-of select="@date"/>
450 </xsl:if>
451 </xsl:for-each>
452 </xsl:variable>
453 <xsl:variable name="revision"
454 select="$page/mal:info/mal:revision[@date = $date][last()]"/>
455 <xsl:if test="$revision/@status != ''">
456 <xsl:text> </xsl:text>
457 <span>
458 <xsl:attribute name="class">
459 <xsl:value-of select="concat('status status-', $revision/@status)"/>
460 </xsl:attribute>
461 <xsl:choose>
462 <xsl:when test="$revision/@status = 'stub'">
463 <xsl:call-template name="l10n.gettext">
464 <xsl:with-param name="msgid" select="'Stub'"/>
465 </xsl:call-template>
466 </xsl:when>
467 <xsl:when test="$revision/@status = 'incomplete'">
468 <xsl:call-template name="l10n.gettext">
469 <xsl:with-param name="msgid" select="'Incomplete'"/>
470 </xsl:call-template>
471 </xsl:when>
472 <xsl:when test="$revision/@status = 'draft'">
473 <xsl:call-template name="l10n.gettext">
474 <xsl:with-param name="msgid" select="'Draft'"/>
475 </xsl:call-template>
476 </xsl:when>
477 <xsl:when test="$revision/@status = 'outdated'">
478 <xsl:call-template name="l10n.gettext">
479 <xsl:with-param name="msgid" select="'Outdated'"/>
480 </xsl:call-template>
481 </xsl:when>
482 <xsl:when test="$revision/@status = 'review'">
483 <xsl:call-template name="l10n.gettext">
484 <xsl:with-param name="msgid" select="'Ready for review'"/>
485 </xsl:call-template>
486 </xsl:when>
487 <xsl:when test="$revision/@status = 'candidate'">
488 <xsl:call-template name="l10n.gettext">
489 <xsl:with-param name="msgid" select="'Candidate'"/>
490 </xsl:call-template>
491 </xsl:when>
492 <xsl:when test="$revision/@status = 'final'">
493 <xsl:call-template name="l10n.gettext">
494 <xsl:with-param name="msgid" select="'Final'"/>
495 </xsl:call-template>
496 </xsl:when>
497 </xsl:choose>
498 </span>
499 </xsl:if>
500 </xsl:if>
501 </xsl:template>
502
503
504 <!--**==========================================================================
505 mal2html.editor.banner
506 Output a banner with the revision status of a page.
507 @revision[version=3.8 date=2012-11-05 status=final]
508
509 [xsl:params]
510 $node: The top-level `page` element.
511
512 This template is called by the {html.body.mode} implementation for `page`
513 elements. It outputs a banner providing information about the revision status
514 of $node. It only outputs a banner if {mal2html.editor_mode} is `true`.
515 -->
516 <xsl:template name="mal2html.editor.banner">
517 <xsl:param name="node" select="."/>
518 <xsl:if test="$mal2html.editor_mode">
519 <xsl:variable name="date">
520 <xsl:for-each select="$node/mal:info/mal:revision">
521 <xsl:sort select="@date" data-type="text" order="descending"/>
522 <xsl:if test="position() = 1">
523 <xsl:value-of select="@date"/>
524 </xsl:if>
525 </xsl:for-each>
526 </xsl:variable>
527 <xsl:variable name="revision"
528 select="$node/mal:info/mal:revision
529 [@date = $date or (not(@date) and $date = '')][last()]"/>
530 <xsl:if test="$revision/@status != ''">
531 <div class="note note-version pagewide"><div class="inner">
532 <!-- FIXME: i18n -->
533 <div class="title">
534 <xsl:choose>
535 <xsl:when test="$revision/@status = 'stub'">
536 <xsl:call-template name="l10n.gettext">
537 <xsl:with-param name="msgid" select="'Stub'"/>
538 </xsl:call-template>
539 </xsl:when>
540 <xsl:when test="$revision/@status = 'incomplete'">
541 <xsl:call-template name="l10n.gettext">
542 <xsl:with-param name="msgid" select="'Incomplete'"/>
543 </xsl:call-template>
544 </xsl:when>
545 <xsl:when test="$revision/@status = 'draft'">
546 <xsl:call-template name="l10n.gettext">
547 <xsl:with-param name="msgid" select="'Draft'"/>
548 </xsl:call-template>
549 </xsl:when>
550 <xsl:when test="$revision/@status = 'outdated'">
551 <xsl:call-template name="l10n.gettext">
552 <xsl:with-param name="msgid" select="'Outdated'"/>
553 </xsl:call-template>
554 </xsl:when>
555 <xsl:when test="$revision/@status = 'review'">
556 <xsl:call-template name="l10n.gettext">
557 <xsl:with-param name="msgid" select="'Ready for review'"/>
558 </xsl:call-template>
559 </xsl:when>
560 <xsl:when test="$revision/@status = 'candidate'">
561 <xsl:call-template name="l10n.gettext">
562 <xsl:with-param name="msgid" select="'Candidate'"/>
563 </xsl:call-template>
564 </xsl:when>
565 <xsl:when test="$revision/@status = 'final'">
566 <xsl:call-template name="l10n.gettext">
567 <xsl:with-param name="msgid" select="'Final'"/>
568 </xsl:call-template>
569 </xsl:when>
570 </xsl:choose>
571 </div>
572 <div class="region"><div class="contents">
573 <xsl:variable name="version">
574 <xsl:choose>
575 <xsl:when test="$revision/@version">
576 <xsl:value-of select="$revision/@version"/>
577 </xsl:when>
578 <xsl:when test="$revision/@docversion">
579 <xsl:value-of select="$revision/@docversion"/>
580 </xsl:when>
581 <xsl:when test="$revision/@pkgversion">
582 <xsl:value-of select="$revision/@pkgversion"/>
583 </xsl:when>
584 </xsl:choose>
585 </xsl:variable>
586 <xsl:if test="$version != '' or $revision/@date">
587 <p class="version">
588 <xsl:value-of select="$version"/>
589 <xsl:if test="$revision/@date">
590 <xsl:text> (</xsl:text>
591 <xsl:value-of select="$revision/@date"/>
592 <xsl:text>)</xsl:text>
593 </xsl:if>
594 </p>
595 </xsl:if>
596 <xsl:apply-templates mode="mal2html.block.mode" select="$revision/*"/>
597 </div></div>
598 </div></div>
599 </xsl:if>
600 </xsl:if>
601 </xsl:template>
602
603
604 <!-- == Matched Templates == -->
605
606 <!--%# html.title.mode -->
607 <xsl:template mode="html.title.mode" match="mal:page">
608 <xsl:variable name="title" select="mal:info/mal:title[@type = 'text'][1]"/>
609 <xsl:choose>
610 <xsl:when test="$title">
611 <xsl:value-of select="$title"/>
612 </xsl:when>
613 <xsl:otherwise>
614 <xsl:value-of select="mal:title"/>
615 </xsl:otherwise>
616 </xsl:choose>
617 </xsl:template>
618
619 <!--%# html.header.mode -->
620 <xsl:template mode="html.header.mode" match="mal:page">
621 <xsl:call-template name="mal2html.page.linktrails"/>
622 </xsl:template>
623
624 <!--%# html.footer.mode -->
625 <xsl:template mode="html.footer.mode" match="mal:page">
626 <xsl:call-template name="mal2html.page.about"/>
627 </xsl:template>
628
629 <!--%# html.sidebar.contents.mode -->
630 <xsl:template mode="html.sidebar.contents.mode" match="mal:page">
631 <xsl:param name="side"/>
632 <xsl:variable name="page" select="."/>
633 <div class="sidebar-contents">
634 <div class="inner">
635 <div class="title">
636 <h2>
637 <span class="title">
638 <xsl:call-template name="l10n.gettext">
639 <xsl:with-param name="msgid" select="'Contents'"/>
640 </xsl:call-template>
641 </span>
642 </h2>
643 </div>
644 <div class="region">
645 <div class="contents">
646 <xsl:for-each select="$mal.cache">
647 <xsl:for-each select="key('mal.cache.key', $mal.link.default_root)">
648 <xsl:call-template name="_html.sidebar.contents.ul"/>
649 </xsl:for-each>
650 </xsl:for-each>
651 </div>
652 </div>
653 </div>
654 </div>
655 </xsl:template>
656
657 <xsl:template name="_html.sidebar.contents.ul">
658 <xsl:param name="node" select="."/>
659 <ul>
660 <xsl:if test="$node/self::mal:page">
661 <li class="links">
662 <a>
663 <xsl:attribute name="href">
664 <xsl:call-template name="mal.link.target">
665 <xsl:with-param name="xref" select="$node/@id"/>
666 </xsl:call-template>
667 </xsl:attribute>
668 <xsl:attribute name="title">
669 <xsl:call-template name="mal.link.tooltip">
670 <xsl:with-param name="xref" select="$node/@id"/>
671 </xsl:call-template>
672 </xsl:attribute>
673 <xsl:call-template name="mal.link.content">
674 <xsl:with-param name="xref" select="$node/@id"/>
675 </xsl:call-template>
676 </a>
677 </li>
678 </xsl:if>
679 <xsl:if test="$node/self::mal:section">
680 <li class="links links-head">
681 <xsl:choose>
682 <xsl:when test="$node/mal:info/mal:title[@type = 'link'][not(@role)]">
683 <xsl:apply-templates mode="mal2html.inline.mode"
684 select="$node/mal:info/mal:title[@type = 'link'][not(@role)][1]/node()"/>
685 </xsl:when>
686 <xsl:otherwise>
687 <xsl:apply-templates mode="mal2html.inline.mode" select="$node/mal:title/node()"/>
688 </xsl:otherwise>
689 </xsl:choose>
690 </li>
691 </xsl:if>
692 <!-- FIXME: Ideally we'd group and sort based on links elements, but those
693 aren't in the cache file, so that's harder.
694 -->
695 <xsl:variable name="links_">
696 <xsl:call-template name="mal.link.topiclinks">
697 <xsl:with-param name="node" select="."/>
698 </xsl:call-template>
699 </xsl:variable>
700 <xsl:variable name="links" select="exsl:node-set($links_)/*"/>
701 <xsl:for-each select="$links">
702 <xsl:sort data-type="number" select="@groupsort"/>
703 <xsl:sort select="mal:title[@type = 'sort']"/>
704 <li class="links">
705 <a>
706 <xsl:attribute name="href">
707 <xsl:call-template name="mal.link.target"/>
708 </xsl:attribute>
709 <xsl:attribute name="title">
710 <xsl:call-template name="mal.link.tooltip"/>
711 </xsl:attribute>
712 <xsl:call-template name="mal.link.content"/>
713 </a>
714 </li>
715 </xsl:for-each>
716 <xsl:for-each select="$node/mal:section">
717 <li class="links">
718 <xsl:call-template name="_html.sidebar.contents.ul"/>
719 </li>
720 </xsl:for-each>
721 </ul>
722 </xsl:template>
723
724 <!--%# html.sidebar.sections.mode -->
725 <xsl:template mode="html.sidebar.sections.mode" match="mal:page">
726 <xsl:param name="side"/>
727 <xsl:if test="mal:section">
728 <div class="sidebar-sections">
729 <div class="inner">
730 <div class="title">
731 <h2>
732 <span class="title">
733 <xsl:call-template name="l10n.gettext">
734 <xsl:with-param name="msgid" select="'On This Page'"/>
735 </xsl:call-template>
736 </span>
737 </h2>
738 </div>
739 <div class="region">
740 <div class="contents">
741 <xsl:call-template name="_mal2html.links.section.ul">
742 <xsl:with-param name="node" select="."/>
743 <xsl:with-param name="nodesc" select="true()"/>
744 </xsl:call-template>
745 </div>
746 </div>
747 </div>
748 </div>
749 </xsl:if>
750 </xsl:template>
751
752 <!--%# html.body.mode -->
753 <xsl:template mode="html.body.mode" match="mal:page">
754 <xsl:call-template name="mal2html.editor.banner"/>
755 <xsl:choose>
756 <xsl:when test="not(mal:links[@type = 'prevnext'])">
757 <xsl:call-template name="mal2html.links.prevnext"/>
758 </xsl:when>
759 <xsl:otherwise>
760 <xsl:apply-templates
761 select="mal:links[@type = 'prevnext'][contains(concat(' ', @style, ' '), ' top ')]">
762 </xsl:apply-templates>
763 </xsl:otherwise>
764 </xsl:choose>
765 <xsl:apply-templates select="."/>
766 <div class="clear"/>
767 </xsl:template>
768
769
770 <!--**==========================================================================
771 mal2html.section
772 Output HTML for a Mallard `section` element.
773 @revision[version=3.4 date=2012-01-26 status=final]
774
775 [xsl:params]
776 $node: The `section` element.
777
778 This template outputs HTML for a `section` element. It it called by the
779 templates that handle `page` and `section` elements.
780 -->
781 <xsl:template name="mal2html.section">
782 <xsl:param name="node" select="."/>
783 <section id="{$node/@id}">
784 <xsl:call-template name="html.class.attr">
785 <xsl:with-param name="node" select="$node"/>
786 <xsl:with-param name="class">
787 <xsl:call-template name="mal2html.ui.expander.class">
788 <xsl:with-param name="node" select="$node"/>
789 </xsl:call-template>
790 </xsl:with-param>
791 </xsl:call-template>
792 <xsl:call-template name="mal2html.ui.expander.data">
793 <xsl:with-param name="node" select="$node"/>
794 </xsl:call-template>
795 <div class="inner">
796 <xsl:apply-templates select="$node"/>
797 </div>
798 </section>
799 </xsl:template>
800
801
802 <!-- page | section -->
803 <xsl:template match="mal:page | mal:section">
804 <xsl:variable name="type" select="ancestor-or-self::mal:page[1]/@type"/>
805 <xsl:variable name="depth" select="count(ancestor-or-self::mal:section) + 1"/>
806 <xsl:variable name="topiclinks">
807 <xsl:if test="$type = 'guide'">
808 <xsl:call-template name="mal.link.topiclinks"/>
809 </xsl:if>
810 </xsl:variable>
811 <xsl:variable name="topicnodes" select="exsl:node-set($topiclinks)/*"/>
812 <xsl:variable name="guidelinks">
813 <xsl:call-template name="mal.link.guidelinks"/>
814 </xsl:variable>
815 <xsl:variable name="guidenodes" select="exsl:node-set($guidelinks)/*"/>
816 <xsl:variable name="seealsolinks">
817 <xsl:call-template name="mal.link.seealsolinks"/>
818 </xsl:variable>
819 <xsl:variable name="seealsonodes" select="exsl:node-set($seealsolinks)/*"/>
820 <xsl:variable name="allgroups">
821 <xsl:if test="$type = 'guide'">
822 <xsl:text> </xsl:text>
823 <xsl:for-each select="mal:links[@type = 'topic']">
824 <xsl:choose>
825 <xsl:when test="@groups">
826 <xsl:value-of select="@groups"/>
827 </xsl:when>
828 <xsl:otherwise>
829 <xsl:text>#default</xsl:text>
830 </xsl:otherwise>
831 </xsl:choose>
832 <xsl:text> </xsl:text>
833 </xsl:for-each>
834 </xsl:if>
835 </xsl:variable>
836 <div class="hgroup pagewide">
837 <xsl:apply-templates mode="mal2html.title.mode" select="mal:title"/>
838 <xsl:apply-templates mode="mal2html.title.mode" select="mal:subtitle"/>
839 </div>
840 <div class="region">
841 <div class="contents pagewide">
842 <xsl:call-template name="html.content.pre">
843 <xsl:with-param name="page" select="boolean(self::mal:page)"/>
844 </xsl:call-template>
845 <xsl:for-each
846 select="*[not(self::mal:section or self::mal:title or self::mal:subtitle)]">
847 <xsl:choose>
848 <xsl:when test="preceding-sibling::mal:section"/>
849 <xsl:when test="self::mal:links[@type = 'topic']">
850 <xsl:if test="$type = 'guide'">
851 <xsl:apply-templates select=".">
852 <xsl:with-param name="allgroups" select="$allgroups"/>
853 <xsl:with-param name="links" select="$topicnodes"/>
854 </xsl:apply-templates>
855 </xsl:if>
856 </xsl:when>
857 <xsl:when test="self::mal:links[@type = 'guide']">
858 <xsl:apply-templates select=".">
859 <xsl:with-param name="links" select="$guidenodes"/>
860 </xsl:apply-templates>
861 </xsl:when>
862 <xsl:when test="self::mal:links[@type = 'seealso']">
863 <xsl:apply-templates select=".">
864 <xsl:with-param name="links" select="$seealsonodes"/>
865 </xsl:apply-templates>
866 </xsl:when>
867 <xsl:when test="self::mal:links[@type = 'prevnext']">
868 <xsl:if test="not(contains(concat(' ', @style, ' '), ' top '))">
869 <xsl:apply-templates select="."/>
870 </xsl:if>
871 </xsl:when>
872 <xsl:when test="self::mal:links">
873 <xsl:apply-templates select="."/>
874 </xsl:when>
875 <xsl:otherwise>
876 <xsl:apply-templates mode="mal2html.block.mode" select="."/>
877 </xsl:otherwise>
878 </xsl:choose>
879 </xsl:for-each>
880 <xsl:if test="$type = 'guide'">
881 <xsl:if test="not(mal:links[@type = 'topic'])">
882 <xsl:call-template name="mal2html.links.topic">
883 <xsl:with-param name="links" select="$topicnodes"/>
884 </xsl:call-template>
885 </xsl:if>
886 </xsl:if>
887 <xsl:if test="$type = 'gloss:glossary'">
888 <xsl:call-template name="mal2html.gloss.terms"/>
889 </xsl:if>
890 <xsl:call-template name="html.content.post">
891 <xsl:with-param name="page" select="boolean(self::mal:page)"/>
892 </xsl:call-template>
893 </div>
894 <xsl:for-each select="mal:section">
895 <xsl:call-template name="mal2html.section"/>
896 </xsl:for-each>
897 <xsl:if test="self::mal:page and not(mal:links[@type = 'prevnext'])">
898 <xsl:call-template name="mal2html.links.prevnext"/>
899 </xsl:if>
900 <xsl:variable name="postlinks" select="mal:section/following-sibling::mal:links"/>
901 <xsl:if test="(not(mal:section) and (
902 ($guidenodes and not(mal:links[@type = 'guide']))
903 or
904 ($seealsonodes and not(mal:links[@type = 'seealso']))
905 )) or
906 ($topicnodes and $postlinks[self::mal:links[@type = 'topic']]) or
907 ($guidenodes and
908 ($postlinks[self::mal:links[@type = 'guide']] or
909 (mal:section and not(mal:links[@type = 'guide'])))) or
910 ($seealsonodes and
911 ($postlinks[self::mal:links[@type = 'seealso']] or
912 (mal:section and not(mal:links[@type = 'seealso']))))
913 ">
914 <section class="links" role="navigation">
915 <div class="inner">
916 <div class="hgroup pagewide"/>
917 <div class="contents pagewide">
918 <xsl:for-each select="$postlinks">
919 <xsl:choose>
920 <xsl:when test="self::mal:links[@type = 'topic']">
921 <xsl:if test="$type = 'guide'">
922 <xsl:apply-templates select=".">
923 <xsl:with-param name="depth" select="$depth + 1"/>
924 <xsl:with-param name="allgroups" select="$allgroups"/>
925 <xsl:with-param name="links" select="$topicnodes"/>
926 </xsl:apply-templates>
927 </xsl:if>
928 </xsl:when>
929 <xsl:when test="self::mal:links[@type = 'guide']">
930 <xsl:apply-templates select=".">
931 <xsl:with-param name="depth" select="$depth + 1"/>
932 <xsl:with-param name="links" select="$guidenodes"/>
933 </xsl:apply-templates>
934 </xsl:when>
935 <xsl:when test="self::mal:links[@type = 'seealso']">
936 <xsl:apply-templates select=".">
937 <xsl:with-param name="depth" select="$depth + 1"/>
938 <xsl:with-param name="links" select="$seealsonodes"/>
939 </xsl:apply-templates>
940 </xsl:when>
941 <xsl:when test="self::mal:links[@type = 'prevnext']">
942 <xsl:if test="not(contains(concat(' ', @style, ' '), ' top '))">
943 <xsl:apply-templates select=".">
944 <xsl:with-param name="depth" select="$depth + 1"/>
945 </xsl:apply-templates>
946 </xsl:if>
947 </xsl:when>
948 <xsl:otherwise>
949 <xsl:apply-templates select=".">
950 <xsl:with-param name="depth" select="$depth + 1"/>
951 </xsl:apply-templates>
952 </xsl:otherwise>
953 </xsl:choose>
954 </xsl:for-each>
955 <xsl:if test="$guidenodes and not(mal:links[@type = 'guide'])">
956 <xsl:call-template name="mal2html.links.guide">
957 <xsl:with-param name="depth" select="$depth + 1"/>
958 <xsl:with-param name="links" select="$guidenodes"/>
959 </xsl:call-template>
960 </xsl:if>
961 <xsl:if test="$seealsonodes and not(mal:links[@type = 'seealso'])">
962 <xsl:call-template name="mal2html.links.seealso">
963 <xsl:with-param name="depth" select="$depth + 1"/>
964 <xsl:with-param name="links" select="$seealsonodes"/>
965 </xsl:call-template>
966 </xsl:if>
967 </div>
968 </div>
969 </section>
970 </xsl:if>
971 </div>
972 </xsl:template>
973
974
975 <!--%%==========================================================================
976 mal2html.title.mode
977 Output headings for titles and subtitles.
978 @revision[version=3.10 date=2013-07-10 status=final]
979
980 This template is called on `title` and `subtitle` elements that appear as
981 direct child content of `page` or `section` elements. Normal block titles
982 are processed in {mal2html.block.mode}.
983 -->
984 <xsl:template mode="mal2html.title.mode" match="mal:title | mal:subtitle">
985 <xsl:if test="not(contains(concat(' ', @style, ' '), ' hidden '))">
986 <xsl:variable name="depth"
987 select="count(ancestor::mal:section) + 1 + boolean(self::mal:subtitle)"/>
988 <xsl:variable name="depth_">
989 <xsl:choose>
990 <xsl:when test="$depth &lt; 6">
991 <xsl:value-of select="$depth"/>
992 </xsl:when>
993 <xsl:otherwise>
994 <xsl:value-of select="6"/>
995 </xsl:otherwise>
996 </xsl:choose>
997 </xsl:variable>
998 <xsl:element name="{concat('h', $depth_)}" namespace="{$html.namespace}">
999 <xsl:call-template name="html.class.attr">
1000 <xsl:with-param name="class" select="local-name(.)"/>
1001 </xsl:call-template>
1002 <span class="{local-name(.)}">
1003 <xsl:apply-templates mode="mal2html.inline.mode"/>
1004 </span>
1005 </xsl:element>
1006 </xsl:if>
1007 </xsl:template>
1008
1009 <!-- We need this in the CSS, but the text templates can't xsl:call-template -->
1010 <xsl:variable name="_color.link_button_hover">
1011 <xsl:call-template name="color.blend">
1012 <xsl:with-param name="bg" select="$color.blue"/>
1013 <xsl:with-param name="fg" select="$color.bg"/>
1014 <xsl:with-param name="mix" select="0.1"/>
1015 </xsl:call-template>
1016 </xsl:variable>
1017
1018 <!--%# html.css.mode -->
1019 <xsl:template mode="html.css.mode" match="mal:page">
1020 <xsl:param name="direction">
1021 <xsl:call-template name="l10n.direction"/>
1022 </xsl:param>
1023 <xsl:param name="left">
1024 <xsl:call-template name="l10n.align.start">
1025 <xsl:with-param name="direction" select="$direction"/>
1026 </xsl:call-template>
1027 </xsl:param>
1028 <xsl:param name="right">
1029 <xsl:call-template name="l10n.align.end">
1030 <xsl:with-param name="direction" select="$direction"/>
1031 </xsl:call-template>
1032 </xsl:param>
1033 <xsl:call-template name="tmpl.file">
1034 <xsl:with-param name="file" select="'css/mallard.css.tmpl'"/>
1035 <xsl:with-param name="node" select="."/>
1036 <xsl:with-param name="direction" select="$direction"/>
1037 <xsl:with-param name="left" select="$left"/>
1038 <xsl:with-param name="right" select="$right"/>
1039 </xsl:call-template>
1040 <xsl:if test="$mal2html.editor_mode">
1041 <xsl:call-template name="tmpl.file">
1042 <xsl:with-param name="file" select="'css/mallard-editor.css.tmpl'"/>
1043 <xsl:with-param name="node" select="."/>
1044 <xsl:with-param name="direction" select="$direction"/>
1045 <xsl:with-param name="left" select="$left"/>
1046 <xsl:with-param name="right" select="$right"/>
1047 </xsl:call-template>
1048 </xsl:if>
1049 </xsl:template>
1050
1051 <!--%# html.js.mode -->
1052 <xsl:template mode="html.js.mode" match="mal:page">
1053 <xsl:text><![CDATA[
1054 document.addEventListener('DOMContentLoaded', function() {
1055 var tiles = document.querySelectorAll('div.links-tile');
1056 for (var i = 0; i < tiles.length; i++) {
1057 (function (tile) {
1058 if (!tile.parentNode.classList.contains('links-tiles') &&
1059 (tile.nextElementSibling &&
1060 tile.nextElementSibling.classList.contains('links-tile')) &&
1061 !(tile.previousElementSibling &&
1062 tile.previousElementSibling.classList.contains('links-tile'))) {
1063 var tilesdiv = document.createElement('div');
1064 tilesdiv.className = 'links-tiles';
1065 tile.parentNode.insertBefore(tilesdiv, tile);
1066 var cur = tile;
1067 while (cur && cur.classList.contains('links-tile')) {
1068 var curcur = cur;
1069 cur = cur.nextElementSibling;
1070 tilesdiv.appendChild(curcur);
1071 }
1072 for (j = 0; j < 2; j++) {
1073 var paddiv = document.createElement('div');
1074 paddiv.className = 'links-tile';
1075 tilesdiv.appendChild(paddiv);
1076 }
1077 }
1078 })(tiles[i]);
1079 }
1080 });
1081 document.addEventListener('DOMContentLoaded', function() {
1082 var overlays = document.querySelectorAll('a.ui-overlay');
1083 for (var i = 0; i < overlays.length; i++) {
1084 (function (ovlink) {
1085 var overlay = ovlink.parentNode.querySelector('div.ui-overlay');
1086 var ui_overlay_show = function (ev) {
1087 overlay.style.display = 'block';
1088 overlay.classList.add('ui-overlay-show');
1089 var screen = document.querySelector('div.ui-overlay-screen');
1090 if (screen == null) {
1091 screen = document.createElement('div');
1092 screen.className = 'ui-overlay-screen';
1093 document.body.appendChild(screen);
1094 }
1095 var inner = overlay.querySelector('div.inner');
1096 var close = inner.querySelector('a.ui-overlay-close');
1097 var media = inner.querySelectorAll('audio, video');
1098
1099 var overlay_play_func = function () {
1100 for (var j = 0; j < media.length; j++) {
1101 media[j].play();
1102 }
1103 };
1104 var overlay_play_timeout = window.setTimeout(overlay_play_func, 1000);
1105
1106 var ui_overlay_funcs = {};
1107 ui_overlay_funcs['hide'] = function () {
1108 overlay.style.display = 'none';
1109 document.body.removeChild(screen);
1110 document.removeEventListener('keydown', ui_overlay_funcs['keydown'], false);
1111 for (var j = 0; j < media.length; j++) {
1112 media[j].pause();
1113 }
1114 window.clearTimeout(overlay_play_timeout);
1115 };
1116 ui_overlay_funcs['hideclick'] = function (uiev) {
1117 ui_overlay_funcs['hide']();
1118 uiev.preventDefault();
1119 };
1120 ui_overlay_funcs['keydown'] = function (uiev) {
1121 if (uiev.keyCode == 27) {
1122 ui_overlay_funcs['hide']();
1123 }
1124 };
1125 screen.addEventListener('click', ui_overlay_funcs['hideclick'], false);
1126 close.addEventListener('click', ui_overlay_funcs['hideclick'], false);
1127 document.addEventListener('keydown', ui_overlay_funcs['keydown'], false);
1128 ev.preventDefault();
1129 };
1130 ovlink.addEventListener('click', ui_overlay_show, false);
1131 })(overlays[i]);
1132 }
1133 });
1134 ]]></xsl:text>
1135 </xsl:template>
1136
1137 </xsl:stylesheet>