Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SADE
SADE
Commits
5ca55fee
Commit
5ca55fee
authored
Jan 18, 2019
by
mrodzis
💪
Committed by
Mathias Goebel
Jan 18, 2019
Browse files
Add content display of charmap and synonyms (closes
#20
)
parent
6bfe7df1
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/app.xqm
View file @
5ca55fee
...
...
@@ -16,9 +16,11 @@ declare namespace tei="http://www.tei-c.org/ns/1.0";
declare namespace test="http://exist-db.org/xquery/xqsuite";
declare namespace tgmd="http://textgrid.info/namespaces/metadata/core/2010";
declare namespace tgrel="http://textgrid.info/relation-ns#";
declare namespace
pkg
="http://expath.org/ns/pkg";
declare namespace
expath
="http://expath.org/ns/pkg";
declare namespace xqdoc="http://www.xqdoc.org/1.0";
declare variable $app:expath := doc($config:app-root || "/expath-pkg.xml");
(:~
: Get the title of this app by using the config.xml.
: @param $node the HTML node with the attribute which triggered this call
...
...
@@ -37,6 +39,21 @@ declare function app:target($node as node(), $model as map(*)) {
config:repoget("target")
};
(:~
: Get the internal title of this app that is used as prefix for charmaps.txt
: and synonyms.txt. :)
declare function app:get-prefix() {
let $abbrev := $app:expath/expath:package/@abbrev/string() => replace("SADE", "sade")
return
(: in case the abbreviation is SADE-develop we have a generic instance
which has the prefix 'sade-' :)
if($abbrev = "sade-develop") then
"sade"
else
$abbrev
};
(:~
: Provides dynamic CSS based on the requested resource name :)
declare function app:css-injection($node as node(), $model as map(*), $exist-resource) {
...
...
@@ -245,9 +262,9 @@ declare
function app:get-sade-info($node as node(), $model as map(*)) {
let $doc := doc($config:app-root || "/expath-pkg.xml")
let $version := $doc//
pkg
:package/@version/string()
let $uri := $doc//
pkg
:package/@name/string()
let $name := $doc//
pkg
:package/@abbrev/string()
let $version := $doc//
expath
:package/@version/string()
let $uri := $doc//
expath
:package/@name/string()
let $name := $doc//
expath
:package/@abbrev/string()
return
(<li>Version: {$version}</li>,
...
...
@@ -255,7 +272,7 @@ function app:get-sade-info($node as node(), $model as map(*)) {
<li>Package name: {$name}</li>,
<li>Dependencies:
<ul>
{for $dep in $doc//
pkg
:dependency return
{for $dep in $doc//
expath
:dependency return
let $dep-name := $dep/(@* except @semver-min)/string()
return
<li>
...
...
@@ -273,6 +290,14 @@ function app:get-sade-info($node as node(), $model as map(*)) {
declare
%templates:wrap
function app:get-charsyn-info($node as node(), $model as map(*)) {
if( not(local:check-dba()) )
then
<div class="row">
<div class="col-md-12">
You have to log in to view this resource.
</div>
</div>
else
let $file-system-path := system:get-exist-home() || util:system-property("file.separator")
let $dir-content := file:list($file-system-path)
let $charmap-available := if($dir-content//*[matches(@name, "charmap\.txt")]) then true() else false()
...
...
@@ -285,6 +310,47 @@ function app:get-charsyn-info($node as node(), $model as map(*)) {
<li>Synonyms available? {if($synonyms-available) then $yes else $no}</li>)
};
declare
%templates:wrap
function app:display-charsyn-info($node as node(), $model as map(*)) {
if( not(local:check-dba()) )
then
<div class="row">
<div class="col-md-12">
You have to log in to view this resource.
</div>
</div>
else
let $file-system-path := system:get-exist-home() || util:system-property("file.separator")
let $dir-content := file:list($file-system-path)
let $prefix := app:get-prefix()
let $charmap-name := $prefix || "-charmap.txt"
let $charmap-path := $file-system-path || $charmap-name
let $charmap := file:read($charmap-path)
let $synonyms-name := $prefix || "-synonyms.txt"
let $synonyms-path := $file-system-path || $synonyms-name
let $synonyms := file:read($synonyms-path)
return
<div class="row">
<div class="col-md-6">
<em>Contents of {$prefix}-charmap.txt:</em>
<pre><code>
{$charmap}
</code></pre>
</div>
<div class="col-md-6">
<em>Contents of {$prefix}-synonyms.txt:</em>
<pre><code>
{$synonyms}
</code></pre>
</div>
</div>
};
(:~
: serves the error messages powered by programmingexcuses.com
...
...
@@ -401,3 +467,8 @@ if(not($newpw)) then () else
</ul>
</div>
};
declare function local:check-dba()
as xs:boolean {
sm:id()//*:username => string() => sm:is-dba()
}
templates/info.html
View file @
5ca55fee
...
...
@@ -19,6 +19,7 @@
<span
class=
"title"
>
Charmaps and Synonyms-file
</span>
</h2>
<ul
class=
"nav-textgrid"
data-template=
"app:get-charsyn-info"
/>
<div
class=
"container"
data-template=
"app:display-charsyn-info"
/>
</section>
<section>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment