Example #1
0
var getCrawled = function (server, ctx, cb) {
    var targetUrl = new jsuri(_.str.rtrim(ctx.uri.getBaseHref(), '/') + ctx.uri.url).deleteQueryParam('prerender').toString();

    var crawler = require('./crawler.js')(server);
    crawler.crawl(targetUrl, function (crawlErr, crawlData) {
        if (crawlErr)
            return cb(crawlErr);

        cb(null, crawlData);
    });
};
Example #2
0
  build: function(collectionName, collection, fn, separator, keyOverride, parentKey) {
    separator = separator || ', ';
    var $sql = '';
    _.each(collection, function(value, key) {
      $sql += fn(collectionName, value, keyOverride || key, parentKey);

      // (always append separator)
      $sql += separator;
    });

    // (then remove final one)
    return _.str.rtrim($sql, separator);
  }
Example #3
0
function generate(options) {
	sails.log.debug("Generating " + options.blueprint + " for " + options.entity + "...");

	// Trim slashes
	options.prefix = _.str.rtrim(options.prefix, '/') + '/';

	if(!options.entity) throw new Error('No output file name specified!');

	var file = renderBlueprint(options.blueprint, options);

	var fileEntity = options.action || options.entity;
	var newFilePath = options.prefix + fileEntity + options.suffix;
	verifyDoesntExist(newFilePath, "A file or directory already exists at: " + newFilePath);
	fs.writeFileSync(newFilePath, file);
}
Example #4
0
			_.each(options.actions, function(action) {
				var fnString = renderBlueprint('action.js', {
					action: action,
					entity: entity,
					viewEngine: sails.config.viewEngine,
					viewPath: _.str.rtrim(sails.config.paths.views, '/'),
					baseurl: '/' + entity
				});

				// If this is not the first action, add a comma
				if(actions !== "") {
					fnString = ',\n\n' + fnString;
				}
				actions += fnString;
			});
Example #5
0
		_.each(options.actions, function(action) {

			action = verifyValidEntity(action, "Invalid action name: " + action);

			return generate({
				blueprint: 'federatedAction.js',
				prefix: sails.config.paths.controllers + '/' + entity,
				entity: entity,
				action: action,
				viewEngine: sails.config.viewEngine,
				viewPath: _.str.rtrim(sails.config.paths.views, '/'),
				baseurl: '/' + entity,
				suffix: ".js"
			});
		});
Example #6
0
var getFsObject = function (rootPath, filePath, stats) {
    var result = {
        type: stats.isFile() ? 'file' : 'folder',
        path: denormalize(filePath.substring(rootPath.length)),
        location: 'files' + denormalize(filePath.substring(rootPath.length)),
        name: path.basename(filePath),
        ext: path.extname(filePath),
        dir: denormalize(path.join(path.dirname(filePath), '/').substring(rootPath.length)),
        size: stats.isFile() ? (stats.size / 1024).round(2) : 0
    };

    if (result.dir !== '/')
        result.dir = _.str.rtrim(result.dir, '/');

    return result;
};
Example #7
0
 lines = lines.map(function (line) {
     return _.str.rtrim(indent + line);
 });
Example #8
0
var Context = function (server, req, res, type) {

    this.server = server;
    this.req = req;
    this.res = res;
    this.type = type || 'html';

    var uri = new parseUri('http://' + server.host + req.url);

    if (!_.str.endsWith(uri.path, '/'))
        uri.path += '/';

    uri = new parseUri(('http://' + server.host + uri.path).toLowerCase() + (uri.query !== '' ? '?' + uri.query : ''));

    var timer = new TimeLogger('context: ' + uri.relative);
    timer.start();

    this.dbgLogger = new DebugLogger();

    if (uri.path === '/' || uri.path.toLowerCase() === '/index.html')
        uri.path = '/';
    else {
        uri.path = _.str.rtrim(uri.path, '/').toLowerCase();
    }

    uri.parts = _.str.trim(uri.path, '/').split('/');
    uri.first = uri.parts.length > 0 ? _.first(uri.parts).toLowerCase() : '';
    uri.last = uri.parts.length > 0 ? _.last(uri.parts).toLowerCase() : '';

    this.method = req.method;
    
    this.timer = timer;

    this.node = undefined;
    this.hierarchy = [];
    this.pointer = undefined;
    this.layouts = [];

    this.meta = {
        title: '',
        description: '',
        keywords: []
    };

    this.params = [];

    this.robots = {
        noindex: false,
        nofollow: false,
        noarchive: false,
        nosnipet: false,
        notranslate: false,
        noimageindex: false
    };

    this.template = '';

    this.uri = {
        url: uri.relative,
        scheme: uri.protocol,
        host: uri.host,
        port: uri.port,
        path: uri.path,
        parts: uri.parts,
        query: uri.queryKey,
        first: uri.first,
        last: uri.last,
        getBaseHref: function () {
            var href = this.scheme;
            href += '://';
            href += this.host;

            if (this.scheme === 'https') {
                href += (this.port !== '433' && this.port !== '433') ? ':' + this.port : '';
            }
            else {
                href += (this.port !== '80' && this.port !== '') ? ':' + this.port : '';
            }
            href += '/';
            return href;
        }
    };

    this.restricted = false;
};
Example #9
0
function func(data, bFirstline) {
  var temp = _.str.rtrim(data, "\n");

  if (bFirstline) {
    legendArray = _.str.words(temp, "|");
  }
  else {
    lineArray = _.str.words(temp, "|");

    if (legendArray.length === lineArray.length) {
      var cdr = {};

      cdr.callId = lineArray[_.indexOf(legendArray, 'fbasename')];
      cdr.calldate = lineArray[_.indexOf(legendArray, 'calldate')];
      cdr.duration = lineArray[_.indexOf(legendArray, 'duration')];
      cdr.caller = lineArray[_.indexOf(legendArray, 'caller')];
      cdr.callerDomain = lineArray[_.indexOf(legendArray, 'caller_domain')];
      cdr.callerName = lineArray[_.indexOf(legendArray, 'callername')];
      cdr.called = lineArray[_.indexOf(legendArray, 'called')];
      cdr.calledDomain = lineArray[_.indexOf(legendArray, 'called_domain')];
      cdr.lastSipResponseNum = lineArray[_.indexOf(legendArray, 'lastSIPresponseNum')];
      cdr.sensorId = lineArray[_.indexOf(legendArray, 'id_sensor')];
      
// a_mos_f1
// a_mos_f2
// a_mos_adapt
// b_mos_f1
// b_mos_f2
// b_mos_adapt
// a_rtcp_loss
// a_rtcp_maxfr
// a_rtcp_avgfr
// a_rtcp_maxjitter
// a_rtcp_avgjitter
// b_rtcp_loss
// b_rtcp_maxfr
// b_rtcp_avgfr
// b_rtcp_maxjitter
// b_rtcp_avgjitter
// jitter
// mos_min
// a_mos_min
// b_mos_min
// packet_loss_perc
// a_packet_loss_perc
// b_packet_loss_perc
// delay_sum
// a_delay_sum
// b_delay_sum
// delay_avg
// a_delay_avg
// b_delay_avg

      //console.log('xxxx:', cdr.callId);
 
      cdrArray.push(cdr);
    }
    else {
      console.log('data mismatch', legendArray.length, "!=", lineArray.length);
      process.exit();
    }
  }
  //console.log('Line: ' + temp);
  //console.log(legendArray);
}