Permalink
Browse files

fixed some things - linus you are to blame

  • Loading branch information...
Nuno Job
Nuno Job committed Apr 15, 2010
1 parent f9b92c5 commit 7c76b4814820a5979f1385afa5db0499796db281
Showing with 3 additions and 34 deletions.
  1. +3 −3 lib/helpers.xqy
  2. +0 −31 rewrite.xqy
View
@@ -3,10 +3,10 @@ xquery version "1.0-ml";
module namespace h = "helpers";
declare function h:link_to_index() {
<a href="/" xmlns="http://www.w3.org/1999/xhtml">Back to main</a> } ;
<a href="/index.xqy" xmlns="http://www.w3.org/1999/xhtml">Back to main</a> } ;
declare function h:link_to_new() {
<a href="/new" xmlns="http://www.w3.org/1999/xhtml">Add new</a> } ;
<a href="/new.xqy" xmlns="http://www.w3.org/1999/xhtml">Add new</a> } ;
declare function h:link_to_show( $path ) {
fn:concat( '/show', $path ) };
fn:concat( '/show.xqy?uri=', $path ) };
View
@@ -1,31 +0,0 @@
(:
: supporting all paths
:)
declare function local:get-uri-encoded-fields() {
let $fields := fn:string-join( for $field in xdmp:get-request-field-names()
return fn:concat( $field, "=",
xdmp:url-encode(xdmp:get-request-field( $field ) ) ), "&amp;" )
return if ($fields) then fn:concat("?", $fields) else "" } ;
declare function local:default( $path ) {
fn:concat( $path, local:get-uri-encoded-fields() ) } ;
declare function local:requested-root ( $path ) { fn:matches($path, "^/$") } ;
declare function local:requested-new ( $path ) {
fn:matches($path, "^/new$") } ;
declare function local:requested-show ( $path ) {
fn:matches($path, "^/show/\.*") } ;
declare function local:show( $path ) {
fn:concat( "show.xqy?uri=/", fn:replace($path, "^/show/(\.*)", "$2") ) };
let $path := xdmp:get-request-path()
return
if ( local:requested-root ( $path ) )
then "index.xqy"
else
if ( local:requested-new ( $path ) )
then fn:concat( "new.xqy", local:get-uri-encoded-fields() )
else
if ( local:requested-show ( $path ) )
then local:show( $path )
else fn:concat( $path, local:get-uri-encoded-fields() )

0 comments on commit 7c76b48

Please sign in to comment.