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

View File

@ -40,7 +40,9 @@
<v-expansion-panel v-model="panel" expand >
<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>
</v-expansion-panel-content>
@ -81,7 +83,7 @@
{text: "description", value: "description"},
{text: "xpath", value: "xpath"}
],
panel: [true,true]
panel: [false, true]
}
},
methods:{

View File

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

View File

@ -3,7 +3,7 @@
<v-container fluid>
<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="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-title class="lime darken-1">Available settings</v-card-title>
@ -27,22 +27,46 @@
keys: ["?"],
showDev: false,
dark:false,
serviceworker:true
serviceworker: true
}
},
methods:{
theme(){
this.$root.$emit("theme",this.dark)
settings.setItem('settings/dark',this.dark)
.then(v=>{
this.$root.$emit("theme",this.dark)
})
},
worker(){
settings.setItem('features/serviceworker',this.serviceworker)
.then(v=>{
console.log("worker",this.serviceworker)
})
}
},
created(){
console.log("settings")
settings.keys()
.then( 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];
})
})
}
}
</script>

View File

@ -34,5 +34,5 @@ declare
function vue-api:settings()
{
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 $url:=resolve-uri($taskdef/@url)
let $info:=query-a:fields($url)
let $info:=query-a:inspect($url)
return $info
};

View File

@ -22,7 +22,11 @@
<v-icon>play_circle_outline</v-icon>
Run</v-btn>
</v-toolbar>
<v-card-text v-if="id">
{{ id }}
</v-card-text>
<v-card-text>
<v-container fluid>
<v-layout row wrap>
@ -30,8 +34,6 @@
<vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform>
</v-flex>
</v-layout>
</v-container>
</v-card-text>
<v-snackbar v-model="snackbar.show"
@ -76,6 +78,22 @@
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>

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 $contents := archive:extract-binary($archive)
let $entries:= archive:entries($archive)

View File

@ -38,5 +38,5 @@ declare
function vue-api:settings()
{
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
: @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
: @default C:/tmp/xqdoc/

View File

@ -1,28 +1,37 @@
(:~
: 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 xqdoc="http://www.xqdoc.org/1.0";
(:~ URL of the doc source
: @default C:/tmp/xqdoc/
: @default file:///C:/tmp/xqdoc/
:)
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 function local:foo($a,$k){
if($a) then map{"k":$k,"d":$a} else ()
declare function local:xqdoc-url($key as item())
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 $files:= $files//c:file
let $names:= $files!string-join(ancestor-or-self::*/@name,"/")
let $xqdocs:=$files!doc(resolve-uri(``[F`{ position() }`/xqdoc.xml]``,$target))
let $paths:= $xqdocs!local:foo(xqd:rxq(*),position())
let $xqdocs:=$files!doc(local:xqdoc-url(position()))
let $paths:= $xqdocs!local:item(xqd:annotations(*, $nsRESTXQ,"path"),position())
let $items:=
for $annots in $paths
let $uri:=$annots?d/string()
@ -32,15 +41,15 @@ for $annots in $paths
<h3>{ $uri }</h3>
<ol>{
for $annot in $annots
let $fun:=$annot?d/../..
let $fun:=$annot?doc/../..
let $funname:=concat($fun/xqdoc:name/string(),'#',$fun/@arity/string())
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>
<a>{ $uri }</a>
</li>
return <div>
let $op:= <div>
<nav id="toc">
<div>
<a href="index.html">
@ -66,4 +75,14 @@ return <div>
<ul>{ $items }</ul>
</div>
=>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( )
{
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';
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.
: @return json format
:)
declare function query-a:fields($mod as xs:anyURI)
declare function query-a:inspect($mod as xs:anyURI)
as element(json)
{
let $updating:=xquery:parse-uri($mod)/@updating/string()

View File

@ -10,7 +10,8 @@ module namespace store = 'quodatum.store';
declare %updating
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
@ -21,7 +22,7 @@ function store:store1($doc as map(*),$base as xs:string)
return switch (substring-before($uri,":"))
case "file" return store:file($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
:)
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})
//c:file/@name/resolve-uri(.,base-uri(.))
};

View File

@ -82,7 +82,7 @@ declare function xqd:gendoc2(
$target as xs:string,
$params as map(*)
)
{
as map(*)* {
let $ip:= $f/@name/resolve-uri(.,base-uri(.))
let $xqdoc:= xqd:xqdoc($ip,map{})
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(*))
{
@ -159,13 +159,15 @@ declare function xqd:export-resources($target as xs:string)
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)*
{
let $restxq:=$xqdoc//xqdoc:namespace[@uri='http://exquery.org/ns/restxq']/@prefix/string()
return $xqdoc//xqdoc:annotations/xqdoc:annotation[@name=(for $p in $restxq return concat($p,':path'))]
let $prefixes:=$xqdoc//xqdoc:namespace[@uri=$annotns]/@prefix/string()
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
Vue.component('qd-autoheight',{template:`
@ -4468,7 +4468,9 @@ const Entity1=Vue.extend({template:`
<v-expansion-panel v-model="panel" expand="">
<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>
</v-expansion-panel-content>
@ -4508,7 +4510,7 @@ const Entity1=Vue.extend({template:`
{text: "description", value: "description"},
{text: "xpath", value: "xpath"}
],
panel: [true,true]
panel: [false, true]
}
},
methods:{
@ -5466,7 +5468,7 @@ const Settings=Vue.extend({template:`
<v-container fluid="">
<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="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-title class="lime darken-1">Available settings</v-card-title>
@ -5489,23 +5491,47 @@ const Settings=Vue.extend({template:`
keys: ["?"],
showDev: false,
dark:false,
serviceworker:true
serviceworker: true
}
},
methods:{
theme(){
this.$root.$emit("theme",this.dark)
settings.setItem('settings/dark',this.dark)
.then(v=>{
this.$root.$emit("theme",this.dark)
})
},
worker(){
settings.setItem('features/serviceworker',this.serviceworker)
.then(v=>{
console.log("worker",this.serviceworker)
})
}
},
created(){
console.log("settings")
settings.keys()
.then( 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];
})
})
}
}
);
@ -5614,7 +5640,11 @@ const Runtask=Vue.extend({template:`
<v-icon>play_circle_outline</v-icon>
Run</v-btn>
</v-toolbar>
<v-card-text v-if="id">
{{ id }}
</v-card-text>
<v-card-text>
<v-container fluid="">
<v-layout row="" wrap="">
@ -5622,8 +5652,6 @@ const Runtask=Vue.extend({template:`
<vp-paramform ref="params" :endpoint="'tasks/'+task"></vp-paramform>
</v-flex>
</v-layout>
</v-container>
</v-card-text>
<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);
});
}
},
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,
enableLiveAutocompletion:true
},
"features/serviceworker": true,
"settings/dark": false,
"features/serviceworker": false,
"edit/items":[
{name:"web.txt", id:"1", mode:"text", dirty: false,
text:`Lorem ipsum dolor sit amet, consectetur adipiscing elit,
@ -6886,7 +6930,6 @@ return $a `},
</foo>`}
],
"edit/currentId": "?",
"system/serviceworker": true,
"images/thumbtask":`
<thumbnail>
<size width="100" height="100"/>

View File

@ -22,7 +22,7 @@
<body>
<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="rect1"></div>