You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-24 23:26:50 +02:00
Merge branch 'master' of github.com:laurent22/joplin
This commit is contained in:
@ -75,9 +75,14 @@ class BaseItem extends BaseModel {
|
||||
return r.total;
|
||||
}
|
||||
|
||||
static systemPath(itemOrId) {
|
||||
if (typeof itemOrId === 'string') return itemOrId + '.md';
|
||||
return itemOrId.id + '.md';
|
||||
static systemPath(itemOrId, extension = null) {
|
||||
if (extension === null)
|
||||
extension = 'md';
|
||||
|
||||
if (typeof itemOrId === 'string')
|
||||
return itemOrId + '.' + extension;
|
||||
else
|
||||
return itemOrId.id + '.' + extension;
|
||||
}
|
||||
|
||||
static isSystemPath(path) {
|
||||
|
@ -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',
|
||||
|
@ -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;
|
@ -238,7 +238,7 @@ function shimInit() {
|
||||
host: url.hostname,
|
||||
port: url.port,
|
||||
method: method,
|
||||
path: url.path + (url.query ? '?' + url.query : ''),
|
||||
path: url.pathname + (url.query ? '?' + url.query : ''),
|
||||
headers: headers,
|
||||
};
|
||||
|
||||
@ -316,4 +316,4 @@ function shimInit() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = { shimInit };
|
||||
module.exports = { shimInit };
|
||||
|
Reference in New Issue
Block a user