Commit 3db840e9 authored by Mathias Goebel's avatar Mathias Goebel 🎠

Merge branch 'feature/document-download-and-navigation' into 'develop'

Feature/document download and navigation

See merge request !77
parents dfc92a04 0d07530a
xquery version "3.1";
(:~
: This module handles the download of the current SADE application on publish.html.
: The current (maybe forked) SADE app is provided as an installable XAR package.
:
: @author unknown
: @author Michelle Weidling
: @version 1.0
:)
declare namespace pkg="http://expath.org/ns/pkg";
import module namespace dbutil="http://exist-db.org/xquery/dbutil";
import module namespace config="https://sade.textgrid.de/ns/config" at "config.xqm";
declare function local:download($app-collection as xs:string, $expathConf as element(), $expand-xincludes as xs:boolean) {
(:~
: The main download function. Pack the SADE app denoted in $app-collection
: into a XAR file and then offer it as a download on publish.html.
:
: @param $app-collection The path to the application that is to be downloaded
: @param $expathConf The root element of the application's expath-pkg.xml
: @param $expand-xincludes true() if XIncludes should be expanded automatically
:
:)
declare function local:download($app-collection as xs:string, $expathConf as element(pkg:package), $expand-xincludes as xs:boolean) as empty-sequence() {
let $name := concat($expathConf/@abbrev, "-", $expathConf/@version, ".xar")
let $entries :=
dbutil:scan(xs:anyURI($app-collection), function($collection as xs:anyURI?, $resource as xs:anyURI?) {
......
xquery version "3.1";
(:~
: description
: This module handles the main level navigation of SADE. The entries can be
: changed at navigation.xml. While each item is rendered as a clickable button,
: submenus are displayed as labels for dropdown menus.
:
: @author unknown
: This module is called by templates/nav_include.html.
:
: Please note that submenus within submenus aren't allowed since they aren't
: regarded as good practice anymore.
:
: @author Mathias Göbel
: @author Stefan Hynek
: @version 0.1
: @author Ubbo Veentjer
: @author Michelle Weidling
: @version 1.1
:)
module namespace nav="https://sade.textgrid.de/ns/navigation";
......@@ -23,21 +32,41 @@ declare variable $nav:langTest := if($nav:langDefault = "")
declare
%templates:wrap
function nav:navitems($node as node(), $model as map(*)) as map(*) {
function nav:navitems($node as node(), $model as map(*)) as map(*)
{
let $confLocation := config:get("location", $nav:module-key)
let $navitems := doc( $config:app-root || "/" || $confLocation)//navigation/*
return
map { "navitems" : $navitems }
};
declare function nav:head($node as node(), $model as map(*)) {
(:~
: Handle the main buttons in the navigation, e.g. "About SADE". For each child
: of navigation in navigation.xqm, <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-template="nav:head"> is evoked and processed.
:
: The whole process considers the currently selected language for the label creation.
:
: @author Mathias Göbel
: @author Stefan Hynek
: @author Ubbo Veentjer
: @author Michelle Weidling
:
: @param $node The current xhtml:a (which is then further processed)
: @param $model A map containing arbitrary data – used to pass information between template calls
: @return element() with the label text in the right language
:)
declare function nav:head($node as node(), $model as map(*)) as element()
{
(: $model("item") is the current child of the navigation entity in navigation.xml :)
switch(local-name($model("item")))
case "submenu" return
element { node-name($node) } {
$node/@*,
if ($nav:langTest)
then (string($model("item")/@label))
else string($model("item")/@*[local-name( . ) = "label-" || $nav:lang]),
if ($nav:langTest) then
string($model("item")/@label)
else
string($model("item")/@*[local-name( . ) = "label-" || $nav:lang]),
$node/node()
}
case "item" return
......@@ -49,21 +78,53 @@ declare function nav:head($node as node(), $model as map(*)) {
else
attribute target {"_blank"},
(: if ($nav:langTest or not($model("subitem")/@*[local-name() ="label-" || $nav:lang])):)
if ($nav:langTest)
then string($model("item")/@label)
else string($model("item")/@*[local-name( . ) = "label-" || $nav:lang])
if ($nav:langTest) then
string($model("item")/@label)
else
string($model("item")/@*[local-name( . ) = "label-" || $nav:lang])
}
default return
<b>not defined: { node-name($model("item")) }</b>
};
(:~
: Create a map of all elements that are displayed as part of a dropdown.
: These are encoded in navigation.xml as nodes with a depth level of 2, i.e.
: children of the root node's children.
:
: @author Mathias Göbel
: @author Stefan Hynek
: @author Ubbo Veentjer
: @author Michelle Weidling
:
: @param $node The current <ul class="dropdown-menu" data-template="nav:subitems">...</ul> which is evoked once for each child of the element 'navigation'
: @param $model A map containing arbitrary data - used to pass information between template calls
: @return A map containing all nodes with a depth level of 2
:)
declare
%templates:wrap
function nav:subitems($node as node(), $model as map(*)) as map(*) {
function nav:subitems($node as node(), $model as map(*)) as map(*)
{
map{ "subitems" : $model("item")/*}
};
declare function nav:subitem($node as node(), $model as map(*)) {
(:~
: Process and serialize the nodes that are part of a dropdown.
:
: @author Mathias Göbel
: @author Stefan Hynek
: @author Ubbo Veentjer
: @author Michelle Weidling
:
: @param $node The current <a href="#" data-template="nav:subitem" /> that is evoked once for each node with a depth level of 2
: @param $model A map containing arbitrary data - used to pass information between template calls
: @return An XHTML element with either a link with a label in the current language or an empty span
:)
declare function nav:subitem($node as node(), $model as map(*)) as element(*)
{
util:log-system-out($node),
if($model("subitem")/@class) then
<span class="{$model("subitem")/@class}">&#160;</span>
else if ($model("subitem")/name() != 'divider') then
......@@ -73,9 +134,11 @@ declare function nav:subitem($node as node(), $model as map(*)) {
()
else
attribute target {"_blank"},
if ($nav:langTest or not($model("subitem")/@*[local-name() ="label-" || $nav:lang]))
then string($model("subitem")/@label)
else string($model("subitem")/@*[local-name( . ) = "label-" || $nav:lang])
if ($nav:langTest
or not($model("subitem")/@*[local-name() ="label-" || $nav:lang])) then
string($model("subitem")/@label)
else
string($model("subitem")/@*[local-name( . ) = "label-" || $nav:lang])
}
else <span>&#160;</span>
else <span>&#160;</span>
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment