Skip to content

Commit

Permalink
add publisher filter facet to sources
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstadler committed Dec 5, 2024
1 parent 10ce7d0 commit 310dc1d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 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 @@ -25,6 +25,7 @@ enum:
- placenames
- places
- pubPlace
- publisher
- repository
- residences
- sender
Expand Down
1 change: 1 addition & 0 deletions catalogues/dictionary_de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@
<entry xml:id="sources-details-cat">Kategorie (Detail)</entry>
<entry xml:id="sources-meta-cat">Kategorie</entry>
<entry xml:id="pubPlace">Druckort</entry>
<entry xml:id="publisher">Verlag/Druckerei</entry>
<entry xml:id="received">erhalten</entry>
<entry xml:id="descriptions">Beschreibungen</entry>
<entry xml:id="sentVersion">Übermittelter Brief</entry>
Expand Down
1 change: 1 addition & 0 deletions catalogues/dictionary_en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@
<entry xml:id="sources-details-cat">Category (Detail)</entry>
<entry xml:id="sources-meta-cat">Category</entry>
<entry xml:id="pubPlace">Place of Publication</entry>
<entry xml:id="publisher">Publisher</entry>
<entry xml:id="received">received</entry>
<entry xml:id="descriptions">Descriptions</entry>
<entry xml:id="sentVersion">Sent letter</entry>
Expand Down
10 changes: 10 additions & 0 deletions modules/api.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,16 @@ declare function api:validate-pubPlace($model as map(*)) as map(*)? {
else error($api:INVALID_PARAMETER, 'Unsupported value for parameter "pubPlace". It must be a WeGA place ID.' )
};

(:~
: Check parameter publisher
: 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-publisher($model as map(*)) as map(*)? {
if(every $i in $model?publisher ! tokenize(., ',') satisfies wdt:personsPlus($i)('check')()) then map { 'publisher': $model?publisher ! tokenize(., ',') }
else error($api:INVALID_PARAMETER, 'Unsupported value for parameter "publisher". It must be a WeGA org or person ID.' )
};

(:~
: Check parameter placenames (NB: this is supposed to be a string value, not a WeGA ID)
: multiple values allowed as input, either by providing multiple URL parameters
Expand Down
2 changes: 1 addition & 1 deletion modules/facets.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ declare %private function facets:display-term($facet as xs:string, $term as xs:s
switch($facet)
case 'persons' case 'personsPlus' case 'sender' case 'addressee'
case 'dedicatees' case 'lyricists' case 'librettists'
case 'composers' case 'authors' case 'editors' return
case 'composers' case 'authors' case 'editors' case 'publisher' return
if(wdt:persons($term)('check')()) then wdt:persons($term)('label-facets')() (:$facets:persons-norm-file//norm:entry[range:eq(@docID,$term)]/normalize-space():)
else wdt:orgs($term)('label-facets')()
case 'works' return wdt:works($term)('label-facets')()
Expand Down
1 change: 1 addition & 0 deletions modules/query.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ declare function query:get-facets($collection as node()*, $facet as xs:string) a
case 'forenames' return $collection//tei:forename[not(@full)]
case 'surnames' return $collection//tei:surname | $collection//tei:orgName[@type]
case 'pubPlace' return ($collection//mei:pubPlace/@codedval | $collection//tei:pubPlace/@key)
case 'publisher' return ($collection//mei:publisher[parent::mei:pubStmt]/@codedval | $collection//tei:publisher[parent::tei:imprint]/@key)
case 'sources-details-cat' return ($collection//mei:termList[@label='sources-details-cat']/mei:term | $collection//tei:keywords[@scheme='sources-details-cat']/tei:term)
case 'sources-meta-cat' return ($collection//mei:termList[@label='sources-meta-cat']/mei:term | $collection//tei:keywords[@scheme='sources-meta-cat']/tei:term)
case 'placenames' return $collection//tei:placeName[@type='reg']
Expand Down
4 changes: 2 additions & 2 deletions templates/ajax/sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ <h4 data-template="lang:translate">sources-details-cat</h4>
<h4 data-template="lang:translate">pubPlace</h4>
<select multiple="multiple" data-template="facets:select" name="pubPlace"/>

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

</div>
</div>
Expand Down

0 comments on commit 310dc1d

Please sign in to comment.