-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcontroller.xql
49 lines (41 loc) · 1.53 KB
/
controller.xql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
xquery version "3.0";
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;
declare variable $app-root :=
let $rawPath := system:get-module-load-path()
let $modulePath :=
(: strip the xmldb: part :)
if (starts-with($rawPath, "xmldb:exist://")) then
if (starts-with($rawPath, "xmldb:exist://embedded-eXist-server")) then
substring($rawPath, 36)
else
substring($rawPath, 15)
else
$rawPath
return
$modulePath
;
if ($exist:path eq "") then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{concat(request:get-uri(), '/')}"/>
</dispatch>
else if ($exist:path eq "/") then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="index.html"/>
</dispatch>
(: change only during sale - remove again after sale is over :)
else if ($exist:path eq "/index.html") then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="index.html"/>
</dispatch>
else if (ends-with($exist:resource, ".html")) then (
util:declare-option("exist:serialize", "method=html5 media-type=text/html"),
doc($app-root || $exist:resource)
) else
(: everything is passed through :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</dispatch>