Skip to content

Commit

Permalink
added gist to readme, changed new so it only accepts submissions with…
Browse files Browse the repository at this point in the history
… a title
  • Loading branch information
Nuno Job committed Apr 14, 2010
1 parent 3021cb1 commit d827daf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://gist.github.com/366471
10 changes: 7 additions & 3 deletions new.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d827daf

Please sign in to comment.