diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/web/controllers/abstract.py | 7 | ||||
-rw-r--r-- | src/web/templates/bookmarks.html | 70 | ||||
-rw-r--r-- | src/web/views/bookmark.py | 5 |
3 files changed, 54 insertions, 28 deletions
diff --git a/src/web/controllers/abstract.py b/src/web/controllers/abstract.py index ae39dff7..47cc365f 100644 --- a/src/web/controllers/abstract.py +++ b/src/web/controllers/abstract.py @@ -51,12 +51,7 @@ class AbstractController: elif key.endswith('__in'): db_filters.add(getattr(self._db_cls, key[:-4]).in_(value)) elif key.endswith('__contains'): - db_filters.add(or_( - getattr(self._db_cls, key[:-10]) \ - .contains(value.lower()), - getattr(self._db_cls, key[:-10]) \ - .contains(value.upper()) - )) + db_filters.add(getattr(self._db_cls, key[:-10]).contains(value)) elif key.endswith('__like'): db_filters.add(getattr(self._db_cls, key[:-6]).like(value)) elif key.endswith('__ilike'): diff --git a/src/web/templates/bookmarks.html b/src/web/templates/bookmarks.html index 71a8056d..33a35252 100644 --- a/src/web/templates/bookmarks.html +++ b/src/web/templates/bookmarks.html @@ -14,27 +14,53 @@ {% endif %} </div> </div> - {{ pagination.links }} - <ul class="list-group"> - {% for bookmark in bookmarks %} - <li class="list-group-item"> - <a href="#"> - <h4 class="list-group-item-heading"> - <a href="{{ bookmark.href }}">{{ bookmark.title }}</a> - </h4> - <p class="list-group-item-text"> - <div class="text-muted">{{ bookmark.description }}</div> - <div>{% for tag in bookmark.tags %}<a href="{{ url_for('bookmarks.list_', tag=tag.text) }}">{{ tag.text }} </a>{% endfor %}</div> - {{ bookmark.time | datetime }} - {% if current_user.is_authenticated %} - <a class="text-muted" href="{{ url_for('bookmark.form', bookmark_id=bookmark.id) }}">edit</a> - <a class="text-muted" href="{{ url_for('bookmark.delete', bookmark_id=bookmark.id) }}">delete</a> - {% endif %} - </p> - </a> - </li> - {% endfor %} - </ul> - {{ pagination.links }} + <br /> + <div class="row"> + <div class="col-md-12 text-right"> + <form method="GET"> + <div class="form-inline"> + <input type="text" name="query" class="form-control" /> + <button type="submit" class="btn btn-default">Search</button> + </div> + </form> + </div> + </div> + <br /> + <div class="row"> + <div class="col-md-8"> + {{ pagination.links }} + </div> + </div> + <br /> + <div class="row"> + <div class="col-md-8"> + <ul class="list-group"> + {% for bookmark in bookmarks %} + <li class="list-group-item"> + <a href="#"> + <h4 class="list-group-item-heading"> + <a href="{{ bookmark.href }}">{{ bookmark.title }}</a> + </h4> + <p class="list-group-item-text"> + <div class="text-muted">{{ bookmark.description }}</div> + <div>{% for tag in bookmark.tags %}<a href="{{ url_for('bookmarks.list_', tag=tag.text) }}">{{ tag.text }} </a>{% endfor %}</div> + {{ bookmark.time | datetime }} + {% if current_user.is_authenticated %} + <a class="text-muted" href="{{ url_for('bookmark.form', bookmark_id=bookmark.id) }}">edit</a> + <a class="text-muted" href="{{ url_for('bookmark.delete', bookmark_id=bookmark.id) }}">delete</a> + {% endif %} + </p> + </a> + </li> + {% endfor %} + </ul> + </div> + </div> + <br /> + <div class="row"> + <div class="col-md-8"> + {{ pagination.links }} + </div> + </div> </div><!-- /.container --> {% endblock %} diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py index 8736e1ca..69a094ac 100644 --- a/src/web/views/bookmark.py +++ b/src/web/views/bookmark.py @@ -58,6 +58,11 @@ def list_(per_page, status='all'): tag = request.args.get('tag', None) if tag: filters['tags_proxy__contains'] = tag + query = request.args.get('query', None) + if query: + query = '%' + query + '%' + filters['__or__'] = {'title__ilike': query, 'description__ilike': query} + if current_user.is_authenticated: # query for the bookmarks of the authenticated user |