driftnet 0.5.0 → 0.7.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 +7 -0
- package/README.md +171 -65
- package/README.zh-TW.md +166 -58
- package/dist/cli.mjs +7 -0
- package/dist/driftnet.mjs +1592 -507
- package/package.json +16 -4
- package/public/index.html +395 -84
package/public/index.html
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
12
12
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
|
13
13
|
<link rel="manifest" href="/manifest.webmanifest">
|
|
14
|
+
<link rel="alternate" type="application/atom+xml" title="driftnet" href="/feed.xml">
|
|
14
15
|
<style>
|
|
15
16
|
:root {
|
|
16
17
|
--bg: #f7f7f5; --panel: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e4e4df;
|
|
@@ -151,10 +152,10 @@
|
|
|
151
152
|
.bar .spacer { flex: 1; }
|
|
152
153
|
dialog.wide { width: min(720px, calc(100vw - 32px)); }
|
|
153
154
|
#nd-body { min-height: 40vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
|
|
154
|
-
body.compact .card
|
|
155
|
+
body.compact .card .demo, body.compact .card .thumb { display: none; }
|
|
155
156
|
body.compact .card { padding-top: 10px; padding-bottom: 10px; }
|
|
156
157
|
body.compact .card p { margin: 2px 0; }
|
|
157
|
-
body.hide-tags .
|
|
158
|
+
body.hide-tags .tags, body.hide-said .said { display: none; }
|
|
158
159
|
.set-group { border: 0; padding: 0; margin: 0 0 16px; }
|
|
159
160
|
.set-group legend { font-weight: 650; font-size: 14px; margin-bottom: 8px; padding: 0; }
|
|
160
161
|
.set-row { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; color: var(--muted); }
|
|
@@ -171,7 +172,8 @@
|
|
|
171
172
|
.map-crumb [aria-current] { font-weight: 600; padding: 6px 4px; }
|
|
172
173
|
.map-crumb .sep { color: var(--muted); }
|
|
173
174
|
.mnode:focus-visible { outline: 2px solid var(--accent, currentColor); outline-offset: 2px; }
|
|
174
|
-
.map-tip { display: flex; gap:
|
|
175
|
+
.map-tip { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
|
|
176
|
+
.map-tip > button { flex: none; }
|
|
175
177
|
.map-wrap { position: relative; overflow: auto; height: 70vh; min-height: 320px; border: 1px solid var(--line);
|
|
176
178
|
border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); touch-action: pan-x pan-y pinch-zoom; overscroll-behavior: contain;
|
|
177
179
|
background-image: radial-gradient(color-mix(in srgb, var(--muted) 18%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
|
|
@@ -282,10 +284,6 @@
|
|
|
282
284
|
@media (max-width: 720px) { #palette-btn { display: none; } }
|
|
283
285
|
.map-wrap { user-select: none; -webkit-user-select: none; }
|
|
284
286
|
.mghost { position: fixed; z-index: 30; pointer-events: none; transform: translate(-50%, -130%) rotate(-2deg); opacity: .95; box-shadow: 0 10px 28px rgba(0,0,0,.25); }
|
|
285
|
-
.peek h3 { margin: 0 0 8px; font-size: 18px; }
|
|
286
|
-
.peek ul { color: var(--muted); padding-left: 20px; }
|
|
287
|
-
.peek-actions { flex-wrap: wrap; }
|
|
288
|
-
.peek-actions .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
|
|
289
287
|
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--bg); border-radius: 12px; margin-bottom: 14px; position: sticky; top: 0; z-index: 1; }
|
|
290
288
|
.tabs button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; min-height: 40px; cursor: pointer; color: var(--muted); font-weight: 600; }
|
|
291
289
|
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
|
|
@@ -299,7 +297,6 @@
|
|
|
299
297
|
.meta .link-btn { min-height: 32px; }
|
|
300
298
|
.tags { white-space: normal; } .tags .tag { white-space: nowrap; }
|
|
301
299
|
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
|
|
302
|
-
@media (max-width: 720px) { .peek-actions { display: grid; grid-template-columns: 1fr 1fr; } .peek-actions .spacer { display: none; } }
|
|
303
300
|
.set-row .envname { font-family: ui-monospace, Menlo, monospace; font-size: 11px; opacity: .6; }
|
|
304
301
|
dialog::backdrop { backdrop-filter: blur(3px); }
|
|
305
302
|
.act span { display: inline-flex; align-items: center; gap: 6px; }
|
|
@@ -309,6 +306,8 @@
|
|
|
309
306
|
.empty.first { display: grid; gap: 14px; justify-items: center; }
|
|
310
307
|
.empty.first .add { display: flex; gap: 8px; width: min(520px, 100%); }
|
|
311
308
|
.empty.first .add input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); }
|
|
309
|
+
.empty.first .tpl { display: grid; gap: 6px; justify-items: center; margin-top: 8px; }
|
|
310
|
+
.empty.first .tpl-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
|
|
312
311
|
.empty.first .btn { display: inline-flex; align-items: center; gap: 6px; }
|
|
313
312
|
@media (pointer: coarse) {
|
|
314
313
|
.mnode .opt { padding: 10px; margin: -6px -12px -6px 0; }
|
|
@@ -421,6 +420,8 @@
|
|
|
421
420
|
display: grid; place-items: center; color: var(--muted); }
|
|
422
421
|
.tool:hover, .tool:focus-visible { background: var(--bg); color: var(--text); }
|
|
423
422
|
.tool.on { color: var(--star); }
|
|
423
|
+
.tool.spin .ico, .btn.spin .ico { animation: spin .9s linear infinite; }
|
|
424
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
424
425
|
.empty { color: var(--muted); padding: 48px 0; text-align: center; }
|
|
425
426
|
|
|
426
427
|
.toast { position: fixed; left: 50%; bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); transform: translate(-50%, 140%);
|
|
@@ -473,6 +474,69 @@
|
|
|
473
474
|
.tools { position: static; justify-content: flex-end; margin: 4px -6px -8px 0; }
|
|
474
475
|
.card ul { padding-left: 18px; }
|
|
475
476
|
}
|
|
477
|
+
/* Card list: a thumbnail, the name, the one-liner and what you would see. Everything else lives in the modal. */
|
|
478
|
+
.card { cursor: pointer; }
|
|
479
|
+
.crow { display: flex; gap: 14px; align-items: flex-start; }
|
|
480
|
+
.cbody { flex: 1; min-width: 0; }
|
|
481
|
+
.thumb { position: relative; flex: 0 0 132px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
|
|
482
|
+
.thumb .more-pics { position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px; background: rgb(0 0 0 / .62); color: #fff; font-size: 12px; font-weight: 600; }
|
|
483
|
+
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
484
|
+
.thumb .play, .g-slide .play { position: absolute; inset: 0; margin: auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
|
|
485
|
+
background: rgba(0,0,0,.6); color: #fff; font-size: 14px; pointer-events: none; }
|
|
486
|
+
.card p.demo { color: var(--muted); font-size: 14px; margin: 2px 0 4px; }
|
|
487
|
+
.meta .has-note { display: inline-flex; color: var(--accent); }
|
|
488
|
+
.meta .has-note .ico { width: 14px; height: 14px; }
|
|
489
|
+
/* The detail modal: gallery, the story, the actions. A full-screen sheet on a phone. */
|
|
490
|
+
dialog.mdl { padding: 0; width: min(760px, calc(100vw - 32px)); max-height: min(92vh, 900px); overflow: hidden; }
|
|
491
|
+
dialog.mdl[open] { display: flex; flex-direction: column; }
|
|
492
|
+
.md-top { display: flex; align-items: center; gap: 4px; padding: 8px 10px 4px 16px; touch-action: none; flex: none; }
|
|
493
|
+
.md-handle { display: none; }
|
|
494
|
+
.md-top .md-pos { color: var(--muted); font-size: 13px; margin-right: auto; }
|
|
495
|
+
.md-top .tool { width: 40px; height: 40px; font-size: 22px; }
|
|
496
|
+
.md-top .tool .ico { width: 20px; height: 20px; }
|
|
497
|
+
.md-top .prev .ico { transform: rotate(180deg); }
|
|
498
|
+
.md-scroll { overflow: auto; padding: 0 18px 12px; flex: 1; min-height: 0; overscroll-behavior: contain; }
|
|
499
|
+
.md-scroll h3 { margin: 12px 0 6px; font-size: 21px; letter-spacing: -.01em; }
|
|
500
|
+
.md-scroll h3 a { color: var(--text); text-decoration: none; }
|
|
501
|
+
.md-scroll h3 a:hover { color: var(--accent); }
|
|
502
|
+
.md-sub { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin: 0 0 10px; color: var(--muted); font-size: 13px; }
|
|
503
|
+
.md-one { margin: 0 0 6px; font-size: 16px; }
|
|
504
|
+
.md-sec { margin: 14px 0; }
|
|
505
|
+
.md-sec h4 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
|
|
506
|
+
.md-sec p { margin: 4px 0; font-size: 15px; }
|
|
507
|
+
.md-sec ul { margin: 4px 0; padding-left: 20px; color: var(--muted); font-size: 14px; line-height: 1.65; }
|
|
508
|
+
.md-sec.demo p { font-size: 16px; }
|
|
509
|
+
.md-try { position: relative; }
|
|
510
|
+
.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; }
|
|
511
|
+
.md-try button { position: absolute; top: 6px; right: 6px; }
|
|
512
|
+
.md-tags { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; color: var(--muted); }
|
|
513
|
+
.md-fine { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 12px; }
|
|
514
|
+
.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; }
|
|
515
|
+
.md-actions .spacer { flex: 1; }
|
|
516
|
+
.md-actions .btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
|
|
517
|
+
.md-actions .btn.on { border-color: var(--star); color: var(--star); }
|
|
518
|
+
.gallery { margin: 4px 0 0; }
|
|
519
|
+
.g-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); overscroll-behavior-x: contain; }
|
|
520
|
+
.g-track::-webkit-scrollbar { display: none; }
|
|
521
|
+
.g-slide { position: relative; flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 16 / 9; max-height: min(34vh, 340px); display: grid; place-items: center; }
|
|
522
|
+
.g-slide a { display: block; width: 100%; height: 100%; }
|
|
523
|
+
.g-slide img { width: 100%; height: 100%; object-fit: contain; display: block; }
|
|
524
|
+
.g-slide .play { width: 56px; height: 56px; font-size: 22px; }
|
|
525
|
+
.g-thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
|
|
526
|
+
.g-th { flex: 0 0 72px; height: 48px; padding: 0; border-radius: 8px; overflow: hidden; border: 2px solid transparent; background: var(--bg); cursor: pointer; opacity: .7; }
|
|
527
|
+
.g-th.on { border-color: var(--accent); opacity: 1; }
|
|
528
|
+
.g-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
|
529
|
+
@media (max-width: 720px) {
|
|
530
|
+
.thumb { flex-basis: 96px; height: 72px; }
|
|
531
|
+
.crow { gap: 10px; }
|
|
532
|
+
dialog.mdl { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; transition: transform .2s ease; }
|
|
533
|
+
.md-handle { display: block; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
|
|
534
|
+
.md-top { padding-top: 14px; }
|
|
535
|
+
.md-actions { display: grid; grid-template-columns: 1fr 1fr; }
|
|
536
|
+
.md-actions .spacer { display: none; }
|
|
537
|
+
.g-slide { max-height: 36vh; }
|
|
538
|
+
}
|
|
539
|
+
@media (prefers-reduced-motion: reduce) { dialog.mdl { transition: none; } }
|
|
476
540
|
@media (prefers-reduced-motion: reduce) { .card, .swipe, .toast, nav, .scrim, nav .twist, .mnode, .mnode .tw, .tool { transition: none !important; } }
|
|
477
541
|
</style>
|
|
478
542
|
</head>
|
|
@@ -492,6 +556,7 @@
|
|
|
492
556
|
<symbol id="i-download" viewBox="0 0 24 24"><path d="M12 3.5v11.5M7 10.5l5 5 5-5M4.5 20.5h15"/></symbol>
|
|
493
557
|
<symbol id="i-lock" viewBox="0 0 24 24"><rect x="4.5" y="10.5" width="15" height="10" rx="2"/><path d="M8 10.5V7.5a4 4 0 0 1 8 0v3"/></symbol>
|
|
494
558
|
<symbol id="i-logout" viewBox="0 0 24 24"><path d="M9.5 20.5H6a2 2 0 0 1-2-2v-13a2 2 0 0 1 2-2h3.5M15.5 16.5 20 12l-4.5-4.5M20 12H9.5"/></symbol>
|
|
559
|
+
<symbol id="i-refresh" viewBox="0 0 24 24"><path d="M20 11a8 8 0 0 0-14.5-4M4 4v4h4M4 13a8 8 0 0 0 14.5 4M20 20v-4h-4"/></symbol>
|
|
495
560
|
<symbol id="i-undo" viewBox="0 0 24 24"><path d="M9 14 4 9l5-5M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/></symbol>
|
|
496
561
|
<symbol id="i-chat" viewBox="0 0 24 24"><path d="M20.5 11.5a8 8 0 0 1-11.7 7.1L4 20l1.4-4.6A8 8 0 1 1 20.5 11.5z"/></symbol>
|
|
497
562
|
<symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
|
|
@@ -557,14 +622,14 @@
|
|
|
557
622
|
<button class="btn" id="st-cancel" type="button"></button><button class="btn primary" id="st-save" type="submit"></button></div>
|
|
558
623
|
</form>
|
|
559
624
|
</dialog>
|
|
560
|
-
<dialog id="
|
|
561
|
-
<div id="
|
|
562
|
-
|
|
563
|
-
<
|
|
564
|
-
<button class="
|
|
565
|
-
<button class="
|
|
566
|
-
|
|
567
|
-
|
|
625
|
+
<dialog id="item-dlg" class="mdl" aria-labelledby="md-title">
|
|
626
|
+
<div class="md-top" id="md-grab"><span class="md-handle" aria-hidden="true"></span>
|
|
627
|
+
<span class="md-pos" id="md-pos" aria-live="polite"></span>
|
|
628
|
+
<button class="tool prev" type="button" data-md="prev" id="md-prev"></button>
|
|
629
|
+
<button class="tool next" type="button" data-md="next" id="md-next"></button>
|
|
630
|
+
<button class="tool" type="button" data-md="close" id="md-close">×</button></div>
|
|
631
|
+
<div class="md-scroll" id="md-scroll"></div>
|
|
632
|
+
<div class="dlg-actions md-actions" id="md-actions"></div>
|
|
568
633
|
</dialog>
|
|
569
634
|
<dialog id="login-dlg" aria-labelledby="lg-title">
|
|
570
635
|
<form id="login-form" method="dialog">
|
|
@@ -641,6 +706,7 @@
|
|
|
641
706
|
folders: "Folders", newFolder: "New folder", newSub: "New folder inside", editFolder: "Edit folder", folderName: "Name",
|
|
642
707
|
folderDesc: "What goes here? (driftnet's AI reads this to sort new links)", folderParent: "Inside", topLevel: "— Top level —",
|
|
643
708
|
save: "Save", cancel: "Cancel", del: "Delete folder", delSure: "Delete? Links move up",
|
|
709
|
+
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}` : ""}`,
|
|
644
710
|
moveTo: "Move to…", moveTitle: (n) => `Move “${n}” to`, moved: (n, f) => `Moved “${n}” to ${f}`, expand: "Show sub-folders",
|
|
645
711
|
dragHint: "Drag onto a folder in the sidebar", foundIn: "Found in this post:", folderMoved: (n, f) => `“${n}” is now inside ${f}`,
|
|
646
712
|
topLevelShort: "the top level",
|
|
@@ -652,7 +718,7 @@
|
|
|
652
718
|
a11yFolder: (n, c) => `Folder ${n}, ${c} cards`, a11yCard: (n) => `Card ${n}`,
|
|
653
719
|
expandAll: "Expand all", collapseAll: "Collapse all", zoomIn: "Zoom in", zoomOut: "Zoom out", fit: "Fit", openCard: "Open card",
|
|
654
720
|
layoutBoth: "Both sides", layoutRight: "Right side", layoutHelp: "Switch between branches on both sides (XMind) and all to the right",
|
|
655
|
-
zoom: "Zoom", gotIt: "Got it", more: (n) => `+${n} more`, mapSearch: (q) => `Highlighting “${q}”`, openLink: "Open link", showInList: "Show in the list", close: "Close",
|
|
721
|
+
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",
|
|
656
722
|
needPassword: "Changing things needs the admin password.",
|
|
657
723
|
notes: "Notes", note: "Note", addNote: "Add a note", editNote: "Edit note", noteFor: (n) => `Note on “${n}”`,
|
|
658
724
|
noteHelp: "Only for you: what you thought, whether you tried it…", newNote: "New note", noteTitle: "Title",
|
|
@@ -660,6 +726,7 @@
|
|
|
660
726
|
emptyNotes: "No notes yet. Notes can link cards: write #12.", exportMd: "Download a backup (Markdown)", exportVault: "Download for Obsidian / Notion",
|
|
661
727
|
saved: "Saved", settings: "Settings", pickedUp: (n) => `Picked up “${n}” — tap the folder it goes into`, alreadyThere: "It's already in that folder",
|
|
662
728
|
readOnlyNudge: "You can only look here — tap Unlock at the top to change things", filterFolders: "Type to find a folder…", undoHint: "z undoes",
|
|
729
|
+
tplTitle: "Start with folders for:", tplAi: "AI & coding", tplResearch: "Research", tplEveryday: "Everyday", tplSkip: "Keep the default", tplFailed: "Can't change the folders now: you already have cards or changed them.",
|
|
663
730
|
addLink: "Add", addPlaceholder: "Paste a link to a tool, post or video…", added: "Saved — sorting it now",
|
|
664
731
|
shortcuts: "Keys: j / k next / previous · f favorite · m move · n note · # trash · / search · g m mind map",
|
|
665
732
|
keysTitle: "Keyboard shortcuts", keysMove: "Move, favorite, trash", keysSelect: "Select several cards", keysGo: "Go to", keysQuick: "File into your most-used folders",
|
|
@@ -689,7 +756,7 @@
|
|
|
689
756
|
plugins: "Plugins", pluginsNone: (dir) => `No plugins. Put .js files in ${dir} — see examples/plugins in the repo.`,
|
|
690
757
|
status: (e) => `Now: sorting by ${({ jev: "Jev", llm: "the model", heuristic: "built-in rules" })[e.judge] ?? e.judge}, summaries: ${e.summarizer === "off" ? "off" : e.summarizer}`, keep: "set — leave empty to keep", unset: "not set",
|
|
691
758
|
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.",
|
|
692
|
-
savedServer: "Saved — already in effect", chat: "Chat replies", genCopied: "New password generated and copied — press Save to keep it",
|
|
759
|
+
savedServer: "Saved — already in effect", chat: "Chat replies", webhook: "Outgoing webhook", feed: "Feed (RSS)", genCopied: "New password generated and copied — press Save to keep it",
|
|
693
760
|
tabGeneral: "General", tabAccess: "Access", tabAi: "AI",
|
|
694
761
|
accessStatus: (pw, key, url) => `Password: ${pw === "✓" ? "set" : "not set"} · Share key: ${key === "✓" ? "made" : "none"} · Public URL: ${url === "—" ? "off" : url}`,
|
|
695
762
|
access: "Access & connections",
|
|
@@ -736,15 +803,21 @@
|
|
|
736
803
|
DRIFTNET_LOCALE: ["Bot language", ""],
|
|
737
804
|
DRIFTNET_REPLY: ["How the bot replies", ""],
|
|
738
805
|
DRIFTNET_PUBLIC_URL: ["This page's public URL", "Replies link here, e.g. https://driftnet.example.com"],
|
|
806
|
+
DRIFTNET_SUMMARY_DEPTH: ["Summary detail", "How much each card says. Detailed costs more model tokens and reads twice as much of each page."],
|
|
739
807
|
DRIFTNET_SUMMARY_RULES: ["Extra rules for summaries", "e.g. Say whether it's free. Mention if it needs a GPU."],
|
|
740
808
|
DRIFTNET_BLOCK_DOMAINS: ["Never catalogue these domains", "Comma or space separated, e.g. example.com, spam.io"],
|
|
809
|
+
DRIFTNET_WEBHOOK_URL: ["Webhook URL", "driftnet POSTs each new or updated card here (n8n, Zapier, Slack workflows…). Treated as a secret."],
|
|
810
|
+
DRIFTNET_WEBHOOK_SECRET: ["Webhook signing secret", "Optional. Adds X-Driftnet-Signature: sha256=<HMAC of the body>."],
|
|
811
|
+
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."],
|
|
741
812
|
},
|
|
742
813
|
choices: {
|
|
743
814
|
DRIFTNET_LLM_PROVIDER: { "": "None", anthropic: "Anthropic (API key)", openai: "OpenAI-compatible (OpenAI, Gemini, Grok, Ollama…)", "claude-cli": "Claude subscription (Claude Code CLI)", "gemini-cli": "Google account (Gemini CLI)" },
|
|
744
|
-
DRIFTNET_LLM_EFFORT: { "": "Default", low: "Low", medium: "Medium", high: "High" },
|
|
815
|
+
DRIFTNET_LLM_EFFORT: { "": "Default", low: "Low", medium: "Medium", high: "High", xhigh: "Extra high" },
|
|
745
816
|
DRIFTNET_JUDGE: { "": "On when a key is set", off: "Off" },
|
|
817
|
+
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" },
|
|
746
818
|
DRIFTNET_LOCALE: { "": "Same as the summaries", en: "English", "zh-TW": "繁體中文" },
|
|
747
819
|
DRIFTNET_REPLY: { "": "One line + link (default)", link: "One line + link", full: "Full summary", off: "Don't reply" },
|
|
820
|
+
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "No (public addresses only)", 1: "Yes" },
|
|
748
821
|
},
|
|
749
822
|
},
|
|
750
823
|
},
|
|
@@ -755,7 +828,7 @@
|
|
|
755
828
|
empty: "還沒有內容,把連結丟進聊天室吧。", emptyFav: "還沒有最愛,把卡片往右滑或按星號。",
|
|
756
829
|
emptyTrash: "垃圾桶是空的。", hint: "往右滑加入最愛,往左滑移到垃圾桶。", hintTrash: "往右滑還原。",
|
|
757
830
|
kinds: { repo: "程式庫", product: "產品", video: "影片", article: "文章", post: "貼文", other: "其他" },
|
|
758
|
-
worth: { skip: "略過", low: "
|
|
831
|
+
worth: { skip: "略過", low: "次要", normal: "值得看", "must-see": "必看" },
|
|
759
832
|
flags: { injection: "提示詞注入", "hidden-chars": "隱藏字元", "low-reputation": "低信譽來源" },
|
|
760
833
|
pending: "等待摘要", noModel: "沒有摘要(未設定模型)", enrichedBy: (a) => `由 ${a} 整理`,
|
|
761
834
|
favorite: "加入最愛", unfavorite: "移出最愛", remove: "移到垃圾桶", restore: "還原",
|
|
@@ -767,6 +840,7 @@
|
|
|
767
840
|
folders: "資料夾", newFolder: "新資料夾", newSub: "在裡面新增資料夾", editFolder: "編輯資料夾", folderName: "名稱",
|
|
768
841
|
folderDesc: "放什麼?(driftnet 的 AI 會照這段說明把新連結分進來)", folderParent: "放在", topLevel: "— 最上層 —",
|
|
769
842
|
save: "儲存", cancel: "取消", del: "刪除資料夾", delSure: "確定刪除?內容移到上一層",
|
|
843
|
+
refresh: "重新整理(再抓一次並重新摘要)", refreshed: (n) => `已重新整理「${n}」`, refreshBusy: "這張卡片正在重新整理。", refreshWait: "剛剛才整理過,請一分鐘後再試。", refreshFailed: (why) => `重新整理失敗${why ? `:${why}` : ""}`,
|
|
770
844
|
moveTo: "移動到…", moveTitle: (n) => `把「${n}」移動到`, moved: (n, f) => `已將「${n}」移到 ${f}`, expand: "展開子資料夾",
|
|
771
845
|
dragHint: "拖到側邊欄的資料夾", foundIn: "從這篇找到:", folderMoved: (n, f) => `「${n}」已移到 ${f} 底下`,
|
|
772
846
|
topLevelShort: "最上層",
|
|
@@ -778,7 +852,7 @@
|
|
|
778
852
|
a11yFolder: (n, c) => `資料夾 ${n},${c} 張卡片`, a11yCard: (n) => `卡片 ${n}`,
|
|
779
853
|
expandAll: "全部展開", collapseAll: "全部收合", zoomIn: "放大", zoomOut: "縮小", fit: "符合畫面", openCard: "開啟卡片",
|
|
780
854
|
layoutBoth: "兩側展開", layoutRight: "往右展開", layoutHelp: "切換:分支分佈在兩側(XMind 預設)或全部往右",
|
|
781
|
-
zoom: "縮放", gotIt: "知道了", more: (n) => `還有 ${n} 張`, mapSearch: (q) => `標亮「${q}」`, openLink: "開啟連結", showInList: "在清單中查看", close: "關閉",
|
|
855
|
+
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: "關閉",
|
|
782
856
|
needPassword: "要修改需要管理密碼。",
|
|
783
857
|
notes: "筆記", note: "筆記", addNote: "加筆記", editNote: "改筆記", noteFor: (n) => `「${n}」的筆記`,
|
|
784
858
|
noteHelp: "只有你看得到:心得、試用結果、要注意的地方…", newNote: "新筆記", noteTitle: "標題",
|
|
@@ -786,6 +860,7 @@
|
|
|
786
860
|
emptyNotes: "還沒有筆記。筆記可以連到卡片:寫 #12。", exportMd: "下載備份(Markdown)", exportVault: "下載給 Obsidian/Notion",
|
|
787
861
|
saved: "已儲存", settings: "設定", pickedUp: (n) => `已拿起「${n}」,點要放進去的資料夾`, alreadyThere: "它已經在這個資料夾裡了",
|
|
788
862
|
readOnlyNudge: "目前只能看。要修改,請點上方的「解鎖」", filterFolders: "輸入文字找資料夾…", undoHint: "按 z 復原",
|
|
863
|
+
tplTitle: "從這些資料夾開始:", tplAi: "AI 與程式", tplResearch: "研究", tplEveryday: "日常生活", tplSkip: "維持預設", tplFailed: "現在不能換資料夾了:已經有卡片,或資料夾被你改過。",
|
|
789
864
|
addLink: "收錄", addPlaceholder: "貼上工具、貼文或影片的連結…", added: "收到,正在整理",
|
|
790
865
|
shortcuts: "快捷鍵:j/k 下一張/上一張 · f 最愛 · m 移動 · n 筆記 · # 垃圾桶 · / 搜尋 · g m 樹狀圖",
|
|
791
866
|
keysTitle: "快捷鍵", keysMove: "移動、最愛、垃圾桶", keysSelect: "一次選多張卡片", keysGo: "切換畫面", keysQuick: "放進最常用的資料夾",
|
|
@@ -815,7 +890,7 @@
|
|
|
815
890
|
plugins: "外掛", pluginsNone: (dir) => `沒有外掛。把 .js 檔放進 ${dir},範例在 repo 的 examples/plugins。`,
|
|
816
891
|
status: (e) => `目前:分類用 ${({ jev: "Jev", llm: "模型", heuristic: "內建規則" })[e.judge] ?? e.judge},摘要用 ${e.summarizer === "off" ? "(未開啟)" : e.summarizer}`, keep: "已設定,留空就不變", unset: "未設定",
|
|
817
892
|
locked: "由執行環境設定", forbidden: "伺服器設定只能在執行 driftnet 的那台電腦上改(或設定 DRIFTNET_TOKEN)。顯示設定照常可用。",
|
|
818
|
-
savedServer: "已儲存,馬上生效", chat: "聊天室回覆", genCopied: "已產生新密碼並複製,按「儲存」才會生效",
|
|
893
|
+
savedServer: "已儲存,馬上生效", chat: "聊天室回覆", webhook: "對外 Webhook", feed: "訂閱源(RSS)", genCopied: "已產生新密碼並複製,按「儲存」才會生效",
|
|
819
894
|
tabGeneral: "一般", tabAccess: "存取", tabAi: "AI",
|
|
820
895
|
accessStatus: (pw, key, url) => `密碼:${pw === "✓" ? "已設定" : "未設定"} · 分享碼:${key === "✓" ? "已產生" : "沒有"} · 公開網址:${url === "—" ? "關閉" : url}`,
|
|
821
896
|
access: "存取與連線",
|
|
@@ -862,15 +937,21 @@
|
|
|
862
937
|
DRIFTNET_LOCALE: ["機器人語言", ""],
|
|
863
938
|
DRIFTNET_REPLY: ["機器人怎麼回覆", ""],
|
|
864
939
|
DRIFTNET_PUBLIC_URL: ["這個網頁的公開網址", "回覆裡的連結會指到這裡,例如 https://driftnet.example.com"],
|
|
940
|
+
DRIFTNET_SUMMARY_DEPTH: ["摘要詳細程度", "每張卡片寫多少。詳細會用較多模型 token,且每個頁面讀兩倍的內容。"],
|
|
865
941
|
DRIFTNET_SUMMARY_RULES: ["摘要的額外規則", "例如:說明是否免費。需要 GPU 的話要提到。"],
|
|
866
942
|
DRIFTNET_BLOCK_DOMAINS: ["不要收錄的網域", "用逗號或空白分隔,例如 example.com, spam.io"],
|
|
943
|
+
DRIFTNET_WEBHOOK_URL: ["Webhook 網址", "每張新增或更新的卡片都會 POST 到這裡(n8n、Zapier、Slack 工作流程…)。視為機密。"],
|
|
944
|
+
DRIFTNET_WEBHOOK_SECRET: ["Webhook 簽章密鑰", "選填。會加上 X-Driftnet-Signature: sha256=<內容的 HMAC>。"],
|
|
945
|
+
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["允許本機 Webhook", "接收端在你自己的區域網路時需要(例如內網的 n8n)。只放行你填的那個位址。"],
|
|
867
946
|
},
|
|
868
947
|
choices: {
|
|
869
948
|
DRIFTNET_LLM_PROVIDER: { "": "不使用", anthropic: "Anthropic(API 金鑰)", openai: "OpenAI 相容(OpenAI、Gemini、Grok、Ollama…)", "claude-cli": "Claude 訂閱(Claude Code CLI)", "gemini-cli": "Google 帳號(Gemini CLI)" },
|
|
870
|
-
DRIFTNET_LLM_EFFORT: { "": "預設", low: "低", medium: "中", high: "高" },
|
|
949
|
+
DRIFTNET_LLM_EFFORT: { "": "預設", low: "低", medium: "中", high: "高", xhigh: "極高" },
|
|
871
950
|
DRIFTNET_JUDGE: { "": "有金鑰就開", off: "關閉" },
|
|
951
|
+
DRIFTNET_SUMMARY_DEPTH: { "": "標準(預設)", brief: "簡短:一句話、2 個重點、看得到什麼", standard: "標準", detailed: "詳細:更多重點、使用情境、怎麼試用" },
|
|
872
952
|
DRIFTNET_LOCALE: { "": "跟摘要一樣", en: "English", "zh-TW": "繁體中文" },
|
|
873
953
|
DRIFTNET_REPLY: { "": "一行+連結(預設)", link: "一行+連結", full: "完整摘要", off: "不回覆" },
|
|
954
|
+
DRIFTNET_WEBHOOK_ALLOW_LOCAL: { "": "否(只允許公開位址)", 1: "是" },
|
|
874
955
|
},
|
|
875
956
|
},
|
|
876
957
|
},
|
|
@@ -1437,7 +1518,7 @@
|
|
|
1437
1518
|
const yes = (b) => (b ? "✓" : "—");
|
|
1438
1519
|
const accessStatus = `<p class="set-status">${esc(st.accessStatus(yes(a.passwordSet), yes(a.readKey), a.tunnel.running ? a.tunnel.url : "—"))}</p>`;
|
|
1439
1520
|
server = {
|
|
1440
|
-
general: group("language") + group("chat"),
|
|
1521
|
+
general: group("language") + group("chat") + group("webhook"),
|
|
1441
1522
|
access: accessStatus + accessPanel(serverSettings, field) + (agentTokens ? tokensPanel(serverSettings.access, agentTokens, minted) + pairPanel(serverSettings.access) : ""),
|
|
1442
1523
|
ai: `<p class="set-status" id="st-status">${esc(st.status(serverSettings.engines))}</p>` + group("model") + group("rules") +
|
|
1443
1524
|
`<fieldset class="set-group"><legend>${esc(st.plugins)}</legend><div class="set-row">${plugins}</div></fieldset>`,
|
|
@@ -1778,7 +1859,7 @@
|
|
|
1778
1859
|
: `<button type="button" data-map="focus" data-id="${esc(id)}">${esc(catLabel(id))}</button>`)).join("") + `</nav>`;
|
|
1779
1860
|
})() : "";
|
|
1780
1861
|
const allOpen = mapOpen.size > 0 || !!state.q;
|
|
1781
|
-
const tip = store.get("driftnet-map-tip") ? "" : `<p class="hint map-tip">${esc(t.mapHint)} ${esc(t.mapHintFocus)}
|
|
1862
|
+
const tip = store.get("driftnet-map-tip") ? "" : `<p class="hint map-tip"><span>${esc(t.mapHint)} ${esc(t.mapHintFocus)}</span><button class="link-btn" type="button" data-map="tip">${esc(t.gotIt)}</button></p>`;
|
|
1782
1863
|
$("list").innerHTML = `<div class="map-bar">
|
|
1783
1864
|
<button class="btn" type="button" data-map="${allOpen ? "collapse" : "expand"}">${ic(allOpen ? "collapse" : "expand")} ${esc(allOpen ? t.collapseAll : t.expandAll)}</button>
|
|
1784
1865
|
<button class="btn" type="button" data-map="new">${ic("plus")} ${esc(t.newFolder)}</button>
|
|
@@ -2131,7 +2212,7 @@
|
|
|
2131
2212
|
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); tapNode(node.dataset.key); }
|
|
2132
2213
|
else if ((e.key === "F2" || e.key === "e") && node.dataset.key.startsWith("f:") && role === "admin") { e.preventDefault(); openFolderDialog(node.dataset.key.slice(2)); }
|
|
2133
2214
|
else if (e.key === "m" && node.dataset.key.startsWith("i:") && role === "admin") { e.preventDefault(); openMovePicker(Number(node.dataset.key.slice(2))); }
|
|
2134
|
-
else if (e.key === "z" && node.dataset.key.startsWith("f:") && !
|
|
2215
|
+
else if (e.key === "z" && node.dataset.key.startsWith("f:") && !canUndo()) { e.preventDefault(); setMapFocus(node.dataset.key.slice(2)); }
|
|
2135
2216
|
else treeKey(e, node);
|
|
2136
2217
|
});
|
|
2137
2218
|
})();
|
|
@@ -2233,38 +2314,188 @@
|
|
|
2233
2314
|
// A long press on a phone must not open the system menu over the map.
|
|
2234
2315
|
$("list").addEventListener("contextmenu", (e) => { if (e.target.closest(".mnode")) e.preventDefault(); });
|
|
2235
2316
|
|
|
2236
|
-
/** A card from the map, without leaving the map. */
|
|
2237
|
-
|
|
2238
|
-
function openPeek(id) {
|
|
2239
|
-
const i = mapItems.find((x) => x.id === id) ?? find(id);
|
|
2240
|
-
if (!i) return;
|
|
2241
|
-
peeking = id;
|
|
2242
|
-
const t = T(), s = i.summary;
|
|
2243
|
-
$("pk-body").innerHTML = `<h3>${esc(s?.name ?? i.title)}</h3>
|
|
2244
|
-
<p><span class="badge folder" style="--c:${folderColor(i.category)}">${esc(folderPath(i.category))}</span>
|
|
2245
|
-
<span class="rating ${i.worth === "must-see" ? "must" : ""}">${i.worth === "must-see" ? ic("star") : ""}${esc(t.worth[i.worth] ?? i.worth)}</span></p>
|
|
2246
|
-
${s ? `<p>${esc(s.oneLiner)}</p>` : ""}
|
|
2247
|
-
${s?.highlights?.length ? `<ul>${s.highlights.map((h) => `<li>${esc(h)}</li>`).join("")}</ul>` : ""}
|
|
2248
|
-
${i.note ? `<div class="mynote">${ic("note")}<span>${esc(i.note)}</span></div>` : ""}`;
|
|
2249
|
-
$("pk-open").href = safeUrl(s?.primaryUrl || i.url);
|
|
2250
|
-
$("pk-open").innerHTML = `${ic("link")} ${esc(t.openLink)}`;
|
|
2251
|
-
$("pk-move").innerHTML = `${ic("move")} ${esc(t.moveTo)}`;
|
|
2252
|
-
$("pk-move").hidden = role !== "admin";
|
|
2253
|
-
$("pk-list").innerHTML = `${ic("list")} ${esc(t.showInList)}`;
|
|
2254
|
-
$("pk-close").textContent = t.close;
|
|
2255
|
-
$("pk-close").hidden = matchMedia("(max-width: 720px)").matches; // tap outside closes it on a phone
|
|
2256
|
-
$("peek-dlg").showModal();
|
|
2257
|
-
}
|
|
2258
|
-
$("pk-close").onclick = () => $("peek-dlg").close();
|
|
2317
|
+
/** A card from the map, without leaving the map: the same modal the list uses. */
|
|
2318
|
+
const openPeek = (id) => openModal(id, "map");
|
|
2259
2319
|
$("pick-cancel").onclick = () => dropPicked();
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
$("
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2320
|
+
|
|
2321
|
+
// ── The detail modal (one implementation for the list and the map) ───────
|
|
2322
|
+
const mdlDlg = $("item-dlg");
|
|
2323
|
+
let modalId = null, modalFrom = "list", keepHash = false;
|
|
2324
|
+
/** Cards ←/→ step through: what the list shows now (nothing when opened from the map). */
|
|
2325
|
+
const mdIds = () => modalFrom === "list" ? [...$("list").querySelectorAll(".swipe")].map((e) => Number(e.dataset.id)) : [];
|
|
2326
|
+
const mediaOf = (i) => (Array.isArray(i.media) ? i.media : []).filter((m) => m && typeof m.src === "string" && m.src.startsWith("/"));
|
|
2327
|
+
function galleryHtml(i) {
|
|
2328
|
+
const m = mediaOf(i), t = T(), name = i.summary?.name ?? i.title;
|
|
2329
|
+
if (!m.length) return "";
|
|
2330
|
+
const url = safeUrl(i.summary?.primaryUrl || i.url);
|
|
2331
|
+
const img = (x, extra = "") => `<img src="${esc(x.src)}" alt="${esc(extra === "t" ? "" : x.alt || name)}" referrerpolicy="no-referrer" loading="lazy" decoding="async" draggable="false" data-media>`;
|
|
2332
|
+
const slide = (x, n) => `<div class="g-slide" role="group" aria-roledescription="slide" aria-label="${esc(t.mdSlide(n + 1, m.length))}">${
|
|
2333
|
+
x.kind === "video" ? `<a href="${esc(url)}" target="_blank" rel="noopener noreferrer" aria-label="${esc(t.mdPlay)}">${img(x)}<span class="play" aria-hidden="true">▶</span></a>` : img(x)}</div>`;
|
|
2334
|
+
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>${
|
|
2335
|
+
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>`;
|
|
2336
|
+
}
|
|
2337
|
+
function paintModal() {
|
|
2338
|
+
const i = find(modalId);
|
|
2339
|
+
if (!i) return void (mdlDlg.open && mdlDlg.close());
|
|
2340
|
+
const t = T(), s = i.summary, admin = role === "admin", inTrash = state.view === "trash";
|
|
2341
|
+
const url = safeUrl(s?.primaryUrl || i.url), name = s?.name ?? i.title;
|
|
2342
|
+
const ids = mdIds(), at = ids.indexOf(i.id);
|
|
2343
|
+
$("md-pos").textContent = at >= 0 ? t.mdPos(at + 1, ids.length) : "";
|
|
2344
|
+
for (const [id, label, off] of [["md-prev", t.mdPrev, at <= 0], ["md-next", t.mdNext, at < 0 || at >= ids.length - 1]]) {
|
|
2345
|
+
const b = $(id); b.innerHTML = ic("chev"); b.setAttribute("aria-label", label); b.title = label; b.hidden = at < 0; b.disabled = off;
|
|
2346
|
+
}
|
|
2347
|
+
$("md-close").setAttribute("aria-label", t.close); $("md-close").title = t.close;
|
|
2348
|
+
const list = (arr) => `<ul>${arr.map((x) => `<li>${esc(x)}</li>`).join("")}</ul>`;
|
|
2349
|
+
const sec = (cls, title, body) => body ? `<section class="md-sec ${cls}"><h4>${esc(title)}</h4>${body}</section>` : "";
|
|
2350
|
+
const why = [s?.why ? `<p>${esc(s.why)}</p>` : "",
|
|
2351
|
+
...(i.said ?? []).map((x) => `<div class="said">${ic("chat")}<span>${esc(x)}</span></div>`),
|
|
2352
|
+
i.note ? `<div class="mynote">${ic("note")}<span>${esc(i.note)}</span></div>` : ""].join("");
|
|
2353
|
+
$("md-scroll").innerHTML = `${galleryHtml(i)}
|
|
2354
|
+
<h3 id="md-title"><a href="${esc(url)}" target="_blank" rel="noopener noreferrer">${esc(name)}</a></h3>
|
|
2355
|
+
<p class="md-sub"><span class="badge folder" style="--c:${folderColor(i.category)}">${esc(folderPath(i.category))}</span>
|
|
2356
|
+
<span class="rating ${i.worth === "must-see" ? "must" : ""}">${i.worth === "must-see" ? ic("star") : ""}${esc(t.worth[i.worth] ?? i.worth)}</span>
|
|
2357
|
+
<span>#${i.id} · ${esc(t.kind1?.[i.kind] ?? t.kinds[i.kind] ?? i.kind)}</span></p>
|
|
2358
|
+
${s?.oneLiner ? `<p class="md-one">${esc(s.oneLiner)}</p>` : ""}
|
|
2359
|
+
${sec("demo", t.mdDemo, s?.demo ? `<p>${esc(s.demo)}</p>` : "")}
|
|
2360
|
+
${sec("why", t.mdWhy, why)}
|
|
2361
|
+
${sec("hl", t.mdHighlights, s?.highlights?.length ? list(s.highlights) : "")}
|
|
2362
|
+
${sec("uc", t.mdUse, s?.useCases?.length ? list(s.useCases) : "")}
|
|
2363
|
+
${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>` : "")}
|
|
2364
|
+
${sec("tags", t.mdTags, s?.tags?.length ? `<div class="md-tags tags">${s.tags.map((x) => `<span class="tag">#${esc(x)}</span>`).join(" ")}</div>` : "")}
|
|
2365
|
+
${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>` : ""}
|
|
2366
|
+
${i.flags?.length ? `<div class="flag">⚠ ${esc(i.flags.map((f) => t.flags[f] ?? f).join(", "))}</div>` : ""}
|
|
2367
|
+
<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>`;
|
|
2368
|
+
const busy = refreshing.has(i.id);
|
|
2369
|
+
const btn = (act, icon, label, extra = "") => `<button class="btn ${extra}" type="button" data-md="${act}">${ic(icon)} ${esc(label)}</button>`;
|
|
2370
|
+
$("md-actions").innerHTML = `<a class="btn primary" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${ic("link")} ${esc(t.openLink)}</a>` +
|
|
2371
|
+
(admin ? (inTrash ? btn("restore", "undo", t.restore)
|
|
2372
|
+
: btn("favorite", "star", i.favorite ? t.unfavorite : t.favorite, i.favorite ? "on" : "") + btn("move", "move", t.moveTo) +
|
|
2373
|
+
`<button class="btn ${busy ? "spin" : ""}" type="button" data-md="refresh" ${busy ? "disabled" : ""}>${ic("refresh")} ${esc(t.refresh)}</button>` +
|
|
2374
|
+
btn("note", "note", i.note ? t.editNote : t.addNote) + `<span class="spacer"></span>` + btn("trash", "trash", t.remove, "danger")) : "") +
|
|
2375
|
+
(modalFrom === "map" ? btn("list", "list", t.showInList) : "");
|
|
2376
|
+
}
|
|
2377
|
+
function openModal(id, from = "list") {
|
|
2378
|
+
if (!find(id)) return;
|
|
2379
|
+
const wasOpen = mdlDlg.open;
|
|
2380
|
+
modalId = id; modalFrom = from;
|
|
2381
|
+
paintModal();
|
|
2382
|
+
if (!wasOpen) mdlDlg.showModal();
|
|
2383
|
+
$("md-scroll").scrollTop = 0;
|
|
2384
|
+
mdlDlg.style.transform = "";
|
|
2385
|
+
history.replaceState(null, "", `${location.pathname}${location.search}#item-${id}`);
|
|
2386
|
+
}
|
|
2387
|
+
/** Step to the previous / next card in the list the modal came from. */
|
|
2388
|
+
function stepModal(d) {
|
|
2389
|
+
const ids = mdIds(), at = ids.indexOf(modalId), to = ids[at + d];
|
|
2390
|
+
if (at < 0 || to == null) return;
|
|
2391
|
+
openModal(to, modalFrom);
|
|
2392
|
+
}
|
|
2393
|
+
mdlDlg.addEventListener("close", () => {
|
|
2394
|
+
if (mdlDlg.open) return; // reopened (a link, a hash) before this queued event ran
|
|
2395
|
+
const id = modalId, from = modalFrom;
|
|
2396
|
+
// Only this card's own hash: a late close event must not wipe the link of a card opened since.
|
|
2397
|
+
if (!keepHash && location.hash === `#item-${id}`) history.replaceState(null, "", location.pathname + location.search);
|
|
2398
|
+
keepHash = false;
|
|
2399
|
+
mdlDlg.style.transform = "";
|
|
2400
|
+
// Focus goes back to the card you ended on (the one you opened, or the last one you stepped to).
|
|
2401
|
+
setTimeout(() => {
|
|
2402
|
+
const c = from === "list" && !document.querySelector("dialog[open]") ? document.querySelector(`#item-${id} .card`) : null;
|
|
2403
|
+
if (c) { c.focus({ preventScroll: true }); c.scrollIntoView({ block: "nearest" }); }
|
|
2404
|
+
}, 0);
|
|
2405
|
+
});
|
|
2406
|
+
mdlDlg.addEventListener("click", async (e) => {
|
|
2407
|
+
if (e.target === mdlDlg) return mdlDlg.close(); // the backdrop
|
|
2408
|
+
const open = e.target.closest("a[data-open]");
|
|
2409
|
+
if (open) { e.preventDefault(); const to = Number(open.dataset.open); if (find(to)) openModal(to, modalFrom); else { mdlDlg.close(); jumpTo(to); } return; }
|
|
2410
|
+
const g = e.target.closest("[data-g]");
|
|
2411
|
+
if (g) { const tr = $("g-track"); tr.scrollTo({ left: Number(g.dataset.g) * tr.clientWidth, behavior: matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth" }); return; }
|
|
2412
|
+
const b = e.target.closest("[data-md]");
|
|
2413
|
+
if (!b || b.disabled) return;
|
|
2414
|
+
const id = modalId, item = find(id), el = document.getElementById(`item-${id}`), act1 = b.dataset.md;
|
|
2415
|
+
if (act1 === "close") return mdlDlg.close();
|
|
2416
|
+
if (act1 === "prev") return stepModal(-1);
|
|
2417
|
+
if (act1 === "next") return stepModal(1);
|
|
2418
|
+
if (act1 === "copy") {
|
|
2419
|
+
await navigator.clipboard?.writeText(item?.summary?.tryIt ?? "").catch(() => {});
|
|
2420
|
+
b.textContent = T().mdCopied; setTimeout(() => { if (b.isConnected) b.textContent = T().mdCopy; }, 1500);
|
|
2421
|
+
return;
|
|
2422
|
+
}
|
|
2423
|
+
if (!item) return;
|
|
2424
|
+
if (act1 === "list") {
|
|
2425
|
+
keepHash = true; mdlDlg.close();
|
|
2426
|
+
Object.assign(state, { view: "all", category: "", kind: "" });
|
|
2427
|
+
history.replaceState(null, "", `#item-${id}`);
|
|
2428
|
+
return load();
|
|
2429
|
+
}
|
|
2430
|
+
if (act1 === "move") { mdlDlg.close(); return openMovePicker(id); }
|
|
2431
|
+
if (act1 === "refresh") return refreshItem(id);
|
|
2432
|
+
if (act1 === "note") return openItemNote(id);
|
|
2433
|
+
if (act1 === "favorite") {
|
|
2434
|
+
if (el) await run(el, "favorite");
|
|
2435
|
+
else { const on = !item.favorite; if (await act(id, on ? "favorite" : "unfavorite")) { item.favorite = on; refreshCounts(); if (mapShown()) drawMap(); } }
|
|
2436
|
+
return paintModal();
|
|
2437
|
+
}
|
|
2438
|
+
if (act1 === "trash" || act1 === "restore") {
|
|
2439
|
+
mdlDlg.close();
|
|
2440
|
+
if (el) return run(el, act1);
|
|
2441
|
+
if (!(await act(id, act1))) return;
|
|
2442
|
+
toast(act1 === "trash" ? T().removed(nameOf(item)) : T().restored(nameOf(item)), async () => { await act(id, act1 === "trash" ? "restore" : "trash"); load(); });
|
|
2443
|
+
return load();
|
|
2444
|
+
}
|
|
2445
|
+
});
|
|
2446
|
+
// ←/→ step through the list; the gallery follows its scroll position.
|
|
2447
|
+
addEventListener("keydown", (e) => {
|
|
2448
|
+
if (e.metaKey || e.ctrlKey || e.altKey || e.shiftKey || !mdlDlg.open || !["ArrowLeft", "ArrowRight", "Escape"].includes(e.key)) return;
|
|
2449
|
+
if (document.querySelectorAll("dialog[open]").length > 1) return; // a picker or note on top keeps its own keys
|
|
2450
|
+
e.preventDefault();
|
|
2451
|
+
if (e.key === "Escape") mdlDlg.close(); else stepModal(e.key === "ArrowLeft" ? -1 : 1);
|
|
2452
|
+
});
|
|
2453
|
+
mdlDlg.addEventListener("scroll", (e) => {
|
|
2454
|
+
const tr = e.target;
|
|
2455
|
+
if (tr?.id !== "g-track") return;
|
|
2456
|
+
const n = Math.round(tr.scrollLeft / Math.max(1, tr.clientWidth));
|
|
2457
|
+
for (const b of mdlDlg.querySelectorAll(".g-th")) b.classList.toggle("on", Number(b.dataset.g) === n);
|
|
2458
|
+
}, true);
|
|
2459
|
+
// A phone: pull the sheet down from its top bar to close it.
|
|
2460
|
+
{
|
|
2461
|
+
let y0 = null, dy = 0;
|
|
2462
|
+
const grab = $("md-grab");
|
|
2463
|
+
grab.addEventListener("touchstart", (e) => { if (e.target.closest("button")) return; y0 = e.touches[0].clientY; dy = 0; mdlDlg.style.transition = "none"; }, { passive: true });
|
|
2464
|
+
grab.addEventListener("touchmove", (e) => { if (y0 == null) return; dy = Math.max(0, e.touches[0].clientY - y0); mdlDlg.style.transform = `translateY(${dy}px)`; }, { passive: true });
|
|
2465
|
+
const end = () => { if (y0 == null) return; y0 = null; mdlDlg.style.transition = ""; if (dy > 90) mdlDlg.close(); else mdlDlg.style.transform = ""; };
|
|
2466
|
+
grab.addEventListener("touchend", end); grab.addEventListener("touchcancel", end);
|
|
2467
|
+
}
|
|
2468
|
+
// A picture that fails to load (a dead link, a missing proxy file) is dropped rather than shown broken.
|
|
2469
|
+
document.addEventListener("error", (e) => {
|
|
2470
|
+
const img = e.target;
|
|
2471
|
+
if (img?.tagName !== "IMG" || !img.hasAttribute("data-media")) return;
|
|
2472
|
+
const th = img.closest(".thumb");
|
|
2473
|
+
if (th) return th.remove();
|
|
2474
|
+
const gal = img.closest(".gallery");
|
|
2475
|
+
if (!gal) return;
|
|
2476
|
+
const slides = [...gal.querySelectorAll(".g-slide")], btns = [...gal.querySelectorAll(".g-th")];
|
|
2477
|
+
const n = img.closest(".g-th") ? btns.indexOf(img.closest(".g-th")) : slides.indexOf(img.closest(".g-slide"));
|
|
2478
|
+
slides[n]?.remove(); btns[n]?.remove();
|
|
2479
|
+
if (!gal.querySelector(".g-slide")) return gal.remove();
|
|
2480
|
+
gal.querySelectorAll(".g-th").forEach((b, k) => { b.dataset.g = k; b.classList.toggle("on", k === 0); });
|
|
2481
|
+
if (gal.querySelectorAll(".g-th").length < 2) gal.querySelector(".g-thumbs")?.remove();
|
|
2482
|
+
}, true);
|
|
2483
|
+
// A GIF in the list shows one still frame until you point at the card (or open it): a list full of moving pictures is noise.
|
|
2484
|
+
document.addEventListener("load", (e) => {
|
|
2485
|
+
const img = e.target;
|
|
2486
|
+
if (img?.tagName !== "IMG" || !img.hasAttribute("data-gif") || img.dataset.anim) return;
|
|
2487
|
+
try {
|
|
2488
|
+
const c = document.createElement("canvas");
|
|
2489
|
+
c.width = img.naturalWidth; c.height = img.naturalHeight;
|
|
2490
|
+
c.getContext("2d").drawImage(img, 0, 0);
|
|
2491
|
+
const still = c.toDataURL("image/png");
|
|
2492
|
+
img.dataset.anim = img.src; img.src = still;
|
|
2493
|
+
} catch { /* leave it moving rather than blank */ }
|
|
2494
|
+
}, true);
|
|
2495
|
+
let hot = null;
|
|
2496
|
+
const playGif = (card, on) => { const im = card?.querySelector("img[data-gif]"); if (im?.dataset.anim) { if (on) { im.dataset.still ??= im.src; im.src = im.dataset.anim; } else if (im.dataset.still) im.src = im.dataset.still; } };
|
|
2497
|
+
$("list").addEventListener("mouseover", (e) => { const c = e.target.closest?.(".card"); if (c === hot) return; playGif(hot, false); hot = c; playGif(hot, true); });
|
|
2498
|
+
$("list").addEventListener("mouseleave", () => { playGif(hot, false); hot = null; });
|
|
2268
2499
|
|
|
2269
2500
|
async function mapWrite(path, method, body) {
|
|
2270
2501
|
const token = store.get("driftnet-token");
|
|
@@ -2376,6 +2607,8 @@
|
|
|
2376
2607
|
zh ? "只要 AI 會開網址就行,把這段貼進對話。唯讀。" : "Any AI that can open a link: paste this into the chat. Read-only.",
|
|
2377
2608
|
zh ? `讀一下 ${withKey(`${base}/llms.txt`)} ,這是我收藏的 AI 工具清單。幫我找適合「(你的需求)」的工具。`
|
|
2378
2609
|
: `Read ${withKey(`${base}/llms.txt`)} — it's my catalogue of AI tools. Find me one for: (your task).`),
|
|
2610
|
+
card("feed", st.feed, zh ? "RSS/Atom 訂閱源:最新 50 張卡片。給 RSS 閱讀器或 n8n、Zapier 用;加上 ?folder=資料夾代號 可只看一個資料夾。" : "RSS / Atom feed of the newest 50 cards, for feed readers, n8n or Zapier. Add ?folder=<folder-id> for one folder.",
|
|
2611
|
+
withKey(`${base}/feed.xml`)),
|
|
2379
2612
|
card("agents", "Hermes / OpenClaw / pi", zh ? "這些 agent 的 MCP 設定。把裡面的 <你的管理密碼> 換成真的密碼;有了它,agent 可以收錄、投票、幫忙讀佇列裡的連結。" : "MCP settings for these agents. Replace <your-admin-password> with the real one; with it they can save, vote and work the queue.",
|
|
2380
2613
|
JSON.stringify({ mcpServers: { driftnet: { type: "http", url: `${base}/mcp`, headers: { Authorization: `Bearer ${pw}` } } } }, null, 2), "Hermes"),
|
|
2381
2614
|
].join("");
|
|
@@ -2456,6 +2689,7 @@
|
|
|
2456
2689
|
item.note = saved.note;
|
|
2457
2690
|
const el = document.getElementById(`item-${noting}`);
|
|
2458
2691
|
if (el) { el.outerHTML = card(item); attachSwipe(document.getElementById(`item-${noting}`)); }
|
|
2692
|
+
if (modalId === noting && mdlDlg.open) paintModal();
|
|
2459
2693
|
setTimeout(restoreFocus, 0);
|
|
2460
2694
|
toast(T().saved);
|
|
2461
2695
|
};
|
|
@@ -2649,6 +2883,26 @@
|
|
|
2649
2883
|
else moveItem(id, to);
|
|
2650
2884
|
});
|
|
2651
2885
|
})();
|
|
2886
|
+
/** One-time chooser on a brand-new catalogue whose folders are still the untouched starter set. */
|
|
2887
|
+
const untouchedSeed = () => folders.length > 0 && folders.every((f) => f.builtin && !f.name && !f.parent);
|
|
2888
|
+
function templateChooser(t) {
|
|
2889
|
+
if (!untouchedSeed() || store.get("driftnet-template-seen")) return "";
|
|
2890
|
+
return `<div class="tpl"><small>${esc(t.tplTitle)}</small><div class="tpl-row">${[["ai", t.tplAi], ["research", t.tplResearch], ["everyday", t.tplEveryday]]
|
|
2891
|
+
.map(([k, l]) => `<button class="btn" type="button" data-template="${k}">${esc(l)}</button>`).join("")}</div></div>`;
|
|
2892
|
+
}
|
|
2893
|
+
async function pickTemplate(template) {
|
|
2894
|
+
store.set("driftnet-template-seen", "1");
|
|
2895
|
+
// "ai" is what is already there: nothing to replace.
|
|
2896
|
+
if (template !== "ai") {
|
|
2897
|
+
const token = store.get("driftnet-token");
|
|
2898
|
+
const res = await fetch("/api/folders/template", { method: "POST", headers: { "content-type": "application/json", ...(token ? { authorization: `Bearer ${token}` } : {}) },
|
|
2899
|
+
body: JSON.stringify({ template }) }).catch(() => null);
|
|
2900
|
+
if (res?.status === 401) return needAdmin();
|
|
2901
|
+
if (!res?.ok) toast(res?.status === 409 ? T().tplFailed : T().failed);
|
|
2902
|
+
}
|
|
2903
|
+
folders = await api("/api/folders").catch(() => folders);
|
|
2904
|
+
await load();
|
|
2905
|
+
}
|
|
2652
2906
|
async function renderCards() {
|
|
2653
2907
|
const p = new URLSearchParams({ limit: "300" });
|
|
2654
2908
|
if (prefs.sort !== "best") p.set("sort", prefs.sort);
|
|
@@ -2662,8 +2916,9 @@
|
|
|
2662
2916
|
: `<div class="empty first"><span>${esc(empty)}</span>${state.view === "all" && !state.q && !state.category && role === "admin"
|
|
2663
2917
|
? `<form class="add" id="add-form"><input id="add-url" type="url" inputmode="url" placeholder="${esc(t.addPlaceholder)}" aria-label="${esc(t.addPlaceholder)}">
|
|
2664
2918
|
<button class="btn primary" type="submit">${ic("plus")} ${esc(t.addLink)}</button></form>
|
|
2665
|
-
<button class="btn" type="button" data-connect-empty>${ic("plug")} ${esc(t.st.connect)}</button
|
|
2919
|
+
<button class="btn" type="button" data-connect-empty>${ic("plug")} ${esc(t.st.connect)}</button>${templateChooser(t)}` : ""}</div>`;
|
|
2666
2920
|
$("add-form")?.addEventListener("submit", addLink);
|
|
2921
|
+
for (const b of $("list").querySelectorAll("[data-template]")) b.addEventListener("click", () => pickTemplate(b.dataset.template));
|
|
2667
2922
|
$("list").querySelector("[data-connect-empty]")?.addEventListener("click", () => openConnect());
|
|
2668
2923
|
for (const el of $("list").querySelectorAll(".swipe")) attachSwipe(el);
|
|
2669
2924
|
syncSelection();
|
|
@@ -2676,8 +2931,10 @@
|
|
|
2676
2931
|
const top = target.getBoundingClientRect().top + scrollY - document.querySelector("header").offsetHeight - ($("crumb").offsetHeight || 0) - 12;
|
|
2677
2932
|
if (splitOn()) target.scrollIntoView({ block: "center" }); else scrollTo({ top });
|
|
2678
2933
|
target.classList.remove("flash"); void target.offsetWidth; target.classList.add("flash");
|
|
2934
|
+
if (hashOpen) { hashOpen = false; openModal(Number(location.hash.slice(6)), "list"); }
|
|
2679
2935
|
}
|
|
2680
2936
|
}
|
|
2937
|
+
if (mdlDlg.open) paintModal();
|
|
2681
2938
|
}
|
|
2682
2939
|
|
|
2683
2940
|
function card(i) {
|
|
@@ -2689,6 +2946,7 @@
|
|
|
2689
2946
|
? `<button class="tool" type="button" data-act="restore" title="${esc(t.restore)}" aria-label="${esc(t.restore)}">${ic("undo")}</button>`
|
|
2690
2947
|
: `<button class="tool grip" type="button" draggable="true" data-grip="${i.id}" title="${esc(t.dragHint)}" aria-hidden="true" tabindex="-1">${ic("grip")}</button>
|
|
2691
2948
|
<button class="tool" type="button" data-act="move" title="${esc(t.moveTo)}" aria-label="${esc(t.moveTo)}">${ic("move")}</button>
|
|
2949
|
+
<button class="tool ${refreshing.has(i.id) ? "spin" : ""}" type="button" data-act="refresh" title="${esc(t.refresh)}" aria-label="${esc(t.refresh)}" ${refreshing.has(i.id) ? "disabled" : ""}>${ic("refresh")}</button>
|
|
2692
2950
|
<button class="tool ${i.favorite ? "on" : ""}" type="button" data-act="favorite" aria-pressed="${i.favorite}"
|
|
2693
2951
|
title="${esc(i.favorite ? t.unfavorite : t.favorite)}" aria-label="${esc(i.favorite ? t.unfavorite : t.favorite)}">${ic("star")}</button>
|
|
2694
2952
|
<button class="tool" type="button" data-act="trash" title="${esc(t.remove)}" aria-label="${esc(t.remove)}">${ic("trash")}</button>`;
|
|
@@ -2696,30 +2954,39 @@
|
|
|
2696
2954
|
<div class="act right ${inTrash ? "restore" : ""}"><span>${ic(inTrash ? "undo" : "star", inTrash || i.favorite ? "" : "filled")} ${esc(inTrash ? t.swipeRestore : i.favorite ? t.swipeUnfav : t.swipeFav)}</span></div>
|
|
2697
2955
|
<div class="act left"><span>${inTrash ? "" : `${esc(t.swipeTrash)} ${ic("trash")}`}</span></div>
|
|
2698
2956
|
<article class="card" tabindex="0" aria-labelledby="name-${i.id}">
|
|
2699
|
-
<div class="
|
|
2700
|
-
|
|
2701
|
-
<
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2957
|
+
<div class="crow">
|
|
2958
|
+
${thumbHtml(i)}
|
|
2959
|
+
<div class="cbody">
|
|
2960
|
+
<div class="top">
|
|
2961
|
+
<a class="name" id="name-${i.id}" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${esc(s?.name ?? i.title)}</a>
|
|
2962
|
+
<span class="badge folder" style="--c:${folderColor(i.category)}">${esc(catLabel(i.category))}</span>
|
|
2963
|
+
<span class="rating ${i.worth === "must-see" ? "must" : ""}">${i.worth === "must-see" ? ic("star") : ""}${esc(t.worth[i.worth] ?? i.worth)}</span>
|
|
2964
|
+
${i.pending ? `<span class="rating">${esc(summaries ? t.pending : t.noModel)}</span>` : ""}
|
|
2965
|
+
</div>
|
|
2966
|
+
${s ? `<p>${esc(s.oneLiner)}</p>` : ""}
|
|
2967
|
+
${s?.demo ? `<p class="demo">${esc(s.demo)}</p>` : ""}
|
|
2968
|
+
${i.flags.length ? `<div class="flag">⚠ ${esc(i.flags.map((f) => t.flags[f] ?? f).join(", "))}</div>` : ""}
|
|
2969
|
+
${state.view === "inbox" ? inboxChips(i) : ""}
|
|
2970
|
+
<div class="meta">
|
|
2971
|
+
<span>#${i.id}</span><span>${esc(t.kind1?.[i.kind] ?? t.kinds[i.kind] ?? i.kind)}</span>${i.shareCount ? `<span>${esc(t.shared(i.shareCount))}</span>` : ""}
|
|
2972
|
+
<span>${esc(i.createdAt.slice(0, 10))}</span>
|
|
2973
|
+
${i.note ? `<span class="has-note" title="${esc(t.mdHasNote)}" role="img" aria-label="${esc(t.mdHasNote)}">${ic("note")}</span>` : ""}
|
|
2974
|
+
</div>
|
|
2975
|
+
</div>
|
|
2718
2976
|
</div>
|
|
2719
2977
|
<div class="tools">${tools}</div>
|
|
2720
2978
|
</article>
|
|
2721
2979
|
</div>`;
|
|
2722
2980
|
}
|
|
2981
|
+
/** The list thumbnail: the first picture, cropped; a card with none (or a broken one) simply has no box. */
|
|
2982
|
+
function thumbHtml(i) {
|
|
2983
|
+
const all = mediaOf(i), m = all[0];
|
|
2984
|
+
if (!m) return "";
|
|
2985
|
+
const gif = m.kind === "gif";
|
|
2986
|
+
return `<div class="thumb">
|
|
2987
|
+
<img src="${esc(m.src)}" alt="${esc(m.alt || i.summary?.name || i.title)}" referrerpolicy="no-referrer" loading="lazy" decoding="async" draggable="false" data-media ${gif ? "data-gif" : ""}>
|
|
2988
|
+
${m.kind === "video" ? `<span class="play" aria-hidden="true">▶</span>` : ""}${all.length > 1 ? `<span class="more-pics">+${all.length - 1}</span>` : ""}</div>`;
|
|
2989
|
+
}
|
|
2723
2990
|
|
|
2724
2991
|
/** Inbox: one-tap chips for the card's suggested folders (keys 1–3), and "other folder…" (m). */
|
|
2725
2992
|
function inboxChips(i) {
|
|
@@ -2795,6 +3062,36 @@
|
|
|
2795
3062
|
refreshCounts();
|
|
2796
3063
|
}
|
|
2797
3064
|
|
|
3065
|
+
/** Fetch a card's page again and redo its summary. The note, star, shares and a folder you chose stay. */
|
|
3066
|
+
const refreshing = new Set();
|
|
3067
|
+
function repaintItem(id) {
|
|
3068
|
+
const el = document.getElementById(`item-${id}`), item = find(id);
|
|
3069
|
+
if (el && item) { const focus = el.contains(document.activeElement); el.outerHTML = card(item); attachSwipe(document.getElementById(`item-${id}`)); if (focus) document.querySelector(`#item-${id} [data-act="refresh"]`)?.focus(); }
|
|
3070
|
+
if (mapShown()) drawMap();
|
|
3071
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
3072
|
+
}
|
|
3073
|
+
async function refreshItem(id) {
|
|
3074
|
+
const item = find(id);
|
|
3075
|
+
if (!item || refreshing.has(id)) return;
|
|
3076
|
+
const t = T();
|
|
3077
|
+
refreshing.add(id);
|
|
3078
|
+
repaintItem(id);
|
|
3079
|
+
try {
|
|
3080
|
+
const token = store.get("driftnet-token");
|
|
3081
|
+
const res = await fetch(`/api/items/${id}/refresh`, { method: "POST", headers: token ? { authorization: `Bearer ${token}` } : {} }).catch(() => null);
|
|
3082
|
+
if (res?.status === 401) return needAdmin();
|
|
3083
|
+
const data = await res?.json().catch(() => ({}));
|
|
3084
|
+
if (!res?.ok) return toast(res?.status === 429 ? t.refreshWait : res?.status === 409 ? t.refreshBusy : res ? t.refreshFailed(data?.error) : t.failed);
|
|
3085
|
+
Object.assign(item, data);
|
|
3086
|
+
toast(t.refreshed(nameOf(item)));
|
|
3087
|
+
} finally {
|
|
3088
|
+
refreshing.delete(id);
|
|
3089
|
+
repaintItem(id);
|
|
3090
|
+
if (modalId === id && mdlDlg.open) paintModal();
|
|
3091
|
+
refreshCounts();
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
|
|
2798
3095
|
async function refreshCounts() {
|
|
2799
3096
|
const stats = await api("/api/stats").catch(() => null);
|
|
2800
3097
|
if (!stats) return;
|
|
@@ -2895,11 +3192,16 @@
|
|
|
2895
3192
|
if (e.shiftKey) selectRange(Number(sw.dataset.id)); else toggleSelect(Number(sw.dataset.id));
|
|
2896
3193
|
return;
|
|
2897
3194
|
}
|
|
2898
|
-
const n = e.target.closest('.link-btn[data-act="note"]');
|
|
2899
|
-
if (n) return openItemNote(Number(n.closest(".swipe").dataset.id));
|
|
2900
3195
|
const b = e.target.closest(".tool");
|
|
2901
|
-
if (!b
|
|
3196
|
+
if (!b) {
|
|
3197
|
+
// The card body (not its name link, chips or buttons) opens the detail modal.
|
|
3198
|
+
const body = e.target.closest(".swipe .card");
|
|
3199
|
+
if (body && !e.target.closest("a, button, .chip, input, summary")) openModal(Number(body.closest(".swipe").dataset.id), "list");
|
|
3200
|
+
return;
|
|
3201
|
+
}
|
|
3202
|
+
if (b.dataset.grip) return;
|
|
2902
3203
|
if (b.dataset.act === "move") return openMovePicker(Number(b.closest(".swipe").dataset.id));
|
|
3204
|
+
if (b.dataset.act === "refresh") return refreshItem(Number(b.closest(".swipe").dataset.id));
|
|
2903
3205
|
run(b.closest(".swipe"), b.dataset.act);
|
|
2904
3206
|
});
|
|
2905
3207
|
$("list").addEventListener("dragstart", (e) => {
|
|
@@ -2910,6 +3212,8 @@
|
|
|
2910
3212
|
const cardEl = grip.closest(".card");
|
|
2911
3213
|
e.dataTransfer.setDragImage(cardEl, 24, 24);
|
|
2912
3214
|
});
|
|
3215
|
+
// A shared link (#item-<id>) opens that card's modal once the list is drawn.
|
|
3216
|
+
let hashOpen = /^#item-\d+$/.test(location.hash);
|
|
2913
3217
|
// A "found in" link to a card outside the current filter: show everything, then jump.
|
|
2914
3218
|
addEventListener("hashchange", () => {
|
|
2915
3219
|
if (location.hash.startsWith("#focus=")) {
|
|
@@ -2918,7 +3222,9 @@
|
|
|
2918
3222
|
else setMapFocus(id);
|
|
2919
3223
|
return;
|
|
2920
3224
|
}
|
|
2921
|
-
if (/^#item-\d+$/.test(location.hash)
|
|
3225
|
+
if (/^#item-\d+$/.test(location.hash)) {
|
|
3226
|
+
if (document.getElementById(location.hash.slice(1))) return openModal(Number(location.hash.slice(6)), "list");
|
|
3227
|
+
hashOpen = true;
|
|
2922
3228
|
Object.assign(state, { view: "all", category: "", kind: "", q: "" });
|
|
2923
3229
|
$("q").value = "";
|
|
2924
3230
|
load();
|
|
@@ -2949,7 +3255,8 @@
|
|
|
2949
3255
|
const limit = () => Math.min(140, el.offsetWidth * 0.32);
|
|
2950
3256
|
const inTrash = state.view === "trash";
|
|
2951
3257
|
cardEl.addEventListener("pointerdown", (e) => {
|
|
2952
|
-
|
|
3258
|
+
// The name is a link and a natural place for a thumb: a swipe may start on it (the click after a drag is swallowed below).
|
|
3259
|
+
if (e.button !== 0 || e.target.closest("button, a:not(.name)")) return;
|
|
2953
3260
|
x0 = e.clientX; y0 = e.clientY; dx = 0; active = true; horizontal = null;
|
|
2954
3261
|
});
|
|
2955
3262
|
cardEl.addEventListener("pointermove", (e) => {
|
|
@@ -3243,6 +3550,8 @@
|
|
|
3243
3550
|
}
|
|
3244
3551
|
// Once the toast is gone, z no longer undoes something you can't see any more.
|
|
3245
3552
|
function hideToast() { $("toast").classList.remove("show"); lastUndo = null; }
|
|
3553
|
+
/** z undoes only what the toast still shows. */
|
|
3554
|
+
const canUndo = () => !!lastUndo && $("toast").classList.contains("show");
|
|
3246
3555
|
let toastMs = 5000;
|
|
3247
3556
|
// Reading or reaching for Undo keeps the toast up.
|
|
3248
3557
|
for (const ev of ["pointerenter", "focusin"]) $("toast").addEventListener(ev, () => clearTimeout(toastTimer));
|
|
@@ -3254,7 +3563,7 @@
|
|
|
3254
3563
|
// ── Keyboard: j/k to step through cards, then act on the focused one ─────
|
|
3255
3564
|
let lastKey = "";
|
|
3256
3565
|
addEventListener("keydown", (e) => {
|
|
3257
|
-
if ((e.metaKey || e.ctrlKey) && e.key === "z" &&
|
|
3566
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "z" && canUndo() && !/^(INPUT|TEXTAREA)$/.test(document.activeElement?.tagName ?? "")) { e.preventDefault(); $("toast-undo").click(); return; }
|
|
3258
3567
|
if (e.metaKey || e.ctrlKey || e.altKey || document.querySelector("dialog[open]")) return;
|
|
3259
3568
|
if (/^(INPUT|TEXTAREA|SELECT)$/.test(document.activeElement?.tagName ?? "")) return;
|
|
3260
3569
|
const k = e.key, prev = lastKey;
|
|
@@ -3262,7 +3571,7 @@
|
|
|
3262
3571
|
if (k === "Escape" && selected.size) { clearSelection(); return; }
|
|
3263
3572
|
if ((k === "Escape" || k === "Backspace") && mapShown() && mapFocus && !picked && !document.body.classList.contains("menu-open")) { e.preventDefault(); mapUp(); return; }
|
|
3264
3573
|
if (k === "/") { e.preventDefault(); $("q").focus(); return; }
|
|
3265
|
-
if ((k === "z" || k === "u") &&
|
|
3574
|
+
if ((k === "z" || k === "u") && canUndo()) { e.preventDefault(); $("toast-undo").click(); return; }
|
|
3266
3575
|
if (k === "?") { openKeys(); return; }
|
|
3267
3576
|
// Inbox: 1–3 pick the focused card's suggestion chips (before the global "file into top-9 folders").
|
|
3268
3577
|
if (state.view === "inbox" && /^[1-3]$/.test(k) && role === "admin" && focusedId() && !selected.size) {
|
|
@@ -3283,6 +3592,8 @@
|
|
|
3283
3592
|
next.focus(); next.scrollIntoView({ block: "nearest" });
|
|
3284
3593
|
return;
|
|
3285
3594
|
}
|
|
3595
|
+
// Enter or o on a focused card opens its detail modal.
|
|
3596
|
+
if ((k === "Enter" || k === "o") && cur && document.activeElement === cur) { e.preventDefault(); openModal(Number(cur.closest(".swipe").dataset.id), "list"); return; }
|
|
3286
3597
|
if (!cur || role !== "admin") return;
|
|
3287
3598
|
const swipe = cur.closest(".swipe");
|
|
3288
3599
|
if (!["f", "#", "Delete", "m", "n"].includes(k)) return;
|