fix search paging

This commit is contained in:
Oleg Belyaev 2025-03-23 14:25:15 +03:00
parent 6e7cf5a3f1
commit b89645a5cc
3 changed files with 21 additions and 10 deletions

View file

@ -186,15 +186,14 @@ declare %rest:path("{$lang}/search/new")
$sd(1)('entry_id'),
string-join($sd(1)('path')?*,"|"))
else
let $r5 := session:set('searchN',0)
return web:redirect('../dict')
web:redirect('../search/clear')
};
declare %rest:path("{$lang}/search/next")
%output:method("html")
%output:html-version('5')
function page:search-next($lang) {
let $n := session:get('searchN')+1
let $n as xs:integer := session:get('searchN')+1
let $r1 := session:set('searchN', $n)
let $sd := session:get('searchData')
return page:by-id($lang, $sd($n)('entry_id'), string-join($sd($n)('path')?*,"|"))
@ -204,7 +203,7 @@ declare %rest:path("{$lang}/search/prev")
%output:method("html")
%output:html-version('5')
function page:search-prev($lang) {
let $n := session:get('searchN')-1
let $n as xs:integer := session:get('searchN')-1
let $r1 := session:set('searchN', $n)
let $sd := session:get('searchData')
return page:by-id($lang, $sd($n)('entry_id'), string-join($sd($n)('path')?*,"|"))
@ -214,7 +213,7 @@ declare %rest:path("{$lang}/search/position")
%rest:query-param("p", "{$p}")
%output:method("html")
%output:html-version('5')
function page:search-position($lang,$p) {
function page:search-position($lang, $p as xs:integer) {
let $r1 := session:set('searchN', $p)
let $sd := session:get('searchData')
return page:by-id($lang, $sd($p)('entry_id'), string-join($sd($p)('path')?*,"|"))

View file

@ -3,8 +3,22 @@ declare namespace abv = "http://ossetic-studies.org/ns/abaevdict";
import module namespace abv-m = 'http://ossetic-studies.org/ns/abaevdict-mod' at './abv-mod.xqm';
let $doc := db:get('abaevdict_en','/xml/entry_az.xml')
return string(abv-m:make-html($doc, 'ru')/article[1]/@id)
for $a in [1,2,3]?*
return $a
(: let $doc-tr := $doc transform with {
replace node xquery:eval("/Q{http://www.tei-c.org/ns/1.0}entry[1]/Q{http://www.tei-c.org/ns/1.0}etym[1]/Q{http://www.tei-c.org/ns/1.0}mentioned[2]/Q{http://www.tei-c.org/ns/1.0}mentioned[18]", {'': .})
with <abv:mark>{xquery:eval("/Q{http://www.tei-c.org/ns/1.0}entry[1]/Q{http://www.tei-c.org/ns/1.0}etym[1]/Q{http://www.tei-c.org/ns/1.0}mentioned[2]/Q{http://www.tei-c.org/ns/1.0}mentioned[18]", {'': .})}</abv:mark>
}
return $doc :)
(: array{for $doc in collection('abaevdict_en/xml')
let $hits := for $node in $doc//text()
where $node contains text 'friend'
return path($node)
where count($hits) > 0
return {'entry_id': string($doc/tei:entry[1]/@xml:id), 'xpath': array{$hits}}} :)
(: let $nid := db:node-id($doc/tei:entry[1]/tei:note[1]) :)
(: return $nid :)
(: return xquery:eval('declare namespace tei = "http://www.tei-c.org/ns/1.0";//tei:note',{'': $doc}) :)
@ -15,8 +29,6 @@ return string(abv-m:make-html($doc, 'ru')/article[1]/@id)
(: import module namespace api = 'http://ossetic-studies.org/ns/abaevdict-api' at './restx_api.xq'; :)
(: abv-m:make-html(doc('abaevdict_en/xml/entry_az.xml')//tei:mentioned,'en') :)
(: abv-m:langname-by-id('inc-x-old-vaidika','en') :)
(: SERIALIZE AS JSONML :)

View file

@ -38,7 +38,7 @@
<!-- The completeness attribute is to be used without namespace, to simplify styling.
For the purposes of conversion, delete it at present -->
<xsl:template match="@abv:completeness | @abv:status">
<xsl:template match="@abv:completeness | @abv:status | @abv:mentionedType">
<!--<xsl:attribute name="completeness">
<xsl:value-of select="."/>
</xsl:attribute>-->