forked from abaevdict/abaev-basex
165 lines
7.9 KiB
Text
165 lines
7.9 KiB
Text
|
module namespace shared = 'http://ossetic-studies.org/ns/abaevdict-site/shared';
|
||
|
|
||
|
declare namespace tei = "http://www.tei-c.org/ns/1.0";
|
||
|
import module namespace search = 'http://ossetic-studies.org/ns/abaevdict-site/search-modal' at '../components/search.xq';
|
||
|
|
||
|
(: =========================================================== :)
|
||
|
(: ================== GLOBAL VARIABLES ======================= :)
|
||
|
(: =========================================================== :)
|
||
|
|
||
|
(: Number of items per page :)
|
||
|
declare variable $shared:items-per-page 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 $shared:lookup := doc('abaevdict_index/lookup.xml')/tei:table/tei:entry;
|
||
|
declare variable $shared:lookup-all := doc('abaevdict_index/lookup.xml')/tei:table/*;
|
||
|
|
||
|
declare variable $shared:total := ceiling(count($shared:lookup) div $shared:items-per-page);
|
||
|
(: 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 $shared:sorted := $shared:lookup;
|
||
|
|
||
|
(: =============================================================== :)
|
||
|
(: ======================= COMMON STUFF ========================== :)
|
||
|
(: =============================================================== :)
|
||
|
|
||
|
declare function shared:head($title as xs:string, $script as node()* := ()) {
|
||
|
<head>
|
||
|
<script src="/static/jquery-3.7.1.min.js">
|
||
|
</script>
|
||
|
<script src="/static/abaev-global.js">
|
||
|
</script>
|
||
|
|
||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.classless.min.css"/>
|
||
|
|
||
|
<link rel="stylesheet" href="{web:create-url('/static/abaev-html.css')}"/>
|
||
|
|
||
|
{$script}
|
||
|
|
||
|
<title>{$title}</title>
|
||
|
</head>
|
||
|
};
|
||
|
|
||
|
(: Navigation header and search dialog :)
|
||
|
declare function shared:header($lang as xs:string, $href-other as xs:string) {
|
||
|
(
|
||
|
<header>
|
||
|
<nav>
|
||
|
<ul class="abv-brand">
|
||
|
<li><img class="abv-logo" src="/static/Abaev_logo.png" alt="Abaevdict logo"></img>
|
||
|
<strong>{
|
||
|
switch($lang)
|
||
|
case 'ru' return 'ИЭСОЯ'
|
||
|
default return `Abaevdict`
|
||
|
}</strong><i> β</i></li>
|
||
|
<li>{
|
||
|
(element {if ($lang = 'ru') then 'mark' else 'a'}{
|
||
|
if ($lang != 'ru') then
|
||
|
(attribute class {'link'},
|
||
|
attribute data-href {`{$href-other}`}) else (),
|
||
|
'ru'
|
||
|
}, ' / ',
|
||
|
element {if ($lang = 'ru') then 'a' else 'mark'}{
|
||
|
if ($lang = 'ru') then
|
||
|
(attribute class {'link'},
|
||
|
attribute data-href {`{$href-other}`}) else (),
|
||
|
'en'
|
||
|
})
|
||
|
}
|
||
|
</li>
|
||
|
</ul>
|
||
|
<ul>
|
||
|
<li>
|
||
|
<form role="search" action="./search/new" id="abv-search">
|
||
|
{if (session:get('searchQuery')) then
|
||
|
<button class="link" data-href="./search/clear" type="button">
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-x-lg" viewBox="0 0 16 16">
|
||
|
<path d="M2.146 2.854a.5.5 0 1 1 .708-.708L8 7.293l5.146-5.147a.5.5 0 0 1 .708.708L8.707 8l5.147 5.146a.5.5 0 0 1-.708.708L8 8.707l-5.146 5.147a.5.5 0 0 1-.708-.708L7.293 8z"/>
|
||
|
</svg>
|
||
|
</button>
|
||
|
else
|
||
|
<select name="searchType" required="1">
|
||
|
<option selected="1" value="full">{if ($lang = 'ru')
|
||
|
then 'Везде' else 'All'}</option>
|
||
|
<option value="form">{if ($lang = 'ru')
|
||
|
then 'Формы' else 'Forms'}</option>
|
||
|
<option value="sense">{if ($lang = 'ru')
|
||
|
then 'Значения' else 'Senses'}</option>
|
||
|
<option value="example">{if ($lang = 'ru')
|
||
|
then 'Примеры' else 'Examples'}</option>
|
||
|
<option value="translation">{if ($lang = 'ru')
|
||
|
then 'Переводы' else 'Translations'}</option>
|
||
|
<option value="mentioned">{if ($lang = 'ru')
|
||
|
then 'Цит. формы' else 'Mentioned'}</option>
|
||
|
<option value="gloss">{if ($lang = 'ru')
|
||
|
then 'Глоссы' else 'Glosses'}</option>
|
||
|
<option value="etym">{if ($lang = 'ru')
|
||
|
then 'Этимологии' else 'Etymology'}</option>
|
||
|
</select>
|
||
|
}
|
||
|
<input name="searchQuery"
|
||
|
placeholder="{if ($lang = 'ru') then 'Искать' else 'Search'}"
|
||
|
value="{session:get('searchQuery')}"
|
||
|
aria-label="Search">
|
||
|
{if (exists(session:get('searchQuery'))) then
|
||
|
attribute disabled {"1"} }
|
||
|
</input>
|
||
|
{if (not(session:get('searchQuery'))) then
|
||
|
<button type="submit">
|
||
|
<svg id="abv-search-icon" xmlns="http://www.w3.org/2000/svg"
|
||
|
width="16" height="16"
|
||
|
viewBox="0 0 16 16"
|
||
|
fill="currentColor" class="bi bi-search">
|
||
|
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0"/>
|
||
|
</svg>
|
||
|
</button>
|
||
|
else
|
||
|
(
|
||
|
if (session:get('searchN') > 1) then
|
||
|
<button type="button" class="link" data-href="./search/prev">
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
|
||
|
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8"/>
|
||
|
</svg>
|
||
|
</button>,
|
||
|
<button type="button" id="abv-btn-searchResults">{session:get('searchN')}/{array:size(session:get('searchData'))}</button>
|
||
|
,
|
||
|
if (session:get('searchN') and session:get('searchN') < array:size(session:get('searchData'))) then
|
||
|
<button type="button" class="link" data-href="./search/next">
|
||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-right" viewBox="0 0 16 16">
|
||
|
<path fill-rule="evenodd" d="M1 8a.5.5 0 0 1 .5-.5h11.793l-3.147-3.146a.5.5 0 0 1 .708-.708l4 4a.5.5 0 0 1 0 .708l-4 4a.5.5 0 0 1-.708-.708L13.293 8.5H1.5A.5.5 0 0 1 1 8"/>
|
||
|
</svg>
|
||
|
</button>
|
||
|
)
|
||
|
}
|
||
|
</form>
|
||
|
</li>
|
||
|
<li><a href="./home">{
|
||
|
switch($lang)
|
||
|
case 'ru' return 'Главная'
|
||
|
default return 'Home'
|
||
|
}
|
||
|
</a></li>
|
||
|
<li><a href="./dict">{switch($lang)
|
||
|
case 'ru' return 'Словарь'
|
||
|
default return 'Dictionary'
|
||
|
}
|
||
|
</a></li>
|
||
|
<li><a href="./index">{switch($lang)
|
||
|
case 'ru' return 'Указатель'
|
||
|
default return 'Index'
|
||
|
}</a></li>
|
||
|
<li><a href="#">{switch($lang)
|
||
|
case 'ru' return 'Литература'
|
||
|
default return 'References'
|
||
|
}</a></li>
|
||
|
</ul>
|
||
|
</nav>
|
||
|
</header>,
|
||
|
search:content($lang)
|
||
|
)
|
||
|
};
|
||
|
|
||
|
declare function shared:invert-lang($lang as xs:string) as xs:string {
|
||
|
if($lang = 'en') then 'ru' else 'en'
|
||
|
};
|