-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontroller.bak
More file actions
117 lines (110 loc) · 5.01 KB
/
Copy pathcontroller.bak
File metadata and controls
117 lines (110 loc) · 5.01 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
xquery version "1.0";
import module namespace theme="http://exist-db.org/xquery/blume/theme" at "modules/theme.xqm";
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:root external;
declare variable $exist:prefix external;
(:
if ($exist:path eq "/") then
(: forward root path to index.xql :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="/"/>
</dispatch>
:)
if ($exist:resource = ("search.html", "export.html", "search-help.html")) then
(: the html page is run through view.xql to expand templates :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/{$exist:resource}">
<set-header name="Cache-Control" value="no-cache"/>
</forward>
<view>
<forward url="{$exist:controller}/modules/view.xql"/>
</view>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
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>
(: Requests for javascript libraries are resolved to the file system :)
else if (contains($exist:path, "/resources/")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/resources/{substring-after($exist:path, '/resources/')}"/>
</dispatch>
else if (starts-with($exist:path, "/")) then
let $id := replace($exist:resource, "^(.*)\.\w+$", "$1")
let $html :=
if ($exist:resource = "") then
"index.html"
else
"view-brief.html"
return
if (ends-with($exist:resource, ".epub")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/get-epub.xql">
<add-parameter name="id" value="{$id}"/>
</forward>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
else if (ends-with($exist:resource, ".tei"))
then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<view>
<forward servlet="XSLTServlet">
<set-attribute name="xslt.stylesheet"
value="xmldb:exist:///db/styles/styles/html/html.xsl"/>
<set-attribute name="xslt.output.media-type"
value="text/html"/>
<set-attribute name="xslt.output.doctype-public"
value="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
<set-attribute name="xslt.output.doctype-system"
value="resources/xhtml1-transitional.dtd"/>
</forward>
</view>
<cache-control cache="no"/>
</dispatch>
else if (ends-with($exist:resource, ".pdf")) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/tei2fo.xql">
<add-parameter name="id" value="{$id}"/>
</forward>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
else if ($exist:resource = "jfb_briefregesten.xml")
then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/create.xql">
</forward>
<cache-control cache="no"/>
</dispatch>
else
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{theme:resolve($exist:prefix, $exist:root, $exist:resource)}"/>
</forward>
<view>
<forward url="{$exist:controller}/modules/view.xql">
<add-parameter name="id" value="{$id}"/>
</forward>
</view>
<error-handler>
<forward url="{$exist:controller}/error-page.html" method="get"/>
<forward url="{$exist:controller}/modules/view.xql"/>
</error-handler>
</dispatch>
else
(: everything else is passed through :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="yes"/>
</dispatch>