search: added basic example query block.
This commit is contained in:
parent
6e89c84604
commit
8f5b7122aa
5 changed files with 30 additions and 1 deletions
|
|
@ -107,5 +107,6 @@ class SearchController(BaseRepoController):
|
|||
c.runtime = execution_time
|
||||
c.cur_query = search_query
|
||||
c.search_type = search_type
|
||||
c.searcher = searcher
|
||||
# Return a rendered template
|
||||
return render('/search/search.mako')
|
||||
|
|
|
|||
|
|
@ -1842,6 +1842,24 @@ def journal_filter_help():
|
|||
)
|
||||
|
||||
|
||||
def search_filter_help(searcher):
|
||||
|
||||
terms = ''
|
||||
return _(
|
||||
'Example filter terms for `{searcher}` search:\n' +
|
||||
'{terms}\n' +
|
||||
'Generate wildcards using \'*\' character:\n' +
|
||||
' "repo_name:vcs*" - search everything starting with \'vcs\'\n' +
|
||||
' "repo_name:*vcs*" - search for repository containing \'vcs\'\n' +
|
||||
'\n' +
|
||||
'Optional AND / OR operators in queries\n' +
|
||||
' "repo_name:vcs OR repo_name:test"\n' +
|
||||
' "owner:test AND repo_name:test*"\n' +
|
||||
'More: {search_doc}'
|
||||
).format(searcher=searcher.name,
|
||||
terms=terms, search_doc=searcher.query_lang_doc)
|
||||
|
||||
|
||||
def not_mapped_error(repo_name):
|
||||
flash(_('%s repository is not mapped to db perhaps'
|
||||
' it was created or renamed from the filesystem'
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ default_location = '%(here)s/data/index'
|
|||
|
||||
|
||||
class BaseSearch(object):
|
||||
query_lang_doc = ''
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class Search(BaseSearch):
|
||||
|
||||
# this also shows in UI
|
||||
query_lang_doc = 'http://whoosh.readthedocs.io/en/latest/querylang.html'
|
||||
name = 'whoosh'
|
||||
|
||||
def __init__(self, config):
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
${h.select('type',c.search_type,[('content',_('File contents')), ('commit',_('Commit messages')), ('path',_('File names')),],id='id_search_type')}
|
||||
<input type="submit" value="${_('Search')}" class="btn"/>
|
||||
<br/>
|
||||
|
||||
<div class="search-feedback-items">
|
||||
% for error in c.errors:
|
||||
<span class="error-message">
|
||||
|
|
@ -71,10 +72,16 @@
|
|||
% endfor
|
||||
</span>
|
||||
% endfor
|
||||
<div class="field">
|
||||
<p class="filterexample" style="position: inherit" onclick="$('#search-help').toggle()">${_('Example Queries')}</p>
|
||||
<pre id="search-help" style="display: none">${h.tooltip(h.search_filter_help(c.searcher))}</pre>
|
||||
</div>
|
||||
|
||||
<div class="field">${c.runtime}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
${h.end_form()}
|
||||
<div class="search">
|
||||
% if c.search_type == 'content':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue