This commit is contained in:
Andy Bunce 2018-10-10 22:57:42 +01:00
parent ba2b8834f8
commit 526c528f06
18 changed files with 175 additions and 61 deletions

View file

@ -63,8 +63,8 @@ var settings = {
enableBasicAutocompletion:true, enableBasicAutocompletion:true,
enableLiveAutocompletion:true enableLiveAutocompletion:true
}, },
"settings/dark": false,
"features/serviceworker": true, "features/serviceworker": false,
"edit/items":[ "edit/items":[
{name:"web.txt", id:"1", mode:"text", dirty: false, {name:"web.txt", id:"1", mode:"text", dirty: false,
text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit, text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@ -82,7 +82,6 @@ return $a `},
</foo>`} </foo>`}
], ],
"edit/currentId": "?", "edit/currentId": "?",
"system/serviceworker": true,
"images/thumbtask":` "images/thumbtask":`
<thumbnail> <thumbnail>
<size width="100" height="100"/> <size width="100" height="100"/>

View file

@ -40,7 +40,9 @@
<v-expansion-panel v-model="panel" expand > <v-expansion-panel v-model="panel" expand >
<v-expansion-panel-content> <v-expansion-panel-content>
<div slot="header" class="title">Code</div> <div slot="header" class="title">Type: <code>{{ item.type }}</code></div>
<prism language="xquery">{{ item.modules }}</prism>
<prism language="xquery">{{ item.namespaces }}</prism>
<prism language="xquery">{{ item.code }}</prism> <prism language="xquery">{{ item.code }}</prism>
</v-expansion-panel-content> </v-expansion-panel-content>
@ -81,7 +83,7 @@
{text: "description", value: "description"}, {text: "description", value: "description"},
{text: "xpath", value: "xpath"} {text: "xpath", value: "xpath"}
], ],
panel: [true,true] panel: [false, true]
} }
}, },
methods:{ methods:{

View file

@ -76,7 +76,7 @@ let $this:=$entity:list("entity")
let $fields:=$this?json let $fields:=$this?json
let $item:=$items[@name=$entity] let $item:=$items[@name=$entity]
(: just one :) (: just one :)
return <json objects="json">{dice:json-flds($item,$fields)/*}</json> return $item
}; };

View file

@ -3,7 +3,7 @@
<v-container fluid> <v-container fluid>
<p>Settings are currently only stored locally in the browser, using <code>localstorage</code></p> <p>Settings are currently only stored locally in the browser, using <code>localstorage</code></p>
<v-switch label="Dark theme" v-model="dark" @change="theme"></v-switch> <v-switch label="Dark theme" v-model="dark" @change="theme"></v-switch>
<v-switch label="Use service worker" v-model="serviceworker" ></v-switch> <v-switch label="Use service worker" v-model="serviceworker" @change="worker"></v-switch>
<v-card> <v-card>
<v-card-title class="lime darken-1">Available settings</v-card-title> <v-card-title class="lime darken-1">Available settings</v-card-title>
@ -27,21 +27,45 @@
keys: ["?"], keys: ["?"],
showDev: false, showDev: false,
dark:false, dark:false,
serviceworker:true serviceworker: true
} }
}, },
methods:{ methods:{
theme(){ theme(){
settings.setItem('settings/dark',this.dark)
.then(v=>{
this.$root.$emit("theme",this.dark) this.$root.$emit("theme",this.dark)
})
},
worker(){
settings.setItem('features/serviceworker',this.serviceworker)
.then(v=>{
console.log("worker",this.serviceworker)
})
} }
}, },
created(){ created(){
console.log("settings") console.log("settings")
settings.keys() settings.keys()
.then( v =>{ .then( v =>{
this.keys=v this.keys=v
}) })
},
beforeRouteEnter (to, from, next) {
Promise.all([
settings.getItem('features/serviceworker'),
settings.getItem('settings/dark')
])
.then( v =>{
next(vm => {
console.log("got ",v)
vm.serviceworker = v[0];
vm.dark = v[1];
})
})
} }
} }

View file

@ -34,5 +34,5 @@ declare
function vue-api:settings() function vue-api:settings()
{ {
let $xq:=resolve-uri($vue-api:query) let $xq:=resolve-uri($vue-api:query)
return query-a:fields($xq) return query-a:inspect($xq)
}; };

View file

@ -36,7 +36,7 @@ function vue-rest:task($task)
{ {
let $taskdef:=doc("taskdef.xml")/tasks/task[@name=$task] let $taskdef:=doc("taskdef.xml")/tasks/task[@name=$task]
let $url:=resolve-uri($taskdef/@url) let $url:=resolve-uri($taskdef/@url)
let $info:=query-a:fields($url) let $info:=query-a:inspect($url)
return $info return $info
}; };

View file

@ -23,6 +23,10 @@
Run</v-btn> Run</v-btn>
</v-toolbar> </v-toolbar>
<v-card-text v-if="id">
{{ id }}
</v-card-text>
<v-card-text> <v-card-text>
<v-container fluid> <v-container fluid>
<v-layout row wrap> <v-layout row wrap>
@ -30,8 +34,6 @@
<vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform> <vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform>
</v-flex> </v-flex>
</v-layout> </v-layout>
</v-container> </v-container>
</v-card-text> </v-card-text>
<v-snackbar v-model="snackbar.show" <v-snackbar v-model="snackbar.show"
@ -76,6 +78,22 @@
console.log(error); console.log(error);
}); });
} }
},
watch:{
id(v){
this.$router.push({ query: { id: this.id }})
},
$route(vnew,vold){
console.log("ROUTE",vnew,vold)
var id=this.$route.query.id
this.id=id?id:null;
if(vnew.query.url != vold.query.url) alert("gg")
}
},
created:function(){
this.id=this.$route.query.id
} }
} }
</script> </script>

View file

@ -12,9 +12,11 @@ declare variable $name as xs:string external :="myapp";
(:~ (:~
: new app : generate new app code with given name
:) :)
declare function local:new($name as xs:string){ declare function local:new($name as xs:string)
as xs:base64Binary
{
let $archive:=file:read-binary(fn:resolve-uri('./data/vuetif.zip')) let $archive:=file:read-binary(fn:resolve-uri('./data/vuetif.zip'))
let $contents := archive:extract-binary($archive) let $contents := archive:extract-binary($archive)
let $entries:= archive:entries($archive) let $entries:= archive:entries($archive)

View file

@ -38,5 +38,5 @@ declare
function vue-api:settings() function vue-api:settings()
{ {
let $xq:=resolve-uri($vue-api:query) let $xq:=resolve-uri($vue-api:query)
return query-a:fields($xq) return query-a:inspect($xq)
}; };

View file

@ -9,7 +9,8 @@ declare namespace c="http://www.w3.org/ns/xproc-step";
(:~ URL of the root folder to document (:~ URL of the root folder to document
: @default C:/Users/andy/git/vue-poc/src/vue-poc : @default C:/Users/andy/git/vue-poc/src/vue-poc
:) :)
declare variable $efolder as xs:anyURI external :="C:/Users/andy/git/vue-poc/src/vue-poc"; declare variable $efolder as xs:anyURI external :=
"C:/Users/andy/git/vue-poc/src/vue-poc";
(:~ URL of the schema to use (:~ URL of the schema to use
: @default C:/tmp/xqdoc/ : @default C:/tmp/xqdoc/

View file

@ -2,27 +2,36 @@
: XQDoc: generate restxq.html from resources located at $target : XQDoc: generate restxq.html from resources located at $target
:) :)
import module namespace xqd = 'quodatum:build.xqdoc' at "../../../lib/xqdoc/xqdoc-proj.xqm"; import module namespace xqd = 'quodatum:build.xqdoc' at "../../../lib/xqdoc/xqdoc-proj.xqm";
import module namespace store = 'quodatum.store' at "../../../lib/store.xqm";
declare namespace c="http://www.w3.org/ns/xproc-step"; declare namespace c="http://www.w3.org/ns/xproc-step";
declare namespace xqdoc="http://www.xqdoc.org/1.0"; declare namespace xqdoc="http://www.xqdoc.org/1.0";
(:~ URL of the doc source (:~ URL of the doc source
: @default C:/tmp/xqdoc/ : @default file:///C:/tmp/xqdoc/
:) :)
declare variable $target as xs:anyURI external := declare variable $target as xs:anyURI external :=
"C:/tmp/xqdoc/" cast as xs:anyURI; "file:///C:/tmp/xqdoc/" cast as xs:anyURI;
declare variable $nsRESTXQ:='http://exquery.org/ns/restxq';
declare variable $files :=doc(resolve-uri("files.xml",$target)); declare variable $files :=doc(resolve-uri("files.xml",$target));
declare function local:foo($a,$k){ declare function local:xqdoc-url($key as item())
if($a) then map{"k":$k,"d":$a} else () as xs:anyURI
{
resolve-uri(``[F`{ string($key) }`/xqdoc.xml]``,$target)
};
declare function local:item($doc as item()*,$key as item())
as map(*)?
{
if($doc) then map{"key":$key,"value":$doc} else ()
}; };
let $base:=$files/*/@xml:base/string() let $base:=$files/*/@xml:base/string()
let $files:= $files//c:file let $files:= $files//c:file
let $names:= $files!string-join(ancestor-or-self::*/@name,"/") let $names:= $files!string-join(ancestor-or-self::*/@name,"/")
let $xqdocs:=$files!doc(resolve-uri(``[F`{ position() }`/xqdoc.xml]``,$target)) let $xqdocs:=$files!doc(local:xqdoc-url(position()))
let $paths:= $xqdocs!local:foo(xqd:rxq(*),position()) let $paths:= $xqdocs!local:item(xqd:annotations(*, $nsRESTXQ,"path"),position())
let $items:= let $items:=
for $annots in $paths for $annots in $paths
let $uri:=$annots?d/string() let $uri:=$annots?d/string()
@ -32,15 +41,15 @@ for $annots in $paths
<h3>{ $uri }</h3> <h3>{ $uri }</h3>
<ol>{ <ol>{
for $annot in $annots for $annot in $annots
let $fun:=$annot?d/../.. let $fun:=$annot?doc/../..
let $funname:=concat($fun/xqdoc:name/string(),'#',$fun/@arity/string()) let $funname:=concat($fun/xqdoc:name/string(),'#',$fun/@arity/string())
let $href:="F12/index.html#field-list" let $href:="F12/index.html#field-list"
return <li><a href="{$href}">{$funname}</a>{$annot?k}</li> return <li><a href="{$href}">{$funname}</a>{$annot?key}</li>
}</ol> }</ol>
<a>{ $uri }</a> <a>{ $uri }</a>
</li> </li>
return <div> let $op:= <div>
<nav id="toc"> <nav id="toc">
<div> <div>
<a href="index.html"> <a href="index.html">
@ -66,4 +75,14 @@ return <div>
<ul>{ $items }</ul> <ul>{ $items }</ul>
</div> </div>
=>xqd:page(map{"resources":"resources/"}) =>xqd:page(map{"resources":"resources/"})
=>xqd:store(resolve-uri("restxq.html",$target),$xqd:HTML5) =>xqd:store2(resolve-uri("restxq.html",$target),$xqd:HTML5)
let $result:=<json type="object">
<extra>hello</extra>
<msg> {$target}, {count($files//c:file)} files processed.</msg>
<id>none</id>
</json>
return (
store:store($op,$target),update:output($result)
)

View file

@ -33,6 +33,6 @@ declare
function tx:parameters( ) function tx:parameters( )
{ {
let $xq:=resolve-uri("tx-validate.xq") let $xq:=resolve-uri("tx-validate.xq")
return query-a:fields($xq) return query-a:inspect($xq)
}; };

View file

@ -6,12 +6,13 @@
module namespace query-a = 'vue-poc/query-a'; module namespace query-a = 'vue-poc/query-a';
import module namespace request = "http://exquery.org/ns/request"; import module namespace request = "http://exquery.org/ns/request";
declare namespace map2='http://www.woerteler.de/xquery/modules/map-extras';
(:~ (:~
: attributes of a stored query including parameters and updating status. : attributes of a stored query including parameters and updating status.
: @return json format : @return json format
:) :)
declare function query-a:fields($mod as xs:anyURI) declare function query-a:inspect($mod as xs:anyURI)
as element(json) as element(json)
{ {
let $updating:=xquery:parse-uri($mod)/@updating/string() let $updating:=xquery:parse-uri($mod)/@updating/string()

View file

@ -10,7 +10,8 @@ module namespace store = 'quodatum.store';
declare %updating declare %updating
function store:store($docs as map(*)*,$base as xs:string) function store:store($docs as map(*)*,$base as xs:string)
{ {
$docs!store:store1(.,$base) let $base:=if(contains($base,"\"))then file:path-to-uri($base) else $base
return $docs!store:store1(.,$base)
}; };
declare %updating declare %updating
@ -21,7 +22,7 @@ function store:store1($doc as map(*),$base as xs:string)
return switch (substring-before($uri,":")) return switch (substring-before($uri,":"))
case "file" return store:file($doc?document,$uri,$opts) case "file" return store:file($doc?document,$uri,$opts)
case "xmldb" return store:xmldb($doc?document,$uri,$opts) case "xmldb" return store:xmldb($doc?document,$uri,$opts)
default return error("unknown protocol") default return error("unknown protocol:" || $uri)
}; };
(:~ (:~

View file

@ -119,7 +119,9 @@ return file:write-text($DEST,string-join(($comment,
(:~ (:~
: return sequence of file paths starting from $path matching $filter : return sequence of file paths starting from $path matching $filter
:) :)
declare function vue:filelist($path as xs:string,$filter as xs:string){ declare function vue:filelist($path as xs:string,$filter as xs:string)
as xs:string*
{
fw:directory-list($path,map{"include-filter": $filter}) fw:directory-list($path,map{"include-filter": $filter})
//c:file/@name/resolve-uri(.,base-uri(.)) //c:file/@name/resolve-uri(.,base-uri(.))
}; };

View file

@ -82,7 +82,7 @@ declare function xqd:gendoc2(
$target as xs:string, $target as xs:string,
$params as map(*) $params as map(*)
) )
{ as map(*)* {
let $ip:= $f/@name/resolve-uri(.,base-uri(.)) let $ip:= $f/@name/resolve-uri(.,base-uri(.))
let $xqdoc:= xqd:xqdoc($ip,map{}) let $xqdoc:= xqd:xqdoc($ip,map{})
let $xq:= fetch:text($ip) let $xq:= fetch:text($ip)
@ -112,7 +112,7 @@ declare function xqd:store($data,$url as xs:string,$params as map(*))
}; };
(:~ (:~
:save $data to $url , create fdolder if missing) : return intent to save $data to $url with serialization $params
:) :)
declare function xqd:store2($data,$url as xs:string,$params as map(*)) declare function xqd:store2($data,$url as xs:string,$params as map(*))
{ {
@ -159,13 +159,15 @@ declare function xqd:export-resources($target as xs:string)
archive:extract-to($target, file:read-binary(resolve-uri('resources.zip'))) archive:extract-to($target, file:read-binary(resolve-uri('resources.zip')))
}; };
(:~ (:~
: return all rest:path annotations : return all matching annotations in xqdoc
:) :)
declare function xqd:rxq($xqdoc as element(xqdoc:xqdoc)) declare function xqd:annotations($xqdoc as element(xqdoc:xqdoc),
$annotns as xs:string,
$aname as xs:string)
as element(xqdoc:annotation)* as element(xqdoc:annotation)*
{ {
let $restxq:=$xqdoc//xqdoc:namespace[@uri='http://exquery.org/ns/restxq']/@prefix/string() let $prefixes:=$xqdoc//xqdoc:namespace[@uri=$annotns]/@prefix/string()
return $xqdoc//xqdoc:annotations/xqdoc:annotation[@name=(for $p in $restxq return concat($p,':path'))] return $xqdoc//xqdoc:annotations/xqdoc:annotation[@name=(for $p in $prefixes return concat($p,':',$aname))]
}; };

View file

@ -1,4 +1,4 @@
// generated 2018-10-07T12:59:06.336+01:00 // generated 2018-10-10T22:55:09.766+01:00
// src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/components/qd-autoheight.vue // src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/components/qd-autoheight.vue
Vue.component('qd-autoheight',{template:` Vue.component('qd-autoheight',{template:`
@ -4468,7 +4468,9 @@ const Entity1=Vue.extend({template:`
<v-expansion-panel v-model="panel" expand=""> <v-expansion-panel v-model="panel" expand="">
<v-expansion-panel-content> <v-expansion-panel-content>
<div slot="header" class="title">Code</div> <div slot="header" class="title">Type: <code>{{ item.type }}</code></div>
<prism language="xquery">{{ item.modules }}</prism>
<prism language="xquery">{{ item.namespaces }}</prism>
<prism language="xquery">{{ item.code }}</prism> <prism language="xquery">{{ item.code }}</prism>
</v-expansion-panel-content> </v-expansion-panel-content>
@ -4508,7 +4510,7 @@ const Entity1=Vue.extend({template:`
{text: "description", value: "description"}, {text: "description", value: "description"},
{text: "xpath", value: "xpath"} {text: "xpath", value: "xpath"}
], ],
panel: [true,true] panel: [false, true]
} }
}, },
methods:{ methods:{
@ -5466,7 +5468,7 @@ const Settings=Vue.extend({template:`
<v-container fluid=""> <v-container fluid="">
<p>Settings are currently only stored locally in the browser, using <code>localstorage</code></p> <p>Settings are currently only stored locally in the browser, using <code>localstorage</code></p>
<v-switch label="Dark theme" v-model="dark" @change="theme"></v-switch> <v-switch label="Dark theme" v-model="dark" @change="theme"></v-switch>
<v-switch label="Use service worker" v-model="serviceworker"></v-switch> <v-switch label="Use service worker" v-model="serviceworker" @change="worker"></v-switch>
<v-card> <v-card>
<v-card-title class="lime darken-1">Available settings</v-card-title> <v-card-title class="lime darken-1">Available settings</v-card-title>
@ -5489,21 +5491,45 @@ const Settings=Vue.extend({template:`
keys: ["?"], keys: ["?"],
showDev: false, showDev: false,
dark:false, dark:false,
serviceworker:true serviceworker: true
} }
}, },
methods:{ methods:{
theme(){ theme(){
settings.setItem('settings/dark',this.dark)
.then(v=>{
this.$root.$emit("theme",this.dark) this.$root.$emit("theme",this.dark)
})
},
worker(){
settings.setItem('features/serviceworker',this.serviceworker)
.then(v=>{
console.log("worker",this.serviceworker)
})
} }
}, },
created(){ created(){
console.log("settings") console.log("settings")
settings.keys() settings.keys()
.then( v =>{ .then( v =>{
this.keys=v this.keys=v
}) })
},
beforeRouteEnter (to, from, next) {
Promise.all([
settings.getItem('features/serviceworker'),
settings.getItem('settings/dark')
])
.then( v =>{
next(vm => {
console.log("got ",v)
vm.serviceworker = v[0];
vm.dark = v[1];
})
})
} }
} }
@ -5615,6 +5641,10 @@ const Runtask=Vue.extend({template:`
Run</v-btn> Run</v-btn>
</v-toolbar> </v-toolbar>
<v-card-text v-if="id">
{{ id }}
</v-card-text>
<v-card-text> <v-card-text>
<v-container fluid=""> <v-container fluid="">
<v-layout row="" wrap=""> <v-layout row="" wrap="">
@ -5622,8 +5652,6 @@ const Runtask=Vue.extend({template:`
<vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform> <vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform>
</v-flex> </v-flex>
</v-layout> </v-layout>
</v-container> </v-container>
</v-card-text> </v-card-text>
<v-snackbar v-model="snackbar.show" :timeout="6000" :success="snackbar.context === 'success'" :error="snackbar.context === 'error'"> <v-snackbar v-model="snackbar.show" :timeout="6000" :success="snackbar.context === 'success'" :error="snackbar.context === 'error'">
@ -5663,6 +5691,22 @@ const Runtask=Vue.extend({template:`
console.log(error); console.log(error);
}); });
} }
},
watch:{
id(v){
this.$router.push({ query: { id: this.id }})
},
$route(vnew,vold){
console.log("ROUTE",vnew,vold)
var id=this.$route.query.id
this.id=id?id:null;
if(vnew.query.url != vold.query.url) alert("gg")
}
},
created:function(){
this.id=this.$route.query.id
} }
} }
@ -6867,8 +6911,8 @@ var settings = {
enableBasicAutocompletion:true, enableBasicAutocompletion:true,
enableLiveAutocompletion:true enableLiveAutocompletion:true
}, },
"settings/dark": false,
"features/serviceworker": true, "features/serviceworker": false,
"edit/items":[ "edit/items":[
{name:"web.txt", id:"1", mode:"text", dirty: false, {name:"web.txt", id:"1", mode:"text", dirty: false,
text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit, text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@ -6886,7 +6930,6 @@ return $a `},
</foo>`} </foo>`}
], ],
"edit/currentId": "?", "edit/currentId": "?",
"system/serviceworker": true,
"images/thumbtask":` "images/thumbtask":`
<thumbnail> <thumbnail>
<size width="100" height="100"/> <size width="100" height="100"/>

View file

@ -22,7 +22,7 @@
<body> <body>
<div id="app"> <div id="app">
<h3><code>vue-poc</code> <small>(v0.3.8)</small> </h3> <h3><code>vue-poc</code> <small>(v0.3.9)</small> </h3>
<div class="spinner"> <div class="spinner">
<div class="rect1"></div> <div class="rect1"></div>