Skip to content

Commit

Permalink
Merge pull request #187 from srophe/development
Browse files Browse the repository at this point in the history
Update dev server
  • Loading branch information
wsalesky authored Aug 27, 2024
2 parents d836162 + 4e98c36 commit ae854af
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 93 deletions.
2 changes: 1 addition & 1 deletion cbss/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="main-content-block">
<div class="indent">
<br/>
<h1>Browse works cited by title </h1>
<h1>Browse works cited by author </h1>
<div data-template="browse:get-all" data-template-element="tei:titleStmt/tei:title[1]" data-template-collection="bibl">
<div class="tabbable">
<!-- Browse Tabs Configurable. -->
Expand Down
2 changes: 1 addition & 1 deletion cbss/facet-def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
-->
<facet-definition name="cbssKeywords" label="Keywords">
<group-by>
<sub-path>descendant::tei:relation[@type="subject"]</sub-path>
<sub-path>descendant::tei:relation[@ref="dc:subject"]</sub-path>
</group-by>
<max-values show="5">40</max-values>
<order-by direction="ascending">value</order-by>
Expand Down
34 changes: 17 additions & 17 deletions modules/lib/data.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ declare function data:get-records($collection as xs:string*, $element as xs:stri
if(request:get-parameter('sort', '') != '') then request:get-parameter('sort', '')
else if(request:get-parameter('sort-element', '') != '') then request:get-parameter('sort-element', '')[1]
else ()
let $hits := util:eval(data:build-collection-path($collection))[descendant::tei:body[ft:query(., (),sf:facet-query())]]
let $hits := util:eval(data:build-collection-path($collection))[ft:query(., (),sf:facet-query())]
return
if(request:get-parameter('view', '') = 'map') then $hits
else if(request:get-parameter('view', '') = 'timeline') then $hits
else if($collection = 'bibl') then
for $hit in $hits
let $s :=
let $s :=
if(contains($sort, 'author')) then ft:field($hit, "author")[1]
else if(contains($sort, 'title') or contains($sort, 'headword')) then
if(request:get-parameter('lang', '') = 'syr') then ft:field($hit, "titleSyriac")[1]
Expand All @@ -155,8 +155,8 @@ declare function data:get-records($collection as xs:string*, $element as xs:stri
else if(request:get-parameter('lang', '') = 'fr') then ft:field($hit, "titleFrench")[1]
else if(request:get-parameter('lang', '') = 'en-x-gedsh') then ft:field($hit, "titleTransliteration")[1]
else ft:field($hit, "author")[1]
order by $s[1] collation 'http://www.w3.org/2013/collation/UCA'
where
order by $s[1] collation 'http://www.w3.org/2013/collation/UCA'
where
if(request:get-parameter('view', '') = 'A-Z') then
(matches($s,'\p{IsBasicLatin}|\p{IsLatin-1Supplement}|\p{IsLatinExtended-A}|\p{IsLatinExtended-B}','i') and matches($s,global:get-alpha-filter()))
else if(request:get-parameter('view', '') = 'ܐ-ܬ') then
Expand All @@ -165,8 +165,8 @@ declare function data:get-records($collection as xs:string*, $element as xs:stri
(matches($s,'\p{IsArabic}','i'))
else if(request:get-parameter('view', '') = 'other') then
not(matches(substring(global:build-sort-string($s,''),1,1),'\p{IsSyriac}|\p{IsArabic}|\p{IsBasicLatin}|\p{IsLatin-1Supplement}|\p{IsLatinExtended-A}|\p{IsLatinExtended-B}|\p{IsLatinExtendedAdditional}','i'))
else matches($s,global:get-alpha-filter())
return $hit/ancestor-or-self::tei:TEI
else matches($s[1],global:get-alpha-filter())
return $hit
else if(request:get-parameter('alpha-filter', '') != ''
and request:get-parameter('alpha-filter', '') != 'All'
and request:get-parameter('alpha-filter', '') != 'ALL'
Expand Down Expand Up @@ -238,7 +238,7 @@ declare function data:search($collection as xs:string*, $queryString as xs:strin
if($params != '') then
if($queryString != '') then
if(ends-with($queryString,'//tei:body')) then ()
else util:eval($queryString)
else util:eval($queryString)[ft:query(., (),sf:facet-query())]
else if(data:create-query($collection) != '') then
util:eval(concat(data:build-collection-path($collection), data:create-query($collection),slider:date-filter(())))
else ()
Expand Down Expand Up @@ -282,7 +282,7 @@ declare function data:apiSearch($collection as xs:string*, $element as xs:string
return concat("/descendant::tei:",$element,"[ft:query(.,'",data:clean-string($queryString),"',data:search-options())]")
else ()
let $eval-string := concat(data:build-collection-path($collection), $elementSearch)
let $hits := util:eval($eval-string)
let $hits := util:eval($eval-string)[ft:query(., (),sf:facet-query())]
let $sort := if($sort-element != '') then
$sort-element[1]
else if(request:get-parameter('sort', '') != '') then
Expand Down Expand Up @@ -501,9 +501,9 @@ declare function data:dynamic-paths($search-config as xs:string?){
if($p = 'keyword') then
data:keyword-search()
else if(string($config//input[@name = $p]/@element) = '.') then
concat("[ft:query(descendant-or-self::tei:body,'",data:clean-string(request:get-parameter($p, '')),"',sf:facet-query())]")
concat("[ft:query(descendant-or-self::tei:body,'",data:clean-string(request:get-parameter($p, '')),"')]")
else if(string($config//input[@name = $p]/@element) != '') then
concat("[ft:query(descendant-or-self::",string($config//input[@name = $p]/@element),",'",data:clean-string(request:get-parameter($p, '')),"',sf:facet-query())]")
concat("[ft:query(descendant-or-self::",string($config//input[@name = $p]/@element),",'",data:clean-string(request:get-parameter($p, '')),"')]")
else ()
else (),'')
};
Expand All @@ -514,10 +514,10 @@ declare function data:dynamic-paths($search-config as xs:string?){
declare function data:keyword-search(){
if(request:get-parameter('keyword', '') != '') then
for $query in request:get-parameter('keyword', '')
return concat("[ft:query(descendant-or-self::tei:body,'",data:clean-string($query),"',sf:facet-query()) or ft:query(ancestor::tei:TEI/descendant::tei:teiHeader,'",data:clean-string($query),"',sf:facet-query())]")
return concat("[ft:query(.,'",data:clean-string($query),"')]")
else if(request:get-parameter('q', '') != '') then
for $query in request:get-parameter('q', '')
return concat("[ft:query(descendant-or-self::tei:body,'",data:clean-string($query),"',sf:facet-query()) or ft:query(ancestor::tei:TEI/descendant::tei:teiHeader,'",data:clean-string($query),"',sf:facet-query())]")
return concat("[ft:query(.,'",data:clean-string($query),"')]")
else ()
};

Expand All @@ -541,7 +541,7 @@ declare function data:uri() as xs:string? {
let $q := request:get-parameter('uri', '')
return
concat("
[ft:query(descendant::*,'&quot;",$q,"&quot;',sf:facet-query()) or
[ft:query(descendant::*,'&quot;",$q,"&quot;') or
.//@passive[matches(.,'",$q,"(\W.*)?$')]
or
.//@mutual[matches(.,'",$q,"(\W.*)?$')]
Expand All @@ -564,7 +564,7 @@ declare function data:element-search($element, $query){
if(exists($element) and $element != '') then
if(request:get-parameter($element, '') != '') then
for $e in $element
return concat("[ft:query(descendant-or-self::tei:",$element,",'",data:clean-string($query),"',sf:facet-query())]")
return concat("[ft:query(descendant-or-self::tei:",$element,",'",data:clean-string($query),"')]")
else ()
else ()
};
Expand Down Expand Up @@ -600,7 +600,7 @@ declare function data:related-places() as xs:string?{
normalize-space($related-place)
else
string-join(distinct-values(
for $r in collection($config:data-root || '/places')//tei:place[ft:query(tei:placeName,$related-place,sf:facet-query())]
for $r in collection($config:data-root || '/places')//tei:place[ft:query(tei:placeName,$related-place)]
let $id := $r//tei:idno[starts-with(.,'http://syriaca.org')]
return $id),'|')
return
Expand Down Expand Up @@ -629,7 +629,7 @@ declare function data:related-persons() as xs:string?{
normalize-space($rel-person)
else
string-join(distinct-values(
for $r in collection($config:data-root || '/persons')//tei:person[ft:query(tei:persName,$rel-person,sf:facet-query())]
for $r in collection($config:data-root || '/persons')//tei:person[ft:query(tei:persName,$rel-person)]
let $id := $r//tei:idno[starts-with(.,'http://syriaca.org')]
return $id),'|')
return
Expand All @@ -650,6 +650,6 @@ declare function data:mentioned() as xs:string?{
let $id := normalize-space(request:get-parameter('mentioned', ''))
return concat("[descendant::*[@ref[matches(.,'",$id,"(\W.*)?$')]]]")
else
concat("[descendant::*[ft:query(tei:title,'",data:clean-string(request:get-parameter('mentioned', '')),"',sf:facet-query())]]")
concat("[descendant::*[ft:query(tei:title,'",data:clean-string(request:get-parameter('mentioned', '')),"')]]")
else ()
};
4 changes: 2 additions & 2 deletions modules/lib/date-slider.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ if(not(empty($min)) and not(empty($max))) then
else()}
<script type="text/javascript">
<![CDATA[
var minPadding = "]]>{'0001-01-01'}<![CDATA["
var maxPadding = "]]>{'2020-01-01'}<![CDATA["
var minPadding = "]]>{$minPadding}<![CDATA["
var maxPadding = "]]>{$maxPadding}<![CDATA["
var minValue = "]]>{$min}<![CDATA["
var maxValue = "]]>{$max}<![CDATA["
$("#slider").dateRangeSlider({
Expand Down
61 changes: 32 additions & 29 deletions modules/lib/facets.xql
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ declare function sf:build-index(){
<index xmlns="http://exist-db.org/collection-config/1.0" xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:srophe="https://srophe.app">
<lucene diacritics="no">
<module uri="http://srophe.org/srophe/facets" prefix="sf" at="xmldb:exist:///{$config:app-root}/modules/lib/facets.xql"/>
<text qname="tei:body">
<text qname="tei:TEI">
{
let $facets :=
for $f in collection($config:app-root)//facet:facet-definition
let $path := document-uri(root($f))
group by $facet-grp := $f/@name
return
if($f[1]/facet:group-by/@function != '') then
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>)
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(., {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>(:,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>:))
else if($f[1]/facet:range) then
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>)
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(., {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>(:,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="sf:facet(descendant-or-self::tei:body, {concat("'",$path[1],"'")}, {concat("'",$facet-grp,"'")})"/>:))
else
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="{replace($f[1]/facet:group-by/facet:sub-path/text(),"&#34;","'")}"/>,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="{replace($f[1]/facet:group-by/facet:sub-path/text(),"&#34;","'")}"/>)
(<facet dimension="{functx:words-to-camel-case($facet-grp)}" expression="{replace($f[1]/facet:group-by/facet:sub-path/text(),"&#34;","'")}"/>(:,
<field name="facet-{functx:words-to-camel-case($facet-grp)}" expression="{replace($f[1]/facet:group-by/facet:sub-path/text(),"&#34;","'")}"/>:))
return
$facets
}
Expand All @@ -82,11 +82,11 @@ declare function sf:build-index(){
}
}
else
( <field name="title" expression="sf:field(descendant-or-self::tei:body,'title')"/>,
<field name="idno" expression="sf:field(descendant-or-self::tei:body,'idno')"/>,
<field name="titleSyriac" expression="sf:field(descendant-or-self::tei:body, 'titleSyriac')"/>,
<field name="titleArabic" expression="sf:field(descendant-or-self::tei:body, 'titleArabic')"/>,
<field name="author" expression="sf:field(descendant-or-self::tei:body, 'author')"/>)
(<field name="title" expression="sf:field(.,'title')"/>,
<field name="idno" expression="sf:field(.,'idno')"/>,
<field name="titleSyriac" expression="sf:field(., 'titleSyriac')"/>,
<field name="titleArabic" expression="sf:field(., 'titleArabic')"/>,
<field name="author" expression="sf:field(., 'author')"/>)
}
</text>
<text qname="tei:fileDesc"/>
Expand All @@ -100,6 +100,9 @@ declare function sf:build-index(){
<text qname="tei:desc" boost="2.0"/>
<!--<text qname="tei:event"/> -->
<text qname="tei:note"/>
<text qname="tei:pubPlace"/>
<text qname="tei:publisher"/>

<!--<text qname="tei:term"/>-->
</lucene>
<range>
Expand Down Expand Up @@ -571,7 +574,7 @@ declare function sf:field-title($element as item()*, $name as xs:string){
: TEI idno field, specific to Srophe applications
:)
declare function sf:field-idno($element as item()*, $name as xs:string){
replace($element/ancestor-or-self::tei:TEI/descendant::tei:publicationStmt/tei:idno[@type="URI"][1],'/tei','')
replace($element/descendant::tei:publicationStmt/tei:idno[@type="URI"][1],'/tei','')
};

(:~
Expand Down Expand Up @@ -662,31 +665,31 @@ declare function sf:field-titleTransliteration($element as item()*, $name as xs:

(: Title Facet :)
declare function sf:facet-title($element as item()*, $facet-definition as item(), $name as xs:string){
if($element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct) then
$element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct/descendant::tei:title
else $element/ancestor-or-self::tei:TEI/descendant::tei:titleStmt/tei:title
if($element/descendant::tei:biblStruct) then
$element/descendant::tei:biblStruct/descendant::tei:title
else $element/descendant::tei:titleStmt/tei:title
};

(: Author field :)
declare function sf:field-author($element as item()*, $name as xs:string){
if($element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct) then
if($element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname) then
concat($element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname, ',',
$element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:forename)
else if($element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:editor[1]/descendant-or-self::tei:surname) then
concat($element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname, ',',
$element/ancestor-or-self::tei:TEI/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:forename)
else $element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct/descendant::tei:author
else $element/ancestor-or-self::tei:TEI/descendant::tei:titleStmt/descendant::tei:author
if($element/descendant::tei:biblStruct) then
if($element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname) then
concat($element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname, ',',
$element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:forename)
else if($element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:editor[1]/descendant-or-self::tei:surname) then
concat($element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:surname, ',',
$element/descendant::tei:body/tei:biblStruct/descendant-or-self::tei:author[1]/descendant-or-self::tei:forename)
else $element/descendant::tei:biblStruct/descendant::tei:author
else $element/descendant::tei:titleStmt/descendant::tei:author
};

(:~
: TEI author facet, specific to Srophe applications
:)
declare function sf:facet-authors($element as item()*, $facet-definition as item(), $name as xs:string){
if($element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct) then
$element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct/descendant::tei:author | $element/ancestor-or-self::tei:TEI/descendant::tei:biblStruct/descendant::tei:editor
else $element/ancestor-or-self::tei:TEI/descendant::tei:titleStmt/descendant::tei:author
if($element/descendant::tei:biblStruct) then
$element/descendant::tei:biblStruct/descendant::tei:author | $element/descendant::tei:biblStruct/descendant::tei:editor
else $element/descendant::tei:titleStmt/descendant::tei:author
};

(:~
Expand All @@ -707,7 +710,7 @@ declare function sf:facet-cbssPubType($element as item()*, $facet-definition as
else if($value = 'journalArticle') then 'Journal Article'
else if($value = 'bookSection') then 'Book Section'
else if($value = 'thesis') then 'Thesis'
else ()
else $value
};

(:
Expand Down
Loading

0 comments on commit ae854af

Please sign in to comment.