Skip to content

Build your personal knowledge base with Trilium Notes

feat(resources): show each resource's license in the download dialog

Elian Doran99a8b979f03c
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ae90f8459e..061194ea0f 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -4621,6 +4621,7 @@
"retry": "Retry",
"cancel": "Cancel",
"not_enough_space_title": "Not enough free space",
- "failed_title": "Download failed"
+ "failed_title": "Download failed",
+ "license": "{{license}} license"
}
}
diff --git a/apps/client/src/widgets/dialogs/resource_download.spec.tsx b/apps/client/src/widgets/dialogs/resource_download.spec.tsx
index c5e939494a..5a3974ec39 100644
--- a/apps/client/src/widgets/dialogs/resource_download.spec.tsx
+++ b/apps/client/src/widgets/dialogs/resource_download.spec.tsx
@@ -32,6 +32,7 @@ const STATUS: ResourcesStatusResponse = {
title: "Speech recognition model",
description: "Transcribes meetings",
icon: "bx bx-captions",
+ license: "CC-BY-4.0",
size: 700,
downloadedSize: 200,
sources: [ "huggingface.co", "github.com" ],
@@ -66,6 +67,8 @@ describe("ResourceDownloadDialog", () => {
expect(row?.querySelector(".resource-download-icon")?.classList).toContain("bx-captions");
expect(row?.textContent).toContain("Speech recognition model");
expect(text(".resource-download-meta")).toContain("huggingface.co, github.com");
+ expect(text(".resource-download-license"))
+ .toBe(`resource_download.license:{"license":"CC-BY-4.0"}`);
expect(text(".resource-download-meta")).toContain(`"size":"200 B"`);
expect(text(".resource-download-item .resource-download-size")).toBe("700 B");
expect(text(".resource-download-total .resource-download-size")).toBe("500 B");
diff --git a/apps/client/src/widgets/dialogs/resource_download.tsx b/apps/client/src/widgets/dialogs/resource_download.tsx
index 9babdbda49..053582f8de 100644
--- a/apps/client/src/widgets/dialogs/resource_download.tsx
+++ b/apps/client/src/widgets/dialogs/resource_download.tsx
@@ -175,6 +175,10 @@ function ResourceItem({ resource, unitOf }: { resource: ResourceInfo; unitOf: nu
<small className="tn-card-option-description">{resource.description}</small>
<small className="tn-card-option-description resource-download-meta">
{t("resource_download.sources", { sources: resource.sources.join(", ") })}
+ {" · "}
+ <span className="resource-download-license">
+ {t("resource_download.license", { license: resource.license })}
+ </span>
{resource.downloadedSize > 0 && <>
{" · "}
{t("resource_download.partially_downloaded", {
diff --git a/apps/desktop/src/services/transcription/model.ts b/apps/desktop/src/services/transcription/model.ts
index 7833e1378b..7dee9d2ece 100644
--- a/apps/desktop/src/services/transcription/model.ts
+++ b/apps/desktop/src/services/transcription/model.ts
@@ -26,6 +26,7 @@ export const RECOGNIZER_MODEL: ResourceDefinition = {
title: () => t("transcription.recognizer-title"),
description: () => t("transcription.recognizer-description"),
icon: "bx bx-captions",
+ license: "CC-BY-4.0",
findLocalCopy: () => fs.existsSync(LOCAL_MODEL_DIR) ? LOCAL_MODEL_DIR : null,
files: [
{
@@ -61,6 +62,7 @@ export const VAD_MODEL: ResourceDefinition = {
title: () => t("transcription.vad-title"),
description: () => t("transcription.vad-description"),
icon: "bx bx-pulse",
+ license: "MIT",
findLocalCopy: () => fs.existsSync(path.join(LOCAL_MODEL_DIR, VAD_FILE)) ? LOCAL_MODEL_DIR : null,
files: [ {
path: VAD_FILE,
@@ -76,6 +78,7 @@ export const SPEAKER_MODEL: ResourceDefinition = {
title: () => t("transcription.speaker-title"),
description: () => t("transcription.speaker-description"),
icon: "bx bx-user-voice",
+ license: "Apache-2.0",
findLocalCopy: () => {
const directory = path.join(LOCAL_MODEL_DIR, "speaker");
return fs.existsSync(path.join(directory, SPEAKER_FILE)) ? directory : null;
diff --git a/apps/server/src/services/resources.spec.ts b/apps/server/src/services/resources.spec.ts
index 05cdd701cd..19ba98e5dd 100644
--- a/apps/server/src/services/resources.spec.ts
+++ b/apps/server/src/services/resources.spec.ts
@@ -89,6 +89,7 @@ describe("ResourceManager", () => {
title: "Test model",
description: "For tests",
icon: "bx bx-test-tube",
+ license: "MIT",
size: MODEL.length + TOKENS.length,
downloadedSize: MODEL.length + TOKENS.length,
sources: [ "127.0.0.1" ],
@@ -168,6 +169,7 @@ function defineModel({ id = "test.model", tokensUrl = "/tokens.txt", tokensHash
title: () => "Test model",
description: () => "For tests",
icon: "bx bx-test-tube",
+ license: "MIT",
files: [
file("nested/model.bin", MODEL),
{ path: "tokens.txt", url: `${baseUrl}${tokensUrl}`, size: tokensSize, sha256: tokensHash }
diff --git a/apps/server/src/services/resources.ts b/apps/server/src/services/resources.ts
index e1c1c2c4bf..c0a3e5907d 100644
--- a/apps/server/src/services/resources.ts
+++ b/apps/server/src/services/resources.ts
@@ -29,6 +29,8 @@ export interface ResourceDefinition {
description(): string;
/** Boxicons classes, `bx bx-…`, for the download dialog. */
icon: string;
+ /** The SPDX identifier of the license the files are under, such as `CC-BY-4.0`. */
+ license: string;
files: ResourceFile[];
/**
* Returns a directory that holds the files outside the manager, such as a model installed by
@@ -195,6 +197,7 @@ export class ResourceManager {
title: definition.title(),
description: definition.description(),
icon: definition.icon,
+ license: definition.license,
size: sumSizes(definition.files),
downloadedSize: sumSizes(downloaded),
sources: [ ...new Set(definition.files.map(({ url }) => new URL(url).hostname)) ],
diff --git a/packages/commons/src/lib/resources.ts b/packages/commons/src/lib/resources.ts
index 87e1c37807..a2f63c3234 100644
--- a/packages/commons/src/lib/resources.ts
+++ b/packages/commons/src/lib/resources.ts
@@ -11,6 +11,8 @@ export interface ResourceInfo {
description: string;
/** Boxicons classes, `bx bx-…`. */
icon: string;
+ /** The SPDX identifier of the license the resource is under, such as `CC-BY-4.0`. */
+ license: string;
/** The size of all its files, in bytes. */
size: number;
/** The bytes of its files already downloaded and verified, kept from an interrupted download. */