Skip to content

Commit 6e07cf3

Browse files
Assembly: move static-url templates to pretext-html
1 parent 5ce43aa commit 6e07cf3

2 files changed

Lines changed: 93 additions & 89 deletions

File tree

xsl/pretext-assembly.xsl

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3220,95 +3220,6 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
32203220
<xsl:template match="interactive[@desmos|@geogebra|@calcplot3d|@circuitjs|@iframe]" mode="embed-iframe-url"/>
32213221

32223222

3223-
<!-- Static URL's -->
3224-
<!-- Predictable and/or stable URLs for versions -->
3225-
<!-- of interactives available online. These are -->
3226-
<!-- -->
3227-
<!-- (1) "standalone" pages for author/local material, -->
3228-
<!-- as a product of the HTML conversion -->
3229-
<!-- (2) computable addresses of network resources, -->
3230-
<!-- eg the YouTube page of a resource -->
3231-
3232-
<!-- Point to HTML-produced, and canonically-hosted, standalone page -->
3233-
<!-- NB: baseurl is assumed to have a trailing slash -->
3234-
3235-
<xsl:template match="audio[@source|@href]|video[@source|@href]|interactive" mode="static-url">
3236-
<xsl:value-of select="$baseurl"/>
3237-
<xsl:apply-templates select="." mode="standalone-filename" />
3238-
</xsl:template>
3239-
3240-
<!-- Natural override for YouTube videos -->
3241-
<!-- Better - standalone page, with "View on You Tube" -->
3242-
3243-
<!-- NB: ampersand is escaped for LaTeX use, be careful with switch to QR codes via Python! -->
3244-
<!-- POTENTIAL BUG: this should be un-LaTeX'ed for general use and then -->
3245-
<!-- sanitized on the receiving end in the LaTeX conversion, or maybe -->
3246-
<!-- the LaTeX conversion will do just fine if the right URL package is -->
3247-
<!-- used and the ampersand is handled correctly? -->
3248-
3249-
<xsl:template match="video[@youtube|@youtubeplaylist]" mode="static-url">
3250-
<xsl:apply-templates select="." mode="youtube-view-url" />
3251-
<xsl:if test="@start">
3252-
<xsl:text>\&amp;start=</xsl:text>
3253-
<xsl:value-of select="@start" />
3254-
</xsl:if>
3255-
<xsl:if test="@end">
3256-
<xsl:text>\&amp;end=</xsl:text>
3257-
<xsl:value-of select="@end" />
3258-
</xsl:if>
3259-
</xsl:template>
3260-
3261-
<xsl:template match="video[@youtube|@youtubeplaylist]" mode="youtube-view-url">
3262-
<xsl:variable name="youtube">
3263-
<xsl:choose>
3264-
<xsl:when test="@youtubeplaylist">
3265-
<xsl:value-of select="normalize-space(@youtubeplaylist)"/>
3266-
</xsl:when>
3267-
<xsl:otherwise>
3268-
<xsl:value-of select="normalize-space(str:replace(@youtube, ',', ' '))" />
3269-
</xsl:otherwise>
3270-
</xsl:choose>
3271-
</xsl:variable>
3272-
<xsl:text>https://www.youtube.com/</xsl:text>
3273-
<xsl:choose>
3274-
<xsl:when test="@youtubeplaylist">
3275-
<xsl:text>playlist?list=</xsl:text>
3276-
<xsl:value-of select="$youtube" />
3277-
</xsl:when>
3278-
<xsl:when test="contains($youtube, ' ')">
3279-
<xsl:text>watch_videos?video_ids=</xsl:text>
3280-
<xsl:value-of select="str:replace($youtube, ' ', ',')" />
3281-
</xsl:when>
3282-
<xsl:otherwise>
3283-
<xsl:text>watch?v=</xsl:text>
3284-
<xsl:value-of select="$youtube" />
3285-
</xsl:otherwise>
3286-
</xsl:choose>
3287-
</xsl:template>
3288-
3289-
<!-- Vimeo view URL -->
3290-
<xsl:template match="video[@vimeo]" mode="static-url">
3291-
<xsl:text>https://vimeo.com/</xsl:text>
3292-
<xsl:value-of select="@vimeo"/>
3293-
</xsl:template>
3294-
3295-
<!-- A bit different than above, but same mode -->
3296-
<!-- When a "datafile" is produced in a static -->
3297-
<!-- context, then we append the $baseurl, and -->
3298-
<!-- provide the external directory. -->
3299-
<xsl:template match="dataurl[@source]" mode="static-url">
3300-
<xsl:value-of select="$baseurl"/>
3301-
<!-- empty when not using managed directories -->
3302-
<xsl:value-of select="$external-directory"/>
3303-
<xsl:apply-templates select="@source" />
3304-
</xsl:template>
3305-
3306-
<!-- interactive programs -->
3307-
<xsl:template match="program[@interactive != '' and @interactive != 'no']" mode="static-url">
3308-
<xsl:value-of select="$baseurl"/>
3309-
<xsl:apply-templates select="." mode="containing-filename" />
3310-
</xsl:template>
3311-
33123223
<!-- The contents of a datafile may be encoded as text in an XML -->
33133224
<!-- file within the generated/datafile directory. The filename -->
33143225
<!-- has this construction, even if we do not always consult it. -->

xsl/pretext-html.xsl

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14025,4 +14025,97 @@ TODO:
1402514025
</exsl:document>
1402614026
</xsl:template>
1402714027

14028+
14029+
<!-- Static URL's -->
14030+
<!-- Predictable and/or stable URLs for versions -->
14031+
<!-- of interactives available online. These are -->
14032+
<!-- -->
14033+
<!-- (1) "standalone" pages for author/local material, -->
14034+
<!-- as a product of the HTML conversion -->
14035+
<!-- (2) computable addresses of network resources, -->
14036+
<!-- eg the YouTube page of a resource -->
14037+
14038+
<!-- Point to HTML-produced, and canonically-hosted, standalone page -->
14039+
<!-- NB: baseurl is assumed to have a trailing slash -->
14040+
14041+
<xsl:template match="audio[@source|@href]|video[@source|@href]|interactive" mode="static-url">
14042+
<xsl:value-of select="$baseurl"/>
14043+
<xsl:apply-templates select="." mode="standalone-filename" />
14044+
</xsl:template>
14045+
14046+
<!-- Natural override for YouTube videos -->
14047+
<!-- Better - standalone page, with "View on You Tube" -->
14048+
14049+
<!-- NB: ampersand is escaped for LaTeX use, be careful with switch to QR codes via Python! -->
14050+
<!-- POTENTIAL BUG: this should be un-LaTeX'ed for general use and then -->
14051+
<!-- sanitized on the receiving end in the LaTeX conversion, or maybe -->
14052+
<!-- the LaTeX conversion will do just fine if the right URL package is -->
14053+
<!-- used and the ampersand is handled correctly? -->
14054+
14055+
<xsl:template match="video[@youtube|@youtubeplaylist]" mode="static-url">
14056+
<xsl:apply-templates select="." mode="youtube-view-url" />
14057+
<xsl:if test="@start">
14058+
<xsl:text>\&amp;start=</xsl:text>
14059+
<xsl:value-of select="@start" />
14060+
</xsl:if>
14061+
<xsl:if test="@end">
14062+
<xsl:text>\&amp;end=</xsl:text>
14063+
<xsl:value-of select="@end" />
14064+
</xsl:if>
14065+
</xsl:template>
14066+
14067+
<xsl:template match="video[@youtube|@youtubeplaylist]" mode="youtube-view-url">
14068+
<xsl:variable name="youtube">
14069+
<xsl:choose>
14070+
<xsl:when test="@youtubeplaylist">
14071+
<xsl:value-of select="normalize-space(@youtubeplaylist)"/>
14072+
</xsl:when>
14073+
<xsl:otherwise>
14074+
<xsl:value-of select="normalize-space(str:replace(@youtube, ',', ' '))" />
14075+
</xsl:otherwise>
14076+
</xsl:choose>
14077+
</xsl:variable>
14078+
<xsl:text>https://www.youtube.com/</xsl:text>
14079+
<xsl:choose>
14080+
<xsl:when test="@youtubeplaylist">
14081+
<xsl:text>playlist?list=</xsl:text>
14082+
<xsl:value-of select="$youtube" />
14083+
</xsl:when>
14084+
<xsl:when test="contains($youtube, ' ')">
14085+
<xsl:text>watch_videos?video_ids=</xsl:text>
14086+
<xsl:value-of select="str:replace($youtube, ' ', ',')" />
14087+
</xsl:when>
14088+
<xsl:otherwise>
14089+
<xsl:text>watch?v=</xsl:text>
14090+
<xsl:value-of select="$youtube" />
14091+
</xsl:otherwise>
14092+
</xsl:choose>
14093+
</xsl:template>
14094+
14095+
<!-- Vimeo view URL -->
14096+
<xsl:template match="video[@vimeo]" mode="static-url">
14097+
<xsl:text>https://vimeo.com/</xsl:text>
14098+
<xsl:value-of select="@vimeo"/>
14099+
</xsl:template>
14100+
14101+
<!-- A bit different than above, but same mode -->
14102+
<xsl:template match="program[@interactive]" mode="static-url">
14103+
<xsl:message>-asb=-=-=<xsl:value-of select="$baseurl"/></xsl:message>
14104+
<xsl:message>-asb=-=-=<xsl:apply-templates select="." mode="assembly-id" /></xsl:message>
14105+
<xsl:message>-asb=-=-=<xsl:value-of select="@unique-id"/></xsl:message>
14106+
<xsl:value-of select="$baseurl"/>
14107+
<xsl:apply-templates select="." mode="containing-filename" />
14108+
</xsl:template>
14109+
14110+
<!-- A bit different than above, but same mode -->
14111+
<!-- When a "datafile" is produced in a static -->
14112+
<!-- context, then we append the $baseurl, and -->
14113+
<!-- provide the external directory. -->
14114+
<xsl:template match="dataurl[@source]" mode="static-url">
14115+
<xsl:value-of select="$baseurl"/>
14116+
<!-- empty when not using managed directories -->
14117+
<xsl:value-of select="$external-directory"/>
14118+
<xsl:apply-templates select="@source" />
14119+
</xsl:template>
14120+
1402814121
</xsl:stylesheet>

0 commit comments

Comments
 (0)