Skip to content

Commit

Permalink
Fix for #127, #129, #130, #131
Browse files Browse the repository at this point in the history
  • Loading branch information
Takatomo INOUE committed Feb 21, 2024
1 parent 79707b6 commit ccca456
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 27 deletions.
48 changes: 40 additions & 8 deletions static/css/tei.css
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,51 @@ div.tei-teiHeader {
.tei-note.type-editorial {
font-style: italic;
}
.tei-note.type-translation::before {
a.tei-note.type-translation::before {
color: #018B84;
content: "<Translation>";
font-style: italic;
}

/* note-translation */
/*a.tei-seg.type-parallel::before {
content: "📝";
}*/

details.tei-note.type-translation {
display: inline;
text-indent: 0;
}
details.tei-note.type-translation summary {
display: inline;
}
details.tei-note.type-translation summary::before {
color: #018B84;
display: inline;
content: "<Translation>📝";
margin-right: 0.25em;
width: 1em;
}
details.tei-note.type-translation[open] summary::before{
color: #018B84;
content: "<Translation>✖";
}

details.tei-note.type-translation div.translation-popup {
width: 30%;
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;
}

.inline {
display: inline;
}
Expand Down Expand Up @@ -1348,13 +1387,6 @@ details.tei-bibl div.citation-popup {
}

/* 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: "📝";
}
Expand Down
26 changes: 26 additions & 0 deletions static/js/dynamic-style.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const passages = document.getElementsByClassName("type-parallel")

for (const passage of passages) {
if (passage.tagName === "DETAILS") {
passage.addEventListener("mouseover", function(e) {
let idToCompare = e.target.id.slice(1)
for (const p of passages) {
if (p.tagName === "SPAN") {
const id = p.getAttribute("id")
if (idToCompare === id.split("g")[1]) {
p.style.backgroundColor = "yellow"
}
}
}
}
)
}
}
for (const passage of passages) {
passage.addEventListener("mouseout", function() {
for (const p of passages) {
p.style.backgroundColor = "transparent"
}
}
)
}
1 change: 1 addition & 0 deletions xslt/add-site-navigation.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</xsl:choose>
<xsl:call-template name="footer"/>
<script src="/js/global.js"></script>
<script src="/js/dynamic-style.js"></script>
</xsl:copy>
</xsl:template>

Expand Down
9 changes: 9 additions & 0 deletions xslt/bibliography-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<xsl:variable name="publication-place" select="imprint/pubPlace"/>
<xsl:variable name="publication-year" select="imprint/date"/>
<xsl:variable name="full-text-link" select="title/@ref"/>
<xsl:variable name="ms-repository" select="respStmt"/>

<li id="{parent::biblStruct/@xml:id}">
<!-- TODO format the bibliographic citation appropriately -->
Expand Down Expand Up @@ -71,6 +72,14 @@
<h2>Publication Year:</h2>
<p>{$publication-year}</p>
</xsl:if>
<xsl:if test="$ms-repository/orgName">
<h2>Holding Institution:</h2>
<p>{$ms-repository/orgName}</p>
</xsl:if>
<xsl:if test="$ms-repository/note[@type='shelfmark']">
<h2>Shelfmark:</h2>
<p>{$ms-repository/note[@type='shelfmark']}</p>
</xsl:if>
<xsl:if test="$full-text-link">
<h2>Link to Fulltext:</h2>
<p><a href="{$full-text-link}">{$full-text-link}</a></p>
Expand Down
12 changes: 11 additions & 1 deletion xslt/lift-title-attributes-to-popups.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<xsl:template match="a[contains(@class, 'tei-seg')]">
<xsl:element name="details">
<xsl:copy-of select="@class"/>
<xsl:element name="summary"></xsl:element>
<xsl:element name="summary"><xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute></xsl:element>
<div class="parallel-popup">
See<br/>
<xsl:for-each select="span[@href]">
Expand All @@ -50,4 +50,14 @@
</div>
</xsl:element>
</xsl:template>
<xsl:template match="a[@class='tei-note type-translation'][@title]">
<xsl:element name="details">
<xsl:copy-of select="@class"/>
<xsl:element name="summary"></xsl:element>
<div class="translation-popup">
<xsl:sequence select="parse-xml-fragment(@title)"/>
</div>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
56 changes: 38 additions & 18 deletions xslt/p5-to-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<xsl:apply-templates select="fileDesc/sourceDesc/msDesc/history" />
<!-- identifiers -->
<xsl:variable name="msIdentifier" select="fileDesc/sourceDesc/msDesc/msIdentifier"/>
<div>
<h2 class="inline">Sotheby Lot No.:</h2>
<xsl:apply-templates select="$msIdentifier/altIdentifier/idno[@type='sotheby_lot']" />
</div>
<div>
<h2 class="inline">Physical Location:</h2>
<xsl:value-of select="string-join(
Expand All @@ -88,10 +92,6 @@
'&#160;'
)"/>
</div>
<div>
<h2 class="inline">Sotheby Lot No.:</h2>
<xsl:apply-templates select="$msIdentifier/altIdentifier/idno[@type='sotheby_lot']" />
</div>
<div>
<h2 class="inline">Electronic Publication:</h2>
<xsl:value-of select="concat(
Expand Down Expand Up @@ -482,6 +482,7 @@
<xsl:apply-templates mode="citation-popup" select="monogr/author[*]"/>
<xsl:apply-templates mode="citation-popup" select="monogr/title[@type='short']"/>
<xsl:apply-templates mode="citation-popup" select="monogr/imprint"/>
<xsl:apply-templates mode="citation-popup" select="monogr/respStmt"/>
</p>
<p>
<a href="/bibliography#{@xml:id}">[View Full Citation]</a>
Expand Down Expand Up @@ -529,7 +530,7 @@
(publisher, date),
', '
),
'.'
'. '
)
"/>
</xsl:template>
Expand All @@ -544,6 +545,11 @@
<xsl:text>. </xsl:text>
</xsl:template>

<xsl:template match="respStmt" mode="citation-popup">
<xsl:value-of select="string-join((orgName, note[@type='shelfmark']), ', ')"/>
<xsl:text>. </xsl:text>
</xsl:template>

<!-- lists and tables -->
<xsl:template match="list" priority="1">
<xsl:apply-templates select="tei:head"/><!-- HTML list headings must precede <ul> element -->
Expand Down Expand Up @@ -639,6 +645,18 @@
</xsl:when>
</xsl:choose>
</xsl:function>

<xsl:template match="note[@rend='diplomatic']|seg[@rend='diplomatic']">
<xsl:if test="$view = 'diplomatic' ">
<xsl:next-match/>
</xsl:if>
</xsl:template>
<xsl:template match="note[@rend='normalized']|seg[@rend='diplomatic']">
<xsl:if test="$view = 'normalized' ">
<xsl:next-match/>
</xsl:if>
</xsl:template>

<xsl:key name="reference-by-target" match="*[@target]" use="@target"/>
<!--<xsl:template match="note[@type='annotation'][@xml:id]" mode="create-content">-->
<xsl:template match="note[@xml:id]" mode="create-content">
Expand All @@ -656,10 +674,16 @@
<xsl:next-match/>
</xsl:template>
<xsl:template match="note[@type='translation']">
<span>
<!-- <span>
<xsl:apply-templates mode="create-attributes" select="."/>
<xsl:attribute name="title" select="normalize-space()"/>
</span>
</span> -->
<xsl:element name="a">
<xsl:apply-templates mode="create-attributes" select="."/>
<xsl:attribute name="title">
<xsl:apply-templates mode="create-content" select="serialize(.)"/>
</xsl:attribute>
</xsl:element>
</xsl:template>
<xsl:template match="note[@place]">
&lt;in
Expand All @@ -683,6 +707,7 @@
<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:attribute name="id"><xsl:value-of select="@xml:id"/></xsl:attribute>
<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>
Expand All @@ -702,17 +727,12 @@
<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:template match="seg[@type='parallel' and @xml:id and @next]">
<xsl:element name="span">
<xsl:apply-templates mode="create-attributes" select="."/>
<xsl:apply-templates mode="create-content" select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

0 comments on commit ccca456

Please sign in to comment.