Merge remote-tracking branch 'origin/master'

This commit is contained in:
Martin Donnelly 2016-03-23 10:29:07 +00:00
commit d6f2248cd1
6 changed files with 132 additions and 80 deletions

View File

@ -16,7 +16,7 @@
<input type="text" id="edittags" name="edittags" value="<%=data.tags.solid%>">
</span>
<button class="mui-button" id="tagSave">Save</button>
<button class="mui-btn" id="tagSave">Save</button>
</span>
</span>
</span>

View File

@ -10,7 +10,7 @@
"script": "keeper-server.js",
"cwd": "/var/www/keeper",
"watch": true,
"max_restarts": 64,
"ignore_watch" : ["node_modules"],
"merge_logs" : true,
"autorestart" : true,
"restart_delay" : 3500,

View File

@ -144,7 +144,7 @@ var doUpdateTagsDB = () => {
});
dbCouch.view('taglist', 'taglist', function (err, body) {
logger.debug(body);
if (!err) {
var outJSON = {};
@ -155,7 +155,7 @@ var doUpdateTagsDB = () => {
}
else {
logger.error('NO TAG LIST EXISTS');
}
});
@ -401,7 +401,7 @@ router.get('/tags', function (req, res) {
logger.info(doc.value.taglist);
if (doc.value[0]==req.params.id)
{
outJSON = doc.value.taglist;
outJSON = doc.value.taglist.sort();
}
});

View File

@ -38,39 +38,7 @@ nano.db.destroy('keeper', function () {
console.log("_design/reducedView added");
});
keeper.insert(
{
"views": {
"taglist": {
"map": function (doc) { if (doc.type == 1) { emit(null, doc); } }
}}
}, '_design/taglist', function (error, response) {
console.log("_design/taglist added");
});
keeper.insert(
{
"views": {
"getAllTags": {
"map": function (doc) { if (doc.tags.list.length > 0) { emit(null, doc.tags.list); } }
}}
}, '_design/getAllTags', function (error, response) {
console.log("_design/getAllTags added");
});
keeper.insert(
{
"views": {
"getAllTags": {
"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]); } } }
}
}}
}, '_design/getTagByKey', function (error, response) {
console.log("_design/getTagByKey added");
});
});
});
@ -79,4 +47,14 @@ nano.db.destroy('keeper', function () {
*/
{
"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]);
}
}
}
}
}

13
server/seedtags.js Normal file
View File

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

View File

@ -1,56 +1,117 @@
var nano = require('nano')('http://localhost:5984');
var logger = require('log4js').getLogger();
var db_name = 'keeper';
var keeper = nano.use(db_name);
keeper.insert(
{
"views": {
"taglist": {
"map": function (doc) { if (doc.type == 1) { emit(null, doc); } }
var tableList = [
{
name: '_design/titles', view: {
"titles": {
"map": function(doc) { emit(null, doc.title); }
}
}
}
, {
name: '_design/reducedView', view: {
"reducedView": {
"map": function(doc) { emit(null, [doc.title, doc.reduced]); }
}
}
}, {
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);
}
}
}
}, '_design/taglist', function (error, response) {
if (error) {
console.log(error);
} else
{
console.log("_design/taglist added");
}
});
keeper.insert(
{
"views": {
"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]);
}
}
}
}
}
}
];
var killTable = (table) =>
{
console.log(table.name);
keeper.get(table.name, {revs_info: true}, function(err, body) {
if (err)
console.log(err);
if (typeof body !== 'undefined') {
keeper.destroy(table.name, body._rev, function(_err, _body) {
if (err) {
console.log(_err);
}
}, '_design/getAllTags', function (error, response) {
if (error) {
console.log(error);
} else
{
console.log("_design/getAllTags added");
else {
console.log(table.name + ' deleted');
console.log(_body);
}
});
}
});
};
});
var updateTable = (table) =>
{
logger.info(table.name);
keeper.get(table.name, {revs_info: true}, function(err, body) {
if (err)
logger.error(body);
keeper.insert(
{
"views": {
"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]); } } }
if (typeof body !== 'undefined') {
logger.debug(body);
keeper.insert({_id: body._id, _rev: body._rev, views: table.view},
function(_err, _body) {
if (err) {
logger.error(_err);
}
}
}, '_design/getTagByKey', function (error, response) {
if (error) {
console.log(error);
} else
{
console.log("_design/getTagByKey added");
}
else {
logger.info(table.name + ' updated');
logger.info(_body);
});
}
});
}
else {
keeper.insert({
"views": table.view
}, table.name, function(error, response) {
if (error) {
logger.error(error);
}
else {
logger.info(response);
}
});
}
});
};
for (var t = 0; t < tableList.length; t++) {
updateTable(tableList[t]);
}