mirror of
https://github.com/djohnlewis/stackdump
synced 2025-04-08 10:43:28 +00:00
Re-ordered the Stackdump-wide search method in code so it is processed before the site-specific methods. This means even if a site is imported with the key 'search', it can't replace that page.
This commit is contained in:
parent
caebcabd89
commit
84f5a951ed
@ -225,6 +225,24 @@ def import_data():
|
|||||||
'''
|
'''
|
||||||
return render_template('import_data.html')
|
return render_template('import_data.html')
|
||||||
|
|
||||||
|
# this method MUST sit above the site_index and other methods below so it
|
||||||
|
# cannot be subverted by a site with a site key of 'search'.
|
||||||
|
@get('/search')
|
||||||
|
@uses_templates
|
||||||
|
@uses_solr
|
||||||
|
@uses_db
|
||||||
|
def search():
|
||||||
|
context = { }
|
||||||
|
context['sites'] = get_sites()
|
||||||
|
|
||||||
|
search_context = perform_search()
|
||||||
|
if not search_context:
|
||||||
|
raise HTTPError(code=500, output='Invalid query attempted.')
|
||||||
|
|
||||||
|
context.update(search_context)
|
||||||
|
|
||||||
|
return render_template('results.html', context)
|
||||||
|
|
||||||
@get('/:site_key#[\w\.]+#')
|
@get('/:site_key#[\w\.]+#')
|
||||||
@get('/:site_key#[\w\.]+#/')
|
@get('/:site_key#[\w\.]+#/')
|
||||||
@uses_templates
|
@uses_templates
|
||||||
@ -243,22 +261,6 @@ def site_index(site_key):
|
|||||||
|
|
||||||
return render_template('index.html', context)
|
return render_template('index.html', context)
|
||||||
|
|
||||||
@get('/search')
|
|
||||||
@uses_templates
|
|
||||||
@uses_solr
|
|
||||||
@uses_db
|
|
||||||
def search():
|
|
||||||
context = { }
|
|
||||||
context['sites'] = get_sites()
|
|
||||||
|
|
||||||
search_context = perform_search()
|
|
||||||
if not search_context:
|
|
||||||
raise HTTPError(code=500, output='Invalid query attempted.')
|
|
||||||
|
|
||||||
context.update(search_context)
|
|
||||||
|
|
||||||
return render_template('results.html', context)
|
|
||||||
|
|
||||||
@get('/:site_key#[\w\.]+#/search')
|
@get('/:site_key#[\w\.]+#/search')
|
||||||
@uses_templates
|
@uses_templates
|
||||||
@uses_solr
|
@uses_solr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user