driftnet 0.8.0 → 0.10.0
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 +224 -57
- package/README.zh-TW.md +209 -51
- package/dist/driftnet.mjs +4168 -434
- package/examples/plugins/rainbow-judge.mjs +25 -0
- package/package.json +2 -1
- package/public/index.html +359 -19
- package/skills/driftnet/SKILL.md +57 -0
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; }
|
|
@@ -413,6 +418,7 @@
|
|
|
413
418
|
.meta .tags { font-size: 12px; color: color-mix(in srgb, var(--muted) 80%, transparent); }
|
|
414
419
|
.meta { color: var(--muted); font-size: 13px; display: flex; gap: 4px 12px; flex-wrap: wrap; }
|
|
415
420
|
.flag { color: var(--warn); font-size: 13px; }
|
|
421
|
+
.vflag { color: var(--muted); font-size: 13px; }
|
|
416
422
|
.tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; }
|
|
417
423
|
/* Desktop: the tools appear on hover / focus; a starred card keeps its star. */
|
|
418
424
|
@media (hover: hover) and (pointer: fine) {
|
|
@@ -514,6 +520,10 @@
|
|
|
514
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; }
|
|
515
521
|
.md-try button { position: absolute; top: 6px; right: 6px; }
|
|
516
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); }
|
|
517
527
|
.md-fine { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; }
|
|
518
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; }
|
|
519
529
|
.md-actions .spacer { flex: 1; }
|
|
@@ -586,6 +596,7 @@
|
|
|
586
596
|
</button>
|
|
587
597
|
<h1 class="brand"><img src="/favicon.svg" alt="" width="26" height="26">driftnet</h1>
|
|
588
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>
|
|
589
600
|
<input id="q" class="search" type="search" enterkeyhint="search">
|
|
590
601
|
<button id="lock" class="lock" type="button" hidden></button>
|
|
591
602
|
<button id="palette-btn" class="lang" type="button" aria-haspopup="dialog"></button>
|
|
@@ -607,10 +618,29 @@
|
|
|
607
618
|
<div class="dlg-actions">
|
|
608
619
|
<button class="btn danger" id="fd-delete" type="button"></button><span class="spacer"></span>
|
|
609
620
|
<button class="btn" id="fd-focus" type="button" hidden></button>
|
|
621
|
+
<button class="btn" id="fd-pack" type="button" hidden></button>
|
|
610
622
|
<button class="btn" id="fd-cancel" type="button"></button><button class="btn primary" id="fd-save" type="submit"></button>
|
|
611
623
|
</div>
|
|
612
624
|
</form>
|
|
613
625
|
</dialog>
|
|
626
|
+
<dialog id="pack-dlg" aria-labelledby="pk-title">
|
|
627
|
+
<form id="pack-form" method="dialog">
|
|
628
|
+
<h3 id="pk-title"></h3>
|
|
629
|
+
<p id="pk-help" style="color:var(--muted);font-size:13px;margin:0 0 12px"></p>
|
|
630
|
+
<p class="dlg-error" id="pk-error"></p>
|
|
631
|
+
<label><span id="pk-name-l"></span><input id="pk-name" maxlength="60" autocomplete="off"></label>
|
|
632
|
+
<label><span id="pk-desc-l"></span><textarea id="pk-desc" rows="2" maxlength="300"></textarea></label>
|
|
633
|
+
<div id="pk-link-box" hidden>
|
|
634
|
+
<label><span id="pk-link-l"></span><input id="pk-link" readonly></label>
|
|
635
|
+
<p id="pk-link-note" style="color:var(--muted);font-size:13px;margin:0 0 12px"></p>
|
|
636
|
+
</div>
|
|
637
|
+
<p id="pk-nolink" style="color:var(--muted);font-size:13px;margin:0 0 12px" hidden></p>
|
|
638
|
+
<div class="dlg-actions">
|
|
639
|
+
<button class="btn" id="pk-copy" type="button" hidden></button><span class="spacer"></span>
|
|
640
|
+
<button class="btn" id="pk-close" type="button"></button><button class="btn primary" id="pk-download" type="button"></button>
|
|
641
|
+
</div>
|
|
642
|
+
</form>
|
|
643
|
+
</dialog>
|
|
614
644
|
<dialog id="move-dlg" aria-labelledby="mv-title">
|
|
615
645
|
<h3 id="mv-title"></h3>
|
|
616
646
|
<input id="mv-filter" class="search" style="max-width:none;width:100%;margin:0 0 8px" type="search" autocomplete="off">
|
|
@@ -699,7 +729,7 @@
|
|
|
699
729
|
kinds: { repo: "Repos", product: "Products", video: "Videos", article: "Articles", post: "Posts", other: "Other" },
|
|
700
730
|
kind1: { repo: "Repo", product: "Product", video: "Video", article: "Article", post: "Post", other: "Other" },
|
|
701
731
|
worth: { skip: "skip", low: "low", normal: "worth a look", "must-see": "must-see" },
|
|
702
|
-
flags: { injection: "prompt injection", "hidden-chars": "hidden characters", "low-reputation": "low-reputation source" },
|
|
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" },
|
|
703
733
|
pending: "waiting for a summary", noModel: "no summary — no model set up", enrichedBy: (a) => `summary by ${a}`,
|
|
704
734
|
favorite: "Add to favorites", unfavorite: "Remove from favorites", remove: "Move to trash", restore: "Restore",
|
|
705
735
|
swipeFav: "Favorite", swipeUnfav: "Unfavorite", swipeTrash: "Remove", swipeRestore: "Restore",
|
|
@@ -712,8 +742,9 @@
|
|
|
712
742
|
save: "Save", cancel: "Cancel", del: "Delete folder", delSure: "Delete? Links move up",
|
|
713
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}` : ""}`,
|
|
714
744
|
moveTo: "Move to…", moveTitle: (n) => `Move “${n}” to`, moved: (n, f) => `Moved “${n}” to ${f}`, expand: "Show sub-folders",
|
|
715
|
-
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}`,
|
|
716
746
|
topLevelShort: "the top level",
|
|
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.",
|
|
717
748
|
mapAll: "All", focusCrumb: "Mind map location", focusUp: "Up one level", focusFolder: "Focus on this folder", mapTree: "Mind map",
|
|
718
749
|
mapHintFocus: "Double-click a folder (or press z on it) to focus on it.",
|
|
719
750
|
kTreeNav: "Mind map: next / previous node", kTreeOpen: "Open a folder, or step into it", kTreeClose: "Close a folder, or step out to its parent", kTreeEnds: "First / last node", kTreeType: "Type a name", kTreeTypeText: "Jump to the node starting with it",
|
|
@@ -724,6 +755,9 @@
|
|
|
724
755
|
layoutBoth: "Both sides", layoutRight: "Right side", layoutHelp: "Switch between branches on both sides (XMind) and all to the right",
|
|
725
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",
|
|
726
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 "),
|
|
727
761
|
notes: "Notes", note: "Note", addNote: "Add a note", editNote: "Edit note", noteFor: (n) => `Note on “${n}”`,
|
|
728
762
|
noteHelp: "Only for you: what you thought, whether you tried it…", newNote: "New note", noteTitle: "Title",
|
|
729
763
|
noteBody: "Markdown. Write #12 to link card 12.", delNote: "Delete note", delNoteSure: "Really delete?", untitled: "Untitled",
|
|
@@ -766,6 +800,14 @@
|
|
|
766
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.",
|
|
767
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",
|
|
768
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",
|
|
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.`,
|
|
769
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.",
|
|
770
812
|
impFile: "Choose a file", impKeep: "Keep my bookmark folders (under Imported)", impReading: "Reading the file…",
|
|
771
813
|
impConfirm: (n, dup) => `Import ${n} links (${dup} already there)? With a model set up, each new link is one model call.`,
|
|
@@ -813,14 +855,31 @@
|
|
|
813
855
|
DRIFTNET_LLM_API_KEY: ["API key", ""],
|
|
814
856
|
DRIFTNET_LLM_EFFORT: ["Reasoning effort", ""],
|
|
815
857
|
TYPESAFE_API_KEY: ["Jev key", "Optional: a ~100 ms classifier that saves model calls (console.typesafe.ai)"],
|
|
816
|
-
DRIFTNET_JUDGE: ["
|
|
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."],
|
|
865
|
+
DRIFTNET_LLM_REGION: ["Region", "Bedrock: e.g. us-east-1. Vertex: e.g. us-central1 (default). Not used by other providers."],
|
|
866
|
+
AWS_ACCESS_KEY_ID: ["AWS access key ID", "Bedrock. Leave empty if you use a Bedrock API key."],
|
|
867
|
+
AWS_SECRET_ACCESS_KEY: ["AWS secret access key", "Bedrock."],
|
|
868
|
+
AWS_SESSION_TOKEN: ["AWS session token", "Bedrock, only for temporary credentials."],
|
|
869
|
+
AWS_BEARER_TOKEN_BEDROCK: ["Bedrock API key", "Bedrock: use this instead of the AWS keys above."],
|
|
870
|
+
GOOGLE_CLOUD_PROJECT: ["Google Cloud project", "Vertex. Optional when the credentials file names one."],
|
|
871
|
+
DRIFTNET_VERTEX_CREDENTIALS: ["Vertex credentials file", "Vertex: path to a service-account JSON file on this computer (or put an access token in API key)."],
|
|
872
|
+
DRIFTNET_JUDGE_RULES: ["Rules file", "For the Rules judge: a file path. One rule per line, e.g. github.com/* -> coding"],
|
|
817
873
|
GITHUB_TOKEN: ["GitHub token", "Optional: GitHub lookups go from 60 to 5000 an hour"],
|
|
818
874
|
DRIFTNET_LANGUAGE: ["Summary language", "English, Traditional Chinese (Taiwan), Japanese…"],
|
|
819
875
|
DRIFTNET_LOCALE: ["Bot language", ""],
|
|
820
876
|
DRIFTNET_REPLY: ["How the bot replies", ""],
|
|
877
|
+
DRIFTNET_REPLY_STYLE: ["Reply style", "Rich: embeds, blocks, cards and vote buttons where the platform has them. Text: plain messages."],
|
|
821
878
|
DRIFTNET_PUBLIC_URL: ["This page's public URL", "Replies link here, e.g. https://driftnet.example.com"],
|
|
822
879
|
DRIFTNET_SUMMARY_DEPTH: ["Summary detail", "How much each card says. Detailed costs more model tokens and reads twice as much of each page."],
|
|
823
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."],
|
|
824
883
|
DRIFTNET_BLOCK_DOMAINS: ["Never catalogue these domains", "Comma or space separated, e.g. example.com, spam.io"],
|
|
825
884
|
DRIFTNET_WEBHOOK_URL: ["Webhook URL", "driftnet POSTs each new or updated card here (n8n, Zapier, Slack workflows…). Treated as a secret."],
|
|
826
885
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook signing secret", "Optional. Adds X-Driftnet-Signature: sha256=<HMAC of the body>."],
|
|
@@ -829,19 +888,29 @@
|
|
|
829
888
|
DRIFTNET_DIGEST_DAY: ["Digest day (weekly)", ""],
|
|
830
889
|
DRIFTNET_DIGEST_TO: ["Digest targets", "Comma separated: telegram:<chat id>, discord:<channel id>, slack:<channel id>, line:<user, group or room id>. Uses the bot tokens already set."],
|
|
831
890
|
DRIFTNET_HEALTH: ["Link health check", "Weekly: a few cards at a time, driftnet checks that links still work and repos aren't archived. Marks dead, archived and stale cards."],
|
|
891
|
+
DRIFTNET_VIDEO: ["Read reels and shorts", "For Instagram, Facebook, Threads, TikTok, YouTube Shorts and X videos whose text says almost nothing, driftnet reads captions, on-screen text and speech with local tools (yt-dlp, ffmpeg, tesseract, whisper) if installed. One video at a time."],
|
|
892
|
+
DRIFTNET_YTDLP: ["yt-dlp path", "Only if yt-dlp is not on PATH."],
|
|
893
|
+
DRIFTNET_FFMPEG: ["ffmpeg path", "Only if ffmpeg is not on PATH."],
|
|
894
|
+
DRIFTNET_TESSERACT: ["tesseract path", "Only if tesseract (on-screen text) is not on PATH."],
|
|
895
|
+
DRIFTNET_WHISPER: ["whisper path", "Only if whisper or whisper-cli (speech) is not on PATH."],
|
|
832
896
|
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."],
|
|
833
897
|
},
|
|
834
898
|
choices: {
|
|
835
|
-
DRIFTNET_LLM_PROVIDER: { "": "None", anthropic: "Anthropic (API key)", openai: "OpenAI-compatible (OpenAI,
|
|
899
|
+
DRIFTNET_LLM_PROVIDER: { "": "None", anthropic: "Anthropic (API key)", openai: "OpenAI-compatible (OpenAI, Grok, Ollama…)", gemini: "Google Gemini (API key)", bedrock: "Amazon Bedrock", vertex: "Google Vertex AI", "claude-cli": "Claude subscription (Claude Code CLI)", "gemini-cli": "Google account (Gemini CLI)" },
|
|
836
900
|
DRIFTNET_LLM_EFFORT: { "": "Default", low: "Low", medium: "Medium", high: "High", xhigh: "Extra high" },
|
|
837
|
-
DRIFTNET_JUDGE: { "": "
|
|
901
|
+
DRIFTNET_JUDGE: { "": "Jev if a key is set", jev: "Jev", rules: "Rules (free, no model)", llm: "The model decides", heuristic: "The model decides", off: "No judge" },
|
|
838
902
|
DRIFTNET_SUMMARY_DEPTH: { "": "Standard (default)", brief: "Brief: one line, 2 highlights, what you see", standard: "Standard", detailed: "Detailed: more highlights, use cases, how to try it" },
|
|
839
903
|
DRIFTNET_LOCALE: { "": "Same as the summaries", en: "English", "zh-TW": "繁體中文" },
|
|
904
|
+
DRIFTNET_REPLY_STYLE: { "": "Rich (default)", rich: "Rich: cards and vote buttons", text: "Plain text" },
|
|
840
905
|
DRIFTNET_REPLY: { "": "One line + link (default)", link: "One line + link", full: "Full summary", off: "Don't reply" },
|
|
841
906
|
DRIFTNET_DIGEST: { "": "Off (default)", off: "Off", daily: "Every day", weekly: "Every week" },
|
|
842
907
|
DRIFTNET_DIGEST_DAY: { "": "Monday (default)", mon: "Monday", tue: "Tuesday", wed: "Wednesday", thu: "Thursday", fri: "Friday", sat: "Saturday", sun: "Sunday" },
|
|
843
908
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "No (public addresses only)", 1: "Yes" },
|
|
844
909
|
DRIFTNET_HEALTH: { "": "Off (default)", off: "Off", weekly: "Weekly (recommended)" },
|
|
910
|
+
DRIFTNET_EMBED: { "": "Automatic (default): on when a local model is found", auto: "Automatic: on when a local model is found", off: "Off" },
|
|
911
|
+
DRIFTNET_EMBED_PROVIDER: { "": "Automatic (local Ollama only)", ollama: "Ollama (on this computer)", openai: "OpenAI", gemini: "Gemini" },
|
|
912
|
+
DRIFTNET_UPDATE_CHECK: { "": "Off (default)", 1: "On", 0: "Off" },
|
|
913
|
+
DRIFTNET_VIDEO: { "": "Automatic (default)", auto: "Automatic: use the tools found", captions: "Captions only (light on battery: no download, OCR or speech)", off: "Off" },
|
|
845
914
|
},
|
|
846
915
|
},
|
|
847
916
|
},
|
|
@@ -853,7 +922,7 @@
|
|
|
853
922
|
pageMore: (n) => `再顯示 ${n} 張`, emptyTrash: "垃圾桶是空的。", hint: "往右滑加入最愛,往左滑移到垃圾桶。", hintTrash: "往右滑還原。",
|
|
854
923
|
kinds: { repo: "程式庫", product: "產品", video: "影片", article: "文章", post: "貼文", other: "其他" },
|
|
855
924
|
worth: { skip: "略過", low: "次要", normal: "值得看", "must-see": "必看" },
|
|
856
|
-
flags: { injection: "提示詞注入", "hidden-chars": "隱藏字元", "low-reputation": "低信譽來源" },
|
|
925
|
+
flags: { injection: "提示詞注入", "hidden-chars": "隱藏字元", "low-reputation": "低信譽來源", "video-read": "已從影片讀取", "video-captions": "影片字幕", "video-ocr": "影片畫面文字", "video-speech": "影片語音" },
|
|
857
926
|
pending: "等待摘要", noModel: "沒有摘要(未設定模型)", enrichedBy: (a) => `由 ${a} 整理`,
|
|
858
927
|
favorite: "加入最愛", unfavorite: "移出最愛", remove: "移到垃圾桶", restore: "還原",
|
|
859
928
|
swipeFav: "加入最愛", swipeUnfav: "移出最愛", swipeTrash: "移到垃圾桶", swipeRestore: "還原",
|
|
@@ -866,8 +935,9 @@
|
|
|
866
935
|
save: "儲存", cancel: "取消", del: "刪除資料夾", delSure: "確定刪除?內容移到上一層",
|
|
867
936
|
refresh: "重新整理(再抓一次並重新摘要)", refreshed: (n) => `已重新整理「${n}」`, refreshBusy: "這張卡片正在重新整理。", refreshWait: "剛剛才整理過,請一分鐘後再試。", refreshFailed: (why) => `重新整理失敗${why ? `:${why}` : ""}`,
|
|
868
937
|
moveTo: "移動到…", moveTitle: (n) => `把「${n}」移動到`, moved: (n, f) => `已將「${n}」移到 ${f}`, expand: "展開子資料夾",
|
|
869
|
-
dragHint: "拖到側邊欄的資料夾", foundIn: "從這篇找到:", folderMoved: (n, f) => `「${n}」已移到 ${f} 底下`,
|
|
938
|
+
dragHint: "拖到側邊欄的資料夾", foundIn: "從這篇找到:", related: "相關卡片:", folderMoved: (n, f) => `「${n}」已移到 ${f} 底下`,
|
|
870
939
|
topLevelShort: "最上層",
|
|
940
|
+
pkShare: "分享成資料夾包…", pkTitle: "分享成資料夾包", pkHelp: "資料夾包把這個資料夾、底下的子資料夾和裡面的卡片包成一個檔案,別人一鍵就能匯入。你的筆記、聊天內容和各種計數都不會放進去。", pkName: "資料夾包名稱", pkDesc: "說明", pkDownload: "下載資料夾包", pkLinkL: "分享連結", pkCopy: "複製連結", pkCopied: "已複製連結", pkSigned: "拿到這個連結的人只能下載這一個資料夾包,看不到你目錄裡的其他內容。", pkOpen: "任何連得到這個位址的人都能下載這個資料夾包。", pkNoLink: "還沒設定公開網址,所以暫時沒有可分享的連結。請到「設定 → 存取」設定,或啟動通道。現在仍可以下載檔案。", pkClose: "關閉", pkTooBig: "這個資料夾太大,無法分享成資料夾包。",
|
|
871
941
|
mapAll: "全部", focusCrumb: "樹狀圖位置", focusUp: "回上一層", focusFolder: "聚焦這個資料夾", mapTree: "樹狀圖",
|
|
872
942
|
mapHintFocus: "連點兩下資料夾(或在資料夾上按 z)可以只看這個資料夾。",
|
|
873
943
|
kTreeNav: "樹狀圖:下一個/上一個節點", kTreeOpen: "展開資料夾,或進入第一個子項", kTreeClose: "收合資料夾,或回到上一層", kTreeEnds: "第一個/最後一個節點", kTreeType: "直接輸入名稱", kTreeTypeText: "跳到名稱開頭相符的節點",
|
|
@@ -878,6 +948,9 @@
|
|
|
878
948
|
layoutBoth: "兩側展開", layoutRight: "往右展開", layoutHelp: "切換:分支分佈在兩側(XMind 預設)或全部往右",
|
|
879
949
|
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: "關閉",
|
|
880
950
|
needPassword: "要修改需要管理密碼。",
|
|
951
|
+
histBtn: "修改紀錄", histTitle: "修改紀錄", histNone: "還沒有修改紀錄。", histRestore: "還原", histRestored: "已還原成先前的版本。", histErr: "無法載入修改紀錄。", histForget: "清除紀錄", histForgot: "這張卡片的修改紀錄已清除。",
|
|
952
|
+
histField: { note: "筆記", summary: "摘要", title: "標題", folder: "資料夾", favorite: "星號", trashed: "垃圾桶" }, histEmptyVal: "(空白)", histStarOn: "已加星", histStarOff: "未加星", histInTrash: "在垃圾桶", histOutTrash: "不在垃圾桶",
|
|
953
|
+
histActor: (a) => a === "admin" ? "你" : a === "system:refresh" ? "重新整理" : a === "system" ? "系統" : a.replace(/^agent:/, "agent "),
|
|
881
954
|
notes: "筆記", note: "筆記", addNote: "加筆記", editNote: "改筆記", noteFor: (n) => `「${n}」的筆記`,
|
|
882
955
|
noteHelp: "只有你看得到:心得、試用結果、要注意的地方…", newNote: "新筆記", noteTitle: "標題",
|
|
883
956
|
noteBody: "支援 Markdown。寫 #12 就會連到第 12 張卡片。", delNote: "刪除筆記", delNoteSure: "確定刪除?", untitled: "未命名",
|
|
@@ -920,6 +993,14 @@
|
|
|
920
993
|
locked: "由執行環境設定", forbidden: "伺服器設定只能在執行 driftnet 的那台電腦上改(或設定 DRIFTNET_TOKEN)。顯示設定照常可用。",
|
|
921
994
|
savedServer: "已儲存,馬上生效", chat: "聊天室回覆", webhook: "對外 Webhook", digest: "定時摘要", feed: "訂閱源(RSS)", genCopied: "已產生新密碼並複製,按「儲存」才會生效",
|
|
922
995
|
tabGeneral: "一般", tabAccess: "存取", tabAi: "AI",
|
|
996
|
+
updates: "更新", bkTitle: "備份", bkHelp: "一個 zip 檔,包含整個收藏(卡片、資料夾、筆記、權杖)和設定。除非勾選,否則不會包含密碼和金鑰。",
|
|
997
|
+
bkDownload: "下載備份", bkSecrets: "包含密碼和金鑰(需要再輸入一次管理員密碼)", bkPassword: "管理員密碼",
|
|
998
|
+
bkRestoreFile: "從備份檔還原", bkRestoreHelp: "會先檢查備份檔。重新啟動 driftnet 之前不會有任何改變;目前的資料會留在旁邊,檔名帶有 before-restore。",
|
|
999
|
+
bkChecking: "正在檢查備份檔…", bkNeedPassword: "要包含密碼和金鑰,請輸入管理員密碼。", bkMade: "備份已下載。",
|
|
1000
|
+
bkRestartTitle: "請重新啟動 driftnet 以完成還原", bkRestartBody: (n) => `備份檔(${n} 張卡片)已檢查完畢並等待中,下次 driftnet 啟動時會取代目前的資料。`,
|
|
1001
|
+
bkSettingsTitle: "備份裡的設定(不會自動套用)。需要的話請自行複製到「設定」:", bkPending: "有一份還原正在等待:請重新啟動 driftnet 以完成還原。",
|
|
1002
|
+
updOut: (v) => `driftnet ${v} 已發布`, updHow: "如何更新", updDismiss: "關閉",
|
|
1003
|
+
impPackTitle: "從資料夾包連結匯入", impPackHelp: "貼上別人傳給你的資料夾包連結。卡片已經整理好(不會呼叫模型),會放進它自己的資料夾。", impPackGo: "檢查連結", impPackConfirm: (name, n, dup) => `資料夾包「${name}」:${n} 張新卡片(${dup} 張已經有了)。要匯入嗎?`, impPackNone: (name, dup) => `資料夾包「${name}」沒有新的卡片(${dup} 張已經有了)。仍要匯入把它們歸檔嗎?`, impPackDone: (name, added, already) => `已匯入「${name}」:新增 ${added}、原本就有 ${already}。`,
|
|
923
1004
|
impTitle: "匯入書籤", impHelp: "匯入瀏覽器的書籤檔(HTML)、Pocket、Raindrop(CSV)、driftnet 的 JSON 清單,或任何含有連結的文字檔。",
|
|
924
1005
|
impFile: "選擇檔案", impKeep: "保留我的書籤資料夾(放在「Imported」底下)", impReading: "讀取檔案中…",
|
|
925
1006
|
impConfirm: (n, dup) => `匯入 ${n} 個連結(${dup} 個已經有了)?若已設定模型,每個新連結都會呼叫一次模型。`,
|
|
@@ -967,14 +1048,31 @@
|
|
|
967
1048
|
DRIFTNET_LLM_API_KEY: ["API 金鑰", ""],
|
|
968
1049
|
DRIFTNET_LLM_EFFORT: ["推理強度", ""],
|
|
969
1050
|
TYPESAFE_API_KEY: ["Jev 金鑰", "選填:約 100ms 的分類器,可以省下模型呼叫(console.typesafe.ai)"],
|
|
970
|
-
DRIFTNET_JUDGE: ["
|
|
1051
|
+
DRIFTNET_JUDGE: ["判斷器", "在模型之前先決定每個連結放哪。「規則」免費,不需要模型。"],
|
|
1052
|
+
DRIFTNET_EMBED: ["以語意搜尋", "依內容意思找卡片,不只比對字(搜「登入」能找到 OAuth)。需要嵌入模型:本機 Ollama 的 nomic-embed-text,或下面的服務。不花摘要的 token。"],
|
|
1053
|
+
DRIFTNET_EMBED_PROVIDER: ["嵌入服務", "指定一個就會開啟語意搜尋。Ollama 全程在你的電腦上;OpenAI、Gemini 會收到每張卡片的摘要(不會有你的筆記或聊天內容)。"],
|
|
1054
|
+
DRIFTNET_EMBED_MODEL: ["嵌入模型", "預設:nomic-embed-text(Ollama)、text-embedding-3-small(OpenAI)、gemini-embedding-001(Gemini)。更換後會在背景重新計算全部卡片。"],
|
|
1055
|
+
DRIFTNET_EMBED_BASE_URL: ["嵌入 API 網址", "Ollama 或相容 OpenAI 的伺服器,例如 http://127.0.0.1:11434。留空:用該服務的預設位址。"],
|
|
1056
|
+
DRIFTNET_EMBED_API_KEY: ["嵌入 API 金鑰", "OpenAI 或 Gemini 用。只有摘要模型是同一家時才會沿用它的金鑰。"],
|
|
1057
|
+
DRIFTNET_EMBED_FLOOR: ["語意相符門檻", "0–1。沒有字面相符時,意思要多接近才會出現。nomic-embed-text 預設 0.55;調高結果會變少。"],
|
|
1058
|
+
DRIFTNET_LLM_REGION: ["區域", "Bedrock:例如 us-east-1。Vertex:例如 us-central1(預設)。其他供應商用不到。"],
|
|
1059
|
+
AWS_ACCESS_KEY_ID: ["AWS 存取金鑰 ID", "Bedrock 用。有 Bedrock API 金鑰就留空。"],
|
|
1060
|
+
AWS_SECRET_ACCESS_KEY: ["AWS 秘密存取金鑰", "Bedrock 用。"],
|
|
1061
|
+
AWS_SESSION_TOKEN: ["AWS 工作階段權杖", "Bedrock 用,只有臨時憑證才需要。"],
|
|
1062
|
+
AWS_BEARER_TOKEN_BEDROCK: ["Bedrock API 金鑰", "Bedrock 用:填這個就不用上面的 AWS 金鑰。"],
|
|
1063
|
+
GOOGLE_CLOUD_PROJECT: ["Google Cloud 專案", "Vertex 用。憑證檔裡有寫專案就可以不填。"],
|
|
1064
|
+
DRIFTNET_VERTEX_CREDENTIALS: ["Vertex 憑證檔", "Vertex 用:這台電腦上服務帳戶 JSON 檔的路徑(或在「API 金鑰」填存取權杖)。"],
|
|
1065
|
+
DRIFTNET_JUDGE_RULES: ["規則檔", "給「規則」判斷器:檔案路徑。一行一條,例如 github.com/* -> coding"],
|
|
971
1066
|
GITHUB_TOKEN: ["GitHub token", "選填:GitHub 查詢上限從每小時 60 次變 5000 次"],
|
|
972
1067
|
DRIFTNET_LANGUAGE: ["摘要語言", "English、Traditional Chinese (Taiwan)、Japanese…"],
|
|
973
1068
|
DRIFTNET_LOCALE: ["機器人語言", ""],
|
|
974
1069
|
DRIFTNET_REPLY: ["機器人怎麼回覆", ""],
|
|
1070
|
+
DRIFTNET_REPLY_STYLE: ["回覆樣式", "豐富:各平台的 embed、區塊、卡片與投票按鈕;純文字:一般訊息。"],
|
|
975
1071
|
DRIFTNET_PUBLIC_URL: ["這個網頁的公開網址", "回覆裡的連結會指到這裡,例如 https://driftnet.example.com"],
|
|
976
1072
|
DRIFTNET_SUMMARY_DEPTH: ["摘要詳細程度", "每張卡片寫多少。詳細會用較多模型 token,且每個頁面讀兩倍的內容。"],
|
|
977
1073
|
DRIFTNET_SUMMARY_RULES: ["摘要的額外規則", "例如:說明是否免費。需要 GPU 的話要提到。"],
|
|
1074
|
+
DRIFTNET_PROFILE: ["關於你", "你是誰、關心什麼(最多 600 字)。模型會用它判斷什麼值得你花時間,並寫「為什麼值得看」那一句。例如:後端工程師,做 Odoo 和 TypeScript;蒐集 AI 寫程式工具和 MCP 伺服器;對加密貨幣沒興趣。"],
|
|
1075
|
+
DRIFTNET_UPDATE_CHECK: ["檢查新版本", "每天向 npm 查一次最新版本號(不會傳送任何與你有關的資料),有新版就顯示小提示。關閉(預設)=完全不查。"],
|
|
978
1076
|
DRIFTNET_BLOCK_DOMAINS: ["不要收錄的網域", "用逗號或空白分隔,例如 example.com, spam.io"],
|
|
979
1077
|
DRIFTNET_WEBHOOK_URL: ["Webhook 網址", "每張新增或更新的卡片都會 POST 到這裡(n8n、Zapier、Slack 工作流程…)。視為機密。"],
|
|
980
1078
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook 簽章密鑰", "選填。會加上 X-Driftnet-Signature: sha256=<內容的 HMAC>。"],
|
|
@@ -983,19 +1081,29 @@
|
|
|
983
1081
|
DRIFTNET_DIGEST_DAY: ["摘要星期(每週)", ""],
|
|
984
1082
|
DRIFTNET_DIGEST_TO: ["摘要送到哪裡", "以逗號分隔:telegram:<聊天室 id>、discord:<頻道 id>、slack:<頻道 id>、line:<使用者、群組或聊天室 id>。使用已設定的機器人金鑰。"],
|
|
985
1083
|
DRIFTNET_HEALTH: ["連結健康檢查", "每週:每次幾張,檢查連結是否還能開、儲存庫是否已封存,並標記失效、封存、久未更新的卡片。"],
|
|
1084
|
+
DRIFTNET_VIDEO: ["讀影片(reels、shorts)", "Instagram、Facebook、Threads、TikTok、YouTube Shorts、X 的影片,若頁面文字幾乎沒內容,就用本機工具(yt-dlp、ffmpeg、tesseract、whisper,有裝才用)讀字幕、畫面文字和語音。一次只處理一支影片。"],
|
|
1085
|
+
DRIFTNET_YTDLP: ["yt-dlp 路徑", "只有 yt-dlp 不在 PATH 時才需要。"],
|
|
1086
|
+
DRIFTNET_FFMPEG: ["ffmpeg 路徑", "只有 ffmpeg 不在 PATH 時才需要。"],
|
|
1087
|
+
DRIFTNET_TESSERACT: ["tesseract 路徑", "只有 tesseract(讀畫面文字)不在 PATH 時才需要。"],
|
|
1088
|
+
DRIFTNET_WHISPER: ["whisper 路徑", "只有 whisper 或 whisper-cli(語音轉文字)不在 PATH 時才需要。"],
|
|
986
1089
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["允許本機 Webhook", "接收端在你自己的區域網路時需要(例如內網的 n8n)。只放行你填的那個位址。"],
|
|
987
1090
|
},
|
|
988
1091
|
choices: {
|
|
989
|
-
DRIFTNET_LLM_PROVIDER: { "": "不使用", anthropic: "Anthropic(API 金鑰)", openai: "OpenAI 相容(OpenAI、
|
|
1092
|
+
DRIFTNET_LLM_PROVIDER: { "": "不使用", anthropic: "Anthropic(API 金鑰)", openai: "OpenAI 相容(OpenAI、Grok、Ollama…)", gemini: "Google Gemini(API 金鑰)", bedrock: "Amazon Bedrock", vertex: "Google Vertex AI", "claude-cli": "Claude 訂閱(Claude Code CLI)", "gemini-cli": "Google 帳號(Gemini CLI)" },
|
|
990
1093
|
DRIFTNET_LLM_EFFORT: { "": "預設", low: "低", medium: "中", high: "高", xhigh: "極高" },
|
|
991
|
-
DRIFTNET_JUDGE: { "": "
|
|
1094
|
+
DRIFTNET_JUDGE: { "": "有 Jev 金鑰就用 Jev", jev: "Jev", rules: "規則(免費,不用模型)", llm: "交給模型", heuristic: "交給模型", off: "不用判斷器" },
|
|
992
1095
|
DRIFTNET_SUMMARY_DEPTH: { "": "標準(預設)", brief: "簡短:一句話、2 個重點、看得到什麼", standard: "標準", detailed: "詳細:更多重點、使用情境、怎麼試用" },
|
|
993
1096
|
DRIFTNET_LOCALE: { "": "跟摘要一樣", en: "English", "zh-TW": "繁體中文" },
|
|
1097
|
+
DRIFTNET_REPLY_STYLE: { "": "豐富(預設)", rich: "豐富:卡片與投票按鈕", text: "純文字" },
|
|
994
1098
|
DRIFTNET_REPLY: { "": "一行+連結(預設)", link: "一行+連結", full: "完整摘要", off: "不回覆" },
|
|
995
1099
|
DRIFTNET_DIGEST: { "": "關閉(預設)", off: "關閉", daily: "每天", weekly: "每週" },
|
|
996
1100
|
DRIFTNET_DIGEST_DAY: { "": "週一(預設)", mon: "週一", tue: "週二", wed: "週三", thu: "週四", fri: "週五", sat: "週六", sun: "週日" },
|
|
997
1101
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "否(只允許公開位址)", 1: "是" },
|
|
998
1102
|
DRIFTNET_HEALTH: { "": "關閉(預設)", off: "關閉", weekly: "每週(建議)" },
|
|
1103
|
+
DRIFTNET_EMBED: { "": "自動(預設):找到本機模型就開", auto: "自動:找到本機模型就開", off: "關閉" },
|
|
1104
|
+
DRIFTNET_EMBED_PROVIDER: { "": "自動(只找本機 Ollama)", ollama: "Ollama(在這台電腦上)", openai: "OpenAI", gemini: "Gemini" },
|
|
1105
|
+
DRIFTNET_UPDATE_CHECK: { "": "關閉(預設)", 1: "開啟", 0: "關閉" },
|
|
1106
|
+
DRIFTNET_VIDEO: { "": "自動(預設)", auto: "自動:有找到工具就用", captions: "只抓字幕(省電:不下載影片、不跑文字辨識和語音模型)", off: "關閉" },
|
|
999
1107
|
},
|
|
1000
1108
|
},
|
|
1001
1109
|
},
|
|
@@ -1009,6 +1117,14 @@
|
|
|
1009
1117
|
return (paneLock = paneLock.catch(() => {}).then(go));
|
|
1010
1118
|
}
|
|
1011
1119
|
const esc = (s) => String(s ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
1120
|
+
// Warnings (injection, hidden characters, low reputation) keep ⚠; "read from video" is good news, not a warning.
|
|
1121
|
+
function flagLines(i, t) {
|
|
1122
|
+
const flags = i.flags ?? [];
|
|
1123
|
+
const warn = flags.filter((f) => !f.startsWith("video-"));
|
|
1124
|
+
const steps = flags.filter((f) => f.startsWith("video-") && f !== "video-read");
|
|
1125
|
+
return (warn.length ? `<div class="flag">⚠ ${esc(warn.map((f) => t.flags[f] ?? f).join(", "))}</div>` : "")
|
|
1126
|
+
+ (flags.includes("video-read") ? `<div class="vflag">🎬 ${esc(t.flags["video-read"])}${steps.length ? ` · ${esc(steps.map((f) => t.flags[f] ?? f).join(", "))}` : ""}</div>` : "");
|
|
1127
|
+
}
|
|
1012
1128
|
const safeUrl = (u) => (/^https?:\/\//.test(u) ? u : "#");
|
|
1013
1129
|
const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } },
|
|
1014
1130
|
set: (k, v) => { try { localStorage.setItem(k, v); } catch {} } };
|
|
@@ -1166,6 +1282,7 @@
|
|
|
1166
1282
|
if (!STRINGS[saved] && STRINGS[ui.locale]) locale = ui.locale;
|
|
1167
1283
|
applyLocale();
|
|
1168
1284
|
$("stats").textContent = T().stats(stats.items, stats.shares);
|
|
1285
|
+
showUpdate(stats.update);
|
|
1169
1286
|
$("lock").innerHTML = `${ic("lock")}<span class="long">${esc(T().st.viewOnly)}</span><span class="short">${esc(T().st.unlockShort)}</span>`;
|
|
1170
1287
|
const btn = (field, key, label, n, icon) =>
|
|
1171
1288
|
`<button type="button" data-field="${field}" data-value="${esc(key)}" aria-pressed="${state[field] === key}">
|
|
@@ -1278,6 +1395,9 @@
|
|
|
1278
1395
|
const fb = $("fd-focus");
|
|
1279
1396
|
fb.hidden = !id || state.view !== "map" || id === mapFocus;
|
|
1280
1397
|
fb.textContent = t.focusFolder;
|
|
1398
|
+
const pb = $("fd-pack");
|
|
1399
|
+
pb.hidden = !id;
|
|
1400
|
+
pb.textContent = t.pkShare;
|
|
1281
1401
|
$("fd-cancel").textContent = t.cancel;
|
|
1282
1402
|
$("fd-save").textContent = t.save;
|
|
1283
1403
|
$("fd-error").textContent = "";
|
|
@@ -1324,6 +1444,67 @@
|
|
|
1324
1444
|
}
|
|
1325
1445
|
}
|
|
1326
1446
|
|
|
1447
|
+
// ── Share a folder as a pack: name it, download it, or copy a link ─────────
|
|
1448
|
+
let packFolder = null, packLink = null;
|
|
1449
|
+
/** The link with the name and description the reader typed (the signature covers only the folder). */
|
|
1450
|
+
function packUrl() {
|
|
1451
|
+
if (!packLink?.url) return "";
|
|
1452
|
+
const u = new URL(packLink.url);
|
|
1453
|
+
if ($("pk-name").value.trim()) u.searchParams.set("name", $("pk-name").value.trim());
|
|
1454
|
+
if ($("pk-desc").value.trim()) u.searchParams.set("description", $("pk-desc").value.trim());
|
|
1455
|
+
return u.href;
|
|
1456
|
+
}
|
|
1457
|
+
$("fd-pack").onclick = async () => {
|
|
1458
|
+
const t = T(), id = editing, f = id ? folderById(id) : null;
|
|
1459
|
+
if (!f) return;
|
|
1460
|
+
$("folder-dlg").close();
|
|
1461
|
+
packFolder = id; packLink = null;
|
|
1462
|
+
$("pk-title").textContent = `${t.pkTitle}: ${catLabel(id)}`;
|
|
1463
|
+
$("pk-help").textContent = t.pkHelp;
|
|
1464
|
+
$("pk-name-l").textContent = t.pkName; $("pk-desc-l").textContent = t.pkDesc; $("pk-link-l").textContent = t.pkLinkL;
|
|
1465
|
+
$("pk-name").value = catLabel(id); $("pk-desc").value = f.description ?? "";
|
|
1466
|
+
$("pk-download").textContent = t.pkDownload; $("pk-close").textContent = t.pkClose; $("pk-copy").textContent = t.pkCopy;
|
|
1467
|
+
$("pk-error").textContent = "";
|
|
1468
|
+
$("pk-link-box").hidden = true; $("pk-copy").hidden = true; $("pk-nolink").hidden = true;
|
|
1469
|
+
$("pack-dlg").showModal();
|
|
1470
|
+
try {
|
|
1471
|
+
packLink = await api(`/api/folders/${encodeURIComponent(id)}/pack-link`);
|
|
1472
|
+
} catch { packLink = null; }
|
|
1473
|
+
if (packFolder !== id || !$("pack-dlg").open) return;
|
|
1474
|
+
if (packLink?.url) {
|
|
1475
|
+
$("pk-link-box").hidden = false; $("pk-copy").hidden = false;
|
|
1476
|
+
$("pk-link-note").textContent = packLink.signed ? t.pkSigned : t.pkOpen;
|
|
1477
|
+
$("pk-link").value = packUrl();
|
|
1478
|
+
} else {
|
|
1479
|
+
$("pk-nolink").hidden = false; $("pk-nolink").textContent = t.pkNoLink;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
for (const id of ["pk-name", "pk-desc"]) $(id).addEventListener("input", () => { if (packLink?.url) $("pk-link").value = packUrl(); });
|
|
1483
|
+
$("pk-link").onfocus = () => $("pk-link").select();
|
|
1484
|
+
$("pk-copy").onclick = async () => {
|
|
1485
|
+
await navigator.clipboard?.writeText($("pk-link").value).catch(() => {});
|
|
1486
|
+
toast(T().pkCopied);
|
|
1487
|
+
};
|
|
1488
|
+
$("pk-close").onclick = () => $("pack-dlg").close();
|
|
1489
|
+
$("pk-download").onclick = async () => {
|
|
1490
|
+
const q = new URLSearchParams();
|
|
1491
|
+
if ($("pk-name").value.trim()) q.set("name", $("pk-name").value.trim());
|
|
1492
|
+
if ($("pk-desc").value.trim()) q.set("description", $("pk-desc").value.trim());
|
|
1493
|
+
const token = store.get("driftnet-token") || store.get("driftnet-key");
|
|
1494
|
+
try {
|
|
1495
|
+
const res = await fetch(`/api/folders/${encodeURIComponent(packFolder)}/pack?${q}`, { headers: token ? { authorization: `Bearer ${token}` } : {} });
|
|
1496
|
+
if (res.status === 401) { $("pk-error").textContent = T().needPassword; return; }
|
|
1497
|
+
if (!res.ok) { $("pk-error").textContent = res.status === 413 ? T().pkTooBig : T().failed; return; }
|
|
1498
|
+
const blob = await res.blob();
|
|
1499
|
+
const m = /filename="([^"]+)"/.exec(res.headers.get("content-disposition") ?? "");
|
|
1500
|
+
const a = document.createElement("a");
|
|
1501
|
+
a.href = URL.createObjectURL(blob);
|
|
1502
|
+
a.download = m?.[1] ?? "folder.driftnet-pack.json";
|
|
1503
|
+
document.body.append(a); a.click(); a.remove();
|
|
1504
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 5000);
|
|
1505
|
+
} catch { $("pk-error").textContent = T().failed; }
|
|
1506
|
+
};
|
|
1507
|
+
|
|
1327
1508
|
// ── Move a card: picker (phones) or drag onto the sidebar (desktop) ───────
|
|
1328
1509
|
let moving = null, movingMany = null;
|
|
1329
1510
|
/** The nine folders cards were filed into most often (the server counts moves and undoes), in tree order on a tie: keys 1–9 file a card there. */
|
|
@@ -1565,7 +1746,7 @@
|
|
|
1565
1746
|
const yes = (b) => (b ? "✓" : "—");
|
|
1566
1747
|
const accessStatus = `<p class="set-status">${esc(st.accessStatus(yes(a.passwordSet), yes(a.readKey), a.tunnel.running ? a.tunnel.url : "—"))}</p>`;
|
|
1567
1748
|
server = {
|
|
1568
|
-
general: group("language") + group("chat") + group("digest") + group("webhook") + importPanel(),
|
|
1749
|
+
general: group("language") + group("chat") + group("digest") + group("webhook") + group("updates") + importPanel() + backupPanel(serverSettings),
|
|
1569
1750
|
access: accessStatus + accessPanel(serverSettings, field) + (agentTokens ? tokensPanel(serverSettings.access, agentTokens, minted) + pairPanel(serverSettings.access) : ""),
|
|
1570
1751
|
ai: `<p class="set-status" id="st-status">${esc(st.status(serverSettings.engines))}</p>` + group("model") + group("rules") +
|
|
1571
1752
|
`<fieldset class="set-group"><legend>${esc(st.plugins)}</legend><div class="set-row">${plugins}</div></fieldset>`,
|
|
@@ -1589,15 +1770,65 @@
|
|
|
1589
1770
|
$("settings-dlg").showModal();
|
|
1590
1771
|
$("st-body").querySelector('[data-tab-btn][aria-selected="true"]')?.focus();
|
|
1591
1772
|
}
|
|
1773
|
+
/** Settings › Backup: download a zip (secrets only with the password typed again) or restore one (applied at the next start). */
|
|
1774
|
+
function backupPanel(sv) {
|
|
1775
|
+
const st = T().st;
|
|
1776
|
+
return `<fieldset class="set-group" id="backup-panel"><legend>${esc(st.bkTitle)}</legend>
|
|
1777
|
+
<small>${esc(st.bkHelp)}</small>
|
|
1778
|
+
<label class="set-row check"><input type="checkbox" id="bk-secrets"><span>${esc(st.bkSecrets)}</span></label>
|
|
1779
|
+
<label class="set-row" id="bk-pw-row" hidden><span>${esc(st.bkPassword)}</span><input type="password" id="bk-pw" autocomplete="off"></label>
|
|
1780
|
+
<div><button class="btn" type="button" id="bk-download">${esc(st.bkDownload)}</button></div>
|
|
1781
|
+
<small>${esc(st.bkRestoreHelp)}</small>
|
|
1782
|
+
<label class="set-row"><span>${esc(st.bkRestoreFile)}</span><input type="file" id="bk-file" accept=".zip,application/zip"></label>
|
|
1783
|
+
<p class="set-status" id="bk-status" role="status" aria-live="polite">${sv.restorePending ? esc(st.bkPending) : ""}</p>
|
|
1784
|
+
<pre id="bk-settings" hidden style="white-space:pre-wrap;user-select:all;font-size:12px"></pre></fieldset>`;
|
|
1785
|
+
}
|
|
1786
|
+
$("st-body").addEventListener("change", (e) => {
|
|
1787
|
+
if (e.target.id === "bk-secrets") $("bk-pw-row").hidden = !e.target.checked;
|
|
1788
|
+
});
|
|
1789
|
+
$("st-body").addEventListener("click", async (e) => {
|
|
1790
|
+
if (e.target.id !== "bk-download") return;
|
|
1791
|
+
const st = T().st, out = $("bk-status"), token = store.get("driftnet-token");
|
|
1792
|
+
const secrets = $("bk-secrets").checked, pw = $("bk-pw").value;
|
|
1793
|
+
if (secrets && !pw) { out.textContent = st.bkNeedPassword; return; }
|
|
1794
|
+
const res = await fetch(`/api/backup${secrets ? "?secrets=1" : ""}`, { headers: { ...(token ? { authorization: `Bearer ${token}` } : {}), ...(secrets ? { "x-driftnet-confirm": pw } : {}) } }).catch(() => null);
|
|
1795
|
+
$("bk-pw").value = "";
|
|
1796
|
+
if (res?.status === 401) { askToken(); return; }
|
|
1797
|
+
if (!res?.ok) { out.textContent = (await res?.json().catch(() => null))?.error ?? T().failed; return; }
|
|
1798
|
+
const name = /filename="([^"]+)"/.exec(res.headers.get("content-disposition") ?? "")?.[1] ?? "driftnet-backup.zip";
|
|
1799
|
+
const a = Object.assign(document.createElement("a"), { href: URL.createObjectURL(await res.blob()), download: name });
|
|
1800
|
+
document.body.append(a); a.click(); a.remove();
|
|
1801
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
|
1802
|
+
out.textContent = st.bkMade;
|
|
1803
|
+
});
|
|
1804
|
+
$("st-body").addEventListener("change", async (e) => {
|
|
1805
|
+
if (e.target.id !== "bk-file") return;
|
|
1806
|
+
const st = T().st, out = $("bk-status"), pre = $("bk-settings"), token = store.get("driftnet-token");
|
|
1807
|
+
const file = e.target.files?.[0];
|
|
1808
|
+
pre.hidden = true;
|
|
1809
|
+
if (!file) { out.textContent = ""; return; }
|
|
1810
|
+
out.textContent = st.bkChecking;
|
|
1811
|
+
const res = await fetch("/api/backup/restore", { method: "POST", body: file, headers: { "content-type": "application/zip", ...(token ? { authorization: `Bearer ${token}` } : {}) } }).catch(() => null);
|
|
1812
|
+
e.target.value = "";
|
|
1813
|
+
if (res?.status === 401 || res?.status === 403) { askToken(); return; }
|
|
1814
|
+
const body = res ? await res.json().catch(() => ({})) : {};
|
|
1815
|
+
if (!res?.ok) { out.textContent = body.error ?? T().failed; return; }
|
|
1816
|
+
out.textContent = `${st.bkRestartTitle}. ${st.bkRestartBody(body.items)}`;
|
|
1817
|
+
out.style.fontWeight = "600";
|
|
1818
|
+
if (body.settings) { pre.textContent = `${st.bkSettingsTitle}\n\n${body.settings}`; pre.hidden = false; }
|
|
1819
|
+
});
|
|
1592
1820
|
/** Settings › Import bookmarks: pick a file, preview the counts (dry run), confirm, then watch the job. */
|
|
1593
|
-
let importContent = "", importTimer = null;
|
|
1821
|
+
let importContent = "", importUrl = "", importPack = null, importTimer = null;
|
|
1594
1822
|
function importPanel() {
|
|
1595
1823
|
const st = T().st;
|
|
1596
|
-
importContent = ""; clearInterval(importTimer);
|
|
1824
|
+
importContent = ""; importUrl = ""; importPack = null; clearInterval(importTimer);
|
|
1597
1825
|
return `<fieldset class="set-group" id="import-panel"><legend>${esc(st.impTitle)}</legend>
|
|
1598
1826
|
<small>${esc(st.impHelp)}</small>
|
|
1599
1827
|
<label class="set-row"><span>${esc(st.impFile)}</span><input type="file" id="im-file" accept=".html,.htm,.csv,.json,.txt,.md"></label>
|
|
1600
1828
|
<label class="set-row check"><input type="checkbox" id="im-keep"><span>${esc(st.impKeep)}</span></label>
|
|
1829
|
+
<small>${esc(st.impPackHelp)}</small>
|
|
1830
|
+
<label class="set-row"><span>${esc(st.impPackTitle)}</span><input type="url" id="im-url" placeholder="https://…/api/folders/…/pack" autocomplete="off"></label>
|
|
1831
|
+
<div><button class="btn" type="button" id="im-url-go">${esc(st.impPackGo)}</button></div>
|
|
1601
1832
|
<p class="set-status" id="im-status" role="status" aria-live="polite"></p>
|
|
1602
1833
|
<div><button class="btn primary" type="button" id="im-start" hidden>${esc(st.impStart)}</button></div></fieldset>`;
|
|
1603
1834
|
}
|
|
@@ -1611,7 +1842,7 @@
|
|
|
1611
1842
|
$("st-body").addEventListener("change", async (e) => {
|
|
1612
1843
|
if (e.target.id !== "im-file") return;
|
|
1613
1844
|
const st = T().st, out = $("im-status"), go = $("im-start");
|
|
1614
|
-
go.hidden = true; importContent = ""; clearInterval(importTimer);
|
|
1845
|
+
go.hidden = true; importContent = ""; importUrl = ""; importPack = null; clearInterval(importTimer);
|
|
1615
1846
|
const file = e.target.files?.[0];
|
|
1616
1847
|
if (!file) { out.textContent = ""; return; }
|
|
1617
1848
|
out.textContent = st.impReading;
|
|
@@ -1630,12 +1861,29 @@
|
|
|
1630
1861
|
d.total && d.skipped ? st.impSkipped(d.skipped) : "", d.capped ? st.impCapped(5000) : ""].filter(Boolean).join(" ");
|
|
1631
1862
|
go.hidden = !d.total;
|
|
1632
1863
|
});
|
|
1864
|
+
$("st-body").addEventListener("click", async (e) => {
|
|
1865
|
+
if (e.target.id !== "im-url-go") return;
|
|
1866
|
+
const st = T().st, out = $("im-status"), go = $("im-start");
|
|
1867
|
+
go.hidden = true; importContent = ""; importUrl = ""; importPack = null; clearInterval(importTimer);
|
|
1868
|
+
const url = $("im-url").value.trim();
|
|
1869
|
+
if (!url) return;
|
|
1870
|
+
out.textContent = st.impReading;
|
|
1871
|
+
const r = await importCall({ url, dryRun: true });
|
|
1872
|
+
if (!r || r.status !== 200) { out.textContent = r?.body?.error ?? T().failed; return; }
|
|
1873
|
+
const d = r.body;
|
|
1874
|
+
importUrl = url; importPack = d.pack ?? null;
|
|
1875
|
+
out.textContent = d.total ? st.impPackConfirm(d.pack?.name ?? "", d.total, d.duplicates) : st.impPackNone(d.pack?.name ?? "", d.duplicates);
|
|
1876
|
+
if (d.skipped) out.textContent += " " + st.impSkipped(d.skipped);
|
|
1877
|
+
go.hidden = false;
|
|
1878
|
+
});
|
|
1633
1879
|
$("st-body").addEventListener("click", async (e) => {
|
|
1634
1880
|
if (e.target.id !== "im-start") return;
|
|
1635
1881
|
const st = T().st, out = $("im-status"), go = $("im-start");
|
|
1636
1882
|
go.hidden = true;
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1883
|
+
const fromPack = !!importUrl;
|
|
1884
|
+
const r = await importCall(fromPack ? { url: importUrl } : { content: importContent, folders: $("im-keep").checked ? "keep" : "none" });
|
|
1885
|
+
const pack = importPack;
|
|
1886
|
+
importContent = ""; importUrl = ""; importPack = null;
|
|
1639
1887
|
if (!r) { out.textContent = T().failed; return; }
|
|
1640
1888
|
if (r.status === 409) { out.textContent = st.impBusy; return; }
|
|
1641
1889
|
if (r.status !== 202) { out.textContent = r.body?.error ?? T().failed; return; }
|
|
@@ -1649,11 +1897,13 @@
|
|
|
1649
1897
|
if (p.state === "running") out.textContent = st.impProgress(p.done, p.total, p.added, p.failed);
|
|
1650
1898
|
else {
|
|
1651
1899
|
clearInterval(importTimer);
|
|
1652
|
-
out.textContent = p.state
|
|
1900
|
+
out.textContent = p.state !== "done" ? st.impFailedRun : pack ? st.impPackDone(pack.name, p.added, p.already) : st.impDone(p.total, p.added, p.already, p.failed);
|
|
1653
1901
|
if (p.state === "done" && p.added) load();
|
|
1654
1902
|
}
|
|
1655
1903
|
};
|
|
1656
1904
|
importTimer = setInterval(tick, 2000);
|
|
1905
|
+
// A pack is done by the time the server answers: don't make the reader wait for the first tick.
|
|
1906
|
+
if (fromPack) tick();
|
|
1657
1907
|
});
|
|
1658
1908
|
let settingsOpener = null;
|
|
1659
1909
|
$("settings-dlg").addEventListener("close", () => { if (settingsOpener?.isConnected) settingsOpener.focus(); });
|
|
@@ -2450,6 +2700,20 @@
|
|
|
2450
2700
|
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>${
|
|
2451
2701
|
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>`;
|
|
2452
2702
|
}
|
|
2703
|
+
// Related cards ({id, name}) come with the single-card endpoint; fetched once per card, painted into their own row.
|
|
2704
|
+
const relatedCache = new Map();
|
|
2705
|
+
function paintRelated(id) {
|
|
2706
|
+
const box = $("md-related");
|
|
2707
|
+
if (!box) return;
|
|
2708
|
+
const rel = relatedCache.get(id);
|
|
2709
|
+
if (rel === undefined) {
|
|
2710
|
+
relatedCache.set(id, []);
|
|
2711
|
+
api(`/api/items/${id}`).then((r) => { relatedCache.set(id, r.related ?? []); if (modalId === id) paintRelated(id); }).catch(() => relatedCache.delete(id));
|
|
2712
|
+
return;
|
|
2713
|
+
}
|
|
2714
|
+
box.hidden = !rel.length;
|
|
2715
|
+
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("")}` : "";
|
|
2716
|
+
}
|
|
2453
2717
|
function paintModal() {
|
|
2454
2718
|
const i = find(modalId);
|
|
2455
2719
|
if (!i) return void (mdlDlg.open && mdlDlg.close());
|
|
@@ -2480,8 +2744,10 @@
|
|
|
2480
2744
|
${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>` : "")}
|
|
2481
2745
|
${sec("tags", t.mdTags, s?.tags?.length ? `<div class="md-tags tags">${s.tags.map((x) => `<span class="tag">#${esc(x)}</span>`).join(" ")}</div>` : "")}
|
|
2482
2746
|
${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>` : ""}
|
|
2483
|
-
|
|
2747
|
+
<div class="found" id="md-related" hidden></div>
|
|
2748
|
+
${flagLines(i, t)}
|
|
2484
2749
|
<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>`;
|
|
2750
|
+
paintRelated(i.id);
|
|
2485
2751
|
const busy = refreshing.has(i.id);
|
|
2486
2752
|
const btn = (act, icon, label, extra = "") => `<button class="btn ${extra}" type="button" data-md="${act}">${ic(icon)} ${esc(label)}</button>`;
|
|
2487
2753
|
$("md-actions").innerHTML = `<a class="btn primary" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${ic("link")} ${esc(t.openLink)}</a>` +
|
|
@@ -2489,11 +2755,64 @@
|
|
|
2489
2755
|
: btn("favorite", "star", i.favorite ? t.unfavorite : t.favorite, i.favorite ? "on" : "") + btn("move", "move", t.moveTo) +
|
|
2490
2756
|
`<button class="btn ${busy ? "spin" : ""}" type="button" data-md="refresh" ${busy ? "disabled" : ""}>${ic("refresh")} ${esc(t.refresh)}</button>` +
|
|
2491
2757
|
btn("health", "refresh", t.checkLink) + btn("note", "note", i.note ? t.editNote : t.addNote) + `<span class="spacer"></span>` + btn("trash", "trash", t.remove, "danger")) : "") +
|
|
2758
|
+
btn("history", "undo", t.histBtn, histFor === i.id ? "on" : "") +
|
|
2492
2759
|
(modalFrom === "map" ? btn("list", "list", t.showInList) : "");
|
|
2760
|
+
if (histFor === i.id) paintHistory(i);
|
|
2761
|
+
}
|
|
2762
|
+
// ── Change history (read: anyone who can read the card; restore: admin) ──
|
|
2763
|
+
let histFor = null, histRows = null;
|
|
2764
|
+
function histPreview(row, f) {
|
|
2765
|
+
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; };
|
|
2766
|
+
if (f === "note" || f === "title") return cut(b[f]);
|
|
2767
|
+
if (f === "summary") { try { const o = JSON.parse(b.summary); return cut(o.oneLiner || o.name); } catch { return t.histEmptyVal; } }
|
|
2768
|
+
if (f === "folder") return folderPath(b.category);
|
|
2769
|
+
if (f === "favorite") return b.favorite ? t.histStarOn : t.histStarOff;
|
|
2770
|
+
return b.trashed_at ? t.histInTrash : t.histOutTrash;
|
|
2771
|
+
}
|
|
2772
|
+
function paintHistory(i) {
|
|
2773
|
+
const t = T(), admin = role === "admin";
|
|
2774
|
+
let sec = document.getElementById("md-hist");
|
|
2775
|
+
if (!sec) { sec = document.createElement("section"); sec.id = "md-hist"; sec.className = "md-sec md-hist"; $("md-scroll").appendChild(sec); }
|
|
2776
|
+
const body = histRows == null ? "…" : !histRows.length ? `<p>${esc(t.histNone)}</p>` :
|
|
2777
|
+
`<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>${
|
|
2778
|
+
admin ? `<button class="btn" type="button" data-md="hist-restore" data-v="${r.v}">${esc(t.histRestore)}</button>` : ""}</li>`).join("")}</ul>`;
|
|
2779
|
+
sec.innerHTML = `<h4>${esc(t.histTitle)}</h4>${body}${admin && histRows?.length ? `<button class="btn" type="button" data-md="hist-forget">${esc(t.histForget)}</button>` : ""}`;
|
|
2780
|
+
}
|
|
2781
|
+
const when = (iso) => { const d = new Date(iso); return esc(isNaN(d) ? iso : d.toLocaleString(locale, { dateStyle: "short", timeStyle: "short" })); };
|
|
2782
|
+
async function loadHistory(id) {
|
|
2783
|
+
try { const rows = await api(`/api/items/${id}/history`); if (histFor === id) histRows = rows; } catch { if (histFor === id) { histRows = []; toast(T().histErr); } }
|
|
2784
|
+
if (histFor === id && modalId === id && mdlDlg.open) paintModal();
|
|
2785
|
+
}
|
|
2786
|
+
async function restoreVersion(id, v) {
|
|
2787
|
+
const saved = await mapWrite(`/api/items/${id}/history/${v}/restore`, "POST");
|
|
2788
|
+
if (!saved) return;
|
|
2789
|
+
const item = find(id);
|
|
2790
|
+
if (item) {
|
|
2791
|
+
// The server omits empty optional fields (a cleared note): replace the card's data, keep what only the list adds.
|
|
2792
|
+
const extra = { found: item.found, said: item.said, suggestions: item.suggestions };
|
|
2793
|
+
for (const k of Object.keys(item)) delete item[k];
|
|
2794
|
+
Object.assign(item, saved, extra);
|
|
2795
|
+
const el = document.getElementById(`item-${id}`);
|
|
2796
|
+
if (el) { el.outerHTML = card(item); attachSwipe(document.getElementById(`item-${id}`)); }
|
|
2797
|
+
}
|
|
2798
|
+
if (mapShown()) drawMap();
|
|
2799
|
+
refreshCounts(); refreshFolders();
|
|
2800
|
+
const rows = await api(`/api/items/${id}/history`).catch(() => null);
|
|
2801
|
+
const undoV = rows?.[0]?.v; // the restore itself is the newest version: restoring it again undoes it
|
|
2802
|
+
histRows = rows ?? histRows;
|
|
2803
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
2804
|
+
toast(T().histRestored, undoV ? async () => { await restoreVersion(id, undoV); } : undefined);
|
|
2805
|
+
}
|
|
2806
|
+
async function forgetHistory(id) {
|
|
2807
|
+
if (!(await mapWrite(`/api/items/${id}/history`, "DELETE"))) return;
|
|
2808
|
+
histRows = [];
|
|
2809
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
2810
|
+
toast(T().histForgot);
|
|
2493
2811
|
}
|
|
2494
2812
|
function openModal(id, from = "list") {
|
|
2495
2813
|
if (!find(id)) return;
|
|
2496
2814
|
const wasOpen = mdlDlg.open;
|
|
2815
|
+
if (modalId !== id) { histFor = null; histRows = null; }
|
|
2497
2816
|
modalId = id; modalFrom = from;
|
|
2498
2817
|
paintModal();
|
|
2499
2818
|
if (!wasOpen) mdlDlg.showModal();
|
|
@@ -2544,6 +2863,13 @@
|
|
|
2544
2863
|
history.replaceState(null, "", `#item-${id}`);
|
|
2545
2864
|
return load();
|
|
2546
2865
|
}
|
|
2866
|
+
if (act1 === "history") {
|
|
2867
|
+
histFor = histFor === id ? null : id; histRows = null;
|
|
2868
|
+
if (histFor) loadHistory(id);
|
|
2869
|
+
return paintModal();
|
|
2870
|
+
}
|
|
2871
|
+
if (act1 === "hist-restore") return restoreVersion(id, Number(b.dataset.v));
|
|
2872
|
+
if (act1 === "hist-forget") return forgetHistory(id);
|
|
2547
2873
|
if (act1 === "move") { mdlDlg.close(); return openMovePicker(id); }
|
|
2548
2874
|
if (act1 === "refresh") return refreshItem(id);
|
|
2549
2875
|
if (act1 === "health") return checkLink(id);
|
|
@@ -3178,7 +3504,7 @@
|
|
|
3178
3504
|
</div>
|
|
3179
3505
|
${s ? `<p>${esc(s.oneLiner)}</p>` : ""}
|
|
3180
3506
|
${s?.demo ? `<p class="demo">${esc(s.demo)}</p>` : ""}
|
|
3181
|
-
${
|
|
3507
|
+
${flagLines(i, t)}
|
|
3182
3508
|
${state.view === "inbox" ? inboxChips(i) : ""}
|
|
3183
3509
|
<div class="meta">
|
|
3184
3510
|
<span>#${i.id}</span><span>${esc(t.kind1?.[i.kind] ?? t.kinds[i.kind] ?? i.kind)}</span>${starsHtml(i)}${i.shareCount ? `<span>${esc(t.shared(i.shareCount))}</span>` : ""}
|
|
@@ -3319,9 +3645,23 @@
|
|
|
3319
3645
|
}
|
|
3320
3646
|
}
|
|
3321
3647
|
|
|
3648
|
+
/** A newer release is out: a small header notice, dismissed per version (this browser only). */
|
|
3649
|
+
function showUpdate(u) {
|
|
3650
|
+
const el = $("update");
|
|
3651
|
+
const ok = u && /^\d{1,9}\.\d{1,9}\.\d{1,9}(-[0-9A-Za-z.-]{1,40})?$/.test(u.latest ?? "");
|
|
3652
|
+
if (!ok || store.get("driftnet-update-dismissed") === u.latest) { el.hidden = true; return; }
|
|
3653
|
+
const t = T().st;
|
|
3654
|
+
const a = $("update-link");
|
|
3655
|
+
a.href = `https://github.com/KevinChu1110/driftnet/releases/tag/v${u.latest}`;
|
|
3656
|
+
a.textContent = `${t.updOut(u.latest)} · ${t.updHow}`;
|
|
3657
|
+
$("update-x").setAttribute("aria-label", t.updDismiss);
|
|
3658
|
+
$("update-x").onclick = () => { store.set("driftnet-update-dismissed", u.latest); el.hidden = true; };
|
|
3659
|
+
el.hidden = false;
|
|
3660
|
+
}
|
|
3322
3661
|
async function refreshCounts() {
|
|
3323
3662
|
const stats = await api("/api/stats").catch(() => null);
|
|
3324
3663
|
if (!stats) return;
|
|
3664
|
+
showUpdate(stats.update);
|
|
3325
3665
|
$("stats").textContent = T().stats(stats.items, stats.shares);
|
|
3326
3666
|
const set = (v, n) => { const c = $("nav").querySelector(`[data-field="view"][data-value="${v}"] .count`); if (c) c.textContent = n || (v === "all" ? "0" : ""); };
|
|
3327
3667
|
set("all", stats.items); set("favorites", stats.favorites); set("trash", stats.trash); set("inbox", stats.inbox); set("review", stats.review);
|