Compare commits

..

No commits in common. "master" and "8918cdd05877d582136662437cd38644153101f9" have entirely different histories.

31
api.js
View File

@ -6,10 +6,10 @@ var events = require( "events" );
var zlib = require( "zlib" ); var zlib = require( "zlib" );
var http = require( "http" ); var http = require( "http" );
var conf = cl.load( "config.all" ).botanjs; var conf = cl.load( "config.botanjs" );
var Session = cl.load( "botansx.modular.session" );
var hash = cl.load( "botansx.utils.hash" ); var hash = cl.load( "botansx.utils.hash" );
var rand = cl.load( "botansx.utils.random" );
var BotanJS = function() var BotanJS = function()
{ {
@ -17,21 +17,10 @@ var BotanJS = function()
this.sv = {}; this.sv = {};
this.kv = {}; this.kv = {};
this.embed = {}; this.embed = {};
this._nonce = {};
this.disabled = false;
}; };
util.inherits( BotanJS, events.EventEmitter ); util.inherits( BotanJS, events.EventEmitter );
var _trim = function( s )
{
if( 100 < s.length )
{
return "[BLOB: " + s.substr( 0, 20 ) + " ...]";
}
return s;
};
BotanJS.prototype.unshift = function() BotanJS.prototype.unshift = function()
{ {
for( var i in arguments ) for( var i in arguments )
@ -68,21 +57,10 @@ BotanJS.prototype.storeForRender = function( rainet, type, ch )
} }
}; };
BotanJS.prototype.nonce = function( type )
{
return ( this._nonce[ type ] ||= rand.randstr( 8 ) );
};
BotanJS.prototype.compile = function( type ) BotanJS.prototype.compile = function( type )
{ {
var _self = this; var _self = this;
if( this.disabled )
{
_self.emit( "complete" );
return;
}
var j = conf.debug ? [ "Components.Console" ] : []; var j = conf.debug ? [ "Components.Console" ] : [];
for( var i in this.sv ) if( this.sv[ i ] ) j.push( i ); for( var i in this.sv ) if( this.sv[ i ] ) j.push( i );
for( var i in this.kv ) if( this.kv[ i ] ) j.push( i ); for( var i in this.kv ) if( this.kv[ i ] ) j.push( i );
@ -105,7 +83,6 @@ BotanJS.prototype.compile = function( type )
var q = j.join( "," ); var q = j.join( "," );
var lookupKey = hash.md5( q ); var lookupKey = hash.md5( q );
var Session = cl.load( "botansx.modular.session" );
var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true ); var fastCache = new Session( lookupKey, "BOTAN_JCACHE", true );
var deflateComplete = function( err, data ) var deflateComplete = function( err, data )
@ -130,10 +107,10 @@ BotanJS.prototype.compile = function( type )
{ {
_self.storeForRender( rainet, type, ch ); _self.storeForRender( rainet, type, ch );
Dragonfly.Debug( "Storing " + _trim( ch ) + " to fastcache[ " + fastCache.id + " ]" ); Dragonfly.Debug( "Storing " + ch + " to fastcache[ " + fastCache.id + " ]" );
fastCache.spawn( 10 ); fastCache.spawn( 10 );
fastCache.set({ type: ch }); fastCache.set( type, ch );
if( res.statusCode != 200 ) if( res.statusCode != 200 )
{ {