1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-11-20 02:18:20 +01:00

Merge pull request #1 from lxsang/master

Add auto build script on pull request
This commit is contained in:
Xuan Sang LE 2020-06-26 10:34:20 +02:00 committed by GitHub
commit 36c73c8035
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 50 additions and 2018 deletions

View File

@ -1,5 +1,5 @@
BUILDDIR?=./build
PROJS?=grs info blog apps os doc ci
PROJS?=grs info blog os doc ci
copyfiles = index.ls mimes.json
main: copy
for f in $(PROJS); do BUILDDIR=$(BUILDDIR)/"$${f}" make -C "$${f}" ; done

View File

@ -1,24 +0,0 @@
copyfiles = router.lua controllers logs views models
coffees = assets/coffee/bootstrap.coffee \
assets/coffee/BaseObject.coffee \
assets/coffee/APIManager.coffee \
assets/coffee/MarkOn.coffee \
assets/coffee/WebVNC.coffee
SED=sed
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED=gsed
endif
main: js
- mkdir -p $(BUILDDIR)/assets
cp -rvf $(copyfiles) $(BUILDDIR)
cp -rv assets/css assets/scripts $(BUILDDIR)/assets
- cd $(BUILDDIR) && ln -s ../grs ./rst
js:
- rm assets/scripts/main.*
for f in $(coffees); do (cat "$${f}"; echo) >> assets/scripts/main.coffee; done
coffee --compile assets/scripts/main.coffee
-rm assets/scripts/main.coffee

View File

@ -1,24 +0,0 @@
class APIManager extends window.classes.BaseObject
constructor: (@args) ->
super "APIManager"
init: () ->
me = @
return console.error "No class found" unless @args and @args.length > 0
cname = (@args.splice 0,1)[0].trim()
@ready()
.then () ->
if mobilecheck()
mobileConsole.init()
# load the class
return if not cname or cname is ""
return console.error("Cannot find class ", cname) unless window.classes[cname]
(new window.classes[cname](me.args)).init()
.catch ( m, s ) ->
console.error(m, s)
APIManager.dependencies = [
"/assets/scripts/mobile_console.js"
]
makeclass "APIManager", APIManager

View File

@ -1,36 +0,0 @@
# private function
require = (lib) ->
return new Promise (r, e) ->
return r() if window.libraries[lib]
$.getScript window.myuri + lib
.done (d) ->
window.libraries[lib] = true
r()
.fail (m, s) ->
e(m, s)
class BaseObject
constructor: (@name) ->
ready: () ->
me = @
return new Promise (r, e) ->
me.resolveDep()
.then () -> r()
.catch (m, s) -> e(m, s)
resolveDep: () ->
me = @
return new Promise (r, e) ->
dep = window.classes[me.name].dependencies
r() unless dep
fn = (l, i) ->
return r() if i >= dep.length
require(l[i])
.then () -> fn(l, i + 1)
.catch (m, s) -> e(m, s)
fn dep, 0
makeclass "BaseObject", BaseObject

View File

@ -1,17 +0,0 @@
class MarkOn extends window.classes.BaseObject
constructor: () ->
super "MarkOn"
init: () ->
me = @
@ready()
.then () ->
me.editor = new SimpleMDE { element: $("#editor")[0] }
.catch (m, s) ->
console.error(m, s)
MarkOn.dependencies = [
"/rst/gscripts/mde/simplemde.min.js"
]
makeclass "MarkOn", MarkOn

View File

@ -1,55 +0,0 @@
class WebVNC extends window.classes.BaseObject
constructor: () ->
super "WebVNC"
init: () ->
me = @
@ready()
.then () ->
me.initVNCClient()
.catch (m, s) ->
console.error(m, s)
initVNCClient: () ->
args =
{
element: 'canvas',
#ws: 'wss://localhost:9192/wvnc',
ws: 'wss://lxsang.me/wvnc',
worker: '/assets/scripts/decoder.js'
}
@client = new WVNC args
me = @
@client.onpassword = () ->
return new Promise (r,e) ->
r('demopass')
@client.oncredential = () ->
return new Promise (r,e) ->
r('demo', 'demo')
@client.oncopy = (text) ->
cosole.log text
@client.onerror = (m) ->
alert(m)
@client.init()
.then () ->
$("#connect").click (e) ->
me.client.connect "/opt/www/vnc.conf", {
bbp: 32,
flag: 3,
quality: 30
}
$("#tbstatus").html "32bbp, compression JPEG & ZLib, JPEG quality 30%"
$("#stop").click (e) ->
me.client.disconnect()
$("#selscale").on 'change', (e) ->
value = Number(@value)/100
me.client.setScale value
#$("#btclipboard").click (e) ->
# me.client.sendTextAsClipboard ($ "#clipboard")[0].value
.catch (m,s) ->
console.error m, s
WebVNC.dependencies = [
"/assets/scripts/wvnc.js"
]
makeclass "WebVNC", WebVNC

View File

@ -1,20 +0,0 @@
window.classes = {}
window.libraries = {}
window.myuri = "/"
window.mobilecheck = () ->
if navigator.userAgent.match(/Android/i) or navigator.userAgent.match(/webOS/i) or navigator.userAgent.match(/iPhone/i) or navigator.userAgent.match(/iPad/i) or navigator.userAgent.match(/iPod/i) or navigator.userAgent.match(/BlackBerry/i) or navigator.userAgent.match(/Windows Phone/i)
return true
return false
window.makeclass = (n, o) -> window.classes[n] = o
###
window.require = (lib) ->
return new Promise (r, e) ->
return r() if window.libraries[lib]
$.getScript window.myuri + lib
.done (d) ->
window.libraries[lib] = true
r()
.fail (m, s) ->
e(m, s) ###

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
var api,onmessage,resolution,wasm_update;importScripts("wvnc_asm.js"),api={},resolution=void 0,Module.onRuntimeInitialized=function(){return api={createBuffer:Module.cwrap("create_buffer","number",["number","number"]),destroyBuffer:Module.cwrap("destroy_buffer","",["number"]),updateBuffer:Module.cwrap("update","number",["number","number","number","number","number","number"]),decodeBuffer:Module.cwrap("decode","number",["number","number","number","number"])}},wasm_update=function(e){var r,u,n,t,a,o,d,f,i,s,m;if(s=(r=new Uint8Array(e))[1]|r[2]<<8,m=r[3]|r[4]<<8,i=r[5]|r[6]<<8,t=r[7]|r[8]<<8,n=r[9],a=api.createBuffer(r.length),Module.HEAP8.set(r,a),d=i*t*4,o=api.decodeBuffer(a,r.length,resolution.depth,d),u=new Uint8Array(Module.HEAP8.buffer,o,d),e={},(f=new Uint8Array(d)).set(u,0),e.pixels=f.buffer,e.x=s,e.y=m,e.w=i,e.h=t,postMessage(e,[e.pixels]),api.destroyBuffer(a),0!==n||32!==resolution.depth)return api.destroyBuffer(o)},onmessage=function(e){return e.data.depth?resolution=e.data:wasm_update(e.data)};

View File

@ -1,221 +0,0 @@
// Generated by CoffeeScript 2.5.1
(function() {
var APIManager, BaseObject, MarkOn, WebVNC, require;
window.classes = {};
window.libraries = {};
window.myuri = "/";
window.mobilecheck = function() {
if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) {
return true;
}
return false;
};
window.makeclass = function(n, o) {
return window.classes[n] = o;
};
/*
window.require = (lib) ->
return new Promise (r, e) ->
return r() if window.libraries[lib]
$.getScript window.myuri + lib
.done (d) ->
window.libraries[lib] = true
r()
.fail (m, s) ->
e(m, s) */
// private function
require = function(lib) {
return new Promise(function(r, e) {
if (window.libraries[lib]) {
return r();
}
return $.getScript(window.myuri + lib).done(function(d) {
window.libraries[lib] = true;
return r();
}).fail(function(m, s) {
return e(m, s);
});
});
};
BaseObject = class BaseObject {
constructor(name) {
this.name = name;
}
ready() {
var me;
me = this;
return new Promise(function(r, e) {
return me.resolveDep().then(function() {
return r();
}).catch(function(m, s) {
return e(m, s);
});
});
}
resolveDep() {
var me;
me = this;
return new Promise(function(r, e) {
var dep, fn;
dep = window.classes[me.name].dependencies;
if (!dep) {
r();
}
fn = function(l, i) {
if (i >= dep.length) {
return r();
}
return require(l[i]).then(function() {
return fn(l, i + 1);
}).catch(function(m, s) {
return e(m, s);
});
};
return fn(dep, 0);
});
}
};
makeclass("BaseObject", BaseObject);
APIManager = class APIManager extends window.classes.BaseObject {
constructor(args1) {
super("APIManager");
this.args = args1;
}
init() {
var cname, me;
me = this;
if (!(this.args && this.args.length > 0)) {
return console.error("No class found");
}
cname = (this.args.splice(0, 1))[0].trim();
return this.ready().then(function() {
if (mobilecheck()) {
mobileConsole.init();
}
// load the class
if (!cname || cname === "") {
return;
}
if (!window.classes[cname]) {
return console.error("Cannot find class ", cname);
}
return (new window.classes[cname](me.args)).init();
}).catch(function(m, s) {
return console.error(m, s);
});
}
};
APIManager.dependencies = ["/assets/scripts/mobile_console.js"];
makeclass("APIManager", APIManager);
MarkOn = class MarkOn extends window.classes.BaseObject {
constructor() {
super("MarkOn");
}
init() {
var me;
me = this;
return this.ready().then(function() {
return me.editor = new SimpleMDE({
element: $("#editor")[0]
});
}).catch(function(m, s) {
return console.error(m, s);
});
}
};
MarkOn.dependencies = ["/rst/gscripts/mde/simplemde.min.js"];
makeclass("MarkOn", MarkOn);
WebVNC = class WebVNC extends window.classes.BaseObject {
constructor() {
super("WebVNC");
}
init() {
var me;
me = this;
return this.ready().then(function() {
return me.initVNCClient();
}).catch(function(m, s) {
return console.error(m, s);
});
}
initVNCClient() {
var args, me;
args = {
element: 'canvas',
//ws: 'wss://localhost:9192/wvnc',
ws: 'wss://lxsang.me/wvnc',
worker: '/assets/scripts/decoder.js'
};
this.client = new WVNC(args);
me = this;
this.client.onpassword = function() {
return new Promise(function(r, e) {
return r('demopass');
});
};
this.client.oncredential = function() {
return new Promise(function(r, e) {
return r('demo', 'demo');
});
};
this.client.oncopy = function(text) {
return cosole.log(text);
};
this.client.onerror = function(m) {
return alert(m);
};
return this.client.init().then(function() {
$("#connect").click(function(e) {
return me.client.connect("/opt/www/vnc.conf", {
bbp: 32,
flag: 3,
quality: 30
});
});
$("#tbstatus").html("32bbp, compression JPEG & ZLib, JPEG quality 30%");
$("#stop").click(function(e) {
return me.client.disconnect();
});
return $("#selscale").on('change', function(e) {
var value;
value = Number(this.value) / 100;
return me.client.setScale(value);
});
//$("#btclipboard").click (e) ->
// me.client.sendTextAsClipboard ($ "#clipboard")[0].value
}).catch(function(m, s) {
return console.error(m, s);
});
}
};
WebVNC.dependencies = ["/assets/scripts/wvnc.js"];
makeclass("WebVNC", WebVNC);
}).call(this);

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -1,30 +0,0 @@
BaseController:subclass("IndexController", {
registry = {}
})
function IndexController:index( ... )
return true
end
function IndexController:actionnotfound(...)
self.template:setView("index")
return self:index(table.unpack({...}))
end
function IndexController:json(...)
std.json()
echo( JSON.encode(REQUEST))
return false
end
function IndexController:get(...)
return true
end
function IndexController:form(...)
return true
end
function IndexController:upload(...)
return true
end

View File

@ -1,13 +0,0 @@
BaseController:subclass("MarkOnController", {
registry = {}
})
function MarkOnController:index( ... )
self.template:set("args", "['MarkOn']")
return true
end
function MarkOnController:actionnotfound(...)
self.template:setView("index")
return self:index(table.unpack({...}))
end

View File

@ -1,19 +0,0 @@
BaseController:subclass("ScriptController", {
registry = {}
})
function ScriptController:index( name )
local path = WWW_ROOT..DIR_SEP.."assets"..DIR_SEP.."shs"..DIR_SEP..name..".sh"
if ulib.exists(path) then
std.header("text/plain")
std.f(path)
else
self:error("No script found")
end
return false
end
function ScriptController:actionnotfound(...)
return self:index(table.unpack({...}))
end

View File

@ -1,13 +0,0 @@
BaseController:subclass("WebVNCController", {
registry = {}
})
function WebVNCController:index( ... )
self.template:set("args", "['WebVNC']")
return true
end
function WebVNCController:actionnotfound(...)
self.template:setView("index")
return self:index(table.unpack({...}))
end

View File

@ -1,59 +0,0 @@
-- the rewrite rule for the framework
-- should be something like this
-- ^\/apps\/+(.*)$ = /apps/router.lua?r=<1>&<query>
-- some global variables
DIR_SEP = "/"
WWW_ROOT = __ROOT__.."/apps"
if HEADER.Host then
HTTP_ROOT= "https://"..HEADER.Host
else
HTTP_ROOT = "https://apps.lxsang.me"
end
-- class path: path.to.class
BASE_FRW = ""
-- class path: path.to.class
CONTROLLER_ROOT = BASE_FRW.."apps.controllers"
MODEL_ROOT = BASE_FRW.."apps.models"
-- file path: path/to/file
VIEW_ROOT = WWW_ROOT..DIR_SEP.."views"
LOG_ROOT = WWW_ROOT..DIR_SEP.."logs"
-- require needed library
require(BASE_FRW.."silk.api")
POLICY.mimes["application/wasm"] = true
-- registry object store global variables
local REGISTRY = {}
-- set logging level
REGISTRY.logger = Logger:new{ levels = {INFO = false, ERROR = true, DEBUG = false}}
REGISTRY.db = DBHelper:new{db="iosapps"}
REGISTRY.layout = 'default'
REGISTRY.fileaccess = true
REGISTRY.db:open()
local router = Router:new{registry = REGISTRY}
REGISTRY.router = router
router:setPath(CONTROLLER_ROOT)
--router:route('edit', 'post/edit', "ALL" )
-- example of depedencies to the current main route
--[[ -- each layout may have different dependencies
local default_routes_dependencies = {
edit = {
url = "post/edit",
visibility = {
shown = true,
routes = {
["post/index"] = true
}
}
},
--category = {
-- url = "cat/index",
-- visibility = "ALL"
--}
}
router:route('default', default_routes_dependencies )]]
router:delegate()
if REGISTRY.db then REGISTRY.db:close() end

View File

@ -1 +0,0 @@
<textarea id = "editor"></textarea>

View File

@ -1,15 +0,0 @@
<?lua
if REQUEST.method == "POST" then
return echo(JSON.encode(REQUEST))
end
?>
<form action="https://apps.localhost:9195/index/form" method="post">
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</fieldset>
</form>

View File

@ -1,3 +0,0 @@
<?lua
echo(JSON.encode(REQUEST))
?>

View File

@ -1,3 +0,0 @@
<h1>
Site under construction
</h1>

View File

@ -1,11 +0,0 @@
<?lua
echo(JSON.encode(REQUEST))
?>
<form action="https://apps.localhost:9192/index/testrq" enctype="multipart/form-data" method="post">
<input type="file" name="fileToUpload" id="fileToUpload"><br>
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>

View File

@ -1,12 +0,0 @@
<?lua
if REQUEST.method == "POST" then
return echo(JSON.encode(REQUEST))
end
?>
<form action="https://apps.localhost:9195/index/upload" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="file" name="fileToUpload1" id="fileToUpload1">
<input type="submit" value="Upload Image" name="submit">
</form>

View File

@ -1,32 +0,0 @@
<?lua
local args = __main__:get("args")
if args == nil then args = "[]" end
?>
<html>
<head>
<title>Application pages</title>
<link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/rst/ubuntu-regular.css" />
<link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/assets/css/style.css" />
<link rel="stylesheet" type="text/css" href="<?=HTTP_ROOT?>/rst/font-awesome.css" />
<!--script type="text/javascript" src="<?=HTTP_ROOT?>/rst/gscripts/riot.min.js"> </script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/rst/resources/antos_tags.js"></script-->
<script type="text/javascript" src="<?=HTTP_ROOT?>/rst/gscripts/jquery-3.2.1.min.js"> </script>
<script type="text/javascript" src="<?=HTTP_ROOT?>/assets/scripts/main.js"></script>
<!--script type="text/javascript" src="<?=HTTP_ROOT?>/rst/gscripts/showdown.min.js"></script-->
<script>
$(window).on('load', function(){
window.myuri = '<?=HTTP_ROOT?>';
var manager = new window.classes.APIManager(<?=args?>);
manager.init();
});
</script>
</head>
<body>
<div id="desktop">
<?lua
__main__:render()
?>
</div>
</body>
</html>

View File

@ -1,18 +0,0 @@
<div id="screen_container">
<ul id = "tool_bar">
<li class ="title">VNC client demo</li>
<li><a id="connect" href="#">Connect</a></li>
<li><a id="stop" href="#">Disconnect</a></li>
<li>
Scale (percent):
<select id="selscale">
<option value="50">40</option>
<option value="60">60</option>
<option value="80">80</option>
<option value="100" selected="selected">100</option>
</select>
</li>
<li id ="tbstatus"></li>
</ul>
<div style="width:1px; display:block; clear:both;"></div>
<canvas id = "canvas" tabindex="1"></canvas>

View File

@ -1,6 +1,6 @@
copyfiles = assets views models controllers router.lua
main:
- mkdir $(BUILDDIR)
- mkdir -p $(BUILDDIR)
cp -rvf $(copyfiles) $(BUILDDIR)
- cd $(BUILDDIR) && ln -s ../grs ./rst

View File

@ -1,6 +1,6 @@
copyfiles = router.lua scripts
main:
- mkdir $(BUILDDIR)
- mkdir -p $(BUILDDIR)
cp -rvf $(copyfiles) $(BUILDDIR)
- mkdir -p $(BUILDDIR)/log

View File

@ -0,0 +1,31 @@
#! /bin/bash
BRANCH="ci"
PRJ="antd-web-apps"
DEST="/opt/www/htdocs"
REPO="https://github.com/lxsang/$PRJ.git"
if [ ! -z $1 ]; then
BRANCH="$1"
fi
{
echo "Build date: $(date)"
echo "Building $PRJ using branch $BRANCH..."
if [ -d "/tmp/ci/$PRJ" ]; then
echo "Clean up /tmp/ci/$PRJ"
rm -rf /tmp/ci/$PRJ
else
echo "Creating /tmp/ci/"
mkdir -p "/tmp/ci"
fi
cd /tmp/ci || (echo "Unable to change directory to /tmp/ci" && exit 1)
echo "Cloning $PRJ (branch $BRANCH) to /tmp/ci..."
git clone -b "$BRANCH" --single-branch --depth=1 "$REPO"
cd "$PRJ" || (echo "Unable to change directory to source code folder" && exit 1)
mkdir -p "$DEST"
BUILDDIR="$DEST" make
echo "Done!"
} 2>&1 | tee "/opt/www/htdocs/ci/log/${PRJ}_${BRANCH}.txt"

View File

@ -1,28 +1,32 @@
#! /bin/bash
BRANCH="ci"
REPO="https://github.com/lxsang/antos.git"
PRJ="antos"
DEST="/opt/www/htdocs/os"
# /opt/www/htdocs
REPO="https://github.com/lxsang/$PRJ.git"
if [ ! -z $1 ]; then
BRANCH="$1"
fi
{
echo "Build date: $(date)"
echo "Building AntOS using branch $BRANCH..."
if [ -d "/tmp/ci" ]; then
echo "Clean up /tmp/ci"
rm -rf /tmp/ci/*
echo "Building $PRJ using branch $BRANCH..."
if [ -d "/tmp/ci/$PRJ" ]; then
echo "Clean up /tmp/ci/$PRJ"
rm -rf /tmp/ci/$PRJ
else
echo "Creating /tmp/ci"
echo "Creating /tmp/ci/"
mkdir -p "/tmp/ci"
fi
cd /tmp/ci || (echo "Unable to change directory to /tmp/ci" && exit 1)
echo "Cloning Antos (branch $BRANCH) to /tmp/ci..."
echo "Cloning $PRJ (branch $BRANCH) to /tmp/ci..."
git clone -b "$BRANCH" --single-branch --depth=1 "$REPO"
cd "$PRJ" || (echo "Unable to change directory to source code folder" && exit 1)
npm i @types/jquery
cd antos || (echo "Unable to change directory to source code folder" && exit 1)
mkdir -p "$DEST"
BUILDDIR="$DEST" make release
echo "Done!"
} > "/opt/www/htdocs/ci/log/antos_$BRANCH.txt"
} 2>&1 | tee "/opt/www/htdocs/ci/log/${PRJ}_${BRANCH}.txt"

View File

@ -1,6 +1,6 @@
copyfiles = views controllers router.lua assets
main:
- mkdir $(BUILDDIR)
- mkdir -p $(BUILDDIR)
cp -rvf $(copyfiles) $(BUILDDIR)
- cd $(BUILDDIR) && ln -s ../grs ./rst

View File

@ -1,6 +1,6 @@
copyfiles = style.css router.lua models views controllers robot.txt
main:
- mkdir $(BUILDDIR)
- mkdir -p $(BUILDDIR)
cp -rvf $(copyfiles) $(BUILDDIR)
- cd $(BUILDDIR) && ln -s ../grs ./rst

View File

@ -1,6 +1,6 @@
copyfiles = controllers libs router.lua
main:
- mkdir $(BUILDDIR)
- mkdir -p $(BUILDDIR)
cp -rfv $(copyfiles) $(BUILDDIR)
- cd $(BUILDDIR) && ln -s ../grs ./rst