mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
getting rid of note complement WIP
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
const becca = require("../../becca/becca");
|
||||
const NotFoundError = require("../../errors/not_found_error");
|
||||
const utils = require("../../services/utils");
|
||||
const blobService = require("../../services/blob.js");
|
||||
|
||||
function getAttachmentBlob(req) {
|
||||
const full = req.query.full === 'true';
|
||||
|
||||
return blobService.getBlobPojo('attachments', req.params.attachmentId, { full });
|
||||
}
|
||||
|
||||
function getAttachments(req) {
|
||||
const includeContent = req.query.includeContent === 'true';
|
||||
@@ -87,6 +94,7 @@ function convertAttachmentToNote(req) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAttachmentBlob,
|
||||
getAttachments,
|
||||
getAttachment,
|
||||
saveAttachment,
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const beccaService = require('../../becca/becca_service');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const noteRevisionService = require('../../services/note_revisions');
|
||||
const utils = require('../../services/utils');
|
||||
const sql = require('../../services/sql');
|
||||
const cls = require('../../services/cls');
|
||||
const path = require('path');
|
||||
const becca = require("../../becca/becca");
|
||||
const blobService = require("../../services/blob.js");
|
||||
|
||||
function getNoteRevisionBlob(req) {
|
||||
const full = req.query.full === 'true';
|
||||
|
||||
return blobService.getBlobPojo('note_revisions', req.params.noteRevisionId, { full });
|
||||
}
|
||||
|
||||
function getNoteRevisions(req) {
|
||||
return becca.getNoteRevisionsFromQuery(`
|
||||
@@ -20,10 +26,11 @@ function getNoteRevisions(req) {
|
||||
}
|
||||
|
||||
function getNoteRevision(req) {
|
||||
// FIXME
|
||||
const noteRevision = becca.getNoteRevision(req.params.noteRevisionId);
|
||||
|
||||
if (noteRevision.type === 'file') {
|
||||
if (noteRevision.isStringNote()) {
|
||||
if (noteRevision.hasStringContent()) {
|
||||
noteRevision.content = noteRevision.getContent().substr(0, 10000);
|
||||
}
|
||||
}
|
||||
@@ -180,6 +187,7 @@ function getNotePathData(note) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getNoteRevisionBlob,
|
||||
getNoteRevisions,
|
||||
getNoteRevision,
|
||||
downloadNoteRevision,
|
||||
|
||||
@@ -10,20 +10,20 @@ const fs = require('fs');
|
||||
const becca = require("../../becca/becca");
|
||||
const ValidationError = require("../../errors/validation_error");
|
||||
const NotFoundError = require("../../errors/not_found_error");
|
||||
const blobService = require("../../services/blob");
|
||||
|
||||
function getNote(req) {
|
||||
const noteId = req.params.noteId;
|
||||
const note = becca.getNote(noteId);
|
||||
|
||||
const note = becca.getNote(req.params.noteId);
|
||||
if (!note) {
|
||||
throw new NotFoundError(`Note '${noteId}' has not been found.`);
|
||||
throw new NotFoundError(`Note '${req.params.noteId}' has not been found.`);
|
||||
}
|
||||
|
||||
const pojo = note.getPojo();
|
||||
|
||||
if (note.isStringNote()) {
|
||||
if (note.hasStringContent()) {
|
||||
pojo.content = note.getContent();
|
||||
|
||||
// FIXME: use blobs instead
|
||||
if (note.type === 'file' && pojo.content.length > 10000) {
|
||||
pojo.content = `${pojo.content.substr(0, 10000)}\r\n\r\n... and ${pojo.content.length - 10000} more characters.`;
|
||||
}
|
||||
@@ -39,6 +39,12 @@ function getNote(req) {
|
||||
return pojo;
|
||||
}
|
||||
|
||||
function getNoteBlob(req) {
|
||||
const full = req.query.full === 'true';
|
||||
|
||||
return blobService.getBlobPojo('notes', req.params.noteId, { full });
|
||||
}
|
||||
|
||||
function createNote(req) {
|
||||
const params = Object.assign({}, req.body); // clone
|
||||
params.parentNoteId = req.params.parentNoteId;
|
||||
@@ -259,6 +265,7 @@ function convertNoteToAttachment(req) {
|
||||
|
||||
module.exports = {
|
||||
getNote,
|
||||
getNoteBlob,
|
||||
updateNoteData,
|
||||
deleteNote,
|
||||
undeleteNote,
|
||||
|
||||
Reference in New Issue
Block a user