abaev-basex-htmx/xq/site/restx_dict.xq

123 lines
4 KiB
Text
Raw Normal View History

module namespace page = 'http://ossetic-studies.org/ns/abaevdict-site';
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';
import module namespace shared = 'http://ossetic-studies.org/ns/abaevdict-site/shared' at './shared/shared.xq';
(: COMPONENTS :)
(: To make the codebase more manageable, components are split into separate
files included as modules. :)
import module namespace home = 'http://ossetic-studies.org/ns/abaevdict-site/home' at './components/home.xq';
import module namespace dict = 'http://ossetic-studies.org/ns/abaevdict-site/dictionary' at './components/dictionary.xq';
import module namespace index = 'http://ossetic-studies.org/ns/abaevdict-site/index' at './components/index.xq';
(: =============================================================== :)
(: ============================ FAVICON ========================== :)
(: =============================================================== :)
declare %rest:path("/favicon.ico")
%rest:GET
function page:favicon() {
fetch:binary('../../static/favicon.ico')
};
(: =============================================================== :)
(: ======================= HOMEPAGE ============================== :)
(: =============================================================== :)
declare %rest:path("{$lang}")
%output:method("html")
%output:html-version('5')
function page:zero($lang) {
page:home($lang)
};
declare %rest:path("/")
%output:method("html")
%output:html-version('5')
function page:zero() {
page:zero('en')
};
declare %rest:path("{$lang}/home")
%output:method("html")
%output:html-version('5')
function page:home($lang) {
<html>
{shared:head(if ($lang='ru') then 'ИЭСОЯ — Главная' else 'Abaevdict — Home',())}
<body>
{shared:header($lang,`../{shared:invert-lang($lang)}/home`)}
<main>
{
home:content($lang)
}
</main>
</body>
</html>
};
declare %rest:path("home")
%output:method("html")
%output:html-version('5')
function page:home() {
page:home('en')
};
(: =============================================================== :)
(: ======================= THE DICTIONARY ======================== :)
(: =============================================================== :)
(: If no language defined, default to English :)
declare %rest:path("dict")
%output:method("html")
%output:html-version('5')
function page:dict() {
web:forward('/en/dict')
};
(: The main dictionary view :)
declare %rest:path("{$lang}/dict")
%rest:query-param("page","{$p}", 1)
%rest:query-param("xpath","{$xpath}", '')
%rest:query-param("entry","{$entry}", '')
%output:method("html")
%output:html-version('5')
function page:dict($lang, $p, $xpath, $entry) {
<html>
{shared:head('HEDO Dictionary',
(<script src="/static/infinite-scroll.pkgd.min.js">
</script>,
<script src="/static/plotly-3.0.1.min.js" charset="utf-8"></script>,
<script src="/static/abaev.js"></script>))}
<body>
{(
shared:header($lang,`../{shared:invert-lang($lang)}/dict`),
dict:main-view($lang, $p, $xpath, $entry)
)}
</body>
</html>
};
(: =============================================================== :)
(: ======================= THE INDEX ============================= :)
(: =============================================================== :)
(: Mentioned index :)
declare %rest:path("{$lang}/index")
%output:method("html")
%output:html-version('5')
function page:index($lang) {
index:content($lang)
};
(: Default to English :)
declare %rest:path("index")
%output:method("html")
%output:html-version('5')
function page:index() {
page:index('en')
};