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
d327b81d
Commit
d327b81d
authored
May 10, 2017
by
Mathias Goebel
Browse files
digilib in controller | we omit REST-API
parent
d618302a
Changes
1
Hide whitespace changes
Inline
Side-by-side
controller.xql
View file @
d327b81d
xquery version "3.1";
import module namespace config="http://textgrid.de/ns/SADE/config" at "modules/config/config.xqm";
import module namespace digilib="http://textgrid.info/namespaces/xquery/digilib" at "../textgrid-connect/digilibProxy.xqm";
declare variable $exist:path external;
declare variable $exist:resource external;
...
...
@@ -11,25 +12,40 @@ declare variable $exist:root external;
let $project := tokenize( $exist:path, "/" )[. != ""][not(ends-with(., "html"))][1]
let $listproject := config:list-projects()[1]
return
(: forward requests without resources to index.html :)
if ($exist:path eq '') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{request:get-uri()}/"/>
</dispatch>
(: forward requests without project to the first project listed :)
else if (empty($project)) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{config:list-projects()[1]}/index.html"/>
</dispatch>
(: forward requests without resources to index.html :)
else if (ends-with($exist:path, "/") or empty($exist:resource)) then
(: forward root path to index.xql :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="index.html"/>
</dispatch>
(: forward REST requests to data collection of the project:)
else if (tokenize($exist:path, '/') = "rest") then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/../sade-projects/{$project}/data/xml/{substring-after($exist:path, "/rest/")}" >
</forward>
<forward url="/../sade-projects/{$project}/data/xml/{substring-after($exist:path, "/rest/")}"/>
</dispatch>
(: forward DIGILIB requests to the proxy function :)
else if (tokenize($exist:path, '/') = "digilib") then
let $path := tokenize($exist:path, '/'),
$id := $path[last()],
$if-modified-since := request:get-header("if-modified-since")
return
digilib:proxy($project, $id, $if-modified-since)
(: the important stuff :)
else if (ends-with($exist:resource, ".html")) then
let $doc-path := $config:projects-dir || $project || config:get("template") || $exist:resource
return
...
...
@@ -45,13 +61,15 @@ else if (ends-with($exist:resource, ".html")) then
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
(: Resource paths starting with $shared are loaded from the shared-resources app :)
(: resource paths starting with $shared are loaded from the shared-resources app :)
else if (contains($exist:path, "/$shared/")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/shared-resources/{substring-after($exist:path, '/$shared/')}">
<set-header name="Cache-Control" value="max-age=3600, must-revalidate"/>
</forward>
</dispatch>
else
(: check if the resource comes from the template or the data
we try to leave the template manipulation as minimal as
...
...
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