Skip to content

Commit

Permalink
Merge pull request #433 from Edirom/issue-432
Browse files Browse the repository at this point in the history
improve display of places
  • Loading branch information
peterstadler committed Nov 21, 2022
2 parents 8f73739 + bdc4aab commit a0491d7
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 22 deletions.
1 change: 1 addition & 0 deletions api/v1/openapi/schemas/facets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum:
- einrichtungsform
- facsimile
- forenames
- geonamesFeatureClass
- journals
- keywords
- librettists
Expand Down
8 changes: 8 additions & 0 deletions catalogues/dictionary_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -651,4 +651,12 @@
<entry xml:id="linesSg">Zeile</entry>
<entry xml:id="approx">ca.</entry>
<entry xml:id="supplied">ergänzt von den Hg.</entry>
<entry xml:id="geonamesFeatureClass">Ortstyp</entry>
<entry xml:id="geonamesFeatureClass_P">Stadt, Ort, …</entry>
<entry xml:id="geonamesFeatureClass_A">Land, Staat, Region, …</entry>
<entry xml:id="geonamesFeatureClass_H">Fluss, See, …</entry>
<entry xml:id="geonamesFeatureClass_L">Park, Anlage, …</entry>
<entry xml:id="geonamesFeatureClass_S">Gebäude, Farm, …</entry>
<entry xml:id="geonamesFeatureClass_T">Berg, Hügel, …</entry>
<entry xml:id="geonamesFeatureClass_V">Wald, Heide, …</entry>
</dictionary>
8 changes: 8 additions & 0 deletions catalogues/dictionary_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -621,4 +621,12 @@
<entry xml:id="linesSg">line</entry>
<entry xml:id="approx">approx.</entry>
<entry xml:id="supplied">supplied by the editors</entry>
<entry xml:id="geonamesFeatureClass">Type of Place</entry>
<entry xml:id="geonamesFeatureClass_P">City, Village, …</entry>
<entry xml:id="geonamesFeatureClass_A">Country, State, Region, …</entry>
<entry xml:id="geonamesFeatureClass_H">Stream, Lake, …</entry>
<entry xml:id="geonamesFeatureClass_L">Parks, Area, …</entry>
<entry xml:id="geonamesFeatureClass_S">Spot, Building, Farm</entry>
<entry xml:id="geonamesFeatureClass_T">Mountain, Hill, Rock, …</entry>
<entry xml:id="geonamesFeatureClass_V">Forest, Heath, …</entry>
</dictionary>
10 changes: 10 additions & 0 deletions modules/api.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,16 @@ declare function api:validate-siglum($model as map(*)) as map(*)? {
else error($api:INVALID_PARAMETER, 'Unsupported value for parameter "siglum". It must be a valid RISM siglum matching the regular expression "^[A-Z]+\-[A-Z]+[a-z]*$".' )
};

(:~
: Check parameter geonamesFeatureClass
: multiple values allowed as input, either by providing multiple URL parameters
: or by sending a comma separated list as the value of one URL parameter
~:)
declare function api:validate-geonamesFeatureClass($model as map(*)) as map(*)? {
if(every $i in $model?geonamesFeatureClass ! tokenize(., ',') satisfies matches($i, '^[A-Z]$')) then map { 'geonamesFeatureClass': $model?geonamesFeatureClass ! tokenize(., ',') }
else error($api:INVALID_PARAMETER, 'Unsupported value for parameter "geonamesFeatureClass". It must be a valid geonamesFeatureClass matching the regular expression "^[A-Z]$".' )
};

(:~
: Check parameter orderby (docID|idno|sortdate|docType|title)
: only one value allowed
Expand Down
40 changes: 25 additions & 15 deletions modules/app.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -692,28 +692,38 @@ declare function app:place-details($node as node(), $model as map(*)) as map(*)
let $geonames-id := str:normalize-space(($model?doc//tei:idno[@type='geonames'])[1])
let $gnd := query:get-gnd($model('doc'))
let $gn-doc := er:grabExternalResource('geonames', $geonames-id, '', ())
let $basic-data := app:place-basic-data($node, $model)
return
map {
'gnd' : $gnd,
'names' : $model?doc//tei:placeName[@type],
'backlinks' : core:getOrCreateColl('backlinks', $model('docID'), true()),
'xml-download-url' : replace(controller:create-url-for-doc($model('doc'), $model('lang')), '\.html', '.xml'),
'geonames_alternateNames' :
for $alternateName in $gn-doc//gn:alternateName
group by $name := $alternateName/text()
order by $name
return
($name || ' (' || $alternateName/data(@xml:lang) => string-join(', ') || ')'),
'geonames_parentCountry' : $gn-doc//gn:parentCountry/analyze-string(@rdf:resource, '/(\d+)/')//fn:group/text() ! query:get-geonames-name(.)
}
map:merge((
map {
'gnd' : $gnd,
'names' : $model?doc//tei:placeName[@type],
'backlinks' : core:getOrCreateColl('backlinks', $model('docID'), true()),
'xml-download-url' : replace(controller:create-url-for-doc($model('doc'), $model('lang')), '\.html', '.xml'),
'note' : exists($model?doc/tei:place/tei:note),
'geonames_alternateNames' :
for $alternateName in $gn-doc//gn:alternateName
group by $name := $alternateName/text()
order by $name
return
($name || ' (' || $alternateName/data(@xml:lang) => string-join(', ') || ')'),
'geonames_parentCountry' : $gn-doc//gn:parentCountry/analyze-string(@rdf:resource, '/(\d+)/')//fn:group/text() ! query:get-geonames-name(.)
},
$basic-data
))
};

(:
: Some additional data that is used in the preview and in the single view
:)
declare
%templates:wrap
function app:place-basic-data($node as node(), $model as map(*)) as map(*) {
map {
'geonames-id' : str:normalize-space(($model?doc//tei:idno[@type='geonames'])[1]),
'coordinates' : str:normalize-space($model?doc//tei:geo)
'coordinates' : str:normalize-space($model?doc//tei:geo),
'residences': $model('doc')//tei:label[.='Ort'][parent::tei:state]/following-sibling::tei:desc/tei:* ! str:normalize-space(.),
'geonamesFeatureCode': $model('doc')//tei:label[.='Kategorie'][parent::tei:state]/following-sibling::tei:desc ! str:normalize-space(.)
}
};

Expand Down Expand Up @@ -898,7 +908,7 @@ declare
%templates:default("lang", "en")
function app:print-wega-bio($node as node(), $model as map(*), $lang as xs:string) as element(xhtml:div)* {
let $query-result:= app:inject-query($model?doc/*)
let $bio := wega-util:transform($query-result//(tei:note[@type='bioSummary'] | tei:event[tei:head] | tei:note[parent::tei:org]), doc(concat($config:xsl-collection-path, '/persons.xsl')), config:get-xsl-params(()))
let $bio := wega-util:transform($query-result//(tei:note[@type='bioSummary'] | tei:event[tei:head] | tei:note[parent::tei:org] | tei:note[parent::tei:place]), doc(concat($config:xsl-collection-path, '/persons.xsl')), config:get-xsl-params(()))
return
if(some $i in $bio satisfies $i instance of element()) then $bio
else
Expand Down
1 change: 1 addition & 0 deletions modules/facets.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ declare %private function facets:display-term($facet as xs:string, $term as xs:s
case 'docTypeSubClass' case 'docStatus' case 'textType'
case 'facsimile' case 'keywords' case 'docLang' return lang:get-language-string($term, $lang)
case 'repository' return facets:display-term-repository($term)
case 'geonamesFeatureClass' return lang:get-language-string('geonamesFeatureClass_' || $term, $lang)
default return str:normalize-space($term)
};

Expand Down
1 change: 1 addition & 0 deletions modules/query.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ declare function query:get-facets($collection as node()*, $facet as xs:string) a
case 'keywords' return $collection//tei:term[parent::tei:keywords]
case 'docLang' return $collection//tei:language/@ident
case 'workTitle' return $collection//mei:title[parent::mei:titleStmt]
case 'geonamesFeatureClass' return $collection//tei:place/@typeof
default return ()
};

Expand Down
4 changes: 4 additions & 0 deletions resources/js/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ $('h1').h1FitText();
/* hide tabs with no respective div content */
$('li').has('a.deactivated').hide();

/* only mark the first div and tab "active" on place pages when tei:note and GeoNames are both present */
$('.nav-tabs a.active').first().parent().nextAll().has('a.active').children().removeClass('active')
$('.tab-content div.active').first().nextAll('.active').removeClass('active')

/*
* Initialise easyResponsiveTabs for person.html
*/
Expand Down
3 changes: 3 additions & 0 deletions templates/ajax/places.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ <h2><a href="#allFilter" class="collapseSingle" aria-expanded="true" data-toggle
<h4 data-template="lang:translate">placenames</h4>
<select multiple="multiple" data-template="facets:select" name="placenames"/>

<h4 data-template="lang:translate">geonamesFeatureClass</h4>
<select multiple="multiple" data-template="facets:select" name="geonamesFeatureClass"/>

<!--<h4 data-template="lang:translate">docType</h4>
<select multiple="multiple" data-template="facets:select" name="textType"/>-->
</div>
Expand Down
6 changes: 5 additions & 1 deletion templates/includes/preview-places.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ <h3 class="media-heading">
<i class="fa fa-globe"/>
<a href="http://www.geonames.org/2661881/aarau.html" data-template="app:place-link" data-template-provider="geoNames">2661881</a>
</p>-->
<p>
<p data-template="app-shared:if-exists" data-template-key="geonamesFeatureCode">
<i class="fa fa-compass"/>
<span data-template="app-shared:join" data-template-key="geonamesFeatureCode">Gasthof</span>
</p>
<p data-template="app-shared:if-exists" data-template-key="coordinates">
<i class="fa fa-location-arrow"/>
<span data-template="app-shared:print" data-template-key="coordinates">50.59403 8.95866</span>
</p>
Expand Down
41 changes: 36 additions & 5 deletions templates/place.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h3 data-template="lang:translate">imageSource</h3>
</div>
</div>
</div>
<div class="col-md paddingBottomIcon col-sm-6 basicdata" data-template="app:place-basic-data">
<div class="col-md paddingBottomIcon col-sm-6 basicdata">
<h2 data-template="lang:translate">basic_data</h2>
<ol class="media">
<li class="media names" data-template="app-shared:each" data-template-from="names" data-template-to="name">
Expand All @@ -64,15 +64,31 @@ <h2 data-template="lang:translate">basic_data</h2>
<span data-template="app-shared:print" data-template-key="name">Frankfurt am Main</span>
</div>
</li>
<li class="media">
<li class="media geonamesFeatureCode" data-template="app-shared:if-exists" data-template-key="geonamesFeatureCode">
<div class="pull-left">
<i class="fa fa-compass"/>
</div>
<div class="media-body" data-template="app-shared:join" data-template-key="geonamesFeatureCode">
Gasthaus, Hotel
</div>
</li>
<li class="media residences" data-template="app-shared:if-exists" data-template-key="residences">
<div class="pull-left">
<i class="fa fa-map-marker"/>
</div>
<div class="media-body" data-template="app-shared:join" data-template-key="residences">
Köln, Gotha
</div>
</li>
<li class="media" data-template="app-shared:if-exists" data-template-key="geonames-id">
<div class="pull-left">
<i class="fa fa-globe"/>
</div>
<div class="media-body">
<span>GeoNames ID:</span> <a href="http://www.geonames.org/2661881/aarau.html" data-template="app:place-link" data-template-provider="geoNames">2661881</a>
</div>
</li>
<li class="media">
<li class="media" data-template="app-shared:if-exists" data-template-key="coordinates">
<div class="pull-left">
<i class="fa fa-location-arrow"/>
</div>
Expand Down Expand Up @@ -120,7 +136,14 @@ <h2 data-template="lang:translate">iconography</h2>
<h2 data-template="lang:translate">documents</h2>
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="nav-item gradient-light">
<li class="nav-item gradient-light" data-template="app-shared:if-exists" data-template-key="note">
<!--
need to mark both "wegaText" and "geonames" as 'active'.
IFF both are actually present, some Javascript will keep only the first one
-->
<a class="nav-link active" data-toggle="tab" href="#wegaText">WeGA Text</a>
</li>
<li class="nav-item gradient-light" data-template="app-shared:if-exists" data-template-key="geonames-id">
<a class="nav-link active" data-toggle="tab" href="#geonames">GeoNames</a>
</li>
<li class="nav-item gradient-light">
Expand All @@ -144,7 +167,15 @@ <h2 data-template="lang:translate">documents</h2>
<div class="col-md-9 ">
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active fade in" id="geonames">
<div class="tab-pane active fade in" id="wegaText" data-template="app-shared:if-exists" data-template-key="note">
<!--
need to mark both "wegaText" and "geonames" as 'active'.
IFF both are actually present, some Javascript will keep only the first one
-->
<h2>WeGA Text</h2>
<div data-template="app:print-wega-bio"></div>
</div>
<div class="tab-pane active fade in" id="geonames" data-template="app-shared:if-exists" data-template-key="geonames-id">
<h2>GeoNames</h2>
<dl>
<dt data-template="lang:translate">pnd_otherNames</dt>
Expand Down
3 changes: 2 additions & 1 deletion xsl/common_link.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<!-- ********************************************* -->
<xsl:template match="tei:persName | tei:author | tei:orgName |
mei:persName | tei:workName | tei:settlement | mei:settlement |
mei:geogName | mei:corpName | mei:title[@codedval]" mode="#all">
mei:geogName | mei:corpName | mei:title[@codedval] | tei:placeName[@key]"
mode="#all">
<xsl:choose>
<xsl:when test="@key or @codedval">
<xsl:call-template name="createLink"/>
Expand Down

0 comments on commit a0491d7

Please sign in to comment.