Skip to content

Commit

Permalink
DBT-383 Add new toc layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoniafriedrich committed Jan 10, 2025
1 parent 112acd8 commit c394d84
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 71 deletions.
66 changes: 39 additions & 27 deletions src/main/resources/toc-layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

<toc-layouts default="legacy">

<toc-layout id="journal_by_volume" field="mir.toc.ancestor">
<label>Band > Heft > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mir.toc.host.volume" order="desc" expanded="true">
<toc-layout id="journal_by_year" field="mir.toc.ancestor">
<label>Jahrgang > Heft > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mods.yearIssued" order="desc" expanded="true">
<level field="mir.toc.host.issue" order="desc" expanded="false">
<publications>
<sortBy field="mir.toc.host.page.int" order="asc" />
Expand All @@ -37,49 +37,61 @@
</level>
</toc-layout>

<toc-layout id="volume_only" field="mir.toc.ancestor">
<label>Band > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mir.toc.host.volume" order="desc" expanded="false">
<!-- This is, pretty much, the MIR legacy layout that was hard-coded -->
<toc-layout id="legacy" field="mir.toc.legacyParent">
<label>Jahrgang > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mods.yearIssued" order="desc" expanded="first">
<publications>
<sortBy field="mir.toc.host.page.int" order="asc" />
<sortBy field="mir.toc.host.page.str" order="asc" />
<sortBy field="mir.toc.host.order" order="desc"/>
<sortBy field="mir.toc.series.order" order="desc"/>
<sortBy field="mir.toc.host.page.int" order="asc"/>
<sortBy field="mir.toc.host.page.str" order="asc"/>
<sortBy field="mods.dateIssued" order="desc"/>
<sortBy field="mods.dateIssued.host" order="desc"/>
<sortBy field="mods.title.main" order="desc"/>
</publications>
</level>
</toc-layout>

<toc-layout id="journal_by_year" field="mir.toc.ancestor">
<label>Jahr > Heft > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mods.yearIssued" order="desc" expanded="true">
<toc-layout id="journal_by_volume" field="mir.toc.ancestor">
<label>Band > Heft > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mir.toc.host.volume" order="desc" expanded="true">
<level field="mir.toc.host.issue" order="desc" expanded="false">
<publications>
<sortBy field="mir.toc.host.page.int" order="asc" />
<sortBy field="mir.toc.host.page.str" order="asc" />
<sortBy field="mir.toc.host.page.int" order="asc"/>
<sortBy field="mir.toc.host.page.str" order="asc"/>
</publications>
</level>
</level>
</toc-layout>

<toc-layout id="blog" field="parent">
<label>Blog (gruppiert nach Erscheinungsjahr), Artikel mit Datum</label>
<level field="mods.yearIssued" order="desc" expanded="first">
<toc-layout id="volume_only" field="mir.toc.ancestor">
<label>Band > Artikel mit Autor:Titel, Seitenzahl</label>
<level field="mir.toc.host.volume" order="desc" expanded="false">
<publications>
<sortBy field="mods.dateIssued" order="desc" />
<sortBy field="mir.toc.host.page.int" order="asc"/>
<sortBy field="mir.toc.host.page.str" order="asc"/>
</publications>
</level>
</toc-layout>

<!-- This is, pretty much, the MIR legacy layout that was hard-coded -->
<toc-layout id="legacy" field="mir.toc.legacyParent">
<label>Standard (gruppiert nach Erscheinungsjahr)</label>

<toc-layout id="sorted_by_volume" field="mir.toc.ancestor">
<label>Band > Titel, Autor, Jahr (Serie)</label>
<level field="mir.toc.series.volume.top" order="asc" expanded="true">
<publications>
<sortBy field="mods.yearIssued" order="desc"/>
<sortBy field="mir.toc.authors" order="desc"/>
<sortBy field="mir.toc.title" order="desc"/>
</publications>
</level>
</toc-layout>

<toc-layout id="blog" field="parent">
<label>Blog (gruppiert nach Erscheinungsjahr), Artikel mit Datum</label>
<level field="mods.yearIssued" order="desc" expanded="first">
<publications>
<sortBy field="mir.toc.host.order" order="desc" />
<sortBy field="mir.toc.series.order" order="desc" />
<sortBy field="mir.toc.host.page.int" order="asc" />
<sortBy field="mir.toc.host.page.str" order="asc" />
<sortBy field="mods.dateIssued" order="desc" />
<sortBy field="mods.dateIssued.host" order="desc" />
<sortBy field="mods.title.main" order="desc" />
<sortBy field="mods.yearIssued" order="desc"/>
</publications>
</level>
</toc-layout>
Expand Down
147 changes: 103 additions & 44 deletions src/main/resources/xsl/toc/custom-toc-layouts.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
exclude-result-prefixes="xalan i18n"
>

<xsl:param name="CurrentLang" select="'de'" />
<xsl:param name="CurrentLang" select="'de'"/>

<!-- ====================
level default:
Expand All @@ -23,35 +23,35 @@

<xsl:template match="item[doc[not(field[@name='mir.toc.title'])]]">
<a href="{$WebApplicationBaseURL}receive/{doc/@id}">
<xsl:apply-templates select="." mode="text" />
<xsl:apply-templates select="." mode="text"/>
</a>
</xsl:template>

<xsl:template match="item">
<xsl:apply-templates select="." mode="text" />
<xsl:apply-templates select="." mode="text"/>
</xsl:template>

<xsl:template match="item" mode="text">
<span class="mir-toc-section-label">
<xsl:apply-templates select="." mode="label" />
<xsl:apply-templates select="." mode="label"/>
</span>
</xsl:template>

<xsl:template match="item" mode="label">
<xsl:value-of select="@value" />
<xsl:apply-templates select="doc" />
<xsl:value-of select="@value"/>
<xsl:apply-templates select="doc"/>
</xsl:template>

<xsl:template match="item/doc">
<xsl:for-each select="field[@name='mir.toc.title']">
<xsl:text>: </xsl:text>
<a href="{$WebApplicationBaseURL}receive/{../@id}">
<xsl:value-of select="." />
<xsl:value-of select="."/>
</a>
</xsl:for-each>
<xsl:for-each select="field[@name='mir.toc.authors']">
<br />
<xsl:value-of select="." />
<br/>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

Expand All @@ -64,12 +64,27 @@
==================== -->

<xsl:template match="level[@field='mir.toc.series.volume']/item" mode="label" priority="1">
<xsl:value-of select="i18n:translate('mir.details.volume.series')" />
<xsl:value-of select="i18n:translate('mir.details.volume.series')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@value" />
<xsl:apply-templates select="doc" />
<xsl:value-of select="@value"/>
<xsl:apply-templates select="doc"/>
</xsl:template>

<xsl:template match="level[@field='mir.toc.series.volume.top']/item" mode="label" priority="1">
<xsl:value-of select="concat(i18n:translate('mir.details.volume.series'),': ')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@value"/>
<xsl:apply-templates select="doc"/>
</xsl:template>

<xsl:template match="level[@field='mir.toc.host.issue.top']/item" mode="label" priority="1">
<xsl:value-of select="i18n:translate('mir.details.issue')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@value"/>
<xsl:apply-templates select="doc"/>
</xsl:template>


<!-- ====================
volume level:
- - - - - - - - - -
Expand All @@ -79,15 +94,15 @@
==================== -->

<xsl:template match="level[@field='mir.toc.host.volume']/item" mode="label" priority="1">
<xsl:value-of select="i18n:translate('mir.details.volume.journal')" />
<xsl:value-of select="i18n:translate('mir.details.volume.journal')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@value" />
<xsl:value-of select="@value"/>
<xsl:for-each select="doc/field[@name='mods.yearIssued']">
<xsl:text> (</xsl:text>
<xsl:value-of select="text()" />
<xsl:value-of select="text()"/>
<xsl:text>)</xsl:text>
</xsl:for-each>
<xsl:apply-templates select="doc" />
<xsl:apply-templates select="doc"/>
</xsl:template>

<!-- ====================
Expand All @@ -99,10 +114,10 @@
==================== -->

<xsl:template match="level[@field='mir.toc.host.issue']/item" mode="label" priority="1">
<xsl:value-of select="i18n:translate('mir.details.issue')" />
<xsl:value-of select="i18n:translate('mir.details.issue')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="@value" />
<xsl:apply-templates select="doc" />
<xsl:value-of select="@value"/>
<xsl:apply-templates select="doc"/>
</xsl:template>

<!-- ====================
Expand Down Expand Up @@ -146,6 +161,46 @@
</div>
</xsl:template>

<!-- ====================
sorted_by_volume:
- - - - - - - - - -
->vol
title (year)
authors
==================== -->

<xsl:template match="toc[@layout='sorted_by_volume']//publications/doc" priority="2">
<xsl:if test="(field[@name='mods.relatedItem.series'])">
<div class="row">
<div class="col-8">
<h4>
<xsl:attribute name="class">
<xsl:text>mir-toc-section-title</xsl:text>
<xsl:value-of select="concat(' ', 'col-10')"/>
</xsl:attribute>
<a href="{$WebApplicationBaseURL}receive/{@id}">
<xsl:value-of select="field[@name='mir.toc.title']"/>
</a>
</h4>
</div>
<div class="col-4">
<xsl:for-each select="field[@name='mods.yearIssued']">
<xsl:text> (</xsl:text>
<xsl:value-of select="text()"/>
<xsl:text>)</xsl:text>
</xsl:for-each>
</div>
</div>
<div class="row">
<div class="col-8">
<xsl:call-template name="toc.authors">
<xsl:with-param name="class">col-12</xsl:with-param>
</xsl:call-template>
</div>
</div>
</xsl:if>
</xsl:template>

<!-- ====================
blog article:
- - - - - - - - - -
Expand All @@ -170,7 +225,7 @@
<!-- ========== title ========== -->

<xsl:template name="toc.title">
<xsl:param name="class" select="''" />
<xsl:param name="class" select="''"/>

<h4>
<xsl:attribute name="class">
Expand All @@ -181,23 +236,23 @@
</xsl:attribute>
<xsl:choose>
<xsl:when test="field[@name='mir.toc.series.volume.top']">
<xsl:value-of select="i18n:translate('mir.details.volume.series')" />
<xsl:value-of select="concat(' ',field[@name='mir.toc.series.volume.top'],': ')" />
<xsl:value-of select="i18n:translate('mir.details.volume.series')"/>
<xsl:value-of select="concat(' ',field[@name='mir.toc.series.volume.top'],': ')"/>
</xsl:when>
<xsl:when test="field[@name='mir.toc.host.volume.top']">
<xsl:value-of select="i18n:translate('mir.details.volume.journal')" />
<xsl:value-of select="concat(' ',field[@name='mir.toc.host.volume.top'],': ')" />
<xsl:value-of select="i18n:translate('mir.details.volume.journal')"/>
<xsl:value-of select="concat(' ',field[@name='mir.toc.host.volume.top'],': ')"/>
</xsl:when>
<xsl:when test="field[@name='mir.toc.host.issue.top']">
<xsl:value-of select="i18n:translate('mir.details.issue')" />
<xsl:value-of select="concat(' ',field[@name='mir.toc.host.issue.top'],': ')" />
<xsl:value-of select="i18n:translate('mir.details.issue')"/>
<xsl:value-of select="concat(' ',field[@name='mir.toc.host.issue.top'],': ')"/>
</xsl:when>
<xsl:when test="field[@name='mir.toc.host.articleNumber.top']">
<xsl:value-of select="concat('#',field[@name='mir.toc.host.articleNumber.top'],': ')" />
<xsl:value-of select="concat('#',field[@name='mir.toc.host.articleNumber.top'],': ')"/>
</xsl:when>
</xsl:choose>
<a href="{$WebApplicationBaseURL}receive/{@id}">
<xsl:value-of select="field[@name='mir.toc.title']" />
<xsl:value-of select="field[@name='mir.toc.title']"/>
</a>
</h4>
</xsl:template>
Expand All @@ -216,15 +271,15 @@
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="." />
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</xsl:template>

<!-- =========== page ========= -->

<xsl:template name="toc.page">
<xsl:param name="class" select="''" />
<xsl:param name="class" select="''"/>

<!-- if no page, then no div too-->
<xsl:for-each select="field[starts-with(@name,'mir.toc.host.page')]">
Expand All @@ -235,17 +290,17 @@
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="i18n:translate('mir.pages.abbreviated.single')" />
<xsl:value-of select="i18n:translate('mir.pages.abbreviated.single')"/>
<xsl:text> </xsl:text>
<xsl:value-of select="." />
<xsl:value-of select="."/>
</div>
</xsl:for-each>
</xsl:template>

<!-- =========== day.month ========= -->

<xsl:template name="toc.day.month">
<xsl:param name="class" select="''" />
<xsl:param name="class" select="''"/>

<div class="{$class}">
<xsl:attribute name="class">
Expand All @@ -254,19 +309,23 @@
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</xsl:attribute>

<xsl:for-each select="field[@name='mods.dateIssued'][1]">
<xsl:call-template name="formatISODate">
<xsl:with-param name="date" select="." />
<xsl:with-param name="format">
<xsl:choose>
<xsl:when test="$CurrentLang='de'">dd.MM.</xsl:when>
<xsl:otherwise>MM-dd</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
<xsl:variable name="formattedDate">
<xsl:call-template name="formatISODate">
<xsl:with-param name="date" select="."/>
<xsl:with-param name="format">
<xsl:choose>
<xsl:when test="$CurrentLang='de'">dd.MM.</xsl:when>
<xsl:otherwise>MM-dd</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:if test="contains($formattedDate, '?') = false">
<xsl:value-of select="$formattedDate"/>
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>

</xsl:stylesheet>

0 comments on commit c394d84

Please sign in to comment.