driftnet 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +5 -0
- package/README.md +94 -28
- package/README.zh-TW.md +91 -28
- package/dist/driftnet.mjs +2042 -217
- package/package.json +1 -1
- package/public/index.html +202 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driftnet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"mcpName": "io.github.KevinChu1110/driftnet",
|
|
5
5
|
"description": "Drop links into any chat; get them sorted, explained and searchable, for you and your agents. Any model, or none.",
|
|
6
6
|
"license": "MIT",
|
package/public/index.html
CHANGED
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
.brand { display: flex; align-items: center; gap: 8px; font-size: 19px; margin: 0; letter-spacing: -0.02em; font-weight: 750; }
|
|
51
51
|
@media (min-width: 721px) { header { padding-inline: max(20px, calc((100vw - 1200px) / 2 + 20px)); } }
|
|
52
52
|
.stats { color: var(--muted); font-size: 13px; }
|
|
53
|
+
.update { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; background: var(--bg); }
|
|
54
|
+
.update[hidden] { display: none; }
|
|
55
|
+
.update a { color: var(--accent); text-decoration: none; }
|
|
56
|
+
.update a:hover, .update a:focus-visible { text-decoration: underline; }
|
|
57
|
+
.update button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 999px; line-height: 1; }
|
|
53
58
|
.search { flex: 1; min-width: 180px; max-width: 420px; margin-left: auto; padding: 9px 12px; border: 1px solid var(--line);
|
|
54
59
|
border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
|
|
55
60
|
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 10px; }
|
|
@@ -515,6 +520,10 @@
|
|
|
515
520
|
.md-try pre { margin: 0; padding: 10px 70px 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; overflow: auto; font-size: 13px; user-select: text; -webkit-user-select: text; }
|
|
516
521
|
.md-try button { position: absolute; top: 6px; right: 6px; }
|
|
517
522
|
.md-tags { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; color: var(--muted); }
|
|
523
|
+
.md-hist ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
|
|
524
|
+
.md-hist li { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: var(--star-soft); font-size: 13px; }
|
|
525
|
+
.md-hist li div { min-width: 0; overflow-wrap: anywhere; }
|
|
526
|
+
.md-hist li small { display: block; color: var(--muted); }
|
|
518
527
|
.md-fine { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; }
|
|
519
528
|
.md-actions { flex: none; margin: 0; padding: 10px 18px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
|
|
520
529
|
.md-actions .spacer { flex: 1; }
|
|
@@ -587,6 +596,7 @@
|
|
|
587
596
|
</button>
|
|
588
597
|
<h1 class="brand"><img src="/favicon.svg" alt="" width="26" height="26">driftnet</h1>
|
|
589
598
|
<span class="stats" id="stats"></span>
|
|
599
|
+
<span class="update" id="update" hidden><a id="update-link" target="_blank" rel="noopener noreferrer"></a><button id="update-x" type="button">✕</button></span>
|
|
590
600
|
<input id="q" class="search" type="search" enterkeyhint="search">
|
|
591
601
|
<button id="lock" class="lock" type="button" hidden></button>
|
|
592
602
|
<button id="palette-btn" class="lang" type="button" aria-haspopup="dialog"></button>
|
|
@@ -719,7 +729,7 @@
|
|
|
719
729
|
kinds: { repo: "Repos", product: "Products", video: "Videos", article: "Articles", post: "Posts", other: "Other" },
|
|
720
730
|
kind1: { repo: "Repo", product: "Product", video: "Video", article: "Article", post: "Post", other: "Other" },
|
|
721
731
|
worth: { skip: "skip", low: "low", normal: "worth a look", "must-see": "must-see" },
|
|
722
|
-
flags: { injection: "prompt injection", "hidden-chars": "hidden characters", "low-reputation": "low-reputation source", "video-read": "read from video", "video-captions": "video captions", "video-ocr": "video on-screen text", "video-speech": "video speech" },
|
|
732
|
+
flags: { injection: "prompt injection", "hidden-chars": "hidden characters", "low-reputation": "low-reputation source", "video-read": "read from video", "video-captions": "video captions", "video-ocr": "video on-screen text", "video-speech": "video speech", "video-watch": "watched by the model", "video-vision": "frames seen by the model" },
|
|
723
733
|
pending: "waiting for a summary", noModel: "no summary — no model set up", enrichedBy: (a) => `summary by ${a}`,
|
|
724
734
|
favorite: "Add to favorites", unfavorite: "Remove from favorites", remove: "Move to trash", restore: "Restore",
|
|
725
735
|
swipeFav: "Favorite", swipeUnfav: "Unfavorite", swipeTrash: "Remove", swipeRestore: "Restore",
|
|
@@ -732,7 +742,7 @@
|
|
|
732
742
|
save: "Save", cancel: "Cancel", del: "Delete folder", delSure: "Delete? Links move up",
|
|
733
743
|
refresh: "Refresh (fetch and summarise again)", refreshed: (n) => `Refreshed “${n}”`, refreshBusy: "Already refreshing this one.", refreshWait: "Refreshed a moment ago — try again in a minute.", refreshFailed: (why) => `Couldn’t refresh${why ? `: ${why}` : ""}`,
|
|
734
744
|
moveTo: "Move to…", moveTitle: (n) => `Move “${n}” to`, moved: (n, f) => `Moved “${n}” to ${f}`, expand: "Show sub-folders",
|
|
735
|
-
dragHint: "Drag onto a folder in the sidebar", foundIn: "Found in this post:", folderMoved: (n, f) => `“${n}” is now inside ${f}`,
|
|
745
|
+
dragHint: "Drag onto a folder in the sidebar", foundIn: "Found in this post:", related: "Related:", folderMoved: (n, f) => `“${n}” is now inside ${f}`,
|
|
736
746
|
topLevelShort: "the top level",
|
|
737
747
|
pkShare: "Share as pack…", pkTitle: "Share as pack", pkHelp: "A pack is this folder, its sub-folders and the cards in them as one file. Someone else imports it with one click. Your notes, chat text and counters are never included.", pkName: "Pack name", pkDesc: "Description", pkDownload: "Download pack", pkLinkL: "Link to share", pkCopy: "Copy link", pkCopied: "Link copied", pkSigned: "Anyone with this link can download this one pack, and nothing else in your catalogue.", pkOpen: "Anyone who can reach this address can download this pack.", pkNoLink: "No public address is set, so there is no link to share yet. Set one in Settings → Access, or start a tunnel. You can still download the file.", pkClose: "Close", pkTooBig: "This folder is too big to share as a pack.",
|
|
738
748
|
mapAll: "All", focusCrumb: "Mind map location", focusUp: "Up one level", focusFolder: "Focus on this folder", mapTree: "Mind map",
|
|
@@ -745,6 +755,9 @@
|
|
|
745
755
|
layoutBoth: "Both sides", layoutRight: "Right side", layoutHelp: "Switch between branches on both sides (XMind) and all to the right",
|
|
746
756
|
zoom: "Zoom", gotIt: "Got it", more: (n) => `+${n} more`, mapSearch: (q) => `Highlighting “${q}”`, openLink: "Open link", mdDemo: "What you'll see", mdWhy: "Why it's here", mdHighlights: "Highlights", mdUse: "Good for", mdTry: "Try it", mdCopy: "Copy", mdCopied: "Copied", mdPrev: "Previous card", mdNext: "Next card", mdPos: (n, m) => `${n} of ${m}`, mdSlide: (n, m) => `Picture ${n} of ${m}`, mdPlay: "Play the video", mdPictures: "Pictures", mdTags: "Tags", mdHasNote: "Has your note", showInList: "Show in the list", close: "Close",
|
|
747
757
|
needPassword: "Changing things needs the admin password.",
|
|
758
|
+
histBtn: "History", histTitle: "Change history", histNone: "No changes recorded yet.", histRestore: "Restore", histRestored: "Restored an earlier version.", histErr: "Could not load the history.", histForget: "Forget history", histForgot: "History for this card was erased.",
|
|
759
|
+
histField: { note: "Note", summary: "Summary", title: "Title", folder: "Folder", favorite: "Star", trashed: "Trash" }, histEmptyVal: "(empty)", histStarOn: "starred", histStarOff: "not starred", histInTrash: "in the trash", histOutTrash: "not in the trash",
|
|
760
|
+
histActor: (a) => a === "admin" ? "You" : a === "system:refresh" ? "Refresh" : a === "system" ? "System" : a.replace(/^agent:/, "agent "),
|
|
748
761
|
notes: "Notes", note: "Note", addNote: "Add a note", editNote: "Edit note", noteFor: (n) => `Note on “${n}”`,
|
|
749
762
|
noteHelp: "Only for you: what you thought, whether you tried it…", newNote: "New note", noteTitle: "Title",
|
|
750
763
|
noteBody: "Markdown. Write #12 to link card 12.", delNote: "Delete note", delNoteSure: "Really delete?", untitled: "Untitled",
|
|
@@ -787,6 +800,13 @@
|
|
|
787
800
|
locked: "set by the environment driftnet runs in", forbidden: "Server settings can only be changed on the computer running driftnet (or set DRIFTNET_TOKEN). Display settings still work.",
|
|
788
801
|
savedServer: "Saved — already in effect", chat: "Chat replies", webhook: "Outgoing webhook", digest: "Scheduled digest", feed: "Feed (RSS)", genCopied: "New password generated and copied — press Save to keep it",
|
|
789
802
|
tabGeneral: "General", tabAccess: "Access", tabAi: "AI",
|
|
803
|
+
updates: "Updates", bkTitle: "Backup", bkHelp: "One zip with your whole catalogue (cards, folders, notes, tokens) and your settings. Passwords and keys are left out unless you tick the box.",
|
|
804
|
+
bkDownload: "Download backup", bkSecrets: "Include passwords and keys (enter the admin password again)", bkPassword: "Admin password",
|
|
805
|
+
bkRestoreFile: "Restore from a backup file", bkRestoreHelp: "The backup is checked first. Nothing changes until you restart driftnet; your current data is kept next to it as a before-restore copy.",
|
|
806
|
+
bkChecking: "Checking the backup…", bkNeedPassword: "Type the admin password to include passwords and keys.", bkMade: "Backup downloaded.",
|
|
807
|
+
bkRestartTitle: "Restart driftnet to finish restoring", bkRestartBody: (n) => `The backup (${n} cards) is checked and waiting. It replaces your data the next time driftnet starts.`,
|
|
808
|
+
bkSettingsTitle: "Settings in the backup (not applied). Copy what you want into Settings:", bkPending: "A restore is waiting: restart driftnet to finish restoring.",
|
|
809
|
+
updOut: (v) => `driftnet ${v} is out`, updHow: "How to update", updDismiss: "Dismiss",
|
|
790
810
|
impPackTitle: "From a pack link", impPackHelp: "Paste the link someone sent you for a folder pack. It comes in already summarised (no model calls), under its own folder.", impPackGo: "Check link", impPackConfirm: (name, n, dup) => `Pack “${name}”: ${n} new cards (${dup} already there). Import it?`, impPackNone: (name, dup) => `Pack “${name}” has nothing new (${dup} already there). Import anyway to file them?`, impPackDone: (name, added, already) => `Imported “${name}”: ${added} added, ${already} already there.`,
|
|
791
811
|
impTitle: "Import bookmarks", impHelp: "Bring in a bookmarks file from your browser (HTML), Pocket, Raindrop (CSV), a driftnet JSON list, or any text with links.",
|
|
792
812
|
impFile: "Choose a file", impKeep: "Keep my bookmark folders (under Imported)", impReading: "Reading the file…",
|
|
@@ -836,6 +856,12 @@
|
|
|
836
856
|
DRIFTNET_LLM_EFFORT: ["Reasoning effort", ""],
|
|
837
857
|
TYPESAFE_API_KEY: ["Jev key", "Optional: a ~100 ms classifier that saves model calls (console.typesafe.ai)"],
|
|
838
858
|
DRIFTNET_JUDGE: ["Judge", "Who files each link before the model does. Rules is free: it needs no model."],
|
|
859
|
+
DRIFTNET_EMBED: ["Search by meaning", "Finds cards by what they are about, not just the words (\"login\" finds OAuth). Needs an embedding model: Ollama with nomic-embed-text, or a provider below. Costs no summary tokens."],
|
|
860
|
+
DRIFTNET_EMBED_PROVIDER: ["Embedding provider", "Naming one turns Search by meaning on. Ollama stays on your machine; OpenAI and Gemini send each card's summary (never your notes or chat) to them."],
|
|
861
|
+
DRIFTNET_EMBED_MODEL: ["Embedding model", "Default: nomic-embed-text (Ollama), text-embedding-3-small (OpenAI), gemini-embedding-001 (Gemini). Changing it re-embeds everything in the background."],
|
|
862
|
+
DRIFTNET_EMBED_BASE_URL: ["Embedding API URL", "Ollama or an OpenAI-compatible server, e.g. http://127.0.0.1:11434. Empty: the provider's own address."],
|
|
863
|
+
DRIFTNET_EMBED_API_KEY: ["Embedding API key", "OpenAI or Gemini. The summary model's key is reused only when it is the same vendor."],
|
|
864
|
+
DRIFTNET_EMBED_FLOOR: ["Meaning match threshold", "0–1. How close a card must be in meaning to show without a matching word. Default 0.55 for nomic-embed-text; higher shows fewer matches."],
|
|
839
865
|
DRIFTNET_LLM_REGION: ["Region", "Bedrock: e.g. us-east-1. Vertex: e.g. us-central1 (default). Not used by other providers."],
|
|
840
866
|
AWS_ACCESS_KEY_ID: ["AWS access key ID", "Bedrock. Leave empty if you use a Bedrock API key."],
|
|
841
867
|
AWS_SECRET_ACCESS_KEY: ["AWS secret access key", "Bedrock."],
|
|
@@ -852,6 +878,8 @@
|
|
|
852
878
|
DRIFTNET_PUBLIC_URL: ["This page's public URL", "Replies link here, e.g. https://driftnet.example.com"],
|
|
853
879
|
DRIFTNET_SUMMARY_DEPTH: ["Summary detail", "How much each card says. Detailed costs more model tokens and reads twice as much of each page."],
|
|
854
880
|
DRIFTNET_SUMMARY_RULES: ["Extra rules for summaries", "e.g. Say whether it's free. Mention if it needs a GPU."],
|
|
881
|
+
DRIFTNET_PROFILE: ["About you", "Who you are and what you care about (600 characters at most). The model uses it to judge what is worth your time and to write the \"why\" line. e.g. Backend engineer, Odoo and TypeScript; collecting AI coding tools and MCP servers; not interested in crypto."],
|
|
882
|
+
DRIFTNET_UPDATE_CHECK: ["Check for new versions", "Once a day driftnet asks the npm registry for the latest version number (nothing about you is sent) and shows a small notice. Off (the default) = never."],
|
|
855
883
|
DRIFTNET_BLOCK_DOMAINS: ["Never catalogue these domains", "Comma or space separated, e.g. example.com, spam.io"],
|
|
856
884
|
DRIFTNET_WEBHOOK_URL: ["Webhook URL", "driftnet POSTs each new or updated card here (n8n, Zapier, Slack workflows…). Treated as a secret."],
|
|
857
885
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook signing secret", "Optional. Adds X-Driftnet-Signature: sha256=<HMAC of the body>."],
|
|
@@ -865,6 +893,7 @@
|
|
|
865
893
|
DRIFTNET_FFMPEG: ["ffmpeg path", "Only if ffmpeg is not on PATH."],
|
|
866
894
|
DRIFTNET_TESSERACT: ["tesseract path", "Only if tesseract (on-screen text) is not on PATH."],
|
|
867
895
|
DRIFTNET_WHISPER: ["whisper path", "Only if whisper or whisper-cli (speech) is not on PATH."],
|
|
896
|
+
DRIFTNET_VIDEO_FRAMES: ["Show frames to the model", "Off by default. When on, and a reel or short is still thin after the local tools, up to 8 distinct frames are attached to the same summary request, so they go to the model you configured and nowhere else. The model must accept pictures (Ollama: a vision model)."],
|
|
868
897
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["Allow a local webhook", "Needed when the receiver is on your own network (n8n on a LAN). Only that exact address is allowed."],
|
|
869
898
|
},
|
|
870
899
|
choices: {
|
|
@@ -879,7 +908,11 @@
|
|
|
879
908
|
DRIFTNET_DIGEST_DAY: { "": "Monday (default)", mon: "Monday", tue: "Tuesday", wed: "Wednesday", thu: "Thursday", fri: "Friday", sat: "Saturday", sun: "Sunday" },
|
|
880
909
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "No (public addresses only)", 1: "Yes" },
|
|
881
910
|
DRIFTNET_HEALTH: { "": "Off (default)", off: "Off", weekly: "Weekly (recommended)" },
|
|
882
|
-
|
|
911
|
+
DRIFTNET_EMBED: { "": "Automatic (default): on when a local model is found", auto: "Automatic: on when a local model is found", off: "Off" },
|
|
912
|
+
DRIFTNET_EMBED_PROVIDER: { "": "Automatic (local Ollama only)", ollama: "Ollama (on this computer)", openai: "OpenAI", gemini: "Gemini" },
|
|
913
|
+
DRIFTNET_UPDATE_CHECK: { "": "Off (default)", 1: "On", 0: "Off" },
|
|
914
|
+
DRIFTNET_VIDEO: { "": "Automatic (default)", auto: "Automatic: use the tools found", captions: "Captions only (light on battery: no download, OCR or speech)", watch: "Also let Gemini/Vertex watch it (sends the video or its YouTube link to that model)", off: "Off" },
|
|
915
|
+
DRIFTNET_VIDEO_FRAMES: { "": "Off (default)", off: "Off", vision: "Attach up to 8 frames to the summary (needs a vision model)" },
|
|
883
916
|
},
|
|
884
917
|
},
|
|
885
918
|
},
|
|
@@ -891,7 +924,7 @@
|
|
|
891
924
|
pageMore: (n) => `再顯示 ${n} 張`, emptyTrash: "垃圾桶是空的。", hint: "往右滑加入最愛,往左滑移到垃圾桶。", hintTrash: "往右滑還原。",
|
|
892
925
|
kinds: { repo: "程式庫", product: "產品", video: "影片", article: "文章", post: "貼文", other: "其他" },
|
|
893
926
|
worth: { skip: "略過", low: "次要", normal: "值得看", "must-see": "必看" },
|
|
894
|
-
flags: { injection: "提示詞注入", "hidden-chars": "隱藏字元", "low-reputation": "低信譽來源", "video-read": "已從影片讀取", "video-captions": "影片字幕", "video-ocr": "影片畫面文字", "video-speech": "影片語音" },
|
|
927
|
+
flags: { injection: "提示詞注入", "hidden-chars": "隱藏字元", "low-reputation": "低信譽來源", "video-read": "已從影片讀取", "video-captions": "影片字幕", "video-ocr": "影片畫面文字", "video-speech": "影片語音", "video-watch": "模型已看過影片", "video-vision": "模型已看過畫面" },
|
|
895
928
|
pending: "等待摘要", noModel: "沒有摘要(未設定模型)", enrichedBy: (a) => `由 ${a} 整理`,
|
|
896
929
|
favorite: "加入最愛", unfavorite: "移出最愛", remove: "移到垃圾桶", restore: "還原",
|
|
897
930
|
swipeFav: "加入最愛", swipeUnfav: "移出最愛", swipeTrash: "移到垃圾桶", swipeRestore: "還原",
|
|
@@ -904,7 +937,7 @@
|
|
|
904
937
|
save: "儲存", cancel: "取消", del: "刪除資料夾", delSure: "確定刪除?內容移到上一層",
|
|
905
938
|
refresh: "重新整理(再抓一次並重新摘要)", refreshed: (n) => `已重新整理「${n}」`, refreshBusy: "這張卡片正在重新整理。", refreshWait: "剛剛才整理過,請一分鐘後再試。", refreshFailed: (why) => `重新整理失敗${why ? `:${why}` : ""}`,
|
|
906
939
|
moveTo: "移動到…", moveTitle: (n) => `把「${n}」移動到`, moved: (n, f) => `已將「${n}」移到 ${f}`, expand: "展開子資料夾",
|
|
907
|
-
dragHint: "拖到側邊欄的資料夾", foundIn: "從這篇找到:", folderMoved: (n, f) => `「${n}」已移到 ${f} 底下`,
|
|
940
|
+
dragHint: "拖到側邊欄的資料夾", foundIn: "從這篇找到:", related: "相關卡片:", folderMoved: (n, f) => `「${n}」已移到 ${f} 底下`,
|
|
908
941
|
topLevelShort: "最上層",
|
|
909
942
|
pkShare: "分享成資料夾包…", pkTitle: "分享成資料夾包", pkHelp: "資料夾包把這個資料夾、底下的子資料夾和裡面的卡片包成一個檔案,別人一鍵就能匯入。你的筆記、聊天內容和各種計數都不會放進去。", pkName: "資料夾包名稱", pkDesc: "說明", pkDownload: "下載資料夾包", pkLinkL: "分享連結", pkCopy: "複製連結", pkCopied: "已複製連結", pkSigned: "拿到這個連結的人只能下載這一個資料夾包,看不到你目錄裡的其他內容。", pkOpen: "任何連得到這個位址的人都能下載這個資料夾包。", pkNoLink: "還沒設定公開網址,所以暫時沒有可分享的連結。請到「設定 → 存取」設定,或啟動通道。現在仍可以下載檔案。", pkClose: "關閉", pkTooBig: "這個資料夾太大,無法分享成資料夾包。",
|
|
910
943
|
mapAll: "全部", focusCrumb: "樹狀圖位置", focusUp: "回上一層", focusFolder: "聚焦這個資料夾", mapTree: "樹狀圖",
|
|
@@ -917,6 +950,9 @@
|
|
|
917
950
|
layoutBoth: "兩側展開", layoutRight: "往右展開", layoutHelp: "切換:分支分佈在兩側(XMind 預設)或全部往右",
|
|
918
951
|
zoom: "縮放", gotIt: "知道了", more: (n) => `還有 ${n} 張`, mapSearch: (q) => `標亮「${q}」`, openLink: "開啟連結", mdDemo: "你會看到什麼", mdWhy: "為什麼收進來", mdHighlights: "重點", mdUse: "適合用在", mdTry: "試試看", mdCopy: "複製", mdCopied: "已複製", mdPrev: "上一張卡片", mdNext: "下一張卡片", mdPos: (n, m) => `第 ${n} / ${m} 張`, mdSlide: (n, m) => `第 ${n} 張圖,共 ${m} 張`, mdPlay: "播放影片", mdPictures: "圖片", mdTags: "標籤", mdHasNote: "有你的筆記", showInList: "在清單中查看", close: "關閉",
|
|
919
952
|
needPassword: "要修改需要管理密碼。",
|
|
953
|
+
histBtn: "修改紀錄", histTitle: "修改紀錄", histNone: "還沒有修改紀錄。", histRestore: "還原", histRestored: "已還原成先前的版本。", histErr: "無法載入修改紀錄。", histForget: "清除紀錄", histForgot: "這張卡片的修改紀錄已清除。",
|
|
954
|
+
histField: { note: "筆記", summary: "摘要", title: "標題", folder: "資料夾", favorite: "星號", trashed: "垃圾桶" }, histEmptyVal: "(空白)", histStarOn: "已加星", histStarOff: "未加星", histInTrash: "在垃圾桶", histOutTrash: "不在垃圾桶",
|
|
955
|
+
histActor: (a) => a === "admin" ? "你" : a === "system:refresh" ? "重新整理" : a === "system" ? "系統" : a.replace(/^agent:/, "agent "),
|
|
920
956
|
notes: "筆記", note: "筆記", addNote: "加筆記", editNote: "改筆記", noteFor: (n) => `「${n}」的筆記`,
|
|
921
957
|
noteHelp: "只有你看得到:心得、試用結果、要注意的地方…", newNote: "新筆記", noteTitle: "標題",
|
|
922
958
|
noteBody: "支援 Markdown。寫 #12 就會連到第 12 張卡片。", delNote: "刪除筆記", delNoteSure: "確定刪除?", untitled: "未命名",
|
|
@@ -959,6 +995,13 @@
|
|
|
959
995
|
locked: "由執行環境設定", forbidden: "伺服器設定只能在執行 driftnet 的那台電腦上改(或設定 DRIFTNET_TOKEN)。顯示設定照常可用。",
|
|
960
996
|
savedServer: "已儲存,馬上生效", chat: "聊天室回覆", webhook: "對外 Webhook", digest: "定時摘要", feed: "訂閱源(RSS)", genCopied: "已產生新密碼並複製,按「儲存」才會生效",
|
|
961
997
|
tabGeneral: "一般", tabAccess: "存取", tabAi: "AI",
|
|
998
|
+
updates: "更新", bkTitle: "備份", bkHelp: "一個 zip 檔,包含整個收藏(卡片、資料夾、筆記、權杖)和設定。除非勾選,否則不會包含密碼和金鑰。",
|
|
999
|
+
bkDownload: "下載備份", bkSecrets: "包含密碼和金鑰(需要再輸入一次管理員密碼)", bkPassword: "管理員密碼",
|
|
1000
|
+
bkRestoreFile: "從備份檔還原", bkRestoreHelp: "會先檢查備份檔。重新啟動 driftnet 之前不會有任何改變;目前的資料會留在旁邊,檔名帶有 before-restore。",
|
|
1001
|
+
bkChecking: "正在檢查備份檔…", bkNeedPassword: "要包含密碼和金鑰,請輸入管理員密碼。", bkMade: "備份已下載。",
|
|
1002
|
+
bkRestartTitle: "請重新啟動 driftnet 以完成還原", bkRestartBody: (n) => `備份檔(${n} 張卡片)已檢查完畢並等待中,下次 driftnet 啟動時會取代目前的資料。`,
|
|
1003
|
+
bkSettingsTitle: "備份裡的設定(不會自動套用)。需要的話請自行複製到「設定」:", bkPending: "有一份還原正在等待:請重新啟動 driftnet 以完成還原。",
|
|
1004
|
+
updOut: (v) => `driftnet ${v} 已發布`, updHow: "如何更新", updDismiss: "關閉",
|
|
962
1005
|
impPackTitle: "從資料夾包連結匯入", impPackHelp: "貼上別人傳給你的資料夾包連結。卡片已經整理好(不會呼叫模型),會放進它自己的資料夾。", impPackGo: "檢查連結", impPackConfirm: (name, n, dup) => `資料夾包「${name}」:${n} 張新卡片(${dup} 張已經有了)。要匯入嗎?`, impPackNone: (name, dup) => `資料夾包「${name}」沒有新的卡片(${dup} 張已經有了)。仍要匯入把它們歸檔嗎?`, impPackDone: (name, added, already) => `已匯入「${name}」:新增 ${added}、原本就有 ${already}。`,
|
|
963
1006
|
impTitle: "匯入書籤", impHelp: "匯入瀏覽器的書籤檔(HTML)、Pocket、Raindrop(CSV)、driftnet 的 JSON 清單,或任何含有連結的文字檔。",
|
|
964
1007
|
impFile: "選擇檔案", impKeep: "保留我的書籤資料夾(放在「Imported」底下)", impReading: "讀取檔案中…",
|
|
@@ -1008,6 +1051,12 @@
|
|
|
1008
1051
|
DRIFTNET_LLM_EFFORT: ["推理強度", ""],
|
|
1009
1052
|
TYPESAFE_API_KEY: ["Jev 金鑰", "選填:約 100ms 的分類器,可以省下模型呼叫(console.typesafe.ai)"],
|
|
1010
1053
|
DRIFTNET_JUDGE: ["判斷器", "在模型之前先決定每個連結放哪。「規則」免費,不需要模型。"],
|
|
1054
|
+
DRIFTNET_EMBED: ["以語意搜尋", "依內容意思找卡片,不只比對字(搜「登入」能找到 OAuth)。需要嵌入模型:本機 Ollama 的 nomic-embed-text,或下面的服務。不花摘要的 token。"],
|
|
1055
|
+
DRIFTNET_EMBED_PROVIDER: ["嵌入服務", "指定一個就會開啟語意搜尋。Ollama 全程在你的電腦上;OpenAI、Gemini 會收到每張卡片的摘要(不會有你的筆記或聊天內容)。"],
|
|
1056
|
+
DRIFTNET_EMBED_MODEL: ["嵌入模型", "預設:nomic-embed-text(Ollama)、text-embedding-3-small(OpenAI)、gemini-embedding-001(Gemini)。更換後會在背景重新計算全部卡片。"],
|
|
1057
|
+
DRIFTNET_EMBED_BASE_URL: ["嵌入 API 網址", "Ollama 或相容 OpenAI 的伺服器,例如 http://127.0.0.1:11434。留空:用該服務的預設位址。"],
|
|
1058
|
+
DRIFTNET_EMBED_API_KEY: ["嵌入 API 金鑰", "OpenAI 或 Gemini 用。只有摘要模型是同一家時才會沿用它的金鑰。"],
|
|
1059
|
+
DRIFTNET_EMBED_FLOOR: ["語意相符門檻", "0–1。沒有字面相符時,意思要多接近才會出現。nomic-embed-text 預設 0.55;調高結果會變少。"],
|
|
1011
1060
|
DRIFTNET_LLM_REGION: ["區域", "Bedrock:例如 us-east-1。Vertex:例如 us-central1(預設)。其他供應商用不到。"],
|
|
1012
1061
|
AWS_ACCESS_KEY_ID: ["AWS 存取金鑰 ID", "Bedrock 用。有 Bedrock API 金鑰就留空。"],
|
|
1013
1062
|
AWS_SECRET_ACCESS_KEY: ["AWS 秘密存取金鑰", "Bedrock 用。"],
|
|
@@ -1024,6 +1073,8 @@
|
|
|
1024
1073
|
DRIFTNET_PUBLIC_URL: ["這個網頁的公開網址", "回覆裡的連結會指到這裡,例如 https://driftnet.example.com"],
|
|
1025
1074
|
DRIFTNET_SUMMARY_DEPTH: ["摘要詳細程度", "每張卡片寫多少。詳細會用較多模型 token,且每個頁面讀兩倍的內容。"],
|
|
1026
1075
|
DRIFTNET_SUMMARY_RULES: ["摘要的額外規則", "例如:說明是否免費。需要 GPU 的話要提到。"],
|
|
1076
|
+
DRIFTNET_PROFILE: ["關於你", "你是誰、關心什麼(最多 600 字)。模型會用它判斷什麼值得你花時間,並寫「為什麼值得看」那一句。例如:後端工程師,做 Odoo 和 TypeScript;蒐集 AI 寫程式工具和 MCP 伺服器;對加密貨幣沒興趣。"],
|
|
1077
|
+
DRIFTNET_UPDATE_CHECK: ["檢查新版本", "每天向 npm 查一次最新版本號(不會傳送任何與你有關的資料),有新版就顯示小提示。關閉(預設)=完全不查。"],
|
|
1027
1078
|
DRIFTNET_BLOCK_DOMAINS: ["不要收錄的網域", "用逗號或空白分隔,例如 example.com, spam.io"],
|
|
1028
1079
|
DRIFTNET_WEBHOOK_URL: ["Webhook 網址", "每張新增或更新的卡片都會 POST 到這裡(n8n、Zapier、Slack 工作流程…)。視為機密。"],
|
|
1029
1080
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook 簽章密鑰", "選填。會加上 X-Driftnet-Signature: sha256=<內容的 HMAC>。"],
|
|
@@ -1037,6 +1088,7 @@
|
|
|
1037
1088
|
DRIFTNET_FFMPEG: ["ffmpeg 路徑", "只有 ffmpeg 不在 PATH 時才需要。"],
|
|
1038
1089
|
DRIFTNET_TESSERACT: ["tesseract 路徑", "只有 tesseract(讀畫面文字)不在 PATH 時才需要。"],
|
|
1039
1090
|
DRIFTNET_WHISPER: ["whisper 路徑", "只有 whisper 或 whisper-cli(語音轉文字)不在 PATH 時才需要。"],
|
|
1091
|
+
DRIFTNET_VIDEO_FRAMES: ["把畫面交給模型看", "預設關閉。開啟後,reel 或 short 在本機工具讀完後仍然太少時,最多 8 張不重複的畫面會附在同一次摘要請求裡,只送給你設定的模型。模型必須看得懂圖片(Ollama:要用視覺模型)。"],
|
|
1040
1092
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["允許本機 Webhook", "接收端在你自己的區域網路時需要(例如內網的 n8n)。只放行你填的那個位址。"],
|
|
1041
1093
|
},
|
|
1042
1094
|
choices: {
|
|
@@ -1051,7 +1103,11 @@
|
|
|
1051
1103
|
DRIFTNET_DIGEST_DAY: { "": "週一(預設)", mon: "週一", tue: "週二", wed: "週三", thu: "週四", fri: "週五", sat: "週六", sun: "週日" },
|
|
1052
1104
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "否(只允許公開位址)", 1: "是" },
|
|
1053
1105
|
DRIFTNET_HEALTH: { "": "關閉(預設)", off: "關閉", weekly: "每週(建議)" },
|
|
1054
|
-
|
|
1106
|
+
DRIFTNET_EMBED: { "": "自動(預設):找到本機模型就開", auto: "自動:找到本機模型就開", off: "關閉" },
|
|
1107
|
+
DRIFTNET_EMBED_PROVIDER: { "": "自動(只找本機 Ollama)", ollama: "Ollama(在這台電腦上)", openai: "OpenAI", gemini: "Gemini" },
|
|
1108
|
+
DRIFTNET_UPDATE_CHECK: { "": "關閉(預設)", 1: "開啟", 0: "關閉" },
|
|
1109
|
+
DRIFTNET_VIDEO: { "": "自動(預設)", auto: "自動:有找到工具就用", captions: "只抓字幕(省電:不下載影片、不跑文字辨識和語音模型)", watch: "再讓 Gemini/Vertex 直接看影片(會把影片或 YouTube 連結送給該模型)", off: "關閉" },
|
|
1110
|
+
DRIFTNET_VIDEO_FRAMES: { "": "關閉(預設)", off: "關閉", vision: "把最多 8 張畫面附在摘要請求裡(需要視覺模型)" },
|
|
1055
1111
|
},
|
|
1056
1112
|
},
|
|
1057
1113
|
},
|
|
@@ -1068,7 +1124,7 @@
|
|
|
1068
1124
|
// Warnings (injection, hidden characters, low reputation) keep ⚠; "read from video" is good news, not a warning.
|
|
1069
1125
|
function flagLines(i, t) {
|
|
1070
1126
|
const flags = i.flags ?? [];
|
|
1071
|
-
const warn = flags.filter((f) => !f.startsWith("video-"));
|
|
1127
|
+
const warn = flags.filter((f) => !f.startsWith("video-") && f !== "needs-transcript");
|
|
1072
1128
|
const steps = flags.filter((f) => f.startsWith("video-") && f !== "video-read");
|
|
1073
1129
|
return (warn.length ? `<div class="flag">⚠ ${esc(warn.map((f) => t.flags[f] ?? f).join(", "))}</div>` : "")
|
|
1074
1130
|
+ (flags.includes("video-read") ? `<div class="vflag">🎬 ${esc(t.flags["video-read"])}${steps.length ? ` · ${esc(steps.map((f) => t.flags[f] ?? f).join(", "))}` : ""}</div>` : "");
|
|
@@ -1230,6 +1286,7 @@
|
|
|
1230
1286
|
if (!STRINGS[saved] && STRINGS[ui.locale]) locale = ui.locale;
|
|
1231
1287
|
applyLocale();
|
|
1232
1288
|
$("stats").textContent = T().stats(stats.items, stats.shares);
|
|
1289
|
+
showUpdate(stats.update);
|
|
1233
1290
|
$("lock").innerHTML = `${ic("lock")}<span class="long">${esc(T().st.viewOnly)}</span><span class="short">${esc(T().st.unlockShort)}</span>`;
|
|
1234
1291
|
const btn = (field, key, label, n, icon) =>
|
|
1235
1292
|
`<button type="button" data-field="${field}" data-value="${esc(key)}" aria-pressed="${state[field] === key}">
|
|
@@ -1693,7 +1750,7 @@
|
|
|
1693
1750
|
const yes = (b) => (b ? "✓" : "—");
|
|
1694
1751
|
const accessStatus = `<p class="set-status">${esc(st.accessStatus(yes(a.passwordSet), yes(a.readKey), a.tunnel.running ? a.tunnel.url : "—"))}</p>`;
|
|
1695
1752
|
server = {
|
|
1696
|
-
general: group("language") + group("chat") + group("digest") + group("webhook") + importPanel(),
|
|
1753
|
+
general: group("language") + group("chat") + group("digest") + group("webhook") + group("updates") + importPanel() + backupPanel(serverSettings),
|
|
1697
1754
|
access: accessStatus + accessPanel(serverSettings, field) + (agentTokens ? tokensPanel(serverSettings.access, agentTokens, minted) + pairPanel(serverSettings.access) : ""),
|
|
1698
1755
|
ai: `<p class="set-status" id="st-status">${esc(st.status(serverSettings.engines))}</p>` + group("model") + group("rules") +
|
|
1699
1756
|
`<fieldset class="set-group"><legend>${esc(st.plugins)}</legend><div class="set-row">${plugins}</div></fieldset>`,
|
|
@@ -1717,6 +1774,53 @@
|
|
|
1717
1774
|
$("settings-dlg").showModal();
|
|
1718
1775
|
$("st-body").querySelector('[data-tab-btn][aria-selected="true"]')?.focus();
|
|
1719
1776
|
}
|
|
1777
|
+
/** Settings › Backup: download a zip (secrets only with the password typed again) or restore one (applied at the next start). */
|
|
1778
|
+
function backupPanel(sv) {
|
|
1779
|
+
const st = T().st;
|
|
1780
|
+
return `<fieldset class="set-group" id="backup-panel"><legend>${esc(st.bkTitle)}</legend>
|
|
1781
|
+
<small>${esc(st.bkHelp)}</small>
|
|
1782
|
+
<label class="set-row check"><input type="checkbox" id="bk-secrets"><span>${esc(st.bkSecrets)}</span></label>
|
|
1783
|
+
<label class="set-row" id="bk-pw-row" hidden><span>${esc(st.bkPassword)}</span><input type="password" id="bk-pw" autocomplete="off"></label>
|
|
1784
|
+
<div><button class="btn" type="button" id="bk-download">${esc(st.bkDownload)}</button></div>
|
|
1785
|
+
<small>${esc(st.bkRestoreHelp)}</small>
|
|
1786
|
+
<label class="set-row"><span>${esc(st.bkRestoreFile)}</span><input type="file" id="bk-file" accept=".zip,application/zip"></label>
|
|
1787
|
+
<p class="set-status" id="bk-status" role="status" aria-live="polite">${sv.restorePending ? esc(st.bkPending) : ""}</p>
|
|
1788
|
+
<pre id="bk-settings" hidden style="white-space:pre-wrap;user-select:all;font-size:12px"></pre></fieldset>`;
|
|
1789
|
+
}
|
|
1790
|
+
$("st-body").addEventListener("change", (e) => {
|
|
1791
|
+
if (e.target.id === "bk-secrets") $("bk-pw-row").hidden = !e.target.checked;
|
|
1792
|
+
});
|
|
1793
|
+
$("st-body").addEventListener("click", async (e) => {
|
|
1794
|
+
if (e.target.id !== "bk-download") return;
|
|
1795
|
+
const st = T().st, out = $("bk-status"), token = store.get("driftnet-token");
|
|
1796
|
+
const secrets = $("bk-secrets").checked, pw = $("bk-pw").value;
|
|
1797
|
+
if (secrets && !pw) { out.textContent = st.bkNeedPassword; return; }
|
|
1798
|
+
const res = await fetch(`/api/backup${secrets ? "?secrets=1" : ""}`, { headers: { ...(token ? { authorization: `Bearer ${token}` } : {}), ...(secrets ? { "x-driftnet-confirm": pw } : {}) } }).catch(() => null);
|
|
1799
|
+
$("bk-pw").value = "";
|
|
1800
|
+
if (res?.status === 401) { askToken(); return; }
|
|
1801
|
+
if (!res?.ok) { out.textContent = (await res?.json().catch(() => null))?.error ?? T().failed; return; }
|
|
1802
|
+
const name = /filename="([^"]+)"/.exec(res.headers.get("content-disposition") ?? "")?.[1] ?? "driftnet-backup.zip";
|
|
1803
|
+
const a = Object.assign(document.createElement("a"), { href: URL.createObjectURL(await res.blob()), download: name });
|
|
1804
|
+
document.body.append(a); a.click(); a.remove();
|
|
1805
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
|
1806
|
+
out.textContent = st.bkMade;
|
|
1807
|
+
});
|
|
1808
|
+
$("st-body").addEventListener("change", async (e) => {
|
|
1809
|
+
if (e.target.id !== "bk-file") return;
|
|
1810
|
+
const st = T().st, out = $("bk-status"), pre = $("bk-settings"), token = store.get("driftnet-token");
|
|
1811
|
+
const file = e.target.files?.[0];
|
|
1812
|
+
pre.hidden = true;
|
|
1813
|
+
if (!file) { out.textContent = ""; return; }
|
|
1814
|
+
out.textContent = st.bkChecking;
|
|
1815
|
+
const res = await fetch("/api/backup/restore", { method: "POST", body: file, headers: { "content-type": "application/zip", ...(token ? { authorization: `Bearer ${token}` } : {}) } }).catch(() => null);
|
|
1816
|
+
e.target.value = "";
|
|
1817
|
+
if (res?.status === 401 || res?.status === 403) { askToken(); return; }
|
|
1818
|
+
const body = res ? await res.json().catch(() => ({})) : {};
|
|
1819
|
+
if (!res?.ok) { out.textContent = body.error ?? T().failed; return; }
|
|
1820
|
+
out.textContent = `${st.bkRestartTitle}. ${st.bkRestartBody(body.items)}`;
|
|
1821
|
+
out.style.fontWeight = "600";
|
|
1822
|
+
if (body.settings) { pre.textContent = `${st.bkSettingsTitle}\n\n${body.settings}`; pre.hidden = false; }
|
|
1823
|
+
});
|
|
1720
1824
|
/** Settings › Import bookmarks: pick a file, preview the counts (dry run), confirm, then watch the job. */
|
|
1721
1825
|
let importContent = "", importUrl = "", importPack = null, importTimer = null;
|
|
1722
1826
|
function importPanel() {
|
|
@@ -2600,6 +2704,20 @@
|
|
|
2600
2704
|
return `<div class="gallery"><div class="g-track" id="g-track" tabindex="0" role="region" aria-label="${esc(t.mdPictures)}">${m.map(slide).join("")}</div>${
|
|
2601
2705
|
m.length > 1 ? `<div class="g-thumbs">${m.map((x, n) => `<button type="button" class="g-th ${n ? "" : "on"}" data-g="${n}" aria-label="${esc(t.mdSlide(n + 1, m.length))}">${img(x, "t")}</button>`).join("")}</div>` : ""}</div>`;
|
|
2602
2706
|
}
|
|
2707
|
+
// Related cards ({id, name}) come with the single-card endpoint; fetched once per card, painted into their own row.
|
|
2708
|
+
const relatedCache = new Map();
|
|
2709
|
+
function paintRelated(id) {
|
|
2710
|
+
const box = $("md-related");
|
|
2711
|
+
if (!box) return;
|
|
2712
|
+
const rel = relatedCache.get(id);
|
|
2713
|
+
if (rel === undefined) {
|
|
2714
|
+
relatedCache.set(id, []);
|
|
2715
|
+
api(`/api/items/${id}`).then((r) => { relatedCache.set(id, r.related ?? []); if (modalId === id) paintRelated(id); }).catch(() => relatedCache.delete(id));
|
|
2716
|
+
return;
|
|
2717
|
+
}
|
|
2718
|
+
box.hidden = !rel.length;
|
|
2719
|
+
box.innerHTML = rel.length ? `<span>${esc(T().related)}</span>${rel.map((c) => `<a href="#item-${c.id}" data-open="${c.id}">${esc(c.name)}</a>`).join("")}` : "";
|
|
2720
|
+
}
|
|
2603
2721
|
function paintModal() {
|
|
2604
2722
|
const i = find(modalId);
|
|
2605
2723
|
if (!i) return void (mdlDlg.open && mdlDlg.close());
|
|
@@ -2630,8 +2748,10 @@
|
|
|
2630
2748
|
${sec("try", t.mdTry, s?.tryIt ? `<div class="md-try"><pre><code>${esc(s.tryIt)}</code></pre><button class="btn" type="button" data-md="copy">${esc(t.mdCopy)}</button></div>` : "")}
|
|
2631
2749
|
${sec("tags", t.mdTags, s?.tags?.length ? `<div class="md-tags tags">${s.tags.map((x) => `<span class="tag">#${esc(x)}</span>`).join(" ")}</div>` : "")}
|
|
2632
2750
|
${i.found?.length ? `<div class="found"><span>${esc(t.foundIn)}</span>${i.found.map((c) => `<a href="#item-${c.id}" data-open="${c.id}">${esc(c.name)}</a>`).join("")}</div>` : ""}
|
|
2751
|
+
<div class="found" id="md-related" hidden></div>
|
|
2633
2752
|
${flagLines(i, t)}
|
|
2634
2753
|
<div class="md-fine">${i.shareCount ? `<span>${esc(t.shared(i.shareCount))}</span>` : ""}<span>${esc(i.createdAt.slice(0, 10))}</span>${i.enrichedBy ? `<span>${esc(t.enrichedBy(i.enrichedBy.replace(/^agent:/, "")))}</span>` : ""}</div>`;
|
|
2754
|
+
paintRelated(i.id);
|
|
2635
2755
|
const busy = refreshing.has(i.id);
|
|
2636
2756
|
const btn = (act, icon, label, extra = "") => `<button class="btn ${extra}" type="button" data-md="${act}">${ic(icon)} ${esc(label)}</button>`;
|
|
2637
2757
|
$("md-actions").innerHTML = `<a class="btn primary" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${ic("link")} ${esc(t.openLink)}</a>` +
|
|
@@ -2639,11 +2759,64 @@
|
|
|
2639
2759
|
: btn("favorite", "star", i.favorite ? t.unfavorite : t.favorite, i.favorite ? "on" : "") + btn("move", "move", t.moveTo) +
|
|
2640
2760
|
`<button class="btn ${busy ? "spin" : ""}" type="button" data-md="refresh" ${busy ? "disabled" : ""}>${ic("refresh")} ${esc(t.refresh)}</button>` +
|
|
2641
2761
|
btn("health", "refresh", t.checkLink) + btn("note", "note", i.note ? t.editNote : t.addNote) + `<span class="spacer"></span>` + btn("trash", "trash", t.remove, "danger")) : "") +
|
|
2762
|
+
btn("history", "undo", t.histBtn, histFor === i.id ? "on" : "") +
|
|
2642
2763
|
(modalFrom === "map" ? btn("list", "list", t.showInList) : "");
|
|
2764
|
+
if (histFor === i.id) paintHistory(i);
|
|
2765
|
+
}
|
|
2766
|
+
// ── Change history (read: anyone who can read the card; restore: admin) ──
|
|
2767
|
+
let histFor = null, histRows = null;
|
|
2768
|
+
function histPreview(row, f) {
|
|
2769
|
+
const t = T(), b = row.before, cut = (x) => { x = String(x ?? "").replace(/\s+/g, " ").trim(); return x ? (x.length > 80 ? x.slice(0, 80) + "…" : x) : t.histEmptyVal; };
|
|
2770
|
+
if (f === "note" || f === "title") return cut(b[f]);
|
|
2771
|
+
if (f === "summary") { try { const o = JSON.parse(b.summary); return cut(o.oneLiner || o.name); } catch { return t.histEmptyVal; } }
|
|
2772
|
+
if (f === "folder") return folderPath(b.category);
|
|
2773
|
+
if (f === "favorite") return b.favorite ? t.histStarOn : t.histStarOff;
|
|
2774
|
+
return b.trashed_at ? t.histInTrash : t.histOutTrash;
|
|
2775
|
+
}
|
|
2776
|
+
function paintHistory(i) {
|
|
2777
|
+
const t = T(), admin = role === "admin";
|
|
2778
|
+
let sec = document.getElementById("md-hist");
|
|
2779
|
+
if (!sec) { sec = document.createElement("section"); sec.id = "md-hist"; sec.className = "md-sec md-hist"; $("md-scroll").appendChild(sec); }
|
|
2780
|
+
const body = histRows == null ? "…" : !histRows.length ? `<p>${esc(t.histNone)}</p>` :
|
|
2781
|
+
`<ul>${histRows.map((r) => `<li><div>${r.fields.map((f) => `<span>${esc(t.histField[f] ?? f)}: ${esc(histPreview(r, f))}</span>`).join("<br>")}<small>${when(r.at)} · ${esc(t.histActor(r.actor))}</small></div>${
|
|
2782
|
+
admin ? `<button class="btn" type="button" data-md="hist-restore" data-v="${r.v}">${esc(t.histRestore)}</button>` : ""}</li>`).join("")}</ul>`;
|
|
2783
|
+
sec.innerHTML = `<h4>${esc(t.histTitle)}</h4>${body}${admin && histRows?.length ? `<button class="btn" type="button" data-md="hist-forget">${esc(t.histForget)}</button>` : ""}`;
|
|
2784
|
+
}
|
|
2785
|
+
const when = (iso) => { const d = new Date(iso); return esc(isNaN(d) ? iso : d.toLocaleString(locale, { dateStyle: "short", timeStyle: "short" })); };
|
|
2786
|
+
async function loadHistory(id) {
|
|
2787
|
+
try { const rows = await api(`/api/items/${id}/history`); if (histFor === id) histRows = rows; } catch { if (histFor === id) { histRows = []; toast(T().histErr); } }
|
|
2788
|
+
if (histFor === id && modalId === id && mdlDlg.open) paintModal();
|
|
2789
|
+
}
|
|
2790
|
+
async function restoreVersion(id, v) {
|
|
2791
|
+
const saved = await mapWrite(`/api/items/${id}/history/${v}/restore`, "POST");
|
|
2792
|
+
if (!saved) return;
|
|
2793
|
+
const item = find(id);
|
|
2794
|
+
if (item) {
|
|
2795
|
+
// The server omits empty optional fields (a cleared note): replace the card's data, keep what only the list adds.
|
|
2796
|
+
const extra = { found: item.found, said: item.said, suggestions: item.suggestions };
|
|
2797
|
+
for (const k of Object.keys(item)) delete item[k];
|
|
2798
|
+
Object.assign(item, saved, extra);
|
|
2799
|
+
const el = document.getElementById(`item-${id}`);
|
|
2800
|
+
if (el) { el.outerHTML = card(item); attachSwipe(document.getElementById(`item-${id}`)); }
|
|
2801
|
+
}
|
|
2802
|
+
if (mapShown()) drawMap();
|
|
2803
|
+
refreshCounts(); refreshFolders();
|
|
2804
|
+
const rows = await api(`/api/items/${id}/history`).catch(() => null);
|
|
2805
|
+
const undoV = rows?.[0]?.v; // the restore itself is the newest version: restoring it again undoes it
|
|
2806
|
+
histRows = rows ?? histRows;
|
|
2807
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
2808
|
+
toast(T().histRestored, undoV ? async () => { await restoreVersion(id, undoV); } : undefined);
|
|
2809
|
+
}
|
|
2810
|
+
async function forgetHistory(id) {
|
|
2811
|
+
if (!(await mapWrite(`/api/items/${id}/history`, "DELETE"))) return;
|
|
2812
|
+
histRows = [];
|
|
2813
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
2814
|
+
toast(T().histForgot);
|
|
2643
2815
|
}
|
|
2644
2816
|
function openModal(id, from = "list") {
|
|
2645
2817
|
if (!find(id)) return;
|
|
2646
2818
|
const wasOpen = mdlDlg.open;
|
|
2819
|
+
if (modalId !== id) { histFor = null; histRows = null; }
|
|
2647
2820
|
modalId = id; modalFrom = from;
|
|
2648
2821
|
paintModal();
|
|
2649
2822
|
if (!wasOpen) mdlDlg.showModal();
|
|
@@ -2694,6 +2867,13 @@
|
|
|
2694
2867
|
history.replaceState(null, "", `#item-${id}`);
|
|
2695
2868
|
return load();
|
|
2696
2869
|
}
|
|
2870
|
+
if (act1 === "history") {
|
|
2871
|
+
histFor = histFor === id ? null : id; histRows = null;
|
|
2872
|
+
if (histFor) loadHistory(id);
|
|
2873
|
+
return paintModal();
|
|
2874
|
+
}
|
|
2875
|
+
if (act1 === "hist-restore") return restoreVersion(id, Number(b.dataset.v));
|
|
2876
|
+
if (act1 === "hist-forget") return forgetHistory(id);
|
|
2697
2877
|
if (act1 === "move") { mdlDlg.close(); return openMovePicker(id); }
|
|
2698
2878
|
if (act1 === "refresh") return refreshItem(id);
|
|
2699
2879
|
if (act1 === "health") return checkLink(id);
|
|
@@ -3469,9 +3649,23 @@
|
|
|
3469
3649
|
}
|
|
3470
3650
|
}
|
|
3471
3651
|
|
|
3652
|
+
/** A newer release is out: a small header notice, dismissed per version (this browser only). */
|
|
3653
|
+
function showUpdate(u) {
|
|
3654
|
+
const el = $("update");
|
|
3655
|
+
const ok = u && /^\d{1,9}\.\d{1,9}\.\d{1,9}(-[0-9A-Za-z.-]{1,40})?$/.test(u.latest ?? "");
|
|
3656
|
+
if (!ok || store.get("driftnet-update-dismissed") === u.latest) { el.hidden = true; return; }
|
|
3657
|
+
const t = T().st;
|
|
3658
|
+
const a = $("update-link");
|
|
3659
|
+
a.href = `https://github.com/KevinChu1110/driftnet/releases/tag/v${u.latest}`;
|
|
3660
|
+
a.textContent = `${t.updOut(u.latest)} · ${t.updHow}`;
|
|
3661
|
+
$("update-x").setAttribute("aria-label", t.updDismiss);
|
|
3662
|
+
$("update-x").onclick = () => { store.set("driftnet-update-dismissed", u.latest); el.hidden = true; };
|
|
3663
|
+
el.hidden = false;
|
|
3664
|
+
}
|
|
3472
3665
|
async function refreshCounts() {
|
|
3473
3666
|
const stats = await api("/api/stats").catch(() => null);
|
|
3474
3667
|
if (!stats) return;
|
|
3668
|
+
showUpdate(stats.update);
|
|
3475
3669
|
$("stats").textContent = T().stats(stats.items, stats.shares);
|
|
3476
3670
|
const set = (v, n) => { const c = $("nav").querySelector(`[data-field="view"][data-value="${v}"] .count`); if (c) c.textContent = n || (v === "all" ? "0" : ""); };
|
|
3477
3671
|
set("all", stats.items); set("favorites", stats.favorites); set("trash", stats.trash); set("inbox", stats.inbox); set("review", stats.review);
|