Compare commits

...

11 Commits

Author SHA1 Message Date
arch
4f6161cd5b
Merge 5d5fd2079a110a41c89f5616df5c5277fe67bb4f into 64662d5215ea01f6634fd72b5ff7a77dbc7e9e7d 2025-12-01 14:34:17 +00:00
Adorian Doran
64662d5215 Merge branch 'main' of https://github.com/TriliumNext/Trilium
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Documentation / Build and Deploy Documentation (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run
2025-12-01 16:33:41 +02:00
Adorian Doran
31cedad976 documentation: mark "calendar:color" as deprecated 2025-12-01 16:33:31 +02:00
Elian Doran
12ac5147d3
Merge branch 'main' of github.com:TriliumNext/Trilium 2025-12-01 14:40:25 +02:00
Elian Doran
17291ff61d
chore(deps): remove unnecessary package 2025-12-01 14:34:55 +02:00
Adorian Doran
f3e334470e style: refactor 2025-12-01 14:27:49 +02:00
Adorian Doran
9407051f1e style: refactor 2025-12-01 14:24:13 +02:00
Adorian Doran
08a6d36153 style/calendar collection/list view: use separate style for the archived events 2025-12-01 14:13:23 +02:00
Adorian Doran
f906fb9b4c Merge branch 'main' of https://github.com/TriliumNext/Trilium 2025-12-01 14:08:32 +02:00
Adorian Doran
b4a6356724 style/calendar collection/list view: fix dot colors 2025-12-01 14:08:24 +02:00
x1arch
5d5fd2079a Fix share access to attachments for notes protected by login:password 2025-11-21 19:52:22 +00:00
12 changed files with 362 additions and 1244 deletions

2
.gitignore vendored
View File

@ -8,6 +8,7 @@ out-tsc
# dependencies # dependencies
node_modules node_modules
.pnpm-store
# IDEs and editors # IDEs and editors
/.idea /.idea
@ -18,6 +19,7 @@ node_modules
*.launch *.launch
.settings/ .settings/
*.sublime-workspace *.sublime-workspace
.devcontainer
# misc # misc
/.sass-cache /.sass-cache

View File

@ -146,6 +146,21 @@ Here's the language coverage we have so far:
### Code ### Code
General (OS / docker / podman, etc.) dependencies:
Debian
```
apt update
apt install -y build-essential python3 make g++ libsqlite3-dev
corepack enable
```
Alpine
```
apk add --no-cache build-base python3 python3-dev sqlite-dev
corepack enable
```
Download the repository, install dependencies using `pnpm` and then run the server (available at http://localhost:8080): Download the repository, install dependencies using `pnpm` and then run the server (available at http://localhost:8080):
```shell ```shell
git clone https://github.com/TriliumNext/Trilium.git git clone https://github.com/TriliumNext/Trilium.git
@ -154,6 +169,10 @@ pnpm install
pnpm run server:start pnpm run server:start
``` ```
> If you faced with some problems, try to delete all `node_modules` and `.pnpm-store` folders, not only from the root, from every directory, like `apps/{app_name}/node_modules`and `/packages/{package_name}/node_modules` and then reinstall it by the `pnpm install`.
Share styles not compiling by default, if you see share page without styles, make `pnpm run server:build` and then run development server.
### Documentation ### Documentation
Download the repository, install dependencies using `pnpm` and then run the environment required to edit the documentation: Download the repository, install dependencies using `pnpm` and then run the environment required to edit the documentation:

View File

@ -49,30 +49,6 @@
z-index: 50; z-index: 50;
} }
.calendar-container a.fc-event {
text-decoration: none;
}
.calendar-container a.fc-event.archived {
opacity: .65;
}
.calendar-container a.fc-event.archived::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
--c1: transparent;
--c2: var(--callendar-coll-event-archived-sripe-color);
background: repeating-linear-gradient(45deg, var(--c1), var(--c1) 8px,
var(--c2) 8px, var(--c2) 16px) !important;
}
.calendar-container .fc-button { .calendar-container .fc-button {
padding: 0.2em 0.5em; padding: 0.2em 0.5em;
} }
@ -113,15 +89,38 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
/* #region Events */ /* #region Events */
.calendar-view a.fc-timegrid-event, /*
.calendar-view a.fc-daygrid-event, * week, month, year views
.fc-daygrid-dot-event .fc-event-title { */
font-weight: 500;
.calendar-container a.fc-event {
text-decoration: none;
} }
.calendar-view a.fc-timegrid-event:focus-visible, .calendar-container a.fc-event.archived {
.calendar-view a.fc-daygrid-event:focus-visible { opacity: .65;
outline: none; }
.calendar-container a.fc-event.archived::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
--c1: transparent;
--c2: var(--callendar-coll-event-archived-sripe-color);
background: repeating-linear-gradient(45deg, var(--c1), var(--c1) 8px,
var(--c2) 8px, var(--c2) 16px);
}
.calendar-view a.fc-timegrid-event,
.calendar-view a.fc-daygrid-event,
.calendar-view .fc-daygrid-dot-event .fc-event-title {
font-weight: 500;
} }
.calendar-view a.fc-timegrid-event, .calendar-view a.fc-timegrid-event,
@ -137,6 +136,20 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
padding-left: 8px; padding-left: 8px;
} }
.calendar-view .fc-timegrid-event.with-hue,
.calendar-view .fc-daygrid-event.with-hue {
--fc-event-text-color: var(--custom-color);
--fc-event-bg-color: hsl(var(--custom-color-hue),
var(--calendar-coll-event-background-saturation),
var(--calendar-coll-event-background-lightness)) !important;
}
.calendar-view a.fc-timegrid-event:focus-visible,
.calendar-view a.fc-daygrid-event:focus-visible {
outline: none;
}
.calendar-view a.fc-timegrid-event.fc-event-selected, .calendar-view a.fc-timegrid-event.fc-event-selected,
.calendar-view a.fc-timegrid-event.fc-event:focus, .calendar-view a.fc-timegrid-event.fc-event:focus,
.calendar-view a.fc-daygrid-event.fc-event-selected, .calendar-view a.fc-daygrid-event.fc-event-selected,
@ -153,21 +166,26 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
opacity: 1; opacity: 1;
} }
.calendar-view .fc-timegrid-event.with-hue, .calendar-view .fc-daygrid-event-dot {
.calendar-view .fc-daygrid-event.with-hue { display: none;
--fc-event-text-color: var(--custom-color);
--fc-event-bg-color: hsl(var(--custom-color-hue),
var(--calendar-coll-event-background-saturation),
var(--calendar-coll-event-background-lightness)) !important;
} }
.calendar-view .fc-event-time { .calendar-view .fc-event-time {
opacity: .75; opacity: .75;
} }
.fc-daygrid-event-dot { /*
display: none; * List view
*/
.fc-list-table tr.fc-event.archived {
opacity: .5;
}
.fc-list-table .fc-list-event-dot {
/* Apply note colors to the list item dots */
--fc-event-border-color: var(--custom-color);
} }
/* #endregion */ /* #endregion */

View File

@ -40,6 +40,13 @@ interface Subroot {
type GetNoteFunction = (id: string) => SNote | BNote | null; type GetNoteFunction = (id: string) => SNote | BNote | null;
function addContentAccessQuery(note: SNote | BNote, secondEl?:boolean) {
if (!(note instanceof BNote) && note.contentAccessor && note.contentAccessor?.type === "query") {
return secondEl ? `&cat=${note.contentAccessor.getToken()}` : `?cat=${note.contentAccessor.getToken()}`;
}
return ""
}
function getSharedSubTreeRoot(note: SNote | BNote | undefined): Subroot { function getSharedSubTreeRoot(note: SNote | BNote | undefined): Subroot {
if (!note || note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) { if (!note || note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
// share root itself is not shared // share root itself is not shared
@ -111,7 +118,7 @@ export function renderNoteContent(note: SNote) {
cssToLoad.push(`assets/scripts.css`); cssToLoad.push(`assets/scripts.css`);
} }
for (const cssRelation of note.getRelations("shareCss")) { for (const cssRelation of note.getRelations("shareCss")) {
cssToLoad.push(`api/notes/${cssRelation.value}/download`); cssToLoad.push(`api/notes/${cssRelation.value}/download${addContentAccessQuery(note)}`);
} }
// Determine JS to load. // Determine JS to load.
@ -119,11 +126,11 @@ export function renderNoteContent(note: SNote) {
"assets/scripts.js" "assets/scripts.js"
]; ];
for (const jsRelation of note.getRelations("shareJs")) { for (const jsRelation of note.getRelations("shareJs")) {
jsToLoad.push(`api/notes/${jsRelation.value}/download`); jsToLoad.push(`api/notes/${jsRelation.value}/download${addContentAccessQuery(note)}`);
} }
const customLogoId = note.getRelation("shareLogo")?.value; const customLogoId = note.getRelation("shareLogo")?.value;
const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png` : `../${assetUrlFragment}/images/icon-color.svg`; const logoUrl = customLogoId ? `api/images/${customLogoId}/image.png${addContentAccessQuery(note)}` : `../${assetUrlFragment}/images/icon-color.svg`;
return renderNoteContentInternal(note, { return renderNoteContentInternal(note, {
subRoot, subRoot,
@ -133,7 +140,7 @@ export function renderNoteContent(note: SNote) {
logoUrl, logoUrl,
ancestors, ancestors,
isStatic: false, isStatic: false,
faviconUrl: note.hasRelation("shareFavicon") ? `api/notes/${note.getRelationValue("shareFavicon")}/download` : `../favicon.ico` faviconUrl: note.hasRelation("shareFavicon") ? `api/notes/${note.getRelationValue("shareFavicon")}/download${addContentAccessQuery(note)}` : `../favicon.ico`
}); });
} }
@ -158,6 +165,7 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
isEmpty, isEmpty,
assetPath: shareAdjustedAssetPath, assetPath: shareAdjustedAssetPath,
assetUrlFragment, assetUrlFragment,
addContentAccessQuery: (second: boolean | undefined) => addContentAccessQuery(note, second),
showLoginInShareTheme, showLoginInShareTheme,
t, t,
isDev, isDev,
@ -325,7 +333,7 @@ function renderText(result: Result, note: SNote | BNote) {
} }
if (href?.startsWith("#")) { if (href?.startsWith("#")) {
handleAttachmentLink(linkEl, href, getNote, getAttachment); handleAttachmentLink(linkEl, href, getNote, getAttachment, note);
} }
} }
@ -349,7 +357,7 @@ function renderText(result: Result, note: SNote | BNote) {
} }
} }
function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNoteFunction, getAttachment: (id: string) => BAttachment | SAttachment | null) { function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNoteFunction, getAttachment: (id: string) => BAttachment | SAttachment | null, note: SNote | BNote) {
const linkRegExp = /attachmentId=([a-zA-Z0-9_]+)/g; const linkRegExp = /attachmentId=([a-zA-Z0-9_]+)/g;
let attachmentMatch; let attachmentMatch;
if ((attachmentMatch = linkRegExp.exec(href))) { if ((attachmentMatch = linkRegExp.exec(href))) {
@ -357,7 +365,7 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNot
const attachment = getAttachment(attachmentId); const attachment = getAttachment(attachmentId);
if (attachment) { if (attachment) {
linkEl.setAttribute("href", `api/attachments/${attachmentId}/download`); linkEl.setAttribute("href", `api/attachments/${attachmentId}/download${addContentAccessQuery(note)}`);
linkEl.classList.add(`attachment-link`); linkEl.classList.add(`attachment-link`);
linkEl.classList.add(`role-${attachment.role}`); linkEl.classList.add(`role-${attachment.role}`);
linkEl.childNodes.length = 0; linkEl.childNodes.length = 0;
@ -430,7 +438,7 @@ function renderMermaid(result: Result, note: SNote | BNote) {
} }
result.content = ` result.content = `
<img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}"> <img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}${addContentAccessQuery(note, true)}">
<hr> <hr>
<details> <details>
<summary>Chart source</summary> <summary>Chart source</summary>
@ -439,14 +447,14 @@ function renderMermaid(result: Result, note: SNote | BNote) {
} }
function renderImage(result: Result, note: SNote | BNote) { function renderImage(result: Result, note: SNote | BNote) {
result.content = `<img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}">`; result.content = `<img src="api/images/${note.noteId}/${note.encodedTitle}?${note.utcDateModified}${addContentAccessQuery(note, true)}">`;
} }
function renderFile(note: SNote | BNote, result: Result) { function renderFile(note: SNote | BNote, result: Result) {
if (note.mime === "application/pdf") { if (note.mime === "application/pdf") {
result.content = `<iframe class="pdf-view" src="api/notes/${note.noteId}/view"></iframe>`; result.content = `<iframe class="pdf-view" src="api/notes/${note.noteId}/view${addContentAccessQuery(note)}"></iframe>`;
} else { } else {
result.content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download'">Download file</button>`; result.content = `<button type="button" onclick="location.href='api/notes/${note.noteId}/download${addContentAccessQuery(note)}'">Download file</button>`;
} }
} }

View File

@ -60,6 +60,20 @@ function checkNoteAccess(noteId: string, req: Request, res: Response) {
const header = req.header("Authorization"); const header = req.header("Authorization");
if (!header?.startsWith("Basic ")) { if (!header?.startsWith("Basic ")) {
if (req.path.startsWith("/share/api") && note.contentAccessor) {
let contentAccessToken = ""
if (note.contentAccessor.type === "cookie") contentAccessToken += req.cookies["trilium.cat"] || ""
else if (note.contentAccessor.type === "query") contentAccessToken += req.query['cat'] || ""
if (contentAccessToken){
if (note.contentAccessor.isTokenValid(contentAccessToken)){
return note
}
res.status(401).send("Access is expired. Return back and update the page.");
return false;
}
}
return false; return false;
} }
@ -124,9 +138,14 @@ function register(router: Router) {
return; return;
} }
if (note.isLabelTruthy("shareExclude")) {
res.status(404);
render404(res);
return;
}
if (!checkNoteAccess(note.noteId, req, res)) { if (!checkNoteAccess(note.noteId, req, res)) {
requestCredentials(res); requestCredentials(res);
return; return;
} }
@ -138,6 +157,10 @@ function register(router: Router) {
return; return;
} }
if (note.contentAccessor && note.contentAccessor.type === "cookie") {
res.cookie('trilium.cat', note.contentAccessor.getToken(), { maxAge: note.contentAccessor.getTokenExpiration() * 1000, httpOnly: true })
}
res.send(renderNoteContent(note)); res.send(renderNoteContent(note));
} }
@ -163,6 +186,9 @@ function register(router: Router) {
const { shareId } = req.params; const { shareId } = req.params;
const note = shaca.aliasToNote[shareId] || shaca.notes[shareId]; const note = shaca.aliasToNote[shareId] || shaca.notes[shareId];
if (note){
note.initContentAccessor()
}
renderNote(note, req, res); renderNote(note, req, res);
}); });

View File

@ -0,0 +1,81 @@
import crypto from "crypto";
import SNote from "./snote";
import utils from "../../../services/utils";
const DefaultAccessTimeoutSec = 10 * 60; // 10 minutes
export class ContentAccessor {
note: SNote;
token: string;
timestamp: number;
type: string;
timeout: number;
key: Buffer;
constructor(note: SNote) {
this.note = note;
this.key = crypto.randomBytes(32);
this.token = "";
this.timestamp = 0;
this.timeout = Number(this.note.getAttributeValue("label", "shareAccessTokenTimeout") || DefaultAccessTimeoutSec)
switch (this.note.getAttributeValue("label", "shareContentAccess")) {
case "basic": this.type = "basic"; break
case "query": this.type = "query"; break
default: this.type = "cookie"; break
};
}
__encrypt(text: string) {
const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv('aes-256-cbc', this.key, iv);
let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
return iv.toString('hex') + encrypted;
}
__decrypt(encryptedText: string) {
try {
const iv = Buffer.from(encryptedText.slice(0, 32), 'hex');
const decipher = crypto.createDecipheriv('aes-256-cbc', this.key, iv);
let decrypted = decipher.update(encryptedText.slice(32), 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
} catch {
return ""
}
}
__compare(originalText: string, encryptedText: string) {
return originalText === this.__decrypt(encryptedText)
}
update() {
if (new Date().getTime() < this.timestamp + this.getTimeout() * 1000) return
this.token = utils.randomString(36);
this.key = crypto.randomBytes(32);
this.timestamp = new Date().getTime();
}
isTokenValid(encToken: string) {
return this.__compare(this.token, encToken) && new Date().getTime() < this.timestamp + this.getTimeout() * 1000;
}
getToken() {
return this.__encrypt(this.token);
}
getTokenExpiration() {
return (this.timestamp + (this.timeout * 1000) - new Date().getTime()) /1000;
}
getTimeout() {
return this.timeout;
}
getContentAccessType() {
return this.type;
}
}

View File

@ -10,6 +10,7 @@ import type SAttribute from "./sattribute.js";
import type SBranch from "./sbranch.js"; import type SBranch from "./sbranch.js";
import type { SNoteRow } from "./rows.js"; import type { SNoteRow } from "./rows.js";
import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js"; import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js";
import { ContentAccessor } from "./content_accessor.js";
const LABEL = "label"; const LABEL = "label";
const RELATION = "relation"; const RELATION = "relation";
@ -33,6 +34,7 @@ class SNote extends AbstractShacaEntity {
private __inheritableAttributeCache: SAttribute[] | null; private __inheritableAttributeCache: SAttribute[] | null;
targetRelations: SAttribute[]; targetRelations: SAttribute[];
attachments: SAttachment[]; attachments: SAttachment[];
contentAccessor: ContentAccessor | undefined;
constructor([noteId, title, type, mime, blobId, utcDateModified, isProtected]: SNoteRow) { constructor([noteId, title, type, mime, blobId, utcDateModified, isProtected]: SNoteRow) {
super(); super();
@ -59,6 +61,15 @@ class SNote extends AbstractShacaEntity {
this.shaca.notes[this.noteId] = this; this.shaca.notes[this.noteId] = this;
} }
initContentAccessor(){
if (!this.contentAccessor && this.getCredentials().length > 0) {
this.contentAccessor = new ContentAccessor(this);
}
if (this.contentAccessor) {
this.contentAccessor.update()
}
}
getParentBranches() { getParentBranches() {
return this.parentBranches; return this.parentBranches;
} }
@ -72,7 +83,7 @@ class SNote extends AbstractShacaEntity {
} }
getVisibleChildBranches() { getVisibleChildBranches() {
return this.getChildBranches().filter((branch) => !branch.isHidden && !branch.getNote().isLabelTruthy("shareHiddenFromTree")); return this.getChildBranches().filter((branch) => !branch.isHidden && !branch.getNote().isLabelTruthy("shareHiddenFromTree") && !branch.getNote().isLabelTruthy("shareExclude"));
} }
getParentNotes() { getParentNotes() {
@ -80,7 +91,7 @@ class SNote extends AbstractShacaEntity {
} }
getChildNotes() { getChildNotes() {
return this.children; return this.children.filter((note) => !note.isLabelTruthy("shareExclude"));
} }
getVisibleChildNotes() { getVisibleChildNotes() {

View File

@ -131,7 +131,7 @@ To do so, create a shared text note and apply the `shareIndex` label. When viewe
## Attribute reference ## Attribute reference
<table class="ck-table-resized"><colgroup><col style="width:18.38%;"><col style="width:81.62%;"></colgroup><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareHiddenFromTree</code></td><td>this note is hidden from left navigation tree, but still accessible with its URL</td></tr><tr><td><code>#shareExternalLink</code></td><td>note will act as a link to an external website in the share tree</td></tr><tr><td><code>#shareAlias</code></td><td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code></td></tr><tr><td><code>#shareOmitDefaultCss</code></td><td>default share page CSS will be omitted. Use when you make extensive styling changes.</td></tr><tr><td><code>#shareRoot</code></td><td>marks note which is served on /share root.</td></tr><tr><td><code>#shareDescription</code></td><td>define text to be added to the HTML meta tag for description</td></tr><tr><td><code>#shareRaw</code></td><td>Note will be served in its raw format, without HTML wrapper. See also&nbsp;<a class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.md">Serving directly the content of a note</a>&nbsp;for an alternative method without setting an attribute.</td></tr><tr><td><code>#shareDisallowRobotIndexing</code></td><td><p>Indicates to web crawlers that the page should not be indexed of this note by:</p><ul><li data-list-item-id="e6baa9f60bf59d085fd31aa2cce07a0e7">Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li><li data-list-item-id="ec0d067db136ef9794e4f1033405880b7">Setting the <code>noindex, follow</code> meta tag.</li></ul></td></tr><tr><td><code>#shareCredentials</code></td><td>require credentials to access this shared note. Value is expected to be in format <code>username:password</code>. Don't forget to make this inheritable to apply to child-notes/images.</td></tr><tr><td><code>#shareIndex</code></td><td>Note with this label will list all roots of shared notes.</td></tr><tr><td><code>#shareHtmlLocation</code></td><td>defines where custom HTML injected via <code>~shareHtml</code> relation should be placed. Applied to the HTML snippet note itself. Format: <code>location:position</code> where location is <code>head</code>, <code>body</code>, or <code>content</code> and position is <code>start</code> or <code>end</code>. Defaults to <code>content:end</code>.</td></tr></tbody></table> <table class="ck-table-resized"><colgroup><col style="width:18.38%;"><col style="width:81.62%;"></colgroup><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareHiddenFromTree</code></td><td>this note is hidden from left navigation tree, but still accessible with its URL</td></tr><tr><td><code>#shareTemplateNoPrevNext</code></td><td>hide bottom page navigation prev and next page.</td></tr><tr><td><code>#shareTemplateNoLeftPanel</code></td><td>hide left panel fully.</td></tr><tr><td><code>#shareExclude</code></td><td>this note will be excluded from share, not accessible via direct URL (implemented to hide scripts from share)</td></tr><tr><td><code>#shareContentAccess</code></td><td>method for attachments authorization in case when note protected with login and password (#shareCredentials). Could be cookie (the cookie will be provided when page loads) / query (every url will be updated with token) / basic (only basic header authorization)). By default for browser used cookie.</td></tr><tr><td><code>#shareAccessTokenTimeout</code></td><td>token expiration timeout in seconds, by default 10 minutes. While token not expired user could download attachment, after that he will get message `Access is expired. Return back and update the page.`</td></tr><tr><td><code>#shareExternalLink</code></td><td>note will act as a link to an external website in the share tree</td></tr><tr><td><code>#shareAlias</code></td><td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code></td></tr><tr><td><code>#shareOmitDefaultCss</code></td><td>default share page CSS will be omitted. Use when you make extensive styling changes.</td></tr><tr><td><code>#shareRoot</code></td><td>marks note which is served on /share root.</td></tr><tr><td><code>#shareDescription</code></td><td>define text to be added to the HTML meta tag for description</td></tr><tr><td><code>#shareRaw</code></td><td>Note will be served in its raw format, without HTML wrapper. See also&nbsp;<a class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.md">Serving directly the content of a note</a>&nbsp;for an alternative method without setting an attribute.</td></tr><tr><td><code>#shareDisallowRobotIndexing</code></td><td><p>Indicates to web crawlers that the page should not be indexed of this note by:</p><ul><li data-list-item-id="e6baa9f60bf59d085fd31aa2cce07a0e7">Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li><li data-list-item-id="ec0d067db136ef9794e4f1033405880b7">Setting the <code>noindex, follow</code> meta tag.</li></ul></td></tr><tr><td><code>#shareCredentials</code></td><td>require credentials to access this shared note. Value is expected to be in format <code>username:password</code>. Don't forget to make this inheritable to apply to child-notes/images.</td></tr><tr><td><code>#shareIndex</code></td><td>Note with this label will list all roots of shared notes.</td></tr><tr><td><code>#shareHtmlLocation</code></td><td>defines where custom HTML injected via <code>~shareHtml</code> relation should be placed. Applied to the HTML snippet note itself. Format: <code>location:position</code> where location is <code>head</code>, <code>body</code>, or <code>content</code> and position is <code>start</code> or <code>end</code>. Defaults to <code>content:end</code>.</td></tr></tbody></table>
### Customizing logo ### Customizing logo

View File

@ -63,7 +63,7 @@ For each note of the calendar, the following attributes can be used:
| `#startTime` | The time the event starts at. If this value is missing, then the event is considered a full-day event. The format is `HH:MM` (hours in 24-hour format and minutes). | | `#startTime` | The time the event starts at. If this value is missing, then the event is considered a full-day event. The format is `HH:MM` (hours in 24-hour format and minutes). |
| `#endTime` | Similar to `startTime`, it mentions the time at which the event ends (in relation with `endDate` if present, or `startDate`). | | `#endTime` | Similar to `startTime`, it mentions the time at which the event ends (in relation with `endDate` if present, or `startDate`). |
| `#color` | Displays the event with a specified color (named such as `red`, `gray` or hex such as `#FF0000`). This will also change the color of the note in other places such as the note tree. | | `#color` | Displays the event with a specified color (named such as `red`, `gray` or hex such as `#FF0000`). This will also change the color of the note in other places such as the note tree. |
| `#calendar:color` | Similar to `#color`, but applies the color only for the event in the calendar and not for other places such as the note tree. | | `#calendar:color` | Similar to `#color`, but applies the color only for the event in the calendar and not for other places such as the note tree. (*Deprecated*) |
| `#iconClass` | If present, the icon of the note will be displayed to the left of the event title. | | `#iconClass` | If present, the icon of the note will be displayed to the left of the event title. |
| `#calendar:title` | Changes the title of an event to point to an attribute of the note other than the title, can either a label or a relation (without the `#` or `~` symbol). See _Use-cases_ for more information. | | `#calendar:title` | Changes the title of an event to point to an attribute of the note other than the title, can either a label or a relation (without the `#` or `~` symbol). See _Use-cases_ for more information. |
| `#calendar:displayedAttributes` | Allows displaying the value of one or more attributes in the calendar like this:     <br> <br>![](9_Calendar_image.png)    <br> <br>`#weight="70" #Mood="Good" #calendar:displayedAttributes="weight,Mood"`   <br> <br>It can also be used with relations, case in which it will display the title of the target note:    <br> <br>`~assignee=@My assignee #calendar:displayedAttributes="assignee"` | | `#calendar:displayedAttributes` | Allows displaying the value of one or more attributes in the calendar like this:     <br> <br>![](9_Calendar_image.png)    <br> <br>`#weight="70" #Mood="Good" #calendar:displayedAttributes="weight,Mood"`   <br> <br>It can also be used with relations, case in which it will display the title of the target note:    <br> <br>`~assignee=@My assignee #calendar:displayedAttributes="assignee"` |

View File

@ -25,7 +25,6 @@
], ],
"devDependencies": { "devDependencies": {
"@ckeditor/ckeditor5-dev-build-tools": "43.1.0", "@ckeditor/ckeditor5-dev-build-tools": "43.1.0",
"@ckeditor/ckeditor5-dev-utils": "43.1.0",
"@ckeditor/ckeditor5-inspector": ">=4.1.0", "@ckeditor/ckeditor5-inspector": ">=4.1.0",
"@ckeditor/ckeditor5-package-tools": "5.0.1", "@ckeditor/ckeditor5-package-tools": "5.0.1",
"@typescript-eslint/eslint-plugin": "~8.48.0", "@typescript-eslint/eslint-plugin": "~8.48.0",

View File

@ -50,7 +50,7 @@
let openGraphImage = subRoot.note.getLabelValue("shareOpenGraphImage"); let openGraphImage = subRoot.note.getLabelValue("shareOpenGraphImage");
// Relation takes priority and requires some altering // Relation takes priority and requires some altering
if (subRoot.note.hasRelation("shareOpenGraphImage")) { if (subRoot.note.hasRelation("shareOpenGraphImage")) {
openGraphImage = `api/images/${subRoot.note.getRelation("shareOpenGraphImage").value}/image.png`; openGraphImage = `api/images/${subRoot.note.getRelation("shareOpenGraphImage").value}/image.png${addContentAccessQuery()}`;
} }
%> %>
<title><%= pageTitle %></title> <title><%= pageTitle %></title>
@ -109,6 +109,7 @@ content = content.replaceAll(headingRe, (...match) => {
<button aria-label="Show Mobile Menu" id="show-menu-button"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"></path></svg></button> <button aria-label="Show Mobile Menu" id="show-menu-button"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path d="M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"></path></svg></button>
</div> </div>
<div id="split-pane"> <div id="split-pane">
<% if (!note.isLabelTruthy("shareTemplateNoLeftPanel")) { %>
<div id="left-pane"> <div id="left-pane">
<div id="navigation"> <div id="navigation">
<div id="site-header"> <div id="site-header">
@ -143,6 +144,8 @@ content = content.replaceAll(headingRe, (...match) => {
<% } %> <% } %>
</div> </div>
</div> </div>
<% } %>
<div id="right-pane"> <div id="right-pane">
<div id="main"> <div id="main">
<div id="content" class="type-<%= note.type %><% if (note.type === "text") { %> ck-content<% } %><% if (isEmpty) { %> no-content<% } %>"> <div id="content" class="type-<%= note.type %><% if (note.type === "text") { %> ck-content<% } %><% if (isEmpty) { %> no-content<% } %>">
@ -152,7 +155,9 @@ content = content.replaceAll(headingRe, (...match) => {
<p>This note has no content.</p> <p>This note has no content.</p>
<% } else { %> <% } else { %>
<% <%
content = content.replace(/<img /g, `<img alt="${t("share_theme.image_alt")}" loading="lazy" `); content = content
.replace(/<img /g, `<img alt="${t("share_theme.image_alt")}" loading="lazy" `)
.replace(/src="(api\/[^"]+)"/g, (m, url) => `src="${url}${addContentAccessQuery(url.includes('?'))}"`);
%> %>
<%- content %> <%- content %>
<% } %> <% } %>
@ -189,7 +194,7 @@ content = content.replaceAll(headingRe, (...match) => {
</div> </div>
<% } %> <% } %>
<% if (hasTree) { %> <% if (hasTree && !note.isLabelTruthy("shareTemplateNoPrevNext")) { %>
<%- include("prev_next", { note: note, subRoot: subRoot }) %> <%- include("prev_next", { note: note, subRoot: subRoot }) %>
<% } %> <% } %>
</footer> </footer>

1255
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff