now index and display subentries

This commit is contained in:
Oleg Belyaev 2025-03-22 00:08:52 +03:00
parent a8c0ea875c
commit 4ef96c50ab
4 changed files with 57 additions and 45 deletions

View file

@ -14,8 +14,12 @@ declare variable $page:items as xs:integer := 20;
(: These variables are declared in module scope because they are needed in
different places, but they are still dynamically evaluated :)
declare variable $page:lookup := doc('abaevdict_index/lookup.xml')/tei:table/tei:entry;
declare variable $page:lookup-all := doc('abaevdict_index/lookup.xml')/tei:table/*;
declare variable $page:total := ceiling(count($page:lookup) div $page:items);
declare variable $page:sorted := abv-m:sort-nodes($page:lookup);
(: This is still called sorted, because I haven't changed the code.
But it's now equal to lookup, because the lookup itself is now sorted. :)
declare variable $page:sorted := $page:lookup;
(: =============================================================== :)
(: ======================= COMMON STUFF ========================== :)
@ -331,15 +335,28 @@ declare %rest:path("{$lang}/dict")
{html:doc('../static/chevron-left.svg')}
</button>
<aside id="leftbar">
<input type="text" id="filter-entries" placeholder="Quick filter…"/>
<fieldset>
<input type="text" id="filter-entries"
placeholder="{if ($lang = 'ru') then 'Быстрый фильтр' else 'Quick filter…'}"/>
<label>
<input id="show-re" type="checkbox" role="switch"></input>
{if ($lang = 'ru') then 'Производные' else 'Show subentries'}
</label>
</fieldset>
<nav id="entrylist">
<ul>
{for $doc in $page:sorted
return <li id="link_{$doc/@xml:id}">
<a href="./dict/{$doc/@xml:id}">
{for $doc in $page:lookup-all
let $id := if ($doc/name() = 'entry') then $doc/@xml:id
else $doc/@corresp
return element li {
if ($doc/name() = 're') then
(attribute hidden {'true'},
attribute class {'abv-menu-re'}) else (),
attribute id {`link_{$id}`},
<a href="./dict/{$id}">
{$doc/text()}
</a>
</li>
}
}
</ul>
</nav>