diff --git a/data/model/repository.py b/data/model/repository.py index 109a9a25e..c49e5cb05 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -509,18 +509,20 @@ def _get_sorted_matching_repositories(lookup_value, repo_kind='image', include_p if search_fields is None: search_fields = set([SEARCH_FIELDS.description.name, SEARCH_FIELDS.name.name]) - # Always search at least on name (init clause) - clause = Repository.name.match(lookup_value) - computed_score = RepositorySearchScore.score.alias('score') + if lookup_value: + # Always search at least on name (init clause) + clause = Repository.name.match(lookup_value) + computed_score = RepositorySearchScore.score.alias('score') - # If the description field is in the search fields, then we need to compute a synthetic score - # to discount the weight of the description more than the name. - if SEARCH_FIELDS.description.name in search_fields: - clause = Repository.description.match(lookup_value) | clause - - cases = [(Repository.name.match(lookup_value), 100 * RepositorySearchScore.score),] - - computed_score = case(None, cases, RepositorySearchScore.score).alias('score') + # If the description field is in the search fields, then we need to compute a synthetic score + # to discount the weight of the description more than the name. + if SEARCH_FIELDS.description.name in search_fields: + clause = Repository.description.match(lookup_value) | clause + cases = [(Repository.name.match(lookup_value), 100 * RepositorySearchScore.score),] + computed_score = case(None, cases, RepositorySearchScore.score).alias('score') + else: + clause = (Repository.id >= 0) + computed_score = RepositorySearchScore.score.alias('score') query = (Repository.select(Repository, Namespace, computed_score) .join(Namespace, on=(Namespace.id == Repository.namespace_user)).where(clause) diff --git a/endpoints/api/search.py b/endpoints/api/search.py index 204b055c5..54abdf4f5 100644 --- a/endpoints/api/search.py +++ b/endpoints/api/search.py @@ -347,9 +347,6 @@ class ConductRepositorySearch(ApiResource): def get(self, parsed_args): """ Get a list of apps and repositories that match the specified query. """ query = parsed_args['query'] - if not query: - return {'results': []} - page = min(max(1, parsed_args['page']), 10) offset = (page - 1) * MAX_PER_PAGE limit = offset + MAX_PER_PAGE + 1 diff --git a/endpoints/api/test/test_search.py b/endpoints/api/test/test_search.py index e67c3dbff..15fbc1864 100644 --- a/endpoints/api/test/test_search.py +++ b/endpoints/api/test/test_search.py @@ -9,6 +9,7 @@ from endpoints.test.shared import client_with_identity from test.fixtures import * @pytest.mark.parametrize('query', [ + (''), ('simple'), ('public'), ('repository'), diff --git a/endpoints/web.py b/endpoints/web.py index 25702b21a..f3785688f 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -215,12 +215,6 @@ def application(path): return index('') -@web.route('/starred/') -@no_cache -def starred(): - return index('') - - @web.route('/security/') @no_cache def security(): diff --git a/static/css/directives/ui/header-bar.css b/static/css/directives/ui/header-bar.css index 19b5ed04f..4ec6760e3 100644 --- a/static/css/directives/ui/header-bar.css +++ b/static/css/directives/ui/header-bar.css @@ -116,4 +116,22 @@ nav.navbar-default .navbar-nav>li>a.active { margin-top: -6px; display: inline-block; margin-bottom: 6px; +} + +@media (max-width: 960px) { + .header-bar-element .navbar-anon .search-box-element input { + width: 200px; + } +} + +@media (max-width: 860px) { + .header-bar-element .navbar-anon .search-box-element input { + width: 150px; + } +} + +@media (max-width: 1150px) { + .header-bar-element .navbar-signedin search-box { + display: none; + } } \ No newline at end of file diff --git a/static/directives/header-bar.html b/static/directives/header-bar.html index ab71d1ced..6fea04ddd 100644 --- a/static/directives/header-bar.html +++ b/static/directives/header-bar.html @@ -16,20 +16,18 @@
-