Skip to content

Commit

Permalink
Merge pull request #124 from IUBLibTech/takatomo_ab_parallel
Browse files Browse the repository at this point in the history
Created highlighting and pop-up features for TEI <ab> elements. @wehooper confirmed that the TEI is now valid and the team is ready to see how this works in the Newton Dev. @randalldfloyd : could you update Newton dev when you have a moment please? Also, holding off on a Newton production update because @aewingate uncovered a problem with the last code merge/update to Dev. Waiting to hear from Newton team re: further testing.
  • Loading branch information
mdalmau authored May 11, 2022
2 parents 72d48ae + 39e3697 commit 154fba5
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
44 changes: 43 additions & 1 deletion static/css/tei.css
Original file line number Diff line number Diff line change
Expand Up @@ -1345,4 +1345,46 @@ details.tei-bibl div.citation-popup {
border-width: thin;
border-color: black;
border-radius: 0.5em;
}
}

/* Parallel passages */
details.tei-seg.type-parallel:hover + span.type-parallel{
background-color: #FFFF00;
}
details.tei-seg.type-parallel:hover + div.tei-p {
background-color: #FFFF00;
}

a.tei-seg.type-parallel::before {
content: "📝";
}

details.tei-seg.type-parallel {
display: inline;
text-indent: 0;
}
details.tei-seg.type-parallel summary {
display: inline-block;
}
details.tei-seg.type-parallel summary::before {
display: inline-block;
content: "📝";
margin-right: 0.25em;
width: 1em;
}
details.tei-seg.type-parallel[open] summary::before{
content: "✖";
}
details.tei-seg.type-parallel div.parallel-popup {
text-align: left;
position: absolute;
color: black;
font-size: small;
font-weight: normal;
background-color: white;
padding: 1em;
border-style: solid;
border-width: thin;
border-color: black;
border-radius: 0.5em;
}
18 changes: 18 additions & 0 deletions xslt/lift-title-attributes-to-popups.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,22 @@
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a[contains(@class, 'tei-seg')]">
<xsl:element name="details">
<xsl:copy-of select="@class"/>
<xsl:element name="summary"></xsl:element>
<div class="parallel-popup">
See<br/>
<xsl:for-each select="span[@href]">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<xsl:value-of select="."/>
<br/>
</xsl:element>
</xsl:for-each>
for corresponding passage(s)
</div>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
36 changes: 36 additions & 0 deletions xslt/p5-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,40 @@
<xsl:attribute name="title" select="reg"/>
</xsl:template>
<xsl:template match="name/reg"/>

<xsl:key name="match-seg-id" match="seg[@next]" use="substring(@xml:id,9)"/>
<xsl:template match="seg[@type='parallel' and @xml:id and not(@next)]">
<xsl:element name="a">
<xsl:apply-templates mode="create-attributes" select="."/>
<xsl:for-each select="tokenize(@xml:id, '-to-')">
<xsl:variable name="token"><xsl:value-of select="."/></xsl:variable>
<xsl:if test="contains($token ,'ALCH')">
<xsl:element name="span">
<xsl:variable name="name"><xsl:value-of select="substring-before($token ,'-')"/></xsl:variable>
<xsl:variable name="doc"><xsl:value-of select="document(concat('../p5/', $name, '.xml'))"/></xsl:variable>
<xsl:variable name="page"><xsl:value-of select="substring-after($token, '-')"/></xsl:variable>
<xsl:attribute name="href"><xsl:value-of select="concat('/text/', $name, '/', $view, '#f', $page)"/></xsl:attribute>
<xsl:value-of select="document(concat('../p5/', $name, '.xml'))/TEI/teiHeader/fileDesc/sourceDesc/msDesc/msIdentifier/collection"/>,
<xsl:value-of select="document(concat('../p5/', $name, '.xml'))/TEI/teiHeader/fileDesc/sourceDesc/msDesc/msIdentifier/idno"/>,
<xsl:value-of select="$page"/>
</xsl:element>
</xsl:if>
</xsl:for-each>
</xsl:element>
<xsl:element name="span">
<xsl:apply-templates mode="create-attributes" select="."/>
<xsl:apply-templates mode="create-content" select="."/>
<xsl:for-each select="key('match-seg-id', @xml:id)">
<xsl:if test="@rend='p-start' or @rend='p-full'">
<br/>
<xsl:element name="span">
<!-- the margin-left value corresponds to text-indent of .tei-p -->
<xsl:attribute name="style">margin-left: 1.5em;</xsl:attribute>
</xsl:element>
</xsl:if>
<xsl:apply-templates mode="create-content" select="."/>
</xsl:for-each>
</xsl:element>
</xsl:template>
<xsl:template match="seg[@type='parallel' and @xml:id and @next]"/>
</xsl:stylesheet>

0 comments on commit 154fba5

Please sign in to comment.