diff --git a/app/gfx/fm.png b/app/gfx/fm.png new file mode 100644 index 0000000..f77b34d Binary files /dev/null and b/app/gfx/fm.png differ diff --git a/app/pocket.html b/app/pocket.html index cb64ddd..0b44104 100644 --- a/app/pocket.html +++ b/app/pocket.html @@ -40,105 +40,70 @@ Keeper Silvtree
-
-

Image is 100 x 80

- -
- -
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 4f43dec..88e7670 100644 --- a/server/keeper.js +++ b/server/keeper.js @@ -557,6 +557,43 @@ function genericGrab(obj, res) { }); } +router.get('/pocket', function (req, res) { + logger.debug('list..'); + + + dbCouch.view('pocketList', 'pocketList', function (err, body) { + if (!err) { + + var outJSON = []; + body.rows.forEach(function (doc) { + var obj = {id: doc.id, entry: doc.value}; +console.log(typeof obj.entry.tn); + if (typeof obj.entry.tn === 'string') { + console.log('its a string:', typeof obj.entry.tn) + obj.entry.tn = 'http://image.silvrtree.co.uk/100,fit,q80/' + obj.entry.tn; + } + else { + obj.entry.tn = 'gfx/fm.png'; + } + + outJSON.push(obj); + + + }); + + logger.debug(util.inspect(body)); + logger.info(util.inspect(outJSON)); + res.render('pocket', {data: outJSON}); + } + else { + res.writeHead(500, {"ContentType": "application/json"}); + res.end(JSON.stringify({})); + } + }); +}); + + + router.get('/list', function (req, res) { logger.debug('list..'); diff --git a/server/maker.js b/server/maker.js index 61e7cfa..019769f 100644 --- a/server/maker.js +++ b/server/maker.js @@ -46,6 +46,7 @@ nano.db.destroy('keeper', function () { * Created by Martin on 02/03/2016. */ +/* { "getTagByKey": { @@ -58,3 +59,4 @@ nano.db.destroy('keeper', function () { } } } +*/ diff --git a/server/viewinsert.js b/server/viewinsert.js index da8b089..ae00b43 100644 --- a/server/viewinsert.js +++ b/server/viewinsert.js @@ -22,34 +22,46 @@ var tableList = [ }, { name: '_design/taglist', view: { "taglist": { - "map": function(doc) { if (doc.type == 1) { emit(null, doc); } } - } - }}, { - name: '_design/getAllTags', view: { - "getAllTags": { - "map": function(doc) { - if (doc.tags.list.length > 0) { - emit(null, doc.tags.list); - } - } - } + "map": function(doc) { if (doc.type == 1) { emit(null, doc); } } + } } }, { - name: '_design/getTagByKey', view:{ + name: '_design/getAllTags', view: { + "getAllTags": { + "map": function(doc) { + if (doc.tags.list.length > 0) { + emit(null, doc.tags.list); + } + } + } + } + }, { + name: '_design/getTagByKey', view: { "getTagByKey": { - "map": function(doc) { - if (doc.tags.list.length > 0) { - for (var t = 0; t < doc.tags.list.length; t++) { - emit(doc._id, [doc.tags.list[t], doc.title]); - } - } + "map": function(doc) { + if (doc.tags.list.length > 0) { + for (var t = 0; t < doc.tags.list.length; t++) { + emit(doc._id, [doc.tags.list[t], doc.title]); } + } + } + } } + }, + + + { + name: '_design/pocketList', view: { + "pocketList": { + "map":function (doc) { emit(doc._id, {'host':doc.host, 'tn':doc.thumbnail, 'title':doc.title, 'nib':doc.nib, 'tags':doc.tags}); } + } + } } - } + + + ]; -var killTable = (table) => -{ +var killTable = (table) => { console.log(table.name); keeper.get(table.name, {revs_info: true}, function(err, body) { @@ -72,8 +84,7 @@ var killTable = (table) => }); }; -var updateTable = (table) => -{ +var updateTable = (table) => { logger.info(table.name); keeper.get(table.name, {revs_info: true}, function(err, body) { @@ -84,16 +95,16 @@ var updateTable = (table) => logger.debug(body); keeper.insert({_id: body._id, _rev: body._rev, views: table.view}, - function(_err, _body) { - if (err) { - logger.error(_err); - } - else { - logger.info(table.name + ' updated'); - logger.info(_body); + function(_err, _body) { + if (err) { + logger.error(_err); + } + else { + logger.info(table.name + ' updated'); + logger.info(_body); - } - }); + } + }); } else { diff --git a/views/pocket.ejs b/views/pocket.ejs new file mode 100644 index 0000000..127cee7 --- /dev/null +++ b/views/pocket.ejs @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Keeper Silvtree + + + + + + + + +
+ + <% for(var i=0; i + +
+
+
+
+ +
+
+ <%= data[i].entry.nib %> +
+
+ <%= data[i].entry.host %> +
+
+ <%= data[i].entry.tags %> +
+
+
+
+
+ + + + + + + + + + + + + + <% } %> + + + + + + + +
+ +