Markdown editor improvements

This commit is contained in:
NGPixel
2016-09-10 22:53:21 -04:00
parent 492bb9efa6
commit 97602b51c8
160 changed files with 558 additions and 123 deletions

View File

@@ -387,9 +387,29 @@ module.exports = {
let self = this;
if(_.isEmpty(entryPath) || entryPath === 'home') {
return Promise.reject(new Error('Invalid path!'));
}
return git.moveDocument(entryPath, newEntryPath).then(() => {
return git.commitDocument(newEntryPath).then(() => {
// Delete old cache version
let oldEntryCachePath = self.getCachePath(entryPath);
fs.unlinkAsync(oldEntryCachePath).catch((err) => { return true; });
// Delete old index entry
ws.emit('searchDel', {
auth: WSInternalKey,
entryPath
});
// Create cache for new entry
return self.updateCache(newEntryPath);
});
});

View File

@@ -111,28 +111,7 @@ module.exports = {
let self = this;
return self._si.searchAsync({
query: {
AND: [{ 'entryPath': [content.entryPath] }]
}
}).then((results) => {
if(results.totalHits > 0) {
let delIds = _.map(results.hits, 'id');
return self._si.delAsync(delIds);
} else {
return true;
}
}).catch((err) => {
if(err.type === 'NotFoundError') {
return true;
} else {
winston.error(err);
}
}).then(() => {
return self.delete(content.entryPath).then(() => {
return self._si.addAsync({
entryPath: content.entryPath,
@@ -179,6 +158,41 @@ module.exports = {
winston.error(err);
});
},
/**
* Delete an entry from the index
*
* @param {String} The entry path
* @return {Promise} Promise of the operation
*/
delete(entryPath) {
let self = this;
return self._si.searchAsync({
query: {
AND: [{ 'entryPath': [entryPath] }]
}
}).then((results) => {
if(results.totalHits > 0) {
let delIds = _.map(results.hits, 'id');
return self._si.delAsync(delIds);
} else {
return true;
}
}).catch((err) => {
if(err.type === 'NotFoundError') {
return true;
} else {
winston.error(err);
}
});
}
};