Skip to content

Commit

Permalink
Removed debug stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Job committed Apr 15, 2010
1 parent cc4521b commit f9b92c5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/helpers.xqy
Expand Up @@ -3,10 +3,10 @@ xquery version "1.0-ml";
module namespace h = "helpers";

declare function h:link_to_index() {
<a href="/index.xqy" xmlns="http://www.w3.org/1999/xhtml">Back to main</a> } ;
<a href="/" xmlns="http://www.w3.org/1999/xhtml">Back to main</a> } ;

declare function h:link_to_new() {
<a href="/new.xqy" xmlns="http://www.w3.org/1999/xhtml">Add new</a> } ;
<a href="/new" xmlns="http://www.w3.org/1999/xhtml">Add new</a> } ;

declare function h:link_to_show( $path ) {
fn:concat( '/show.xqy?uri=', $path ) };
fn:concat( '/show', $path ) };
8 changes: 0 additions & 8 deletions new.xqy
Expand Up @@ -48,14 +48,6 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
let $xpaths := xdmp:get-request-field-names()
let $values := for $field in $xpaths
return xdmp:get-request-field($field)[1]

let $_ := xdmp:log($salt)
let $_ := xdmp:log($title)
let $_ := xdmp:log($dir)
let $_ := xdmp:log($path)
let $_ := xdmp:log(fn:string-join($xpaths, ", "))
let $_ := xdmp:log(fn:string-join($values, ", "))

return (xdmp:document-insert( $path,
gen:process-fields( $xpaths, $values ) ),
<p>New Post created</p>)
Expand Down
31 changes: 31 additions & 0 deletions rewrite.xqy
@@ -0,0 +1,31 @@
(:
: 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 f9b92c5

Please sign in to comment.