From 3caf0a79d813c7a9f72cb4d139abfab7a9faf6b4 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Thu, 14 Mar 2024 11:26:49 +0530 Subject: [PATCH] Spruce up the 404 page and improve the overall layout for agents pages --- src/khoj/interface/web/404.html | 42 +++++++++++++++++++++++++++--- src/khoj/interface/web/agent.html | 2 +- src/khoj/interface/web/agents.html | 2 +- src/khoj/routers/web_client.py | 13 +++++++++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/khoj/interface/web/404.html b/src/khoj/interface/web/404.html index 7041ff80..0762bde8 100644 --- a/src/khoj/interface/web/404.html +++ b/src/khoj/interface/web/404.html @@ -2,14 +2,19 @@ Khoj: An AI Personal Assistant for your digital brain - - + + + + + {% import 'utils.html' as utils %} + {{ utils.heading_pane(user_photo, username, is_active, has_documents) }} +
-

Oops, this is awkward. That page couldn't be found.

+

Oops, this is awkward. Looks like there's nothing here.

- Go Home + Go Home @@ -18,5 +23,34 @@ body.not-found { padding: 0 10% } + + body { + background-color: var(--background-color); + color: var(--main-text-color); + text-align: center; + font-family: var(--font-family); + font-size: medium; + font-weight: 300; + line-height: 1.5em; + height: 100vh; + margin: 0; + } + + body a.redirect-link { + font-size: 18px; + font-weight: bold; + background-color: var(--primary); + text-decoration: none; + border: 1px solid var(--main-text-color); + color: var(--main-text-color); + border-radius: 8px; + padding: 4px; + } + + body a.redirect-link:hover { + background-color: var(--main-text-color); + color: var(--primary); + } + diff --git a/src/khoj/interface/web/agent.html b/src/khoj/interface/web/agent.html index e1ca6141..37294254 100644 --- a/src/khoj/interface/web/agent.html +++ b/src/khoj/interface/web/agent.html @@ -242,7 +242,7 @@ @media only screen and (min-width: 700px) { body { grid-template-columns: auto min(70vw, 100%) auto; - grid-template-rows: auto minmax(80px, 100%) auto; + grid-template-rows: auto auto auto; } body > * { grid-column: 2; diff --git a/src/khoj/interface/web/agents.html b/src/khoj/interface/web/agents.html index cbb7757c..6c3ae084 100644 --- a/src/khoj/interface/web/agents.html +++ b/src/khoj/interface/web/agents.html @@ -61,7 +61,7 @@ line-height: 1.5em; height: 100vh; margin: 0; - grid-template-rows: auto minmax(80px, 100%) auto; + grid-template-rows: auto auto auto; } h1#agents-list-title { diff --git a/src/khoj/routers/web_client.py b/src/khoj/routers/web_client.py index 667c857f..c7d3e530 100644 --- a/src/khoj/routers/web_client.py +++ b/src/khoj/routers/web_client.py @@ -169,6 +169,19 @@ def agents_page(request: Request, agent_slug: str): agent = AgentAdapters.get_agent_by_slug(agent_slug) + if agent == None: + return templates.TemplateResponse( + "404.html", + context={ + "request": request, + "khoj_version": state.khoj_version, + "username": user.username if user else None, + "has_documents": False, + "is_active": has_required_scope(request, ["premium"]), + "user_photo": user_picture, + }, + ) + agent_metadata = { "slug": agent.slug, "avatar": agent.avatar,