diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c6f835..f700e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2.7.0 + +### New Features +- Zubbi now searches the `roles` directory recursively for roles defined in a + subdirectory. + ## 2.6.2 ### Fixes diff --git a/zubbi/models.py b/zubbi/models.py index 9812eeb..7293a0a 100644 --- a/zubbi/models.py +++ b/zubbi/models.py @@ -15,6 +15,7 @@ import collections import logging import ssl +from urllib.parse import quote_plus import markupsafe from elasticsearch.exceptions import ElasticsearchException @@ -270,8 +271,9 @@ def search_query(self, query, fields_set, exact=False, extra_filter=None): def detail_query(self, block_name, repo, extra_filter=None): extra_filter = extra_filter or [] + query_string = block_name.translate(TRANSLATION_TABLE) detail_query = [ - Q("query_string", query=block_name, fields=["job_name", "role_name"]), + Q("query_string", query=query_string, fields=["job_name", "role_name"]), Q("match", repo=repo), ] return self.query("bool", filter=extra_filter, must=detail_query) @@ -336,6 +338,9 @@ def init_elasticsearch(app): app.add_template_test(role_type) app.add_template_test(job_type) app.add_template_filter(block_type) + # Jinja2 doesn't provide it's own filter equivalent for + # urllib.parse.quote_plus, so we add it by ourselves. + app.add_template_filter(quote_plus) def init_elasticsearch_con( diff --git a/zubbi/templates/search.html b/zubbi/templates/search.html index 46cbcb8..078c109 100644 --- a/zubbi/templates/search.html +++ b/zubbi/templates/search.html @@ -93,7 +93,7 @@
{% if match.description_rendered %}{{ match.description_rendered.split('\n')|first|striptags }}{% endif %}
- Show details + Show details {%- endfor %} diff --git a/zubbi/views.py b/zubbi/views.py index dfb0880..3ea14bd 100644 --- a/zubbi/views.py +++ b/zubbi/views.py @@ -17,6 +17,7 @@ import hmac import json import math +import urllib.parse from elasticsearch_dsl import Q from flask import ( @@ -159,7 +160,7 @@ def get(self): "zubbi.details", repo=block.repo, block_type=block_type(block), - name=block.name, + name=urllib.parse.quote_plus(block.name), ), code=303, ) @@ -199,6 +200,7 @@ def get(self, repo, block_type, name): abort(400, "Unknown block type '{}'".format(block_type)) extra_filter = Q("term", private=False) + name = urllib.parse.unquote_plus(name) search = BlockSearch(block_class=BlockClass).detail_query( name, repo, extra_filter )