Skip to content

Commit

Permalink
Moved tei2html script
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Nov 21, 2019
1 parent 376e338 commit d4e38db
Show file tree
Hide file tree
Showing 10 changed files with 2,107 additions and 1,478 deletions.
1,025 changes: 0 additions & 1,025 deletions xxe/eoa/xsl/tei2html.xsl

This file was deleted.

96 changes: 96 additions & 0 deletions xxe/eoa/xsl/tei2html/tei2html.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:eoa="http://www.edition-open-access.de/ns"
exclude-result-prefixes="xs tei eoa"
version="2.0"
>
<xsl:output
method="html"
encoding="UTF-8"
indent="yes"
/>

<xsl:include href="tei2html_publ_frontpage_utils.xsl"/>
<xsl:include href="tei2html_chapter_utils.xsl"/>
<xsl:include href="utils/html_rules.xsl"/>
<xsl:include href="utils/common.xsl"/>
<xsl:include href="utils/print.xsl"/>

<xsl:param name="output_dir" as="xs:string" select="'./output'"/>
<xsl:param name="static_dir" as="xs:string" select="'../static'"/>
<xsl:param name="intermediate_dir" as="xs:string?" select="concat($output_dir, '/intermediate')"/>
<xsl:param name="logo_dir" as="xs:string" select="concat($static_dir, '/assets/images')"/>
<xsl:param name="nav_items" as="element(eoa:entry)*">
<eoa:entry active="1">
<eoa:link>
<xsl:text>#</xsl:text>
</eoa:link>
<eoa:title>Publications</eoa:title>
</eoa:entry>
</xsl:param>

<!--
<xsl:param name="verbosity" as="xs:integer" required="no" select="0"/>
-->

<xsl:template match="/">
<xsl:sequence select="eoa:info(concat('domain: ', $domain))"/>
<xsl:variable name="output_subdir" as="xs:string">
<xsl:value-of select="concat($output_dir, '/', $series, '/', $publication_number)"/>
</xsl:variable>
<xsl:variable name="indices" as="element(eoa:index)*">
<xsl:variable name="ctxt" select="."/>
<xsl:for-each select="$index_types">
<xsl:variable name="index_type" as="xs:string" select="."/>
<xsl:for-each select="$ctxt">
<xsl:call-template name="create_index">
<xsl:with-param name="indextype" select="$index_type"/>
</xsl:call-template>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$intermediate_dir">
<xsl:result-document
method="xml"
encoding="UTF-8"
indent="yes"
href="{concat($intermediate_dir, '/indices.xml')}"
>
<xsl:copy-of select="$indices"/>
</xsl:result-document>
</xsl:if>
<xsl:result-document
method="html"
encoding="UTF-8"
include-content-type="yes"
indent="yes"
href="{concat($output_subdir, '/index.html')}"
>
<xsl:call-template name="render_publication_frontpage">
<xsl:with-param name="static_dir" select="concat('../../', $static_dir)"/>
<xsl:with-param name="logo_dir" select="concat('../../', $logo_dir)"/>
<xsl:with-param name="nav_items" as="element(eoa:entry)*" select="$nav_items"/>
<xsl:with-param name="indices" as="element(eoa:index)*" select="$indices"/>
</xsl:call-template>
</xsl:result-document>
<xsl:for-each select="//tei:div[@type='chapter']">
<xsl:result-document
method="html"
encoding="UTF-8"
include-content-type="yes"
indent="yes"
href="{concat($output_subdir, '/', position(), '/index.html')}"
>
<xsl:call-template name="render_chapter">
<xsl:with-param name="static_dir" select="concat('../../../', $static_dir)"/>
<xsl:with-param name="logo_dir" select="concat('../../../', $logo_dir)"/>
<xsl:with-param name="nav_items" as="element(eoa:entry)*" select="$nav_items"/>
</xsl:call-template>
</xsl:result-document>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
40 changes: 40 additions & 0 deletions xxe/eoa/xsl/tei2html/tei2html_chapter.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:eoa="http://www.edition-open-access.de/ns"
exclude-result-prefixes="xs tei eoa"
version="2.0">

<xsl:param name="static_dir" as="xs:string" select="'static'"/>
<xsl:param name="logo_dir" as="xs:string" select="concat($static_dir, '/assets/images')"/>
<xsl:param name="nav_items" as="element(eoa:entry)*">
<eoa:entry active="1">
<eoa:link>
<xsl:text>#</xsl:text>
</eoa:link>
<eoa:title>Publications</eoa:title>
</eoa:entry>
</xsl:param>
<xsl:param name="chapter_nr" as="xs:integer" required="1"/>

<xsl:output method="html" encoding="UTF-8"/>

<xsl:include href="utils/common.xsl"/>
<xsl:include href="utils/html_rules.xsl"/>
<xsl:include href="tei2html_chapter_utils.xsl"/>

<xsl:template match="/">
<xsl:sequence select="eoa:info(concat('domain: ', $domain))"/>
<xsl:for-each select="(//tei:div[@type='chapter'])[position() = $chapter_nr]">
<xsl:sequence select="eoa:info(concat('printing chapter ', $chapter_nr, '. head: ', tei:head))"/>
<xsl:call-template name="render_chapter">
<xsl:with-param name="static_dir" select="$static_dir"/>
<xsl:with-param name="logo_dir" select="$logo_dir"/>
<xsl:with-param name="nav_items" as="element(eoa:entry)*" select="$nav_items"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
246 changes: 246 additions & 0 deletions xxe/eoa/xsl/tei2html/tei2html_chapter_utils.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:tei="http://www.tei-c.org/ns/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:eoa="http://www.edition-open-access.de/ns"
exclude-result-prefixes="xs tei eoa"
version="2.0"
>
<xsl:output method="html" encoding="UTF-8"/>

<!-- use-character-maps="texreplacements"/>-->
<xsl:variable name="langid" select="//tei:langUsage/tei:language/@ident"/>
<xsl:variable name="transl" select="document('data/aux/translations.xml')"/>

<xsl:key name="en" match="translations/entry" use="@en"/>
<xsl:key name="de" match="translations/entry" use="@de"/>
<xsl:key name="fr" match="translations/entry" use="@fr"/>
<xsl:key name="it" match="translations/entry" use="@it"/>

<!-- index sorting, https://stackoverflow.com/questions/13763271 -->
<xsl:key name="kWith1stLetter" match="family" use="substring(.,1,1)"/>

<!-- context: //tei:div[@type='chapter'] -->
<xsl:template name="render_chapter">
<xsl:param name="static_dir" as="xs:string"/>
<xsl:param name="logo_dir" as="xs:string"/>
<xsl:param name="nav_items" as="element(eoa:entry)*"/>

<xsl:call-template name="website_template">
<xsl:with-param name="title">
<xsl:call-template name="chapter_title"/>
</xsl:with-param>
<xsl:with-param name="platform_name">Edition Open Access</xsl:with-param>
<xsl:with-param name="platform_link">http://edition-open-access.de</xsl:with-param>
<xsl:with-param name="platform_logo">
<!-- TODO: replace by "text logo" -->
<xsl:value-of select="concat($logo_dir, '/logo.png')"/>
</xsl:with-param>
<xsl:with-param name="nav_items" as="element(eoa:entry)*" select="$nav_items"/>
<xsl:with-param name="meta_tags">
<xsl:call-template name="website_meta_tags">
<xsl:with-param name="citation_title">
<xsl:choose>
<xsl:when test="./tei:head/tei:choice">
<xsl:apply-templates select="./tei:head/tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./tei:head"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="citation_author">
<xsl:choose>
<xsl:when test="@resp">
<xsl:variable name="people" select="@resp"/>
<xsl:call-template name="format_string_authors">
<xsl:with-param name="authors" select="$people"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="people" select="//tei:titleStmt/tei:author/@ref | //tei:titleStmt/tei:editor[@role='volumeeditor']/@ref"/>
<xsl:call-template name="format_persons">
<xsl:with-param name="people" select="$people"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="dc_title">
<xsl:choose>
<xsl:when test="./tei:head/tei:choice">
<xsl:apply-templates select="./tei:head/tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./tei:head"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
<xsl:with-param name="dc_publisher">
<xsl:value-of select="//tei:publicationStmt/tei:publisher/tei:orgName[@n='Press']/tei:choice/tei:expan/text()"/>
</xsl:with-param>
<xsl:with-param name="dc_creator">
<xsl:variable name="people" select="//tei:titleStmt/tei:author/@ref | //tei:titleStmt/tei:editor[@role='volumeeditor']/@ref"/>
<xsl:call-template name="format_persons">
<xsl:with-param name="people" select="$people"/>
</xsl:call-template>
</xsl:with-param>
</xsl:call-template>
</xsl:with-param>
<xsl:with-param name="static_dir" select="$static_dir"/>
<xsl:with-param name="breadcrumbs" as="element(eoa:entry)*">
<eoa:entry>
<eoa:link>
<xsl:value-of select="concat('./publications.html/', lower-case(//tei:seriesStmt/tei:title))"/>
</eoa:link>
<eoa:title>
<xsl:value-of select="//tei:seriesStmt/tei:title"/>
</eoa:title>
</eoa:entry>
<eoa:entry>
<eoa:link>
<xsl:value-of select="concat('../../', //tei:seriesStmt/tei:idno[@type='number'], '/index.html')"/>
</eoa:link>
<eoa:title>
<xsl:apply-templates select="//tei:titleStmt/tei:title[@type='main']"/>
</eoa:title>
</eoa:entry>
<eoa:entry active="1">
<eoa:title>
<xsl:choose>
<xsl:when test="./tei:head/tei:choice">
<xsl:apply-templates select="./tei:head/tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./tei:head"/>
</xsl:otherwise>
</xsl:choose>
</eoa:title>
</eoa:entry>
</xsl:with-param>
<xsl:with-param name="main">
<main class="main publications publications2">
<div class="container">
<div class="main-content">
<!-- chapter table of contents -->
<section class="publications__overview">
<div class="accordion">
<div class="accordion__item accordion__item--border-top active">
<a class="accordion__title" href="#">
<h2>Overview</h2>
</a>
<div class="accordion__content">
<div class="publications__list">
<ul>
<xsl:for-each select="./tei:div[@type='section']">
<li>
<xsl:element name="a">
<xsl:attribute name="href" select="concat('#',@xml:id)"/>
<xsl:if test="../@n != 'nonumber'">
<xsl:value-of select="concat(../@n, '.', @n, ' ')"/>
</xsl:if>
<!-- build-toc mode is as yet unspecified, but it does the trick -->
<xsl:apply-templates select="./tei:head" mode="build-toc"/>
</xsl:element>
</li>
</xsl:for-each>
</ul>
</div>
</div>
</div>
</div>
<a class="link link--green" href="#">
<span class="link__label link__label--outer">Download Chapter</span>
</a>
</section>
<!-- chapter content: -->
<section class="publication-detail">
<xsl:apply-templates mode="chapter_main" select="."/>
<!-- back/forward navigation -->
<xsl:apply-templates mode="chapter_navigation" select="."/>
</section>
<!-- chapter content closed-->
</div>
</div>
</main>
</xsl:with-param>
<xsl:with-param name="footer_items" as="element(eoa:entry)*">
<eoa:entry>
<eoa:link><xsl:text>/imprint.html</xsl:text></eoa:link>
<eoa:title>Imprint &amp; Contact</eoa:title>
</eoa:entry>
<eoa:entry>
<eoa:link><xsl:text>/technical.html</xsl:text></eoa:link>
<eoa:title>Technical Information</eoa:title>
</eoa:entry>
</xsl:with-param>
<xsl:with-param name="script">
<xsl:if test=".//tei:formula">
<xsl:sequence select="eoa:info('adding mathjax...')"/>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ["tex2jax.js"],
jax: ["input/TeX","output/HTML-CSS"],
tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}
});
</script>
<script type="text/javascript" src="{concat($static_dir, '/MathJax-2.7.5/MathJax.js')}"/>
</xsl:if>
</xsl:with-param>
</xsl:call-template>
</xsl:template>

<xsl:template name="chapter_title">
<xsl:value-of select="//tei:publicationStmt/tei:publisher/tei:orgName[@n='Press']/tei:choice/tei:abbr/text()"/>
<xsl:text> | </xsl:text>
<xsl:apply-templates select="//tei:titleStmt/tei:title[@type='main']"/>
<xsl:text> | </xsl:text>
<xsl:choose>
<xsl:when test="./tei:head/tei:choice">
<xsl:apply-templates select="./tei:head/tei:choice/tei:expan"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="./tei:head"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="footnotes">
<xsl:variable name="chapter" select="."/>
<xsl:if test="$chapter//tei:note[@place = 'bottom']">
<div class="accordion__item active">
<a class="accordion__title" href="#">
<h2> Footnotes </h2>
</a>
<div class="accordion__content">
<div class="publication-detail__footnotes">
<ol>
<xsl:for-each select="$chapter//tei:note[@place = 'bottom']">
<xsl:variable name="container_id" as="xs:string?">
<xsl:for-each select="parent::tei:*">
<xsl:call-template name="container_id"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="footnote_id" as="xs:string">
<xsl:call-template name="footnote_id"/>
</xsl:variable>
<xsl:if test="$container_id">
<li id="{$footnote_id}">
<xsl:for-each select="tei:p">
<p><xsl:apply-templates mode="html"/></p>
</xsl:for-each>
<a href="#{$container_id}">to paragraph</a>
</li>
</xsl:if>
</xsl:for-each>
</ol>
</div>
<!-- the link to close the accordeon: -->
<a class="accordion__pageup" href="#"></a> <a class="accordion__popap" href="#"></a>
<div class="accordion__popap-eye"></div>
</div>
</div>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
Loading

0 comments on commit d4e38db

Please sign in to comment.