Updated to the new version of keeper

This commit is contained in:
Martin Donnelly 2016-07-12 16:26:36 +01:00
parent 809eb59eee
commit b3d4435d90
6 changed files with 631 additions and 349 deletions

View File

@ -96,6 +96,7 @@ buttons {
*/
#sidedrawer.active {
transform: translate(200px);
background-color: #E1E1E1;
}
@ -165,6 +166,10 @@ buttons {
padding: 7px;
cursor:pointer;
border-top: 1px solid rgba(255, 255, 255, 0.5);
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
/*#sidedrawer .entry:after {

272
server/grabbers.js Normal file
View File

@ -0,0 +1,272 @@
/**
*
* User: Martin Donnelly
* Date: 2016-07-05
* Time: 15:01
*
*/
'use strict';
var cheerio = require('cheerio');
var log4js = require('log4js');
var logger = log4js.getLogger();
var STRING = require('string');
var URL = require('url');
var converter = require('html-to-markdown');
function cleaner(b) {
var _b = b;
var unwanted = [
'LINK',
'META',
'TITLE',
'div#disqus_thread',
'SCRIPT',
'FOOTER',
'div.ssba',
'.shareaholic-canvas',
'.yarpp-related',
'div.dfad',
'div.postFooterShare',
'div#nextPrevLinks',
'.post-comments',
'HEADER',
'.post-title',
'#side-menu',
'.footer-container',
'#pre-footer',
'#cakephp-global-navigation',
'.masthead',
'.breadcrumb-header',
'.single-recipe-sidebar',
'#recipe-related-videos',
'#tnav',
'.footer',
'#tb-wrapper',
'#comments',
'#menu',
'aside',
'#ad-mpu-premium-1-mobile',
'#recipetools',
'.adsense-ads-separator',
'.comments',
'.related-content',
'.tip-wrapper',
'#recipe-related-video-mobile',
'.float-wrapper',
'.source-jamie',
'.ad.mobile',
'.foodity-wrapper',
'#ad-most-watched-mobile',
'#sticky',
'.nutrition-expand',
'.grid-list-wrapper',
'#recipe-finder__box',
'.browser-upgrade-alert-message',
'.main-menu',
'.recipe-media',
'.method-mobile-prompt-wrapper',
'.sharebox-wrapper',
'.jumbotron',
'.slideshow',
'.top-cat-recipe',
'.analytic-box',
'.recipe-reviews',
'.recipe-tools',
'.promo-module',
'.widgettitle',
'.post_related'
];
for (var i = 0; i < unwanted.length; i++) {
_b.find(unwanted[i]).remove();
}
return _b;
}
exports = module.exports = {
doBBCGoodFood: function(body, url) {
logger.info('GRABBING BBCGoodFood');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV#main-content');
logger.debug('Length:' , tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug('Title: ', title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
var s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
},
doEngadget: function(body, url) {
logger.info('GRABBING Engadget');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV#page_body');
logger.debug('Length:' , tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug('Title: ', title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
let s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
},
doAndroidDeveloper: function(body, url) {
logger.info('GRABBING AndroidDeveloper');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV.jd-descr');
logger.debug(tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug(title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
let s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
},
doReddit: function(body, url) {
logger.info('GRABBING REDDIT');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV.entry');
tdihbody.find('A.thumbnail').each(function(i, elem) {
logger.warn($(this));
});
logger.info('++++++');
// Logger.debug(tdihbody.html());
logger.debug(tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug(title);
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
};

View File

@ -8,7 +8,7 @@ var http = require('http'), request = require('request'), cheerio = require(
var jsonfile = require('jsonfile'), fs = require('fs'), STRING = require(
'string');
var converter = require('html-to-markdown');
var markdown = require( "markdown" ).markdown;
var markdown = require('markdown').markdown;
var zlib = require('zlib');
var log4js = require('log4js');
var logger = log4js.getLogger();
@ -18,13 +18,19 @@ var router = express.Router();
var EventEmitter = require('events');
//var nano = require('nano')('http://localhost:5984');
var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984');
var nano = require('nano')('http://localhost:5984');
//var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984');
var busEmitter = new EventEmitter();
var db_name = 'recipes';
var dbCouch = nano.use(db_name);
var Keeper = require('./keeperService')(busEmitter);
console.log(Keeper);
var grabbers = require('./grabbers');
console.log(grabbers);
var jsonFile = __dirname + '/' + 'output.json';
var bodyfile = __dirname + '/' + 'body.html';
var htmlfile = __dirname + '/' + 'testoutput.html';
@ -40,28 +46,25 @@ var generics = [
var specialHandlers = [{
url: 'www.reddit.com', fn: function(body, url) {
return doReddit(body, url);
return grabbers.doReddit(body, url);
}
},
{
url: 'developer.android.com', fn: function(body, url) {
return doAndroidDeveloper(body, url);
return grabbers.doAndroidDeveloper(body, url);
}
},
{
url: 'www.engadget.com', fn: function(body, url) {
return doEngadget(body, url);
return grabbers.doEngadget(body, url);
}
}
,
{
url: 'www.bbcgoodfood.com', fn: function(body, url) {
return doBBCGoodFood(body, url);
return grabbers.doBBCGoodFood(body, url);
}
}
];
@ -117,7 +120,20 @@ function cleaner(b) {
'#recipe-finder__box',
'.browser-upgrade-alert-message',
'.main-menu',
'.recipe-media'
'.recipe-media',
'.method-mobile-prompt-wrapper',
'.sharebox-wrapper',
'.jumbotron',
'.slideshow',
'.top-cat-recipe',
'.analytic-box',
'.recipe-reviews',
'.recipe-tools',
'.promo-module',
'.widgettitle',
'.post_related'
@ -260,195 +276,6 @@ busEmitter.on('saveTagsDB', doSaveTagsDB);
busEmitter.on('saveNew', doSaveNew);
function doBBCGoodFood(body, url) {
logger.info('GRABBING BBCGoodFood');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV#main-content');
logger.debug('Length:' , tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug('Title: ', title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
let s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
function doEngadget(body, url) {
logger.info('GRABBING Engadget');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV#page_body');
logger.debug('Length:' , tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug('Title: ', title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
let s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
function doAndroidDeveloper(body, url) {
logger.info('GRABBING AndroidDeveloper');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV.jd-descr');
logger.debug(tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug(title);
urlObj = URL.parse(url);
urlPrefix = urlObj.protocol + '//' + urlObj.host + '/';
try {
tdihbody.find('IMG').each(function(i, elem) {
let s, src = $(this).attr('src');
if (src !== null) {
if (!STRING(src).startsWith('http')) {
logger.debug('Stripping:' + src);
src = urlPrefix + STRING(src).stripLeft('/').trim().s;
}
if (typeof obj.thumbnail === 'undefined') {
obj.thumbnail = src;
}
s = 'http://image.silvrtree.co.uk/900,fit/' + src;
$(this).attr('src', s);
}
});
}
catch (e) {
logger.error(e);
}
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
function doReddit(body, url) {
logger.info('GRABBING REDDIT');
var obj = {}, tdihbody, i, urlObj, urlPrefix;
var $ = cheerio.load(body);
var title = $('TITLE').text();
tdihbody = $('DIV.entry');
tdihbody.find('A.thumbnail').each(function(i, elem) {
logger.warn($(this));
});
logger.info('++++++');
// Logger.debug(tdihbody.html());
logger.debug(tdihbody.length);
tdihbody = cleaner(tdihbody);
logger.debug(title);
obj.url = STRING(url).trim().s;
obj.html = $.html();
obj.reduced = STRING(tdihbody.html()).trim().s;
obj.nib = STRING(tdihbody.text()).collapseWhitespace().trim().left(300).s;
obj.title = STRING(title).collapseWhitespace().s;
obj.markdown = converter.convert(obj.reduced);
return obj;
}
function saveNew(obj) {
logger.info('Saving new page');
@ -692,167 +519,27 @@ router.get('/pocket', function(req, res) {
router.get('/list', function(req, res) {
logger.debug('list..');
dbCouch.view('titles', 'titles', function(err, body) {
if (!err) {
var outJSON = [];
body.rows.forEach(function(doc) {
outJSON.push({id: doc.id, title: doc.value});
});
//Logger.debug(util.inspect(body));
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify({list: outJSON}));
} else {
res.writeHead(500, {ContentType: 'application/json'});
res.end(JSON.stringify({}));
}
});
Keeper.listGET({},res);
});
router.get('/entry/:id', function(req, res) {
logger.debug('entry..');
logger.debug(req.params.id);
dbCouch.get(req.params.id, function(err, body) {
if (!err) {
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = body.tags || {solid: '', list: []};
//Logger.debug(util.inspect(body));
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify(outJSON));
} else {
res.writeHead(500, {ContentType: 'application/json'});
res.end(JSON.stringify({}));
}
});
Keeper.entryIdGET(req.params, res);
});
router.route('/tags')
.get(function(req, res, next) {
logger.debug('tag list..');
logger.debug(req.params.id);
dbCouch.view('taglist', 'taglist', function(err, body) {
if (!err) {
logger.debug(body);
var outJSON = [];
body.rows.forEach(function(doc) {
logger.info(doc.value.taglist);
if (doc.value[0] == req.params.id) {
outJSON = doc.value.taglist.sort();
}
});
//Logger.debug(util.inspect(body));
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify({list: outJSON}));
} else {
logger.error(err);
res.writeHead(500, {ContentType: 'application/json'});
res.end(JSON.stringify({}));
}
});
Keeper.tagsGET(req.params, res);
}).post(function(req, res, next) {
var t = req.body;
console.log(t);
logger.info('regetting:' + req.body._id);
dbCouch.get(req.body._id, function(err, body) {
if (!err) {
var obj = {};
obj.url = body.url;
obj.html = body.html;
obj.reduced = body.reduced;
obj.title = body.title;
obj.tags = req.body.tags;
logger.info('Updating...');
busEmitter.emit('updateBookmarkData', obj, body._id, body._rev, res);
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = req.body.tags;
//Logger.debug(util.inspect(body));
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify(outJSON));
} else {
res.writeHead(500, {ContentType: 'application/json'});
res.end(JSON.stringify({}));
}
});
Keeper.tagsPOST(req.body,res);
});
router.get('/tags/:id', function(req, res) {
logger.debug('entry..');
logger.debug(req.params.id);
dbCouch.view('getTagByKey', 'getTagByKey', function(err, body) {
if (!err) {
// Logger.debug(body);
var outJSON = [];
body.rows.forEach(function(doc) {
// Logger.debug(doc);
if (doc.value[0] == req.params.id) {
outJSON.push({id: doc.id, title: doc.value[1]})
}
});
//Logger.debug(util.inspect(body));
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify({list: outJSON}));
} else {
logger.error(err);
res.writeHead(500, {ContentType: 'application/json'});
res.end(JSON.stringify({}));
}
});
Keeper.tagsIDGET(req.params, res);
});
router.post('/add', function(req, res) {
logger.debug('add entry..');
var t = req.body;
if (t.hasOwnProperty('url')) {
var url = JSON.parse(t.url.toString());
logger.debug(url);
busEmitter.emit('getBookmark', t);
} else {
logger.error('No data block!');
}
res.writeHead(200, {ContentType: 'application/json'});
res.end(JSON.stringify({adding: url}));
Keeper.addPOST(req.body, res);
});
router.post('/savenew', function(req, res) {

179
server/keeperService.js Normal file
View File

@ -0,0 +1,179 @@
/**
*
* User: Martin Donnelly
* Date: 2016-07-05
* Time: 15:01
*
*/
var log4js = require('log4js');
var logger = log4js.getLogger();
var nano = require('nano')('http://localhost:5984');
var db_name = 'recipes';
var dbCouch = nano.use(db_name);
var busEmitter = null;
var keeperService;
module.exports = exports = keeperService = function setBus(cfg) {
'use strict';
busEmitter = cfg;
console.log(busEmitter);
var core = {};
core.listGET = function(args, res) {
logger.debug('list..');
dbCouch.view('titles', 'titles', function(err, body) {
if (!err) {
var outJSON = [];
body.rows.forEach(function(doc) {
outJSON.push({id: doc.id, title: doc.value});
});
//Logger.debug(util.inspect(body));
res.status(200).json({list: outJSON});
} else {
res.status(500).json({});
}
});
};
core.entryIdGET = function(args, res) {
logger.debug('entry..');
logger.debug(args.id);
dbCouch.get(args.id, function(err, body) {
if (!err) {
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = body.tags || {solid: '', list: []};
res.status(200).json(outJSON);
} else {
logger.error(err);
res.status(500).json({});
}
});
};
core.tagsGET = function(args, res) {
logger.debug('tag list..');
logger.debug(args.id);
dbCouch.view('get', 'taglist', function(err, body) {
if (!err) {
logger.debug(body);
var outJSON = [];
body.rows.forEach(function(doc) {
logger.info(doc.value.taglist);
if (doc.value[0] === args.id) {
outJSON = doc.value.taglist.sort();
}
});
res.status(200).json({list: outJSON});
} else {
logger.error(err);
res.status(500).json({});
}
});
};
core.tagsPOST = function(args, res) {
console.log(args);
logger.info('regetting:' + args._id);
dbCouch.get(args._id, function(err, body) {
if (!err) {
var obj = {};
obj.url = body.url;
obj.html = body.html;
obj.reduced = body.reduced;
obj.title = body.title;
obj.tags = args.tags;
logger.info('Updating...');
busEmitter.emit('updateBookmarkData', obj, body._id, body._rev, res);
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = args.tags;
//Logger.debug(util.inspect(body));
res.status(200).json(outJSON);
} else {
logger.error(err);
res.status(500).json({});
}
});
};
core.tagsIDGET = function(args, res) {
logger.debug('entry..');
logger.debug(args.id);
dbCouch.view('getTagByKey', 'getTagByKey', function(err, body) {
if (!err) {
var outJSON = [];
body.rows.forEach(function(doc) {
if (doc.value[0] == args.id) {
outJSON.push({id: doc.id, title: doc.value[1]});
}
});
res.status(200).json({list: outJSON});
} else {
logger.error(err);
res.status(500).json({});
}
});
};
core.addPOST = function(args, res) {
var url;
logger.debug('add entry..');
if (args.hasOwnProperty('url')) {
url = JSON.parse(args.url.toString());
logger.debug(url);
busEmitter.emit('getBookmark', args);
} else {
logger.error('No data block!');
}
res.status(200).json({adding: url});
};
return core;
};

139
server/mdtest.js Normal file
View File

@ -0,0 +1,139 @@
/**
*
* User: Martin Donnelly
* Date: 2016-07-05
* Time: 15:01
*
*/
var log4js = require('log4js');
var logger = log4js.getLogger();
var nano = require('nano')('http://localhost:5984');
var db_name = 'recipes';
var dbCouch = nano.use(db_name);
var busEmitter = null;
var keeperService;
module.exports = exports = keeperService = function setBus(cfg) {
'use strict';
busEmitter = cfg;
console.log(busEmitter);
var core = {};
core.listGET = function(args, res) {
logger.debug('list..');
dbCouch.view('titles', 'titles', function(err, body) {
if (!err) {
var outJSON = [];
body.rows.forEach(function(doc) {
outJSON.push({id: doc.id, title: doc.value});
});
//Logger.debug(util.inspect(body));
res.status(200).json({list: outJSON});
} else {
res.status(500).json({});
}
});
};
core.entryIdGET = function(args, res) {
logger.debug('entry..');
logger.debug(args.id);
dbCouch.get(args.id, function(err, body) {
if (!err) {
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = body.tags || {solid: '', list: []};
res.status(200).json(outJSON);
} else {
res.status(500).json({}); }
});
};
core.tagsGET = function(args, res) {
logger.debug('tag list..');
logger.debug(args.id);
dbCouch.view('taglist', 'taglist', function(err, body) {
if (!err) {
logger.debug(body);
var outJSON = [];
body.rows.forEach(function(doc) {
logger.info(doc.value.taglist);
if (doc.value[0] === args.id) {
outJSON = doc.value.taglist.sort();
}
});
res.status(200).json({list: outJSON});
} else {
logger.error(err);
res.status(500).json({});
}
});
};
core.tagsPOST = function(args, res) {
console.log(args);
logger.info('regetting:' + args._id);
dbCouch.get(args._id, function(err, body) {
if (!err) {
var obj = {};
obj.url = body.url;
obj.html = body.html;
obj.reduced = body.reduced;
obj.title = body.title;
obj.tags = args.tags;
logger.info('Updating...');
busEmitter.emit('updateBookmarkData', obj, body._id, body._rev, res);
var outJSON = {};
outJSON._id = body._id;
outJSON._rev = body._rev;
outJSON.title = body.title;
outJSON.reduced = body.reduced;
outJSON.url = body.url;
outJSON.tags = args.tags;
//Logger.debug(util.inspect(body));
res.status(200).json(outJSON);
} else {
res.status(500).json({}); }
});
};
return core;
};

View File

@ -1,7 +1,7 @@
var nano = require('nano')('http://localhost:5984');
var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984');
var logger = require('log4js').getLogger();
var db_name = 'keeper';
var db_name = 'recipes';
var keeper = nano.use(db_name);
keeper.insert({type:1,taglist:[]}, function(error, response) {
if (error) {
@ -10,4 +10,4 @@ keeper.insert({type:1,taglist:[]}, function(error, response) {
else {
logger.info(response);
}
});
});