update for basex 8.0

This commit is contained in:
Andy Bunce 2015-03-07 22:48:51 +00:00
parent 47ae7ff0b7
commit dd3c397ba6
23 changed files with 1181 additions and 1163 deletions

View File

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>de.loskutov.FileSync.FSBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
</natures>

View File

@ -1,4 +1,4 @@
# graphxq - interface to graphviz for BaseX 7.5
# graphxq - interface to graphviz for BaseX 8.0
* includes dotML
* BaseX RestXQ interface

View File

@ -1,181 +1,181 @@
<!--
graphviz options for shape,color
-->
<graphviz>
<shapes>
<shape>box</shape>
<shape>polygon</shape>
<shape>ellipse</shape>
<shape>circle</shape>
<shape>point</shape>
<shape>egg</shape>
<shape>triangle</shape>
<shape>plaintext</shape>
<shape>diamond</shape>
<shape>trapezium</shape>
<shape>parallelogram</shape>
<shape>house</shape>
<shape>hexagon</shape>
<shape>octagon</shape>
<shape>doublecircle</shape>
<shape>doubleoctagon</shape>
<shape>tripleoctagon</shape>
<shape>invtriangle</shape>
<shape>invtrapezium</shape>
<shape>invhouse</shape>
<shape>Mdiamond</shape>
<shape>Msquare</shape>
<shape>Mcircle</shape>
<shape>record</shape>
<shape>Mrecord</shape>
</shapes>
<colors>
<color>aliceblue</color>
<color>antiquewhite</color>
<color>aqua</color>
<color>aquamarine</color>
<color>azure</color>
<color>beige</color>
<color>bisque</color>
<color>black</color>
<color>blanchedalmond</color>
<color>blue</color>
<color>blueviolet</color>
<color>brown</color>
<color>burlywood</color>
<color>cadetblue</color>
<color>chartreuse</color>
<color>chocolate</color>
<color>coral</color>
<color>cornflowerblue</color>
<color>cornsilk</color>
<color>crimson</color>
<color>cyan</color>
<color>darkblue</color>
<color>darkcyan</color>
<color>darkgoldenrod</color>
<color>darkgray</color>
<color>darkgreen</color>
<color>darkgrey</color>
<color>darkkhaki</color>
<color>darkmagenta</color>
<color>darkolivegreen</color>
<color>darkorange</color>
<color>darkorchid</color>
<color>darkred</color>
<color>darksalmon</color>
<color>darkseagreen</color>
<color>darkslateblue</color>
<color>darkslategray</color>
<color>darkslategrey</color>
<color>darkturquoise</color>
<color>darkviolet</color>
<color>deeppink</color>
<color>deepskyblue</color>
<color>dimgray</color>
<color>dimgrey</color>
<color>dodgerblue</color>
<color>firebrick</color>
<color>floralwhite</color>
<color>forestgreen</color>
<color>fuchsia</color>
<color>gainsboro</color>
<color>ghostwhite</color>
<color>gold</color>
<color>goldenrod</color>
<color>gray</color>
<color>grey</color>
<color>green</color>
<color>greenyellow</color>
<color>honeydew</color>
<color>hotpink</color>
<color>indianred</color>
<color>indigo</color>
<color>ivory</color>
<color>khaki</color>
<color>lavender</color>
<color>lavenderblush</color>
<color>lawngreen</color>
<color>lemonchiffon</color>
<color>lightblue</color>
<color>lightcoral</color>
<color>lightcyan</color>
<color>lightgoldenrodyellow</color>
<color>lightgray</color>
<color>lightgreen</color>
<color>lightgrey</color>
<color>lightpink</color>
<color>lightsalmon</color>
<color>lightseagreen</color>
<color>lightskyblue</color>
<color>lightslategray</color>
<color>lightslategrey</color>
<color>lightsteelblue</color>
<color>lightyellow</color>
<color>lime</color>
<color>limegreen</color>
<color>linen</color>
<color>magenta</color>
<color>maroon</color>
<color>mediumaquamarine</color>
<color>mediumblue</color>
<color>mediumorchid</color>
<color>mediumpurple</color>
<color>mediumseagreen</color>
<color>mediumslateblue</color>
<color>mediumspringgreen</color>
<color>mediumturquoise</color>
<color>mediumvioletred</color>
<color>midnightblue</color>
<color>mintcream</color>
<color>mistyrose</color>
<color>moccasin</color>
<color>navajowhite</color>
<color>navy</color>
<color>oldlace</color>
<color>olive</color>
<color>olivedrab</color>
<color>orange</color>
<color>orangered</color>
<color>orchid</color>
<color>palegoldenrod</color>
<color>palegreen</color>
<color>paleturquoise</color>
<color>palevioletred</color>
<color>papayawhip</color>
<color>peachpuff</color>
<color>peru</color>
<color>pink</color>
<color>plum</color>
<color>powderblue</color>
<color>purple</color>
<color>red</color>
<color>rosybrown</color>
<color>royalblue</color>
<color>saddlebrown</color>
<color>salmon</color>
<color>sandybrown</color>
<color>seagreen</color>
<color>seashell</color>
<color>sienna</color>
<color>silver</color>
<color>skyblue</color>
<color>slateblue</color>
<color>slategray</color>
<color>slategrey</color>
<color>snow</color>
<color>springgreen</color>
<color>steelblue</color>
<color>tan</color>
<color>teal</color>
<color>thistle</color>
<color>tomato</color>
<color>turquoise</color>
<color>violet</color>
<color>wheat</color>
<color>white</color>
<color>whitesmoke</color>
<color>yellow</color>
<color>yellowgreen</color>
</colors>
</graphviz>
<!--
graphviz options for shape,color
-->
<graphviz>
<shapes>
<shape>box</shape>
<shape>polygon</shape>
<shape>ellipse</shape>
<shape>circle</shape>
<shape>point</shape>
<shape>egg</shape>
<shape>triangle</shape>
<shape>plaintext</shape>
<shape>diamond</shape>
<shape>trapezium</shape>
<shape>parallelogram</shape>
<shape>house</shape>
<shape>hexagon</shape>
<shape>octagon</shape>
<shape>doublecircle</shape>
<shape>doubleoctagon</shape>
<shape>tripleoctagon</shape>
<shape>invtriangle</shape>
<shape>invtrapezium</shape>
<shape>invhouse</shape>
<shape>Mdiamond</shape>
<shape>Msquare</shape>
<shape>Mcircle</shape>
<shape>record</shape>
<shape>Mrecord</shape>
</shapes>
<colors>
<color>aliceblue</color>
<color>antiquewhite</color>
<color>aqua</color>
<color>aquamarine</color>
<color>azure</color>
<color>beige</color>
<color>bisque</color>
<color>black</color>
<color>blanchedalmond</color>
<color>blue</color>
<color>blueviolet</color>
<color>brown</color>
<color>burlywood</color>
<color>cadetblue</color>
<color>chartreuse</color>
<color>chocolate</color>
<color>coral</color>
<color>cornflowerblue</color>
<color>cornsilk</color>
<color>crimson</color>
<color>cyan</color>
<color>darkblue</color>
<color>darkcyan</color>
<color>darkgoldenrod</color>
<color>darkgray</color>
<color>darkgreen</color>
<color>darkgrey</color>
<color>darkkhaki</color>
<color>darkmagenta</color>
<color>darkolivegreen</color>
<color>darkorange</color>
<color>darkorchid</color>
<color>darkred</color>
<color>darksalmon</color>
<color>darkseagreen</color>
<color>darkslateblue</color>
<color>darkslategray</color>
<color>darkslategrey</color>
<color>darkturquoise</color>
<color>darkviolet</color>
<color>deeppink</color>
<color>deepskyblue</color>
<color>dimgray</color>
<color>dimgrey</color>
<color>dodgerblue</color>
<color>firebrick</color>
<color>floralwhite</color>
<color>forestgreen</color>
<color>fuchsia</color>
<color>gainsboro</color>
<color>ghostwhite</color>
<color>gold</color>
<color>goldenrod</color>
<color>gray</color>
<color>grey</color>
<color>green</color>
<color>greenyellow</color>
<color>honeydew</color>
<color>hotpink</color>
<color>indianred</color>
<color>indigo</color>
<color>ivory</color>
<color>khaki</color>
<color>lavender</color>
<color>lavenderblush</color>
<color>lawngreen</color>
<color>lemonchiffon</color>
<color>lightblue</color>
<color>lightcoral</color>
<color>lightcyan</color>
<color>lightgoldenrodyellow</color>
<color>lightgray</color>
<color>lightgreen</color>
<color>lightgrey</color>
<color>lightpink</color>
<color>lightsalmon</color>
<color>lightseagreen</color>
<color>lightskyblue</color>
<color>lightslategray</color>
<color>lightslategrey</color>
<color>lightsteelblue</color>
<color>lightyellow</color>
<color>lime</color>
<color>limegreen</color>
<color>linen</color>
<color>magenta</color>
<color>maroon</color>
<color>mediumaquamarine</color>
<color>mediumblue</color>
<color>mediumorchid</color>
<color>mediumpurple</color>
<color>mediumseagreen</color>
<color>mediumslateblue</color>
<color>mediumspringgreen</color>
<color>mediumturquoise</color>
<color>mediumvioletred</color>
<color>midnightblue</color>
<color>mintcream</color>
<color>mistyrose</color>
<color>moccasin</color>
<color>navajowhite</color>
<color>navy</color>
<color>oldlace</color>
<color>olive</color>
<color>olivedrab</color>
<color>orange</color>
<color>orangered</color>
<color>orchid</color>
<color>palegoldenrod</color>
<color>palegreen</color>
<color>paleturquoise</color>
<color>palevioletred</color>
<color>papayawhip</color>
<color>peachpuff</color>
<color>peru</color>
<color>pink</color>
<color>plum</color>
<color>powderblue</color>
<color>purple</color>
<color>red</color>
<color>rosybrown</color>
<color>royalblue</color>
<color>saddlebrown</color>
<color>salmon</color>
<color>sandybrown</color>
<color>seagreen</color>
<color>seashell</color>
<color>sienna</color>
<color>silver</color>
<color>skyblue</color>
<color>slateblue</color>
<color>slategray</color>
<color>slategrey</color>
<color>snow</color>
<color>springgreen</color>
<color>steelblue</color>
<color>tan</color>
<color>teal</color>
<color>thistle</color>
<color>tomato</color>
<color>turquoise</color>
<color>violet</color>
<color>wheat</color>
<color>white</color>
<color>whitesmoke</color>
<color>yellow</color>
<color>yellowgreen</color>
</colors>
</graphviz>

View File

@ -52,7 +52,7 @@ declare %private function dot-execute( $dot as xs:string, $params as xs:string*)
};
(:~ run dot command returning binary :)
declare %private function dot-executeb( $dot as xs:string, $params as xs:string*) as xs:base64Binary{
declare function dot-executeb( $dot as xs:string, $params as xs:string*) as xs:base64Binary{
let $fname:=$gr:tmpdir || random:uuid()
let $oname:=$fname || ".o"
let $junk:=file:write-text($fname,$dot)

View File

@ -1,207 +1,207 @@
(:~
: RESTXQ interface for graphviz
: @author andy bunce
: @since sept 2012
:)
module namespace grxq = 'apb.graphviz.web';
declare default function namespace 'apb.graphviz.web';
import module namespace gr = 'apb.graphviz' at "graphviz.xqm";
import module namespace dotml = 'http://www.martin-loetzsch.de/DOTML' at "dotml.xqm";
import module namespace dotui = 'apb.graphxq.dotui' at "dotui.xqm";
import module namespace txq = 'apb.txq' at "lib/txq.xqm";
import module namespace request = "http://exquery.org/ns/request";
declare namespace svg= "http://www.w3.org/2000/svg";
declare namespace restxq = 'http://exquery.org/ns/restxq';
(:~ shared page wrapper :)
declare variable $grxq:layout:=fn:resolve-uri("views/layout.xml");
(:~
: Home page for app
:)
declare
%restxq:GET %restxq:path("graphxq")
%output:method("html") %output:version("5.0")
function home(){
<restxq:redirect>/restxq/graphxq/about</restxq:redirect>
};
(:~
: about page for app
:)
declare
%restxq:GET %restxq:path("graphxq/about")
%output:method("html") %output:version("5.0")
function about(){
render("views/about.xml",map{"title":="GraphXQ"})
};
(:~
: GET or POST return svg for dot, with download option
:)
declare
%restxq:path("graphxq/api/dot")
%restxq:form-param("data","{$dot}")
%restxq:form-param("url","{$url}")
%restxq:form-param("dl","{$dl}")
%restxq:form-param("dotopt","{$dotopt}")
%output:media-type("image/svg+xml")
function graphxq-svg($dot,$url,$dl,$dotopt) {
let $dot2:=getdot($dot,$url)
let $svg:=dot2svg($dot2)
let $fname:=if($dl)then "dot.svg" else ()
return (headers($fname),$svg)
};
(:~
: display dot edit form
: @param src load from url
:)
declare
%restxq:GET %restxq:path("graphxq/dot")
%output:method("html") %output:version("5.0")
%restxq:form-param("src","{$src}")
function dotform($src){
let $dot:= getdot("digraph {a -> b}",$src)
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $map:=map{"list-shapes":=dotui:shapes(""),
"list-colors":=dotui:colors(""),
"svgwidget":=$svgwidget,
"toolbar":=$toolbar,
"title":="DOT editor",
"dot":=$dot}
return render("views/dotform.xml",$map)
};
declare
%restxq:GET %restxq:path("graphxq/dotml")
%output:method("html") %output:version("5.0")
%restxq:form-param("src","{$src}")
function dotmlform($src){
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $default:=<graph xmlns="http://www.martin-loetzsch.de/DOTML"><node id="test"/></graph>
let $dotml:= getdotml($default ,$src)
let $dotml:= fn:serialize($dotml)
let $v:=map{ "svgwidget":=$svgwidget,
"toolbar":=$toolbar,
"title":="DOTML editor",
"bodyclass":="h100",
"dotml":=$dotml}
return render("views/dotmlform.xml",$v)
};
(:~ static api page :)
declare
%restxq:GET %restxq:path("graphxq/api")
%output:method("html") %output:version("5.0")
function api(){
render("views/api.xml",map{"title":="API information"})
};
(:~ static ace page :)
declare
%restxq:GET %restxq:path("graphxq/ace")
%output:method("html") %output:version("5.0")
function ace(){
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $v:=map{
"title":="XQuery editor (for no reason) ",
"bodyclass":="h100"
}
return render("views/ace.xml",$v)
};
declare
%restxq:GET %restxq:path("graphxq/library")
%output:method("html") %output:version("5.0")
function library(){
let $lib:=fn:doc("data/library.xml")
let $map:=map{"title":="Samples",
"items":=$lib//items,
"url":=function($item){fn:concat($item/url/@type,'?src=data/samples/',$item/url)}
}
return render("views/library.xml",$map)
};
(:~
: @return svg from dotml
:)
declare
%restxq:POST %restxq:path("graphxq/api/dotml")
%restxq:form-param("data","{$dotml}")
%restxq:form-param("dl","{$dl}")
function api-dotml($dotml,$dl ) {
let $dotml:=fn:trace($dotml,"dot: ")
let $dotml:=fn:parse-xml($dotml)
let $x:=dotml:generate($dotml)
let $svg:=dot2svg($x)
let $fname:=if($dl)then "dotml.svg" else ()
return (headers($fname),$svg)
};
(:~ if url is defined then treat as url and fetch else use dot :)
declare %private function getdot($dot as xs:string,$url) as xs:string{
if($url) then
try{fn:unparsed-text(fn:resolve-uri($url))} catch * { "digraph {{ failed to load remote }}" }
else
$dot
};
(:~ if url is defined then treat as url and fetch else use dotml :)
declare %private function getdotml($dotml as node(),$url) as node(){
if($url) then
try{
fn:doc(fn:resolve-uri($url))
} catch * {
<graph xmlns="http://www.martin-loetzsch.de/DOTML">
<node id="fail"/>
</graph> }
else
$dotml
};
(:~ CORS header with download option :)
declare function headers($attachment){
<restxq:response>
<http:response>
<http:header name="Access-Control-Allow-Origin" value="*"/>
{if($attachment)
then <http:header name="Content-Disposition" value='attachment;filename="{$attachment}"'/>
else ()}
</http:response>
</restxq:response>
};
(:~ Generate svg from dot :)
declare %private function dot2svg($dot as xs:string) as node(){
let $svgx:=gr:dot($dot,())
return gr:autosize($svgx)
};
(:~ css class to highlight current page :)
declare function active-link($path as xs:string,$page as xs:string) as xs:string{
if(fn:ends-with($path,$page)) then "active" else ""
};
(:~
: Render html page
: @param template path to page template
: @params locals map of page variables
:)
declare function render($template as xs:string,$locals){
let $path:=request:path()
let $default:=map{ "title":=request:path(),
"active-link":=active-link($path,?), (: *** FAILS IF request:path() :)
"bodyclass":=""}
let $locals:=map:new(($default,$locals))
return txq:render(fn:resolve-uri($template),$locals,$grxq:layout)
(:~
: RESTXQ interface for graphviz
: @author andy bunce
: @since sept 2012
:)
module namespace grxq = 'apb.graphviz.web';
declare default function namespace 'apb.graphviz.web';
import module namespace gr = 'apb.graphviz' at "graphviz.xqm";
import module namespace dotml = 'http://www.martin-loetzsch.de/DOTML' at "dotml.xqm";
import module namespace dotui = 'apb.graphxq.dotui' at "dotui.xqm";
import module namespace txq = 'quodatum.txq' at "lib/txq.xqm";
import module namespace request = "http://exquery.org/ns/request";
declare namespace svg= "http://www.w3.org/2000/svg";
declare namespace restxq = 'http://exquery.org/ns/restxq';
(:~ shared page wrapper :)
declare variable $grxq:layout:=fn:resolve-uri("views/layout.xq");
(:~
: Home page for app
:)
declare
%restxq:GET %restxq:path("graphxq")
%output:method("html") %output:version("5.0")
function home(){
<restxq:redirect>/graphxq/about</restxq:redirect>
};
(:~
: about page for app
:)
declare
%restxq:GET %restxq:path("graphxq/about")
%output:method("html") %output:version("5.0")
function about(){
render("views/about.xml",map{"title":"GraphXQ"})
};
(:~
: GET or POST return svg for dot, with download option
:)
declare
%restxq:path("graphxq/api/dot")
%restxq:form-param("data","{$dot}")
%restxq:form-param("url","{$url}")
%restxq:form-param("dl","{$dl}")
%restxq:form-param("dotopt","{$dotopt}")
%output:media-type("image/svg+xml")
function graphxq-svg($dot,$url,$dl,$dotopt) {
let $dot2:=getdot($dot,$url)
let $svg:=dot2svg($dot2)
let $fname:=if($dl)then "dot.svg" else ()
return (headers($fname),$svg)
};
(:~
: display dot edit form
: @param src load from url
:)
declare
%restxq:GET %restxq:path("graphxq/dot")
%output:method("html") %output:version("5.0")
%restxq:form-param("src","{$src}")
function dotform($src){
let $dot:= getdot("digraph {a -> b}",$src)
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $map:=map{"list-shapes": dotui:shapes(""),
"list-colors": dotui:colors(""),
"svgwidget": $svgwidget,
"toolbar": $toolbar,
"title": "DOT editor",
"dot": $dot}
return render("views/dotform.xq",$map)
};
declare
%restxq:GET %restxq:path("graphxq/dotml")
%output:method("html") %output:version("5.0")
%restxq:form-param("src","{$src}")
function dotmlform($src){
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $default:=<graph xmlns="http://www.martin-loetzsch.de/DOTML"><node id="test"/></graph>
let $dotml:= getdotml($default ,$src)
let $dotml:= fn:serialize($dotml)
let $v:=map{ "svgwidget": $svgwidget,
"toolbar": $toolbar,
"title": "DOTML editor",
"bodyclass": "h100",
"dotml": $dotml}
return render("views/dotmlform.xq",$v)
};
(:~ static api page :)
declare
%restxq:GET %restxq:path("graphxq/api")
%output:method("html") %output:version("5.0")
function api(){
render("views/api.xml",map{"title": "API information"})
};
(:~ static ace page :)
declare
%restxq:GET %restxq:path("graphxq/ace")
%output:method("html") %output:version("5.0")
function ace(){
let $svgwidget:=fn:doc("views/widget.svg")
let $toolbar:=fn:doc("views/toolbar.xml")
let $v:=map{
"title": "XQuery editor (for no reason) ",
"bodyclass": "h100"
}
return render("views/ace.xml",$v)
};
declare
%restxq:GET %restxq:path("graphxq/library")
%output:method("html") %output:version("5.0")
function library(){
let $lib:=fn:doc("data/library.xml")
let $map:=map{"title": "Samples",
"items": $lib//items,
"url": function($item){fn:concat($item/url/@type,'?src=data/samples/',$item/url)}
}
return render("views/library.xml",$map)
};
(:~
: @return svg from dotml
:)
declare
%restxq:POST %restxq:path("graphxq/api/dotml")
%restxq:form-param("data","{$dotml}")
%restxq:form-param("dl","{$dl}")
function api-dotml($dotml,$dl ) {
let $dotml:=fn:trace($dotml,"dot: ")
let $dotml:=fn:parse-xml($dotml)
let $x:=dotml:generate($dotml)
let $svg:=dot2svg($x)
let $fname:=if($dl)then "dotml.svg" else ()
return (headers($fname),$svg)
};
(:~ if url is defined then treat as url and fetch else use dot :)
declare %private function getdot($dot as xs:string,$url) as xs:string{
if($url) then
try{fn:unparsed-text(fn:resolve-uri($url))} catch * { "digraph {{ failed to load remote }}" }
else
$dot
};
(:~ if url is defined then treat as url and fetch else use dotml :)
declare %private function getdotml($dotml as node(),$url) as node(){
if($url) then
try{
fn:doc(fn:resolve-uri($url))
} catch * {
<graph xmlns="http://www.martin-loetzsch.de/DOTML">
<node id="fail"/>
</graph> }
else
$dotml
};
(:~ CORS header with download option :)
declare function headers($attachment){
<restxq:response>
<http:response>
<http:header name="Access-Control-Allow-Origin" value="*"/>
{if($attachment)
then <http:header name="Content-Disposition" value='attachment;filename="{$attachment}"'/>
else ()}
</http:response>
</restxq:response>
};
(:~ Generate svg from dot :)
declare %private function dot2svg($dot as xs:string) as node(){
let $svgx:=gr:dot($dot,())
return gr:autosize($svgx)
};
(:~ css class to highlight current page :)
declare function active-link($path as xs:string,$page as xs:string) as xs:string{
if(fn:ends-with($path,$page)) then "active" else ""
};
(:~
: Render html page
: @param template path to page template
: @params locals map of page variables
:)
declare function render($template as xs:string,$locals){
let $path:=request:path()
let $default:=map{ "title": request:path(),
"active-link": active-link($path,?), (: *** FAILS IF request:path() :)
"bodyclass": ""}
let $locals:=map:merge(($default,$locals))
return txq:render(fn:resolve-uri($template),$locals,$grxq:layout)
};

View File

@ -1,45 +1,46 @@
(:~
: A(nother) templating Engine for XQuery (BaseX 7.5 specific)
: specials:
: partial(file,name,sequence)
:
: @author andy bunce
: @since sept 2012
:)
module namespace txq = 'apb.txq';
declare default function namespace 'apb.txq';
import module namespace xquery = "http://basex.org/modules/xquery";
(:~
: template function
: @param template url to fill
: @param map name and value to apply
: @return updated doc from map
:)
declare function render($template as xs:string,$map as map(*)){
let $map:=map:new(($map,map{"partial":=partial(?,?,?,$map,$template)}))
return xquery:invoke($template,$map)
};
(:~
: template function with wrapping layout
: @param layout
: @return updated doc from map
:)
declare function render($template as xs:string,$map as map(*),$layout as xs:string){
let $content:=render($template,$map)
let $map:=map:new(($map,map{"body":=$content}))
return render($layout,$map)
};
(:~
: partial template function: evaluate part for each value in sequence
: @return updated doc from map
:)
declare function partial($part as xs:string,$name,$seq,$map,$base){
for $s in $seq
let $map:=map:new(($map,map{$name:=$s}))
return render(fn:resolve-uri($part,$base),$map)
};
xquery version "3.0";
(:~
: A(nother) templating Engine for XQuery (BaseX specific)
: specials:
: partial(file,name,sequence)
:
: @author andy bunce
: @since sept 2012
: @licence apache 2
:)
module namespace txq = 'quodatum.txq';
declare default function namespace 'quodatum.txq';
import module namespace xquery = "http://basex.org/modules/xquery";
(:~
: template function
: @param template url to fill
: @param map name and value to apply
: @return updated doc from map
:)
declare function render($template as xs:string,$map as map(*)){
let $map:=map:merge(($map,map{"partial": partial(?,?,?,$map,$template)}))
return xquery:invoke($template,$map)
};
(:~
: template function with wrapping layout
: @param $layout outer template with $body placeholder to insert $template
: @return updated doc from map
:)
declare function render($template as xs:string,$map as map(*),$layout as xs:string){
let $content:=render($template,$map)
let $map:=map:merge(($map,map{"body": $content}))
return render($layout,$map)
};
(:~
: partial template function: evaluate part for each value in sequence
: @return updated doc from map
:)
declare function partial($part as xs:string,$name,$seq,$map,$base){
for $s in $seq
let $map:=map:merge(($map,map{$name: $s}))
return render(fn:resolve-uri($part,$base),$map)
};

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -55,7 +55,7 @@ for a better way?
<img style="position: absolute; top: 50px; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png" alt="Fork me on GitHub"/>
</a>
<footer>
<p>&#169; Andy Bunce 2013</p>
<p>&#169; Andy Bunce 2013 -2015</p>
<ul class="quick-links">
<!--
<li><iframe class="github-btn"

View File

@ -1,34 +1,37 @@
<div class="row-fluid">
<div class="row-fluid" style="height:24px">
{$toolbar}
</div>
<div class="row-fluid">
<div class="span6 " id="leftPane">
<div id="dsrc" class="extend ace-container" >
<div id="acedata" class="ace " data-mode="dot" ></div>
</div>
<form id="editForm" action="api/dot" method="post" target="_new" style="display:none"
>
<textarea id="data" name="data" rows="100"
style="width:100%;overflow:scroll;height:98%">{$dot}</textarea>
<input name="dl" type="checkbox" style="display:none"/>
<input name="dotopt" type="text" value="a" style="display:none"/>
<input name="dotopt" type="text" value="bb" style="display:none"/>
</form>
<textarea id="cleartext" style="display: none">digraph title {{ bgcolor=seashell
node[shape=circle,style=filled,fillcolor=lightblue]
}}</textarea>
</div>
<div class="span6" id="rightPane">
<div id="svgdiv" class="extend"
style="width:100%;height:30em;border: 1px solid #E3E3E3;min-height:10em;">{$svgwidget}</div>
<div id="svgsrc" class="extend ace-container" style="display: none">
<div id="svgsrc2" class="ace " data-mode="svg" data-readonly="1">(no svg loaded)</div>
</div>
</div>
</div>
declare variable $toolbar external :="{tooolbar}";
declare variable $dot external :="{dot}";
declare variable $svgwidget external :="{svg}";
<div class="row-fluid">
<div class="row-fluid" style="height:24px">
{$toolbar}
</div>
<div class="row-fluid">
<div class="span6 " id="leftPane">
<div id="dsrc" class="extend ace-container" >
<div id="acedata" class="ace " data-mode="dot" ></div>
</div>
<form id="editForm" action="api/dot" method="post" target="_new" style="display:none"
>
<textarea id="data" name="data" rows="100"
style="width:100%;overflow:scroll;height:98%">{$dot}</textarea>
<input name="dl" type="checkbox" style="display:none"/>
<input name="dotopt" type="text" value="a" style="display:none"/>
<input name="dotopt" type="text" value="bb" style="display:none"/>
</form>
<textarea id="cleartext" style="display: none">digraph title {{ bgcolor=seashell
node[shape=circle,style=filled,fillcolor=lightblue]
}}</textarea>
</div>
<div class="span6" id="rightPane">
<div id="svgdiv" class="extend"
style="width:100%;height:30em;border: 1px solid #E3E3E3;min-height:10em;">{$svgwidget}</div>
<div id="svgsrc" class="extend ace-container" style="display: none">
<div id="svgsrc2" class="ace " data-mode="svg" data-readonly="1">(no svg loaded)</div>
</div>
</div>
</div>
</div>

View File

@ -1,29 +1,33 @@
<div class="row-fluid">
<div class="row-fluid" style="height:24px">
{$toolbar}
</div>
<div class="row-fluid">
<div class="span6" id="leftPane" style="position:relative;height:100%">
<div id="dsrc" class="extend ace-container" >
<div id="acedata" class="ace " data-mode="xml" ></div>
</div>
<form id="editForm" method="post" action="api/dotml" target="_new" style="display:none"
>
<textarea id="data" name="data" rows="20"
style="width:100%;overflow:scroll;height:98%">{$dotml}</textarea>
<input name="dl" type="checkbox" style="display:none" />
</form>
<textarea id="cleartext" style="display: none">&lt;graph xmlns="http://www.martin-loetzsch.de/DOTML"&gt;
&lt;node id="test"/&gt;
&lt;/graph&gt;</textarea>
</div>
<div class="span6" id="rightPane">
<div id="svgdiv" class="extend"
style="width:100%;height:30em;border: 1px solid #E3E3E3;min-height:10em;">{$svgwidget}</div>
<div id="svgsrc" class="extend ace-container" style="display: none">
<div id="svgsrc2" class="ace "
data-mode="svg" data-readonly="1">(no svg loaded)</div>
</div>
</div>
</div>
declare variable $toolbar external :="{tooolbar}";
declare variable $dotml external :="{dotml}";
declare variable $svgwidget external :="{svg}";
<div class="row-fluid">
<div class="row-fluid" style="height:24px">
{$toolbar}
</div>
<div class="row-fluid">
<div class="span6" id="leftPane" style="position:relative;height:100%">
<div id="dsrc" class="extend ace-container" >
<div id="acedata" class="ace " data-mode="xml" ></div>
</div>
<form id="editForm" method="post" action="api/dotml" target="_new" style="display:none"
>
<textarea id="data" name="data" rows="20"
style="width:100%;overflow:scroll;height:98%">{$dotml}</textarea>
<input name="dl" type="checkbox" style="display:none" />
</form>
<textarea id="cleartext" style="display: none">&lt;graph xmlns="http://www.martin-loetzsch.de/DOTML"&gt;
&lt;node id="test"/&gt;
&lt;/graph&gt;</textarea>
</div>
<div class="span6" id="rightPane">
<div id="svgdiv" class="extend"
style="width:100%;height:30em;border: 1px solid #E3E3E3;min-height:10em;">{$svgwidget}</div>
<div id="svgsrc" class="extend ace-container" style="display: none">
<div id="svgsrc2" class="ace "
data-mode="svg" data-readonly="1">(no svg loaded)</div>
</div>
</div>
</div>
</div>

View File

@ -1,3 +1,8 @@
declare variable $body external :="{body}";
declare variable $title external :="{title}";
declare variable $bodyclass external :="{$bodyclass}";
declare variable $active-link external :=function($_){$_};
<html >
<head id="head">
<meta charset="utf-8" />
@ -14,13 +19,13 @@
rel="stylesheet" type="text/css" />
<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="/graphxq/graphxq2.png" />
<link rel="shortcut icon" href="/static/graphxq/graphxq2.png" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.2.2/bootstrap.min.js" type="text/javascript"></script>
<script src="http://raw.github.com/ajaxorg/ace-builds/master/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<link href="/graphxq/app.css" rel="stylesheet" type="text/css" />
<script src="/graphxq/app.js" type="text/javascript"></script>
<link href="/static/graphxq/app.css" rel="stylesheet" type="text/css" />
<script src="/static/graphxq/app.js" type="text/javascript"></script>
<script type="text/javascript"><![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34544921-1']);
@ -44,7 +49,7 @@
<span class="icon-bar"></span>
</a>
<a href="about" class="brand" title="Version 0.4.0">
<img src="/graphxq/graphxq2.png" />
<img src="/static/graphxq/graphxq2.png" />
graphXQ
</a>

View File

@ -1,64 +1,64 @@
<div>
<div class="btn-group">
<button id="bnRefresh" class="btn btn-mini"
title="Resend SVG request" >
<i class="icon-refresh"></i>
Redraw
</button>
</div>
<div class="btn-group">
<a id="bnOpts" class="btn btn-mini"
href="/graphxq/views/options.xml" data-target="#myModal" data-toggle="modal"
title="Extra settings (not implemented yet)" >
<i class="icon-gift"></i>
Options
</a>
</div>
<div class="btn-group">
<button id="bnclear" class="btn btn-mini"
title="Set editor to default empty content" >
<i class="icon-remove"></i>
Clear
</button>
</div>
<!-- http://stackoverflow.com/questions/12101781/splitter-for-twitter-bootstrap -->
<div class="btn-group " data-toggle="buttons-radio">
<a rel="tooltip" title="Show only the editor" class="btn btn-mini"
data-action="lDom" data-placement="left">
<i class="icon icon-indent-left"></i>
</a>
<a rel="tooltip" title="Make both sides equal" class="btn btn-mini"
data-placement="left" data-action="equality">
<i class="icon icon-resize-horizontal"></i>
</a>
<a rel="tooltip" title="Show only the result" class="btn btn-mini"
data-placement="left" data-action="rDom">
<i class="icon icon-indent-right"></i>
</a>
</div>
<a id="infotip" data-original-title="Status from Ajax"
class="btn btn-mini" rel="popover" data-placement="bottom" data-content="nothing yet."
title="Ajax request status">
<i class="icon-info-sign" title="Request status, click for more.">></i>
</a>
<div class="btn-group pull-right">
<button id="bnsvg" class="btn btn-mini" title="Show SVG standalone.">
<i class="icon-fullscreen"></i>
SVG
</button>
<button id="bndn" class="btn btn-mini" title="Download SVG file">
<i class="icon-download-alt"></i>
download
</button>
</div>
<div class="btn-group pull-right">
<button id="bnxml" class="btn btn-mini" data-toggle="button" title="Toggle SVG graphic and text">
<i class="icon-eye-close"></i>
SVG text
</button>
</div>
<div>
<div class="btn-group">
<button id="bnRefresh" class="btn btn-mini"
title="Resend SVG request" >
<i class="icon-refresh"></i>
Redraw
</button>
</div>
<div class="btn-group">
<a id="bnOpts" class="btn btn-mini"
href="/graphxq/views/options.xml" data-target="#myModal" data-toggle="modal"
title="Extra settings (not implemented yet)" >
<i class="icon-gift"></i>
Options
</a>
</div>
<div class="btn-group">
<button id="bnclear" class="btn btn-mini"
title="Set editor to default empty content" >
<i class="icon-remove"></i>
Clear
</button>
</div>
<!-- http://stackoverflow.com/questions/12101781/splitter-for-twitter-bootstrap -->
<div class="btn-group " data-toggle="buttons-radio">
<a rel="tooltip" title="Show only the editor" class="btn btn-mini"
data-action="lDom" data-placement="left">
<i class="icon icon-indent-left"></i>
</a>
<a rel="tooltip" title="Make both sides equal" class="btn btn-mini"
data-placement="left" data-action="equality">
<i class="icon icon-resize-horizontal"></i>
</a>
<a rel="tooltip" title="Show only the result" class="btn btn-mini"
data-placement="left" data-action="rDom">
<i class="icon icon-indent-right"></i>
</a>
</div>
<a id="infotip" data-original-title="Status from Ajax"
class="btn btn-mini" rel="popover" data-placement="bottom" data-content="nothing yet."
title="Ajax request status">
<i class="icon-info-sign" title="Request status, click for more.">></i>
</a>
<div class="btn-group pull-right">
<button id="bnsvg" class="btn btn-mini" title="Show SVG standalone.">
<i class="icon-fullscreen"></i>
SVG
</button>
<button id="bndn" class="btn btn-mini" title="Download SVG file">
<i class="icon-download-alt"></i>
download
</button>
</div>
<div class="btn-group pull-right">
<button id="bnxml" class="btn btn-mini" data-toggle="button" title="Toggle SVG graphic and text">
<i class="icon-eye-close"></i>
SVG text
</button>
</div>
</div>

View File

Before

Width:  |  Height:  |  Size: 880 B

After

Width:  |  Height:  |  Size: 880 B

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 880 B

After

Width:  |  Height:  |  Size: 880 B

View File

Before

Width:  |  Height:  |  Size: 880 B

After

Width:  |  Height:  |  Size: 880 B