Skip to content

Commit

Permalink
Some small changes to improve class
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Job committed Apr 14, 2010
1 parent 748c381 commit 3021cb1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
Binary file added img/.DS_Store
Binary file not shown.
Binary file added img/marklogic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions index.xqy
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
xquery version "1.0-ml" ; xquery version "1.0-ml" ;


import module namespace h = "helpers" at "/lib/helpers.xqy" ;

xdmp:set-response-content-type( "application/xhtml+xml" ), xdmp:set-response-content-type( "application/xhtml+xml" ),
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
Expand All @@ -12,7 +14,7 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<body id="home"> <body id="home">
<div id="wrapper"> <div id="wrapper">
<div id="header"> <div id="header">
<h1> MarkLogic Blog </h1> <h1> <img border="0" alt="MarkLogic" src="img/marklogic.png"/> Blog </h1>
</div> </div>
<div id="nav"> <div id="nav">
<ul> <ul>
Expand All @@ -22,7 +24,6 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<div id="content"> <div id="content">
<div id="subcol"> <div id="subcol">
<h2>Facets</h2> <h2>Facets</h2>
Not yet
</div> </div>


<div id="maincol"> <div id="maincol">
Expand All @@ -34,15 +35,14 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
</div><br/> </div><br/>
<h2>Listing Posts</h2> <h2>Listing Posts</h2>
<dl> { for $a in fn:doc() [1 to 10] <dl> { for $a in fn:doc() [1 to 10]
let $_ := xdmp:log ( xdmp:quote($a) )
let $permalink := fn:concat('show.xqy?uri=', fn:document-uri($a)) let $permalink := fn:concat('show.xqy?uri=', fn:document-uri($a))
let $snippet := fn:string-join( let $snippet := fn:string-join(
fn:tokenize(fn:string($a//*:body), " ")[1 to 20], " ") fn:tokenize(fn:string($a//*:body), " ")[1 to 20], " ")
return return
(<dt><a href="{$permalink}">{fn:string($a//*:title)}</a></dt>, (<dt><a href="{$permalink}">{fn:string($a//*:title)}</a></dt>,
<dd>{$snippet}</dd>) } <dd>{$snippet}</dd>) }
</dl> </dl>
<p>[ <a href="new.xqy">Add new</a> ]</p> <p>[ {h:link_to_new()} ]</p>
</div> </div>
</div> </div>
</div> </div>
Expand Down
9 changes: 9 additions & 0 deletions lib/helpers.xqy
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
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> } ;

declare function h:link_to_new() {
<a href="new.xqy" xmlns="http://www.w3.org/1999/xhtml">Add new</a> } ;
7 changes: 4 additions & 3 deletions new.xqy
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,6 @@
xquery version "1.0-ml" ; xquery version "1.0-ml" ;

import module namespace h = "helpers" at "/lib/helpers.xqy" ;
import module namespace gen = "http://ns.dscape.org/2010/generate-tree" import module namespace gen = "http://ns.dscape.org/2010/generate-tree"
at "/lib/generate-tree.xqy" ; at "/lib/generate-tree.xqy" ;


Expand All @@ -14,7 +16,7 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<body id="home"> <body id="home">
<div id="wrapper"> <div id="wrapper">
<div id="header"> <div id="header">
<h1> MarkLogic Blog </h1> <h1> <img border="0" alt="MarkLogic" src="img/marklogic.png"/> Blog </h1>
</div> </div>
<div id="nav"> <div id="nav">
<ul> <ul>
Expand All @@ -24,7 +26,6 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<div id="content"> <div id="content">
<div id="subcol"> <div id="subcol">
<h2>Facets</h2> <h2>Facets</h2>
Not yet
</div> </div>


<div id="maincol"> <div id="maincol">
Expand All @@ -48,7 +49,7 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
return xdmp:document-insert( $path, return xdmp:document-insert( $path,
gen:process-fields( $xpaths, $values ) ) } gen:process-fields( $xpaths, $values ) ) }
</div> </div>
<p>[ <a href="index.xqy">Back to main</a> ]</p> <p>[ { h:link_to_index() } ]</p>
</div> </div>
</div> </div>
</div> </div>
Expand Down
11 changes: 7 additions & 4 deletions show.xqy
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,7 @@
xquery version "1.0-ml" ; xquery version "1.0-ml" ;


import module namespace h = "helpers" at "/lib/helpers.xqy" ;

xdmp:set-response-content-type( "application/xhtml+xml" ), xdmp:set-response-content-type( "application/xhtml+xml" ),
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
Expand All @@ -12,7 +14,7 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<body id="home"> <body id="home">
<div id="wrapper"> <div id="wrapper">
<div id="header"> <div id="header">
<h1> MarkLogic Blog </h1> <h1> <img border="0" alt="MarkLogic" src="img/marklogic.png"/> Blog </h1>
</div> </div>
<div id="nav"> <div id="nav">
<ul> <ul>
Expand All @@ -22,7 +24,6 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
<div id="content"> <div id="content">
<div id="subcol"> <div id="subcol">
<h2>Facets</h2> <h2>Facets</h2>
Not yet
</div> </div>


<div id="maincol"> <div id="maincol">
Expand All @@ -33,11 +34,13 @@ xdmp:set-response-content-type( "application/xhtml+xml" ),
</form> </form>
</div><br/> { </div><br/> {
let $uri := xdmp:get-request-field("uri") let $uri := xdmp:get-request-field("uri")
let $a := doc($uri) let $a := doc(xdmp:url-encode($uri))
let $_ := xdmp:log(xdmp:quote($a))
let $_ := xdmp:log($uri)
return return
(<h2>{fn:string($a//*:title)}</h2>, (<h2>{fn:string($a//*:title)}</h2>,
<p>{fn:string($a//*:body)}</p>) } <p>{fn:string($a//*:body)}</p>) }
<p>[ <a href="new.xqy">Add new</a> ]</p> <p>[ { h:link_to_index() } ]</p>
</div> </div>
</div> </div>
</div> </div>
Expand Down

0 comments on commit 3021cb1

Please sign in to comment.