mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
Compare commits
29 Commits
4d3ed962e9
...
6f60b7c0d7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f60b7c0d7 | ||
|
|
8eca14069a | ||
|
|
1af0477ac0 | ||
|
|
43920f12ae | ||
|
|
5a0beec6cb | ||
|
|
98241fb54b | ||
|
|
3051664228 | ||
|
|
1ed774365c | ||
|
|
f2e33dfd58 | ||
|
|
90b5282b39 | ||
|
|
d520fc46b9 | ||
|
|
e69b5988ec | ||
|
|
3cdc1ba794 | ||
|
|
25e1008c5c | ||
|
|
a093862311 | ||
|
|
53057ea9fc | ||
|
|
94db96de3e | ||
|
|
60e4fbbf75 | ||
|
|
d35dd67632 | ||
|
|
8813985c68 | ||
|
|
538c98b587 | ||
|
|
389c7029cf | ||
|
|
d47f9e1131 | ||
|
|
c0a8d29756 | ||
|
|
668fd34af6 | ||
|
|
8aa08cf8fe | ||
|
|
16c04f5ae4 | ||
|
|
1f21c65a99 | ||
|
|
5d5fd2079a |
2
.github/workflows/playwright.yml
vendored
2
.github/workflows/playwright.yml
vendored
@ -79,7 +79,7 @@ jobs:
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: e2e report
|
||||
name: e2e report ${{ matrix.arch }}
|
||||
path: apps/server-e2e/test-output
|
||||
|
||||
- name: Kill the server
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,6 +8,7 @@ out-tsc
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
.pnpm-store
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
@ -18,6 +19,7 @@ node_modules
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
.devcontainer
|
||||
|
||||
# misc
|
||||
/.sass-cache
|
||||
|
||||
19
README.md
19
README.md
@ -146,6 +146,21 @@ Here's the language coverage we have so far:
|
||||
|
||||
### 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):
|
||||
```shell
|
||||
git clone https://github.com/TriliumNext/Trilium.git
|
||||
@ -154,6 +169,10 @@ pnpm install
|
||||
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
|
||||
|
||||
Download the repository, install dependencies using `pnpm` and then run the environment required to edit the documentation:
|
||||
|
||||
21
apps/client/src/menus/context_menu_utils.ts
Normal file
21
apps/client/src/menus/context_menu_utils.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { t } from "../services/i18n"
|
||||
import attributes from "../services/attributes"
|
||||
import FNote from "../entities/fnote"
|
||||
|
||||
export function getArchiveMenuItem(note: FNote) {
|
||||
if (!note.isArchived) {
|
||||
return {
|
||||
title: t("board_view.archive-note"),
|
||||
uiIcon: "bx bx-archive",
|
||||
handler: () => attributes.addLabel(note.noteId, "archived")
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
title: t("board_view.unarchive-note"),
|
||||
uiIcon: "bx bx-archive-out",
|
||||
handler: async () => {
|
||||
attributes.removeOwnedLabelByName(note, "archived")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -207,7 +207,7 @@ function toObject<T, R>(array: T[], fn: (arg0: T) => [key: string, value: R]) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
function randomString(len: number) {
|
||||
export function randomString(len: number) {
|
||||
let text = "";
|
||||
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
|
||||
|
||||
@ -257,6 +257,11 @@ button.close:hover {
|
||||
color: var(--hover-item-text-color);
|
||||
}
|
||||
|
||||
button.custom-title-bar-button {
|
||||
background: transparent;
|
||||
border: unset;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: var(--modal-background-color) !important;
|
||||
}
|
||||
|
||||
@ -275,7 +275,8 @@
|
||||
--calendar-coll-event-background-lightness: 20%;
|
||||
--calendar-coll-event-background-color: #3c3c3c;
|
||||
--calendar-coll-event-text-color: white;
|
||||
--calendar-cell-event-hover-filter: brightness(1.25);
|
||||
--calendar-coll-event-hover-filter: brightness(1.25);
|
||||
--callendar-coll-event-archived-sripe-color: #00000026;
|
||||
--calendar-coll-today-background-color: #ffffff08;
|
||||
}
|
||||
|
||||
|
||||
@ -273,7 +273,8 @@
|
||||
--calendar-coll-event-background-saturation: 80%;
|
||||
--calendar-coll-event-background-color: #eaeaea;
|
||||
--calendar-coll-event-text-color: black;
|
||||
--calendar-cell-event-hover-filter: brightness(.95) saturate(1.25);
|
||||
--calendar-coll-event-hover-filter: brightness(.95) saturate(1.25);
|
||||
--callendar-coll-event-archived-sripe-color: #0000000a;
|
||||
--calendar-coll-today-background-color: #00000006;
|
||||
}
|
||||
|
||||
|
||||
@ -643,7 +643,7 @@ html .note-detail-editable-text :not(figure, .include-note, hr):first-child {
|
||||
}
|
||||
}
|
||||
|
||||
.note-detail-printable:not(.word-wrap) pre code {
|
||||
.ck-content:not(.word-wrap) pre code {
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
|
||||
@ -162,7 +162,8 @@
|
||||
"inPageSearch": "页面内搜索",
|
||||
"newTabWithActivationNoteLink": "在新标签页打开笔记链接并激活该标签页",
|
||||
"title": "资料表",
|
||||
"newTabNoteLink": "在新标签页开启链接"
|
||||
"newTabNoteLink": "在新标签页开启链接",
|
||||
"editShortcuts": "编辑键盘快捷键"
|
||||
},
|
||||
"import": {
|
||||
"importIntoNote": "导入到笔记",
|
||||
@ -2104,5 +2105,8 @@
|
||||
"clear-color": "清除笔记颜色",
|
||||
"set-color": "设置笔记颜色",
|
||||
"set-custom-color": "设置自定义笔记颜色"
|
||||
},
|
||||
"popup-editor": {
|
||||
"maximize": "切换至完整编辑器"
|
||||
}
|
||||
}
|
||||
|
||||
@ -736,8 +736,8 @@
|
||||
"zoom_out_title": "Zoom Out"
|
||||
},
|
||||
"zpetne_odkazy": {
|
||||
"backlink": "{{count}} Backlink",
|
||||
"backlinks": "{{count}} Backlinks",
|
||||
"backlink_one": "{{count}} Backlink",
|
||||
"backlink_other": "{{count}} Backlinks",
|
||||
"relation": "relation"
|
||||
},
|
||||
"mobile_detail_menu": {
|
||||
|
||||
@ -2105,5 +2105,8 @@
|
||||
"clear-color": "ノートの色をクリア",
|
||||
"set-color": "ノートの色を設定",
|
||||
"set-custom-color": "ノートの色をカスタム設定"
|
||||
},
|
||||
"popup-editor": {
|
||||
"maximize": "フルエディターに切り替え"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1362,8 +1362,9 @@
|
||||
"title": "Factorul de zoom (doar pentru versiunea desktop)"
|
||||
},
|
||||
"zpetne_odkazy": {
|
||||
"backlink": "{{count}} legături de retur",
|
||||
"backlinks": "{{count}} legături de retur",
|
||||
"backlink_one": "{{count}} legătură de retur",
|
||||
"backlink_few": "{{count}} legături de retur",
|
||||
"backlink_other": "{{count}} de legături de retur",
|
||||
"relation": "relație"
|
||||
},
|
||||
"svg_export_button": {
|
||||
|
||||
@ -162,7 +162,8 @@
|
||||
"inPageSearch": "頁面內搜尋",
|
||||
"title": "列表",
|
||||
"newTabNoteLink": "在新分頁開啟筆記連結",
|
||||
"newTabWithActivationNoteLink": "在新分頁開啟並切換至筆記連結"
|
||||
"newTabWithActivationNoteLink": "在新分頁開啟並切換至筆記連結",
|
||||
"editShortcuts": "編輯鍵盤快捷鍵"
|
||||
},
|
||||
"import": {
|
||||
"importIntoNote": "匯入至筆記",
|
||||
@ -2104,5 +2105,8 @@
|
||||
"clear-color": "清除筆記顏色",
|
||||
"set-color": "設定筆記顏色",
|
||||
"set-custom-color": "設定自訂筆記顏色"
|
||||
},
|
||||
"popup-editor": {
|
||||
"maximize": "切換至完整編輯器"
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ import froca from "../services/froca";
|
||||
import NoteLink from "./react/NoteLink";
|
||||
import RawHtml from "./react/RawHtml";
|
||||
import { ViewTypeOptions } from "./collections/interface";
|
||||
import attributes from "../services/attributes";
|
||||
|
||||
export interface FloatingButtonContext {
|
||||
parentComponent: Component;
|
||||
@ -310,13 +311,24 @@ function Backlinks({ note, isDefaultViewMode }: FloatingButtonContext) {
|
||||
let [ popupOpen, setPopupOpen ] = useState(false);
|
||||
const backlinksContainerRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
function refresh() {
|
||||
if (!isDefaultViewMode) return;
|
||||
|
||||
server.get<BacklinkCountResponse>(`note-map/${note.noteId}/backlink-count`).then(resp => {
|
||||
setBacklinkCount(resp.count);
|
||||
});
|
||||
}, [ note ]);
|
||||
}
|
||||
|
||||
useEffect(() => refresh(), [ note ]);
|
||||
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||
loadResults.getAttributeRows().some(attr =>
|
||||
attr.type === "relation" &&
|
||||
attr.name === "internalLink" &&
|
||||
attributes.isAffecting(attr, note))
|
||||
{
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
// Determine the max height of the container.
|
||||
const { windowHeight } = useWindowSize();
|
||||
|
||||
@ -14,8 +14,10 @@ import ws from "../services/ws";
|
||||
import { UpdateAttributeResponse } from "@triliumnext/commons";
|
||||
import attributes from "../services/attributes";
|
||||
import debounce from "../services/debounce";
|
||||
import { randomString } from "../services/utils";
|
||||
|
||||
interface Cell {
|
||||
uniqueId: string;
|
||||
definitionAttr: FAttribute;
|
||||
definition: DefinitionObject;
|
||||
valueAttr: Attribute;
|
||||
@ -44,6 +46,7 @@ export default function PromotedAttributes() {
|
||||
<div className="promoted-attributes-widget">
|
||||
{cells && cells.length > 0 && <div className="promoted-attributes-container">
|
||||
{note && cells?.map(cell => <PromotedAttributeCell
|
||||
key={cell.uniqueId}
|
||||
cell={cell}
|
||||
cells={cells} setCells={setCells}
|
||||
shouldFocus={cell === cellToFocus} setCellToFocus={setCellToFocus}
|
||||
@ -103,7 +106,8 @@ function usePromotedAttributeData(note: FNote | null | undefined, componentId: s
|
||||
valueAttr.attributeId = "";
|
||||
}
|
||||
|
||||
cells.push({ definitionAttr, definition, valueAttr, valueName });
|
||||
const uniqueId = randomString(10);
|
||||
cells.push({ definitionAttr, definition, valueAttr, valueName, uniqueId });
|
||||
}
|
||||
}
|
||||
setCells(cells);
|
||||
|
||||
@ -2,9 +2,9 @@ import FNote from "../../../entities/fnote";
|
||||
import NoteColorPicker from "../../../menus/custom-items/NoteColorPicker";
|
||||
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
||||
import link_context_menu from "../../../menus/link_context_menu";
|
||||
import attributes from "../../../services/attributes";
|
||||
import branches from "../../../services/branches";
|
||||
import dialog from "../../../services/dialog";
|
||||
import { getArchiveMenuItem } from "../../../menus/context_menu_utils";
|
||||
import { t } from "../../../services/i18n";
|
||||
import Api from "./api";
|
||||
|
||||
@ -43,17 +43,6 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
||||
items: [
|
||||
...link_context_menu.getItems(),
|
||||
{ kind: "separator" },
|
||||
{
|
||||
title: t("board_view.move-to"),
|
||||
uiIcon: "bx bx-transfer",
|
||||
items: api.columns.map(columnToMoveTo => ({
|
||||
title: columnToMoveTo,
|
||||
enabled: columnToMoveTo !== column,
|
||||
handler: () => api.changeColumn(note.noteId, columnToMoveTo)
|
||||
})),
|
||||
},
|
||||
getArchiveMenuItem(note),
|
||||
{ kind: "separator" },
|
||||
{
|
||||
title: t("board_view.insert-above"),
|
||||
uiIcon: "bx bx-list-plus",
|
||||
@ -65,6 +54,17 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
||||
handler: () => api.insertRowAtPosition(column, branchId, "after")
|
||||
},
|
||||
{ kind: "separator" },
|
||||
{
|
||||
title: t("board_view.move-to"),
|
||||
uiIcon: "bx bx-transfer",
|
||||
items: api.columns.map(columnToMoveTo => ({
|
||||
title: columnToMoveTo,
|
||||
enabled: columnToMoveTo !== column,
|
||||
handler: () => api.changeColumn(note.noteId, columnToMoveTo)
|
||||
})),
|
||||
},
|
||||
{ kind: "separator" },
|
||||
getArchiveMenuItem(note),
|
||||
{
|
||||
title: t("board_view.remove-from-board"),
|
||||
uiIcon: "bx bx-task-x",
|
||||
@ -85,20 +85,3 @@ export function openNoteContextMenu(api: Api, event: ContextMenuEvent, note: FNo
|
||||
});
|
||||
}
|
||||
|
||||
function getArchiveMenuItem(note: FNote) {
|
||||
if (!note.isArchived) {
|
||||
return {
|
||||
title: t("board_view.archive-note"),
|
||||
uiIcon: "bx bx-archive",
|
||||
handler: () => attributes.addLabel(note.noteId, "archived")
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
title: t("board_view.unarchive-note"),
|
||||
uiIcon: "bx bx-archive-out",
|
||||
handler: async () => {
|
||||
attributes.removeOwnedLabelByName(note, "archived")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,11 +3,10 @@ import FNote from "../../../entities/fnote";
|
||||
import contextMenu, { ContextMenuEvent } from "../../../menus/context_menu";
|
||||
import link_context_menu from "../../../menus/link_context_menu";
|
||||
import branches from "../../../services/branches";
|
||||
import froca from "../../../services/froca";
|
||||
import { note } from "mermaid/dist/rendering-util/rendering-elements/shapes/note.js";
|
||||
import { getArchiveMenuItem } from "../../../menus/context_menu_utils";
|
||||
import { t } from "../../../services/i18n";
|
||||
|
||||
export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, parentNote: FNote) {
|
||||
export function openCalendarContextMenu(e: ContextMenuEvent, note: FNote, parentNote: FNote) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@ -17,15 +16,13 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, par
|
||||
items: [
|
||||
...link_context_menu.getItems(),
|
||||
{ kind: "separator" },
|
||||
getArchiveMenuItem(note),
|
||||
{
|
||||
title: t("calendar_view.delete_note"),
|
||||
uiIcon: "bx bx-trash",
|
||||
handler: async () => {
|
||||
const noteToDelete = await froca.getNote(noteId);
|
||||
if (!noteToDelete) return;
|
||||
|
||||
let branchIdToDelete: string | null = null;
|
||||
for (const parentBranch of noteToDelete.getParentBranches()) {
|
||||
for (const parentBranch of note.getParentBranches()) {
|
||||
const parentNote = await parentBranch.getNote();
|
||||
if (parentNote?.hasAncestor(parentNote.noteId)) {
|
||||
branchIdToDelete = parentBranch.branchId;
|
||||
@ -40,9 +37,9 @@ export function openCalendarContextMenu(e: ContextMenuEvent, noteId: string, par
|
||||
{ kind: "separator" },
|
||||
{
|
||||
kind: "custom",
|
||||
componentFn: () => NoteColorPicker({note: noteId})
|
||||
componentFn: () => NoteColorPicker({note: note})
|
||||
}
|
||||
],
|
||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, noteId),
|
||||
selectMenuItemHandler: ({ command }) => link_context_menu.handleLinkContextMenuItem(command, note.noteId),
|
||||
})
|
||||
}
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
--calendar-coll-event-background-lightness: 95%;
|
||||
--calendar-coll-event-background-saturation: 80%;
|
||||
--calendar-coll-event-background-color: var(--accented-background-color);
|
||||
--calendar-coll-event-text-color: var(--primary-button-text-color);
|
||||
--calendar-cell-event-hover-filter: none;
|
||||
--calendar-coll-event-text-color: var(--main-text-color);
|
||||
--calendar-coll-event-hover-filter: none;
|
||||
--callendar-coll-event-archived-sripe-color: #00000013;
|
||||
--calendar-coll-today-background-color: var(--more-accented-background-color);
|
||||
}
|
||||
|
||||
@ -53,7 +54,23 @@
|
||||
}
|
||||
|
||||
.calendar-container a.fc-event.archived {
|
||||
opacity: 0.5;
|
||||
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 {
|
||||
@ -129,17 +146,18 @@ body.desktop:not(.zen) .calendar-view .calendar-header {
|
||||
|
||||
.calendar-view a.fc-timegrid-event:hover,
|
||||
.calendar-view a.fc-daygrid-event:hover {
|
||||
filter: var(--calendar-cell-event-hover-filter);
|
||||
filter: var(--calendar-coll-event-hover-filter);
|
||||
border-color: var(--fc-event-text-color);
|
||||
text-decoration: none;
|
||||
color: currentColor;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.calendar-view .fc-timegrid-event.with-hue,
|
||||
.calendar-view .fc-daygrid-event.with-hue {
|
||||
--fc-event-text-color: var(--custom-color);
|
||||
|
||||
background: hsl(var(--custom-color-hue),
|
||||
--fc-event-bg-color: hsl(var(--custom-color-hue),
|
||||
var(--calendar-coll-event-background-saturation),
|
||||
var(--calendar-coll-event-background-lightness)) !important;
|
||||
}
|
||||
|
||||
@ -307,9 +307,11 @@ function useEventDisplayCustomization(parentNote: FNote) {
|
||||
$(mainContainer ?? e.el).append($(promotedAttributesHtml));
|
||||
}
|
||||
|
||||
e.el.addEventListener("contextmenu", (contextMenuEvent) => {
|
||||
const noteId = e.event.extendedProps.noteId;
|
||||
openCalendarContextMenu(contextMenuEvent, noteId, parentNote);
|
||||
e.el.addEventListener("contextmenu", async (contextMenuEvent) => {
|
||||
const note = await froca.getNote(e.event.extendedProps.noteId);
|
||||
if (!note) return;
|
||||
|
||||
openCalendarContextMenu(contextMenuEvent, note, parentNote);
|
||||
});
|
||||
}, []);
|
||||
return { eventDidMount };
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
"better-sqlite3": "12.5.0",
|
||||
"mime-types": "3.0.2",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"tsx": "4.20.6",
|
||||
"tsx": "4.21.0",
|
||||
"yargs": "18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -43,7 +43,7 @@ test("User can change language from settings", async ({ page, context }) => {
|
||||
// Check that the default value (English) is set.
|
||||
await expect(app.currentNoteSplit).toContainText("First day of the week");
|
||||
const languageCombobox = app.dropdown(app.currentNoteSplit.locator(".options-section .dropdown").first());
|
||||
await expect(languageCombobox).toContainText("English");
|
||||
await expect(languageCombobox).toContainText("English (United States)");
|
||||
|
||||
// Select Chinese and ensure the translation is set.
|
||||
await languageCombobox.selectOptionByText("简体中文");
|
||||
@ -53,8 +53,8 @@ test("User can change language from settings", async ({ page, context }) => {
|
||||
await expect(languageCombobox).toContainText("简体中文");
|
||||
|
||||
// Select English again.
|
||||
await languageCombobox.selectOptionByText("English");
|
||||
await languageCombobox.selectOptionByText("English (United States)");
|
||||
await app.currentNoteSplit.locator("button[name=restart-app-button]").click();
|
||||
await expect(app.currentNoteSplit).toContainText("Language", { timeout: 15000 });
|
||||
await expect(languageCombobox).toContainText("English");
|
||||
await expect(languageCombobox).toContainText("English (United States)");
|
||||
});
|
||||
|
||||
@ -40,15 +40,21 @@ interface Subroot {
|
||||
|
||||
type GetNoteFunction = (id: string) => SNote | BNote | null;
|
||||
|
||||
function getSharedSubTreeRoot(note: SNote | BNote | undefined): Subroot {
|
||||
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 ""
|
||||
}
|
||||
|
||||
export function getSharedSubTreeRoot(note: SNote | BNote | undefined, parentId: string | undefined = undefined): Subroot {
|
||||
if (!note || note.noteId === shareRoot.SHARE_ROOT_NOTE_ID) {
|
||||
// share root itself is not shared
|
||||
return {};
|
||||
}
|
||||
|
||||
// every path leads to share root, but which one to choose?
|
||||
// for the sake of simplicity, URLs are not note paths
|
||||
const parentBranch = note.getParentBranches()[0];
|
||||
const parentBranches = note.getParentBranches()
|
||||
const parentBranch = (parentId ? parentBranches.find((pb: SBranch | BBranch) => pb.parentNoteId === parentId) : undefined) || parentBranches[0];
|
||||
|
||||
if (note instanceof BNote) {
|
||||
return {
|
||||
@ -64,7 +70,7 @@ function getSharedSubTreeRoot(note: SNote | BNote | undefined): Subroot {
|
||||
};
|
||||
}
|
||||
|
||||
return getSharedSubTreeRoot(parentBranch.getParentNote());
|
||||
return getSharedSubTreeRoot(parentBranch.getParentNote(), parentId);
|
||||
}
|
||||
|
||||
export function renderNoteForExport(note: BNote, parentBranch: BBranch, basePath: string, ancestors: string[]) {
|
||||
@ -91,7 +97,7 @@ export function renderNoteForExport(note: BNote, parentBranch: BBranch, basePath
|
||||
}
|
||||
|
||||
export function renderNoteContent(note: SNote) {
|
||||
const subRoot = getSharedSubTreeRoot(note);
|
||||
const subRoot = getSharedSubTreeRoot(note, note.parentId);
|
||||
|
||||
const ancestors: string[] = [];
|
||||
let notePointer = note;
|
||||
@ -107,23 +113,23 @@ export function renderNoteContent(note: SNote) {
|
||||
// Determine CSS to load.
|
||||
const cssToLoad: string[] = [];
|
||||
if (!note.isLabelTruthy("shareOmitDefaultCss")) {
|
||||
cssToLoad.push(`assets/styles.css`);
|
||||
cssToLoad.push(`assets/scripts.css`);
|
||||
cssToLoad.push(`../assets/styles.css`);
|
||||
cssToLoad.push(`../assets/scripts.css`);
|
||||
}
|
||||
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.
|
||||
const jsToLoad: string[] = [
|
||||
"assets/scripts.js"
|
||||
"../assets/scripts.js"
|
||||
];
|
||||
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 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, {
|
||||
subRoot,
|
||||
@ -133,7 +139,7 @@ export function renderNoteContent(note: SNote) {
|
||||
logoUrl,
|
||||
ancestors,
|
||||
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 +164,7 @@ function renderNoteContentInternal(note: SNote | BNote, renderArgs: RenderArgs)
|
||||
isEmpty,
|
||||
assetPath: shareAdjustedAssetPath,
|
||||
assetUrlFragment,
|
||||
addContentAccessQuery: (second: boolean | undefined) => addContentAccessQuery(note, second),
|
||||
showLoginInShareTheme,
|
||||
t,
|
||||
isDev,
|
||||
@ -325,7 +332,7 @@ function renderText(result: Result, note: SNote | BNote) {
|
||||
}
|
||||
|
||||
if (href?.startsWith("#")) {
|
||||
handleAttachmentLink(linkEl, href, getNote, getAttachment);
|
||||
handleAttachmentLink(linkEl, href, getNote, getAttachment, note);
|
||||
}
|
||||
}
|
||||
|
||||
@ -349,7 +356,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;
|
||||
let attachmentMatch;
|
||||
if ((attachmentMatch = linkRegExp.exec(href))) {
|
||||
@ -357,7 +364,7 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNot
|
||||
const attachment = getAttachment(attachmentId);
|
||||
|
||||
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(`role-${attachment.role}`);
|
||||
linkEl.childNodes.length = 0;
|
||||
@ -373,7 +380,7 @@ function handleAttachmentLink(linkEl: HTMLElement, href: string, getNote: GetNot
|
||||
const linkedNote = getNote(noteId);
|
||||
if (linkedNote) {
|
||||
const isExternalLink = linkedNote.hasLabel("shareExternalLink");
|
||||
const href = isExternalLink ? linkedNote.getLabelValue("shareExternalLink") : `./${linkedNote.shareId}`;
|
||||
const href = isExternalLink ? linkedNote.getLabelValue("shareExternalLink") : `../${linkedNote.shareId}`;
|
||||
if (href) {
|
||||
linkEl.setAttribute("href", href);
|
||||
}
|
||||
@ -430,7 +437,7 @@ function renderMermaid(result: Result, note: SNote | BNote) {
|
||||
}
|
||||
|
||||
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>
|
||||
<details>
|
||||
<summary>Chart source</summary>
|
||||
@ -439,14 +446,14 @@ function renderMermaid(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) {
|
||||
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 {
|
||||
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>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import searchService from "../services/search/services/search.js";
|
||||
import SearchContext from "../services/search/search_context.js";
|
||||
import type SNote from "./shaca/entities/snote.js";
|
||||
import type SAttachment from "./shaca/entities/sattachment.js";
|
||||
import { getDefaultTemplatePath, renderNoteContent } from "./content_renderer.js";
|
||||
import { getDefaultTemplatePath, getSharedSubTreeRoot, renderNoteContent } from "./content_renderer.js";
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
function addNoIndexHeader(note: SNote, res: Response) {
|
||||
@ -60,6 +60,20 @@ function checkNoteAccess(noteId: string, req: Request, res: Response) {
|
||||
const header = req.header("Authorization");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -124,9 +138,14 @@ function register(router: Router) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (note.isLabelTruthy("shareExclude")) {
|
||||
res.status(404);
|
||||
render404(res);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkNoteAccess(note.noteId, req, res)) {
|
||||
requestCredentials(res);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -138,6 +157,10 @@ function register(router: Router) {
|
||||
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));
|
||||
}
|
||||
|
||||
@ -157,14 +180,29 @@ function register(router: Router) {
|
||||
renderNote(shaca.shareRootNote, req, res);
|
||||
});
|
||||
|
||||
router.get("/share/:parentShareId/:shareId", (req, res) => {
|
||||
shacaLoader.ensureLoad();
|
||||
|
||||
const { parentShareId, shareId } = req.params;
|
||||
|
||||
const note = shaca.aliasToNote[shareId] || shaca.notes[shareId];
|
||||
if (note){
|
||||
note.parentId = parentShareId
|
||||
note.initContentAccessor()
|
||||
}
|
||||
|
||||
renderNote(note, req, res);
|
||||
});
|
||||
|
||||
router.get("/share/:shareId", (req, res) => {
|
||||
shacaLoader.ensureLoad();
|
||||
|
||||
const { shareId } = req.params;
|
||||
|
||||
const note = shaca.aliasToNote[shareId] || shaca.notes[shareId];
|
||||
const parent = getSharedSubTreeRoot(note)
|
||||
|
||||
renderNote(note, req, res);
|
||||
res.redirect(`${parent?.note?.noteId}/${shareId}`)
|
||||
});
|
||||
|
||||
router.get("/share/api/notes/:noteId", (req, res) => {
|
||||
|
||||
81
apps/server/src/share/shaca/entities/content_accessor.ts
Normal file
81
apps/server/src/share/shaca/entities/content_accessor.ts
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,6 +10,7 @@ import type SAttribute from "./sattribute.js";
|
||||
import type SBranch from "./sbranch.js";
|
||||
import type { SNoteRow } from "./rows.js";
|
||||
import { NOTE_TYPE_ICONS } from "../../../becca/entities/bnote.js";
|
||||
import { ContentAccessor } from "./content_accessor.js";
|
||||
|
||||
const LABEL = "label";
|
||||
const RELATION = "relation";
|
||||
@ -19,6 +20,7 @@ const isCredentials = (attr: SAttribute) => attr.type === "label" && attr.name =
|
||||
|
||||
class SNote extends AbstractShacaEntity {
|
||||
noteId: string;
|
||||
parentId?: string | undefined;
|
||||
title: string;
|
||||
type: string;
|
||||
mime: string;
|
||||
@ -33,11 +35,13 @@ class SNote extends AbstractShacaEntity {
|
||||
private __inheritableAttributeCache: SAttribute[] | null;
|
||||
targetRelations: SAttribute[];
|
||||
attachments: SAttachment[];
|
||||
contentAccessor: ContentAccessor | undefined;
|
||||
|
||||
constructor([noteId, title, type, mime, blobId, utcDateModified, isProtected]: SNoteRow) {
|
||||
super();
|
||||
|
||||
this.noteId = noteId;
|
||||
this.parentId = undefined;
|
||||
this.title = isProtected ? "[protected]" : title;
|
||||
this.type = type;
|
||||
this.mime = mime;
|
||||
@ -59,6 +63,19 @@ class SNote extends AbstractShacaEntity {
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
getParentId() {
|
||||
return this.parentId;
|
||||
}
|
||||
|
||||
getParentBranches() {
|
||||
return this.parentBranches;
|
||||
}
|
||||
@ -72,7 +89,7 @@ class SNote extends AbstractShacaEntity {
|
||||
}
|
||||
|
||||
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() {
|
||||
@ -80,7 +97,7 @@ class SNote extends AbstractShacaEntity {
|
||||
}
|
||||
|
||||
getChildNotes() {
|
||||
return this.children;
|
||||
return this.children.filter((note) => !note.isLabelTruthy("shareExclude"));
|
||||
}
|
||||
|
||||
getVisibleChildNotes() {
|
||||
|
||||
55
docs/README-fa.md
vendored
55
docs/README-fa.md
vendored
@ -33,50 +33,39 @@ quick overview:
|
||||
|
||||
<a href="https://triliumnext.github.io/Docs/Wiki/screenshot-tour"><img src="./docs/app.png" alt="Trilium Screenshot" width="1000"></a>
|
||||
|
||||
## ⏬ Download
|
||||
- [Latest release](https://github.com/TriliumNext/Trilium/releases/latest) –
|
||||
stable version, recommended for most users.
|
||||
## ⏬ دانلود
|
||||
- [آخرین انتشار]{1} – نسخه پایدار، برای بیشتر کاربران پیشنهاد میشود.
|
||||
- [Nightly build](https://github.com/TriliumNext/Trilium/releases/tag/nightly) –
|
||||
unstable development version, updated daily with the latest features and
|
||||
fixes.
|
||||
|
||||
## 📚 Documentation
|
||||
## 📚 کتابچه راهنما
|
||||
|
||||
**Visit our comprehensive documentation at
|
||||
[docs.triliumnotes.org](https://docs.triliumnotes.org/)**
|
||||
|
||||
Our documentation is available in multiple formats:
|
||||
- **Online Documentation**: Browse the full documentation at
|
||||
[docs.triliumnotes.org](https://docs.triliumnotes.org/)
|
||||
- **In-App Help**: Press `F1` within Trilium to access the same documentation
|
||||
directly in the application
|
||||
- **GitHub**: Navigate through the [User
|
||||
Guide](./docs/User%20Guide/User%20Guide/) in this repository
|
||||
مستندات ما در چندین قالب مختلف در دسترس است:
|
||||
- مستندات آنلاین: میتوانید نسخهٔ کامل مستندات را در
|
||||
[docs.triliumnotes.org](https://docs.triliumnotes.org/) مرور کنید
|
||||
- ** In-App Help **: Press `F1 ` در Trilium برای دسترسی به همان اسناد به طور
|
||||
مستقیم در برنامه
|
||||
- ** GitHub **: از طریق [راهنمای کاربر] در این مخزن حرکت کنید
|
||||
|
||||
### Quick Links
|
||||
- [Getting Started Guide](https://docs.triliumnotes.org/)
|
||||
- [Installation
|
||||
Instructions](./docs/User%20Guide/User%20Guide/Installation%20&%20Setup/Server%20Installation.md)
|
||||
- [Docker
|
||||
Setup](./docs/User%20Guide/User%20Guide/Installation%20&%20Setup/Server%20Installation/1.%20Installing%20the%20server/Using%20Docker.md)
|
||||
- [Upgrading
|
||||
TriliumNext](./docs/User%20Guide/User%20Guide/Installation%20%26%20Setup/Upgrading%20TriliumNext.md)
|
||||
- [Basic Concepts and
|
||||
Features](./docs/User%20Guide/User%20Guide/Basic%20Concepts%20and%20Features/Notes.md)
|
||||
- [Patterns of Personal Knowledge
|
||||
Base](https://triliumnext.github.io/Docs/Wiki/patterns-of-personal-knowledge)
|
||||
### لینکهای سریع
|
||||
- راهنمای شروع کار
|
||||
- دستورالعملهای نصب
|
||||
- راهاندازی داکر
|
||||
- ارتقای TriliumNext
|
||||
- مفاهیم و ویژگیهای پایه
|
||||
- الگوهای پایگاه دانشی شخصی
|
||||
|
||||
## 🎁 Features
|
||||
## 🎁 ویژگیها
|
||||
|
||||
* Notes can be arranged into arbitrarily deep tree. Single note can be placed
|
||||
into multiple places in the tree (see
|
||||
[cloning](https://triliumnext.github.io/Docs/Wiki/cloning-notes))
|
||||
* Rich WYSIWYG note editor including e.g. tables, images and
|
||||
[math](https://triliumnext.github.io/Docs/Wiki/text-notes) with markdown
|
||||
[autoformat](https://triliumnext.github.io/Docs/Wiki/text-notes#autoformat)
|
||||
* Support for editing [notes with source
|
||||
code](https://triliumnext.github.io/Docs/Wiki/code-notes), including syntax
|
||||
highlighting
|
||||
* یادداشتها میتوانند در یک درخت با عمق دلخواه سازماندهی شوند. یک یادداشت
|
||||
میتواند در چندین نقطهٔ مختلف از درخت قرار گیرد.
|
||||
* ویرایشگر یادداشت غنی WYSIWYG از جمله جداول، تصاویر و [math] [1] با علامت گذاری
|
||||
[autoformat] [2]
|
||||
* پشتیبانی از ویرایش [یادداشت با کد منبع][۱]، از جمله نحو برجسته
|
||||
* Fast and easy [navigation between
|
||||
notes](https://triliumnext.github.io/Docs/Wiki/note-navigation), full text
|
||||
search and [note
|
||||
|
||||
@ -131,7 +131,7 @@ To do so, create a shared text note and apply the `shareIndex` label. When viewe
|
||||
|
||||
## 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 <a class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.md">Serving directly the content of a note</a> 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 <a class="reference-link" href="Sharing/Serving%20directly%20the%20content%20o.md">Serving directly the content of a note</a> 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
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
"esbuild": "0.27.0",
|
||||
"eslint": "9.39.1",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-plugin-playwright": "2.3.0",
|
||||
"eslint-plugin-playwright": "2.4.0",
|
||||
"eslint-plugin-react-hooks": "7.0.1",
|
||||
"happy-dom": "~20.0.0",
|
||||
"http-server": "14.1.1",
|
||||
@ -62,7 +62,7 @@
|
||||
"react-refresh": "0.18.0",
|
||||
"rollup-plugin-webpack-stats": "2.1.8",
|
||||
"tslib": "2.8.1",
|
||||
"tsx": "4.20.6",
|
||||
"tsx": "4.21.0",
|
||||
"typescript": "~5.9.0",
|
||||
"typescript-eslint": "8.48.0",
|
||||
"upath": "2.0.1",
|
||||
|
||||
@ -14,7 +14,7 @@ export interface Locale {
|
||||
const UNSORTED_LOCALES = [
|
||||
{ id: "cn", name: "简体中文", electronLocale: "zh_CN" },
|
||||
{ id: "de", name: "Deutsch", electronLocale: "de" },
|
||||
{ id: "en", name: "English", electronLocale: "en" },
|
||||
{ id: "en", name: "English (United States)", electronLocale: "en" },
|
||||
{ id: "en-GB", name: "English (United Kingdom)", electronLocale: "en_GB" },
|
||||
{ id: "es", name: "Español", electronLocale: "es" },
|
||||
{ id: "fr", name: "Français", electronLocale: "fr" },
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
let openGraphImage = subRoot.note.getLabelValue("shareOpenGraphImage");
|
||||
// Relation takes priority and requires some altering
|
||||
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>
|
||||
@ -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>
|
||||
</div>
|
||||
<div id="split-pane">
|
||||
<% if (!note.isLabelTruthy("shareTemplateNoLeftPanel")) { %>
|
||||
<div id="left-pane">
|
||||
<div id="navigation">
|
||||
<div id="site-header">
|
||||
@ -143,6 +144,8 @@ content = content.replaceAll(headingRe, (...match) => {
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div id="right-pane">
|
||||
<div id="main">
|
||||
<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>
|
||||
<% } 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 %>
|
||||
<% } %>
|
||||
@ -189,7 +194,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (hasTree) { %>
|
||||
<% if (hasTree && !note.isLabelTruthy("shareTemplateNoPrevNext")) { %>
|
||||
<%- include("prev_next", { note: note, subRoot: subRoot }) %>
|
||||
<% } %>
|
||||
</footer>
|
||||
|
||||
434
pnpm-lock.yaml
generated
434
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user