nm3clol-express-app/views/search-results.ejs

84 lines
3.7 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<title>Search Results for <%- query %> - <%- h.getSiteName() %></title>
<%- include('./includes/common-head.ejs') %>
</head>
<body>
<%- include('./includes/top-navbar.ejs') %>
<%- include('./includes/no-trash-svg.ejs') %>
<main class="container">
<header>
<h1 class="mt-5" style="font-family: 'Covered By Your Grace'">
<a href="/"><%=h.getSiteName()%></a>
<span class="separator">&rsaquo; </span>
Search Results for <%- query %>
</h1>
</header>
<div class="container">
<p>
Disclaimer: Use of the search feature is subject to both the <a href="/search-policy">Search
Policy</a> and the <a href="/privacy-policy">Privacy Policy</a>.
</p>
</div>
<% if (typeof response !== "undefined" && typeof response.numFound !== "undefined" && typeof response.docs !== "undefined" && typeof highlighting !== "undefined") { %>
<div id="searchResults" class="mt-3 shadow-lg">
<!-- Search results will be dynamically populated here -->
<% if (response.numFound == 0) { %>
<p>No documents found matching the search query.</p>
<% } else { %>
<ul class="list-group shadow-lg">
<% response.docs.forEach(doc => { %>
<li class="list-group-item list-group-item-action flex-column align-items-start">
<h5><%= doc.title %></h5>
<% if (highlighting[doc.id] && highlighting[doc.id].text) { %>
<% highlighting[doc.id].text.forEach(snippet => { %>
<pre><%- h.stripWebVTT(snippet) %></pre>
<% }); %>
<% } else { %>
<!-- <p>No highlight available.</p> -->
<% } %>
<a href="<%= doc.url %>"><%= doc.url %></a>
</li>
<% }); %>
</ul>
<% } %>
</div>
</div>
<% } %>
<!-- Pagination controls -->
<% if (typeof totalPages !== "undefined" && totalPages) { %>
<nav aria-label="Search results pagination">
<ul class="pagination justify-content-center mt-4">
<% if (page > 1) { %>
<li class="page-item">
<a class="page-link" href="/search?q=<%= query %>&page=<%= page - 1 %>&pageSize=<%= pageSize %>">Previous</a>
</li>
<% } %>
<% for (let i = Math.max(Math.min(page - 7, totalPages - 14), 1); i <= Math.min(totalPages, Math.max(page - 7, 1) + 14); i++) { %>
<li class="page-item <%= i == page ? 'active' : '' %>">
<a class="page-link" href="/search?q=<%= query %>&page=<%= i %>&pageSize=<%= pageSize %>"><%= i %></a>
</li>
<% } %>
<% if (page < totalPages) { %>
<li class="page-item">
<a class="page-link" href="/search?q=<%= query %>&page=<%= parseInt(page) + 1 %>&pageSize=<%= pageSize %>">Next</a>
</li>
<% } %>
</ul>
</nav>
<p class="center">Page <%= page %> out of <%= totalPages %>. Displaying results <%= (page-1)*pageSize+1 %> through <%= Math.min(page*pageSize, totalResults) %> out of <%= totalResults %> total results.</p>
<% } %>
</main>
<%- include('./includes/bottom-navbar.ejs') %>
<!-- Bootstrap JS (optional, if you need Bootstrap JS features) -->
<script src="https://daball.me/vendor/jquery/jquery.min.js"></script>
<script src="https://daball.me/vendor/popper.js/dist/popper.min.js"></script>
<script src="https://daball.me/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="https://daball.me/vendor/jquery-easing/jquery.easing.min.js"></script>
<script src="https://daball.me/layouts/blog/js/blog.min.js"></script>
</body>
</html>