Skip to content

Commit

Permalink
DBT-383 Add mir files as reference to changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoniafriedrich committed Jan 10, 2025
1 parent 361ded1 commit 112acd8
Show file tree
Hide file tree
Showing 2 changed files with 359 additions and 0 deletions.
87 changes: 87 additions & 0 deletions src/main/resources/toc-layouts.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
Table of contents layouts. Each layout has its own ID.
Use custom-toc-layouts.xsl to customize HTML output of level labels and publications.
toc-layout : a layout for table of contents
@id : a unique ID used to select this layout
@field : SOLR field used to find all publications "below", controls depth of TOC
parent | mir.toc.ancestor
level : a grouping level for table of contents
@field : a SOLR index field to build this level as facet
@limit : maximum number of level items at this level facet
overrides default from MIR.TableOfContents.LevelLimit
@order : display order for TOC level items
@expanded : by default, should level be show expanded or collapsed?
options are true|false|first (only fist item at level expanded)
publications : may occur at any level, but specify at lowest please!
sortBy : sort publications by @field and @order,
may be repeated
-->


<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">
<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" />
</publications>
</level>
</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">
<publications>
<sortBy field="mir.toc.host.page.int" order="asc" />
<sortBy field="mir.toc.host.page.str" order="asc" />
</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">
<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" />
</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">
<publications>
<sortBy field="mods.dateIssued" order="desc" />
</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>
<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" />
</publications>
</level>
</toc-layout>

</toc-layouts>
272 changes: 272 additions & 0 deletions src/main/resources/xsl/toc/custom-toc-layouts.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- Custom table of contents layouts to display levels and publications -->
<!-- Default templates may be overwritten by higher priority custom templates -->

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation"
exclude-result-prefixes="xalan i18n"
>

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

<!-- ====================
level default:
- - - - - - - - - -
value
-or- value(linked)
-or- value: title(linked)
authors
==================== -->

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

<xsl:template match="item">
<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" />
</span>
</xsl:template>

<xsl:template match="item" mode="label">
<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="." />
</a>
</xsl:for-each>
<xsl:for-each select="field[@name='mir.toc.authors']">
<br />
<xsl:value-of select="." />
</xsl:for-each>
</xsl:template>

<!-- ====================
volume level:
- - - - - - - - - -
Vol. #
-or- Vol. #: title(linked)
authors
==================== -->

<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:text> </xsl:text>
<xsl:value-of select="@value" />
<xsl:apply-templates select="doc" />
</xsl:template>

<!-- ====================
volume level:
- - - - - - - - - -
Vol. #
-or- Vol. #: title(linked)
authors
==================== -->

<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:text> </xsl:text>
<xsl:value-of select="@value" />
<xsl:for-each select="doc/field[@name='mods.yearIssued']">
<xsl:text> (</xsl:text>
<xsl:value-of select="text()" />
<xsl:text>)</xsl:text>
</xsl:for-each>
<xsl:apply-templates select="doc" />
</xsl:template>

<!-- ====================
issue level:
- - - - - - - - - -
No. #
-or- No. #: title(linked)
authors
==================== -->

<xsl:template match="level[@field='mir.toc.host.issue']/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>

<!-- ====================
default publication:
- - - - - - - - - -
linked title page
authors
==================== -->

<xsl:template match="publications/doc" priority="1">
<div class="row">
<xsl:call-template name="toc.title">
<xsl:with-param name="class">col-10</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.page">
<xsl:with-param name="class">col-2</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.authors">
<xsl:with-param name="class">col-10</xsl:with-param>
</xsl:call-template>
</div>
</xsl:template>

<!-- ====================
legacy publication:
- - - - - - - - - -
[vol -] title page
authors
==================== -->
<xsl:template match="toc[@layout='legacy']//publications/doc" priority="2">
<div class="row">
<xsl:call-template name="toc.title">
<xsl:with-param name="class">col-10</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.page">
<xsl:with-param name="class">col-2</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.authors">
<xsl:with-param name="class">col-10</xsl:with-param>
</xsl:call-template>
</div>
</xsl:template>

<!-- ====================
blog article:
- - - - - - - - - -
date linked title
authors
==================== -->

<xsl:template match="toc[@layout='blog']//publications/doc" priority="2">
<div class="row">
<xsl:call-template name="toc.day.month">
<xsl:with-param name="class">col-1</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.title">
<xsl:with-param name="class">col-11</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="toc.authors">
<xsl:with-param name="class">offset-1 col-11</xsl:with-param>
</xsl:call-template>
</div>
</xsl:template>

<!-- ========== title ========== -->

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

<h4>
<xsl:attribute name="class">
<xsl:text>mir-toc-section-title</xsl:text>
<xsl:if test="string-length($class) &gt; 0">
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</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: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: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:when>
<xsl:when test="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']" />
</a>
</h4>
</xsl:template>

<!-- ========== authors ========== -->

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

<!-- if no authors, then no div too-->
<xsl:for-each select="field[@name='mir.toc.authors']">
<div>
<xsl:attribute name="class">
<xsl:text>mir-toc-section-author</xsl:text>
<xsl:if test="string-length($class) &gt; 0">
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="." />
</div>
</xsl:for-each>
</xsl:template>

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

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

<!-- if no page, then no div too-->
<xsl:for-each select="field[starts-with(@name,'mir.toc.host.page')]">
<div>
<xsl:attribute name="class">
<xsl:text>mir-toc-section-page</xsl:text>
<xsl:if test="string-length($class) &gt; 0">
<xsl:value-of select="concat(' ', $class)"/>
</xsl:if>
</xsl:attribute>
<xsl:value-of select="i18n:translate('mir.pages.abbreviated.single')" />
<xsl:text> </xsl:text>
<xsl:value-of select="." />
</div>
</xsl:for-each>
</xsl:template>

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

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

<div class="{$class}">
<xsl:attribute name="class">
<xsl:text>mir-toc-section-date</xsl:text>
<xsl:if test="string-length($class) &gt; 0">
<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:for-each>
</div>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 112acd8

Please sign in to comment.