hushdrop-mcp 0.3.3 → 0.4.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/README.md +25 -27
- package/SKILL.md +173 -5
- package/brand/badge.html +2 -2
- package/brand/download-page.html +1 -1
- package/brand/gate.html +1 -1
- package/comment-widget.mjs +23 -0
- package/drop.mjs +1062 -59
- package/mcp.mjs +689 -8
- package/package.json +6 -2
- package/protect.mjs +26 -0
- package/read-beacon.mjs +17 -0
- package/site.mjs +60 -0
package/README.md
CHANGED
|
@@ -1,41 +1,39 @@
|
|
|
1
1
|
# hushdrop-mcp
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
**Turn anything your AI agent builds into a password-locked link.** Reports, dashboards, prototypes,
|
|
4
|
+
Markdown or files. Your agent publishes them as a page the other person opens in a browser, and you can
|
|
5
|
+
update it in place and see whether it was opened.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Site and docs: **[hushdrop.dev](https://hushdrop.dev)** · Source: [github.com/maxtechera/hushdrop](https://github.com/maxtechera/hushdrop)
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Fastest way in: no install
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
# or one-line installer:
|
|
14
|
-
curl -fsSL https://hushdrop.dev/install.sh | sh
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Use
|
|
11
|
+
Using Claude or ChatGPT in the browser or desktop app? Add the hosted connector in one click at
|
|
12
|
+
**[hushdrop.dev](https://hushdrop.dev)**. Its URL is `https://hushdrop.dev/mcp`, and you sign in once.
|
|
18
13
|
|
|
19
|
-
|
|
20
|
-
hush report.html # just works — anonymous managed link, no setup or account (auto-expires 24h)
|
|
21
|
-
hush login # free account → persistent links on your own handle
|
|
22
|
-
hush deploy --domain you.com # self-host → your own domain (after a Blob token)
|
|
23
|
-
drop notes.md # markdown → branded HTML
|
|
24
|
-
drop site.zip # multi-file static site
|
|
25
|
-
hush list | rm <slug> | gc # manage drops
|
|
26
|
-
```
|
|
14
|
+
## Local MCP server (Claude Code, Cursor, Codex, VS Code, Windsurf, Zed)
|
|
27
15
|
|
|
28
|
-
|
|
16
|
+
Add this to your agent's MCP config:
|
|
29
17
|
|
|
30
|
-
```
|
|
31
|
-
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"mcpServers": {
|
|
21
|
+
"hushdrop": { "command": "npx", "args": ["-y", "hushdrop-mcp"] }
|
|
22
|
+
}
|
|
23
|
+
}
|
|
32
24
|
```
|
|
33
25
|
|
|
34
|
-
|
|
26
|
+
Then ask your agent: *"share this as a private link"*.
|
|
27
|
+
|
|
28
|
+
- **No account needed for the first drop.** You get a locked link right away. Without an account it
|
|
29
|
+
stops working after 24 hours.
|
|
30
|
+
- **Keep your links:** ask the agent to sign you in (free). It shows you a link to approve, and from then
|
|
31
|
+
on your pages live at `hushdrop.dev/<you>/...` with version history and rollback.
|
|
32
|
+
- Pages are encrypted on your machine before upload, so the stored copy is unreadable without the password.
|
|
35
33
|
|
|
36
|
-
##
|
|
34
|
+
## Tools
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
`publish_html`, `publish_file`, `update_site`, `list_sites`, `delete_site`, `set_password`,
|
|
37
|
+
`set_expiry`, `login` / `finish_login`, plus versions, rollback and per-page editors once you're signed in.
|
|
40
38
|
|
|
41
39
|
MIT © [Max Techera](https://maxtechera.dev)
|
package/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: hushdrop
|
|
3
|
-
description: "
|
|
3
|
+
description: "Turn anything Claude made into a private, password-locked share link: Claude artifacts (claude.ai/artifact links), HTML pages, Markdown, PDFs, files, whole sites. Use it right away, without asking first, whenever the user wants something Claude made to reach another person or leave the chat: 'send this', 'share this', 'send it to Ana', 'get this to the client', 'give me a link', 'shareable link', 'publish this', 'drop this', 'can my team see this', 'post it in Slack/WhatsApp', or sharing an artifact link. After building an HTML page the user will likely pass on, offer a link in one line. Skip it when 'this' is an email, chat message, PR or code change that goes out through its own channel, or the user only wants to view the page themselves. Locked by default (AES-256 in the browser); returns URL + password."
|
|
4
4
|
user-invocable: true
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -12,9 +12,49 @@ deploy-per-file — it's object storage (Vercel Blob) behind a one-line edge pro
|
|
|
12
12
|
|
|
13
13
|
## When to use
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Publish as soon as the user signals that something Claude made should reach someone else or leave the
|
|
16
|
+
chat. Phrases like "send this", "share this", "send it to Ana", "get this to the client", "give me a
|
|
17
|
+
link" or "post it in Slack" are the go-ahead: publish first, then hand back the link. Don't stop to ask
|
|
18
|
+
whether they want a link.
|
|
19
|
+
|
|
20
|
+
- **"this" = the most recent thing Claude made** in the conversation: an artifact, an HTML page, a
|
|
21
|
+
report, a Markdown doc. If two things fit equally, publish the newest and name it in the reply.
|
|
22
|
+
- **Offer, don't publish,** when you've just built an HTML page the user is likely to pass on but
|
|
23
|
+
hasn't asked to share it yet: one line, "Want a private link to send? I can hushdrop it."
|
|
24
|
+
- **Not this skill** when "this" is an email, a chat message, a PR or a code change that goes out
|
|
25
|
+
through its own channel, or when the user only wants to open the page themselves (use the
|
|
26
|
+
Artifact tool or a local preview for that).
|
|
27
|
+
- **Never message anyone yourself.** Return the link and password; the user decides where they go.
|
|
28
|
+
|
|
29
|
+
## Sharing a Claude artifact
|
|
30
|
+
|
|
31
|
+
Claude artifacts (`claude.ai/artifact/...` or `claude.ai/code/artifact/...`) are private pages. `hush`
|
|
32
|
+
can't fetch them by URL; it refuses with a hint. Get the HTML onto disk, then hush the file:
|
|
33
|
+
|
|
34
|
+
1. **Published this session:** you still have the local `.html` you passed to the Artifact tool. Run
|
|
35
|
+
`hush <that file>`.
|
|
36
|
+
2. **Otherwise:** call the Artifact tool with `action: "read"` and the artifact URL. It saves the full
|
|
37
|
+
page as `.../tool-results/artifact-<id>-<version>.html`. Run `hush <that path>`.
|
|
38
|
+
|
|
39
|
+
`hush` detects the viewer skeleton the saved file is wrapped in, publishes only the page you wrote, and
|
|
40
|
+
names the drop after the page's `<title>` (so the slug reads `standup-shipped-nov-18-19-x7f2`, not
|
|
41
|
+
`artifact-b205a0bc-...`). Pass `-t`/`-s` to override.
|
|
42
|
+
|
|
43
|
+
Limits to tell the user about when they apply:
|
|
44
|
+
- An artifact **someone else owns** comes back from `read` as a summary, not HTML. Ask the owner, or
|
|
45
|
+
rebuild the page and hush that.
|
|
46
|
+
- **Multi-file artifacts** (extra `.js`/`.css`/images published through `files`): fetch each with
|
|
47
|
+
`read` + `paths`, put them beside the page in one folder, and `hush <folder>` (self-host only).
|
|
48
|
+
- Pages that call **`window.claude.*`** (shared state, Claude Q&A, uploads, live data) won't have that
|
|
49
|
+
runtime off claude.ai. Those parts stop working in the drop; say so.
|
|
50
|
+
|
|
51
|
+
### Reply shape
|
|
52
|
+
|
|
53
|
+
> Here's the link: https://hushdrop.dev/... password `opal-summit-95`. Send them together, or
|
|
54
|
+
> separately for anything sensitive.
|
|
55
|
+
|
|
56
|
+
Keep it locked (the default). Only use `--no-lock` when the user asks for a link that
|
|
57
|
+
opens without a password.
|
|
18
58
|
|
|
19
59
|
## Two ways to run
|
|
20
60
|
|
|
@@ -38,14 +78,136 @@ hush report.html --expire 7d # auto-expire (7d/24h/2w/date); enforce deletion
|
|
|
38
78
|
drop bundle.zip # raw file, unguessable URL → /bundle-x7f2k9.zip
|
|
39
79
|
drop file.pdf --page # generate a branded download page wrapping the file
|
|
40
80
|
drop file.pdf --page -p secret # password-protect that download page
|
|
81
|
+
hush ./dist # publish a whole static site (folder) → /slug/ (public)
|
|
82
|
+
hush ./dist -p secret # lock the entire site behind a password (self-host)
|
|
83
|
+
hush site.zip # same, from a zip
|
|
41
84
|
drop -s q3-deck deck.html # force the slug → /q3-deck
|
|
42
85
|
hush list # list live drops + their passwords
|
|
43
86
|
hush rm q3-deck # delete a drop
|
|
44
87
|
hush gc # delete drops whose --expire has passed (cron-friendly)
|
|
88
|
+
hush stats q3-deck --json # opened yet? views, people, first/last opened (hosted drops)
|
|
89
|
+
hush alerts every # email me on each new viewer (first open is on by default, free)
|
|
90
|
+
hush leads q3-deck on --fields name,company # ask for email (+fields, Pro) before it opens
|
|
91
|
+
hush recipients q3-deck --link "Ann at Acme" # Pro: named link, see if Ann opened it
|
|
92
|
+
hush webhook add https://x.com/hook --events drop.first_opened,lead.captured # Pro: signed callbacks
|
|
45
93
|
```
|
|
46
94
|
|
|
95
|
+
**Starting from a template:** for a client proposal, statement of work, pitch deck, weekly status
|
|
96
|
+
report, project handoff, quote, product spec, research brief, property listing or event RSVP, run
|
|
97
|
+
`hush template list --json`, then `hush template <id> -o page.html` (MCP: `get_template`). Replace every
|
|
98
|
+
`{{placeholder}}` with real content, leave no `{{` behind, and publish with `hush page.html`. Gallery: https://hushdrop.dev/templates
|
|
99
|
+
Teams keep their own starters: `hush template list --team <h>` and `hush template <id> --team <h> -o page.html`
|
|
100
|
+
(MCP: `get_template {team}`) before the built-in ones. Save a finished page for the team with
|
|
101
|
+
`hush template save page.html --team <h> --name <id> --title "..."` (editor or above, paid team).
|
|
102
|
+
|
|
103
|
+
**Publishing into a team:** before writing a page for a team (`--to <team>`), read
|
|
104
|
+
`hush rules --team <team>` (MCP: `page_rules {team}`) and follow the team's house style where it
|
|
105
|
+
differs from the general rules. Admins set it with `hush team style <team> style.md`.
|
|
106
|
+
|
|
107
|
+
**Pages that collect answers (Pro):** if you build a form, survey or RSVP page, publish it hosted,
|
|
108
|
+
run `hush data <slug> collect`, and have the page save with
|
|
109
|
+
`fetch("/api/data?drop=<handle>/<slug>", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(answers) })`.
|
|
110
|
+
Read answers with `hush data <slug> --json` (or `--csv`); `data.submitted` webhooks fire on each one.
|
|
111
|
+
|
|
112
|
+
**Pages that call an API (Pro):** never put an API key in a page. Run
|
|
113
|
+
`hush secret set OPENAI_KEY --base https://api.openai.com < key.txt`, then call
|
|
114
|
+
`fetch("/api/proxy?drop=<handle>/<slug>&secret=OPENAI_KEY&path=/v1/chat/completions", { method: "POST", headers: { "content-type": "application/json" }, body })`.
|
|
115
|
+
|
|
116
|
+
**Several drops for one client (Pro):** `hush portal create "Acme Corp"` once, then
|
|
117
|
+
`hush portal add "Acme Corp" <slug> --label "Q3 proposal"` after each publish. Send the client the
|
|
118
|
+
portal link, not each drop link.
|
|
119
|
+
|
|
120
|
+
**Feedback loop:** publish with `--comments` so viewers can pin comments on the page. When the
|
|
121
|
+
user says "address the feedback", run `hush comments <slug> --json`, edit the source at each
|
|
122
|
+
comment's `selector` / `snippet`, republish with `-s <slug>`, then `hush comments <slug> resolve all`.
|
|
123
|
+
|
|
124
|
+
**View-only (Pro):** `hush <file> --protect` (or `hush protect <slug>`, MCP `set_view_only`) blocks copy, save and
|
|
125
|
+
print, blurs the page in the background and watermarks it with the viewer's email when the drop collects emails
|
|
126
|
+
(`hush leads <slug> on` or `--email-gate`). Say it deters copying; it can't stop a phone camera.
|
|
127
|
+
|
|
128
|
+
**Before generating a page to share,** run `hush rules` (MCP: `page_rules`) once per session and
|
|
129
|
+
follow it: one file, no outside requests, phone-first, light/dark, printable.
|
|
130
|
+
|
|
131
|
+
When the user asks "did they open it?", "has anyone seen the link?" or "how many views", run
|
|
132
|
+
`hush stats <slug> --json` (MCP: `drop_stats`) and answer from `opened`, `last_viewed_at`, `views`.
|
|
133
|
+
|
|
47
134
|
**MCP server:** `node skill/mcp.mjs` exposes `publish_html`, `publish_file`, `update_site`,
|
|
48
|
-
`list_sites`, `delete_site`
|
|
135
|
+
`list_sites`, `delete_site`, `list_versions`, `rollback_site`, `list_editors`, `add_editor`,
|
|
136
|
+
`remove_editor`, `list_shared_with_me`, `list_teams`, `create_team`, `list_team_members`, `add_team_member`, `remove_team_member`, `add_domain`, `domain_status`,
|
|
137
|
+
`list_domains`, `remove_domain`, `set_team_domain`, `set_team_sso` over stdio. Wire it into agents with `node skill/install.mjs`.
|
|
138
|
+
|
|
139
|
+
## Versions, editors and teams (hosted tier, after `hush login`)
|
|
140
|
+
|
|
141
|
+
Every hosted publish is kept as a version, so a bad update can be undone on the same URL.
|
|
142
|
+
You have a personal space plus any number of **team spaces** (shared accounts with their own handle,
|
|
143
|
+
`hushdrop.dev/<team>/...`). Team roles: editor (publish incl. new drops, rollback), admin (also delete,
|
|
144
|
+
settings, editors), owner (everything). Or share **one drop** with an editor (they can only update it).
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
hush versions q3-deck # history: version, when, size, who published, which is live
|
|
148
|
+
hush rollback q3-deck 3 # make v3 live again (same URL)
|
|
149
|
+
hush editors add q3-deck @krista # Krista can now update max/q3-deck (only that drop)
|
|
150
|
+
hush editors q3-deck # who can update it
|
|
151
|
+
hush editors rm q3-deck @krista # revoke
|
|
152
|
+
# as Krista:
|
|
153
|
+
hush shared # drops others let you update
|
|
154
|
+
hush deck.html --to max/q3-deck # publish a new version of max/q3-deck
|
|
155
|
+
hush versions q3-deck --to max # its history; `hush rollback q3-deck 2 --to max` to undo
|
|
156
|
+
|
|
157
|
+
hush team create acme # team space → hushdrop.dev/acme/...
|
|
158
|
+
hush team invite acme ana@acme.com leo@studio.io # email invites; they sign up from the link and join (first invite starts the Team trial)
|
|
159
|
+
hush team add acme @ana # Ana can publish anything into @acme
|
|
160
|
+
hush team add acme @ana --role admin # also delete drops, change settings, manage editors
|
|
161
|
+
hush team # your personal space + teams (● = active)
|
|
162
|
+
hush team domain acme acme.com # anyone signing in as @acme.com (Google/Microsoft/email) joins @acme
|
|
163
|
+
# Team plan: drops also open at acme.hushdrop.dev/<slug> (subdomain_url in `hush team members acme --json`)
|
|
164
|
+
hush login --with google # or microsoft, or sso: sign in with a work account
|
|
165
|
+
hush team sso acme --metadata-url https://idp.acme.com/saml/metadata # SAML SSO (Team add-on)
|
|
166
|
+
hush use acme # default publishes to @acme (hush use personal to switch back)
|
|
167
|
+
hush launch.html --to acme -s launch # or target a team per command
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Team spaces are the paid **Team** plan: $29/mo flat per team, unlimited members. Every team gets a
|
|
171
|
+
14-day free trial with no card. Creating a team is free; adding members and publishing into it need
|
|
172
|
+
Team. Per-drop editors, versions and rollback stay free.
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
hush team upgrade acme # start Team on @acme (the free trial while checkout isn't live)
|
|
176
|
+
hush team upgrade acme --add @ana # ...and add Ana as soon as it's on
|
|
177
|
+
hush billing acme # plan, days left / renewal
|
|
178
|
+
hush upgrade # Pro ($9/mo) for your personal space
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
When a team command or a `--to <team>` publish returns HTTP 402, the JSON has a `paywall` object:
|
|
182
|
+
`can_upgrade`, `trial_available`, `upgrade` (the command) and `then` (the action that was blocked).
|
|
183
|
+
If `can_upgrade` is true, tell the user what the trial gives them and, once they agree, run
|
|
184
|
+
`hush team upgrade <team> --json` (plus `--add <then.add>` if set), then retry the blocked action.
|
|
185
|
+
If the result has a `url`, give it to the user to open instead. If `can_upgrade` is false, tell the
|
|
186
|
+
user an owner has to upgrade the team.
|
|
187
|
+
|
|
188
|
+
Agents: prefer explicit `--to <team>` over `hush use`, since `use` changes the default for every later call.
|
|
189
|
+
|
|
190
|
+
Agents: before overwriting a drop someone else may also edit, run `hush versions <slug> --json` to
|
|
191
|
+
see who published last; if an update breaks the page, `hush rollback <slug> <previous>` restores it.
|
|
192
|
+
All of these accept `--json`.
|
|
193
|
+
|
|
194
|
+
## Custom domains (hosted, Pro/Team)
|
|
195
|
+
|
|
196
|
+
Serve hosted drops on your own domain, with HTTPS issued automatically. Connect a domain to a whole
|
|
197
|
+
space (`share.acme.com/<slug>`) or to one drop (served at the domain's root).
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
hush domains add share.acme.com # every drop in your space: share.acme.com/<slug>
|
|
201
|
+
hush domains add deck.acme.com q3-deck # just this drop, at https://deck.acme.com/
|
|
202
|
+
hush domains add docs.acme.com --to acme # a team space's domain
|
|
203
|
+
hush domains status share.acme.com # DNS/verification state + the records still missing
|
|
204
|
+
hush domains # list · hush domains rm share.acme.com
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
`add` prints the DNS records to create: a CNAME for a subdomain (or an A record for an apex domain),
|
|
208
|
+
plus a TXT record if ownership must be proven. Agents: show the user those exact records, then poll
|
|
209
|
+
`hush domains status <domain> --json` until `live` is true. Locked drops stay end-to-end encrypted on
|
|
210
|
+
custom domains. Self-hosting instead? `hush deploy --domain` puts your whole instance on your domain.
|
|
49
211
|
|
|
50
212
|
The URL (and password, if locked) is printed and **copied to the clipboard**.
|
|
51
213
|
|
|
@@ -58,6 +220,12 @@ The URL (and password, if locked) is printed and **copied to the clipboard**.
|
|
|
58
220
|
3. Upload to **Vercel Blob** under a clean key; served via `middleware.js` on the configured domain
|
|
59
221
|
(rewrites Blob headers so encrypted HTML renders instead of downloading).
|
|
60
222
|
|
|
223
|
+
**Sites (folder/zip):** a folder or zip is uploaded file-by-file under `/<slug>/`; the root
|
|
224
|
+
`index.html` is branded and gets a `<base href>` so relative links resolve. A public site (no `-p`)
|
|
225
|
+
relies on its unguessable slug and is served `noindex`. With `-p`, a PBKDF2 verifier
|
|
226
|
+
(`<slug>/.hush.json`) drives an **edge** password gate — the whole site sits behind one unlock page
|
|
227
|
+
(self-host only; requires `HUSH_GATE_SECRET`, set automatically by `hush deploy`).
|
|
228
|
+
|
|
61
229
|
## Configuration
|
|
62
230
|
|
|
63
231
|
- **Branding** → `brand/brand.json` (name, colors, owner, social links) + swap `brand/logo-white.png`
|
package/brand/badge.html
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<!-- drop: subtle corner badge (injected before </body>) -->
|
|
2
|
-
<a id="drop-badge" href="https://__DROP_DOMAIN__" target="_blank" rel="noopener noreferrer"
|
|
2
|
+
<a id="drop-badge" href="https://__DROP_DOMAIN__/?utm_source=drop&utm_medium=badge&utm_campaign=made-with" target="_blank" rel="noopener noreferrer"
|
|
3
3
|
style="position:fixed;right:14px;bottom:14px;z-index:2147483646;display:flex;align-items:center;gap:7px;
|
|
4
4
|
padding:7px 12px 7px 9px;border-radius:999px;text-decoration:none;
|
|
5
5
|
font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,sans-serif;
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
onmouseover="this.style.transform='translateY(-1px)';this.style.background='rgba(20,20,22,0.78)'"
|
|
12
12
|
onmouseout="this.style.transform='none';this.style.background='rgba(20,20,22,0.62)'">
|
|
13
13
|
<span style="width:9px;height:9px;border-radius:50%;background:linear-gradient(135deg,#ff6b35,#ea580c);display:block;flex:0 0 auto;"></span>
|
|
14
|
-
<span style="opacity:.78;">
|
|
14
|
+
<span style="opacity:.78;">__DROP_BADGE_TEXT__</span>
|
|
15
15
|
</a>
|
package/brand/download-page.html
CHANGED
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
</div>
|
|
104
104
|
</div>
|
|
105
105
|
<a class="btn" href="__DROP_FILE_URL__" download>Download</a>
|
|
106
|
-
<p class="footer">Shared via <a href="https://__DROP_DOMAIN__">__DROP_DOMAIN__</a><br />
|
|
106
|
+
<p class="footer">Shared via <a href="https://__DROP_DOMAIN__/?utm_source=drop&utm_medium=download">__DROP_DOMAIN__</a><br />
|
|
107
107
|
<span style="opacity:.8;">made by <a href="__DROP_WEBSITE__">__DROP_OWNER__</a> · <a href="__DROP_GITHUB__">github</a> · <a href="__DROP_INSTAGRAM__">instagram</a></span>
|
|
108
108
|
</p>
|
|
109
109
|
</div>
|
package/brand/gate.html
CHANGED
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
<input type="submit" class="staticrypt-decrypt-button" value="/*[|template_button|]*/0" />
|
|
255
255
|
</form>
|
|
256
256
|
</div>
|
|
257
|
-
<p class="drop-footer">Shared via <a href="https://__DROP_DOMAIN__">__DROP_DOMAIN__</a></p>
|
|
257
|
+
<p class="drop-footer">Shared via <a href="https://__DROP_DOMAIN__/?utm_source=drop&utm_medium=gate">__DROP_DOMAIN__</a></p>
|
|
258
258
|
</div>
|
|
259
259
|
</div>
|
|
260
260
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Viewer comment widget for hosted drops with comments on (sites.feedback). The edge injects
|
|
2
|
+
// it into unlocked drops; the CLI bakes it into locked ones before encryption (--comments).
|
|
3
|
+
// Without a drop id it reads /<handle>/<slug> from the URL, and hides itself when comments are off.
|
|
4
|
+
// Plain inline JS + CSS (fits the drop CSP). Click "Comment", click a spot, type, send.
|
|
5
|
+
// Pins are stored with a CSS selector and a text snippet so an agent can locate the spot.
|
|
6
|
+
export function commentWidget(drop = null) {
|
|
7
|
+
const d = drop ? JSON.stringify(drop) : 'location.pathname.split("/").filter(Boolean).slice(0,2).join("/")';
|
|
8
|
+
return `<div id="hd-c-root"></div><script>(function(){
|
|
9
|
+
var DROP=${d},API="/api/comments?drop="+encodeURIComponent(DROP),mode=false,root=document.getElementById("hd-c-root");
|
|
10
|
+
var st=document.createElement("style");st.textContent=".hd-c-btn{position:fixed;left:14px;bottom:14px;z-index:2147483646;padding:8px 13px;border-radius:999px;border:0;font:600 13px system-ui,sans-serif;background:#ff6b35;color:#fff;cursor:pointer;box-shadow:0 2px 10px rgba(0,0,0,.2)}.hd-c-on{cursor:crosshair!important}.hd-c-pin{position:absolute;z-index:2147483645;width:24px;height:24px;margin:-12px 0 0 -12px;border-radius:50% 50% 50% 0;background:#ff6b35;color:#fff;font:700 12px/24px system-ui;text-align:center;cursor:pointer;border:2px solid #fff;box-shadow:0 1px 6px rgba(0,0,0,.3)}.hd-c-box{position:absolute;z-index:2147483647;width:260px;max-width:80vw;background:#fff;color:#111;border-radius:10px;padding:10px;box-shadow:0 6px 24px rgba(0,0,0,.25);font:14px system-ui,sans-serif}.hd-c-box textarea,.hd-c-box input{width:100%;box-sizing:border-box;margin:4px 0;padding:7px;border:1px solid #ccc;border-radius:6px;font:inherit;color:#111;background:#fff}.hd-c-box button{padding:6px 11px;border:0;border-radius:6px;background:#ff6b35;color:#fff;font-weight:600;cursor:pointer}.hd-c-box .x{background:#eee;color:#111;margin-left:6px}.hd-c-box p{margin:0 0 6px;white-space:pre-wrap}.hd-c-box small{color:#666}";document.head.appendChild(st);
|
|
11
|
+
var b=document.createElement("button");b.className="hd-c-btn";b.textContent="Comment";b.style.display="none";root.appendChild(b);
|
|
12
|
+
function sel(el){var p=[];while(el&&el.nodeType===1&&el!==document.body&&p.length<6){var s=el.tagName.toLowerCase();if(el.id){p.unshift(s+"#"+el.id);break}var i=1,n=el;while((n=n.previousElementSibling))if(n.tagName===el.tagName)i++;p.unshift(s+":nth-of-type("+i+")");el=el.parentElement}return p.join(">")}
|
|
13
|
+
function close(){var o=document.querySelector(".hd-c-box");if(o)o.remove()}
|
|
14
|
+
function pin(c,i){var e=document.createElement("div");e.className="hd-c-pin";e.textContent=i;e.style.left=c.x+"%";e.style.top=c.y+"px";e.onclick=function(ev){ev.stopPropagation();close();var x=document.createElement("div");x.className="hd-c-box";x.style.left=c.x+"%";x.style.top=(c.y+14)+"px";var p=document.createElement("p");p.textContent=c.body;var s=document.createElement("small");s.textContent=(c.author||"Anonymous")+" \\u00b7 "+new Date(c.created_at).toLocaleString();x.appendChild(p);x.appendChild(s);document.body.appendChild(x)};document.body.appendChild(e)}
|
|
15
|
+
function load(){fetch(API).then(function(r){if(!r.ok)throw 0;b.style.display="";return r.json()}).then(function(d){document.querySelectorAll(".hd-c-pin").forEach(function(n){n.remove()});(d.comments||[]).forEach(function(c,i){pin(c,i+1)})}).catch(function(){})}
|
|
16
|
+
b.onclick=function(e){e.stopPropagation();mode=!mode;document.documentElement.classList.toggle("hd-c-on",mode);b.textContent=mode?"Click a spot\\u2026":"Comment"};
|
|
17
|
+
document.addEventListener("click",function(e){if(!mode||root.contains(e.target)||e.target.closest(".hd-c-box"))return;e.preventDefault();e.stopPropagation();mode=false;document.documentElement.classList.remove("hd-c-on");b.textContent="Comment";close();
|
|
18
|
+
var w=document.documentElement.scrollWidth,x=Math.round(e.pageX/w*1000)/10,y=Math.round(e.pageY),t=e.target,snip=(t.innerText||t.textContent||"").trim().slice(0,160);
|
|
19
|
+
var box=document.createElement("div");box.className="hd-c-box";box.style.left=x+"%";box.style.top=(y+14)+"px";box.innerHTML='<textarea rows=3 placeholder="What should change here?"></textarea><input placeholder="Your name (optional)" maxlength=60><button>Send</button><button class=x>Cancel</button>';document.body.appendChild(box);box.querySelector("textarea").focus();
|
|
20
|
+
box.querySelector(".x").onclick=close;box.querySelector("button").onclick=function(){var body=box.querySelector("textarea").value.trim();if(!body)return;this.disabled=true;
|
|
21
|
+
fetch(API,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({body:body,author:box.querySelector("input").value.trim(),selector:sel(t),snippet:snip,x:x,y:y})}).then(function(r){close();if(r.ok)load();else alert("Could not send the comment.")})}},true);
|
|
22
|
+
load()})();</script>`;
|
|
23
|
+
}
|