mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
renamed Help to User Guide
This commit is contained in:
parent
df47679c7f
commit
94dcaae12d
@ -71,8 +71,8 @@ const HIDDEN_SUBTREE_DEFINITION = {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '_help',
|
id: '_userGuide',
|
||||||
title: 'Help',
|
title: 'User Guide',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
icon: 'bx-help-circle'
|
icon: 'bx-help-circle'
|
||||||
},
|
},
|
||||||
|
@ -89,7 +89,7 @@ const defaultOptions = [
|
|||||||
{ name: 'minTocHeadings', value: '5', isSynced: true },
|
{ name: 'minTocHeadings', value: '5', isSynced: true },
|
||||||
{ name: 'checkForUpdates', value: 'true', isSynced: true },
|
{ name: 'checkForUpdates', value: 'true', isSynced: true },
|
||||||
{ name: 'disableTray', value: 'false', isSynced: false },
|
{ name: 'disableTray', value: 'false', isSynced: false },
|
||||||
{ name: 'helpSha256Hash', value: '', isSynced: true },
|
{ name: 'userGuideSha256Hash', value: '', isSynced: true },
|
||||||
];
|
];
|
||||||
|
|
||||||
function initStartupOptions() {
|
function initStartupOptions() {
|
||||||
|
@ -20,12 +20,12 @@ if (!fs.existsSync(MIGRATIONS_DIR)) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const HELP_ZIP_DIR = path.resolve(RESOURCE_DIR, "tmp");
|
const USER_GUIDE_ZIP_DIR = path.resolve(RESOURCE_DIR, "tmp");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
RESOURCE_DIR,
|
RESOURCE_DIR,
|
||||||
MIGRATIONS_DIR,
|
MIGRATIONS_DIR,
|
||||||
DB_INIT_DIR,
|
DB_INIT_DIR,
|
||||||
ELECTRON_APP_ROOT_DIR,
|
ELECTRON_APP_ROOT_DIR,
|
||||||
HELP_ZIP_DIR
|
USER_GUIDE_ZIP_DIR
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ const sql = require("./sql");
|
|||||||
const becca = require("../becca/becca");
|
const becca = require("../becca/becca");
|
||||||
const protectedSessionService = require("../services/protected_session");
|
const protectedSessionService = require("../services/protected_session");
|
||||||
const hiddenSubtreeService = require("./hidden_subtree");
|
const hiddenSubtreeService = require("./hidden_subtree");
|
||||||
const helpImportService = require("./help_import");
|
const helpImportService = require("./user_guide_import.js");
|
||||||
|
|
||||||
function getRunAtHours(note) {
|
function getRunAtHours(note) {
|
||||||
try {
|
try {
|
||||||
@ -55,7 +55,7 @@ sqlInit.dbReady.then(() => {
|
|||||||
cls.init(() => {
|
cls.init(() => {
|
||||||
hiddenSubtreeService.checkHiddenSubtree();
|
hiddenSubtreeService.checkHiddenSubtree();
|
||||||
|
|
||||||
helpImportService.importHelpIfNeeded();
|
helpImportService.importUserGuideIfNeeded();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!process.env.TRILIUM_SAFE_MODE) {
|
if (!process.env.TRILIUM_SAFE_MODE) {
|
||||||
|
@ -13,29 +13,29 @@ const yauzl = require("yauzl");
|
|||||||
const htmlSanitizer = require('./html_sanitizer');
|
const htmlSanitizer = require('./html_sanitizer');
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const options = require('./options');
|
const options = require('./options');
|
||||||
const {HELP_ZIP_DIR} = require('./resource_dir');
|
const {USER_GUIDE_ZIP_DIR} = require('./resource_dir');
|
||||||
|
|
||||||
async function importHelpIfNeeded() {
|
async function importUserGuideIfNeeded() {
|
||||||
const helpSha256HashInDb = options.getOption('helpSha256Hash');
|
const userGuideSha256HashInDb = options.getOption('userGuideSha256Hash');
|
||||||
let helpSha256HashInFile = await fs.readFile(HELP_ZIP_DIR + "/help.zip.sha256");
|
let userGuideSha256HashInFile = await fs.readFile(USER_GUIDE_ZIP_DIR + "/user-guide.zip.sha256");
|
||||||
|
|
||||||
if (!helpSha256HashInFile || helpSha256HashInFile.byteLength < 64) {
|
if (!userGuideSha256HashInFile || userGuideSha256HashInFile.byteLength < 64) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
helpSha256HashInFile = helpSha256HashInFile.toString().substr(0, 64);
|
userGuideSha256HashInFile = userGuideSha256HashInFile.toString().substr(0, 64);
|
||||||
|
|
||||||
if (helpSha256HashInDb === helpSha256HashInFile) {
|
if (userGuideSha256HashInDb === userGuideSha256HashInFile) {
|
||||||
// help file has been already imported and is up to date
|
// user guide ZIP file has been already imported and is up-to-date
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hiddenRoot = becca.getNote("_hidden");
|
const hiddenRoot = becca.getNote("_hidden");
|
||||||
const data = await fs.readFile(HELP_ZIP_DIR + "/" + "help.zip", "binary");
|
const data = await fs.readFile(USER_GUIDE_ZIP_DIR + "/user-guide.zip", "binary");
|
||||||
|
|
||||||
await importZip(Buffer.from(data, 'binary'), hiddenRoot);
|
await importZip(Buffer.from(data, 'binary'), hiddenRoot);
|
||||||
|
|
||||||
options.setOption('helpSha256Hash', helpSha256HashInFile);
|
options.setOption('userGuideSha256Hash', userGuideSha256HashInFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function importZip(fileBuffer, importRootNote) {
|
async function importZip(fileBuffer, importRootNote) {
|
||||||
@ -87,15 +87,15 @@ async function importZip(fileBuffer, importRootNote) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getNoteId(noteMeta) {
|
function getNoteId(noteMeta) {
|
||||||
let helpNoteId = noteMeta.attributes?.find(attr => attr.type === 'label' && attr.name === 'helpNoteId')?.value;
|
let userGuideNoteId = noteMeta.attributes?.find(attr => attr.type === 'label' && attr.name === 'helpNoteId')?.value;
|
||||||
|
|
||||||
helpNoteId = '_help' + noteMeta.title.replace(/[^a-z0-9]/ig, '');
|
userGuideNoteId = '_userGuide' + noteMeta.title.replace(/[^a-z0-9]/ig, '');
|
||||||
|
|
||||||
if (helpNoteId === '_helpHelp') {
|
if (noteMeta.title.trim() === 'User Guide') {
|
||||||
helpNoteId = '_help';
|
userGuideNoteId = '_userGuide';
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteId = helpNoteId || noteMeta.noteId;
|
const noteId = userGuideNoteId || noteMeta.noteId;
|
||||||
noteIdMap[noteMeta.noteId] = noteId;
|
noteIdMap[noteMeta.noteId] = noteId;
|
||||||
|
|
||||||
return noteId;
|
return noteId;
|
||||||
@ -394,7 +394,7 @@ async function importZip(fileBuffer, importRootNote) {
|
|||||||
metaFile = JSON.parse(entries.find(entry => entry.type === 'file' && entry.filePath === '!!!meta.json').content);
|
metaFile = JSON.parse(entries.find(entry => entry.type === 'file' && entry.filePath === '!!!meta.json').content);
|
||||||
|
|
||||||
sql.transactional(() => {
|
sql.transactional(() => {
|
||||||
deleteHelpSubtree();
|
deleteUserGuideSubtree();
|
||||||
|
|
||||||
for (const {type, filePath, content} of entries) {
|
for (const {type, filePath, content} of entries) {
|
||||||
if (type === 'directory') {
|
if (type === 'directory') {
|
||||||
@ -424,11 +424,11 @@ async function importZip(fileBuffer, importRootNote) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a special implementation of deleting the subtree, because we want to preserve the links to the help pages
|
* This is a special implementation of deleting the subtree, because we want to preserve the links to the user guide pages
|
||||||
* and clones.
|
* and clones.
|
||||||
*/
|
*/
|
||||||
function deleteHelpSubtree() {
|
function deleteUserGuideSubtree() {
|
||||||
const DELETE_ID = 'help';
|
const DELETE_ID = 'user-guide';
|
||||||
|
|
||||||
function remove(branch) {
|
function remove(branch) {
|
||||||
branch.markAsDeleted(DELETE_ID);
|
branch.markAsDeleted(DELETE_ID);
|
||||||
@ -444,7 +444,7 @@ function deleteHelpSubtree() {
|
|||||||
note.markAsDeleted(DELETE_ID)
|
note.markAsDeleted(DELETE_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(becca.getBranchFromChildAndParent('_help', '_hidden'));
|
remove(becca.getBranchFromChildAndParent('_userGuide', '_hidden'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {string} path without leading or trailing slash and backslashes converted to forward ones */
|
/** @returns {string} path without leading or trailing slash and backslashes converted to forward ones */
|
||||||
@ -491,5 +491,5 @@ function readZipFile(buffer, processEntryCallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
importHelpIfNeeded
|
importUserGuideIfNeeded
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user