1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-27 23:28:38 +02:00

Merge branch 'master' of github.com:laurent22/joplin

This commit is contained in:
Laurent Cozic
2018-11-13 22:38:32 +00:00
6 changed files with 68 additions and 6 deletions

View File

@ -58,6 +58,10 @@ class InteropService {
format: 'raw',
target: 'directory',
description: _('Joplin Export Directory'),
}, {
format: 'json',
target: 'directory',
description: _('Json Export Directory'),
}, {
format: 'md',
target: 'directory',

View File

@ -0,0 +1,30 @@
const InteropService_Exporter_Base = require('lib/services/InteropService_Exporter_Base');
const { basename, filename } = require('lib/path-utils.js');
const { shim } = require('lib/shim');
class InteropService_Exporter_Json extends InteropService_Exporter_Base {
async init(destDir) {
this.destDir_ = destDir;
this.resourceDir_ = destDir ? destDir + '/resources' : null;
await shim.fsDriver().mkdir(this.destDir_);
await shim.fsDriver().mkdir(this.resourceDir_);
}
async processItem(ItemClass, item) {
const fileName = ItemClass.systemPath(item, "json");
const filePath = this.destDir_ + '/' + fileName;
const serialized = JSON.stringify(item);
await shim.fsDriver().writeFile(filePath, serialized, 'utf-8');
}
async processResource(resource, filePath) {
const destResourcePath = this.resourceDir_ + '/' + basename(filePath);
await shim.fsDriver().copy(filePath, destResourcePath);
}
async close() {}
}
module.exports = InteropService_Exporter_Json;