diff --git a/tutordash/server/app.py b/tutordash/server/app.py index e553eb7..e96c1ff 100644 --- a/tutordash/server/app.py +++ b/tutordash/server/app.py @@ -54,6 +54,13 @@ async def home() -> str: @app.get("/plugin/store") async def plugin_store() -> str: + return await render_template( + "plugin_store.html", + **shared_template_context(), + ) + +@app.get("/plugin/store/list") +async def plugin_store_list() -> str: installed_plugins = tutorclient.Client.installed_plugins() plugins: list[dict[str, str]] = [ { @@ -67,26 +74,26 @@ async def plugin_store() -> str: for p in tutorclient.Client.plugins_in_store() ] - search_query = request.args.get("q", default="", type=str).strip().lower() + search_query = request.args.get("search", default="", type=str).strip().lower() if search_query: plugins = [plugin for plugin in plugins if search_query in plugin["name"].lower()] - page = request.args.get("page", default=1, type=int) - per_page = 9 - total_pages = (len(plugins) + per_page - 1) // per_page - if page < 1: - page = 1 - elif page > total_pages: - page = total_pages - start = (page - 1) * per_page - end = start + per_page - plugins = plugins[start:end] + # page = request.args.get("page", default=1, type=int) + # per_page = 9 + # total_pages = (len(plugins) + per_page - 1) // per_page + # if page < 1: + # page = 1 + # elif page > total_pages: + # page = total_pages + # start = (page - 1) * per_page + # end = start + per_page + # plugins = plugins[start:end] return await render_template( - "plugin_store.html", + "_plugin_store_list.html", plugins=plugins, - page_count=total_pages, - current_page=page, + # page_count=total_pages, + # current_page=page, **shared_template_context(), ) diff --git a/tutordash/server/templates/base_header.html b/tutordash/server/templates/base_header.html index e7be1b3..e5dac2b 100644 --- a/tutordash/server/templates/base_header.html +++ b/tutordash/server/templates/base_header.html @@ -18,7 +18,7 @@ class="form-control search-input" name="search" placeholder="Search..." - hx-get="{{ url_for('installed_plugins_list') }}" + hx-get="{{ search_endpoint }}" hx-trigger="input changed delay:300ms, search" hx-target="#plugins-list" hx-indicator="#search-indicator"> diff --git a/tutordash/server/templates/installed_plugins.html b/tutordash/server/templates/installed_plugins.html index 0b88525..e4fcfa4 100644 --- a/tutordash/server/templates/installed_plugins.html +++ b/tutordash/server/templates/installed_plugins.html @@ -33,6 +33,8 @@ Running local launch will allow all changes to plugins to take effect. This coul {% set sidebar_active_tab = "my-plugins" %} +{% set search_endpoint = url_for('installed_plugins_list') %} + {% block workspace_content %}
{% endblock %} diff --git a/tutordash/server/templates/plugin_store.html b/tutordash/server/templates/plugin_store.html index 7660b18..ea8338b 100644 --- a/tutordash/server/templates/plugin_store.html +++ b/tutordash/server/templates/plugin_store.html @@ -16,64 +16,11 @@ View and install available plugins. {% set sidebar_active_tab = "plugin-marketplace" %} +{% set search_endpoint = url_for('plugin_store_list') %} + {% block workspace_content %} -