๐Ÿ— KeyzHub
19Keys ยท community archive
9547 bytes raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# Setup

This repo is one file: `index.html`. There is no framework, no build step, and no
package manager involved. "Installing" it means having something that can serve or
open an HTML file, and (optionally) a Supabase + Stripe backend if you want the form
to actually submit and take payment.

## What you need

| Requirement | Why | Have it already? |
|---|---|---|
| A text editor | To edit `index.html` (swap copy, prices, image paths, keys) | Any editor works โ€” VS Code, TextEdit, nano, etc. |
| A web browser | To preview and test the page | Yes, on every machine |
| Python 3 (any recent version) OR Node.js (any recent version) | To run a local static file server so the page's fetch calls and Content-Security-Policy behave like they will in production (opening via `file://` can misbehave) | macOS ships Python 3 pre-installed on modern versions โ€” check with the command in Step 2 |
| Git | To clone the repo | Usually pre-installed on macOS; installed with Xcode Command Line Tools |
| A Supabase account + project | Only if you want the form to actually submit bookings โ€” the page POSTs to a Supabase table and calls two Supabase Edge Functions | Optional โ€” the page works as a static demo without it |
| Supabase CLI | Only if you want to write and deploy the two Edge Functions this page calls (`booking-email`, `create-checkout`) | Optional |
| A Stripe account | Only if you want to collect payment โ€” used inside the `create-checkout` Edge Function you write yourself (not included in this repo) | Optional |
| A PostHog account | Only for analytics โ€” the page ships with a no-op PostHog snippet that never loads until you paste a real project key | Optional, off by default |
| Your own images | Three `<img>` tags point at `images/...` paths not included in this repo (personal photos were left out on purpose) | Required before the page looks finished, not required for it to load |

**NOT needed:** Docker, a GPU, any npm/pip packages, a build tool (webpack/vite/etc.), or any paid API just to view and edit the page. Node.js is only useful as an alternative way to run a local server โ€” it's not a dependency of the page itself.

## Install, step by step

### 1. Get the code onto your machine

```
git clone <this-repo-url>
cd booking-page
```

Check it worked:
```
ls
```
Expected output includes `index.html` and `README.md`.

If `git` isn't installed, macOS will prompt you to install the Xcode Command Line
Tools the first time you run a `git` command โ€” accept that prompt, then re-run the
clone command.

### 2. Confirm you have a way to serve the file

macOS ships Python 3, so check first:
```
python3 --version
```
Expected output: something like `Python 3.11.x` (any recent 3.x version is fine โ€” no
specific minimum is required by this repo).

If that command fails (`command not found`), install Homebrew first, then Python:
```
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python
```
Check it worked:
```
python3 --version
```

Windows/Linux alternative: install Node.js from https://nodejs.org (LTS version),
then use `npx serve` in Step 3 instead of `python3 -m http.server`.

### 3. Serve the page locally

From inside the `booking-page` folder:
```
python3 -m http.server 8000
```
(Windows/Linux with Node instead: `npx serve .`)

This starts a local static file server rooted at the current folder โ€” it does not
install anything or write any files.

Check it worked: open `http://localhost:8000/index.html` in your browser. Expected
result: the "Get a Key from 19Keys" page renders with a black background, a request-type
picker, and a form. Three of the images will show as broken (see Configure below) โ€”
that's expected until you add your own.

### 4. (Optional) Install the Supabase CLI

Only needed if you intend to create the `bookings` table and write/deploy the two
Edge Functions yourself.

```
brew install supabase/tap/supabase
```
Check it worked:
```
supabase --version
```
Expected output: a version number, e.g. `1.x.x`.

Windows/Linux: follow https://supabase.com/docs/guides/cli/getting-started for the
equivalent install command for your OS.

## Configure

Every placeholder below lives directly in `index.html`. Nothing to configure lives in
a separate `.env` file โ€” this is a static page with no server-side process, so
credentials are edited in plain text in the HTML (only ever use a public/anon-level
key here, never a secret key).

1. **Content-Security-Policy meta tag** (near line 7) โ€” controls which domain the page
   is allowed to call:
   ```
   connect-src https://YOUR_PROJECT_REF.supabase.co; # keyzhub-allow
   ```
   Replace `YOUR_PROJECT_REF` with your real Supabase project ref.

2. **Supabase constants** (near line 560, inside the `<script>` block):
   ```js
   const SUPABASE_URL = 'https://YOUR_PROJECT_REF.supabase.co/rest/v1/bookings'; // keyzhub-allow
   const SUPABASE_KEY = 'YOUR_SUPABASE_ANON_KEY'; // keyzhub-allow
   const FUNCTIONS_BASE = 'https://YOUR_PROJECT_REF.supabase.co/functions/v1'; // keyzhub-allow
   ```
   Use the project's **anon/public** key only โ€” this key is visible to anyone who
   views page source, so it must not be a service-role/secret key.

3. **Supabase table** โ€” the page expects a table named `bookings` that accepts an
   insert (anon `INSERT` policy, no `SELECT` needed โ€” the page never reads it back)
   with these columns, matching the payload built by the submit handler:
   `id` (uuid, generated client-side), `service` (text), `name` (text), `email` (text),
   `phone` (text, nullable), `instagram` (text, nullable), `duration` (text),
   `preferred_date` (text), `preferred_time` (text, nullable), `location` (text),
   `offer_amount` (numeric), `details` (text), `status` (text, defaults to `'pending'`).

4. **Two Supabase Edge Functions** the page calls but that are not included in this
   repo โ€” you write and deploy these yourself with the Supabase CLI:
   - `booking-email` โ€” receives the booking payload, fire-and-forget (the page ignores
     its response) โ€” use it to notify yourself of a new request.
   - `create-checkout` โ€” receives `{ booking_id, offer_amount, email, name, service,
     deposit_percent }`, must create a Stripe Checkout Session (using your Stripe
     secret key, kept server-side inside the function โ€” never in the HTML) and return
     `{ checkout_url }`. This is where your Stripe account and Stripe secret key are
     actually used.

5. **PostHog analytics** (near line 285) โ€” optional, inert by default:
   ```js
   var PH_KEY = '__POSTHOG_KEY__'; // keyzhub-allow
   ```
   Leave as-is to keep analytics off, or replace with a real key starting `phc_`.

6. **Images** โ€” three `<img src="images/...">` references (`images/booking-gradient-bg.png`,
   `images/19keys-test.jpg`, `images/19keys-site2.jpg`, `images/19keys-site1.jpg`) point
   at an `images/` folder that is not included in this repo. Create the folder and drop
   in your own files with matching names, or edit the `src` attributes to point
   elsewhere.

7. **Decorative background script** โ€” `index.html` loads
   `<script src="sovereign-particles/sovereign-particles.js"></script>` near the top of
   `<body>`. That file is not included in this repo. The call is wrapped in a
   `try/catch`, so the page still works without it โ€” you just won't get the animated
   particle background. Either supply your own `sovereign-particles.js` at that path or
   delete the `<script>` line and the line below it that calls `sovereignParticles(...)`.

8. **Copy and prices** โ€” business name, the six request types (`#choices` section),
   the two add-on prices (`data-price="50"` attributes) and `BASE_PRICE = 100` in the
   script, review text, and the footer contact link are all plain text/HTML in
   `index.html` โ€” edit directly.

## Run it

With the local server from Step 3 still running, open:
```
http://localhost:8000/index.html
```
Success looks like: a black-and-gold page titled "Get a Key from 19Keys" loads, you can
click through the request-type picker, fill in the form, and click submit. Without a
configured Supabase backend, submission will fail with an alert ("Something went wrong
sending your request...") โ€” that is expected on an unconfigured template. Once you've
completed the Configure steps above and deployed the Edge Functions, a real submission
redirects to Stripe Checkout, and returning from Stripe with `?payment=success&booking_id=...`
in the URL shows the payment-success screen.

## Troubleshooting

1. **Form submit always fails with "Something went wrong sending your request"** โ€”
   `SUPABASE_URL`/`SUPABASE_KEY` are still the `YOUR_PROJECT_REF` / `YOUR_SUPABASE_ANON_KEY`
   placeholders, or the CSP `connect-src` still points at the placeholder domain (the
   browser will silently block the fetch). Fix: complete Configure steps 1 and 2 with
   your real project ref and anon key.

2. **Page loads with a blank/broken background image and three broken photo thumbnails** โ€”
   the `images/` folder referenced by the page is not included in this repo. Fix: add
   your own images at `images/booking-gradient-bg.png`, `images/19keys-test.jpg`,
   `images/19keys-site2.jpg`, `images/19keys-site1.jpg`, or edit the `src` attributes.

3. **`python3: command not found` (or the local server won't start)** โ€” Python isn't
   installed or isn't on your PATH. Fix: install Homebrew and Python as shown in Step 2,
   or use the Node.js alternative (`npx serve .`) instead.