mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 15:06:21 +02:00
chore(standalone): addres requested changes
This commit is contained in:
@@ -259,7 +259,6 @@ function bootstrapRoute(): BootstrapDefinition {
|
||||
if (!isDbInitialized) {
|
||||
return {
|
||||
...commonItems,
|
||||
isStandalone: true,
|
||||
baseApiUrl: "../api/",
|
||||
isProtectedSessionAvailable: false,
|
||||
};
|
||||
|
||||
@@ -15,13 +15,13 @@ function buildDescendantCountMap(noteIdsToCount: string[]) {
|
||||
throw new Error("noteIdsToCount: type error");
|
||||
}
|
||||
|
||||
const noteIdToCountMap = Object.create(null);
|
||||
const noteIdToCountMap: Record<string, number> = Object.create(null);
|
||||
|
||||
function getCount(noteId: string) {
|
||||
function getCount(noteId: string): number {
|
||||
if (!(noteId in noteIdToCountMap)) {
|
||||
const note = becca.getNote(noteId);
|
||||
if (!note) {
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const hiddenImageNoteIds = note.getRelations("imageLink").map((rel) => rel.value);
|
||||
@@ -258,7 +258,6 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
|
||||
removeImages(document);
|
||||
|
||||
for (const linkEl of document.querySelectorAll("a")) {
|
||||
console.log("Got ", linkEl.innerHTML);
|
||||
const href = linkEl.getAttribute("href");
|
||||
|
||||
if (!href || !href.endsWith(referencedNoteId)) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import becca from "../becca/becca";
|
||||
import BNote from "../becca/entities/bnote";
|
||||
import protected_session from "../services/protected_session";
|
||||
import BAttachment from "../becca/entities/battachment";
|
||||
import { utils } from "..";
|
||||
import { getContentDisposition } from "../services/utils/index";
|
||||
|
||||
export function downloadNoteInt(noteId: string, res: Response, contentDisposition = true) {
|
||||
const note = becca.getNote(noteId);
|
||||
@@ -23,7 +23,7 @@ export function downloadData(noteOrAttachment: BNote | BAttachment, res: Respons
|
||||
if (contentDisposition) {
|
||||
const fileName = noteOrAttachment.getFileName();
|
||||
|
||||
res.setHeader("Content-Disposition", utils.getContentDisposition(fileName));
|
||||
res.setHeader("Content-Disposition", getContentDisposition(fileName));
|
||||
}
|
||||
|
||||
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
||||
|
||||
@@ -6,6 +6,7 @@ import optionService from "./options";
|
||||
import { getCurrentLocale } from "./i18n";
|
||||
import attributes from "./attributes";
|
||||
import BNote from "../becca/entities/bnote";
|
||||
import { getPlatform } from "./platform";
|
||||
|
||||
export default function getSharedBootstrapItems(assetPath: string, dbInitialized: boolean) {
|
||||
const sql = getSql();
|
||||
@@ -20,7 +21,6 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitialized
|
||||
layoutOrientation: "vertical" as const,
|
||||
headingStyle: "plain" as const,
|
||||
componentId: "",
|
||||
appCssNoteIds: getAppCssNoteIds(),
|
||||
...getIconConfig(assetPath)
|
||||
};
|
||||
|
||||
@@ -29,7 +29,8 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitialized
|
||||
return {
|
||||
...commonItems,
|
||||
themeCssUrl: false as const,
|
||||
themeUseNextAsBase: "next" as const
|
||||
themeUseNextAsBase: "next" as const,
|
||||
appCssNoteIds: []
|
||||
};
|
||||
}
|
||||
|
||||
@@ -46,6 +47,7 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitialized
|
||||
isProtectedSessionAvailable: protected_session.isProtectedSessionAvailable(),
|
||||
themeCssUrl: getThemeCssUrl(theme, commonItems.assetPath, themeNote) as string | false,
|
||||
themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") as "next" | "next-light" | "next-dark",
|
||||
appCssNoteIds: getAppCssNoteIds(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +83,7 @@ function getThemeCssUrl(theme: string, assetPath: string, themeNote: BNote | nul
|
||||
return `${assetPath}/stylesheets/theme-next-light.css`;
|
||||
} else if (theme === "next-dark") {
|
||||
return `${assetPath}/stylesheets/theme-next-dark.css`;
|
||||
} else if (!process.env.TRILIUM_SAFE_MODE && themeNote) {
|
||||
} else if (!getPlatform().getEnv("TRILIUM_SAFE_MODE") && themeNote) {
|
||||
return `api/notes/download/${themeNote.noteId}`;
|
||||
}
|
||||
// baseline light theme
|
||||
|
||||
@@ -505,19 +505,19 @@ describe.todo("#getResourceDir", () => {});
|
||||
|
||||
describe("#isElectron", () => {
|
||||
it("should export a boolean", () => {
|
||||
expect(utils.isElectron).toBeTypeOf("boolean");
|
||||
expect(utils.isElectron()).toBeTypeOf("boolean");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#isMac", () => {
|
||||
it("should export a boolean", () => {
|
||||
expect(utils.isMac).toBeTypeOf("boolean");
|
||||
expect(utils.isMac()).toBeTypeOf("boolean");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#isWindows", () => {
|
||||
it("should export a boolean", () => {
|
||||
expect(utils.isWindows).toBeTypeOf("boolean");
|
||||
expect(utils.isWindows()).toBeTypeOf("boolean");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ export function stringToInt(val: string | undefined) {
|
||||
* @returns An array of patterns to match both with and without trailing slash
|
||||
*/
|
||||
export function normalizeCustomHandlerPattern(pattern: string | null | undefined): (string | null | undefined)[] {
|
||||
if (!pattern || typeof pattern !== 'string') {
|
||||
if (!pattern || typeof pattern !== "string") {
|
||||
return [pattern];
|
||||
}
|
||||
|
||||
@@ -287,32 +287,32 @@ export function normalizeCustomHandlerPattern(pattern: string | null | undefined
|
||||
}
|
||||
|
||||
// If pattern already ends with optional trailing slash, return as-is
|
||||
if (pattern.endsWith('/?$') || pattern.endsWith('/?)')) {
|
||||
if (pattern.endsWith("/?$") || pattern.endsWith("/?)")) {
|
||||
return [pattern];
|
||||
}
|
||||
|
||||
// If pattern ends with $, handle it specially
|
||||
if (pattern.endsWith('$')) {
|
||||
if (pattern.endsWith("$")) {
|
||||
const basePattern = pattern.slice(0, -1);
|
||||
|
||||
// If already ends with slash, create both versions
|
||||
if (basePattern.endsWith('/')) {
|
||||
const withoutSlash = `${basePattern.slice(0, -1) }$`;
|
||||
if (basePattern.endsWith("/")) {
|
||||
const withoutSlash = `${basePattern.slice(0, -1)}$`;
|
||||
const withSlash = pattern;
|
||||
return [withoutSlash, withSlash];
|
||||
}
|
||||
// Add optional trailing slash
|
||||
const withSlash = `${basePattern }/?$`;
|
||||
const withSlash = `${basePattern}/?$`;
|
||||
return [withSlash];
|
||||
|
||||
}
|
||||
|
||||
// For patterns without $, add both versions
|
||||
if (pattern.endsWith('/')) {
|
||||
if (pattern.endsWith("/")) {
|
||||
const withoutSlash = pattern.slice(0, -1);
|
||||
return [withoutSlash, pattern];
|
||||
}
|
||||
const withSlash = `${pattern }/`;
|
||||
const withSlash = `${pattern}/`;
|
||||
return [pattern, withSlash];
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user