mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server: Address requested changes
This commit is contained in:
parent
45bf75b864
commit
3aa38b998a
@ -7,7 +7,7 @@ import { Request, Response } from 'express';
|
|||||||
import BNote from "../../becca/entities/bnote.js";
|
import BNote from "../../becca/entities/bnote.js";
|
||||||
import BRevision from "../../becca/entities/brevision.js";
|
import BRevision from "../../becca/entities/brevision.js";
|
||||||
import { AppRequest } from '../route-interface';
|
import { AppRequest } from '../route-interface';
|
||||||
import resource_dir from "../../services/resource_dir.js";
|
import { RESOURCE_DIR } from "../../services/resource_dir.js";
|
||||||
|
|
||||||
function returnImageFromNote(req: Request, res: Response) {
|
function returnImageFromNote(req: Request, res: Response) {
|
||||||
const image = becca.getNote(req.params.noteId);
|
const image = becca.getNote(req.params.noteId);
|
||||||
@ -24,7 +24,7 @@ function returnImageFromRevision(req: Request, res: Response) {
|
|||||||
function returnImageInt(image: BNote | BRevision | null, res: Response) {
|
function returnImageInt(image: BNote | BRevision | null, res: Response) {
|
||||||
if (!image) {
|
if (!image) {
|
||||||
res.set('Content-Type', 'image/png');
|
res.set('Content-Type', 'image/png');
|
||||||
return res.send(fs.readFileSync(`${resource_dir.RESOURCE_DIR}/db/image-deleted.png`));
|
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
|
||||||
} else if (!["image", "canvas", "mermaid"].includes(image.type)) {
|
} else if (!["image", "canvas", "mermaid"].includes(image.type)) {
|
||||||
return res.sendStatus(400);
|
return res.sendStatus(400);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ function returnAttachedImage(req: Request, res: Response) {
|
|||||||
|
|
||||||
if (!attachment) {
|
if (!attachment) {
|
||||||
res.set('Content-Type', 'image/png');
|
res.set('Content-Type', 'image/png');
|
||||||
return res.send(fs.readFileSync(`${resource_dir.RESOURCE_DIR}/db/image-deleted.png`));
|
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!["image"].includes(attachment.role)) {
|
if (!["image"].includes(attachment.role)) {
|
||||||
|
@ -20,7 +20,7 @@ import AttachmentMeta from "../meta/attachment_meta.js";
|
|||||||
import AttributeMeta from "../meta/attribute_meta.js";
|
import AttributeMeta from "../meta/attribute_meta.js";
|
||||||
import BBranch from "../../becca/entities/bbranch.js";
|
import BBranch from "../../becca/entities/bbranch.js";
|
||||||
import { Response } from 'express';
|
import { Response } from 'express';
|
||||||
import resource_dir from "../resource_dir.js";
|
import { RESOURCE_DIR } from "../resource_dir.js";
|
||||||
|
|
||||||
async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "html" | "markdown", res: Response | fs.WriteStream, setHeaders = true) {
|
async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "html" | "markdown", res: Response | fs.WriteStream, setHeaders = true) {
|
||||||
if (!['html', 'markdown'].includes(format)) {
|
if (!['html', 'markdown'].includes(format)) {
|
||||||
@ -473,7 +473,7 @@ ${markdownContent}`;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function saveCss(rootMeta: NoteMeta, cssMeta: NoteMeta) {
|
function saveCss(rootMeta: NoteMeta, cssMeta: NoteMeta) {
|
||||||
const cssContent = fs.readFileSync(`${resource_dir.RESOURCE_DIR}/libraries/ckeditor/ckeditor-content.css`);
|
const cssContent = fs.readFileSync(`${RESOURCE_DIR}/libraries/ckeditor/ckeditor-content.css`);
|
||||||
|
|
||||||
archive.append(cssContent, { name: cssMeta.dataFileName });
|
archive.append(cssContent, { name: cssMeta.dataFileName });
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import log from "./log.js";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
const RESOURCE_DIR = path.resolve(__dirname, "../..");
|
export const RESOURCE_DIR = path.resolve(__dirname, "../..");
|
||||||
|
|
||||||
// where the "trilium" executable is
|
// where the "trilium" executable is
|
||||||
const ELECTRON_APP_ROOT_DIR = path.resolve(RESOURCE_DIR, "../..");
|
const ELECTRON_APP_ROOT_DIR = path.resolve(RESOURCE_DIR, "../..");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user