initial commit
This commit is contained in:
parent
e3e3fbf9d3
commit
b1c5365bf7
36 changed files with 100477 additions and 1 deletions
44
tools/compile.xq
Normal file
44
tools/compile.xq
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
(:~
|
||||
: create app.js from vue files
|
||||
:)
|
||||
import module namespace html5="text.html5" at "html5parse.xqm";
|
||||
import module namespace fw="quodatum:file.walker";
|
||||
declare namespace c="http://www.w3.org/ns/xproc-step";
|
||||
declare namespace Document="java:ch.digitalfondue.jfiveparse.Document";
|
||||
declare namespace Element="java:ch.digitalfondue.jfiveparse.Element";
|
||||
declare namespace Node="java:ch.digitalfondue.jfiveparse.Node";
|
||||
declare namespace list="java:java.util.ArrayList";
|
||||
declare namespace functx = "http://www.functx.com";
|
||||
declare variable $SRC:="C:/Users/andy/git/vue-poc/src/vue-poc/templates/";
|
||||
declare variable $CORE:="C:/Users/andy/git/vue-poc/src/vue-poc/static/core.js";
|
||||
declare variable $DEST:="C:/Users/andy/git/vue-poc/src/vue-poc/static/app-gen.js";
|
||||
|
||||
(:~
|
||||
: generate javascript vue call from vue file
|
||||
:)
|
||||
declare function local:process($doc)
|
||||
{
|
||||
let $tempNode:= Document:getElementsByTagName($doc,"template")=>list:get(xs:int(0))
|
||||
let $template:= Node:getInnerHTML($tempNode)
|
||||
let $id:= Element:getAttribute($tempNode,"id")
|
||||
let $name:=functx:capitalize-first($id)=>trace("ID")
|
||||
|
||||
let $script:= Document:getElementsByTagName($doc,"script")=>list:get(xs:int(0))
|
||||
let $tempfix:=replace($template,"\$","\\\$")
|
||||
let $s:= Node:getInnerHTML($script)=>replace('[''"]#' || $id || '[''"]','`' ||$tempfix ||'`')
|
||||
|
||||
let $js:= ``[const `{$name}`=Vue.extend(`{$s}`
|
||||
);
|
||||
]``
|
||||
return if($id="") then () else $js
|
||||
};
|
||||
|
||||
declare function functx:capitalize-first
|
||||
( $arg as xs:string? ) as xs:string?
|
||||
{
|
||||
concat(upper-case(substring($arg,1,1)), substring($arg,2))
|
||||
};
|
||||
let $files:= fw:directory-list($SRC,map{"include-filter":".*\.vue"})
|
||||
//c:file/@name/resolve-uri(.,base-uri(.))
|
||||
let $docs:=$files!(fetch:text(.)=>html5:doc()=>local:process())
|
||||
return file:write-text($DEST,string-join(($docs,fetch:text($CORE))))
|
||||
30
tools/html5parse.xqm
Normal file
30
tools/html5parse.xqm
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
module namespace html5="text.html5";
|
||||
declare namespace Document="java:ch.digitalfondue.jfiveparse.Document";
|
||||
declare namespace Element="java:ch.digitalfondue.jfiveparse.Element";
|
||||
declare namespace Node="java:ch.digitalfondue.jfiveparse.Node";
|
||||
declare namespace Parser="java:ch.digitalfondue.jfiveparse.Parser";
|
||||
declare namespace Selector="java:ch.digitalfondue.jfiveparse.Selector";
|
||||
declare namespace list="java:java.util.ArrayList";
|
||||
|
||||
|
||||
declare function html5:doc($text as xs:string)
|
||||
{
|
||||
let $p:=Parser:new()
|
||||
return Parser:parse($p,$text)
|
||||
};
|
||||
|
||||
|
||||
declare function html5:for-each($nodes,$fn as function(*))
|
||||
{
|
||||
for $index in 0 to list:size($nodes)-1
|
||||
let $a:=list:get($nodes,xs:int($index))
|
||||
return $fn($a)
|
||||
};
|
||||
|
||||
declare function html5:selector()
|
||||
{
|
||||
Selector:select()
|
||||
=>Selector:element("script")
|
||||
=>Selector:attrValEq("type", "text/x-template")
|
||||
=>Selector:toMatcher()
|
||||
};
|
||||
30
tools/split.xq
Normal file
30
tools/split.xq
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
(:~
|
||||
: create vue files from app.html
|
||||
:)
|
||||
import module namespace html5="text.html5" at "html5parse.xqm";
|
||||
declare namespace Document="java:ch.digitalfondue.jfiveparse.Document";
|
||||
declare namespace Element="java:ch.digitalfondue.jfiveparse.Element";
|
||||
declare namespace Node="java:ch.digitalfondue.jfiveparse.Node";
|
||||
|
||||
declare variable $DEST:="C:/Users/andy/git/vue-poc/src/vue-poc/templates/";
|
||||
declare variable $SRC:="C:/Users/andy/git/vue-poc/src/vue-poc/static/app.html";
|
||||
|
||||
|
||||
declare function local:process($node)
|
||||
{
|
||||
let $id:= Element:getAttribute($node,"id")
|
||||
let $html:=Node:getInnerHTML($node)
|
||||
let $name:=$DEST || $id || ".vue"
|
||||
let $out:=``[<!DOCTYPE html>
|
||||
<template id="`{$id}`">`{$html}`</template>
|
||||
<script>
|
||||
</script>
|
||||
]``
|
||||
return file:write-text($name,$out)
|
||||
|
||||
};
|
||||
|
||||
let $doc:=$SRC=>fetch:text()=>html5:doc()
|
||||
let $matcher:=html5:selector()
|
||||
let $nodes:= Document:getAllNodesMatching($doc,$matcher)
|
||||
return $nodes=>html5:for-each(local:process#1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue