Commit a9e1596d authored by Matija Obreza's avatar Matija Obreza
Browse files

Updated display of search results

parent 4b90ea42
......@@ -26,6 +26,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.util.HtmlUtils;
@Controller
@RequestMapping("/search")
......@@ -39,6 +40,7 @@ public class SearchController {
public String find(ModelMap model, @RequestParam(required = false, value = "q") String searchQuery,
@RequestParam(value = "page", required = false, defaultValue = "1") int page) {
model.addAttribute("q", HtmlUtils.htmlEscape(searchQuery));
if (!StringUtils.isBlank(searchQuery)) {
LOG.info("Searching for: " + searchQuery);
Page<?> x = searchService.search(searchQuery, new String[] { "title", "body", "description" }, page - 1, 50);
......
......@@ -13,7 +13,7 @@
<link type="text/css" href="/html/css/bootstrap.css" rel="stylesheet" />
<link type="text/css" href="/html/css/custom.css" rel="stylesheet" />
<!--
<script type="text/javascript" src="/html/js/jquery.min.js"></script>
<script type="text/javascript" src="/html/js/modernizr-2.6.2.min.js"></script>
<script type="text/javascript" src="/html/js/plugins.js"></script>
......@@ -23,17 +23,17 @@
<link type="text/css" href="/html/css/jquery-ui.css" rel="stylesheet" />
<link type="text/css" href="/html/css/jquery.dataTables.css" rel="stylesheet" />
-->
<%--Fallback for older browsers--%>
<script type="text/javascript" src="/html/js/json2.js"></script>
<!--
<script type="text/javascript" src="/html/js/globalize.js"></script>
<script type="text/javascript" src="/html/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/html/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="/html/js/handlebars.js"></script>
<script type="text/javascript" src="/html/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/html/js/main.js"></script>
<script type="text/javascript" src="/html/js/handlebars.js"></script> -->
<!-- <script type="text/javascript" src="/html/js/bootstrap.min.js"></script>
--><!-- <script type="text/javascript" src="/html/js/main.js"></script>
-->
<sitemesh:write property="head" />
</head>
......@@ -82,10 +82,10 @@
</sec:authorize>
</div>
<div class="pull-right">
<form method="get" action="<c:url value="/search" />">
<input type="text" name="q" /> <input type="submit" value="Search" />
</form>
<div class="pull-right searcher" style="padding: 10px 15px 0 0;">
<form class="search form-horizontal" method="get" action="<c:url value="/search" />">
<input type="text" name="q" class="" /> <button type="submit"class="">Search</button>
</form>
</div>
</div>
</div>
......
......@@ -8,26 +8,53 @@
<title><spring:message code="sample.message.index.title" /></title>
</head>
<body>
<form method="get" action="<c:url value="/search" />">
<input type="text" name="q" /> <input type="submit" value="Search" />
<form class="form-horizontal" method="get" action="<c:url value="/search" />">
<input type="text" name="q" class="" value="<c:out value="${q}" />" /> <input type="submit" value="Search" class="" />
</form>
<c:if test="${searchResults.totalElements eq 0}">
<div class="alert">No results!</div>
</c:if>
<c:if test="${searchResults ne null and searchResults.totalElements gt 0}">
<div class="nav-header">
<spring:message code="paged.totalElements" arguments="${searchResults.totalElements}" />
<br />
<spring:message code="paged.pageOfPages" arguments="${searchResults.number+1},${searchResults.totalPages}" />
<a href="?page=${searchResults.number}">⇇ Previous</a> <a href="?page=${searchResults.number + 2}">Next ⇉</a>
<a href="?q=${q}&amp;page=${searchResults.number}">⇇ Previous</a> <a href="?q=${q}&amp;page=${searchResults.number + 2}">Next ⇉</a>
</div>
<ul class="funny-list">
<c:forEach items="${searchResults.content}" var="searchResult" varStatus="status">
<li>${searchResult}</li>
<li><small>${searchResult.getClass().simpleName} <b><fmt:formatNumber value="${status.count + (searchResults.number)*searchResults.size}" /></b>.</small>
<c:if test="${searchResult.getClass().simpleName eq 'Taxonomy'}">
<a href="<c:url value="/acn/t/${searchResult.genus}/${searchResult.species}" />"><c:out value="${searchResult.taxonName}" /></a>
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'Accession'}">
<a href="<c:url value="/acn/id/${searchResult.id}" />">${searchResult.accessionName}</a>
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'Crop'}">
<a href="<c:url value="/c/${searchResult.shortName}/data" />">${searchResult.name}</a>
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'FaoInstitute'}">
<a href="<c:url value="/wiews/${searchResult.code.toLowerCase()}" />">${searchResult.fullName}</a>
${searchResult.code} ${searchResult.country.name}
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'Metadata'}">
<a href="<c:url value="/data/view/${searchResult.id}" />">${searchResult.title}</a>
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'ActivityPost'}">
${searchResult.title}
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'Country'}">
<a href="<c:url value="/geo/${searchResult.code3.toLowerCase()}" />">${searchResult.name}</a>
</c:if>
<c:if test="${searchResult.getClass().simpleName eq 'Article'}">
<a href="<c:url value="/content/${searchResult.slug}" />">${searchResult.title}</a>
</c:if>
</li>
</c:forEach>
</ul>
</c:if>
......
......@@ -142,8 +142,8 @@ body {
}
.content-block *:FIRST-CHILD {
margin-top: 0;
padding-top: 0;
/* margin-top: 0;
padding-top: 0; */
}
#header {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment