mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
chore(server): different handling of buffer vs string
This commit is contained in:
parent
58a883797d
commit
979ef6287f
@ -123,7 +123,9 @@ export function buildRewardMap(note: BNote) {
|
|||||||
|
|
||||||
if (note.type === "text" && note.isDecrypted) {
|
if (note.type === "text" && note.isDecrypted) {
|
||||||
const content = note.getContent();
|
const content = note.getContent();
|
||||||
const dom = parse(content.toString());
|
if (typeof content !== "string") return map;
|
||||||
|
|
||||||
|
const dom = parse(content);
|
||||||
|
|
||||||
const addHeadingsToRewardMap = (elName: string, rewardFactor: number) => {
|
const addHeadingsToRewardMap = (elName: string, rewardFactor: number) => {
|
||||||
for (const el of dom.querySelectorAll(elName)) {
|
for (const el of dom.querySelectorAll(elName)) {
|
||||||
|
@ -257,11 +257,8 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
|
|||||||
|
|
||||||
const excerpts: string[] = [];
|
const excerpts: string[] = [];
|
||||||
|
|
||||||
console.log("Removing images")
|
|
||||||
removeImages(document);
|
removeImages(document);
|
||||||
|
|
||||||
console.log("Querying links");
|
|
||||||
|
|
||||||
for (const linkEl of document.querySelectorAll("a")) {
|
for (const linkEl of document.querySelectorAll("a")) {
|
||||||
console.log("Got ", linkEl.innerHTML);
|
console.log("Got ", linkEl.innerHTML);
|
||||||
const href = linkEl.getAttribute("href");
|
const href = linkEl.getAttribute("href");
|
||||||
@ -275,7 +272,6 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
|
|||||||
let centerEl: HTMLElement = linkEl;
|
let centerEl: HTMLElement = linkEl;
|
||||||
|
|
||||||
while (centerEl.tagName !== "BODY" && centerEl.parentNode && (centerEl.parentNode?.textContent?.length || 0) <= EXCERPT_CHAR_LIMIT) {
|
while (centerEl.tagName !== "BODY" && centerEl.parentNode && (centerEl.parentNode?.textContent?.length || 0) <= EXCERPT_CHAR_LIMIT) {
|
||||||
console.log("Got ", centerEl.tagName, centerEl.parentNode);
|
|
||||||
centerEl = centerEl.parentNode;
|
centerEl = centerEl.parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +367,6 @@ function getBacklinks(req: Request): BacklinksResponse {
|
|||||||
let backlinksWithExcerptCount = 0;
|
let backlinksWithExcerptCount = 0;
|
||||||
|
|
||||||
return getFilteredBacklinks(note).map((backlink) => {
|
return getFilteredBacklinks(note).map((backlink) => {
|
||||||
console.log("Processing ", backlink);
|
|
||||||
const sourceNote = backlink.note;
|
const sourceNote = backlink.note;
|
||||||
|
|
||||||
if (sourceNote.type !== "text" || backlinksWithExcerptCount > 50) {
|
if (sourceNote.type !== "text" || backlinksWithExcerptCount > 50) {
|
||||||
|
@ -66,7 +66,8 @@ function renderIndex(result: Result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderText(result: Result, note: SNote) {
|
function renderText(result: Result, note: SNote) {
|
||||||
const document = parse(result.content?.toString() || "");
|
if (typeof result.content !== "string") return;
|
||||||
|
const document = parse(result.content || "");
|
||||||
|
|
||||||
// Process include notes.
|
// Process include notes.
|
||||||
for (const includeNoteEl of document.querySelectorAll("section.include-note")) {
|
for (const includeNoteEl of document.querySelectorAll("section.include-note")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user