mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Address requested changes
This commit is contained in:
parent
1ac65fff47
commit
a66e4435ba
@ -9,14 +9,13 @@ import cls = require('./cls');
|
|||||||
import entityChangesService = require('./entity_changes');
|
import entityChangesService = require('./entity_changes');
|
||||||
import optionsService = require('./options');
|
import optionsService = require('./options');
|
||||||
import BBranch = require('../becca/entities/bbranch');
|
import BBranch = require('../becca/entities/bbranch');
|
||||||
import revisionService = require('./revisions');
|
|
||||||
import becca = require('../becca/becca');
|
import becca = require('../becca/becca');
|
||||||
import utils = require('../services/utils');
|
import utils = require('../services/utils');
|
||||||
import eraseService = require('../services/erase');
|
import eraseService = require('../services/erase');
|
||||||
import sanitizeAttributeName = require('./sanitize_attribute_name');
|
import sanitizeAttributeName = require('./sanitize_attribute_name');
|
||||||
import noteTypesService = require('../services/note_types');
|
import noteTypesService = require('../services/note_types');
|
||||||
import { BranchRow, NoteRow } from '../becca/entities/rows';
|
import { BranchRow } from '../becca/entities/rows';
|
||||||
import { EntityChange, EntityRow } from './entity_changes_interface';
|
import { EntityChange } from './entity_changes_interface';
|
||||||
const noteTypes = noteTypesService.getNoteTypeNames();
|
const noteTypes = noteTypesService.getNoteTypeNames();
|
||||||
|
|
||||||
class ConsistencyChecks {
|
class ConsistencyChecks {
|
||||||
|
@ -7,7 +7,7 @@ import importUtils = require('./utils');
|
|||||||
function renderToHtml(content: string, title: string) {
|
function renderToHtml(content: string, title: string) {
|
||||||
const html = marked.parse(content, {
|
const html = marked.parse(content, {
|
||||||
async: false
|
async: false
|
||||||
}) as string; // FIXME: mangle and headerIds does not seem to exist in marked
|
}) as string;
|
||||||
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
|
const h1Handled = importUtils.handleH1(html, title); // h1 handling needs to come before sanitization
|
||||||
return htmlSanitizer.sanitize(h1Handled);
|
return htmlSanitizer.sanitize(h1Handled);
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,7 @@ import mimeService = require('./mime');
|
|||||||
import utils = require('../../services/utils');
|
import utils = require('../../services/utils');
|
||||||
import importUtils = require('./utils');
|
import importUtils = require('./utils');
|
||||||
import htmlSanitizer = require('../html_sanitizer');
|
import htmlSanitizer = require('../html_sanitizer');
|
||||||
|
import { File } from "./common";
|
||||||
interface File {
|
|
||||||
originalname: string;
|
|
||||||
mimetype: string;
|
|
||||||
buffer: string | Buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
function importSingleFile(taskContext: TaskContext, file: File, parentNote: BNote) {
|
function importSingleFile(taskContext: TaskContext, file: File, parentNote: BNote) {
|
||||||
const mime = mimeService.getMime(file.originalname) || file.mimetype;
|
const mime = mimeService.getMime(file.originalname) || file.mimetype;
|
||||||
|
@ -35,8 +35,8 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
|||||||
// path => noteId, used only when meta file is not available
|
// path => noteId, used only when meta file is not available
|
||||||
/** path => noteId | attachmentId */
|
/** path => noteId | attachmentId */
|
||||||
const createdPaths: Record<string, string> = { '/': importRootNote.noteId, '\\': importRootNote.noteId };
|
const createdPaths: Record<string, string> = { '/': importRootNote.noteId, '\\': importRootNote.noteId };
|
||||||
let metaFile!: MetaFile;
|
let metaFile: MetaFile | null = null;
|
||||||
let firstNote!: BNote;
|
let firstNote: BNote | null = null;
|
||||||
const createdNoteIds = new Set<string>();
|
const createdNoteIds = new Set<string>();
|
||||||
|
|
||||||
function getNewNoteId(origNoteId: string) {
|
function getNewNoteId(origNoteId: string) {
|
||||||
@ -99,7 +99,7 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
|||||||
dataFileName: ""
|
dataFileName: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
let parent!: NoteMeta;
|
let parent: NoteMeta | undefined = undefined;
|
||||||
|
|
||||||
for (const segment of pathSegments) {
|
for (const segment of pathSegments) {
|
||||||
if (!cursor?.children?.length) {
|
if (!cursor?.children?.length) {
|
||||||
@ -590,6 +590,10 @@ async function importZip(taskContext: TaskContext, fileBuffer: Buffer, importRoo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!firstNote) {
|
||||||
|
throw new Error("Unable to determine first note.");
|
||||||
|
}
|
||||||
|
|
||||||
return firstNote;
|
return firstNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ export interface CookieJar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ExecOpts {
|
export interface ExecOpts {
|
||||||
proxy: "noproxy" | string | null;
|
proxy: string | null;
|
||||||
method: string;
|
method: string;
|
||||||
url: string;
|
url: string;
|
||||||
paging?: {
|
paging?: {
|
||||||
|
@ -12,7 +12,6 @@ import AbstractBeccaEntity = require('../becca/entities/abstract_becca_entity');
|
|||||||
import env = require('./env');
|
import env = require('./env');
|
||||||
import { IncomingMessage, Server } from 'http';
|
import { IncomingMessage, Server } from 'http';
|
||||||
import { EntityChange } from './entity_changes_interface';
|
import { EntityChange } from './entity_changes_interface';
|
||||||
import { TaskData } from './task_context_interface';
|
|
||||||
|
|
||||||
if (env.isDev()) {
|
if (env.isDev()) {
|
||||||
const chokidar = require('chokidar');
|
const chokidar = require('chokidar');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user