-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontroller.xql
35 lines (33 loc) · 1.3 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
xquery version "1.0";
declare variable $exist:root external;
declare variable $exist:prefix external;
declare variable $exist:controller external;
declare variable $exist:path external;
declare variable $exist:resource external;
if ($exist:path eq '') then
(: work around trailing slash bug :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="{concat(request:get-uri(), '/')}"/>
</dispatch>
else if ($exist:path eq "/") then
(: redirect root path to blog.xql :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="blog.xql"/>
</dispatch>
else if ($exist:path eq "/blog.xql") then
(: forward to blog.xql's actual location in modules :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="modules/blog.xql"/>
</dispatch>
else if (ends-with($exist:resource, '.xml')) then
(: forward to blog.xql's location in modules :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/blog.xql">
<add-parameter name="entry" value="{$exist:path}"/>
</forward>
</dispatch>
else
(: everything else is passed through :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</dispatch>