Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,77 @@ Build the JAR file with `mvn clean install` and copy it to `~/.mycore/(dev-)mir/

### Configure `mycore.properties`

#### Enable navigation on object pages in frontend

To use the plugin, configuration in `~/.mycore/(dev-)mir/mycore.properties` is required.
The RSS feed requires a `mycoreobject-rss` stylesheet, which is not included by default.
For historical reasons, the link to the RSS feed is always displayed, but it can be disabled if needed.
All in all, configure as follows:

```text
# Add 'series-banner' and 'series-layout'.
MIR.Layout.End=mir-edit,series-banner,series-layout,mir-citation,mir-thumbnail,mir-epusta,mir-access-rights,mir-export,mir-admindata,mir-historydata
# Add 'series-layout'.
MIR.Layout.End=mir-edit,series-layout,mir-citation,mir-thumbnail,mir-epusta,mir-access-rights,mir-export,mir-admindata,mir-historydata

# Optional: disable RSS feed.
MIR.Metadata.Navigation.SeriesPanel.RSS.Enabled=false
```

#### MyCoReWebPage support

The panel can optionally be rendered within a
[MyCoReWebPage](https://www.mycore.de/documentation/frontend/frontend_static_content/).
To enable this, the stylesheet `series-panel-adapter.xsl` is provided.
The panel can be embedded using a `<series-panel />` element in your MyCoReWebPage.
When embedding, pay attention to the layout to ensure the panel is formatted correctly.

> ⚠️ Note: The parameters `MCRObjectID` and `MCRDerivateID` must be present in the transformer session to resolve the
> navigation.

To activate it, add the stylesheet as follows:

```text
# Add 'series-panel-adapter.xsl' to enable series panel rendering in MyCoReWebPage.
MCR.URIResolver.xslIncludes.MyCoReWebPage=%MCR.URIResolver.xslIncludes.MyCoReWebPage%,series-panel-adapter.xsl
```

Example MyCoReWebPage with panel and layout:

```xml
<MyCoReWebPage>
<section xml:lang="en" title="Title">
<div class="row detail_row">
<div class="col-xs-12 col-sm-8">
<p>Hello world</p>
</div>
<div class="col-xs-12 col-sm-4">
<series-panel />
</div>
</div>
</section>
</MyCoReWebPage>
```

#### Extended MyCoReWebPage support

MyCoReWebPage support can be extended with `series-panel-enricher.xsl`. By setting `render-series-panel="true"` in a
MyCoReWebPage, a series panel with layout is automatically generated, using the section’s content.
To activate it, add the stylesheet alongside `series-panel-adapter.xsl` as follows:

```text
# Add 'series-panel-enricher.xsl' to enable extended series panel rendering in MyCoReWebPage.
MCR.URIResolver.xslIncludes.MyCoReWebPage=%MCR.URIResolver.xslIncludes.MyCoReWebPage%,series-panel-enricher.xsl,series-panel-adapter.xsl
```

Example MyCoReWebPage with automatic panel and layout using `render-series-panel`:

```xml
<MyCoReWebPage render-series-panel="true">
<section xml:lang="en" title="Title">
<p>Hello world</p>
</section>
</MyCoReWebPage>
```

### Reload and rebuild Solr

The plugin leverages enhanced Solr handling for parent documents.
Expand Down
22 changes: 7 additions & 15 deletions src/main/resources/xsl/navigation-flatmir-layout.xsl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- ============================================== -->
<!-- $Revision$ $Date$ -->
<!-- ============================================== -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation" xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan i18n">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:include href="series-panel.xsl" />
<xsl:include href="resource:xsl/render-series-panel.xsl" />
<xsl:include href="copynodes.xsl" />

<xsl:param name="WebApplicationBaseURL" />
Expand All @@ -15,24 +10,21 @@

<xsl:template match="/MyCoReWebPage">
<xsl:copy>

<section xml:lang="all">

<div class="row detail_row">
<div class="col-xs-12 col-sm-8" id="main_col">
<xsl:copy-of select="@*" />
<xsl:apply-templates select="*|text()" />
</div>
<div class="col-xs-12 col-sm-4" id="aux_col">
<xsl:apply-templates select="document(concat('notnull:mcrfile:',$MCRDerivateID,'/navigation.xml'))/item"
mode="seriesLayout">
<xsl:with-param name="rootID" select="$MCRObjectID" />
</xsl:apply-templates>
<xsl:call-template name="resolve-navigation-and-render-series-panel">
<xsl:with-param name="root-object-id" select="$MCRObjectID" />
<xsl:with-param name="derivate-id" select="$MCRDerivateID" />
</xsl:call-template>
</div>
</div>
</section>

</xsl:copy>
</xsl:template>

</xsl:stylesheet>
</xsl:stylesheet>
116 changes: 116 additions & 0 deletions src/main/resources/xsl/render-series-panel.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="CurrentLang" />
<xsl:param name="ServletsBaseURL" />
<xsl:param name="WebApplicationBaseURL" />

<xsl:param name="MIR.Metadata.Navigation.SeriesPanel.RSS.Enabled" />

<xsl:template name="resolve-navigation-and-render-series-panel">
<xsl:param name="root-object-id" />
<xsl:param name="derivate-id" />
<xsl:variable name="navigation-uri" select="concat('notnull:mcrfile:', $derivate-id, '/navigation.xml')" />
<xsl:variable name="nav-item" select="document($navigation-uri)/item" />
<xsl:if test="$nav-item">
<xsl:call-template name="render-series-panel">
<xsl:with-param name="nav" select="$nav-item" />
<xsl:with-param name="root-object-id" select="$root-object-id" />
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="render-series-panel">
<xsl:param name="nav" />
<xsl:param name="root-object-id" />

<div id="series-layout">
<xsl:if test="normalize-space($nav/@banner) != ''">
<a class="banner-link" href="{$WebApplicationBaseURL}receive/{$root-object-id}">
<img
src="{$WebApplicationBaseURL}{$nav/@banner}"
class="card-img-top"
alt="Logo { $nav/label[lang($CurrentLang)] }" />
</a>
</xsl:if>
<div class="card series-card">
<div class="card-header">
<h3 class="card-title">
<xsl:value-of select="$nav/label[lang($CurrentLang)]" />
</h3>
</div>
<div class="card-body">
<ul>
<xsl:for-each select="$nav/item">
<xsl:call-template name="render-nav-item">
<xsl:with-param name="itemNode" select="." />
</xsl:call-template>
</xsl:for-each>
<xsl:if test="$MIR.Metadata.Navigation.SeriesPanel.RSS.Enabled='true'">
<xsl:call-template name="render-rss-item">
<xsl:with-param name="object-id" select="$root-object-id" />
</xsl:call-template>
</xsl:if>
</ul>
</div>
<div class="card-footer">
<xsl:call-template name="render-search-form">
<xsl:with-param name="root-object-id" select="$root-object-id" />
</xsl:call-template>
</div>
</div>
</div>
</xsl:template>

<xsl:template name="render-nav-item">
<xsl:param name="itemNode" />
<li>
<xsl:choose>
<xsl:when test="starts-with($itemNode/@ref, 'http')">
<a href="{$itemNode/@ref}">
<xsl:value-of select="$itemNode/label[lang($CurrentLang)]" />
</a>
</xsl:when>
<xsl:otherwise>
<a href="{concat($WebApplicationBaseURL, $itemNode/@ref)}">
<xsl:value-of select="$itemNode/label[lang($CurrentLang)]" />
</a>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:template>

<xsl:template name="render-search-form">
<xsl:param name="root-object-id" />
<form role="search" action="{$ServletsBaseURL}solr/select" method="post" class="rssfeed-search form-inline">
<input type="hidden" name="q" value="root:{$root-object-id}" />
<div class="input-group" style="width:100%;">
<label class="sr-only input-group-prepend" for="qSeries">
<xsl:text>Suche in </xsl:text>
<xsl:value-of select="label[lang($CurrentLang)]" />
</label>
<input
id="qSeries"
type="text"
name="fq"
class="form-control"
placeholder="Suche in {label[lang($CurrentLang)]}" />
<div class="input-group-append">
<button class="btn btn-primary" type="submit">
<i class="fas fa-search" />
</button>
</div>
</div>
</form>
</xsl:template>

<xsl:template name="render-rss-item">
<xsl:param name="object-id" />
<li>
<a href="{$WebApplicationBaseURL}receive/{$object-id}?XSL.Style=rss">
<i class="fas fa-rss" />
<xsl:text>RSS 2.0 Feed</xsl:text>
</a>
</li>
</xsl:template>
</xsl:stylesheet>
18 changes: 18 additions & 0 deletions src/main/resources/xsl/series-panel-adapter.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:include href="resource:xsl/render-series-panel.xsl" />

<xsl:param name="MCRDerivateID" />
<xsl:param name="MCRObjectID" />

<xsl:template match="series-panel">
<xsl:if test="$MCRObjectID and $MCRDerivateID">
<xsl:call-template name="resolve-navigation-and-render-series-panel">
<xsl:with-param name="root-object-id" select="$MCRObjectID" />
<xsl:with-param name="derivate-id" select="$MCRDerivateID" />
</xsl:call-template>
</xsl:if>
</xsl:template>

</xsl:stylesheet>
26 changes: 26 additions & 0 deletions src/main/resources/xsl/series-panel-enricher.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exslt="http://exslt.org/common"
extension-element-prefixes="exslt">

<xsl:template match="/MyCoReWebPage[@render-series-panel='true']/section" priority="10">
<xsl:variable name="enriched-section">
<div class="row detail_row">
<div class="col-xs-12 col-sm-8" id="main_col">
<xsl:apply-templates select="node()[not(self::head)]"/>
</div>
<div class="col-xs-12 col-sm-4" id="aux_col">
<series-panel />
</div>
</div>
</xsl:variable>

<section>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="head/node()"/>
<xsl:apply-templates select="exslt:node-set($enriched-section)/node()"/>
</section>
</xsl:template>

</xsl:stylesheet>
Loading
Loading