Permalink
Browse files

added gist to readme, changed new so it only accepts submissions with…

… a title
  • Loading branch information...
Nuno Job
Nuno Job committed Apr 14, 2010
1 parent 3021cb1 commit d827daf76a5666171bef661cafc8ba360a999524
Showing with 8 additions and 3 deletions.
  1. +1 −0 README
  2. +7 −3 new.xqy
View
1 README
@@ -0,0 +1 @@
http://gist.github.com/366471
View
10 new.xqy
@@ -38,16 +38,20 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<textarea name="/article/body" id="body" cols="50"/><br/>
<input type="submit" id="submit" value="Publish"/>
</form>
else <p>New Post created</p>,
else
let $title := xdmp:url-encode(xdmp:get-request-field('/article/title'))
return if ( $title ) then
let $salt := fn:substring(xdmp:md5(fn:string(fn:current-dateTime())), 1, 4)
let $title := xdmp:url-encode(xdmp:get-request-field('/article/title'))
let $dir := fn:replace(fn:tokenize(xs:string(fn:current-dateTime()), "T")[1], "-", "/")
let $path := fn:concat("/", $dir, "/", $title, "-", $salt ,".xml")
let $xpaths := xdmp:get-request-field-names()
let $values := for $field in $xpaths
return xdmp:get-request-field($field)
return xdmp:document-insert( $path,
gen:process-fields( $xpaths, $values ) ) }
return (xdmp:document-insert( $path,
gen:process-fields( $xpaths, $values ) ),
<p>New Post created</p>)
else <p>No title was supplied</p> }
</div>
<p>[ { h:link_to_index() } ]</p>
</div>

0 comments on commit d827daf

Please sign in to comment.