module namespace entries = 'http://ossetic-studies.org/ns/abaevdict-site/entries'; declare namespace tei = "http://www.tei-c.org/ns/1.0"; import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at '../../abv-mod.xqm'; (: MAIN DICTIONARY VIEW COMPONENT :) (: GET INDIVIDUAL ENTRY :) declare %rest:path("{$lang}/entries/{$id}") %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entry($lang as xs:string, $id as xs:string, $query as xs:string?) { if (count($query) = 0) then doc(`abaevdict_{$lang}/html/{$id}.html`) (: abv-m:make-html(doc(`abaevdict_{$lang}/xml/{$id}.xml`),$lang) :) else let $xml := doc(`abaevdict_{$lang}/xml/{$id}.xml`)/tei:entry[1] let $marked := ft:mark( xquery:eval( `declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; .[{$query}]`, {'': $xml}) ) return abv-m:make-html($marked,$lang) }; declare %rest:path("/entries/{$id}") %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entry($id as xs:string, $query as xs:string?) { entries:entry('en', $id, $query) }; (: GET ENTRIES CATALOG :) declare %rest:path("{$lang}/entries") %rest:query-param("per-chunk", "{$per-chunk}", 5) %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entries($lang as xs:string, $per-chunk as xs:integer, $query as xs:string?) { let $docs := abv-m:collection($lang,'xml')/tei:entry let $chosen := if($query) then xquery:eval(`declare namespace tei = "http://www.tei-c.org/ns/1.0"; declare namespace abv = "http://ossetic-studies.org/ns/abaevdict"; .[{$query}]`, {'': $docs})/string(@xml:id) for tumbling window $w in abv-m:lookups() start at $s when true() only end at $e when $e - $s eq ($per-chunk - 1) return
{ for $entry in $w let $id := $entry/@xml:id return
{if ($id = $chosen) then attribute hx-vals { `{'{'}"query": "{$query}"{'}'}` }} {
}
}
}; declare %rest:path("/entries") %rest:query-param("per-chunk", "{$per-chunk}", 5) %rest:query-param("query", "{$query}") %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entries($per-chunk as xs:integer, $query as xs:string?) { entries:entries('en', $per-chunk, $query) }; (: LIST OF ENTRIES FOR MENU :) declare %rest:path("{$lang}/entrylist") %rest:query-param("filter", "{$filter}") %rest:query-param("subentries", "{$subentries}", false()) %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entrylist($lang as xs:string, $filter as xs:string?, $subentries as xs:boolean?) { }; declare %rest:path("entrylist") %rest:query-param("filter", "{$filter}") %rest:query-param("subentries", "{$subentries}", false()) %rest:GET %rest:produces("text/html") %output:method("html") %output:html-version('5') function entries:entrylist($filter as xs:string?, $subentries as xs:boolean?) { entries:entrylist('en',$filter,$subentries) }; (: QUICK ENTRY LIST SIDEBAR :) declare function entries:sidebar($lang as xs:string) { (, , ) };