diff --git a/app/pocket.html b/app/pocket.html new file mode 100644 index 0000000..cb64ddd --- /dev/null +++ b/app/pocket.html @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Keeper Silvtree + + + +
+
+

Image is 100 x 80

+ +
+ +
+ + + diff --git a/gulpfile.js b/gulpfile.js index d19a1f9..7790850 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -30,8 +30,7 @@ gulp.task('scripts', function() { /*.pipe(rename({suffix: '.min'}))*/ .pipe(concat('app.js')) /*.pipe(uglify({mangle: false}))*/ - .pipe(gulp.dest('dist/js')) - .pipe(notify({ message: 'Scripts task complete' })); + .pipe(gulp.dest('dist/js')); }); gulp.task('styles', function() { @@ -41,8 +40,7 @@ gulp.task('styles', function() { /*.pipe(rename({suffix: '.min'}))*/ .pipe(cssnano()) .pipe(concat('app.css')) - .pipe(gulp.dest('dist/css')) - .pipe(notify({ message: 'Styles task complete' })); + .pipe(gulp.dest('dist/css')); }); gulp.task('partials', function() { @@ -75,4 +73,4 @@ gulp.task('clean', function() { gulp.task('default', ['clean'], function() { gulp.start('styles', 'scripts','partials','index'); -}); \ No newline at end of file +}); diff --git a/keeper-server.js b/keeper-server.js index 5c4cd4a..d07fd79 100644 --- a/keeper-server.js +++ b/keeper-server.js @@ -17,7 +17,7 @@ app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: true })); app.use(cookieParser()); -app.use(express.static(path.join(__dirname, 'dist'))); +app.use(express.static(path.join(__dirname, 'app'))); app.use('/', keeper); diff --git a/server/keeper.js b/server/keeper.js index 4f2d6d1..fbf5e13 100644 --- a/server/keeper.js +++ b/server/keeper.js @@ -22,6 +22,7 @@ var busEmitter = new EventEmitter(); var db_name = 'keeper'; var dbCouch = nano.use(db_name); +var jsonFile = __dirname + '/' + 'output.json'; var bodyfile = __dirname + '/' + 'body.html'; var htmlfile = __dirname + '/' + 'testoutput.html'; var generics = [ @@ -132,8 +133,6 @@ var doUpdateTagsDB = () => { dbCouch.view('getAllTags', 'getAllTags', function (err, body) { var masterList = []; if (!err) { - - var outJSON = []; body.rows.forEach(function (doc) { masterList = masterList.concat(doc.value); @@ -151,7 +150,7 @@ logger.debug(body); body.rows.forEach(function (doc) { doSaveTagsDB(doc.value,masterList); - }) + }); } else { @@ -171,7 +170,6 @@ logger.debug(body); var doSaveTagsDB = (orig, newList) => { logger.debug('doSaveTagsDB'); - // logger.info('sendSocket: ' + JSON.stringify(obj)); var _obj = orig; @@ -232,13 +230,21 @@ function processBody(body, url, _id, _rev) { urlObj = URL.parse(url); urlPrefix = urlObj.protocol + '//' + urlObj.host + '/'; + obj.host = urlObj.host; try { tdihbody.find('IMG').each(function (i, elem) { let s, src = $(this).attr("src"); if (!STRING(src).startsWith('http')) { - src = urlPrefix + STRING(src).stripLeft('/').s; + 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); @@ -249,11 +255,16 @@ function processBody(body, url, _id, _rev) { logger.error(e); } - obj.url = url; + 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; + + jsonfile.writeFile(jsonFile, obj, function (err) { console.error(err); }); + + if (_id !== null) { busEmitter.emit("updateBookmarkData", obj, _id, _rev); } @@ -345,7 +356,7 @@ router.get('/list', function (req, res) { var outJSON = []; body.rows.forEach(function (doc) { - outJSON.push({id: doc.id, title: doc.value}) + outJSON.push({id: doc.id, title: doc.value}); }); //logger.debug(util.inspect(body));