added string and use it to fixe white space and missing .'s

This commit is contained in:
Martin Donnelly 2016-02-15 10:13:54 +00:00
parent f7c331cc78
commit dd55cff45b
2 changed files with 8 additions and 11 deletions

View File

@ -3,7 +3,7 @@
*/
var http = require('http'), request = require('request'), cheerio = require('cheerio'), Forecast = require('forecast.io'), util = require('util'), UltraSES = require('ultrases'), cron = require('node-cron');
var jade = require('jade'), _ = require('lodash'), dateFormat = require('dateformat');
var jsonfile = require('jsonfile'), fs = require('fs');
var jsonfile = require('jsonfile'), fs = require('fs'), STRING = require('string');
var log4js = require('log4js');
var logger = log4js.getLogger();
@ -134,16 +134,11 @@ module.exports = {
var output = [];
tdihbody.find('.tdihevent > p').each(function (div) {
// logger.info($(this));
var s = $(this).text();
if (s.indexOf('Today\'s recipe:') == -1) {
output.push(s);
}
output.push(STRING(s).collapseWhitespace().s);
});
todayCache.data.history = todayCache.data.history.concat(output);
console.log(todayCache.data.history);
});
},
getHistory: function () {
@ -258,12 +253,13 @@ module.exports = {
j.later = data.daily.summary;
j.alerts = data.alerts || {};
var fs = STRING(j.currently).endsWith('.') ? '' : '.';
if (tempMax == tempMin) {
data.currently.summary += '<br/>Around ' + tempMin.toString() + ' degrees.';
j.currently += fs + ' Around ' + tempMin.toString() + ' degrees.';
}
else
{
data.currently.summary += '<br/>Around ' + tempMin.toString() + ' to ' + tempMax.toString() + ' degrees.';
j.currently += fs + ' Around ' + tempMin.toString() + ' to ' + tempMax.toString() + ' degrees.';
}
todayCache.data.weather = j;
});

View File

@ -20,10 +20,11 @@
"express": "3.x",
"node-cron": "^1.0.0",
"scrape": "^0.2.3",
"string": "^3.3.1",
"ultrases": "^0.1.3",
"unstyler": "^0.2.2"
},
"scripts" : {
"start" : "node web-server.js"
"scripts": {
"start": "node web-server.js"
}
}