adding-bookmarks
created pr with
77.1
pr_reviewed
cmds
checkout latest patchset:
ssh pr.pico.sh print 77 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 77.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 77
Patchset
77.2
add bookmarks
Benjamin Pollack
2025-08-24T17:32:57ZSemantic diff summary
2 added,
2 modified,
0 signature changed,
0 removed
across 2 analyzed files
(2 files skipped: unsupported file type)
+2
-0
commands.ts
#
+4
-1
deno.jsonc
#
| ... | ... | @@ -1,9 +1,11 @@ | |
| 1 | 1 | { | |
| 2 | 2 | "imports": { | |
| 3 | + | "@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@^0.1.56", | |
| 3 | 4 | "@cliffy/ansi": "jsr:@cliffy/ansi@^1.0.0-rc.8", | |
| 4 | 5 | "@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.8", | |
| 5 | 6 | "@david/dax": "jsr:@david/dax@^0.43.2", | |
| 6 | 7 | "@littletof/charmd": "jsr:@littletof/charmd@^0.1.2", | |
| 8 | + | "@mozilla/readability": "npm:@mozilla/readability@^0.6.0", | |
| 7 | 9 | "@std/assert": "jsr:@std/assert@^1.0.14", | |
| 8 | 10 | "@std/collections": "jsr:@std/collections@^1.1.3", | |
| 9 | 11 | "@std/datetime": "jsr:@std/datetime@^0.225.5", |
| ... | ... | @@ -14,7 +16,8 @@ | |
| 14 | 16 | "@std/path": "jsr:@std/path@^1.1.2", | |
| 15 | 17 | "@std/text": "jsr:@std/text@^1.0.16", | |
| 16 | 18 | "@std/ulid": "jsr:@std/ulid@^1.0.0", | |
| 17 | - | "marked": "npm:marked@^16.2.0" | |
| 19 | + | "marked": "npm:marked@^16.2.0", | |
| 20 | + | "turndown": "npm:turndown@^7.2.1" | |
| 18 | 21 | }, | |
| 19 | 22 | "tasks": { | |
| 20 | 23 | "install": "deno install -g -f -n hsh -c deno.jsonc -A main.ts" |
+38
-3
deno.lock
#
| ... | ... | @@ -10,11 +11,13 @@ | |
| 10 | 11 | "jsr:@david/dax@~0.43.2": "0.43.2", | |
| 11 | 12 | "jsr:@david/path@0.2": "0.2.0", | |
| 12 | 13 | "jsr:@david/which@~0.4.1": "0.4.1", | |
| 14 | + | "jsr:@denosaurs/plug@1.1.0": "1.1.0", | |
| 13 | 15 | "jsr:@littletof/charmd@~0.1.2": "0.1.2", | |
| 14 | 16 | "jsr:@std/assert@^1.0.14": "1.0.14", | |
| 15 | 17 | "jsr:@std/bytes@^1.0.5": "1.0.6", | |
| 16 | 18 | "jsr:@std/collections@^1.1.3": "1.1.3", | |
| 17 | 19 | "jsr:@std/datetime@~0.225.5": "0.225.5", | |
| 20 | + | "jsr:@std/encoding@1": "1.0.10", | |
| 18 | 21 | "jsr:@std/encoding@~1.0.5": "1.0.10", | |
| 19 | 22 | "jsr:@std/fmt@0.223.0": "0.223.0", | |
| 20 | 23 | "jsr:@std/fmt@1": "1.0.8", |
| ... | ... | @@ -36,14 +39,22 @@ | |
| 36 | 39 | "jsr:@std/toml@^1.0.3": "1.0.9", | |
| 37 | 40 | "jsr:@std/ulid@1": "1.0.0", | |
| 38 | 41 | "jsr:@std/yaml@^1.0.5": "1.0.9", | |
| 39 | - | "npm:marked@^16.2.0": "16.2.0" | |
| 42 | + | "npm:@mozilla/readability@0.6": "0.6.0", | |
| 43 | + | "npm:marked@^16.2.0": "16.2.0", | |
| 44 | + | "npm:turndown@^7.2.1": "7.2.1" | |
| 40 | 45 | }, | |
| 41 | 46 | "jsr": { | |
| 47 | + | "@b-fuze/deno-dom@0.1.56": { | |
| 48 | + | "integrity": "8030e2dc1d8750f1682b53462ab893d9c3470f2287feecbe22f44a88c54ab148", | |
| 49 | + | "dependencies": [ | |
| 50 | + | "jsr:@denosaurs/plug" | |
| 51 | + | ] | |
| 52 | + | }, | |
| 42 | 53 | "@cliffy/ansi@1.0.0-rc.8": { | |
| 43 | 54 | "integrity": "ba37f10ce55bbfbdd8ddd987f91f029b17bce88385b98ba3058870f3b007b80c", | |
| 44 | 55 | "dependencies": [ | |
| 45 | 56 | "jsr:@cliffy/internal", | |
| 46 | - | "jsr:@std/encoding", | |
| 57 | + | "jsr:@std/encoding@~1.0.5", | |
| 47 | 58 | "jsr:@std/fmt@~1.0.2" | |
| 48 | 59 | ] | |
| 49 | 60 | }, |
| ... | ... | @@ -97,6 +108,15 @@ | |
| 97 | 108 | "@david/which@0.4.1": { | |
| 98 | 109 | "integrity": "896a682b111f92ab866cc70c5b4afab2f5899d2f9bde31ed00203b9c250f225e" | |
| 99 | 110 | }, | |
| 111 | + | "@denosaurs/plug@1.1.0": { | |
| 112 | + | "integrity": "eb2f0b7546c7bca2000d8b0282c54d50d91cf6d75cb26a80df25a6de8c4bc044", | |
| 113 | + | "dependencies": [ | |
| 114 | + | "jsr:@std/encoding@1", | |
| 115 | + | "jsr:@std/fmt@1", | |
| 116 | + | "jsr:@std/fs@1", | |
| 117 | + | "jsr:@std/path@1" | |
| 118 | + | ] | |
| 119 | + | }, | |
| 100 | 120 | "@littletof/charmd@0.1.2": { | |
| 101 | 121 | "integrity": "1d349b5a4acb3d9fe054e5c856ee8a5c0f18bbdccf1f0d733b6e73d518514928", | |
| 102 | 122 | "dependencies": [ |
| ... | ... | @@ -185,13 +205,26 @@ | |
| 185 | 205 | } | |
| 186 | 206 | }, | |
| 187 | 207 | "npm": { | |
| 208 | + | "@mixmark-io/domino@2.2.0": { | |
| 209 | + | "integrity": "sha512-Y28PR25bHXUg88kCV7nivXrP2Nj2RueZ3/l/jdx6J9f8J4nsEGcgX0Qe6lt7Pa+J79+kPiJU3LguR6O/6zrLOw==" | |
| 210 | + | }, | |
| 211 | + | "@mozilla/readability@0.6.0": { | |
| 212 | + | "integrity": "sha512-juG5VWh4qAivzTAeMzvY9xs9HY5rAcr2E4I7tiSSCokRFi7XIZCAu92ZkSTsIj1OPceCifL3cpfteP3pDT9/QQ==" | |
| 213 | + | }, | |
| 188 | 214 | "marked@16.2.0": { | |
| 189 | 215 | "integrity": "sha512-LbbTuye+0dWRz2TS9KJ7wsnD4KAtpj0MVkWc90XvBa6AslXsT0hTBVH5k32pcSyHH1fst9XEFJunXHktVy0zlg==", | |
| 190 | 216 | "bin": true | |
| 217 | + | }, | |
| 218 | + | "turndown@7.2.1": { | |
| 219 | + | "integrity": "sha512-7YiPJw6rLClQL3oUKN3KgMaXeJJ2lAyZItclgKDurqnH61so4k4IH/qwmMva0zpuJc/FhRExBBnk7EbeFANlgQ==", | |
| 220 | + | "dependencies": [ | |
| 221 | + | "@mixmark-io/domino" | |
| 222 | + | ] | |
| 191 | 223 | } | |
| 192 | 224 | }, | |
| 193 | 225 | "workspace": { | |
| 194 | 226 | "dependencies": [ | |
| 227 | + | "jsr:@b-fuze/deno-dom@~0.1.56", | |
| 195 | 228 | "jsr:@cliffy/ansi@^1.0.0-rc.8", | |
| 196 | 229 | "jsr:@cliffy/command@^1.0.0-rc.8", | |
| 197 | 230 | "jsr:@david/dax@~0.43.2", |
+29
-0
plugins/bookmarks.ts
#
| ... | ... | @@ -0,0 +1,29 @@ | |
| 1 | + | import { Command } from "@cliffy/command"; | |
| 2 | + | import { Readability } from "@mozilla/readability"; | |
| 3 | + | import { DOMParser } from "@b-fuze/deno-dom"; | |
| 4 | + | import TurndownService from "turndown"; | |
| 5 | + | ||
| 6 | + | import { currentNotebook, getNotebooks, iconForEntry } from "../notebooks.ts"; | |
| 7 | + | import { print } from "../utils.ts"; | |
| 8 | + | ||
| 9 | + | function addCommands(cmd: Command) { | |
| 10 | + | cmd | |
| 11 | + | .command("bookmark", getBookmarkCommands().alias("bm")); | |
| 12 | + | } | |
| 13 | + | ||
| 14 | + | function getBookmarkCommands() { | |
| 15 | + | return new Command() | |
| 16 | + | .command("add", "add a bookmark") | |
| 17 | + | .description("manage bookmarks") | |
| 18 | + | .arguments("<url:string>") | |
| 19 | + | .action(async (_opts, url) => { | |
| 20 | + | const content = await (await fetch(url)).text(); | |
| 21 | + | const dom = new DOMParser().parseFromString(content, "text/html"); | |
| 22 | + | const readable = new Readability(dom); | |
| 23 | + | const parsed = readable.parse(); | |
| 24 | + | if (parsed == null) throw new Error("nope"); | |
| 25 | + | const md = new TurndownService().turndown(parsed.content); | |
| 26 | + | }); | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | export default { addCommands }; |