AgPerry commited on
Commit
24732dc
·
verified ·
1 Parent(s): 366cc97

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. tasks/zennioptical/solution/site/README.md +4 -0
  2. tasks/zennioptical/solution/site/implementation/Dockerfile +7 -0
  3. tasks/zennioptical/solution/site/implementation/README.md +5 -0
  4. tasks/zennioptical/solution/site/implementation/backend/model.json +435 -0
  5. tasks/zennioptical/solution/site/implementation/backend/runtime.json +105 -0
  6. tasks/zennioptical/solution/site/implementation/clone/app.py +1917 -0
  7. tasks/zennioptical/solution/site/implementation/clone/backend/site_backend_integration.py +112 -0
  8. tasks/zennioptical/solution/site/implementation/clone/data/accessories.json +242 -0
  9. tasks/zennioptical/solution/site/implementation/clone/data/products.json +0 -0
  10. tasks/zennioptical/solution/site/implementation/clone/requirements.txt +2 -0
  11. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110100023-accessories-01.jpg +3 -0
  12. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110200030-accessories-01.jpg +3 -0
  13. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110300224-accessories-01.jpg +3 -0
  14. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110400030-accessories-01.jpg +3 -0
  15. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A50100015-accessories-01.jpg +3 -0
  16. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60104517-accessories-01.jpg +3 -0
  17. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105615-accessories-01.jpg +3 -0
  18. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105616-accessories-01.jpg +3 -0
  19. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105621-accessories-01.jpg +3 -0
  20. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105624-accessories-01.jpg +3 -0
  21. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105630-accessories-01.jpg +3 -0
  22. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105818-accessories-01.jpg +3 -0
  23. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105942-accessories-01.jpg +3 -0
  24. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60106042-accessories-01.jpg +3 -0
  25. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60122230-accessories-01.jpg +3 -0
  26. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60122619-accessories-01.jpg +3 -0
  27. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60123321-accessories-01.jpg +3 -0
  28. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60123323-accessories-01.jpg +3 -0
  29. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90100121-accessories-01.jpg +3 -0
  30. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90100424-accessories-01.jpg +3 -0
  31. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90103724-accessories-01.jpg +3 -0
  32. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90104816-accessories-01.jpg +3 -0
  33. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90104821-accessories-01.jpg +3 -0
  34. tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90105118-accessories-01.jpg +3 -0
  35. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-bestsellers.png +3 -0
  36. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-cateye.png +3 -0
  37. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-new-arrivals.png +3 -0
  38. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-onsale.png +3 -0
  39. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-oversize.png +3 -0
  40. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-rectagle.png +3 -0
  41. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-titanium.png +3 -0
  42. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-top-rated.png +3 -0
  43. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-tortoiseshell.png +3 -0
  44. tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-under30.png +3 -0
  45. tasks/zennioptical/solution/site/implementation/clone/static/products/106215-eyeglasses-side-view.jpg +3 -0
  46. tasks/zennioptical/solution/site/implementation/clone/static/products/106223-eyeglasses-angle-view.jpg +3 -0
  47. tasks/zennioptical/solution/site/implementation/clone/static/products/106223-eyeglasses-front-view.jpg +3 -0
  48. tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-angle-view.jpg +3 -0
  49. tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-front-view.jpg +3 -0
  50. tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-side-view.jpg +3 -0
tasks/zennioptical/solution/site/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Oracle support
2
+
3
+ The materializer assembles the frozen clone, backend, and reference adapter as
4
+ the private implementation. No additional oracle-only behavior is required.
tasks/zennioptical/solution/site/implementation/Dockerfile ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+ WORKDIR /srv/reference
3
+ COPY . .
4
+ ENV HOST=0.0.0.0 PORT=8080 DATA_DIR=/tmp/websitebench-zennioptical-reference-data SEED=0 TZ=UTC
5
+ RUN ./compile.sh
6
+ HEALTHCHECK --interval=2s --timeout=3s --retries=30 CMD python3 -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/healthz', timeout=2)"
7
+ CMD ["./executable"]
tasks/zennioptical/solution/site/implementation/README.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Direct reference adapter
2
+
3
+ The materializer overlays these ABI files on the frozen Zenni Optical clone and
4
+ backend. The same assembled bytes form the private oracle implementation; the
5
+ clone and backend are not duplicated in this authoring directory.
tasks/zennioptical/solution/site/implementation/backend/model.json ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": "offline-clone.backend-model.v1",
3
+ "site_id": "zennioptical",
4
+ "status": "draft",
5
+ "profile": "offline-benchmark",
6
+ "database": {
7
+ "engine": "sqlite",
8
+ "location_policy": "runtime-data-outside-candidate",
9
+ "concurrency_model": "wal-transactional-single-writer",
10
+ "migration_strategy": "versioned-forward-migrations",
11
+ "deterministic_reset": true,
12
+ "restart_persistence": true,
13
+ "site_isolation": "one-database-per-site",
14
+ "proofs": [
15
+ {
16
+ "obligation": "data-location",
17
+ "status": "planned",
18
+ "evidence": []
19
+ },
20
+ {
21
+ "obligation": "schema-migration",
22
+ "status": "planned",
23
+ "evidence": []
24
+ },
25
+ {
26
+ "obligation": "deterministic-reset",
27
+ "status": "planned",
28
+ "evidence": []
29
+ },
30
+ {
31
+ "obligation": "restart-persistence",
32
+ "status": "planned",
33
+ "evidence": []
34
+ },
35
+ {
36
+ "obligation": "backup-restore",
37
+ "status": "planned",
38
+ "evidence": []
39
+ },
40
+ {
41
+ "obligation": "concurrency",
42
+ "status": "planned",
43
+ "evidence": []
44
+ }
45
+ ]
46
+ },
47
+ "auth_semantics": {
48
+ "account_database_scope": "site-isolated",
49
+ "credential_storage": "salted-scrypt-hash",
50
+ "session_storage": "opaque-cookie-digest-at-rest",
51
+ "registration_account_creation": "after-email-verification",
52
+ "verification_challenge_storage": "salted-hash",
53
+ "password_reset_enumeration": "indistinguishable-public-response",
54
+ "mail_default": "LOCAL_ONLY",
55
+ "mail_statuses": [
56
+ "LOCAL_ONLY",
57
+ "SMTP_PENDING",
58
+ "SMTP_SENT",
59
+ "SMTP_FAILED"
60
+ ],
61
+ "smtp_activation": "explicit-complete-config-only",
62
+ "smtp_delivery_ceiling": 3,
63
+ "rejected_secret_journaling": "forbidden",
64
+ "legacy_write_policy": "read-compatible-write-rejected"
65
+ },
66
+ "common_capabilities": {
67
+ "account_registration": "account-registration",
68
+ "account_sign_in": "account-sign-in",
69
+ "session_lifecycle": "session-lifecycle",
70
+ "password_recovery": "password-recovery",
71
+ "email_delivery": "email-delivery"
72
+ },
73
+ "capabilities": [
74
+ {
75
+ "id": "account-registration",
76
+ "label": "Verified local account registration",
77
+ "priority": "p0",
78
+ "category": "authentication",
79
+ "implementation_status": "planned",
80
+ "entities": [
81
+ {
82
+ "name": "pending-registration",
83
+ "identity": "opaque pending id bound to one browser session",
84
+ "owner_scope": "session",
85
+ "persistence": "durable"
86
+ },
87
+ {
88
+ "name": "local-account",
89
+ "identity": "site-local account id and unique normalized email",
90
+ "owner_scope": "account",
91
+ "persistence": "durable"
92
+ }
93
+ ],
94
+ "state_machine": {
95
+ "kind": "challenge-lifecycle",
96
+ "states": [
97
+ "collecting",
98
+ "pending-verification",
99
+ "verified",
100
+ "account-created",
101
+ "expired",
102
+ "locked"
103
+ ],
104
+ "transitions": [
105
+ {
106
+ "from": "collecting",
107
+ "to": "pending-verification",
108
+ "trigger": "validated registration request"
109
+ },
110
+ {
111
+ "from": "pending-verification",
112
+ "to": "verified",
113
+ "trigger": "correct unexpired code within attempt budget"
114
+ },
115
+ {
116
+ "from": "verified",
117
+ "to": "account-created",
118
+ "trigger": "transactional account creation and session rotation"
119
+ },
120
+ {
121
+ "from": "pending-verification",
122
+ "to": "expired",
123
+ "trigger": "challenge expiry"
124
+ },
125
+ {
126
+ "from": "pending-verification",
127
+ "to": "locked",
128
+ "trigger": "verification attempt budget exhausted"
129
+ }
130
+ ]
131
+ },
132
+ "server_authorities": [
133
+ "The server normalizes identity and hashes password and code.",
134
+ "An account is created only after successful verification.",
135
+ "Duplicate normalized email creation is rejected transactionally."
136
+ ],
137
+ "external_effect": "none",
138
+ "journey_ids": [],
139
+ "invariant_ids": [],
140
+ "proofs": {
141
+ "evidence": {},
142
+ "planned": [
143
+ "valid",
144
+ "invalid",
145
+ "duplicate",
146
+ "stale",
147
+ "foreign-owner",
148
+ "unauthorized-role",
149
+ "restart",
150
+ "migration",
151
+ "concurrency"
152
+ ],
153
+ "not_applicable": []
154
+ }
155
+ },
156
+ {
157
+ "id": "account-sign-in",
158
+ "label": "Password-based local account sign-in",
159
+ "priority": "p0",
160
+ "category": "authentication",
161
+ "implementation_status": "planned",
162
+ "entities": [
163
+ {
164
+ "name": "local-account",
165
+ "identity": "site-local account id and normalized email",
166
+ "owner_scope": "account",
167
+ "persistence": "durable"
168
+ }
169
+ ],
170
+ "state_machine": {
171
+ "kind": "entity-lifecycle",
172
+ "states": [
173
+ "signed-out",
174
+ "identified",
175
+ "authenticated",
176
+ "rejected"
177
+ ],
178
+ "transitions": [
179
+ {
180
+ "from": "signed-out",
181
+ "to": "identified",
182
+ "trigger": "normalized email submitted"
183
+ },
184
+ {
185
+ "from": "identified",
186
+ "to": "authenticated",
187
+ "trigger": "constant-time password verification succeeds"
188
+ },
189
+ {
190
+ "from": "identified",
191
+ "to": "rejected",
192
+ "trigger": "credentials are invalid"
193
+ }
194
+ ]
195
+ },
196
+ "server_authorities": [
197
+ "The server verifies salted password hashes.",
198
+ "The server rotates the authenticated session.",
199
+ "Client-selected fixture identity is not authentication."
200
+ ],
201
+ "external_effect": "none",
202
+ "journey_ids": [],
203
+ "invariant_ids": [],
204
+ "proofs": {
205
+ "evidence": {},
206
+ "planned": [
207
+ "valid",
208
+ "invalid",
209
+ "duplicate",
210
+ "stale",
211
+ "foreign-owner",
212
+ "unauthorized-role",
213
+ "restart",
214
+ "migration",
215
+ "concurrency"
216
+ ],
217
+ "not_applicable": []
218
+ }
219
+ },
220
+ {
221
+ "id": "session-lifecycle",
222
+ "label": "Anonymous and authenticated browser sessions",
223
+ "priority": "p0",
224
+ "category": "authentication",
225
+ "implementation_status": "planned",
226
+ "entities": [
227
+ {
228
+ "name": "browser-session",
229
+ "identity": "opaque cookie token with digest persisted at rest",
230
+ "owner_scope": "session",
231
+ "persistence": "durable"
232
+ }
233
+ ],
234
+ "state_machine": {
235
+ "kind": "session-lifecycle",
236
+ "states": [
237
+ "anonymous",
238
+ "authenticated",
239
+ "revoked",
240
+ "expired"
241
+ ],
242
+ "transitions": [
243
+ {
244
+ "from": "anonymous",
245
+ "to": "authenticated",
246
+ "trigger": "successful sign-in or registration rotates session"
247
+ },
248
+ {
249
+ "from": "authenticated",
250
+ "to": "revoked",
251
+ "trigger": "sign-out or security reset"
252
+ },
253
+ {
254
+ "from": "anonymous",
255
+ "to": "expired",
256
+ "trigger": "session expiry"
257
+ },
258
+ {
259
+ "from": "authenticated",
260
+ "to": "expired",
261
+ "trigger": "session expiry"
262
+ }
263
+ ]
264
+ },
265
+ "server_authorities": [
266
+ "Raw session tokens are never stored in the database.",
267
+ "Ownership is resolved from the server-side session record.",
268
+ "Sign-out revokes server-side authority before deleting the cookie."
269
+ ],
270
+ "external_effect": "none",
271
+ "journey_ids": [],
272
+ "invariant_ids": [],
273
+ "proofs": {
274
+ "evidence": {},
275
+ "planned": [
276
+ "valid",
277
+ "invalid",
278
+ "duplicate",
279
+ "stale",
280
+ "foreign-owner",
281
+ "unauthorized-role",
282
+ "restart",
283
+ "migration",
284
+ "concurrency"
285
+ ],
286
+ "not_applicable": []
287
+ }
288
+ },
289
+ {
290
+ "id": "password-recovery",
291
+ "label": "Enumeration-resistant local password recovery",
292
+ "priority": "p0",
293
+ "category": "authentication",
294
+ "implementation_status": "planned",
295
+ "entities": [
296
+ {
297
+ "name": "password-reset-challenge",
298
+ "identity": "opaque reset id bound to one browser session",
299
+ "owner_scope": "session",
300
+ "persistence": "durable"
301
+ },
302
+ {
303
+ "name": "local-account",
304
+ "identity": "nullable concealed account binding",
305
+ "owner_scope": "account",
306
+ "persistence": "durable"
307
+ }
308
+ ],
309
+ "state_machine": {
310
+ "kind": "challenge-lifecycle",
311
+ "states": [
312
+ "requested",
313
+ "verified",
314
+ "consumed",
315
+ "expired",
316
+ "locked"
317
+ ],
318
+ "transitions": [
319
+ {
320
+ "from": "requested",
321
+ "to": "verified",
322
+ "trigger": "correct unexpired code within attempt budget"
323
+ },
324
+ {
325
+ "from": "verified",
326
+ "to": "consumed",
327
+ "trigger": "password is replaced and sessions are revoked"
328
+ },
329
+ {
330
+ "from": "requested",
331
+ "to": "expired",
332
+ "trigger": "challenge expiry"
333
+ },
334
+ {
335
+ "from": "requested",
336
+ "to": "locked",
337
+ "trigger": "verification attempt budget exhausted"
338
+ }
339
+ ]
340
+ },
341
+ "server_authorities": [
342
+ "Known and unknown emails receive indistinguishable public responses.",
343
+ "Only the server binds a reset flow to an account.",
344
+ "Password replacement revokes prior authenticated sessions."
345
+ ],
346
+ "external_effect": "local-only",
347
+ "journey_ids": [],
348
+ "invariant_ids": [],
349
+ "proofs": {
350
+ "evidence": {},
351
+ "planned": [
352
+ "valid",
353
+ "invalid",
354
+ "duplicate",
355
+ "stale",
356
+ "foreign-owner",
357
+ "unauthorized-role",
358
+ "restart",
359
+ "migration",
360
+ "concurrency"
361
+ ],
362
+ "not_applicable": []
363
+ }
364
+ },
365
+ {
366
+ "id": "email-delivery",
367
+ "label": "Truthful local verification and recovery mail outbox",
368
+ "priority": "p0",
369
+ "category": "communication",
370
+ "implementation_status": "planned",
371
+ "entities": [
372
+ {
373
+ "name": "mail-outbox-entry",
374
+ "identity": "site-local outbox id and purpose-bound flow id",
375
+ "owner_scope": "system",
376
+ "persistence": "durable"
377
+ }
378
+ ],
379
+ "state_machine": {
380
+ "kind": "delivery-lifecycle",
381
+ "states": [
382
+ "local-only",
383
+ "smtp-pending",
384
+ "smtp-sent",
385
+ "smtp-failed"
386
+ ],
387
+ "transitions": [
388
+ {
389
+ "from": "local-only",
390
+ "to": "smtp-pending",
391
+ "trigger": "operator enables complete explicit SMTP configuration"
392
+ },
393
+ {
394
+ "from": "smtp-pending",
395
+ "to": "smtp-sent",
396
+ "trigger": "SMTP transport confirms delivery handoff"
397
+ },
398
+ {
399
+ "from": "smtp-pending",
400
+ "to": "smtp-failed",
401
+ "trigger": "delivery attempt fails or ceiling is reached"
402
+ },
403
+ {
404
+ "from": "smtp-failed",
405
+ "to": "smtp-pending",
406
+ "trigger": "bounded idempotent retry below the delivery ceiling"
407
+ }
408
+ ]
409
+ },
410
+ "server_authorities": [
411
+ "Offline mode records LOCAL_ONLY and never claims external delivery.",
412
+ "SMTP is disabled unless every required setting is present.",
413
+ "Claim, retry, and startup replay share one delivery ceiling."
414
+ ],
415
+ "external_effect": "local-only",
416
+ "journey_ids": [],
417
+ "invariant_ids": [],
418
+ "proofs": {
419
+ "evidence": {},
420
+ "planned": [
421
+ "valid",
422
+ "invalid",
423
+ "duplicate",
424
+ "stale",
425
+ "foreign-owner",
426
+ "unauthorized-role",
427
+ "restart",
428
+ "migration",
429
+ "concurrency"
430
+ ],
431
+ "not_applicable": []
432
+ }
433
+ }
434
+ ]
435
+ }
tasks/zennioptical/solution/site/implementation/backend/runtime.json ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "database": {
3
+ "data_dir": "data",
4
+ "engine": "sqlite",
5
+ "filename": "zennioptical.sqlite3",
6
+ "legacy_unbound_migration": false,
7
+ "migration_hook": "zenni.schema:migrate",
8
+ "seed_hook": "zenni.schema:seed",
9
+ "volume_identity": "websitebench-zennioptical-data"
10
+ },
11
+ "deployment": {
12
+ "profiles": {
13
+ "cloudflare-review": {
14
+ "mail_adapter": "redis-resend",
15
+ "payment_adapter": "local-sandbox",
16
+ "persistence": "ephemeral-reset"
17
+ },
18
+ "docker-volume": {
19
+ "mail_adapter": "effects-gateway",
20
+ "payment_adapter": "local-sandbox",
21
+ "persistence": "persistent-volume"
22
+ },
23
+ "offline-harbor": {
24
+ "mail_adapter": "local-outbox",
25
+ "payment_adapter": "local-sandbox",
26
+ "persistence": "persistent"
27
+ }
28
+ }
29
+ },
30
+ "mail": {
31
+ "purposes": {
32
+ "password-reset": {
33
+ "body": "Your password reset code is ${code}.",
34
+ "expiry": "This code expires in ${minutes} minutes.",
35
+ "footer": "Ignore this message if you did not contact Zenni Optical.",
36
+ "lead": "A password reset was requested for Zenni Optical.",
37
+ "required_variables": [
38
+ "code",
39
+ "minutes"
40
+ ],
41
+ "secret_variables": [
42
+ "code"
43
+ ],
44
+ "subject": "Reset your Zenni Optical password",
45
+ "template_id": "zennioptical.password-reset.v1"
46
+ },
47
+ "registration": {
48
+ "body": "Your verification code is ${code}.",
49
+ "expiry": "This code expires in ${minutes} minutes.",
50
+ "footer": "This code is only for Zenni Optical.",
51
+ "lead": "Finish creating your Zenni Optical account.",
52
+ "required_variables": [
53
+ "code",
54
+ "minutes"
55
+ ],
56
+ "secret_variables": [
57
+ "code"
58
+ ],
59
+ "subject": "Verify your Zenni Optical account",
60
+ "template_id": "zennioptical.registration.v1"
61
+ }
62
+ },
63
+ "sender": {
64
+ "address_env": "RESEND_FROM_EMAIL",
65
+ "display_name": "Zenni Optical"
66
+ }
67
+ },
68
+ "payments": {
69
+ "currency": "USD",
70
+ "default_adapter": "local-sandbox",
71
+ "enabled": false,
72
+ "local_sandbox": {
73
+ "scenarios": [
74
+ {
75
+ "display_label": "Simulated approval",
76
+ "id": "sandbox-approved",
77
+ "outcome": "approved"
78
+ },
79
+ {
80
+ "display_label": "Simulated decline",
81
+ "id": "sandbox-declined",
82
+ "outcome": "declined"
83
+ },
84
+ {
85
+ "display_label": "Simulated retry",
86
+ "id": "sandbox-retry",
87
+ "outcome": "retryable"
88
+ }
89
+ ]
90
+ },
91
+ "stripe_test": null
92
+ },
93
+ "schema_version": "websitebench.site-backend-runtime.v1",
94
+ "session": {
95
+ "host_only": true,
96
+ "http_only": true,
97
+ "same_site": "Lax",
98
+ "secure": true
99
+ },
100
+ "site": {
101
+ "id": "zennioptical",
102
+ "label": "Zenni Optical",
103
+ "public_origin": "https://zennioptical.offline.invalid"
104
+ }
105
+ }
tasks/zennioptical/solution/site/implementation/clone/app.py ADDED
@@ -0,0 +1,1917 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Zenni Optical offline clone.
2
+
3
+ Every route, control and state below was walked on the source with Playwright;
4
+ all data, accounts, mail and payments stay inside this site's local backend.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import hashlib
10
+ import json
11
+ import os
12
+ import sys
13
+ from html import escape
14
+ from pathlib import Path
15
+ from typing import Any
16
+ from urllib.parse import urlencode
17
+
18
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
19
+
20
+ from fastapi import FastAPI, Form, Request
21
+ from fastapi.responses import HTMLResponse, RedirectResponse, Response
22
+ from fastapi.staticfiles import StaticFiles
23
+
24
+ from backend.site_backend_integration import open_site_services
25
+ from websitebench.site_backend.errors import PaymentRejected
26
+ from zenni import (accessories, catalog, lenses, nav, render, reviews,
27
+ store)
28
+ from zenni import home as home_content
29
+ from zenni.render import money, page
30
+ from zenni.schema import reset as reset_site_rows
31
+
32
+ SITE_ID = "zennioptical"
33
+ DISPLAY_NAME = "Zenni Optical"
34
+
35
+ app = FastAPI(title=DISPLAY_NAME)
36
+ app.mount(
37
+ "/static",
38
+ StaticFiles(directory=str(Path(__file__).resolve().parent / "static")),
39
+ name="static",
40
+ )
41
+
42
+ def _bind_sandbox_data_dir() -> None:
43
+ """Honour the isolation contract's writable data directory.
44
+
45
+ Under ``verify --section live`` the candidate root is mounted read-only and
46
+ the sandbox hands the process ``WEBSITEBENCH_DATA_DIR``; the site database
47
+ has to live there instead of beside the frozen contracts.
48
+ """
49
+
50
+ if os.environ.get("WEBSITEBENCH_SITE_BACKEND_DATABASE"):
51
+ return
52
+ data_dir = os.environ.get("WEBSITEBENCH_DATA_DIR")
53
+ if not data_dir:
54
+ return
55
+ runtime = json.loads(
56
+ (Path(__file__).resolve().parents[1] / "backend" / "runtime.json")
57
+ .read_text(encoding="utf-8"))
58
+ target = Path(data_dir) / runtime["database"]["filename"]
59
+ target.parent.mkdir(parents=True, exist_ok=True)
60
+ os.environ["WEBSITEBENCH_SITE_BACKEND_DATABASE"] = str(target)
61
+
62
+
63
+ _bind_sandbox_data_dir()
64
+ BACKEND, AUTH = open_site_services()
65
+ COOKIE = BACKEND.session_cookie
66
+ SEED_ACCOUNTS = [
67
+ {
68
+ "subject_id": "zenni-shopper",
69
+ "email": "shopper@zennioptical.offline.invalid",
70
+ "display_name": "Sandbox Shopper",
71
+ "password": "OfflineClone!2026",
72
+ "email_verified": True,
73
+ },
74
+ ]
75
+
76
+ # Routes that the source only serves to a signed-in session.
77
+ AUTH_REQUIRED_PREFIXES = ("/b/", "/p/", "/search", "/orderProcess",
78
+ "/shoppingCart", "/orderCheckout", "/myAccount",
79
+ "/tryon")
80
+
81
+
82
+ def _seed_accounts() -> None:
83
+ for account in SEED_ACCOUNTS:
84
+ if not AUTH.account_exists(email=account["email"]):
85
+ AUTH.seed_account(
86
+ subject_id=account["subject_id"], email=account["email"],
87
+ display_name=account["display_name"],
88
+ password=account["password"], email_verified=True,
89
+ )
90
+
91
+
92
+ _seed_accounts()
93
+
94
+
95
+ def connection():
96
+ return AUTH.connect()
97
+
98
+
99
+ class Ctx:
100
+ """Per-request session, account and cart facts."""
101
+
102
+ def __init__(self, request: Request) -> None:
103
+ token = request.cookies.get(COOKIE["name"])
104
+ self.token, self.session = AUTH.ensure_session(token)
105
+ self.new_cookie = self.token != token
106
+ resolved = AUTH.resolve_session(self.token) or {}
107
+ self.account = resolved.get("account") or resolved.get("subject")
108
+ if isinstance(self.account, str):
109
+ self.account = {"subject_id": self.account}
110
+ self.subject_id = (self.account or {}).get("subject_id")
111
+ self.display_name = (self.account or {}).get("display_name") or "there"
112
+
113
+ def state(self, connection_) -> dict[str, Any]:
114
+ return {
115
+ "account": self.account,
116
+ "cart_count": store.cart_count(connection_, self.token),
117
+ "display_name": self.display_name,
118
+ }
119
+
120
+
121
+ def respond(ctx: Ctx, html: str, status: int = 200) -> HTMLResponse:
122
+ response = HTMLResponse(html, status_code=status)
123
+ _stamp(ctx, response)
124
+ return response
125
+
126
+
127
+ def redirect(ctx: Ctx, location: str, status: int = 303) -> RedirectResponse:
128
+ response = RedirectResponse(location, status_code=status)
129
+ _stamp(ctx, response)
130
+ return response
131
+
132
+
133
+ def _stamp(ctx: Ctx, response: Response) -> None:
134
+ if not ctx.new_cookie:
135
+ return
136
+ # Keep the runtime cookie contract intact: the ``__Host-`` prefix is only
137
+ # accepted with Secure set, and browsers treat 127.0.0.1 as a trustworthy
138
+ # origin, so the review target over loopback HTTP still stores it.
139
+ options = {k: v for k, v in COOKIE.items() if k != "name"}
140
+ response.set_cookie(COOKIE["name"], ctx.token, **options)
141
+
142
+
143
+ def _login_redirect(ctx: Ctx, request: Request) -> RedirectResponse:
144
+ state = str(request.url.path)
145
+ if request.url.query:
146
+ state += "?" + request.url.query
147
+ return redirect(ctx, "/login?" + urlencode({"state": state}), status=302)
148
+
149
+
150
+ def _requires_auth(path: str) -> bool:
151
+ return any(path.startswith(prefix) for prefix in AUTH_REQUIRED_PREFIXES)
152
+
153
+
154
+ # --------------------------------------------------------------------------
155
+ # Diagnostics
156
+
157
+
158
+ @app.get("/healthz")
159
+ def healthz() -> dict[str, object]:
160
+ return {"ok": True, "site_id": SITE_ID}
161
+
162
+
163
+ @app.post("/__reset__")
164
+ def reset_state() -> dict[str, object]:
165
+ """Deterministic reset so a review run always starts from seed."""
166
+
167
+ AUTH.reset_site_state(
168
+ site_reset=reset_site_rows, seed_accounts=SEED_ACCOUNTS)
169
+ return {"ok": True, "site_id": SITE_ID, "state": "seeded"}
170
+
171
+
172
+ # --------------------------------------------------------------------------
173
+ # Authentication
174
+
175
+
176
+ @app.get("/login", response_class=HTMLResponse)
177
+ def login_form(request: Request, state: str = "/", error: str = "") -> Response:
178
+ ctx = Ctx(request)
179
+ if ctx.account:
180
+ return redirect(ctx, state or "/")
181
+ demo = SEED_ACCOUNTS[0]
182
+ banner = f'<p class="flash error">{escape(error)}</p>' if error else ""
183
+ body = (
184
+ '<div class="wrap auth"><h1 class="page">Account Login</h1>'
185
+ f"{banner}"
186
+ '<form method="post" action="/login">'
187
+ f'<input type="hidden" name="state" value="{escape(state)}">'
188
+ '<label>Email<input name="email" type="email" required '
189
+ 'autocomplete="username"></label>'
190
+ '<label>Password<input name="password" type="password" required '
191
+ 'autocomplete="current-password"></label>'
192
+ '<button class="zenbtn zenbtn-primary zenbtn-large" '
193
+ 'data-testid="sign-in">Sign in</button></form>'
194
+ '<p class="muted">New here? <a href="/register">Create an account</a>'
195
+ "</p>"
196
+ '<div class="sandbox"><strong>Local sandbox account</strong><br>'
197
+ f'{escape(demo["email"])}<br>{escape(demo["password"])}<br>'
198
+ "No real Zenni credential is accepted or stored here.</div></div>"
199
+ )
200
+ return respond(ctx, page("Account Login | Zenni Optical", body,
201
+ ctx.state(connection())))
202
+
203
+
204
+ @app.post("/login")
205
+ def login_submit(request: Request, email: str = Form(...),
206
+ password: str = Form(...), state: str = Form("/")) -> Response:
207
+ ctx = Ctx(request)
208
+ old_token = ctx.token
209
+ try:
210
+ result = AUTH.sign_in(ctx.token, email=email, password=password)
211
+ except Exception:
212
+ return redirect(
213
+ ctx,
214
+ "/login?" + urlencode(
215
+ {"state": state, "error": "Email or password is incorrect."}),
216
+ )
217
+ token = result.get("session_token") or ctx.token
218
+ ctx.token, ctx.new_cookie = token, True
219
+ resolved = AUTH.resolve_session(token) or {}
220
+ account = resolved.get("account") or {}
221
+ store.adopt_session(connection(), old_token, token,
222
+ account.get("subject_id"))
223
+ return redirect(ctx, state or "/")
224
+
225
+
226
+ @app.get("/register", response_class=HTMLResponse)
227
+ def register_form(request: Request, error: str = "") -> Response:
228
+ ctx = Ctx(request)
229
+ banner = f'<p class="flash error">{escape(error)}</p>' if error else ""
230
+ body = (
231
+ '<div class="wrap auth"><h1 class="page">Create your account</h1>'
232
+ f"{banner}"
233
+ '<form method="post" action="/register">'
234
+ '<label>Name<input name="display_name" required></label>'
235
+ '<label>Email<input name="email" type="email" required></label>'
236
+ '<label>Password<input name="password" type="password" required '
237
+ 'minlength="10"></label>'
238
+ '<button class="zenbtn zenbtn-primary zenbtn-large">Create account'
239
+ "</button></form>"
240
+ '<div class="sandbox">Verification mail is written to this site\'s '
241
+ "local outbox; nothing is sent to a real address.</div></div>"
242
+ )
243
+ return respond(ctx, page("Create Account | Zenni Optical", body,
244
+ ctx.state(connection())))
245
+
246
+
247
+ @app.post("/register")
248
+ def register_submit(request: Request, display_name: str = Form(...),
249
+ email: str = Form(...), password: str = Form(...)) -> Response:
250
+ ctx = Ctx(request)
251
+ try:
252
+ AUTH.start_registration(
253
+ ctx.token, email=email, display_name=display_name,
254
+ password=password, restart_invalid_flow=True)
255
+ except Exception as error: # surfaced to the shopper, never swallowed
256
+ return redirect(
257
+ ctx, "/register?" + urlencode({"error": str(error)[:160]}))
258
+ return redirect(ctx, "/register/verify")
259
+
260
+
261
+ @app.get("/register/verify", response_class=HTMLResponse)
262
+ def register_verify_form(request: Request, error: str = "") -> Response:
263
+ ctx = Ctx(request)
264
+ try:
265
+ mail = AUTH.local_mail_for_session(
266
+ ctx.token, purpose="registration") or []
267
+ except Exception:
268
+ mail = []
269
+ if isinstance(mail, dict):
270
+ mail = [mail]
271
+ outbox = "".join(
272
+ f"<li>{escape(str(entry.get('subject', 'Verification email')))}</li>"
273
+ for entry in mail if isinstance(entry, dict)
274
+ )
275
+ banner = f'<p class="flash error">{escape(error)}</p>' if error else ""
276
+ body = (
277
+ '<div class="wrap auth"><h1 class="page">Verify your email</h1>'
278
+ f"{banner}"
279
+ '<form method="post" action="/register/verify">'
280
+ '<label>Verification code<input name="code" required '
281
+ 'inputmode="numeric"></label>'
282
+ '<button class="zenbtn zenbtn-primary zenbtn-large">Verify</button>'
283
+ "</form>"
284
+ f'<div class="sandbox">Local outbox<ul>{outbox or "<li>(empty)</li>"}'
285
+ "</ul>Open the site outbox to read the code; it never leaves this "
286
+ "machine.</div></div>"
287
+ )
288
+ return respond(ctx, page("Verify Email | Zenni Optical", body,
289
+ ctx.state(connection())))
290
+
291
+
292
+ @app.post("/register/verify")
293
+ def register_verify(request: Request, code: str = Form(...)) -> Response:
294
+ ctx = Ctx(request)
295
+ try:
296
+ AUTH.verify_registration_code(ctx.token, code=code)
297
+ AUTH.complete_registration(ctx.token)
298
+ except Exception as error:
299
+ return redirect(
300
+ ctx, "/register/verify?" + urlencode({"error": str(error)[:160]}))
301
+ return redirect(ctx, "/myAccount/myDashBoard")
302
+
303
+
304
+ @app.post("/logout")
305
+ def logout(request: Request) -> Response:
306
+ ctx = Ctx(request)
307
+ AUTH.sign_out(ctx.token)
308
+ ctx.new_cookie = True
309
+ ctx.token, _ = AUTH.ensure_session(None)
310
+ return redirect(ctx, "/")
311
+
312
+
313
+ # --------------------------------------------------------------------------
314
+ # Storefront
315
+
316
+
317
+ @app.get("/", response_class=HTMLResponse)
318
+ def home(request: Request) -> Response:
319
+ ctx = Ctx(request)
320
+ conn = connection()
321
+ favourites = store.favorites(conn, ctx.token)
322
+ # Section order, backgrounds and card geometry follow the measured source
323
+ # home page: two tinted product rails, category rows of 198x186 artwork,
324
+ # full-width campaign banners, then the payment and sign-up strips.
325
+ def rail(slides, name, w, h, per_view=2, autoplay=True):
326
+ return render.carousel(slides, name=name, card_w=w, card_h=h,
327
+ per_view=per_view, autoplay=autoplay)
328
+
329
+ def section(heading, inner, testid, *, tint="", links=(), lede="",
330
+ center=False):
331
+ head = ""
332
+ if heading:
333
+ head_links = ""
334
+ if links:
335
+ head_links = '<span class="sec-links">' + "".join(
336
+ f'<a href="{escape(href)}">{escape(text)}</a>'
337
+ for text, href in links) + "</span>"
338
+ head = (f'<div class="sec-head"><h2>{escape(heading)}</h2>'
339
+ f"{head_links}</div>")
340
+ classes = " ".join(x for x in ("home-section", tint,
341
+ "center" if center else "") if x)
342
+ return (
343
+ f'<section class="{classes}" data-testid="{testid}">'
344
+ f'<div class="wrap">{head}'
345
+ + (f'<p class="home-lede">{escape(lede)}</p>' if lede else "")
346
+ + f"{inner}</div></section>"
347
+ )
348
+
349
+ best_items = catalog.query(
350
+ where={"category": "eyeglasses"},
351
+ sort_by="prod_zenni_products_en_best_seller")["items"][:12]
352
+ under30 = catalog.query(where={"max_price": 30.0},
353
+ sort_by="prod_zenni_products_en_top_rated"
354
+ )["items"][:12]
355
+
356
+ body = (
357
+ f'<div class="wrap">{render.pill_row(home_content.PILLS)}</div>'
358
+ f'{rail(home_content.HERO_SLIDES, "hp-hero", 604, 480)}'
359
+ + section(
360
+ "Best Sellers",
361
+ '<div class="rail-tabs" data-testid="hp-bestseller-tabs">'
362
+ '<a href="/b/all-glasses" aria-current="true">Eyeglasses</a>'
363
+ '<a href="/b/sunglasses" aria-current="false">Sunglasses</a>'
364
+ "</div>"
365
+ + render.rail_grid(best_items, favourites, "hp-bestsellers-grid"),
366
+ "home-best-sellers", tint="tint-blue",
367
+ links=[("Shop all", "/b/best-seller-glasses")])
368
+ + section(
369
+ "", rail(home_content.BEST_SELLER_RAIL, "hp-promo-rail", 604, 515),
370
+ "home-promo-rail")
371
+ + section(
372
+ "Eyewear for Everyone\u00ae",
373
+ '<div class="service-row">' + "".join(
374
+ f'<a href="{escape(href)}">{escape(text)}</a>'
375
+ for text, href in home_content.SERVICE_LINKS) + "</div>"
376
+ + '<div class="trust-row">' + "".join(
377
+ f"<div><strong>{escape(head)}</strong>{escape(sub)}</div>"
378
+ for head, sub in home_content.TRUST_POINTS) + "</div>"
379
+ + render.banner(home_content.BANNERS["bogo"], "hp-banner-bogo"),
380
+ "home-eyewear-for-everyone", center=True)
381
+ + section(
382
+ "Smarter Defense Starts Here",
383
+ rail(home_content.EDUCATIONAL_RAIL, "hp-educational-rail",
384
+ 604, 480),
385
+ "home-smarter-defense", center=True)
386
+ + section(
387
+ "So Many Ways to See",
388
+ rail(home_content.WAYS_TO_SEE_RAIL, "hp-ways-rail", 604, 480),
389
+ "home-ways-to-see", center=True)
390
+ + section(
391
+ "Shop by Frame Shape",
392
+ render.category_row(home_content.FRAME_SHAPES, "hp-frame-shape"),
393
+ "home-frame-shape", center=True)
394
+ + f'<div class="wrap">'
395
+ f'{render.banner(home_content.BANNERS["trend"], "hp-banner-trend")}'
396
+ f"</div>"
397
+ + section(
398
+ "Under $30 Picks",
399
+ render.rail_grid(under30, favourites, "hp-under30-grid"),
400
+ "home-under-30", tint="tint-teal",
401
+ links=[("Shop all", "/b/glasses-under-30")])
402
+ + section(
403
+ "Shop by Price",
404
+ render.mini_pills(home_content.PRICE_TILES, "hp-price-pills"),
405
+ "home-shop-by-price", center=True)
406
+ + section(
407
+ "Shop by Face Shape",
408
+ render.category_row(home_content.FACE_SHAPES, "hp-face-shape"),
409
+ "home-face-shape", center=True)
410
+ + section(
411
+ "Frames for Your Life",
412
+ render.category_row(home_content.FRAMES_FOR_LIFE,
413
+ "hp-frames-for-life"),
414
+ "home-frames-for-life", center=True)
415
+ + section(
416
+ "",
417
+ '<div class="csr">' + "".join(
418
+ render.banner(tile, f"hp-csr-{i}")
419
+ for i, tile in enumerate(home_content.CSR_TILES)) + "</div>",
420
+ "home-see-to-succeed")
421
+ + render.payment_strip(home_content.PAYMENT_METHODS)
422
+ + render.signup_strip(home_content.SOCIAL)
423
+ )
424
+ return respond(ctx, page(
425
+ "Zenni Optical | Eyewear for Everyone® | Affordable Glasses and "
426
+ "Sunglasses", body, ctx.state(conn)))
427
+
428
+
429
+ def _filter_panel(base_path: str, params: dict[str, str],
430
+ selected: dict[str, list[str]]) -> str:
431
+ groups = []
432
+ for group in catalog.FACET_GROUPS:
433
+ key = group["key"]
434
+ chosen = selected.get(key, [])
435
+ options = []
436
+ for value in group["values"]:
437
+ active = value in chosen
438
+ rest = {k: list(v) for k, v in selected.items()}
439
+ values = list(rest.get(key, []))
440
+ if active:
441
+ values.remove(value)
442
+ else:
443
+ values.append(value)
444
+ if values:
445
+ rest[key] = values
446
+ else:
447
+ rest.pop(key, None)
448
+ query = {k: v for k, v in params.items()
449
+ if v and k not in {"filter", "page"}}
450
+ filter_value = catalog.unparse_filters(rest)
451
+ if filter_value:
452
+ query["filter"] = filter_value
453
+ href = base_path + (f"?{urlencode(query)}" if query else "")
454
+ options.append(
455
+ f'<li><a data-testid="filter-checkbox-{escape(key)}:'
456
+ f'{escape(value)}" href="{escape(href)}">'
457
+ f'<label><input type="checkbox" readonly '
458
+ f'{"checked" if active else ""}> {escape(value)}</label>'
459
+ "</a></li>"
460
+ )
461
+ helper = ""
462
+ if key == "prod_lens_width_size":
463
+ helper = ('<a class="linkbtn" data-testid="find-my-size" '
464
+ 'href="/measure-eyeglass-frame-size-how-to">'
465
+ "Find my size</a>")
466
+ elif key == "sku_color":
467
+ helper = ('<a class="linkbtn" data-testid="find-my-pd" '
468
+ 'href="/measuring-pd-infographic">Find my PD</a>')
469
+ groups.append(
470
+ f'<details class="facet" open><summary '
471
+ f'data-testid="{escape(key)}-accordion">{escape(group["title"])}'
472
+ f'</summary><ul>{"".join(options)}</ul>{helper}</details>'
473
+ )
474
+ cleared = {k: v for k, v in params.items()
475
+ if v and k not in {"filter", "page"}}
476
+ clear_href = base_path + (f"?{urlencode(cleared)}" if cleared else "")
477
+ return (
478
+ '<aside class="filter-panel">'
479
+ '<div class="filter-panel-head">'
480
+ '<h3 data-testid="filter-panel-title">Filters</h3>'
481
+ '<button class="linkbtn" data-testid="hide-filters" '
482
+ 'aria-expanded="true" aria-controls="filter-groups">Hide Filters'
483
+ "</button></div>"
484
+ f'<div id="filter-groups">{"".join(groups)}</div>'
485
+ '<div class="filter-panel-foot">'
486
+ f'<a class="linkbtn" data-testid="clear-filters" '
487
+ f'href="{escape(clear_href)}">Clear</a>'
488
+ '<a class="zenbtn zenbtn-primary" data-testid="show-results" '
489
+ 'href="#filter-groups">Show results</a></div></aside>'
490
+ )
491
+
492
+
493
+ def _listing_page(ctx: Ctx, request: Request, *, base_path: str, title: str,
494
+ meta_title: str, where: dict[str, Any] | None = None,
495
+ keyphrase: str | None = None, slug: str | None = None,
496
+ lead: str | None = None) -> Response:
497
+ conn = connection()
498
+ params = dict(request.query_params)
499
+ selected = catalog.parse_filters(params.get("filter"))
500
+ sort_by = params.get("sortBy", "")
501
+ try:
502
+ page_no = int(params.get("page", "1"))
503
+ except ValueError:
504
+ page_no = 1
505
+ result = catalog.query(where=where, keyphrase=keyphrase, filters=selected,
506
+ sort_by=sort_by, page=page_no)
507
+ favourites = store.favorites(conn, ctx.token)
508
+
509
+ chips = ""
510
+ if selected:
511
+ pieces = []
512
+ for key, values in selected.items():
513
+ for value in values:
514
+ rest = {k: list(v) for k, v in selected.items()}
515
+ rest[key] = [v for v in rest[key] if v != value]
516
+ if not rest[key]:
517
+ rest.pop(key)
518
+ query = {k: v for k, v in params.items()
519
+ if v and k not in {"filter", "page"}}
520
+ filter_value = catalog.unparse_filters(rest)
521
+ if filter_value:
522
+ query["filter"] = filter_value
523
+ href = base_path + (f"?{urlencode(query)}" if query else "")
524
+ pieces.append(
525
+ f'<a class="chip" href="{escape(href)}">'
526
+ f"{escape(value)} &times;</a>")
527
+ chips = f'<div class="chips">{"".join(pieces)}</div>'
528
+
529
+ if result["items"]:
530
+ listing = (
531
+ render.product_grid(
532
+ result["items"], favourites,
533
+ offset=(result["page"] - 1) * catalog.PAGE_SIZE)
534
+ + render.pagination(base_path, params, result["page"],
535
+ result["pages"])
536
+ )
537
+ else:
538
+ listing = (
539
+ '<div class="empty"><h2>No results were found</h2>'
540
+ "<p>Please try modifying your filters or browse our top "
541
+ "categories:</p>"
542
+ '<p><a class="zenbtn zenbtn-primary-outline" href="/b/sunglasses">'
543
+ "Shop All Sunglasses</a></p></div>"
544
+ )
545
+
546
+ first = (result["page"] - 1) * catalog.PAGE_SIZE + 1 if result["total"] else 0
547
+ last = min(first + catalog.PAGE_SIZE - 1, result["total"])
548
+ counter = (f'{first}-{last} of {result["total"]} items'
549
+ if result["total"] else "0 items")
550
+
551
+ head = ""
552
+ if slug:
553
+ art = catalog.banner(slug)
554
+ head += (
555
+ f'<div class="plp-banner">'
556
+ f'<div class="kicker">{escape(art["kicker"])}</div>'
557
+ f'<h2>{escape(art["headline"])}</h2>'
558
+ f'<p>{escape(art["sub"])}</p></div>'
559
+ )
560
+ head += f'<h1 class="page">{escape(title)}</h1>'
561
+ if lead:
562
+ head += f'<p class="plp-seo">{escape(lead)}</p>'
563
+ related = catalog.related_links(slug or "")
564
+ if related:
565
+ head += '<div class="plp-related">' + "".join(
566
+ f'<a href="{escape(href)}">{escape(text)}</a>'
567
+ for text, href in related) + "</div>"
568
+
569
+ crumb = (
570
+ '<nav class="breadcrumb" aria-label="Breadcrumb">'
571
+ '<a href="/" aria-label="Home">&#8962;</a><span>&rsaquo;</span>'
572
+ f'<span>{escape(title)}</span></nav>'
573
+ )
574
+ density = (
575
+ '<div class="density" role="group" aria-label="Grid density">'
576
+ '<span class="g2"><i></i><i></i><i></i><i></i></span>'
577
+ '<span class="g3" aria-current="true">'
578
+ '<i></i><i></i><i></i><i></i><i></i><i></i></span></div>'
579
+ )
580
+ body = (
581
+ f'<div class="wrap">{crumb}'
582
+ f'<div class="plp">{_filter_panel(base_path, params, selected)}'
583
+ f'<section>{head}<div class="plp-toolbar">'
584
+ f'<span data-testid="results-counter">{counter}</span>'
585
+ f'<span style="display:flex;gap:20px;align-items:center">{density}'
586
+ f'{render.sort_control(base_path, params, sort_by)}</span></div>'
587
+ f"{chips}{listing}</section></div></div>"
588
+ )
589
+ return respond(ctx, page(meta_title, body, ctx.state(conn)))
590
+
591
+
592
+ @app.get("/b/{slug:path}", response_class=HTMLResponse)
593
+ def category_page(slug: str, request: Request) -> Response:
594
+ ctx = Ctx(request)
595
+ if not ctx.account:
596
+ return _login_redirect(ctx, request)
597
+ entry = catalog.category(slug)
598
+ if entry is None:
599
+ return not_found(ctx)
600
+ meta = entry.get("meta_title") or entry["title"]
601
+ if entry.get("kind") == "accessories":
602
+ return _accessory_listing(ctx, entry["title"], meta)
603
+ return _listing_page(
604
+ ctx, request, base_path=f"/b/{slug}", title=entry["title"],
605
+ meta_title=f"{meta} | Zenni Optical", where=entry.get("where"),
606
+ slug=slug, lead=entry.get("lead"))
607
+
608
+
609
+ def _accessory_listing(ctx: Ctx, title: str, meta_title: str) -> Response:
610
+ """Accessories list without the frame facets the source also omits."""
611
+
612
+ cards = "".join(
613
+ render.accessory_card(item, "/b/accessories")
614
+ for item in accessories.accessories()
615
+ )
616
+ body = (
617
+ f'<div class="wrap"><h1 class="page">{escape(title)}</h1>'
618
+ f'<p class="muted">{len(accessories.accessories())} accessories</p>'
619
+ f'<div class="accessories">{cards}</div></div>'
620
+ )
621
+ return respond(ctx, page(f"{meta_title} | Zenni Optical", body,
622
+ ctx.state(connection())))
623
+
624
+
625
+ @app.get("/search", response_class=HTMLResponse)
626
+ def search(request: Request, keyphrase: str = "") -> Response:
627
+ ctx = Ctx(request)
628
+ if not ctx.account:
629
+ return _login_redirect(ctx, request)
630
+ conn = connection()
631
+ needle = keyphrase.strip()
632
+ target = catalog.SEARCH_REDIRECTS.get(needle.lower())
633
+ if target:
634
+ return redirect(ctx, f"/b/{target}", status=302)
635
+ result = catalog.query(keyphrase=needle) if needle else {
636
+ "items": [], "total": 0, "page": 1, "pages": 1}
637
+ if not result["items"]:
638
+ links = "".join(
639
+ f'<li><a href="{escape(href)}">{escape(text)}</a></li>'
640
+ for text, href in [
641
+ ("Shop All", "/b/all-glasses"),
642
+ ("Shop by Women", "/b/all-women-glasses"),
643
+ ("Shop by Men", "/b/all-men-glasses"),
644
+ ("Shop by Best Sellers", "/b/best-seller-glasses"),
645
+ ("Shop by Sunglasses", "/b/sunglasses"),
646
+ ("Shop by Under $30", "/b/glasses-under-30"),
647
+ ]
648
+ )
649
+ suggestions = catalog.query(sort_by="rating_desc")["items"][:6]
650
+ body = (
651
+ '<div class="wrap"><div class="empty">'
652
+ f"<h2>No results were found for “{escape(needle)}”</h2>"
653
+ "<p>Please try modifying your search term or feel free to browse "
654
+ "our top categories:</p>"
655
+ f'<ul style="list-style:none;padding:0">{links}</ul></div>'
656
+ '<h2 class="sec">You Might Also Like</h2>'
657
+ f'{render.product_grid(suggestions, store.favorites(conn, ctx.token))}'
658
+ "</div>"
659
+ )
660
+ return respond(ctx, page("Search Result | Zenni Optical", body,
661
+ ctx.state(conn)))
662
+ return _listing_page(
663
+ ctx, request, base_path="/search",
664
+ title=f"Search Results for “{needle}”",
665
+ meta_title="Search Result | Zenni Optical", keyphrase=needle)
666
+
667
+
668
+ @app.get("/p/{slug}/{product_id}/{sku}", response_class=HTMLResponse)
669
+ def product_detail(slug: str, product_id: str, sku: str,
670
+ request: Request, tab: str = "description") -> Response:
671
+ ctx = Ctx(request)
672
+ if not ctx.account:
673
+ return _login_redirect(ctx, request)
674
+ conn = connection()
675
+ found = catalog.find_sku(sku)
676
+ if not found or found[0]["product_id"] != product_id:
677
+ return not_found(ctx)
678
+ product, variant = found
679
+ kind = "Sunglasses" if product["category"] == "sunglasses" else "Glasses"
680
+ heading = f'{variant["color"]} {product["shape"]} {kind} #{sku}'
681
+ images = variant["images"]
682
+ order = [v for v in ("front", "side", "angle") if v in images]
683
+ hero = images[order[0]]
684
+ thumbs = "".join(
685
+ f'<button data-testid="{escape(view.title())} view of {kind} {sku} '
686
+ f'in {escape(variant["color"] or "")} thumbnail" '
687
+ f'aria-current="{"true" if index == 0 else "false"}">'
688
+ f'<img src="{escape(images[view])}" alt="{escape(view)} view">'
689
+ "</button>"
690
+ for index, view in enumerate(order)
691
+ )
692
+ swatches = "".join(
693
+ f'<a class="style_option{" style_active" if v["sku"] == sku else ""}" '
694
+ f'data-testid="color-option-{v["sku"]}" '
695
+ f'aria-label="Select {escape(v["color"] or "")} color" '
696
+ f'href="/p/{product["slug"]}/{product_id}/{v["sku"]}">'
697
+ f'{render.swatch(v["color"])}</a>'
698
+ for v in product["variants"]
699
+ )
700
+ tabs = "".join(
701
+ f'<a data-testid="tab-{key}" aria-current="{"true" if tab == key else "false"}" '
702
+ f'href="/p/{slug}/{product_id}/{sku}?tab={key}">{escape(label)}</a>'
703
+ for key, label in [("fitSize", "Fit & Size"),
704
+ ("features", "Features"),
705
+ ("description", "Description")]
706
+ )
707
+ if tab == "fitSize":
708
+ panel = (
709
+ f'<p>Frame width {product["frame_width"]}mm, lens height '
710
+ f'{product["frame_height"]}mm, weight {product["weight"]}g. '
711
+ f'Size {variant["size"]}.</p>'
712
+ )
713
+ elif tab == "features":
714
+ panel = (
715
+ "<ul><li>High-quality frame</li>"
716
+ "<li>Optimized premium lens</li><li>Anti-scratch coating</li>"
717
+ "<li>100% UV protection</li></ul>"
718
+ )
719
+ else:
720
+ panel = f'<p>{escape(product["description"] or "")}</p>'
721
+ faved = sku in store.favorites(conn, ctx.token)
722
+ here = f"/p/{slug}/{product_id}/{sku}"
723
+ addons = "".join(
724
+ render.accessory_card(item, here)
725
+ for item in accessories.suggestions(product_id)
726
+ )
727
+ review_panel = render.review_block(
728
+ product,
729
+ reviews.reviews(sku, product["rating"] or 0,
730
+ product["review_count"] or 0),
731
+ reviews.snapshot(product["rating"] or 0, product["review_count"] or 0),
732
+ reviews.averages(sku),
733
+ )
734
+ rating = ""
735
+ if product["rating"]:
736
+ # The source rounds the group rating to one decimal in this pill.
737
+ rating = (
738
+ f'<span class="rating-pill" data-testid="pdp-rating">'
739
+ f'<span aria-hidden="true">&#9733;</span>'
740
+ f'<strong>{product["rating"]:.1f}</strong>'
741
+ f'<a href="#pdp-reviews">{product["review_count"]} reviews</a>'
742
+ "</span>"
743
+ )
744
+ crumb = (
745
+ '<nav class="breadcrumb" aria-label="Breadcrumb">'
746
+ '<a href="/" aria-label="Home">&#8962;</a><span>&rsaquo;</span>'
747
+ f'<span>{escape(product["shape"])} '
748
+ f'{"Sunglasses" if product["category"] == "sunglasses" else "Glasses"} '
749
+ f'{sku}</span></nav>'
750
+ )
751
+ body = (
752
+ f'<div class="wrap">{crumb}<div class="pdp"><div class="pdp-media">'
753
+ f'<div class="pdp-stage">'
754
+ f'<form method="post" action="/favorites/toggle" class="pdp-fav">'
755
+ f'<input type="hidden" name="sku" value="{sku}">'
756
+ f'<input type="hidden" name="next" value="{escape(here)}">'
757
+ f'<button class="favorite-btn" data-testid="add-favorite-sku-{sku}" '
758
+ f'aria-pressed="{"true" if faved else "false"}" '
759
+ f'title="Add To My Favorite">{"&#9829;" if faved else "&#9825;"}'
760
+ f"</button></form>"
761
+ f'<button class="media-arrow left" '
762
+ f'data-testid="product-media-left-arrow" aria-label="Previous image">'
763
+ f"&lsaquo;</button>"
764
+ f'<div class="pdp-hero"><img src="{escape(hero)}" '
765
+ f'alt="{escape(heading)}"></div>'
766
+ f'<button class="media-arrow right" '
767
+ f'data-testid="product-media-right-arrow" aria-label="Next image">'
768
+ f"&rsaquo;</button></div>"
769
+ f'<div class="media-actions">'
770
+ f'<span class="round-btn" data-testid="product-360-degree-btn">'
771
+ f"360&deg;</span>"
772
+ f'<a class="zenbtn zenbtn-primary-outline" '
773
+ f'data-testid="vto-fitting-box-btn" href="/tryon?sku={sku}">Try On</a>'
774
+ f'<span class="round-btn" '
775
+ f'data-testid="product-ruler-front-measure-btn">&#8596;</span></div>'
776
+ f'<div class="pdp-thumbs">{thumbs}</div></div>'
777
+ f"<div><h1>{escape(heading)}</h1>"
778
+ f'<div class="price-row"><div>'
779
+ f'<p class="muted" style="margin:0">Starting at</p>'
780
+ f'<p class="pdp-price" style="margin:0">'
781
+ f'{money(float(variant["price"]))}</p></div>{rating}</div>'
782
+ f'<div class="pdp-card">'
783
+ f'<div class="row"><div><strong>Size:</strong> '
784
+ f'{variant["lens_width"]}mm frame width &middot; '
785
+ f'{variant["lens_height"]}mm lens height</div>'
786
+ f'<a class="linkbtn" data-testid="size-chart-link" '
787
+ f'href="/measure-eyeglass-frame-size-how-to">Size and fit</a></div>'
788
+ f'<span class="size-chip" data-testid="size-frame-type-tag">'
789
+ f'{escape(variant["size"] or "")}</span>'
790
+ f'<div style="margin-top:16px"><strong>Frame Color:</strong> '
791
+ f'<span data-testid="pdp-product-color">'
792
+ f'{escape(variant["color"] or "")}</span></div>'
793
+ f'<div class="swatch-row" style="margin-top:10px">{swatches}</div>'
794
+ f"</div>"
795
+ f'<p class="pdp-note muted">Shown with smoke gray gradient tint. '
796
+ f"(Additional charges apply)</p>"
797
+ f'<div class="rush-row" data-testid="rush-delivery">'
798
+ f'<span class="rush-pill">Rush Delivery</span>'
799
+ f'<label><input type="checkbox" name="rush" value="1"> '
800
+ f'<strong>{render.DELIVERY_ETA}</strong></label>'
801
+ f'<span class="muted">Rush Delivery starts at $19 '
802
+ f'<a class="linkbtn" href="/help/shipping-returns/shipping-delivery">'
803
+ f"See restrictions</a></span></div>"
804
+ f'<a class="zenbtn zenbtn-primary zenbtn-cta" '
805
+ f'data-testid="btn-pdp-enter-prescription" '
806
+ f'href="/orderProcess?productId={product_id}&skuId={sku}">'
807
+ f'Select Lens &amp; Tint</a>'
808
+ f'<div class="pdp-card"><div>Pay over time with PayPal, Affirm or '
809
+ f'Afterpay <a class="linkbtn" href="/c/faq">Learn More</a></div>'
810
+ f'<div style="margin-top:8px">Use your insurance or FSA/HSA benefits. '
811
+ f'<a class="linkbtn" href="/c/faq">Learn more</a></div></div>'
812
+ f"</div></div>"
813
+ f'<div class="tabs">{tabs}</div>'
814
+ f'<div class="tabpanel" role="tabpanel">{panel}</div>'
815
+ f'<div class="spec-grid">'
816
+ f'<div><dt>Material</dt><dd>{escape(product["material"] or "")}</dd></div>'
817
+ f'<div><dt>Shape</dt><dd>{escape(product["shape"])}</dd></div>'
818
+ f'<div><dt>Rim</dt><dd>{escape(product["rim"])}</dd></div>'
819
+ f'<div><dt>Gender</dt><dd>{escape(product["gender"])}</dd></div>'
820
+ f"</div>"
821
+ f'<h2 class="sec">Customers also bought</h2>'
822
+ f'<div class="accessories">{addons}</div>'
823
+ f'<h2 class="sec">You Might Also Like</h2>'
824
+ f'{render.product_grid(_related(product), store.favorites(conn, ctx.token))}'
825
+ f"{review_panel}</div>"
826
+ )
827
+ return respond(ctx, page(f"{heading} | Zenni Optical", body,
828
+ ctx.state(conn)))
829
+
830
+
831
+ def _related(product: dict[str, Any]) -> list[dict[str, Any]]:
832
+ same = [
833
+ other for other in catalog.products()
834
+ if other["product_id"] != product["product_id"]
835
+ and other["shape"] == product["shape"]
836
+ ]
837
+ if len(same) < 6:
838
+ same += [
839
+ other for other in catalog.products()
840
+ if other["product_id"] != product["product_id"] and other not in same
841
+ ]
842
+ return same[:6]
843
+
844
+
845
+ @app.get("/tryon", response_class=HTMLResponse)
846
+ def tryon(request: Request, sku: str = "") -> Response:
847
+ ctx = Ctx(request)
848
+ if not ctx.account:
849
+ return _login_redirect(ctx, request)
850
+ found = catalog.find_sku(sku) if sku else None
851
+ if not found:
852
+ return not_found(ctx)
853
+ product, variant = found
854
+ body = (
855
+ '<div class="wrap"><h1 class="page">Virtual Try-On</h1>'
856
+ '<div class="card"><p>This offline clone renders the frame preview '
857
+ "from the local product images instead of a camera capture. No photo "
858
+ "is requested, uploaded or stored.</p>"
859
+ f'<img style="max-width:520px" src="{escape(variant["images"].get("front", ""))}" '
860
+ f'alt="{escape(variant["color"] or "")} frame preview">'
861
+ f'<p><a class="zenbtn zenbtn-primary" '
862
+ f'href="/p/{product["slug"]}/{product["product_id"]}/{sku}">'
863
+ "Back to frame</a></p></div></div>"
864
+ )
865
+ return respond(ctx, page("Virtual Try-On | Zenni Optical", body,
866
+ ctx.state(connection())))
867
+
868
+
869
+ # --------------------------------------------------------------------------
870
+ # Lens configurator
871
+
872
+
873
+ def _wizard_config(params: dict[str, str]) -> dict[str, str]:
874
+ return {
875
+ key: params[key] for key in
876
+ ("usage", "lens_type", "tint", "lens_index", "coating", "engraving",
877
+ "warranty")
878
+ if params.get(key)
879
+ }
880
+
881
+
882
+ @app.get("/orderProcess", response_class=HTMLResponse)
883
+ def order_process(request: Request, productId: str = "", skuId: str = "",
884
+ screen: str = "prescription-type") -> Response:
885
+ ctx = Ctx(request)
886
+ if not ctx.account:
887
+ return _login_redirect(ctx, request)
888
+ found = catalog.find_sku(skuId)
889
+ if not found or found[0]["product_id"] != productId:
890
+ return not_found(ctx)
891
+ product, variant = found
892
+ params = dict(request.query_params)
893
+ config = _wizard_config(params)
894
+ if screen not in lenses.SCREENS or not lenses.screen_applies(screen, config):
895
+ screen = "prescription-type"
896
+ running = lenses.price(float(variant["price"]), config)
897
+
898
+ steps = "".join(
899
+ f'<li aria-current="{"step" if screen in screens else "false"}">'
900
+ f"{escape(label)}</li>"
901
+ for label, screens in lenses.STEP_LABELS
902
+ )
903
+
904
+ def keep(extra: dict[str, str]) -> str:
905
+ query = {"productId": productId, "skuId": skuId}
906
+ query.update(config)
907
+ query.update(extra)
908
+ return "?" + urlencode({k: v for k, v in query.items() if v})
909
+
910
+ heading, blurb, cards, primary = _wizard_screen(
911
+ screen, config, keep, productId, skuId)
912
+
913
+ previous = lenses.previous_screen(screen, config)
914
+ back = (
915
+ f'<a class="linkbtn" href="/orderProcess{keep({"screen": previous})}">'
916
+ "Previous Step</a>" if previous else
917
+ f'<a class="linkbtn" href="/p/{product["slug"]}/{productId}/{skuId}">'
918
+ "Back to Frame</a>"
919
+ )
920
+ summary_rows = "".join(
921
+ f'<div class="pdp-row"><span class="muted">{escape(label)}</span><br>'
922
+ f"{escape(value)}</div>"
923
+ for label, value in lenses.describe(config)
924
+ )
925
+ body = (
926
+ f'<div class="wrap"><div class="wizard"><section>'
927
+ f"<p>{back}</p>"
928
+ f'<ul class="steps">{steps}</ul>'
929
+ f'<h1 class="page">{escape(heading)}</h1>'
930
+ f'<p class="muted">{escape(blurb)}</p>'
931
+ f'<div class="cards">{cards}</div>{primary}</section>'
932
+ f'<aside class="summary-card">'
933
+ f'<img src="{escape(variant["images"].get("front", ""))}" '
934
+ f'alt="{escape(variant["color"] or "")} frame">'
935
+ f'<strong>{escape(product["shape"])} '
936
+ f'{"Sunglasses" if product["category"] == "sunglasses" else "Glasses"}'
937
+ f'</strong><span class="muted">{escape(variant["color"] or "")} '
938
+ f'&middot; {escape(variant["size"] or "")} &middot; {skuId}</span>'
939
+ f'<div class="pdp-row"><span class="muted">Price</span><br>'
940
+ f'<span class="pdp-price" data-testid="running-price">'
941
+ f"{money(running)}</span></div>{summary_rows}"
942
+ '<p class="muted">Shipping &amp; handling calculated at checkout</p>'
943
+ "</aside></div></div>"
944
+ )
945
+ return respond(ctx, page("Order Page | Zenni Optical", body,
946
+ ctx.state(connection())))
947
+
948
+
949
+ def _wizard_screen(screen: str, config: dict[str, str], keep,
950
+ product_id: str, sku: str) -> tuple[str, str, str, str]:
951
+ field = lenses.FIELD_FOR_SCREEN.get(screen)
952
+ headings = {
953
+ "prescription-type": ("How will you use your glasses?", ""),
954
+ "prescription": ("Enter your prescription",
955
+ "Values stay in this local database."),
956
+ "lens-type": ("What type of lens do you need ?", ""),
957
+ "sunglasses-lens-type": (
958
+ "Choose a Sunglass tint",
959
+ "All styles feature a fixed, all-day tint that stays dark indoors "
960
+ "and out."),
961
+ "lens-index": ("Select a lens index", ""),
962
+ "lens-coating": (
963
+ "Add a protective coating to your lenses",
964
+ "All our lenses meet the US standard for 100% UV protection "
965
+ "according to ANSI Z80.1, and come with scratch-resistant "
966
+ "coatings."),
967
+ "addon": ("Add Ons (optional)", "Complete your look with a engraving"),
968
+ "warranty": ("Protect your purchase (optional)",
969
+ "Add our extended warranty to protect your glasses for a "
970
+ "full year."),
971
+ }
972
+ heading, blurb = headings[screen]
973
+
974
+ if screen == "prescription":
975
+ following = lenses.next_screen(screen, config)
976
+ hidden = "".join(
977
+ f'<input type="hidden" name="{k}" value="{escape(v)}">'
978
+ for k, v in config.items())
979
+ cards = (
980
+ '<form method="get" action="/orderProcess" class="grid">'
981
+ f'<input type="hidden" name="productId" value="{product_id}">'
982
+ f'<input type="hidden" name="skuId" value="{sku}">'
983
+ f'<input type="hidden" name="screen" value="{following}">'
984
+ f"{hidden}"
985
+ '<label>OD (right) sphere<input name="od" value="-1.00"></label>'
986
+ '<label>OS (left) sphere<input name="os" value="-1.25"></label>'
987
+ '<label>Pupillary distance (PD)<input name="pd" value="63">'
988
+ "</label>"
989
+ '<div class="full"><button class="zenbtn zenbtn-primary '
990
+ 'zenbtn-large" data-testid="button-primary-screen-prescription">'
991
+ "Continue</button></div></form>"
992
+ )
993
+ return heading, blurb, cards, ""
994
+
995
+ if screen == "addon":
996
+ following = lenses.next_screen(screen, config)
997
+ hidden = "".join(
998
+ f'<input type="hidden" name="{k}" value="{escape(v)}">'
999
+ for k, v in config.items() if k != "engraving")
1000
+ cards = (
1001
+ '<form method="get" action="/orderProcess">'
1002
+ f'<input type="hidden" name="productId" value="{product_id}">'
1003
+ f'<input type="hidden" name="skuId" value="{sku}">'
1004
+ f'<input type="hidden" name="screen" value="{following}">'
1005
+ f"{hidden}"
1006
+ '<div class="productCardContainer" data-testid="engraving">'
1007
+ f'<span class="heading">Engraving</span> '
1008
+ f'<span class="muted">(From +{money(lenses.ENGRAVING_PRICE)})</span>'
1009
+ "<p>Add a personal touch with your name, a special message or a "
1010
+ "symbol to make your glasses unique.</p>"
1011
+ '<label>Engraving text<input name="engraving" maxlength="20" '
1012
+ f'value="{escape(config.get("engraving", ""))}"></label></div>'
1013
+ '<p><button class="zenbtn zenbtn-primary zenbtn-large" '
1014
+ 'data-testid="button-primary-screen-addon">Continue</button></p>'
1015
+ "</form>"
1016
+ )
1017
+ return heading, blurb, cards, ""
1018
+
1019
+ if screen == "warranty":
1020
+ hidden = "".join(
1021
+ f'<input type="hidden" name="{k}" value="{escape(v)}">'
1022
+ for k, v in config.items())
1023
+ cards = (
1024
+ f'<a class="productCardContainer" '
1025
+ f'href="/orderProcess{keep({"screen": "warranty", "warranty": "1"})}" '
1026
+ f'aria-pressed="{"true" if config.get("warranty") else "false"}">'
1027
+ f'<span class="heading">1-Year Extended Warranty</span> '
1028
+ f'<span class="muted">+{money(lenses.WARRANTY_PRICE)}</span>'
1029
+ "<p>Covers breaks, scratches, and daily wear for a full year, "
1030
+ "with one replacement pair included.</p></a>"
1031
+ )
1032
+ primary = (
1033
+ '<form method="post" action="/cart/add">'
1034
+ f'<input type="hidden" name="sku" value="{sku}">'
1035
+ f"{hidden}"
1036
+ '<button class="zenbtn zenbtn-primary zenbtn-large" '
1037
+ 'data-testid="button-primary-screen-warranty">Add to cart</button>'
1038
+ "</form>"
1039
+ )
1040
+ return heading, blurb, cards, primary
1041
+
1042
+ following = lenses.next_screen(screen, config)
1043
+ prefix = {
1044
+ "lens-index": "lens-index-card-",
1045
+ "lens-coating": "lens-coating-card-",
1046
+ }.get(screen, "")
1047
+
1048
+ def option_card(option: dict[str, Any]) -> str:
1049
+ chips = "".join(
1050
+ f'<span class="muted">{escape(option[key])}</span><br>'
1051
+ for key in ("tag", "flag") if option.get(key)
1052
+ )
1053
+ extra = (
1054
+ f' <span class="muted">+{money(option["price"])}</span>'
1055
+ if option["price"] else ""
1056
+ )
1057
+ pressed = "true" if config.get(field) == option["id"] else "false"
1058
+ href = keep({field: option["id"], "screen": screen})
1059
+ return (
1060
+ f'<a class="productCardContainer" '
1061
+ f'data-testid="{prefix}{option["id"]}" aria-pressed="{pressed}" '
1062
+ f'href="/orderProcess{href}">{chips}'
1063
+ f'<span class="heading" data-testid="heading-{option["id"]}">'
1064
+ f'{escape(option["heading"])}</span>{extra}'
1065
+ f'<p>{escape(option["body"])}</p></a>'
1066
+ )
1067
+
1068
+ cards = "".join(option_card(o) for o in lenses.options_for(screen))
1069
+ disabled = "" if config.get(field) else " disabled"
1070
+ primary = (
1071
+ f'<a class="zenbtn zenbtn-primary zenbtn-large" '
1072
+ f'data-testid="button-primary-screen-{screen}" '
1073
+ f'href="/orderProcess{keep({"screen": following})}"{disabled}>'
1074
+ "Continue</a>"
1075
+ if config.get(field) else
1076
+ f'<span class="zenbtn zenbtn-primary zenbtn-large" '
1077
+ f'data-testid="button-primary-screen-{screen}" aria-disabled="true">'
1078
+ "Continue</span>"
1079
+ )
1080
+ return heading, blurb, cards, primary
1081
+
1082
+
1083
+ # --------------------------------------------------------------------------
1084
+ # Cart, checkout and favourites
1085
+
1086
+
1087
+ @app.post("/cart/add")
1088
+ def cart_add(request: Request, sku: str = Form(...), usage: str = Form(""),
1089
+ lens_type: str = Form(""), tint: str = Form(""),
1090
+ lens_index: str = Form(""), coating: str = Form(""),
1091
+ engraving: str = Form(""), warranty: str = Form("")) -> Response:
1092
+ ctx = Ctx(request)
1093
+ if not ctx.account:
1094
+ return _login_redirect(ctx, request)
1095
+ found = catalog.find_sku(sku)
1096
+ if not found:
1097
+ return not_found(ctx)
1098
+ _, variant = found
1099
+ config = {"usage": usage, "lens_type": lens_type, "tint": tint,
1100
+ "lens_index": lens_index, "coating": coating,
1101
+ "engraving": engraving, "warranty": bool(warranty)}
1102
+ unit = lenses.price(float(variant["price"]), {
1103
+ k: v for k, v in config.items() if v})
1104
+ store.add_to_cart(connection(), ctx.token, ctx.subject_id, sku, config,
1105
+ unit)
1106
+ return redirect(ctx, "/shoppingCart")
1107
+
1108
+
1109
+ @app.post("/cart/add-accessory")
1110
+ def cart_add_accessory(request: Request, sku: str = Form(...),
1111
+ next: str = Form("/shoppingCart")) -> Response:
1112
+ """Accessories skip the lens builder, exactly as they do on the source."""
1113
+
1114
+ ctx = Ctx(request)
1115
+ if not ctx.account:
1116
+ return _login_redirect(ctx, request)
1117
+ item = accessories.find(sku)
1118
+ if not item:
1119
+ return not_found(ctx)
1120
+ store.add_to_cart(
1121
+ connection(), ctx.token, ctx.subject_id, sku,
1122
+ {"usage": "accessory", "lens_type": "", "tint": None,
1123
+ "lens_index": "", "coating": "", "engraving": "", "warranty": False},
1124
+ float(item["price"]))
1125
+ return redirect(ctx, next or "/shoppingCart")
1126
+
1127
+
1128
+ @app.post("/cart/update")
1129
+ def cart_update(request: Request, item_id: int = Form(...),
1130
+ quantity: int = Form(...)) -> Response:
1131
+ ctx = Ctx(request)
1132
+ store.set_quantity(connection(), ctx.token, item_id, quantity)
1133
+ return redirect(ctx, "/shoppingCart")
1134
+
1135
+
1136
+ @app.post("/cart/remove")
1137
+ def cart_remove(request: Request, item_id: int = Form(...)) -> Response:
1138
+ ctx = Ctx(request)
1139
+ store.remove_item(connection(), ctx.token, item_id)
1140
+ return redirect(ctx, "/shoppingCart")
1141
+
1142
+
1143
+ @app.get("/shoppingCart", response_class=HTMLResponse)
1144
+ def shopping_cart(request: Request) -> Response:
1145
+ ctx = Ctx(request)
1146
+ if not ctx.account:
1147
+ return _login_redirect(ctx, request)
1148
+ conn = connection()
1149
+ items = store.cart_items(conn, ctx.token)
1150
+ if not items:
1151
+ body = (
1152
+ '<div class="wrap"><h1 class="page">Shopping Cart</h1>'
1153
+ '<div class="empty"><h2>Your shopping cart is empty.</h2>'
1154
+ "<p>You have no items in your shopping cart.</p>"
1155
+ '<p><a class="zenbtn zenbtn-primary zenbtn-large" '
1156
+ 'href="/b/sunglasses">Start shopping</a></p></div></div>'
1157
+ )
1158
+ return respond(ctx, page("Shopping Cart | Zenni Optical", body,
1159
+ ctx.state(conn)))
1160
+
1161
+ rows = []
1162
+ for item in items:
1163
+ if item["kind"] == "accessory":
1164
+ rows.append(_accessory_cart_row(item))
1165
+ continue
1166
+ product, variant = item["product"], item["variant"]
1167
+ config_rows = "".join(
1168
+ f'<div class="muted">{escape(label)}: {escape(value)}</div>'
1169
+ for label, value in lenses.describe(
1170
+ {k: v for k, v in item["config"].items() if v})
1171
+ )
1172
+ rows.append(
1173
+ f'<article class="cart-item" data-testid="cart-item-{item["id"]}">'
1174
+ f'<img src="{escape(variant["images"].get("front", ""))}" '
1175
+ f'alt="{escape(variant["color"] or "")} frame">'
1176
+ f"<div><strong data-testid=\"cart-item-product-name\">"
1177
+ f'{escape(variant["color"] or "")} {escape(product["shape"])} '
1178
+ f'{"Sunglasses" if product["category"] == "sunglasses" else "Glasses"} '
1179
+ f'{item["sku"]}</strong>{config_rows}'
1180
+ f'<div class="cart-item-actions" data-testid="cart-item-actions" '
1181
+ f'style="margin-top:10px;display:flex;gap:14px;align-items:center">'
1182
+ f'<form method="post" action="/cart/update" class="qty">'
1183
+ f'<input type="hidden" name="item_id" value="{item["id"]}">'
1184
+ f'<button name="quantity" value="{item["quantity"] - 1}" '
1185
+ f'data-testid="quantity-minus" aria-label="Decrease quantity">'
1186
+ f"&minus;</button>"
1187
+ f'<span>{item["quantity"]}</span>'
1188
+ f'<button name="quantity" value="{item["quantity"] + 1}" '
1189
+ f'data-testid="quantity-plus" aria-label="Increase quantity">'
1190
+ f"+</button></form>"
1191
+ f'<a class="linkbtn" data-testid="cart-item-edit-button" '
1192
+ f'href="/orderProcess?productId={product["product_id"]}'
1193
+ f'&skuId={item["sku"]}">Edit</a>'
1194
+ f'<form method="post" action="/cart/remove">'
1195
+ f'<input type="hidden" name="item_id" value="{item["id"]}">'
1196
+ f'<button class="linkbtn" data-testid="cart-item-remove-button">'
1197
+ f"Remove</button></form></div></div>"
1198
+ f'<div style="text-align:right"><strong>'
1199
+ f'{money(item["line_total"])}</strong></div></article>'
1200
+ )
1201
+
1202
+ subtotal = round(sum(item["line_total"] for item in items), 2)
1203
+ shipping = 0.0 if subtotal >= 65 else 4.95
1204
+ in_cart = {item["sku"] for item in items}
1205
+ upsell = "".join(
1206
+ render.accessory_card(entry, "/shoppingCart")
1207
+ for entry in accessories.suggestions(items[0]["sku"], count=3)
1208
+ if entry["sku"] not in in_cart
1209
+ )
1210
+ body = (
1211
+ f'<div class="wrap"><h1 class="page">Shopping Cart</h1>'
1212
+ f'<div class="cart"><section>{"".join(rows)}</section>'
1213
+ f'<aside class="summary-card"><h2 style="margin:0">Order Summary</h2>'
1214
+ f'<div class="pdp-row">Subtotal<strong style="float:right">'
1215
+ f"{money(subtotal)}</strong></div>"
1216
+ f'<div class="pdp-row">Shipping<strong style="float:right">'
1217
+ f'{"Free" if shipping == 0 else money(shipping)}</strong></div>'
1218
+ f'<p class="muted">Free standard shipping on orders $65+</p>'
1219
+ f'<a class="zenbtn zenbtn-primary zenbtn-large" '
1220
+ f'data-testid="checkout-button" href="/orderCheckout">Checkout</a>'
1221
+ f"</aside></div>"
1222
+ f'<h2 class="sec">Add an accessory</h2>'
1223
+ f'<div class="accessories">{upsell}</div></div>'
1224
+ )
1225
+ return respond(ctx, page("Shopping Cart | Zenni Optical", body,
1226
+ ctx.state(conn)))
1227
+
1228
+
1229
+ def _accessory_cart_row(item: dict[str, Any]) -> str:
1230
+ """Accessory lines carry no lens configuration, so they show no Edit link."""
1231
+
1232
+ accessory = item["accessory"]
1233
+ return (
1234
+ f'<article class="cart-item" data-testid="cart-item-{item["id"]}">'
1235
+ f'<img src="{escape(accessory["image"])}" '
1236
+ f'alt="{escape(accessory["name"])}">'
1237
+ f'<div><strong data-testid="cart-item-product-name">'
1238
+ f'{escape(accessory["name"])} {item["sku"]}</strong>'
1239
+ f'<div class="muted">Accessory</div>'
1240
+ f'<div class="cart-item-actions" data-testid="cart-item-actions" '
1241
+ f'style="margin-top:10px;display:flex;gap:14px;align-items:center">'
1242
+ f'<form method="post" action="/cart/update" class="qty">'
1243
+ f'<input type="hidden" name="item_id" value="{item["id"]}">'
1244
+ f'<button name="quantity" value="{item["quantity"] - 1}" '
1245
+ f'data-testid="quantity-minus" aria-label="Decrease quantity">'
1246
+ f"&minus;</button><span>{item['quantity']}</span>"
1247
+ f'<button name="quantity" value="{item["quantity"] + 1}" '
1248
+ f'data-testid="quantity-plus" aria-label="Increase quantity">+</button>'
1249
+ f"</form>"
1250
+ f'<form method="post" action="/cart/remove">'
1251
+ f'<input type="hidden" name="item_id" value="{item["id"]}">'
1252
+ f'<button class="linkbtn" data-testid="cart-item-remove-button">'
1253
+ f"Remove</button></form></div></div>"
1254
+ f'<div style="text-align:right"><strong>'
1255
+ f'{money(item["line_total"])}</strong></div></article>'
1256
+ )
1257
+
1258
+
1259
+ @app.post("/favorites/toggle")
1260
+ def favorites_toggle(request: Request, sku: str = Form(...),
1261
+ next: str = Form("/")) -> Response:
1262
+ ctx = Ctx(request)
1263
+ if not ctx.account:
1264
+ return _login_redirect(ctx, request)
1265
+ store.toggle_favorite(connection(), ctx.token, ctx.subject_id, sku)
1266
+ return redirect(ctx, next or "/")
1267
+
1268
+
1269
+ @app.get("/anonymousFavorites", response_class=HTMLResponse)
1270
+ def anonymous_favorites(request: Request) -> Response:
1271
+ ctx = Ctx(request)
1272
+ if ctx.account:
1273
+ return redirect(ctx, "/myAccount/myFavorites")
1274
+ body = (
1275
+ '<div class="wrap"><h1 class="page">Favorites</h1>'
1276
+ '<div class="empty"><h2>No Saved Favorites</h2>'
1277
+ "<p>Sign in to save items you love and access them here anytime.</p>"
1278
+ '<p><a class="zenbtn zenbtn-primary zenbtn-large" href="/login">'
1279
+ "Sign in</a></p></div></div>"
1280
+ )
1281
+ return respond(ctx, page("Favorites | Zenni Optical", body,
1282
+ ctx.state(connection())))
1283
+
1284
+
1285
+ US_STATES = ["CA", "NY", "TX", "WA", "IL", "FL", "MA", "CO", "OR", "NV"]
1286
+
1287
+
1288
+ @app.get("/orderCheckout", response_class=HTMLResponse)
1289
+ def checkout(request: Request, error: str = "") -> Response:
1290
+ ctx = Ctx(request)
1291
+ if not ctx.account:
1292
+ return _login_redirect(ctx, request)
1293
+ conn = connection()
1294
+ items = store.cart_items(conn, ctx.token)
1295
+ if not items:
1296
+ return redirect(ctx, "/shoppingCart")
1297
+ subtotal = round(sum(item["line_total"] for item in items), 2)
1298
+ shipping = 0.0 if subtotal >= 65 else 4.95
1299
+ tax = round(subtotal * 0.0725, 2)
1300
+ scenarios = "".join(
1301
+ f'<option value="{escape(entry["id"])}">{escape(entry["display_label"])}'
1302
+ "</option>"
1303
+ for entry in BACKEND.payments.runtime.payments["local_sandbox"]["scenarios"]
1304
+ )
1305
+ states = "".join(f"<option>{code}</option>" for code in US_STATES)
1306
+ banner = f'<p class="flash error">{escape(error)}</p>' if error else ""
1307
+ body = (
1308
+ f'<div class="wrap"><h1 class="page">Checkout</h1>{banner}'
1309
+ f'<div class="cart"><form method="post" action="/orderCheckout">'
1310
+ f"<fieldset><legend>Shipping</legend>"
1311
+ f'<div class="grid" style="display:grid;grid-template-columns:1fr 1fr;'
1312
+ f'gap:16px">'
1313
+ f'<label>Firstname<input name="firstName" required></label>'
1314
+ f'<label>Lastname<input name="lastName" required></label>'
1315
+ f'<label style="grid-column:1/-1">Address'
1316
+ f'<input name="address1" required></label>'
1317
+ f'<label>City<input name="city" required></label>'
1318
+ f'<label>State/Province<select name="stateDropdown">{states}</select>'
1319
+ f"</label>"
1320
+ f'<label>Zip code<input name="postalCode" required></label>'
1321
+ f'<label>Phone<input name="phoneNumber" type="tel"></label>'
1322
+ f"</div></fieldset>"
1323
+ f"<fieldset><legend>Payment</legend>"
1324
+ f'<p class="sandbox">This clone uses the local sandbox payment '
1325
+ f"adapter. No card number is requested, transmitted or stored.</p>"
1326
+ f'<label>Sandbox scenario<select name="scenario">{scenarios}</select>'
1327
+ f"</label></fieldset>"
1328
+ f'<button class="zenbtn zenbtn-primary zenbtn-large" '
1329
+ f'data-testid="place-order">Place order</button></form>'
1330
+ f'<aside class="summary-card"><h2 style="margin:0">Order Summary</h2>'
1331
+ f'<div class="pdp-row">Subtotal<strong style="float:right">'
1332
+ f"{money(subtotal)}</strong></div>"
1333
+ f'<div class="pdp-row">Shipping<strong style="float:right">'
1334
+ f'{"Free" if shipping == 0 else money(shipping)}</strong></div>'
1335
+ f'<div class="pdp-row">Estimated tax<strong style="float:right">'
1336
+ f"{money(tax)}</strong></div>"
1337
+ f'<div class="pdp-row"><strong>Order total</strong>'
1338
+ f'<strong style="float:right">{money(subtotal + shipping + tax)}'
1339
+ f"</strong></div></aside></div></div>"
1340
+ )
1341
+ return respond(ctx, page("Checkout | Zenni Optical", body,
1342
+ ctx.state(conn)))
1343
+
1344
+
1345
+ @app.post("/orderCheckout")
1346
+ def checkout_submit(request: Request, firstName: str = Form(...),
1347
+ lastName: str = Form(...), address1: str = Form(...),
1348
+ city: str = Form(...), stateDropdown: str = Form(...),
1349
+ postalCode: str = Form(...), phoneNumber: str = Form(""),
1350
+ scenario: str = Form("sandbox-approved")) -> Response:
1351
+ ctx = Ctx(request)
1352
+ if not ctx.account:
1353
+ return _login_redirect(ctx, request)
1354
+ conn = connection()
1355
+ items = store.cart_items(conn, ctx.token)
1356
+ if not items:
1357
+ return redirect(ctx, "/shoppingCart")
1358
+ total = round(sum(item["line_total"] for item in items), 2)
1359
+ owner = f"shopper:{ctx.subject_id or ctx.token}"[:240]
1360
+ amount_minor = int(round(total * 100))
1361
+ # Cart row ids are unique per add, so a genuinely new cart yields a new
1362
+ # fingerprint while a resubmitted form replays the same one.
1363
+ basis = "|".join(
1364
+ [owner, str(amount_minor), scenario]
1365
+ + [f'{item["id"]}:{item["sku"]}x{item["quantity"]}' for item in items]
1366
+ )
1367
+ fingerprint = hashlib.sha256(basis.encode("utf-8")).hexdigest()
1368
+ key = f"checkout.{fingerprint[:32]}"
1369
+ try:
1370
+ intent = BACKEND.payments.create_intent(
1371
+ owner=owner, amount_minor=amount_minor, currency="USD",
1372
+ fingerprint=fingerprint, idempotency_key=f"intent.{key}")
1373
+ outcome = BACKEND.payments.attempt(
1374
+ flow_id=intent["flow_id"], owner=owner,
1375
+ amount_minor=amount_minor, currency="USD",
1376
+ fingerprint=fingerprint, scenario_id=scenario,
1377
+ idempotency_key=f"attempt.{key}")
1378
+ approved = outcome.get("status") == "APPROVED"
1379
+ except PaymentRejected:
1380
+ approved = False
1381
+ if not approved:
1382
+ return redirect(
1383
+ ctx,
1384
+ "/orderCheckout?" + urlencode(
1385
+ {"error": "Sandbox payment was declined. "
1386
+ "Choose another scenario to continue."}),
1387
+ )
1388
+ # Consume the approval inside the same transaction that writes the order,
1389
+ # so a replayed submit cannot produce a second order.
1390
+ conn.execute("BEGIN IMMEDIATE")
1391
+ try:
1392
+ BACKEND.payments.consume_approval(
1393
+ conn, flow_id=intent["flow_id"], owner=owner,
1394
+ amount_minor=amount_minor, currency="USD",
1395
+ fingerprint=fingerprint)
1396
+ conn.commit()
1397
+ except Exception:
1398
+ conn.rollback()
1399
+ return redirect(
1400
+ ctx,
1401
+ "/orderCheckout?" + urlencode(
1402
+ {"error": "That payment was already used. "
1403
+ "Start a new checkout to continue."}),
1404
+ )
1405
+ ship_to = {"firstName": firstName, "lastName": lastName,
1406
+ "address1": address1, "city": city, "state": stateDropdown,
1407
+ "postalCode": postalCode, "phone": phoneNumber}
1408
+ order_number = store.place_order(
1409
+ conn, ctx.token, ctx.subject_id, items, ship_to, scenario)
1410
+ if ctx.subject_id:
1411
+ store.add_address(conn, ctx.subject_id, {
1412
+ "firstName": firstName, "lastName": lastName,
1413
+ "address1": address1, "city": city,
1414
+ "stateDropdown": stateDropdown, "postalCode": postalCode,
1415
+ "phoneNumber": phoneNumber})
1416
+ store.clear_cart(conn, ctx.token)
1417
+ return redirect(ctx, f"/orderConfirmation?order={order_number}")
1418
+
1419
+
1420
+ @app.get("/orderConfirmation", response_class=HTMLResponse)
1421
+ def order_confirmation(request: Request, order: str = "") -> Response:
1422
+ ctx = Ctx(request)
1423
+ conn = connection()
1424
+ if not order:
1425
+ return redirect(ctx, "/myAccount/myOrders")
1426
+ record = store.find_order(conn, order)
1427
+ if not record:
1428
+ return not_found(ctx)
1429
+ body = (
1430
+ f'<div class="wrap"><h1 class="page">Thank you for your order</h1>'
1431
+ f'<div class="card"><p>Order number <strong>'
1432
+ f'{escape(record["order_number"])}</strong></p>'
1433
+ f'<p>Status: {escape(record["status"])}</p>'
1434
+ f'<p>Total: {money(record["total"])}</p>'
1435
+ f'<p class="muted">Recorded in this site\'s local ledger only.</p>'
1436
+ f'<p><a class="zenbtn zenbtn-primary" href="/myAccount/myOrders">'
1437
+ f"View my orders</a></p></div></div>"
1438
+ )
1439
+ return respond(ctx, page("Order Confirmation | Zenni Optical", body,
1440
+ ctx.state(conn)))
1441
+
1442
+
1443
+ @app.get("/trackOrder", response_class=HTMLResponse)
1444
+ def track_order(request: Request, order: str = "") -> Response:
1445
+ ctx = Ctx(request)
1446
+ conn = connection()
1447
+ record = store.find_order(conn, order) if order else None
1448
+ if order and not record:
1449
+ result = '<p class="flash error">No order matches that number.</p>'
1450
+ elif record:
1451
+ result = (
1452
+ f'<div class="card"><strong>{escape(record["order_number"])}'
1453
+ f'</strong><p>Status: {escape(record["status"])}</p>'
1454
+ f'<p>Placed {escape(record["placed_at"])}</p>'
1455
+ f'<p>Total {money(record["total"])}</p></div>'
1456
+ )
1457
+ else:
1458
+ result = ""
1459
+ body = (
1460
+ f'<div class="wrap"><h1 class="page">Track My Order</h1>'
1461
+ f'<form method="get" action="/trackOrder" class="grid">'
1462
+ f'<label class="full">Order number'
1463
+ f'<input name="order" value="{escape(order)}" placeholder="ZO1000001">'
1464
+ f"</label>"
1465
+ f'<div class="full"><button class="zenbtn zenbtn-primary">Track'
1466
+ f"</button></div></form>{result}</div>"
1467
+ )
1468
+ return respond(ctx, page("Track My Order | Zenni Optical", body,
1469
+ ctx.state(conn)))
1470
+
1471
+
1472
+ # --------------------------------------------------------------------------
1473
+ # Account
1474
+
1475
+
1476
+ def _account_nav(current: str) -> str:
1477
+ blocks = []
1478
+ for title, links in nav.ACCOUNT_NAV:
1479
+ items = "".join(
1480
+ f'<li><a href="{escape(href)}" '
1481
+ f'aria-current="{"page" if href == current else "false"}">'
1482
+ f"{escape(text)}</a></li>"
1483
+ for text, href in links
1484
+ )
1485
+ blocks.append(f"<h4>{escape(title)}</h4><ul>{items}</ul>")
1486
+ blocks.append(
1487
+ "<h4>Help &amp; Support</h4><ul>"
1488
+ '<li><a href="/help">Help Center</a></li>'
1489
+ '<li><form method="post" action="/logout">'
1490
+ '<button class="linkbtn">Sign Out</button></form></li></ul>'
1491
+ )
1492
+ return f'<nav>{"".join(blocks)}</nav>'
1493
+
1494
+
1495
+ def _account_page(ctx: Ctx, request: Request, current: str, title: str,
1496
+ inner: str) -> Response:
1497
+ body = (
1498
+ f'<div class="wrap"><h1 class="page">My Account</h1>'
1499
+ f'<div class="account">{_account_nav(current)}'
1500
+ f"<section>{inner}</section></div></div>"
1501
+ )
1502
+ return respond(ctx, page(f"{title} | Zenni Optical", body,
1503
+ ctx.state(connection())))
1504
+
1505
+
1506
+ @app.get("/myAccount/myDashBoard", response_class=HTMLResponse)
1507
+ def account_dashboard(request: Request) -> Response:
1508
+ ctx = Ctx(request)
1509
+ if not ctx.account:
1510
+ return _login_redirect(ctx, request)
1511
+ conn = connection()
1512
+ order_list = store.orders(conn, ctx.subject_id, ctx.token)
1513
+ scripts = store.prescriptions(conn, ctx.subject_id or "")
1514
+ spent = round(sum(o["total"] for o in order_list), 2)
1515
+ tiers = "".join(
1516
+ f"<div><strong>{escape(name)}</strong><br>"
1517
+ f'<span class="muted">{escape(threshold)}</span></div>'
1518
+ for name, threshold in [("Fan", "Starter"), ("Friend", "$150+"),
1519
+ ("VIP", "$250+"), ("Icon", "$500+")]
1520
+ )
1521
+ orders_block = (
1522
+ f"<p>{len(order_list)} order(s) placed.</p>"
1523
+ f'<a class="zenbtn zenbtn-primary-outline" href="/myAccount/myOrders">'
1524
+ "View orders</a>"
1525
+ if order_list else
1526
+ "<h2>No Orders Yet</h2><p>View and manage your orders here after "
1527
+ 'making a purchase.</p><a class="zenbtn zenbtn-primary" '
1528
+ 'href="/b/sunglasses">Start Shopping</a>'
1529
+ )
1530
+ scripts_block = (
1531
+ f"<p>{len(scripts)} saved prescription(s).</p>"
1532
+ if scripts else
1533
+ "<h2>No Saved Prescriptions</h2><p>Keep your glasses prescription on "
1534
+ "file with us for quick and easy reordering.</p>"
1535
+ '<a class="zenbtn zenbtn-primary-outline" '
1536
+ 'href="/myAccount/myPrescription">Add Prescription</a>'
1537
+ )
1538
+ inner = (
1539
+ f'<div class="card"><h2 style="margin-top:0">Hi, '
1540
+ f'{escape(ctx.display_name)}</h2>'
1541
+ f'<p class="muted">Store Credit: $0.00</p></div>'
1542
+ f'<div class="card"><h2 style="margin-top:0">Zenni Rewards</h2>'
1543
+ f"<p>Status: Fan &middot; Points: 0 ($0 value) &middot; "
1544
+ f"Total Spent: {money(spent)}</p>"
1545
+ f'<div class="tiers">{tiers}</div></div>'
1546
+ f'<div class="card">{orders_block}</div>'
1547
+ f'<div class="card">{scripts_block}</div>'
1548
+ )
1549
+ return _account_page(ctx, request, "/myAccount/myDashBoard", "My Account",
1550
+ inner)
1551
+
1552
+
1553
+ @app.get("/myAccount/myOrders", response_class=HTMLResponse)
1554
+ def account_orders(request: Request) -> Response:
1555
+ ctx = Ctx(request)
1556
+ if not ctx.account:
1557
+ return _login_redirect(ctx, request)
1558
+ conn = connection()
1559
+ order_list = store.orders(conn, ctx.subject_id, ctx.token)
1560
+ if not order_list:
1561
+ inner = (
1562
+ '<div class="empty"><h2>No Orders Yet</h2>'
1563
+ "<p>View and manage your orders here after making a purchase.</p>"
1564
+ '<a class="zenbtn zenbtn-primary" href="/b/sunglasses">'
1565
+ "Start Shopping</a></div>"
1566
+ )
1567
+ else:
1568
+ cards = []
1569
+ for record in order_list:
1570
+ lines = "".join(
1571
+ f"<li>{escape(line['found'][1]['color'] or '')} "
1572
+ f"{escape(line['found'][0]['shape'])} &times;"
1573
+ f"{line['quantity']} &mdash; {money(line['unit_price'])}</li>"
1574
+ for line in record["lines"] if line["found"]
1575
+ )
1576
+ cards.append(
1577
+ f'<div class="card"><strong>{escape(record["order_number"])}'
1578
+ f'</strong> <span class="muted">{escape(record["placed_at"])}'
1579
+ f'</span><p>Status: {escape(record["status"])}</p>'
1580
+ f"<ul>{lines}</ul>"
1581
+ f"<p>Subtotal {money(record['subtotal'])} &middot; "
1582
+ f"Shipping {money(record['shipping'])} &middot; "
1583
+ f"Tax {money(record['tax'])} &middot; "
1584
+ f"<strong>Total {money(record['total'])}</strong></p>"
1585
+ f'<a class="linkbtn" href="/trackOrder?order='
1586
+ f'{escape(record["order_number"])}">Track this order</a></div>'
1587
+ )
1588
+ inner = "".join(cards)
1589
+ return _account_page(ctx, request, "/myAccount/myOrders", "Orders", inner)
1590
+
1591
+
1592
+ @app.get("/myAccount/myFavorites", response_class=HTMLResponse)
1593
+ def account_favorites(request: Request) -> Response:
1594
+ ctx = Ctx(request)
1595
+ if not ctx.account:
1596
+ return _login_redirect(ctx, request)
1597
+ conn = connection()
1598
+ saved = store.favorites(conn, ctx.token)
1599
+ products = [
1600
+ catalog.find_sku(sku)[0] for sku in saved if catalog.find_sku(sku)
1601
+ ]
1602
+ unique = {p["product_id"]: p for p in products}
1603
+ if not unique:
1604
+ inner = (
1605
+ '<div class="empty"><h2>No Saved Favorites</h2>'
1606
+ "<p>Save items you love to your favorites list and access them "
1607
+ 'here anytime.</p><a class="zenbtn zenbtn-primary" '
1608
+ 'href="/b/sunglasses">Show now</a></div>'
1609
+ )
1610
+ else:
1611
+ inner = render.product_grid(list(unique.values()), saved)
1612
+ return _account_page(ctx, request, "/myAccount/myFavorites", "Favorites",
1613
+ inner)
1614
+
1615
+
1616
+ @app.get("/myAccount/myPrescription", response_class=HTMLResponse)
1617
+ def account_prescription(request: Request) -> Response:
1618
+ ctx = Ctx(request)
1619
+ if not ctx.account:
1620
+ return _login_redirect(ctx, request)
1621
+ conn = connection()
1622
+ saved = store.prescriptions(conn, ctx.subject_id or "")
1623
+ rows = "".join(
1624
+ f'<div class="card"><strong>{escape(row["label"])}</strong>'
1625
+ f'<p>OD {escape(row["od_sphere"])} &middot; OS '
1626
+ f'{escape(row["os_sphere"])} &middot; PD {escape(row["pd"])}</p></div>'
1627
+ for row in saved
1628
+ )
1629
+ inner = (
1630
+ (rows or '<div class="empty"><h2>No Saved Prescriptions</h2>'
1631
+ "<p>Keep your glasses prescription on file with us for quick "
1632
+ "and easy reordering.</p></div>")
1633
+ + '<div class="card"><h2 style="margin-top:0">Add Prescription</h2>'
1634
+ '<form method="post" action="/myAccount/myPrescription" class="grid">'
1635
+ '<label>Label<input name="label" required value="My prescription">'
1636
+ "</label>"
1637
+ '<label>PD<input name="pd" required value="63"></label>'
1638
+ '<label>OD sphere<input name="od" required value="-1.00"></label>'
1639
+ '<label>OS sphere<input name="os" required value="-1.25"></label>'
1640
+ '<div class="full"><button class="zenbtn zenbtn-primary">Save'
1641
+ "</button></div></form></div>"
1642
+ )
1643
+ return _account_page(ctx, request, "/myAccount/myPrescription",
1644
+ "My Prescription", inner)
1645
+
1646
+
1647
+ @app.post("/myAccount/myPrescription")
1648
+ def account_prescription_add(request: Request, label: str = Form(...),
1649
+ od: str = Form(...), os: str = Form(...),
1650
+ pd: str = Form(...)) -> Response:
1651
+ ctx = Ctx(request)
1652
+ if not ctx.account:
1653
+ return _login_redirect(ctx, request)
1654
+ store.add_prescription(connection(), ctx.subject_id or "", label, od, os,
1655
+ pd)
1656
+ return redirect(ctx, "/myAccount/myPrescription")
1657
+
1658
+
1659
+ @app.get("/myAccount/addressBook", response_class=HTMLResponse)
1660
+ def account_addresses(request: Request) -> Response:
1661
+ ctx = Ctx(request)
1662
+ if not ctx.account:
1663
+ return _login_redirect(ctx, request)
1664
+ conn = connection()
1665
+ saved = store.addresses(conn, ctx.subject_id or "")
1666
+ rows = "".join(
1667
+ f'<div class="card"><strong>{escape(row["first_name"])} '
1668
+ f'{escape(row["last_name"])}</strong><p>{escape(row["address1"])}<br>'
1669
+ f'{escape(row["city"])}, {escape(row["state"])} '
1670
+ f'{escape(row["postal_code"])}</p></div>'
1671
+ for row in saved
1672
+ )
1673
+ states = "".join(f"<option>{code}</option>" for code in US_STATES)
1674
+ inner = (
1675
+ (rows or '<div class="empty"><h2>No saved addresses</h2>'
1676
+ "<p>Addresses you use at checkout are saved here.</p></div>")
1677
+ + '<div class="card"><h2 style="margin-top:0">Add an address</h2>'
1678
+ '<form method="post" action="/myAccount/addressBook" class="grid">'
1679
+ '<label>Firstname<input name="firstName" required></label>'
1680
+ '<label>Lastname<input name="lastName" required></label>'
1681
+ '<label class="full">Address<input name="address1" required></label>'
1682
+ '<label>City<input name="city" required></label>'
1683
+ f'<label>State/Province<select name="stateDropdown">{states}</select>'
1684
+ "</label>"
1685
+ '<label>Zip code<input name="postalCode" required></label>'
1686
+ '<label>Phone<input name="phoneNumber" type="tel"></label>'
1687
+ '<div class="full"><button class="zenbtn zenbtn-primary">Save address'
1688
+ "</button></div></form></div>"
1689
+ )
1690
+ return _account_page(ctx, request, "/myAccount/addressBook", "Addresses",
1691
+ inner)
1692
+
1693
+
1694
+ @app.post("/myAccount/addressBook")
1695
+ def account_address_add(request: Request, firstName: str = Form(...),
1696
+ lastName: str = Form(...), address1: str = Form(...),
1697
+ city: str = Form(...), stateDropdown: str = Form(...),
1698
+ postalCode: str = Form(...),
1699
+ phoneNumber: str = Form("")) -> Response:
1700
+ ctx = Ctx(request)
1701
+ if not ctx.account:
1702
+ return _login_redirect(ctx, request)
1703
+ store.add_address(connection(), ctx.subject_id or "", {
1704
+ "firstName": firstName, "lastName": lastName, "address1": address1,
1705
+ "city": city, "stateDropdown": stateDropdown,
1706
+ "postalCode": postalCode, "phoneNumber": phoneNumber})
1707
+ return redirect(ctx, "/myAccount/addressBook")
1708
+
1709
+
1710
+ SIMPLE_ACCOUNT_PAGES = {
1711
+ "myGiftCardBalance": ("Gift Card Balance",
1712
+ "<h2>Gift Card Balance</h2><p>Balance: $0.00</p>"
1713
+ "<p class=\"muted\">Gift cards in this clone are "
1714
+ "local ledger entries only.</p>"),
1715
+ "myStoreCredit": ("Store Credit",
1716
+ "<h2>Store Credit</h2><p>Store Credit: $0.00</p>"),
1717
+ "myRewardDashboard": ("Zenni Rewards",
1718
+ "<h2>Zenni Rewards</h2><p>Status: Fan &middot; "
1719
+ "Points: 0 ($0 value)</p>"),
1720
+ "myReferAFriend": ("Refer Friends",
1721
+ "<h2>Refer Friends, Earn $15</h2>"
1722
+ "<p>Your local referral link: "
1723
+ "<code>/register?ref=zenni-shopper</code></p>"),
1724
+ "paymentMethods": ("Payments",
1725
+ "<h2>Payments</h2><p>No stored payment methods. This "
1726
+ "clone uses the local sandbox payment adapter and never "
1727
+ "collects card data.</p>"),
1728
+ "myCommunicationPreferences": (
1729
+ "Communication Preferences",
1730
+ "<h2>Communication Preferences</h2>"
1731
+ "<p>Email updates are written to the local outbox only.</p>"),
1732
+ "language": ("Language", "<h2>Language</h2><p>English (United States)</p>"),
1733
+ }
1734
+
1735
+
1736
+ @app.get("/myAccount/myAccountSetting", response_class=HTMLResponse)
1737
+ def account_settings(request: Request) -> Response:
1738
+ ctx = Ctx(request)
1739
+ if not ctx.account:
1740
+ return _login_redirect(ctx, request)
1741
+ inner = (
1742
+ f'<div class="card"><h2 style="margin-top:0">Personal Information</h2>'
1743
+ f"<p>Name: {escape(ctx.display_name)}</p>"
1744
+ f'<p class="muted">Managed by this site\'s local account store.</p>'
1745
+ f"</div>"
1746
+ )
1747
+ return _account_page(ctx, request, "/myAccount/myAccountSetting",
1748
+ "Personal Information", inner)
1749
+
1750
+
1751
+ @app.get("/myAccount/{slug}", response_class=HTMLResponse)
1752
+ def account_simple(slug: str, request: Request) -> Response:
1753
+ ctx = Ctx(request)
1754
+ if not ctx.account:
1755
+ return _login_redirect(ctx, request)
1756
+ entry = SIMPLE_ACCOUNT_PAGES.get(slug)
1757
+ if not entry:
1758
+ return not_found(ctx)
1759
+ title, inner = entry
1760
+ return _account_page(ctx, request, f"/myAccount/{slug}", title,
1761
+ f'<div class="card">{inner}</div>')
1762
+
1763
+
1764
+ # --------------------------------------------------------------------------
1765
+ # Content
1766
+
1767
+
1768
+ HELP_ARTICLES: dict[str, tuple[str, str]] = {
1769
+ "shipping-returns/shipping-delivery": (
1770
+ "Shipping & Delivery",
1771
+ "<p>Standard shipping is free on orders over $65. Orders under that "
1772
+ "threshold add a $4.95 standard shipping charge, calculated at "
1773
+ "checkout.</p>"),
1774
+ "prescriptions/prescription-faq": (
1775
+ "Prescription FAQ",
1776
+ "<p>Save a prescription in your account to reuse it at checkout. "
1777
+ "Pupillary distance (PD) is required for prescription lenses.</p>"),
1778
+ "lens-types-coatings/lens-faqs": (
1779
+ "Lens FAQ",
1780
+ "<p>Every lens includes 100% UV protection and a scratch-resistant "
1781
+ "coating. Anti-reflective, water-resistant, oil-resistant and "
1782
+ "anti-fog coatings are optional upgrades in the lens builder.</p>"),
1783
+ "specialty-lenses-sunglasses/sunglasses-clip-ons": (
1784
+ "Sunglasses & Clip-Ons",
1785
+ "<p>Permanent tint sunglasses stay dark indoors and out. Polarized "
1786
+ "tints reduce glare from water and roads.</p>"),
1787
+ "frames-fitting/virtual-try-on": (
1788
+ "Virtual Try-On",
1789
+ "<p>The offline clone previews frames from local product photography "
1790
+ "instead of a camera capture.</p>"),
1791
+ "ordering-payment/contact-us": (
1792
+ "Contact Us",
1793
+ "<p>Support hours and channels are informational in this clone; no "
1794
+ "message is delivered off this machine.</p>"),
1795
+ }
1796
+
1797
+
1798
+ @app.get("/help", response_class=HTMLResponse)
1799
+ def help_center(request: Request) -> Response:
1800
+ ctx = Ctx(request)
1801
+ links = "".join(
1802
+ f'<li><a href="/help/{escape(slug)}">{escape(title)}</a></li>'
1803
+ for slug, (title, _) in HELP_ARTICLES.items()
1804
+ )
1805
+ body = (
1806
+ f'<div class="wrap"><h1 class="page">Customer Service</h1>'
1807
+ f'<div class="card"><ul>{links}</ul></div>'
1808
+ f'<div class="card"><h2 style="margin-top:0">Quick links</h2>'
1809
+ f'<ul><li><a href="/c/faq">Frequently Asked Questions</a></li>'
1810
+ f'<li><a href="/trackOrder">Track My Order</a></li></ul></div></div>'
1811
+ )
1812
+ return respond(ctx, page("Customer Service | Zenni Optical", body,
1813
+ ctx.state(connection())))
1814
+
1815
+
1816
+ @app.get("/help/{slug:path}", response_class=HTMLResponse)
1817
+ def help_article(slug: str, request: Request) -> Response:
1818
+ ctx = Ctx(request)
1819
+ entry = HELP_ARTICLES.get(slug)
1820
+ if not entry:
1821
+ return not_found(ctx)
1822
+ title, content = entry
1823
+ body = (
1824
+ f'<div class="wrap"><h1 class="page">{escape(title)}</h1>'
1825
+ f'<div class="card tabpanel">{content}</div>'
1826
+ f'<p><a class="linkbtn" href="/help">Back to Customer Service</a></p>'
1827
+ f"</div>"
1828
+ )
1829
+ return respond(ctx, page(f"{title} | Zenni Optical", body,
1830
+ ctx.state(connection())))
1831
+
1832
+
1833
+ FAQ = [
1834
+ ("How long does shipping take?",
1835
+ "Standard delivery arrives in about 7&ndash;10 business days once your "
1836
+ "lenses are cut."),
1837
+ ("What is the return policy?",
1838
+ "Returns are accepted within 30 days by mail."),
1839
+ ("Do I need my pupillary distance?",
1840
+ "Yes, PD is required for prescription lenses. Non-prescription "
1841
+ "sunglasses do not need it."),
1842
+ ("Can I use my insurance or FSA/HSA?",
1843
+ "Insurance and FSA/HSA reimbursement are described here for parity; this "
1844
+ "clone processes no real benefit claim."),
1845
+ ]
1846
+
1847
+
1848
+ @app.get("/c/faq", response_class=HTMLResponse)
1849
+ def faq(request: Request) -> Response:
1850
+ ctx = Ctx(request)
1851
+ items = "".join(
1852
+ f"<details class=\"facet\"><summary>{escape(question)}</summary>"
1853
+ f"<p>{answer}</p></details>"
1854
+ for question, answer in FAQ
1855
+ )
1856
+ body = (
1857
+ f'<div class="wrap"><h1 class="page">Frequently Asked Questions</h1>'
1858
+ f'<div class="card">{items}</div></div>'
1859
+ )
1860
+ return respond(ctx, page("FAQ | Zenni Optical", body,
1861
+ ctx.state(connection())))
1862
+
1863
+
1864
+ STATIC_CONTENT: dict[str, tuple[str, str]] = {
1865
+ "/sunglasses-guide": (
1866
+ "Sunglasses Guide",
1867
+ "<p>Permanent tint, polarized and Blokz sunglass lenses each suit a "
1868
+ "different kind of glare. Start from the shape that fits your face, "
1869
+ "then choose a tint in the lens builder.</p>"),
1870
+ "/discounts-promo-codes": (
1871
+ "Everyday Value & Promotions",
1872
+ "<p>Free standard shipping applies automatically on orders over "
1873
+ "$65.</p>"),
1874
+ "/measuring-pd-infographic": (
1875
+ "How to Measure Pupillary Distance (PD)",
1876
+ "<p>Measure from the centre of one pupil to the centre of the other, "
1877
+ "in millimetres. Most adults fall between 54mm and 74mm.</p>"),
1878
+ "/measure-eyeglass-frame-size-how-to": (
1879
+ "How to Measure Your Frame Size",
1880
+ "<p>Frame size is printed on the inside of the temple as three "
1881
+ "numbers: lens width, bridge width and temple length, all in "
1882
+ "millimetres. Compare them against a pair that already fits.</p>"
1883
+ "<p>This catalogue groups lens width into XS, S, M, L and XL, which is "
1884
+ "the Frame Sizes facet on every listing page.</p>"),
1885
+ "/glasses-for-face-shape": (
1886
+ "Glasses for Your Face Shape",
1887
+ "<p>Round faces suit rectangle and square frames; square faces suit "
1888
+ "round and oval frames; heart shapes suit aviators and cat-eyes.</p>"),
1889
+ }
1890
+
1891
+
1892
+ @app.get("/{slug:path}", response_class=HTMLResponse)
1893
+ def static_content(slug: str, request: Request) -> Response:
1894
+ ctx = Ctx(request)
1895
+ entry = STATIC_CONTENT.get("/" + slug)
1896
+ if not entry:
1897
+ return not_found(ctx)
1898
+ title, content = entry
1899
+ body = (
1900
+ f'<div class="wrap"><h1 class="page">{escape(title)}</h1>'
1901
+ f'<div class="card tabpanel">{content}</div></div>'
1902
+ )
1903
+ return respond(ctx, page(f"{title} | Zenni Optical", body,
1904
+ ctx.state(connection())))
1905
+
1906
+
1907
+ def not_found(ctx: Ctx) -> HTMLResponse:
1908
+ body = (
1909
+ '<div class="wrap"><div class="empty">'
1910
+ "<h1 class=\"page\">We can't find that page</h1>"
1911
+ "<p>The page you were looking for is not part of this offline "
1912
+ "clone.</p>"
1913
+ '<p><a class="zenbtn zenbtn-primary zenbtn-large" href="/">'
1914
+ "Back to home</a></p></div></div>"
1915
+ )
1916
+ return respond(ctx, page("Page Not Found | Zenni Optical", body,
1917
+ ctx.state(connection())), status=404)
tasks/zennioptical/solution/site/implementation/clone/backend/site_backend_integration.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Generated, site-bound backend integration seam."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import json
7
+ import os
8
+ import sqlite3
9
+ from pathlib import Path
10
+ from typing import Any, Callable
11
+
12
+ from websitebench.local_clone_auth import LocalAuthStore
13
+ from websitebench.site_backend import (
14
+ SiteBackend,
15
+ load_runtime,
16
+ serve_jsonl,
17
+ validate_allowlist,
18
+ )
19
+
20
+
21
+ DEFAULT_RUNTIME_PATH = (
22
+ Path(__file__).resolve().parents[2] / "backend" / "runtime.json"
23
+ )
24
+ BRIDGE_DESCRIPTOR_PATH = (
25
+ Path(__file__).resolve().parents[2] / "backend" / "node-bridge.json"
26
+ )
27
+
28
+
29
+ def _declared_hook(
30
+ declaration: str | None,
31
+ ) -> Callable[[sqlite3.Connection], None] | None:
32
+ if declaration is None:
33
+ return None
34
+ module_name, function_name = declaration.split(":", 1)
35
+ module = importlib.import_module(module_name)
36
+ hook: Any = getattr(module, function_name, None)
37
+ if not callable(hook):
38
+ raise RuntimeError(f"declared backend hook is not callable: {declaration}")
39
+ actual = f"{hook.__module__}:{hook.__name__}"
40
+ if actual != declaration:
41
+ raise RuntimeError(
42
+ f"declared backend hook resolved as {actual!r}, expected {declaration!r}"
43
+ )
44
+ return hook
45
+
46
+
47
+ def open_site_services() -> tuple[SiteBackend, LocalAuthStore]:
48
+ """Open one bound database; never omit the site id for permanent auth."""
49
+
50
+ runtime_path = Path(
51
+ os.environ.get(
52
+ "WEBSITEBENCH_SITE_BACKEND_RUNTIME",
53
+ str(DEFAULT_RUNTIME_PATH),
54
+ )
55
+ ).resolve()
56
+ runtime = load_runtime(runtime_path)
57
+ migration_hook = _declared_hook(runtime.migration_hook)
58
+ seed_hook = _declared_hook(runtime.seed_hook)
59
+ deployed_database = os.environ.get(
60
+ "WEBSITEBENCH_SITE_BACKEND_DATABASE",
61
+ )
62
+ if deployed_database is None:
63
+ backend = SiteBackend.open(
64
+ runtime_path,
65
+ migration_hook=migration_hook,
66
+ seed_hook=seed_hook,
67
+ )
68
+ else:
69
+ database_path = Path(deployed_database).resolve()
70
+ if database_path.name != runtime.database_filename:
71
+ raise RuntimeError(
72
+ "deployed database filename does not match runtime contract"
73
+ )
74
+ backend = SiteBackend.open(
75
+ json.loads(runtime_path.read_text(encoding="utf-8")),
76
+ data_root=database_path.parent,
77
+ migration_hook=migration_hook,
78
+ seed_hook=seed_hook,
79
+ )
80
+ if backend.lifecycle.database_path != database_path:
81
+ raise RuntimeError(
82
+ "deployed database path does not match backend preflight"
83
+ )
84
+ backend.lifecycle.initialize()
85
+ auth = LocalAuthStore(
86
+ backend.lifecycle.database_path,
87
+ site_id=backend.config.site_id,
88
+ )
89
+ auth.ensure_schema()
90
+ return backend, auth
91
+
92
+
93
+ def run_stdio_bridge() -> None:
94
+ """Run only operations frozen in this site's descriptor."""
95
+
96
+ backend, auth = open_site_services()
97
+ descriptor = json.loads(BRIDGE_DESCRIPTOR_PATH.read_text(encoding="utf-8"))
98
+ allowed = validate_allowlist(
99
+ descriptor,
100
+ expected_site_id=backend.config.site_id,
101
+ )
102
+ serve_jsonl(backend, auth, allowed, sys.stdin, sys.stdout)
103
+
104
+
105
+ if __name__ == "__main__":
106
+ import argparse
107
+ import sys
108
+
109
+ parser = argparse.ArgumentParser(prog="websitebench-node-backend-bridge")
110
+ parser.add_argument("--stdio", action="store_true", required=True)
111
+ parser.parse_args()
112
+ run_stdio_bridge()
tasks/zennioptical/solution/site/implementation/clone/data/accessories.json ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "sku": "A60122619",
4
+ "href": "/p/eyeglass-chain/A601226/A60122619",
5
+ "name": "Rose Gold Metal Eyeglass Chain",
6
+ "price": 3.95,
7
+ "rating": 4.3,
8
+ "review_count": 13,
9
+ "badge": "Best seller",
10
+ "image": "/static/accessories/A60122619-accessories-01.jpg"
11
+ },
12
+ {
13
+ "sku": "A110400030",
14
+ "href": "/p/repair-kit/A1104000/A110400030",
15
+ "name": "White Eyeglasses Repair Kit",
16
+ "price": 6.95,
17
+ "rating": 3.9,
18
+ "review_count": 43,
19
+ "badge": "Best seller",
20
+ "image": "/static/accessories/A110400030-accessories-01.jpg"
21
+ },
22
+ {
23
+ "sku": "A110300224",
24
+ "href": "/p/pre-moistened-lens-wipe/A1103002/A110300224",
25
+ "name": "Green Pre-Moistened Lens Wipe",
26
+ "price": 9.95,
27
+ "rating": 2.8,
28
+ "review_count": 5,
29
+ "badge": null,
30
+ "image": "/static/accessories/A110300224-accessories-01.jpg"
31
+ },
32
+ {
33
+ "sku": "A90100121",
34
+ "href": "/p/eyeglass-case/A901001/A90100121",
35
+ "name": "Black Deluxe Tri-Fold Eyeglass Case",
36
+ "price": 6.95,
37
+ "rating": 4.6,
38
+ "review_count": 106,
39
+ "badge": "Top rated",
40
+ "image": "/static/accessories/A90100121-accessories-01.jpg"
41
+ },
42
+ {
43
+ "sku": "A90100424",
44
+ "href": "/p/eyeglass-case/A901004/A90100424",
45
+ "name": "Zenni Teal Travel Case (4-Frame)",
46
+ "price": 17.95,
47
+ "rating": 4.9,
48
+ "review_count": 11,
49
+ "badge": null,
50
+ "image": "/static/accessories/A90100424-accessories-01.jpg"
51
+ },
52
+ {
53
+ "sku": "A110200030",
54
+ "href": "/p/cleaning-kit/A1102000/A110200030",
55
+ "name": "White Lens Spray Kit",
56
+ "price": 4.95,
57
+ "rating": 4.2,
58
+ "review_count": 26,
59
+ "badge": "Best seller",
60
+ "image": "/static/accessories/A110200030-accessories-01.jpg"
61
+ },
62
+ {
63
+ "sku": "A90103724",
64
+ "href": "/p/hard-shell-eyeglass-case/A901037/A90103724",
65
+ "name": "Zenni Teal Hard-Shell Eyeglass Case",
66
+ "price": 2.95,
67
+ "rating": null,
68
+ "review_count": null,
69
+ "badge": "Best seller",
70
+ "image": "/static/accessories/A90103724-accessories-01.jpg"
71
+ },
72
+ {
73
+ "sku": "A50100015",
74
+ "href": "/p/eyeglass-case/A501000/A50100015",
75
+ "name": "Brown Deluxe Eyeglass Case",
76
+ "price": 4.95,
77
+ "rating": 4.4,
78
+ "review_count": 121,
79
+ "badge": "Best seller",
80
+ "image": "/static/accessories/A50100015-accessories-01.jpg"
81
+ },
82
+ {
83
+ "sku": "A90104821",
84
+ "href": "/p/eyeglass-case/A901048/A90104821",
85
+ "name": "Black Pocket Clip-On Case with Keyring",
86
+ "price": 2.95,
87
+ "rating": 2.8,
88
+ "review_count": 6,
89
+ "badge": "Best seller",
90
+ "image": "/static/accessories/A90104821-accessories-01.jpg"
91
+ },
92
+ {
93
+ "sku": "A60105818",
94
+ "href": "/p/eyeglass-case/A601058/A60105818",
95
+ "name": "Red Artist Deluxe Eyewear Lunar New Year Case",
96
+ "price": 9.95,
97
+ "rating": null,
98
+ "review_count": null,
99
+ "badge": null,
100
+ "image": "/static/accessories/A60105818-accessories-01.jpg"
101
+ },
102
+ {
103
+ "sku": "A60106042",
104
+ "href": "/p/eyeglass-case/A601060/A60106042",
105
+ "name": "Orange Year of the Horse Hard-Shell Eyeglass Case",
106
+ "price": 3.95,
107
+ "rating": null,
108
+ "review_count": null,
109
+ "badge": null,
110
+ "image": "/static/accessories/A60106042-accessories-01.jpg"
111
+ },
112
+ {
113
+ "sku": "A60105942",
114
+ "href": "/p/eyeglass-case/A601059/A60105942",
115
+ "name": "Orange Lunar New Year Zip-Up Eyeglass Bag",
116
+ "price": 19.95,
117
+ "rating": null,
118
+ "review_count": null,
119
+ "badge": "Best seller",
120
+ "image": "/static/accessories/A60105942-accessories-01.jpg"
121
+ },
122
+ {
123
+ "sku": "A60105621",
124
+ "href": "/p/eyeglass-case/A601056/A60105621",
125
+ "name": "Black Deluxe Eyewear Case",
126
+ "price": 3.95,
127
+ "rating": 4.4,
128
+ "review_count": 17,
129
+ "badge": null,
130
+ "image": "/static/accessories/A60105621-accessories-01.jpg"
131
+ },
132
+ {
133
+ "sku": "A60104517",
134
+ "href": "/p/eyeglass-case/A601045/A60104517",
135
+ "name": "Purple Year of the Snake Hard-Shell Eyeglass Case",
136
+ "price": 3.95,
137
+ "rating": 4.4,
138
+ "review_count": 7,
139
+ "badge": "Best seller",
140
+ "image": "/static/accessories/A60104517-accessories-01.jpg"
141
+ },
142
+ {
143
+ "sku": "A60105624",
144
+ "href": "/p/eyeglass-case/A601056/A60105624",
145
+ "name": "Green Deluxe Eyewear Case",
146
+ "price": 3.95,
147
+ "rating": 4.4,
148
+ "review_count": 17,
149
+ "badge": null,
150
+ "image": "/static/accessories/A60105624-accessories-01.jpg"
151
+ },
152
+ {
153
+ "sku": "A90105118",
154
+ "href": "/p/lunar-new-year-hard-shell-eyeglass-case/A901051/A90105118",
155
+ "name": "Red Year of the Dragon Hard-Shell Eyeglass Case",
156
+ "price": 3.95,
157
+ "rating": null,
158
+ "review_count": 5,
159
+ "badge": null,
160
+ "image": "/static/accessories/A90105118-accessories-01.jpg"
161
+ },
162
+ {
163
+ "sku": "A60123323",
164
+ "href": "/p/adult-silicone-eyewear-retainer/A601233/A60123323",
165
+ "name": "Clear Silicone Eyewear Retainer 2-Pack",
166
+ "price": 6.95,
167
+ "rating": null,
168
+ "review_count": null,
169
+ "badge": null,
170
+ "image": "/static/accessories/A60123323-accessories-01.jpg"
171
+ },
172
+ {
173
+ "sku": "A110100023",
174
+ "href": "/p/nose-pad/A1101000/A110100023",
175
+ "name": "Translucent Adhesive Nose Pads",
176
+ "price": 1.95,
177
+ "rating": 2.6,
178
+ "review_count": 40,
179
+ "badge": "Best seller",
180
+ "image": "/static/accessories/A110100023-accessories-01.jpg"
181
+ },
182
+ {
183
+ "sku": "A60105615",
184
+ "href": "/p/eyeglass-case/A601056/A60105615",
185
+ "name": "Brown Deluxe Eyewear Case",
186
+ "price": 3.95,
187
+ "rating": 4.4,
188
+ "review_count": 17,
189
+ "badge": null,
190
+ "image": "/static/accessories/A60105615-accessories-01.jpg"
191
+ },
192
+ {
193
+ "sku": "A60105616",
194
+ "href": "/p/eyeglass-case/A601056/A60105616",
195
+ "name": "Blue Deluxe Eyewear Case",
196
+ "price": 3.95,
197
+ "rating": 4.4,
198
+ "review_count": 17,
199
+ "badge": null,
200
+ "image": "/static/accessories/A60105616-accessories-01.jpg"
201
+ },
202
+ {
203
+ "sku": "A60105630",
204
+ "href": "/p/eyeglass-case/A601056/A60105630",
205
+ "name": "White Deluxe Eyewear Case",
206
+ "price": 3.95,
207
+ "rating": 4.4,
208
+ "review_count": 17,
209
+ "badge": null,
210
+ "image": "/static/accessories/A60105630-accessories-01.jpg"
211
+ },
212
+ {
213
+ "sku": "A60122230",
214
+ "href": "/p/eyeglass-chain/A601222/A60122230",
215
+ "name": "White Pearl Eyeglass Chain",
216
+ "price": 4.95,
217
+ "rating": 4.4,
218
+ "review_count": 5,
219
+ "badge": null,
220
+ "image": "/static/accessories/A60122230-accessories-01.jpg"
221
+ },
222
+ {
223
+ "sku": "A60123321",
224
+ "href": "/p/adult-silicone-eyewear-retainer/A601233/A60123321",
225
+ "name": "Black Silicone Eyewear Retainer 2-Pack",
226
+ "price": 6.95,
227
+ "rating": null,
228
+ "review_count": null,
229
+ "badge": null,
230
+ "image": "/static/accessories/A60123321-accessories-01.jpg"
231
+ },
232
+ {
233
+ "sku": "A90104816",
234
+ "href": "/p/eyeglass-case/A901048/A90104816",
235
+ "name": "Zenni Teal Pocket Clip-On Case with Keyring",
236
+ "price": 2.95,
237
+ "rating": 2.8,
238
+ "review_count": 6,
239
+ "badge": null,
240
+ "image": "/static/accessories/A90104816-accessories-01.jpg"
241
+ }
242
+ ]
tasks/zennioptical/solution/site/implementation/clone/data/products.json ADDED
The diff for this file is too large to render. See raw diff
 
tasks/zennioptical/solution/site/implementation/clone/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastapi>=0.115
2
+ uvicorn>=0.30
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110100023-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 67488d9d2eb407b14325723265e449b56d0b0c7b6a18cb21cb919dcbd5732612
  • Pointer size: 130 Bytes
  • Size of remote file: 85.3 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110200030-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 9aac5f4d6ba1f9e9f5c05a130ea37339056436218398bcf930de17f6ffadbd55
  • Pointer size: 131 Bytes
  • Size of remote file: 115 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110300224-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 1b67d41e2609f712e5b605c0ae2152bfde4277311fb6a8c1a876b6bac8f2c768
  • Pointer size: 130 Bytes
  • Size of remote file: 85 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A110400030-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: ca1e442317c30b6fad33ea64554410e50216506c01d67f3129fec103faa8be9f
  • Pointer size: 131 Bytes
  • Size of remote file: 138 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A50100015-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 86da27b745a510b42d368978eb75d05481ad00ee47a5a35224fd27cee0007259
  • Pointer size: 131 Bytes
  • Size of remote file: 120 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60104517-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 224e30bfd1bd2cdb5ce068a30e15d0c78115005d5da3460058b09e4308133f5f
  • Pointer size: 130 Bytes
  • Size of remote file: 93.2 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105615-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: b79f85951ef8b52ebab9f08ceb395895694c2fa32615ca91a359c34ee24fb4a9
  • Pointer size: 131 Bytes
  • Size of remote file: 110 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105616-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 063bfc776ff682a1746d3116e713b101ec3320bed86f096f1fe52ebd640baa73
  • Pointer size: 131 Bytes
  • Size of remote file: 141 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105621-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: ca9931aa7bf4ed7331d554ec4fb2d88f37369fae62dcf7705dffbb1580bc3d16
  • Pointer size: 131 Bytes
  • Size of remote file: 104 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105624-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 408657a519f9414321dca079a6ef92d93bd4851f2525c6304b5df1b60ee78633
  • Pointer size: 131 Bytes
  • Size of remote file: 109 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105630-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 549232a94b6f0ba747bf891e937d26cf499307123baff7fb9bb6cc1b6750b782
  • Pointer size: 130 Bytes
  • Size of remote file: 98.2 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105818-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: d1c54b97883b54f56cbde335334fe703398bb5881ca93582dcaaa49cf5c00a6e
  • Pointer size: 131 Bytes
  • Size of remote file: 110 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60105942-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: c446a730bf9f6f18fd5c4a4f79feaf01be9305fb29f4e89c7a53d68ac77eccf6
  • Pointer size: 131 Bytes
  • Size of remote file: 171 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60106042-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: f4bdd95af92aec1becf6bcb0d6148bbde5ecce0de69ff88f37a6dab4bd497c24
  • Pointer size: 130 Bytes
  • Size of remote file: 80.6 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60122230-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 7c31d4d24dd110c641c2701074c893dbff023231407fe4a971ce111b7150c3e0
  • Pointer size: 130 Bytes
  • Size of remote file: 44.5 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60122619-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: a4ee7bfdae9c56414081e36a03292192f8c182a9072384a211b0c16e65e8f517
  • Pointer size: 130 Bytes
  • Size of remote file: 42.7 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60123321-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 34d8b40deecbee98be42473a6fd21d722e1adbcb427699e34bb01abc539306cf
  • Pointer size: 130 Bytes
  • Size of remote file: 47.3 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A60123323-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: be9c365c16fd392f8e9f8e375b783b986715390df5f8ff6fd856e99ddef9efac
  • Pointer size: 130 Bytes
  • Size of remote file: 31.9 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90100121-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 72723b024cdc67e023e37d9740ecf716e054e6fe25000f11130c68a3bfd65b38
  • Pointer size: 131 Bytes
  • Size of remote file: 169 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90100424-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 006f2529eca114a0d49f5adc71c9eed0276aa3348a036317ce47486a99b7a008
  • Pointer size: 131 Bytes
  • Size of remote file: 106 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90103724-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 8f5da24c526b32d5257c4b5ef7bc32ec7032e2814f74fbff9354ba7803b75122
  • Pointer size: 130 Bytes
  • Size of remote file: 96.5 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90104816-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: a42d1d2a328f22f92946c2fc08f9ab2b5ef000aa6a9ef8031599964a32780718
  • Pointer size: 130 Bytes
  • Size of remote file: 88.6 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90104821-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: b6f25ef0a01313ba55bf56c8b63a9265ae734f2b2e054feb27199e542e1739b9
  • Pointer size: 130 Bytes
  • Size of remote file: 76.5 kB
tasks/zennioptical/solution/site/implementation/clone/static/accessories/A90105118-accessories-01.jpg ADDED

Git LFS Details

  • SHA256: 2d0d38cba8fe5dcef492d414d33c5babddc7653dcc5edb82cce00bd2a737005c
  • Pointer size: 130 Bytes
  • Size of remote file: 92.7 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-bestsellers.png ADDED

Git LFS Details

  • SHA256: 6c27107ac3243c530aabe54a2474c21ac2c5e055ed81c02a5d441facbdf64564
  • Pointer size: 129 Bytes
  • Size of remote file: 1.19 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-cateye.png ADDED

Git LFS Details

  • SHA256: e2cb338241ee96bd7cdf80cec424cff6f4a1bc58c29d4b7418e6f7d99f32ab06
  • Pointer size: 129 Bytes
  • Size of remote file: 1.2 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-new-arrivals.png ADDED

Git LFS Details

  • SHA256: 529f5d74a0aa6d5ea8d4fbf1d9963bd819c9640b1d20b85822e0d54886285254
  • Pointer size: 129 Bytes
  • Size of remote file: 1.15 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-onsale.png ADDED

Git LFS Details

  • SHA256: 6d1b55b395f962bfc29a78148592a171f5ff451a76bd360190398875be9474ef
  • Pointer size: 129 Bytes
  • Size of remote file: 1.25 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-oversize.png ADDED

Git LFS Details

  • SHA256: bc43fc95f0d6cb1a8d91508e98deb1fd14ade82c8eb2e466c73a79ef025d7992
  • Pointer size: 129 Bytes
  • Size of remote file: 1.29 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-rectagle.png ADDED

Git LFS Details

  • SHA256: 181bb53023f4e9e57ad3cfa92f908c7dad6a5184cb04fef6eca99a9002af7869
  • Pointer size: 129 Bytes
  • Size of remote file: 1.43 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-titanium.png ADDED

Git LFS Details

  • SHA256: df495021f64d8fca03e791b0e2b2341ee71fc98c12cca6a430108def2221009a
  • Pointer size: 129 Bytes
  • Size of remote file: 1.27 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-top-rated.png ADDED

Git LFS Details

  • SHA256: 6ab017894b335a9a45fe5985c5b03067b5e9a000b4a1e5a20e537780860b11c3
  • Pointer size: 129 Bytes
  • Size of remote file: 1.18 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-tortoiseshell.png ADDED

Git LFS Details

  • SHA256: cb3d4f56ff9d050c38b1351d5ae554ce39deb6b3869d755127aa2da9a708935e
  • Pointer size: 129 Bytes
  • Size of remote file: 1.29 kB
tasks/zennioptical/solution/site/implementation/clone/static/pills/HP-pills-under30.png ADDED

Git LFS Details

  • SHA256: 7e35e77c7e67508f34fba10855c8871937eb1818e63225a489d683d96864e9f5
  • Pointer size: 129 Bytes
  • Size of remote file: 1.23 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106215-eyeglasses-side-view.jpg ADDED

Git LFS Details

  • SHA256: d5a07c014a38f6a2e0ed756bc85816d2925761f29d13aaa79b9e07805bcc60c6
  • Pointer size: 130 Bytes
  • Size of remote file: 36.6 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106223-eyeglasses-angle-view.jpg ADDED

Git LFS Details

  • SHA256: 2cce45c42163c76de6a13182de6ad6c62081a7585b883e8afbda5d5d18e30796
  • Pointer size: 130 Bytes
  • Size of remote file: 37.9 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106223-eyeglasses-front-view.jpg ADDED

Git LFS Details

  • SHA256: 5b812c0f176725cfb9883e8f2c75678a4aacd2f4eede9577af065f4a261f1ee9
  • Pointer size: 130 Bytes
  • Size of remote file: 56.4 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-angle-view.jpg ADDED

Git LFS Details

  • SHA256: 747a40b90ce27a88423e44a172e7e1f60b62e5baded583a02e6f86b9c27ab0ad
  • Pointer size: 130 Bytes
  • Size of remote file: 54.7 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-front-view.jpg ADDED

Git LFS Details

  • SHA256: d850adc06d23bc899069bcdef8c7e30371b998201f7c2bb1781101d33ce11707
  • Pointer size: 130 Bytes
  • Size of remote file: 66.3 kB
tasks/zennioptical/solution/site/implementation/clone/static/products/106225-eyeglasses-side-view.jpg ADDED

Git LFS Details

  • SHA256: 587294bd70af2f7f4845b6ea0b095c7bb7132fdfd7437f66ec2572cf7a96d369
  • Pointer size: 130 Bytes
  • Size of remote file: 37.4 kB