Skip to content

Commit

Permalink
Merge pull request #906 from joewiz/url-rewrite-edits
Browse files Browse the repository at this point in the history
[urlrewrite] Minor edits
  • Loading branch information
duncdrum authored Dec 20, 2023
2 parents e449ef5 + e7e23d2 commit 430bc37
Show file tree
Hide file tree
Showing 8 changed files with 426 additions and 317 deletions.
8 changes: 4 additions & 4 deletions src/main/xar-resources/data/urlrewrite/listings/listing-1.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "3.1";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace exist="http://exist.sourceforge.net/NS/exist";

declare variable $exist:path external;
declare variable $exist:resource external;
Expand All @@ -9,7 +9,7 @@ declare variable $exist:prefix external;
declare variable $exist:root external;

<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/transform.xq">
<add-parameter name="doc" value="{$exist:resource}.xml"/>
</forward>
<forward url="{$exist:controller}/modules/transform.xq">
<add-parameter name="doc" value="{$exist:resource}.xml"/>
</forward>
</dispatch>
59 changes: 30 additions & 29 deletions src/main/xar-resources/data/urlrewrite/listings/listing-11.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
if (starts-with($path, '/sandbox/execute'))
then
let $query := request:get-parameter("qu", ())
let $startTime := util:system-time()
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- Query is executed by XQueryServlet -->
<forward servlet="XQueryServlet">
<!-- Query is passed via the attribute 'xquery.source' -->
<set-attribute name="xquery.source" value="{$query}"/>
<!-- Results should be written into attribute 'results' -->
<set-attribute name="xquery.attribute" value="results"/>
<!-- Errors should be passed through instead of terminating the request -->
<set-attribute name="xquery.report-errors" value="yes"/>
</forward>
<view>
<!-- Post process the result: store it into the HTTP session and return the number of hits only. -->
<forward url="session.xq">
<clear-attribute name="xquery.source"/>
<clear-attribute name="xquery.attribute"/>
<set-attribute name="elapsed" value="{string(seconds-from-duration(util:system-time() - $startTime))}"/>
</forward>
</view>
</dispatch>
else if (starts-with($path, '/sandbox/results/'))
if (starts-with($path, "/eXide/execute"))
then
let $query := request:get-parameter("qu", ())
let $startTime := util:system-time()
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- Query is executed by XQueryServlet -->
<forward servlet="XQueryServlet">
<!-- Query is passed via the attribute "xquery.source" -->
<set-attribute name="xquery.source" value="{$query}"/>
<!-- Results should be written into attribute "results" -->
<set-attribute name="xquery.attribute" value="results"/>
<!-- Errors should be passed through instead of terminating the request -->
<set-attribute name="xquery.report-errors" value="yes"/>
</forward>
<view>
<!-- Post process the result: store it into the HTTP session and return the number of hits only. -->
<forward url="session.xq">
<clear-attribute name="xquery.source"/>
<clear-attribute name="xquery.attribute"/>
<set-attribute name="elapsed" value="{string(seconds-from-duration(util:system-time() - $startTime))}"/>
</forward>
</view>
</dispatch>
else
if (starts-with($path, "/sandbox/results/"))
then
(: Retrieve an item from the query results stored in the HTTP session. The
format of the URL will be /sandbox/results/X, where X is the number of the
item in the result set :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="../session.xq">
<add-parameter name="num" value="{$name}"/>
</forward>
</dispatch>
<forward url="../session.xq">
<add-parameter name="num" value="{$name}"/>
</forward>
</dispatch>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<clear-attribute name="xxx">
<clear-attribute name="xxx"/>
10 changes: 5 additions & 5 deletions src/main/xar-resources/data/urlrewrite/listings/listing-2.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xquery version "3.1";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";
declare namespace exist="http://exist.sourceforge.net/NS/exist";

declare variable $exist:path external;
declare variable $exist:resource external;
Expand All @@ -9,8 +9,8 @@ declare variable $exist:prefix external;
declare variable $exist:root external;

<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="data/{$exist:resource}.xml"/>
<view>
<forward url="{$exist:controller}/modules/transform.xq"/>
</view>
<forward url="data/{$exist:resource}.xml"/>
<view>
<forward url="{$exist:controller}/modules/transform.xq"/>
</view>
</dispatch>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="..."/>
</dispatch>
8 changes: 4 additions & 4 deletions src/main/xar-resources/data/urlrewrite/listings/listing-3.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ($exist:path eq '/') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="index.xml"/>
</dispatch>
if ($exist:path eq "/") then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<redirect url="index.xml"/>
</dispatch>
10 changes: 6 additions & 4 deletions src/main/xar-resources/data/urlrewrite/listings/listing-7.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!--
Default configuration: main web application is served from the
webapp directory.
<!-- HTTP requests to /apps are mapped onto the database path /db/apps -->
<root pattern="/apps" path="xmldb:exist:///db/apps"/>

<!--
++ The default fallback web application is served from the
++ /etc/webapp directory on the filesystem.
-->
<root pattern="/tools" path="xmldb:exist:///db/www"/>
<root pattern=".*" path="/"/>
Loading

0 comments on commit 430bc37

Please sign in to comment.