Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue298 #27

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions pn-indexer/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"apache" "https://repository.apache.org/content/repositories/releases/"
"apache-snapshots" "https://repository.apache.org/content/repositories/snapshots"}
:jvm-opts ["-Xms1G" "-Xmx1G" "-Djava.awt.headless=true"]
:dependencies [[org.clojure/clojure "1.3.0"]
:dependencies [[org.clojure/clojure "1.8.0"]
[ant/ant-launcher "1.6.2"]
[org.apache.maven/maven-ant-tasks "2.0.10"]
[org.apache.solr/solr-core "3.5.0"]
Expand All @@ -22,7 +22,7 @@
[commons-httpclient/commons-httpclient "3.1"]
[commons-logging/commons-logging "1.1.1"]
[commons-codec/commons-codec "1.5"]]
:dev-dependencies [[lein-marginalia "0.7.0-SNAPSHOT" :exclusions
:dev-dependencies [[lein-marginalia "0.7.0-SNAPSHOT" :exclusions
[org.clojure/clojure]]]
:main info.papyri.indexer
:aot [info.papyri.indexer])
21 changes: 15 additions & 6 deletions pn-indexer/src/info/papyri/indexer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@
[n, name]
(File. (str tmpath "/dump/files/" (int (Math/floor (/ (Integer. n) 1000))) "/" n "-" name ".clj")))


(defn process-tm-file
[f, n]
(with-open [rdr (io/reader (str tmpath "/dump/" f ".csv"))]
Expand All @@ -759,7 +760,8 @@
(with-open [out (io/writer of)]
(binding [*out* out
*print-dup* true]
(prn (vector fields)))))
(if-not (nil? fields)
(prn (vector fields))))))
(do ;; if the file exists, we might already have it loaded from the last row, so don't re-read it
(if-not (= @outfile of)
(dosync
Expand All @@ -768,22 +770,26 @@
(into [] (concat r (vector fields))))))
(dosync
(ref-set record (into [] (concat @record (vector fields))))))))))))
(when-not (nil? @outfile)
(when-not (or (nil? @outfile) (nil? @record))
(with-open [out (io/writer @outfile)]
(binding [*out* out
*print-dup* true]
(prn @record)))))))

(defn map-tm-functions
[out name, fieldnums, rels]
(for [values rels]
([out name, fieldnums, rels]
(for [values rels]
(partial write-tm-xml out name values fieldnums [])))
([out, name, fieldnums, rels, fns]
(for [values rels]
(partial write-tm-xml out name values fieldnums fns))))

(defn preprocess-tm
"Converts TM data into XML for inclusion in the PN."
[]
(process-tm-file "dates" 1)
(process-tm-file "texref" 1)
(process-tm-file "editref" 0)
(process-tm-file "geotex" 1)
(process-tm-file "georef" 5)
(process-tm-file "ref" 7)
Expand All @@ -800,6 +806,8 @@
dates (when (.exists datefile) (with-open [f (PushbackReader. (FileReader. datefile))] (read f)))
texreffile (tm-file (nth fields 0) "texref")
texrefs (when (.exists texreffile) (with-open [f (PushbackReader. (FileReader. texreffile))] (read f)))
editreffile (tm-file (nth (nth texrefs 0) 0) "editref") ;; needs to be changed to texref
editrefs (when (.exists editreffile) (with-open [f (PushbackReader. (FileReader. editreffile))] (read f)))
geotexfile (tm-file (nth fields 0) "geotex")
geotex (when (.exists geotexfile) (with-open [f (PushbackReader. (FileReader. geotexfile))] (read f)))
georeffile (tm-file (nth fields 0) "georef")
Expand All @@ -812,8 +820,9 @@
collrefs (when (.exists collreffile) (with-open [f (PushbackReader. (FileReader. collreffile))] (read f)))
fns (concat
(map-tm-functions out "date" [2 3 4 9 14] dates)
(map-tm-functions out "texref" [1 2 3 4 5 14 15] texrefs)
(map-tm-functions out "geotex" [2 28] geotex)
(map-tm-functions out "texref" [1 2 3 4 5 14 15 19 21] texrefs
(map-tm-functions out "editref" [0 1] editrefs))
(map-tm-functions out "geotex" [2 20 22] geotex)
(map-tm-functions out "georef" [0 7 25 35 36 37 38] georefs)
(map-tm-functions out "personref" [0 132 53 54 55 56 151] personrefs)
(map-tm-functions out "archref" [5 37] archrefs)
Expand Down
6 changes: 3 additions & 3 deletions pn-xslt/MakeHTML.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
<body onload="init()">
<div id="d">
<div id="hd">
<h1>DCLP</h1>
<h1>Papyri.info</h1>
<h2 id="login"><a href="/editor/user/signin">sign in</a></h2>
</div>
<div id="bd">
Expand Down Expand Up @@ -295,7 +295,7 @@
</div>
</div>
<xsl:if test="$collection = 'ddbdp'">
<xsl:if test="$hgv or $apis or $dclp">
<xsl:if test="$hgv or $apis or $dclp or $tm">
<div class="metadata">
<xsl:for-each select="$relations[contains(., 'hgv/')]">
<xsl:sort select="." order="ascending"/>
Expand Down Expand Up @@ -751,4 +751,4 @@
<xsl:template match="rdf:Description">
<xsl:value-of select="@rdf:about"/>
</xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>
1 change: 1 addition & 0 deletions pn-xslt/metadata-dclp.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
<xsl:apply-templates
select="t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:history/t:origin/(t:origPlace|t:p)"
mode="metadata"/>
<xsl:apply-templates select="t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:history/t:provenance[not(@type = 'stored')]" mode="metadata"/>

<!-- Place Stored (Ancient) -->
<xsl:apply-templates
Expand Down
39 changes: 32 additions & 7 deletions pn-xslt/metadata.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<xsl:apply-templates
select="t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:history/t:origin/(t:origPlace|t:p)"
mode="metadata"/>
<xsl:apply-templates select="t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:history/t:provenance" mode="metadata"/>
<!-- Material -->
<xsl:apply-templates
select="t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:physDesc/t:objectDesc/t:supportDesc/t:support/t:material"
Expand Down Expand Up @@ -180,19 +181,42 @@
<!-- Publications -->
<tr>
<th>Publications</th>
<td><xsl:value-of select="field[@n='6']"/><xsl:text> </xsl:text>
<xsl:value-of select="replace(field[@n='8'],'&lt;br&gt;',' ')"/></td>
<td><xsl:for-each select="texref[starts-with(field[@n='15'], '1.')]">
<xsl:variable name="eds" select="tokenize(field[@n='19'], ' / ')"/>
<xsl:value-of select="field[@n='14']"/> (<xsl:for-each
select="editref"><xsl:variable name="pos"
select="count(preceding-sibling::editref) + 1"/><a
href="http://www.trismegistos.org/editor/{field[@n='1']}"><xsl:value-of
select="$eds[$pos]"/></a><xsl:if test="position() != last()">
<xsl:text> / </xsl:text></xsl:if></xsl:for-each>; <xsl:value-of
select="field[@n='21']"/>)<xsl:if test="position() != last()"><xsl:text> +
</xsl:text></xsl:if>
</xsl:for-each>
<xsl:for-each select="texref[not(starts-with(field[@n='15'], '1.'))]">
<xsl:if test="position() = 1"><xsl:text> = </xsl:text></xsl:if>
<xsl:variable name="eds" select="tokenize(field[@n='19'], ' / ')"/>
<xsl:value-of select="field[@n='14']"/> (<xsl:for-each
select="editref"><a
href="http://www.trismegistos.org/editor/{field[@n='1']}"><xsl:value-of
select="$eds[position()]"/></a><xsl:if test="position() != last()">
<xsl:text> / </xsl:text></xsl:if></xsl:for-each>; <xsl:value-of
select="field[@n='21']"/>)<xsl:if test="position() != last()"><xsl:text> =
</xsl:text></xsl:if>
</xsl:for-each></td>
</tr>
<!-- Inventory Number -->
<tr>
<th>Inv. no.</th>
<td><a href="http://www.trismegistos.org/collection/{collref[starts-with(field[@n='15'],'1.')]/field[@n='1']}"><xsl:value-of select="collref[starts-with(field[@n='15'],'1.')]/field[@n='14']"/></a>
<td><xsl:for-each select="collref[starts-with(field[@n='15'],'1.')]"><a
href="http://www.trismegistos.org/collection/{field[@n='1']}"><xsl:value-of select="field[@n='14']"/></a><xsl:if test="following-sibling::collref[starts-with(field[@n='15'],'1.')]">; </xsl:if></xsl:for-each>
<xsl:if test="collref[not(starts-with(field[@n='15'],'1.'))]">;
<xsl:if test="collref[starts-with(field[@n='15'],'2.')]">other inv.: </xsl:if>
<xsl:if test="collref[starts-with(field[@n='15'],'2.')]">. other inv.: </xsl:if>
<xsl:for-each select="collref[starts-with(field[@n='15'],'2.')]">
<a href="http://www.trismegistos.org/collection/{field[@n='1']}"><xsl:value-of select="field[@n='14']"/></a><xsl:if test="following-sibling::collref[not(starts-with(field[@n='15'],'1.'))]">; </xsl:if>
<a href="http://www.trismegistos.org/collection/{field[@n='1']}"><xsl:value-of
select="field[@n='14']"/></a><xsl:if
test="following-sibling::collref[starts-with(field[@n='15'],'2.')]">; </xsl:if>
</xsl:for-each>
<xsl:if test="collref[starts-with(field[@n='15'],'3.')]">formerly: </xsl:if>
<xsl:if test="collref[starts-with(field[@n='15'],'3.')]">. formerly: </xsl:if>
<xsl:for-each select="collref[starts-with(field[@n='15'],'3.')]">
<a href="http://www.trismegistos.org/collection/{field[@n='1']}"><xsl:value-of select="field[@n='14']"/></a><xsl:if test="following-sibling::collref[starts-with(field[@n='15'],'3.')]">; </xsl:if>
</xsl:for-each></xsl:if>
Expand Down Expand Up @@ -223,7 +247,8 @@
<tr>
<th>Provenance</th>
<td><xsl:for-each select="geotex">
<a href="http://www.trismegistos.org/place/{field[@n='2']}"><xsl:value-of select="field[@n='28']"/></a><xsl:if test="following-sibling::geotex">; </xsl:if>
<a href="http://www.trismegistos.org/place/{field[@n='2']}"><xsl:value-of
select="field[@n='22']"/><xsl:if test="field[@n='20'] != ''"> <xsl:value-of select="field[@n='20']"/></xsl:if></a><xsl:if test="following-sibling::geotex">; </xsl:if>
</xsl:for-each></td>
</tr>
<!-- Archive -->
Expand Down