diff --git a/.gitmodules b/.gitmodules index 002c6d1..8872381 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "botanss"] path = botanss url = AstroGit:BotanSS.git +[submodule "ext/utils"] + path = ext/utils + url = AstroGit:botansx-utils diff --git a/botanss b/botanss index dcdd941..cd2cce7 160000 --- a/botanss +++ b/botanss @@ -1 +1 @@ -Subproject commit dcdd941f3b4cdfebc54d452688aa59a68498efac +Subproject commit cd2cce7e985a00c685f9f0ad776af6a9f394d765 diff --git a/ext/utils b/ext/utils new file mode 160000 index 0000000..0ae868a --- /dev/null +++ b/ext/utils @@ -0,0 +1 @@ +Subproject commit 0ae868ac2d08675bc20c05a99e25f331b10724b8 diff --git a/index.js b/index.js index 2cc984d..a17bd6b 100755 --- a/index.js +++ b/index.js @@ -56,7 +56,7 @@ else // Define AppNS cl.rootNS( "notifyterm", "./notify-term" ); - cl.rootNS( "notifysrv", "./notifysrv" ); + cl.rootNS( "botansx", "./ext/" ); var App = cl.load( "notifyterm.app" ); diff --git a/notify-term/Notis.js b/notify-term/Notis.js index a546c0a..7f77eeb 100644 --- a/notify-term/Notis.js +++ b/notify-term/Notis.js @@ -4,7 +4,7 @@ var cl = global.botanLoader; var Dragonfly = global.Dragonfly; var HttpRequest = cl.load( "botanss.net.HttpRequest" ); -var ustr = cl.load( "notifysrv.utils.string" ); +var ustr = cl.load( "botansx.utils.string" ); class Notis { diff --git a/notify-term/WNSAuth.js b/notify-term/WNSAuth.js index bbaba80..37ecb56 100644 --- a/notify-term/WNSAuth.js +++ b/notify-term/WNSAuth.js @@ -6,7 +6,8 @@ var Dragonfly = global.Dragonfly; var EventEmitter = require( "events" ).EventEmitter; var HttpRequest = cl.load( "botanss.net.HttpRequest" ); -var Rand = cl.load( "notifysrv.utils.random" ); +var Rand = cl.load( "botansx.utils.random" ); + var Notis = cl.load( "notifyterm.Notis" ); var Model = cl.load( "notifyterm.schema" ); diff --git a/notify-term/app.js b/notify-term/app.js index 8982d83..4c6a2c2 100644 --- a/notify-term/app.js +++ b/notify-term/app.js @@ -4,7 +4,7 @@ var cl = global.botanLoader; var Dragonfly = global.Dragonfly; var HttpRequest = cl.load( "botanss.net.HttpRequest" ); -var Base = cl.load( "notifysrv.postframe" ); +var Base = cl.load( "botanss.net.PostFrame" ); var WNSAuth = cl.load( "notifyterm.WNSAuth" ); var Model = cl.load( "notifyterm.schema" ); diff --git a/notifysrv/eventargs/eventargs.js b/notifysrv/eventargs/eventargs.js deleted file mode 100644 index 72d7ce5..0000000 --- a/notifysrv/eventargs/eventargs.js +++ /dev/null @@ -1,15 +0,0 @@ -"use strict"; - -var cl = global.botanLoader; -var Dragonfly = global.Dragonfly; -var qstr = cl.load( "notifysrv.utils.querystr" ); - -class EventArgs -{ - constructor() - { - this.Handled = false; - } -} - -module.exports = EventArgs; diff --git a/notifysrv/eventargs/postrequest.js b/notifysrv/eventargs/postrequest.js deleted file mode 100644 index 4b348cb..0000000 --- a/notifysrv/eventargs/postrequest.js +++ /dev/null @@ -1,23 +0,0 @@ -"use strict"; - -var cl = global.botanLoader; -var Dragonfly = global.Dragonfly; -var qstr = cl.load( "notifysrv.utils.querystr" ); - -var EventArgs = cl.load( "notifysrv.eventargs.eventargs" ); - -class PostRequestEventArgs extends EventArgs -{ - constructor( QueryString ) - { - super(); - this.Raw = QueryString; - } - - get Data() - { - return qstr.queryStr( this.Raw ); - } -} - -module.exports = PostRequestEventArgs; diff --git a/notifysrv/postframe.js b/notifysrv/postframe.js deleted file mode 100644 index 4b387e0..0000000 --- a/notifysrv/postframe.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -var cl = global.botanLoader; -var Dragonfly = global.Dragonfly; - -var PostRequestEventArgs = cl.load( "notifysrv.eventargs.postrequest" ); -var EventEmitter = require( "events" ).EventEmitter; - -class PostFrame extends EventEmitter -{ - constructor( Http ) - { - super(); - this.HTTP = Http; - this.result = "Error: PostFrame is unhandled"; - this.planted = false; - } - - run() - { - var _self = this; - var requestStr = ""; - - if( this.HTTP.request.isPost ) - { - var Req = this.HTTP.request.raw; - - var ReceiveData = function( data ) - { - requestStr += data + ""; - if( 51200 < requestStr.length ) - { - _self.result = "The size of request is too big ( 500KB < )"; - Req.removeListener( "data", ReceiveData ); - Req.removeListener( "end", ReceiveEnd ); - - _self.plantResult(); - } - }; - - var ReceiveEnd = function() - { - var EventArgs = new PostRequestEventArgs( requestStr ); - - _self.emit( "PostRequest", this, EventArgs ); - if( !EventArgs.Handled ) - { - _self.result = "Error: Unhandled Request"; - _self.plantResult(); - } - }; - - Req.addListener( "data", ReceiveData ); - Req.addListener( "end", ReceiveEnd ); - return; - } - else - { - Dragonfly.Info( - "GET: " + encodeURI( this.HTTP.request.raw.url ) - + " - " + this.HTTP.request.raw.headers["user-agent"] - , Dragonfly.Visibility.VISIBLE - ); - } - - this.plantResult(); - } - - plantResult() - { - if( !this.planted ) - { - this.planted = true; - if( this.HTTP ) - { - if( !( this.result instanceof Buffer ) ) - { - this.result = String( this.result ); - } - - this.HTTP.response.headers["Content-Type"] = "text/plain"; - this.HTTP.response.headers["Content-Length"] = this.result.length; - this.HTTP.response.write( this.result ); - this.HTTP.response.end(); - } - - } - } -} - -module.exports = PostFrame; diff --git a/notifysrv/utils/querystr.js b/notifysrv/utils/querystr.js deleted file mode 100644 index 9f19f96..0000000 --- a/notifysrv/utils/querystr.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = { - queryStr: function( qstr ) - { - var qObj = {}; - - qstr.split( "&" ).forEach( function( val ) - { - val = val.split( "=" ); - qObj[ val[0] ] = val[1] ? decodeURIComponent( val[1].replace( /\+/g, " " ) ) : true; - } ); - - return qObj; - } -}; diff --git a/notifysrv/utils/random.js b/notifysrv/utils/random.js deleted file mode 100644 index 8fdcfc5..0000000 --- a/notifysrv/utils/random.js +++ /dev/null @@ -1,15 +0,0 @@ -var lut = []; for ( var i=0; i<256; i++ ) { lut[i] = (i<16?'0':'')+(i).toString(16); } - -module.exports = { - uuid: function() - { - var d0 = Math.random()*0xffffffff|0; - var d1 = Math.random()*0xffffffff|0; - var d2 = Math.random()*0xffffffff|0; - var d3 = Math.random()*0xffffffff|0; - return lut[d0&0xff]+lut[d0>>8&0xff]+lut[d0>>16&0xff]+lut[d0>>24&0xff]+'-'+ - lut[d1&0xff]+lut[d1>>8&0xff]+'-'+lut[d1>>16&0x0f|0x40]+lut[d1>>24&0xff]+'-'+ - lut[d2&0x3f|0x80]+lut[d2>>8&0xff]+'-'+lut[d2>>16&0xff]+lut[d2>>24&0xff]+ - lut[d3&0xff]+lut[d3>>8&0xff]+lut[d3>>16&0xff]+lut[d3>>24&0xff]; - } -}; diff --git a/notifysrv/utils/string.js b/notifysrv/utils/string.js deleted file mode 100644 index bfe30cd..0000000 --- a/notifysrv/utils/string.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - encodeHtml: function ( str, br ) - { - str = ( str + "" ).replace(/&/g, "&") - .replace(//g, ">") - .replace(/"/g, """) - .replace(/'/g, "'") - ; - if( br ) str = str.replace( /\n/g, "
" ); - return str; - } -}