mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
Script API changes, finished porting reddit plugin, reddit importer tar file
This commit is contained in:
@@ -9,7 +9,8 @@ const BUILTIN_ATTRIBUTES = [
|
||||
'run_on_startup',
|
||||
'disable_versioning',
|
||||
'calendar_root',
|
||||
'hide_in_autocomplete'
|
||||
'hide_in_autocomplete',
|
||||
'exclude_from_export'
|
||||
];
|
||||
|
||||
async function getNoteAttributeMap(noteId) {
|
||||
|
||||
@@ -84,6 +84,9 @@ async function createNewNote(parentNoteId, noteOpts, dataKey, sourceId) {
|
||||
}
|
||||
|
||||
async function createNote(parentNoteId, title, content = "", extraOptions = {}) {
|
||||
if (!parentNoteId) throw new Error("Empty parentNoteId");
|
||||
if (!title) throw new Error("Empty title");
|
||||
|
||||
const note = {
|
||||
title: title,
|
||||
content: extraOptions.json ? JSON.stringify(content, null, '\t') : content,
|
||||
|
||||
@@ -2,15 +2,24 @@ const log = require('./log');
|
||||
const protected_session = require('./protected_session');
|
||||
const notes = require('./notes');
|
||||
const sql = require('./sql');
|
||||
const utils = require('./utils');
|
||||
const attributes = require('./attributes');
|
||||
const date_notes = require('./date_notes');
|
||||
const config = require('./config');
|
||||
const Repository = require('./repository');
|
||||
const axios = require('axios');
|
||||
|
||||
function ScriptContext(dataKey) {
|
||||
dataKey = protected_session.getDataKey(dataKey);
|
||||
const repository = new Repository(dataKey);
|
||||
|
||||
this.axios = axios;
|
||||
|
||||
this.utils = {
|
||||
unescapeHtml: utils.unescapeHtml,
|
||||
isoDateTimeStr: utils.dateStr
|
||||
};
|
||||
|
||||
this.getInstanceName = () => config.General ? config.General.instanceName : null;
|
||||
|
||||
this.getNoteById = async function(noteId) {
|
||||
@@ -30,7 +39,7 @@ function ScriptContext(dataKey) {
|
||||
this.createNote = async function(parentNoteId, title, content = "", extraOptions = {}) {
|
||||
extraOptions.dataKey = dataKey;
|
||||
|
||||
notes.createNote(parentNoteId, title, content, extraOptions);
|
||||
return await notes.createNote(parentNoteId, title, content, extraOptions);
|
||||
};
|
||||
|
||||
this.createAttribute = attributes.createAttribute;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const crypto = require('crypto');
|
||||
const randtoken = require('rand-token').generator({source: 'crypto'});
|
||||
const unescape = require('unescape');
|
||||
|
||||
function newNoteId() {
|
||||
return randomString(12);
|
||||
@@ -129,6 +130,10 @@ async function stopWatch(what, func) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function unescapeHtml(str) {
|
||||
return unescape(str);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
randomSecureToken,
|
||||
randomString,
|
||||
@@ -153,5 +158,6 @@ module.exports = {
|
||||
getDateTimeForFile,
|
||||
sanitizeSql,
|
||||
assertArguments,
|
||||
stopWatch
|
||||
stopWatch,
|
||||
unescapeHtml
|
||||
};
|
||||
Reference in New Issue
Block a user