diff --git a/hubsrht/blueprints/public.py b/hubsrht/blueprints/public.py index 210c6de..84278f1 100644 --- a/hubsrht/blueprints/public.py +++ b/hubsrht/blueprints/public.py @@ -45,9 +45,13 @@ def project_index(): .filter(Project.checklist_complete)) search = request.args.get("search") + search_error = None if search: - projects = search_by(projects, search, - [Project.name, Project.description]) + try: + projects = search_by(projects, search, + [Project.name, Project.description]) + except ValueError as e: + search_error = str(e) sort = request.args.get("sort") if sort and sort == "recently-updated": @@ -68,7 +72,7 @@ def project_index(): return render_template("project-index.html", projects=projects, search=search, features=features, sort=sort, **pagination, - search_keys=["sort"]) + search_keys=["sort"], search_error=search_error) @public.route("/projects/featured") def featured_projects(): diff --git a/hubsrht/templates/project-index.html b/hubsrht/templates/project-index.html index 07c9fdb..8993f3a 100644 --- a/hubsrht/templates/project-index.html +++ b/hubsrht/templates/project-index.html @@ -12,7 +12,7 @@ name="search" type="text" placeholder="Search all public projects" - class="form-control" + class="form-control {% if search_error %} is-invalid{% endif %}" value="{{search if search else ""}}" /> {% if search_error %}
{{ search_error }}