1
0
mirror of /repos/Prototyper.git synced 2025-12-30 06:31:32 +01:00

code cleanup

This commit is contained in:
Aiko Mastboom 2013-04-27 10:21:45 +02:00
parent c926ec56b2
commit 0cadac6dca
3 changed files with 10 additions and 5 deletions

View File

@ -5,7 +5,7 @@ var path = require('path');
var fs = require('fs');
module.exports = function (config, mongoInstance, shareModel) {
module.exports = function (config, mongoInstance) {
var import_leftovers_tag = 'import_leftovers__([A-Za-z0-9]+)_([A-Za-z0-9]+)_([A-Za-z0-9]+)';
var import_leftovers_regexp = new RegExp(helpers.marker_prefix + import_leftovers_tag + helpers.marker_postfix);
@ -164,11 +164,15 @@ module.exports = function (config, mongoInstance, shareModel) {
delete data._id;
}
_.extend(parent_result, data);
return mongoInstance.setMongoContent(parent_result, context, function (err, result) {
return mongoInstance.setMongoContent(parent_result, context, function (err) {
if (err) {
config.errors && console.log('ERR importer.importRemainder setMongoContent', err);
return callback(err);
}
var documentId = 'json:' + context.collection + ':' + context.name;
var keys = _.keys(parent_result); // reset all attributes;
return mongoInstance.updateShareDocument(documentId, parent_result, keys, function () {
return replaceWithEmptyContent(err);
return replaceWithEmptyContent(null);
});
});
} else {

View File

@ -292,7 +292,7 @@ module.exports = function (db, shareModel, config) {
});
return shareModel.applyOp(documentId, { op: ops, v: doc.v }, function (err, result) {
if (err) {
config.errors && console.log('ERR setMongoAttribute createShareDocument shareModel.applyOp', documentId, err);
config.errors && console.log('WARN setMongoAttribute createShareDocument shareModel.applyOp', documentId, err);
return callback && callback();
}
config.debug && console.log('createShareDocument shareModel.applyOp', documentId, ops, err, result);

View File

@ -291,6 +291,7 @@ module.exports = function (app, db, config) {
var attribute_parts = options.query.name.split('.');
var markdownTag = 'markdown__' + options.collection + '_' + attribute_parts[0] + '_' + attribute_parts[1];
//var markdownDocument=helpers.marker_prefix + markdownTag + helpers.marker_postfix;
// TODO: remove hardcoded marker
var markdownDocument = '<!-- @@' + markdownTag + ' -->';
return previewInstance.getPreviewHTML(markdownDocument, { req: options.req },
responder(options, res, next)
@ -328,7 +329,7 @@ module.exports = function (app, db, config) {
}
);
var importerInstance = importer(config, mongoDataInstance, model);
var importerInstance = importer(config, mongoDataInstance);
route = config.api.importer + '/:filename';
app.get(route, function importFile(req, res, next) {