| 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:exsl="http://exslt.org/common" |
| 19 |
xmlns:mal="http://projectmallard.org/1.0/" |
| 20 |
xmlns:ui="http://projectmallard.org/ui/1.0/" |
| 21 |
xmlns:uix="http://projectmallard.org/experimental/ui/" |
| 22 |
xmlns:math="http://exslt.org/math" |
| 23 |
xmlns="http://www.w3.org/1999/xhtml" |
| 24 |
exclude-result-prefixes="mal ui uix math exsl" |
| 25 |
version="1.0"> |
| 26 |
|
| 27 |
<!--!!========================================================================== |
| 28 |
Mallard to HTML - UI Extension |
| 29 |
Support for Mallard UI extension elements. |
| 30 |
|
| 31 |
This stylesheet contains templates to support features from the Mallard UI |
| 32 |
extension. |
| 33 |
--> |
| 34 |
|
| 35 |
|
| 36 |
<!--**========================================================================== |
| 37 |
mal2html.ui.expander.class |
| 38 |
Output HTML class value for an expander. |
| 39 |
@revision[version=3.32 date=2018-10-14 status=final] |
| 40 |
|
| 41 |
[xsl:params] |
| 42 |
$node: The source element to output data for. |
| 43 |
$hastitle: True if $node has a title or a title can be automatically computed. |
| 44 |
|
| 45 |
This template outputs HTML class attribute values for elements that can be |
| 46 |
expanded and collapsed. It outputs the string `ui-expander` only if $node has |
| 47 |
a `ui:expanded` attribute and $hastitle is true. By default, $hastitle is true |
| 48 |
if $node has a `title` element. Set $hastitle explicitly when calling this |
| 49 |
template on elements that have an automatic default title. |
| 50 |
|
| 51 |
This template also outputs `ui-expander-preview` if $node is an expander and |
| 52 |
it has the style hint `ui-expander-preview`. This is an alternative style |
| 53 |
that shows a scaled down preview of collapsed content. |
| 54 |
--> |
| 55 |
<xsl:template name="mal2html.ui.expander.class"> |
| 56 |
<xsl:param name="node" select="."/> |
| 57 |
<xsl:param name="hastitle" select="$node/mal:title"/> |
| 58 |
<xsl:if test="$hastitle and ($node/@ui:expanded or $node/@uix:expanded)"> |
| 59 |
<xsl:text> ui-expander </xsl:text> |
| 60 |
<xsl:if test="contains(concat(' ', $node/@style, ' '), ' ui-expander-preview ')"> |
| 61 |
<xsl:text>ui-expander-preview </xsl:text> |
| 62 |
</xsl:if> |
| 63 |
</xsl:if> |
| 64 |
</xsl:template> |
| 65 |
|
| 66 |
|
| 67 |
<!--**========================================================================== |
| 68 |
mal2html.ui.expander.data |
| 69 |
Output data for an expander. |
| 70 |
@revision[version=3.32 date=2018-10-14 status=final] |
| 71 |
|
| 72 |
[xsl:params] |
| 73 |
$node: The source element to output data for. |
| 74 |
$hastitle: True if $node has a title or a title can be automatically computed. |
| 75 |
|
| 76 |
This template outputs an HTML `div` element with the `class` attribute set to |
| 77 |
`"yelp-data yelp-data-ui-expander"`. All `yelp-data` elements are hidden by |
| 78 |
the CSS. The div contains information about text directionality, the default |
| 79 |
expanded state, and optionally additional titles for the expanded and collapsed |
| 80 |
states. |
| 81 |
|
| 82 |
The expander information is only output if $node has a `ui:expanded` attribute |
| 83 |
and $hastitle is true. By default, $hastitle is true if $node has a `title` |
| 84 |
element. Set $hastitle explicitly when calling this template on elements that |
| 85 |
have an automatic default title. |
| 86 |
--> |
| 87 |
<xsl:template name="mal2html.ui.expander.data"> |
| 88 |
<xsl:param name="node" select="."/> |
| 89 |
<xsl:param name="hastitle" select="$node/mal:title"/> |
| 90 |
<xsl:if test="$node/@uix:expanded and not($node/@ui:expanded)"> |
| 91 |
<xsl:message> |
| 92 |
<xsl:text>DEPRECATION WARNING: The expanded attribute from the experimental/ui namespace |
| 93 |
is deprecated. Use the expanded attribute from the ui/1.0 namespace instead. |
| 94 |
Note that the non-experimental attribute takes true/false instead of yes/no. |
| 95 |
http://projectmallard.org/ui/1.0/ui_expanded.html</xsl:text> |
| 96 |
</xsl:message> |
| 97 |
</xsl:if> |
| 98 |
<xsl:if test="$hastitle and ($node/@ui:expanded or $node/@uix:expanded)"> |
| 99 |
<xsl:variable name="title_e" select="$node/mal:info/mal:title[@type = 'ui:expanded'][1]"/> |
| 100 |
<xsl:variable name="title_c" select="$node/mal:info/mal:title[@type = 'ui:collapsed'][1]"/> |
| 101 |
<div class="yelp-data yelp-data-ui-expander"> |
| 102 |
<xsl:attribute name="dir"> |
| 103 |
<xsl:call-template name="l10n.direction"> |
| 104 |
<xsl:with-param name="node" select="$node"/> |
| 105 |
</xsl:call-template> |
| 106 |
</xsl:attribute> |
| 107 |
<xsl:attribute name="data-yelp-expanded"> |
| 108 |
<xsl:choose> |
| 109 |
<xsl:when test="$node/@ui:expanded = 'false'"> |
| 110 |
<xsl:text>false</xsl:text> |
| 111 |
</xsl:when> |
| 112 |
<xsl:when test="$node/@uix:expanded = 'no'"> |
| 113 |
<xsl:text>false</xsl:text> |
| 114 |
</xsl:when> |
| 115 |
<xsl:otherwise> |
| 116 |
<xsl:text>true</xsl:text> |
| 117 |
</xsl:otherwise> |
| 118 |
</xsl:choose> |
| 119 |
</xsl:attribute> |
| 120 |
<xsl:if test="$title_e"> |
| 121 |
<div class="yelp-title-expanded"> |
| 122 |
<xsl:apply-templates mode="mal2html.inline.mode" select="$title_e/node()"/> |
| 123 |
</div> |
| 124 |
</xsl:if> |
| 125 |
<xsl:if test="$title_c"> |
| 126 |
<div class="yelp-title-collapsed"> |
| 127 |
<xsl:apply-templates mode="mal2html.inline.mode" select="$title_c/node()"/> |
| 128 |
</div> |
| 129 |
</xsl:if> |
| 130 |
</div> |
| 131 |
</xsl:if> |
| 132 |
</xsl:template> |
| 133 |
|
| 134 |
|
| 135 |
<!--**========================================================================== |
| 136 |
mal2html.ui.links.tiles |
| 137 |
Output links as thumbnail tiles. |
| 138 |
@revision[version=3.28 date=2015-10-22 status=volatile] |
| 139 |
|
| 140 |
[xsl:params] |
| 141 |
$node: A `links` element to link from. |
| 142 |
$links: A list of links, as from a template in {mal-link}. |
| 143 |
$role: A link role, used to select the appropriate title and thumbnail. |
| 144 |
|
| 145 |
This template outputs links as thumbnail tiles. For each link, it outputs |
| 146 |
a `div` element with a thumbnail, title, and desc (unless the `nodesc` |
| 147 |
style hint is used). This template calls {mal2html.ui.links.img} to find |
| 148 |
the best-match thumbnail and output the HTML `img` element for each link. |
| 149 |
|
| 150 |
This template handles link sorting. |
| 151 |
--> |
| 152 |
<xsl:template name="mal2html.ui.links.tiles"> |
| 153 |
<xsl:param name="node" select="."/> |
| 154 |
<xsl:param name="links"/> |
| 155 |
<xsl:param name="role"/> |
| 156 |
<div class="links-tiles"> |
| 157 |
<xsl:for-each select="$links"> |
| 158 |
<xsl:sort data-type="number" select="@groupsort"/> |
| 159 |
<xsl:sort select="mal:title[@type = 'sort']"/> |
| 160 |
<xsl:variable name="link" select="."/> |
| 161 |
<xsl:for-each select="$mal.cache"> |
| 162 |
<xsl:variable name="target" select="key('mal.cache.key', $link/@xref)"/> |
| 163 |
<div class="links-tile {$link/@class}"> |
| 164 |
<xsl:for-each select="$link/@*"> |
| 165 |
<xsl:if test="starts-with(name(.), 'data-')"> |
| 166 |
<xsl:copy-of select="."/> |
| 167 |
</xsl:if> |
| 168 |
</xsl:for-each> |
| 169 |
<xsl:variable name="infos" select="$target/mal:info | $link[@href]/mal:info"/> |
| 170 |
<xsl:variable name="thumbs" select="$infos/uix:thumb"/> |
| 171 |
<a> |
| 172 |
<xsl:attribute name="href"> |
| 173 |
<xsl:call-template name="mal.link.target"> |
| 174 |
<xsl:with-param name="node" select="$node"/> |
| 175 |
<xsl:with-param name="xref" select="$link/@xref"/> |
| 176 |
<xsl:with-param name="href" select="$link/@href"/> |
| 177 |
</xsl:call-template> |
| 178 |
</xsl:attribute> |
| 179 |
<xsl:attribute name="title"> |
| 180 |
<xsl:call-template name="mal.link.tooltip"> |
| 181 |
<xsl:with-param name="node" select="$node"/> |
| 182 |
<xsl:with-param name="xref" select="$link/@xref"/> |
| 183 |
<xsl:with-param name="href" select="$link/@href"/> |
| 184 |
<xsl:with-param name="role" select="$role"/> |
| 185 |
<xsl:with-param name="info" select="$link[@href]/mal:info"/> |
| 186 |
</xsl:call-template> |
| 187 |
</xsl:attribute> |
| 188 |
<span class="links-tile-img"> |
| 189 |
<xsl:call-template name="mal2html.ui.links.img"> |
| 190 |
<xsl:with-param name="node" select="$node"/> |
| 191 |
<xsl:with-param name="thumbs" select="$thumbs"/> |
| 192 |
<xsl:with-param name="role" select="$role"/> |
| 193 |
</xsl:call-template> |
| 194 |
</span> |
| 195 |
<span class="links-tile-text"> |
| 196 |
<span class="title"> |
| 197 |
<xsl:call-template name="mal.link.content"> |
| 198 |
<xsl:with-param name="node" select="$node"/> |
| 199 |
<xsl:with-param name="xref" select="$link/@xref"/> |
| 200 |
<xsl:with-param name="href" select="$link/@href"/> |
| 201 |
<xsl:with-param name="role" select="$role"/> |
| 202 |
<xsl:with-param name="info" select="$link[@href]/mal:info"/> |
| 203 |
</xsl:call-template> |
| 204 |
</span> |
| 205 |
<xsl:if test="not(contains(concat(' ', $node/@style, ' '), ' nodesc '))"> |
| 206 |
<xsl:variable name="desc"> |
| 207 |
<xsl:call-template name="mal.link.desc"> |
| 208 |
<xsl:with-param name="node" select="$node"/> |
| 209 |
<xsl:with-param name="xref" select="$link/@xref"/> |
| 210 |
<xsl:with-param name="href" select="$link/@href"/> |
| 211 |
<xsl:with-param name="role" select="$role"/> |
| 212 |
<xsl:with-param name="info" select="$link[@href]/mal:info"/> |
| 213 |
</xsl:call-template> |
| 214 |
</xsl:variable> |
| 215 |
<xsl:variable name="desc_" select="exsl:node-set($desc)/node()"/> |
| 216 |
<xsl:if test="$desc_/node()"> |
| 217 |
<span class="desc"> |
| 218 |
<xsl:apply-templates mode="_mal2html.links.divs.nolink.mode" |
| 219 |
select="$desc_"/> |
| 220 |
</span> |
| 221 |
</xsl:if> |
| 222 |
</xsl:if> |
| 223 |
</span> |
| 224 |
</a> |
| 225 |
</div> |
| 226 |
</xsl:for-each> |
| 227 |
</xsl:for-each> |
| 228 |
<!-- blank tiles for homogeneous sizing --> |
| 229 |
<div class="links-tile"></div> |
| 230 |
<div class="links-tile"></div> |
| 231 |
</div> |
| 232 |
</xsl:template> |
| 233 |
|
| 234 |
|
| 235 |
<!--DEPRECATED================================================================== |
| 236 |
_mal2html.ui.links.hover |
| 237 |
Output links with thumbnails shown on hover. |
| 238 |
@revision[version=3.4 date=2012-02-26 status=final] |
| 239 |
|
| 240 |
[xsl:params] |
| 241 |
$node: A `links` element to link from. |
| 242 |
$links: A list of links, as from a template in {mal-link}. |
| 243 |
$role: A link role, used to select the appropriate title and thumbnail. |
| 244 |
|
| 245 |
This template outputs links alongside thumbnail images, using the UI extension. |
| 246 |
The thumbnail image for each link is shown when the user hovers over that link. |
| 247 |
This template calls {mal2html.ui.links.img} to find the best-match thumbnail |
| 248 |
and output the HTML `img` element for each link. |
| 249 |
|
| 250 |
If $node contains a `ui:thumb` element, that image is used when no links |
| 251 |
are hovered. |
| 252 |
|
| 253 |
This template handles link sorting. |
| 254 |
--> |
| 255 |
<!--#* _mal2html.ui.links.hover --> |
| 256 |
<xsl:template name="_mal2html.ui.links.hover"> |
| 257 |
<xsl:param name="node"/> |
| 258 |
<xsl:param name="links"/> |
| 259 |
<xsl:param name="role"/> |
| 260 |
<xsl:variable name="width"> |
| 261 |
<xsl:choose> |
| 262 |
<xsl:when test="$node/@uix:width"> |
| 263 |
<xsl:value-of select="$node/@uix:width"/> |
| 264 |
</xsl:when> |
| 265 |
<xsl:otherwise> |
| 266 |
<xsl:text>250</xsl:text> |
| 267 |
</xsl:otherwise> |
| 268 |
</xsl:choose> |
| 269 |
</xsl:variable> |
| 270 |
<xsl:variable name="height"> |
| 271 |
<xsl:choose> |
| 272 |
<xsl:when test="$node/@uix:height"> |
| 273 |
<xsl:value-of select="$node/@uix:height"/> |
| 274 |
</xsl:when> |
| 275 |
<xsl:otherwise> |
| 276 |
<xsl:text>200</xsl:text> |
| 277 |
</xsl:otherwise> |
| 278 |
</xsl:choose> |
| 279 |
</xsl:variable> |
| 280 |
<xsl:message> |
| 281 |
<xsl:text>DEPRECATION WARNING: The uix:thumbs attribute on the links element is deprecated.</xsl:text> |
| 282 |
</xsl:message> |
| 283 |
<div class="links-uix-hover"> |
| 284 |
<div class="links-uix-hover-img" style="width: {$width}px; height: {$height}px;"> |
| 285 |
<xsl:for-each select="$node/uix:thumb[1]"> |
| 286 |
<img> |
| 287 |
<xsl:call-template name="mal2html.ui.links.img.src"> |
| 288 |
<xsl:with-param name="node" select="$node"/> |
| 289 |
<xsl:with-param name="thumb" select="."/> |
| 290 |
</xsl:call-template> |
| 291 |
<xsl:call-template name="mal2html.ui.links.img.attrs"> |
| 292 |
<xsl:with-param name="node" select="$node"/> |
| 293 |
<xsl:with-param name="thumb" select="."/> |
| 294 |
<xsl:with-param name="width" select="$width"/> |
| 295 |
<xsl:with-param name="height" select="$height"/> |
| 296 |
</xsl:call-template> |
| 297 |
</img> |
| 298 |
</xsl:for-each> |
| 299 |
</div> |
| 300 |
<ul class="links-uix-hover"> |
| 301 |
<xsl:for-each select="$links"> |
| 302 |
<xsl:sort data-type="number" select="@groupsort"/> |
| 303 |
<xsl:sort select="mal:title[@type = 'sort']"/> |
| 304 |
<xsl:variable name="link" select="."/> |
| 305 |
<xsl:variable name="xref" select="@xref"/> |
| 306 |
<xsl:for-each select="$mal.cache"> |
| 307 |
<xsl:variable name="target" select="key('mal.cache.key', $xref)"/> |
| 308 |
<xsl:variable name="infos" select="$target/mal:info | $link[@href]/mal:info"/> |
| 309 |
<xsl:variable name="thumbs" select="$infos/uix:thumb"/> |
| 310 |
<li class="links {$link/@class}"> |
| 311 |
<xsl:for-each select="$link/@*"> |
| 312 |
<xsl:if test="starts-with(name(.), 'data-')"> |
| 313 |
<xsl:copy-of select="."/> |
| 314 |
</xsl:if> |
| 315 |
</xsl:for-each> |
| 316 |
<a class="bold"> |
| 317 |
<xsl:attribute name="href"> |
| 318 |
<xsl:call-template name="mal.link.target"> |
| 319 |
<xsl:with-param name="xref" select="$xref"/> |
| 320 |
<xsl:with-param name="href" select="$link/@href"/> |
| 321 |
</xsl:call-template> |
| 322 |
</xsl:attribute> |
| 323 |
<xsl:attribute name="title"> |
| 324 |
<xsl:call-template name="mal.link.tooltip"> |
| 325 |
<xsl:with-param name="xref" select="$xref"/> |
| 326 |
<xsl:with-param name="href" select="$link/@href"/> |
| 327 |
<xsl:with-param name="role" select="$role"/> |
| 328 |
<xsl:with-param name="info" select="$link[@href]/mal:info"/> |
| 329 |
</xsl:call-template> |
| 330 |
</xsl:attribute> |
| 331 |
<span class="links-uix-hover-img" style="width: {$width}px; height: {$height}px;"> |
| 332 |
<xsl:call-template name="mal2html.ui.links.img"> |
| 333 |
<xsl:with-param name="node" select="$node"/> |
| 334 |
<xsl:with-param name="thumbs" select="$thumbs"/> |
| 335 |
<xsl:with-param name="role" select="$role"/> |
| 336 |
<xsl:with-param name="width" select="$width"/> |
| 337 |
<xsl:with-param name="height" select="$height"/> |
| 338 |
</xsl:call-template> |
| 339 |
</span> |
| 340 |
<span class="title"> |
| 341 |
<xsl:call-template name="mal.link.content"> |
| 342 |
<xsl:with-param name="node" select="."/> |
| 343 |
<xsl:with-param name="xref" select="$xref"/> |
| 344 |
<xsl:with-param name="href" select="$link/@href"/> |
| 345 |
<xsl:with-param name="role" select="$role"/> |
| 346 |
<xsl:with-param name="info" select="$link[@href]/mal:info"/> |
| 347 |
</xsl:call-template> |
| 348 |
</span> |
| 349 |
</a> |
| 350 |
</li> |
| 351 |
</xsl:for-each> |
| 352 |
</xsl:for-each> |
| 353 |
</ul> |
| 354 |
</div> |
| 355 |
</xsl:template> |
| 356 |
|
| 357 |
|
| 358 |
<!--**========================================================================== |
| 359 |
mal2html.ui.links.img |
| 360 |
Output an image for a link using UI thumbnails. |
| 361 |
@revision[version=3.28 date=2017-08-11 status=final] |
| 362 |
|
| 363 |
[xsl:params] |
| 364 |
$node: A `links` element to link from. |
| 365 |
$thumbs: A list of candidate `uix:thumb` elements. |
| 366 |
$role: A link role, used to select the appropriate thumbnail. |
| 367 |
$width: The width to fit thumbnails into. |
| 368 |
$height: The height to fit thumbnails into. |
| 369 |
|
| 370 |
This template selects the best-fit thumbnail from $thumbs, based on how well |
| 371 |
the aspect ratio and dimensions of each image matches the $width and $height |
| 372 |
parameters. It outputs an HTML `img` element for the best-fit thumbnail. It |
| 373 |
calls $mal2thml.ui.links.img.src to output the `src` attribute, and calls |
| 374 |
$mal2html.ui.links.img.attrs to output `width` and `height` attributes. |
| 375 |
|
| 376 |
Before checking for a best-fit thumbnail on dimensions, this template first |
| 377 |
looks for `uix:thumb` elements with the `type` attribute set to `"links"`. |
| 378 |
Within those, it looks for `uix:thumb` elements whose `role` attribute |
| 379 |
matches the $role parameter. This is similar to how link titles are |
| 380 |
selected. |
| 381 |
|
| 382 |
If the $thumbs parameter is empty, this template attempts to use a default |
| 383 |
thumbnail provided by a `uix:thumb` child element of $node. |
| 384 |
|
| 385 |
The $width and $height parameters can be computed automatically from the |
| 386 |
$node element. |
| 387 |
--> |
| 388 |
<xsl:template name="mal2html.ui.links.img"> |
| 389 |
<xsl:param name="node"/> |
| 390 |
<xsl:param name="thumbs"/> |
| 391 |
<xsl:param name="role"/> |
| 392 |
<xsl:param name="width" select="$node/@uix:width"/> |
| 393 |
<xsl:param name="height" select="$node/@uix:height"/> |
| 394 |
<xsl:choose> |
| 395 |
<xsl:when test="$thumbs"> |
| 396 |
<img> |
| 397 |
<xsl:for-each select="$thumbs[not(@type) or ( |
| 398 |
@type = 'link' and (not(@role) or @role = $role))]"> |
| 399 |
<xsl:sort data-type="number" select="number(not(@type = 'link'))"/> |
| 400 |
<xsl:sort data-type="number" select="number(not(@role = $role))"/> |
| 401 |
<xsl:sort data-type="number" select="number(not(@width))"/> |
| 402 |
<xsl:sort data-type="number" select="number(not(@height))"/> |
| 403 |
<xsl:sort data-type="number" select="($width div $height) div (@width div @height)"/> |
| 404 |
<xsl:sort data-type="number" select="math:abs($width - @width)"/> |
| 405 |
<xsl:sort data-type="number" select="math:abs($height - @height)"/> |
| 406 |
<xsl:if test="position() = 1"> |
| 407 |
<xsl:call-template name="mal2html.ui.links.img.src"> |
| 408 |
<xsl:with-param name="node" select="$node"/> |
| 409 |
<xsl:with-param name="thumb" select="."/> |
| 410 |
</xsl:call-template> |
| 411 |
<xsl:call-template name="mal2html.ui.links.img.attrs"> |
| 412 |
<xsl:with-param name="node" select="$node"/> |
| 413 |
<xsl:with-param name="thumb" select="."/> |
| 414 |
<xsl:with-param name="width" select="$width"/> |
| 415 |
<xsl:with-param name="height" select="$height"/> |
| 416 |
</xsl:call-template> |
| 417 |
</xsl:if> |
| 418 |
</xsl:for-each> |
| 419 |
</img> |
| 420 |
</xsl:when> |
| 421 |
<xsl:when test="$node/uix:thumb"> |
| 422 |
<img> |
| 423 |
<xsl:call-template name="mal2html.ui.links.img.src"> |
| 424 |
<xsl:with-param name="node" select="$node"/> |
| 425 |
<xsl:with-param name="thumb" select="$node/uix:thumb"/> |
| 426 |
</xsl:call-template> |
| 427 |
<xsl:call-template name="mal2html.ui.links.img.attrs"> |
| 428 |
<xsl:with-param name="node" select="$node"/> |
| 429 |
<xsl:with-param name="thumb" select="$node/uix:thumb"/> |
| 430 |
<xsl:with-param name="width" select="$width"/> |
| 431 |
<xsl:with-param name="height" select="$height"/> |
| 432 |
</xsl:call-template> |
| 433 |
</img> |
| 434 |
</xsl:when> |
| 435 |
</xsl:choose> |
| 436 |
</xsl:template> |
| 437 |
|
| 438 |
|
| 439 |
<!--**========================================================================== |
| 440 |
mal2html.ui.links.img.src |
| 441 |
Output the `src` attribute for a thumbnail image. |
| 442 |
@revision[version=3.28 date=2017-08-11 status=final] |
| 443 |
|
| 444 |
[xsl:params] |
| 445 |
$node: A `links` element to link from. |
| 446 |
$thumb: A `uix:thumb` element. |
| 447 |
$width: The width to fit thumbnails into. |
| 448 |
$height: The height to fit thumbnails into. |
| 449 |
|
| 450 |
This template outputs `src` attribute for the HTML `img` element created |
| 451 |
from $thumb. By default, it just copies the `src` attribute of $thumb. |
| 452 |
Override this template if you need to support multi-directory output. |
| 453 |
--> |
| 454 |
<xsl:template name="mal2html.ui.links.img.src"> |
| 455 |
<xsl:param name="node"/> |
| 456 |
<xsl:param name="thumb"/> |
| 457 |
<xsl:attribute name="src"> |
| 458 |
<xsl:value-of select="$thumb/@src"/> |
| 459 |
</xsl:attribute> |
| 460 |
</xsl:template> |
| 461 |
|
| 462 |
|
| 463 |
<!--**========================================================================== |
| 464 |
mal2html.ui.links.img.attrs |
| 465 |
Output the `width` and `height` attributes for a thumbnail image. |
| 466 |
@revision[version=3.28 date=2017-08-11 status=final] |
| 467 |
|
| 468 |
[xsl:params] |
| 469 |
$node: A `links` element to link from. |
| 470 |
$thumb: A `uix:thumb` element. |
| 471 |
$width: The width to fit thumbnails into. |
| 472 |
$height: The height to fit thumbnails into. |
| 473 |
|
| 474 |
This template outputs `width` and `height` attributes for the HTML `img` |
| 475 |
element created from $thumb, based on the `uix:overflow` attribute on $node. |
| 476 |
The $width and $height parameters can be computed automatically from the |
| 477 |
$node element. |
| 478 |
--> |
| 479 |
<xsl:template name="mal2html.ui.links.img.attrs"> |
| 480 |
<xsl:param name="node"/> |
| 481 |
<xsl:param name="thumb"/> |
| 482 |
<xsl:param name="width" select="$node/@uix:width"/> |
| 483 |
<xsl:param name="height" select="$node/@uix:height"/> |
| 484 |
<xsl:choose> |
| 485 |
<xsl:when test="$node/@uix:overflow = 'crop'"/> |
| 486 |
<xsl:when test="$node/@uix:overflow = 'width'"> |
| 487 |
<xsl:attribute name="width"> |
| 488 |
<xsl:value-of select="$width"/> |
| 489 |
</xsl:attribute> |
| 490 |
</xsl:when> |
| 491 |
<xsl:when test="$node/@uix:overflow = 'height'"> |
| 492 |
<xsl:attribute name="height"> |
| 493 |
<xsl:value-of select="$height"/> |
| 494 |
</xsl:attribute> |
| 495 |
</xsl:when> |
| 496 |
<xsl:when test="$node/@uix:overflow = 'scale'"> |
| 497 |
<xsl:attribute name="width"> |
| 498 |
<xsl:value-of select="$width"/> |
| 499 |
</xsl:attribute> |
| 500 |
<xsl:attribute name="height"> |
| 501 |
<xsl:value-of select="$height"/> |
| 502 |
</xsl:attribute> |
| 503 |
</xsl:when> |
| 504 |
<xsl:when test="$thumb/@width and $thumb/@height"> |
| 505 |
<xsl:variable name="ratio" select="$width div $height"/> |
| 506 |
<xsl:variable name="tratio" select="$thumb/@width div $thumb/@height"/> |
| 507 |
<xsl:choose> |
| 508 |
<xsl:when test="$thumb/@width < $width and $thumb/@height < $height"> |
| 509 |
<xsl:copy-of select="$thumb/@width | $thumb/@height"/> |
| 510 |
</xsl:when> |
| 511 |
<xsl:when test="$ratio < $tratio"> |
| 512 |
<xsl:attribute name="width"> |
| 513 |
<xsl:value-of select="$width"/> |
| 514 |
</xsl:attribute> |
| 515 |
<xsl:attribute name="height"> |
| 516 |
<xsl:value-of select="round($width * ($thumb/@height div $thumb/@width))"/> |
| 517 |
</xsl:attribute> |
| 518 |
</xsl:when> |
| 519 |
<xsl:otherwise> |
| 520 |
<xsl:attribute name="width"> |
| 521 |
<xsl:value-of select="round($height * ($thumb/@width div $thumb/@height))"/> |
| 522 |
</xsl:attribute> |
| 523 |
<xsl:attribute name="height"> |
| 524 |
<xsl:value-of select="$height"/> |
| 525 |
</xsl:attribute> |
| 526 |
</xsl:otherwise> |
| 527 |
</xsl:choose> |
| 528 |
</xsl:when> |
| 529 |
<xsl:otherwise> |
| 530 |
<xsl:attribute name="width"> |
| 531 |
<xsl:value-of select="$width"/> |
| 532 |
</xsl:attribute> |
| 533 |
<xsl:attribute name="height"> |
| 534 |
<xsl:value-of select="$height"/> |
| 535 |
</xsl:attribute> |
| 536 |
</xsl:otherwise> |
| 537 |
</xsl:choose> |
| 538 |
</xsl:template> |
| 539 |
|
| 540 |
|
| 541 |
<!-- == Matched Templates == --> |
| 542 |
|
| 543 |
<!-- = ui:thumb = --> |
| 544 |
<xsl:template mode="mal2html.block.mode" match="uix:thumb"/> |
| 545 |
|
| 546 |
<!-- = ui:overlay = --> |
| 547 |
<xsl:template mode="mal2html.block.mode" match="uix:overlay"> |
| 548 |
<xsl:variable name="media" select="mal:media[1]"/> |
| 549 |
<xsl:variable name="width"> |
| 550 |
<xsl:choose> |
| 551 |
<xsl:when test="@width"> |
| 552 |
<xsl:value-of select="@width"/> |
| 553 |
</xsl:when> |
| 554 |
<xsl:otherwise> |
| 555 |
<xsl:text>280</xsl:text> |
| 556 |
</xsl:otherwise> |
| 557 |
</xsl:choose> |
| 558 |
</xsl:variable> |
| 559 |
<xsl:variable name="height"> |
| 560 |
<xsl:choose> |
| 561 |
<xsl:when test="@height"> |
| 562 |
<xsl:value-of select="@height"/> |
| 563 |
</xsl:when> |
| 564 |
<xsl:otherwise> |
| 565 |
<xsl:text>280</xsl:text> |
| 566 |
</xsl:otherwise> |
| 567 |
</xsl:choose> |
| 568 |
</xsl:variable> |
| 569 |
<div class="links-tile"> |
| 570 |
<a href="{$media/@src}" class="ui-overlay"> |
| 571 |
<span class="links-tile-img"> |
| 572 |
<xsl:choose> |
| 573 |
<xsl:when test="$media/uix:thumb"> |
| 574 |
<img src="{$media/uix:thumb[1]/@src}" width="{$width}"/> |
| 575 |
</xsl:when> |
| 576 |
<!-- FIXME: audio/video with image child --> |
| 577 |
<!-- |
| 578 |
<xsl:when test="($media/@type = 'video' or $media/@type = 'audio') and |
| 579 |
$media/mal:media[not(@type) or @type = 'image']"> |
| 580 |
</xsl:when> |
| 581 |
--> |
| 582 |
<xsl:when test="$media/@type = 'video'"> |
| 583 |
<video src="{$media/@src}" width="{$width}"/> |
| 584 |
</xsl:when> |
| 585 |
<xsl:otherwise> |
| 586 |
<img src="{$media/@src}" width="{$width}"/> |
| 587 |
</xsl:otherwise> |
| 588 |
</xsl:choose> |
| 589 |
</span> |
| 590 |
<xsl:if test="$media/uix:thumb/uix:caption"> |
| 591 |
<span class="links-tile-text"> |
| 592 |
<xsl:variable name="title" select="$media/uix:thumb/uix:caption/mal:title[1]"/> |
| 593 |
<xsl:if test="$title"> |
| 594 |
<span> |
| 595 |
<xsl:attribute name="class"> |
| 596 |
<xsl:text>title</xsl:text> |
| 597 |
<xsl:if test="contains(concat(' ', $title/@style, ' '), ' center ')"> |
| 598 |
<xsl:text> center</xsl:text> |
| 599 |
</xsl:if> |
| 600 |
</xsl:attribute> |
| 601 |
<xsl:apply-templates mode="mal2html.inline.mode" select="$title/node()"/> |
| 602 |
</span> |
| 603 |
</xsl:if> |
| 604 |
<xsl:variable name="desc" select="$media/uix:thumb/uix:caption/mal:desc[1]"/> |
| 605 |
<xsl:if test="$desc"> |
| 606 |
<span> |
| 607 |
<xsl:attribute name="class"> |
| 608 |
<xsl:text>desc</xsl:text> |
| 609 |
<xsl:if test="contains(concat(' ', $desc/@style, ' '), ' center ')"> |
| 610 |
<xsl:text> center</xsl:text> |
| 611 |
</xsl:if> |
| 612 |
</xsl:attribute> |
| 613 |
<xsl:apply-templates mode="mal2html.inline.mode" select="$desc/node()"/> |
| 614 |
</span> |
| 615 |
</xsl:if> |
| 616 |
</span> |
| 617 |
</xsl:if> |
| 618 |
</a> |
| 619 |
<div class="ui-overlay"> |
| 620 |
<div class="inner"> |
| 621 |
<a href="#" class="ui-overlay-close"> |
| 622 |
<xsl:attribute name="title"> |
| 623 |
<xsl:call-template name="l10n.gettext"> |
| 624 |
<xsl:with-param name="msgid" select="'Close'"/> |
| 625 |
</xsl:call-template> |
| 626 |
</xsl:attribute> |
| 627 |
<xsl:text>тип</xsl:text> |
| 628 |
</a> |
| 629 |
<xsl:apply-templates mode="mal2html.block.mode" select="uix:caption/mal:title[1]"/> |
| 630 |
<div class="contents"> |
| 631 |
<xsl:apply-templates mode="mal2html.block.mode" select="$media"/> |
| 632 |
</div> |
| 633 |
<xsl:apply-templates mode="mal2html.block.mode" select="uix:caption/mal:desc[1]"/> |
| 634 |
</div> |
| 635 |
</div> |
| 636 |
</div> |
| 637 |
</xsl:template> |
| 638 |
|
| 639 |
</xsl:stylesheet> |