mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
single file export working, tar WIP
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
const nativeTarExportService = require('../../services/export/native_tar');
|
||||
const markdownTarExportService = require('../../services/export/markdown_tar');
|
||||
const markdownSingleExportService = require('../../services/export/markdown_single');
|
||||
const tarExportService = require('../../services/export/tar');
|
||||
const singleExportService = require('../../services/export/single');
|
||||
const opmlExportService = require('../../services/export/opml');
|
||||
const repository = require("../../services/repository");
|
||||
|
||||
async function exportNote(req, res) {
|
||||
// entityId maybe either noteId or branchId depending on format
|
||||
const entityId = req.params.entityId;
|
||||
const type = req.params.type;
|
||||
const format = req.params.format;
|
||||
async function exportBranch(req, res) {
|
||||
const {branchId, type, format} = req.params;
|
||||
const branch = await repository.getBranch(branchId);
|
||||
|
||||
if (type === 'tar') {
|
||||
await nativeTarExportService.exportToTar(await repository.getBranch(entityId), format, res);
|
||||
if (type === 'subtree' && (format === 'html' || format === 'markdown')) {
|
||||
await tarExportService.exportToTar(branch, format, res);
|
||||
}
|
||||
// else if (format === 'tar') {
|
||||
// await markdownTarExportService.exportToMarkdown(await repository.getBranch(entityId), res);
|
||||
// }
|
||||
// export single note without subtree
|
||||
else if (format === 'markdown-single') {
|
||||
await markdownSingleExportService.exportSingleMarkdown(await repository.getNote(entityId), res);
|
||||
else if (type === 'single') {
|
||||
await singleExportService.exportSingleNote(branch, format, res);
|
||||
}
|
||||
else if (format === 'opml') {
|
||||
await opmlExportService.exportToOpml(await repository.getBranch(entityId), res);
|
||||
await opmlExportService.exportToOpml(branch, res);
|
||||
}
|
||||
else {
|
||||
return [404, "Unrecognized export format " + format];
|
||||
@@ -31,5 +24,5 @@ async function exportNote(req, res) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
exportNote
|
||||
exportBranch
|
||||
};
|
||||
Reference in New Issue
Block a user