|
131 | 131 | { |
132 | 132 | "data": { |
133 | 133 | "text/plain": [ |
134 | | - "datetime.datetime(2025, 10, 5, 14, 0)" |
| 134 | + "datetime.datetime(2025, 10, 27, 14, 0)" |
135 | 135 | ] |
136 | 136 | }, |
137 | 137 | "execution_count": null, |
|
1322 | 1322 | "outputs": [], |
1323 | 1323 | "source": [ |
1324 | 1324 | "#| export\n", |
| 1325 | + "def _canonical(req):\n", |
| 1326 | + " if not req.app.canonical: return []\n", |
| 1327 | + " url = str(getattr(req, 'canonical', req.url)).replace('http://', 'https://', 1)\n", |
| 1328 | + " return [Link(rel=\"canonical\", href=url)]\n", |
| 1329 | + "\n", |
1325 | 1330 | "def _xt_cts(req, resp):\n", |
1326 | 1331 | " \"Extract content and headers, render as full page or fragment\"\n", |
1327 | 1332 | " hdr_tags = 'title','meta','link','style','base'\n", |
1328 | 1333 | " resp = tuplify(resp)\n", |
1329 | 1334 | " heads,bdy = partition(resp, lambda o: getattr(o, 'tag', '') in hdr_tags)\n", |
1330 | 1335 | " if not is_full_page(req, resp):\n", |
1331 | 1336 | " title = [] if any(getattr(o, 'tag', '')=='title' for o in heads) else [Title(req.app.title)]\n", |
1332 | | - " canonical = [Link(rel=\"canonical\", href=getattr(req, 'canonical', req.url))] if req.app.canonical else []\n", |
1333 | | - " resp = respond(req, [*heads, *title, *canonical], bdy)\n", |
| 1337 | + " resp = respond(req, [*heads, *title, *_canonical(req)], bdy)\n", |
1334 | 1338 | " return _to_xml(req, resp, indent=fh_cfg.indent)" |
1335 | 1339 | ] |
1336 | 1340 | }, |
|
1422 | 1426 | " \"multi-swap\": \"https://cdn.jsdelivr.net/npm/[email protected]/multi-swap.js\",\n", |
1423 | 1427 | " \"path-deps\": \"https://cdn.jsdelivr.net/npm/[email protected]/path-deps.js\",\n", |
1424 | 1428 | " \"remove-me\": \"https://cdn.jsdelivr.net/npm/[email protected]/remove-me.js\",\n", |
| 1429 | + " \"debug\": \"https://unpkg.com/[email protected]/dist/ext/debug.js\",\n", |
1425 | 1430 | " \"ws\": \"https://cdn.jsdelivr.net/npm/[email protected]/ws.js\",\n", |
1426 | 1431 | " \"chunked-transfer\": \"https://cdn.jsdelivr.net/npm/[email protected]/transfer-encoding-chunked.js\"\n", |
1427 | 1432 | "}" |
|
1445 | 1450 | "name": "stdout", |
1446 | 1451 | "output_type": "stream", |
1447 | 1452 | "text": [ |
1448 | | - "morph head-support preload class-tools loading-states multi-swap path-deps remove-me ws chunked-transfer\n" |
| 1453 | + "morph head-support preload class-tools loading-states multi-swap path-deps remove-me debug ws chunked-transfer\n" |
1449 | 1454 | ] |
1450 | 1455 | } |
1451 | 1456 | ], |
|
1461 | 1466 | "outputs": [], |
1462 | 1467 | "source": [ |
1463 | 1468 | "#| export\n", |
1464 | | - "htmxsrc = Script(src=\"https://cdn.jsdelivr.net/npm/[email protected].6/dist/htmx.min.js\")\n", |
| 1469 | + "htmxsrc = Script(src=\"https://cdn.jsdelivr.net/npm/[email protected].7/dist/htmx.js\")\n", |
1465 | 1470 | "fhjsscr = Script(src=\"https://cdn.jsdelivr.net/gh/answerdotai/[email protected]/fasthtml.js\")\n", |
1466 | 1471 | "surrsrc = Script(src=\"https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js\")\n", |
1467 | 1472 | "scopesrc = Script(src=\"https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js\")\n", |
|
2879 | 2884 | "name": "stdout", |
2880 | 2885 | "output_type": "stream", |
2881 | 2886 | "text": [ |
2882 | | - "Set to 2025-09-17 09:13:49.740165\n" |
| 2887 | + "Set to 2025-10-27 07:27:07.025956\n" |
2883 | 2888 | ] |
2884 | 2889 | }, |
2885 | 2890 | { |
2886 | 2891 | "data": { |
2887 | 2892 | "text/plain": [ |
2888 | | - "'Session time: 2025-09-17 09:13:49.740165'" |
| 2893 | + "'Session time: 2025-10-27 07:27:07.025956'" |
2889 | 2894 | ] |
2890 | 2895 | }, |
2891 | 2896 | "execution_count": null, |
|
3482 | 3487 | " <html>\n", |
3483 | 3488 | " <head>\n", |
3484 | 3489 | " <title>FastHTML page</title>\n", |
3485 | | - " <link rel=\"canonical\" href=\"http://testserver/setcookie\">\n", |
| 3490 | + " <link rel=\"canonical\" href=\"https://testserver/setcookie\">\n", |
3486 | 3491 | " <meta charset=\"utf-8\">\n", |
3487 | 3492 | " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\">\n", |
3488 | | - "<script src=\"https://cdn.jsdelivr.net/npm/[email protected].6/dist/htmx.min.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/answerdotai/[email protected]/fasthtml.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js\"></script><script>\n", |
| 3493 | + "<script src=\"https://cdn.jsdelivr.net/npm/[email protected].7/dist/htmx.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/answerdotai/[email protected]/fasthtml.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/answerdotai/surreal@main/surreal.js\"></script><script src=\"https://cdn.jsdelivr.net/gh/gnat/css-scope-inline@main/script.js\"></script><script>\n", |
3489 | 3494 | " function sendmsg() {\n", |
3490 | 3495 | " window.parent.postMessage({height: document.documentElement.offsetHeight}, '*');\n", |
3491 | 3496 | " }\n", |
|
3502 | 3507 | { |
3503 | 3508 | "data": { |
3504 | 3509 | "text/plain": [ |
3505 | | - "'Cookie was set at time 08:12:02.333734'" |
| 3510 | + "'Cookie was set at time 07:28:31.264910'" |
3506 | 3511 | ] |
3507 | 3512 | }, |
3508 | 3513 | "execution_count": null, |
|
0 commit comments