-
Notifications
You must be signed in to change notification settings - Fork 580
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix blank page when initiating a search with no search criteria (#7444)
* Fix blank page when initiating a search with no search criteria * Update source/_templates/search.html Co-authored-by: Carrie Warner (Mattermost) <[email protected]> * Update source/_templates/search.html Co-authored-by: Carrie Warner (Mattermost) <[email protected]> --------- Co-authored-by: Carrie Warner (Mattermost) <[email protected]>
- Loading branch information
1 parent
1b3e78f
commit 365a14b
Showing
1 changed file
with
68 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,70 @@ | ||
{% extends "page.html" %} | ||
{%- block regular_scripts -%} | ||
{# Load lunr.js and mark.js before anything else #} | ||
<script type="text/javascript" src="https://unpkg.com/[email protected]/lunr.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.es6.min.js" | ||
integrity="sha512-jZSRKDD86PmExf0ZoXQEMxhtxvLtOxo2xMJwgnx3VE/5VT5c8LCsnvut4wK3fIdFyO4szlbz/2tpg+xulnJDyQ==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer"></script> | ||
{{ super() }} | ||
<script src="{{ pathto('_static/js/mattermost-search.js', 1) }}"></script> | ||
<script src="{{ pathto('_static/language_data.js', 1) }}"></script> | ||
{%- endblock regular_scripts -%} | ||
{%- block htmltitle -%} | ||
<title>{{ _("Search") }} - {{ docstitle }}</title> | ||
{%- endblock htmltitle -%} | ||
{% block content %} | ||
<noscript> | ||
<div class="admonition error"> | ||
<p class="admonition-title">{% trans %}Error{% endtrans %}</p> | ||
<p> | ||
{% trans %}Please activate JavaScript to enable the search functionality.{% endtrans %} | ||
</p> | ||
</div> | ||
</noscript> | ||
{% extends "page.html" %} {%- block regular_scripts -%} {# Load lunr.js and | ||
mark.js before anything else #} | ||
<script | ||
type="text/javascript" | ||
src="https://unpkg.com/[email protected]/lunr.js" | ||
></script> | ||
<script | ||
src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.es6.min.js" | ||
integrity="sha512-jZSRKDD86PmExf0ZoXQEMxhtxvLtOxo2xMJwgnx3VE/5VT5c8LCsnvut4wK3fIdFyO4szlbz/2tpg+xulnJDyQ==" | ||
crossorigin="anonymous" | ||
referrerpolicy="no-referrer" | ||
></script> | ||
{{ super() }} | ||
<script src="{{ pathto('_static/js/mattermost-search.js', 1) }}"></script> | ||
<script src="{{ pathto('_static/language_data.js', 1) }}"></script> | ||
{%- endblock regular_scripts -%} {%- block htmltitle -%} | ||
<title>{{ _("Search") }} - {{ docstitle }}</title> | ||
{%- endblock htmltitle -%} {% block content %} | ||
<noscript> | ||
<div class="admonition error"> | ||
<p class="admonition-title">{% trans %}Error{% endtrans %}</p> | ||
<p> | ||
{% trans %}Please activate JavaScript to enable the search | ||
functionality.{% endtrans %} | ||
</p> | ||
</div> | ||
</noscript> | ||
|
||
<div style="display:inline-block"> | ||
<h2 id="search-title" style="float: left;"></h2><h2 id="search-dots" style="float: right;"></h2> | ||
</div> | ||
<p id="search-summary" class="search-summary"></p> | ||
<!-- configuration setting-specific results will display here --> | ||
<div id="config-setting-results-section" style="display: none;"> | ||
<h3>Configuration settings</h3><a id="config-setting-results-anchor"></a> | ||
<div class="search" id="config-setting-results-list"></div> | ||
</div> | ||
<!-- all other results will display here --> | ||
<div id="search-additional-information-header" style="display: none;"> | ||
<h3>Additional information</h3><a id="search-results-anchor"></a> | ||
</div> | ||
<div id="search-results"> | ||
<ul class="search" id="search-results-list"></ul> | ||
</div> | ||
{% endblock %} | ||
{% block scripts -%} | ||
{{ super() }} | ||
{# Load the search indexes after the DOM has finished loading #} | ||
<script lang="js"> | ||
_ready(() => { | ||
Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); | ||
}); | ||
_ready(() => { | ||
Search.loadConfigSettingsIndex("{{ pathto('config-settings-index.json', 1) }}"); | ||
}); | ||
</script> | ||
<div style="display: inline-block"> | ||
<h2 id="search-title" style="float: left"></h2> | ||
<h2 id="search-dots" style="float: right"></h2> | ||
</div> | ||
<p id="search-summary" class="search-summary"></p> | ||
<!-- configuration setting-specific results will display here --> | ||
<div id="config-setting-results-section" style="display: none"> | ||
<h3>Configuration settings</h3> | ||
<a id="config-setting-results-anchor"></a> | ||
<div class="search" id="config-setting-results-list"></div> | ||
</div> | ||
<!-- all other results will display here --> | ||
<div id="search-additional-information-header" style="display: none"> | ||
<h3>Additional information</h3> | ||
<a id="search-results-anchor"></a> | ||
</div> | ||
<div id="search-results"> | ||
<ul class="search" id="search-results-list"></ul> | ||
</div> | ||
{% endblock %} {% block scripts -%} {{ super() }} {# Load the search indexes | ||
after the DOM has finished loading #} | ||
<script lang="js"> | ||
_ready(() => { | ||
Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); | ||
}); | ||
_ready(() => { | ||
Search.loadConfigSettingsIndex("{{ pathto('config-settings-index.json', 1) }}"); | ||
}); | ||
|
||
document.addEventListener('DOMContentLoaded', function() { | ||
const searchTitle = document.getElementById('search-title'); | ||
const searchResults = document.getElementById('search-results'); | ||
const searchSummary = document.getElementById('search-summary'); | ||
const searchQuery = new URLSearchParams(window.location.search).get('q'); | ||
|
||
if (!searchQuery || searchQuery.trim() === '') { | ||
searchTitle.textContent = "Search Results"; | ||
searchSummary.textContent = "Please enter at least one search term."; | ||
} | ||
}); | ||
</script> | ||
{%- endblock scripts %} |