~edwargix/git.sr.ht

e0bba8961be3478dad523a190d33b5297c95cda7 — Drew DeVault 8 years ago a0114a8
Improve search on user page
2 files changed, 16 insertions(+), 1 deletions(-)

M gitsrht/blueprints/public.py
M gitsrht/templates/user.html
M gitsrht/blueprints/public.py => gitsrht/blueprints/public.py +4 -1
@@ 4,6 4,7 @@ import requests
from srht.config import cfg
from gitsrht.types import User, Repository, RepoVisibility
from gitsrht.access import UserAccess, has_access, get_repo
from sqlalchemy import or_

public = Blueprint('cgit', __name__)



@@ 93,7 94,9 @@ def user_index(username):
        # TODO: ACLs
        repos = repos.filter(Repository.visibility == RepoVisibility.public)
    if search:
        repos = repos.filter(Repository.name.ilike("%" + search + "%"))
        repos = repos.filter(or_(
                Repository.name.ilike("%" + search + "%"),
                Repository.description.ilike("%" + search + "%")))
    repos = repos.order_by(Repository.updated.desc())
    total_repos = repos.count()
    total_pages = repos.count() // 5 + 1

M gitsrht/templates/user.html => gitsrht/templates/user.html +12 -0
@@ 32,7 32,19 @@
    </section>
    <section class="col-md-8">
      {% if len(repos) == 0 %}
      {% if search %}
      <form>
        <input
          name="search"
          type="text"
          placeholder="Search"
          class="form-control"
          value="{{ search if search else "" }}" />
      </form>
      <p>Nothing found.</p>
      {% else %}
      <p>This user has no repositories.</p>
      {% endif %}
      {% else %}
      <form>
        <input