mirror of https://git.sr.ht/~sircmpwn/hub.sr.ht
parent
c212995eef
commit
134c1f27d6
|
@ -45,9 +45,13 @@ def project_index():
|
||||||
.filter(Project.checklist_complete))
|
.filter(Project.checklist_complete))
|
||||||
|
|
||||||
search = request.args.get("search")
|
search = request.args.get("search")
|
||||||
|
search_error = None
|
||||||
if search:
|
if search:
|
||||||
projects = search_by(projects, search,
|
try:
|
||||||
[Project.name, Project.description])
|
projects = search_by(projects, search,
|
||||||
|
[Project.name, Project.description])
|
||||||
|
except ValueError as e:
|
||||||
|
search_error = str(e)
|
||||||
|
|
||||||
sort = request.args.get("sort")
|
sort = request.args.get("sort")
|
||||||
if sort and sort == "recently-updated":
|
if sort and sort == "recently-updated":
|
||||||
|
@ -68,7 +72,7 @@ def project_index():
|
||||||
|
|
||||||
return render_template("project-index.html", projects=projects,
|
return render_template("project-index.html", projects=projects,
|
||||||
search=search, features=features, sort=sort, **pagination,
|
search=search, features=features, sort=sort, **pagination,
|
||||||
search_keys=["sort"])
|
search_keys=["sort"], search_error=search_error)
|
||||||
|
|
||||||
@public.route("/projects/featured")
|
@public.route("/projects/featured")
|
||||||
def featured_projects():
|
def featured_projects():
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
name="search"
|
name="search"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Search all public projects"
|
placeholder="Search all public projects"
|
||||||
class="form-control"
|
class="form-control {% if search_error %} is-invalid{% endif %}"
|
||||||
value="{{search if search else ""}}" />
|
value="{{search if search else ""}}" />
|
||||||
{% if search_error %}
|
{% if search_error %}
|
||||||
<div class="invalid-feedback">{{ search_error }}</div>
|
<div class="invalid-feedback">{{ search_error }}</div>
|
||||||
|
|
Loading…
Reference in New Issue