From c82cd0862aa79edf92a19c708bef8589f9ab1a18 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 6 Nov 2023 23:11:22 -0800 Subject: [PATCH] Delete deprecated content config pages for local files from web client The desktop app now manages syncing local computer files to index The server only manages "cloud" data source like github and notion. --- .../interface/web/content_type_input.html | 159 ------------------ src/khoj/routers/web_client.py | 47 ------ 2 files changed, 206 deletions(-) delete mode 100644 src/khoj/interface/web/content_type_input.html diff --git a/src/khoj/interface/web/content_type_input.html b/src/khoj/interface/web/content_type_input.html deleted file mode 100644 index f8751ddc..00000000 --- a/src/khoj/interface/web/content_type_input.html +++ /dev/null @@ -1,159 +0,0 @@ -{% extends "base_config.html" %} -{% block content %} -
-
-

- {{ content_type|capitalize }} - {{ content_type|capitalize }} -

-
- - - - - - - - - - - -
- - - {% if current_config['input_files'] is none %} - - {% else %} - {% for input_file in current_config['input_files'] %} - - {% endfor %} - {% endif %} - - -
- - - {% if current_config['input_filter'] is none %} - - {% else %} - {% for input_filter in current_config['input_filter'] %} - - {% endfor %} - {% endif %} - - -
-
- - -
-
-
-
- -{% endblock %} diff --git a/src/khoj/routers/web_client.py b/src/khoj/routers/web_client.py index 35603e18..65292ccf 100644 --- a/src/khoj/routers/web_client.py +++ b/src/khoj/routers/web_client.py @@ -9,7 +9,6 @@ from fastapi.responses import HTMLResponse, FileResponse, RedirectResponse from fastapi.templating import Jinja2Templates from starlette.authentication import requires from khoj.utils.rawconfig import ( - TextContentConfig, GithubContentConfig, GithubRepoConfig, NotionContentConfig, @@ -18,14 +17,11 @@ from khoj.utils.rawconfig import ( # Internal Packages from khoj.utils import constants, state from database.adapters import EntryAdapters, get_user_github_config, get_user_notion_config, ConversationAdapters -from database.models import LocalOrgConfig, LocalMarkdownConfig, LocalPdfConfig, LocalPlaintextConfig # Initialize Router web_client = APIRouter() templates = Jinja2Templates(directory=constants.web_directory) -VALID_TEXT_CONTENT_TYPES = ["org", "markdown", "pdf", "plaintext"] - # Create Routes @web_client.get("/", response_class=FileResponse) @@ -109,17 +105,6 @@ def login_page(request: Request): ) -def map_config_to_object(content_type: str): - if content_type == "org": - return LocalOrgConfig - if content_type == "markdown": - return LocalMarkdownConfig - if content_type == "pdf": - return LocalPdfConfig - if content_type == "plaintext": - return LocalPlaintextConfig - - @web_client.get("/config", response_class=HTMLResponse) @requires(["authenticated"], redirect="login_page") def config_page(request: Request): @@ -224,35 +209,3 @@ def notion_config_page(request: Request): "user_photo": user_picture, }, ) - - -@web_client.get("/config/content_type/{content_type}", response_class=HTMLResponse) -@requires(["authenticated"], redirect="login_page") -def content_config_page(request: Request, content_type: str): - if content_type not in VALID_TEXT_CONTENT_TYPES: - return templates.TemplateResponse("config.html", context={"request": request}) - - object = map_config_to_object(content_type) - user = request.user.object - user_picture = request.session.get("user", {}).get("picture") - config = object.objects.filter(user=user).first() - if config == None: - config = object.objects.create(user=user) - - current_config = TextContentConfig( - input_files=config.input_files, - input_filter=config.input_filter, - index_heading_entries=config.index_heading_entries, - ) - current_config = json.loads(current_config.json()) - - return templates.TemplateResponse( - "content_type_input.html", - context={ - "request": request, - "current_config": current_config, - "content_type": content_type, - "username": user.username, - "user_photo": user_picture, - }, - )