Renamed custom search to extended search. Moved templates from VIVO repository
This commit is contained in:
parent
cdcc051d3f
commit
c1b01cd757
5 changed files with 283 additions and 14 deletions
|
@ -37,7 +37,7 @@ public class UrlBuilder {
|
|||
LOGIN("/login"),
|
||||
LOGOUT("/logout"),
|
||||
OBJECT_PROPERTY_EDIT("/propertyEdit"),
|
||||
CUSTOMSEARCH("/customsearch"),
|
||||
EXTENDED_SEARCH("/extendedsearch"),
|
||||
SEARCH("/search"),
|
||||
SITE_ADMIN("/siteAdmin"),
|
||||
TERMS_OF_USE("/termsOfUse"),
|
||||
|
|
|
@ -304,7 +304,7 @@ public class FreemarkerConfigurationImpl extends Configuration {
|
|||
urls.put("home", UrlBuilder.getHomeUrl());
|
||||
urls.put("about", UrlBuilder.getUrl(Route.ABOUT));
|
||||
urls.put("search", UrlBuilder.getUrl(Route.SEARCH));
|
||||
urls.put("customsearch", UrlBuilder.getUrl(Route.CUSTOMSEARCH));
|
||||
urls.put("extendedsearch", UrlBuilder.getUrl(Route.EXTENDED_SEARCH));
|
||||
urls.put("termsOfUse", UrlBuilder.getUrl(Route.TERMS_OF_USE));
|
||||
urls.put("login", UrlBuilder.getLoginUrl());
|
||||
urls.put("logout", UrlBuilder.getLogoutUrl());
|
||||
|
|
|
@ -58,11 +58,11 @@ import edu.ucsf.vitro.opensocial.OpenSocialManager;
|
|||
* Paged search controller that uses the search engine
|
||||
*/
|
||||
|
||||
@WebServlet(name = "CustomSearchController", urlPatterns = {"/customsearch","/customsearch.jsp","/customfedsearch","/customsearchcontroller"} )
|
||||
public class CustomSearchController extends FreemarkerHttpServlet {
|
||||
@WebServlet(name = "ExtendedSearchController", urlPatterns = {"/extendedsearch","/extendedsearch.jsp","/extendedfedsearch","/extendedsearchcontroller"} )
|
||||
public class ExtendedSearchController extends FreemarkerHttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(CustomSearchController.class);
|
||||
private static final Log log = LogFactory.getLog(ExtendedSearchController.class);
|
||||
|
||||
protected static final int DEFAULT_HITS_PER_PAGE = 25;
|
||||
protected static final int DEFAULT_MAX_HIT_COUNT = 1000;
|
||||
|
@ -74,6 +74,7 @@ public class CustomSearchController extends FreemarkerHttpServlet {
|
|||
private static final String PARAM_CLASSGROUP = "classgroup";
|
||||
private static final String PARAM_RDFTYPE = "type";
|
||||
private static final String PARAM_QUERY_TEXT = "querytext";
|
||||
private static final String EXTENDEDSEARCH = "/extendedsearch";
|
||||
|
||||
protected static final Map<Format,Map<Result,String>> templateTable;
|
||||
|
||||
|
@ -552,9 +553,9 @@ public class CustomSearchController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
public static class VClassGroupSearchLink extends LinkTemplateModel {
|
||||
long count = 0;
|
||||
long count = 0;
|
||||
VClassGroupSearchLink(String querytext, VClassGroup classgroup, long count) {
|
||||
super(classgroup.getPublicName(), "/customsearch", PARAM_QUERY_TEXT, querytext, PARAM_CLASSGROUP, classgroup.getURI());
|
||||
super(classgroup.getPublicName(), EXTENDEDSEARCH, PARAM_QUERY_TEXT, querytext, PARAM_CLASSGROUP, classgroup.getURI());
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
@ -564,7 +565,7 @@ public class CustomSearchController extends FreemarkerHttpServlet {
|
|||
public static class VClassSearchLink extends LinkTemplateModel {
|
||||
long count = 0;
|
||||
VClassSearchLink(String querytext, VClass type, long count) {
|
||||
super(type.getName(), "/customsearch", PARAM_QUERY_TEXT, querytext, PARAM_RDFTYPE, type.getURI());
|
||||
super(type.getName(), EXTENDEDSEARCH, PARAM_QUERY_TEXT, querytext, PARAM_RDFTYPE, type.getURI());
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
@ -738,15 +739,15 @@ public class CustomSearchController extends FreemarkerHttpServlet {
|
|||
HashMap<Result,String> resultsToTemplates = new HashMap<Result,String>();
|
||||
|
||||
// set up HTML format
|
||||
resultsToTemplates.put(Result.PAGED, "search-pagedResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "search-error.ftl");
|
||||
resultsToTemplates.put(Result.PAGED, "extendedsearch-pagedResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "extendedsearch-error.ftl");
|
||||
// resultsToTemplates.put(Result.BAD_QUERY, "search-badQuery.ftl");
|
||||
table.put(Format.HTML, Collections.unmodifiableMap(resultsToTemplates));
|
||||
|
||||
// set up XML format
|
||||
resultsToTemplates = new HashMap<Result,String>();
|
||||
resultsToTemplates.put(Result.PAGED, "search-xmlResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "search-xmlError.ftl");
|
||||
resultsToTemplates.put(Result.PAGED, "extendedsearch-xmlResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "extendedsearch-xmlError.ftl");
|
||||
|
||||
// resultsToTemplates.put(Result.BAD_QUERY, "search-xmlBadQuery.ftl");
|
||||
table.put(Format.XML, Collections.unmodifiableMap(resultsToTemplates));
|
||||
|
@ -754,8 +755,8 @@ public class CustomSearchController extends FreemarkerHttpServlet {
|
|||
|
||||
// set up CSV format
|
||||
resultsToTemplates = new HashMap<Result,String>();
|
||||
resultsToTemplates.put(Result.PAGED, "search-csvResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "search-csvError.ftl");
|
||||
resultsToTemplates.put(Result.PAGED, "extendedsearch-csvResults.ftl");
|
||||
resultsToTemplates.put(Result.ERROR, "extendedsearch-csvError.ftl");
|
||||
|
||||
// resultsToTemplates.put(Result.BAD_QUERY, "search-xmlBadQuery.ftl");
|
||||
table.put(Format.CSV, Collections.unmodifiableMap(resultsToTemplates));
|
|
@ -0,0 +1,16 @@
|
|||
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
||||
|
||||
<#-- Template for displaying search error message -->
|
||||
|
||||
<#if title??>
|
||||
<div class="errorPageTitle">
|
||||
<h2>${title?html}</h2>
|
||||
</div>
|
||||
</#if>
|
||||
<div id="nomatchingTitle">
|
||||
<p>
|
||||
${message?html}
|
||||
</p>
|
||||
</div>
|
||||
<#include "searchSelector.ftl">
|
||||
<#include "search-help.ftl" >
|
|
@ -0,0 +1,252 @@
|
|||
<#-- $This file is distributed under the terms of the license in LICENSE$ -->
|
||||
|
||||
<#-- Template for displaying paged search results -->
|
||||
|
||||
<h2 class="searchResultsHeader">
|
||||
|
||||
<#include "searchSelector.ftl">
|
||||
|
||||
<#escape x as x?html>
|
||||
<div id='searchQueryResults'> ${i18n().search_results_for} '${querytext}'</div>
|
||||
<div id='limitedToClassGroup'> <#if classGroupName?has_content>${i18n().limited_to_type} '${classGroupName}'</#if> </div>
|
||||
<div id='limitedToType'> <#if typeName?has_content>${i18n().limited_to_type} '${typeName}'</#if> </div>
|
||||
</#escape>
|
||||
<script type="text/javascript">
|
||||
var url = window.location.toString();
|
||||
if (url.indexOf("?") == -1){
|
||||
var queryText = 'querytext=${querytext}';
|
||||
} else {
|
||||
var urlArray = url.split("?");
|
||||
var queryText = urlArray[1];
|
||||
}
|
||||
|
||||
var urlsBase = '${urls.base}';
|
||||
</script>
|
||||
|
||||
<img id="downloadIcon" src="images/download-icon.png" alt="${i18n().download_results}" title="${i18n().download_results}" />
|
||||
<#-- <span id="downloadResults" style="float:left"></span> -->
|
||||
</h2>
|
||||
|
||||
<span id="searchHelp"><a href="${urls.base}/searchHelp" title="${i18n().search_help}">${i18n().not_expected_results}</a></span>
|
||||
<div class="contentsBrowseGroup">
|
||||
|
||||
<#-- Refinement links -->
|
||||
<#if classGroupLinks?has_content && classGroupLinks?size gt 1>
|
||||
<div class="searchTOC">
|
||||
<h4>${i18n().display_only}</h4>
|
||||
<ul>
|
||||
<#list classGroupLinks as link>
|
||||
<li><a href="${link.url}" title="${i18n().class_group_link}">${link.text}</a><span>(${link.count})</span></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
<#if classLinks?has_content && classLinks?size gt 1 >
|
||||
<div class="searchTOC">
|
||||
<#if classGroupName?has_content>
|
||||
<h4>${i18n().limit} ${classGroupName} ${i18n().to}</h4>
|
||||
<#else>
|
||||
<h4>${i18n().limit_to}</h4>
|
||||
</#if>
|
||||
<ul>
|
||||
<#list classLinks as link>
|
||||
<li><a href="${link.url}" title="${i18n().class_link}">${link.text}</a><span>(${link.count})</span></li>
|
||||
</#list>
|
||||
</ul>
|
||||
</div>
|
||||
</#if>
|
||||
|
||||
|
||||
<div class="virtualArticleSwitch">
|
||||
<label class="switch">${i18n().show_virtual_article}
|
||||
<input id="virtualArticleCheck" type="checkbox" checked="false" onclick="showVirtualArticles();">
|
||||
</label>
|
||||
<#if user.loggedIn>
|
||||
<button onclick="createNewCompilation()">${i18n().create_compilation_button}</button>
|
||||
</#if>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<#-- Search results -->
|
||||
<ul class="searchhits">
|
||||
<#list individuals as individual>
|
||||
<li>
|
||||
<@shortView uri=individual.uri viewContext="search" />
|
||||
</li>
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
|
||||
<#-- Paging controls -->
|
||||
<#if (pagingLinks?size > 0)>
|
||||
<div class="searchpages">
|
||||
${i18n().pages}:
|
||||
<#if prevPage??><a class="prev" href="${prevPage}" title="${i18n().previous}">${i18n().previous}</a></#if>
|
||||
<#list pagingLinks as link>
|
||||
<#if link.url??>
|
||||
<a href="${link.url}" title="${i18n().page_link}">${link.text}</a>
|
||||
<#else>
|
||||
<span>${link.text}</span> <#-- no link if current page -->
|
||||
</#if>
|
||||
</#list>
|
||||
<#if nextPage??><a class="next" href="${nextPage}" title="${i18n().next_capitalized}">${i18n().next_capitalized}</a></#if>
|
||||
</div>
|
||||
</#if>
|
||||
<br />
|
||||
|
||||
<#-- VIVO OpenSocial Extension by UCSF -->
|
||||
<#if openSocial??>
|
||||
<#if openSocial.visible>
|
||||
<h3>OpenSocial</h3>
|
||||
<script type="text/javascript" language="javascript">
|
||||
// find the 'Search' gadget(s).
|
||||
var searchGadgets = my.findGadgetsAttachingTo("gadgets-search");
|
||||
var keyword = '${querytext}';
|
||||
// add params to these gadgets
|
||||
if (keyword) {
|
||||
for (var i = 0; i < searchGadgets.length; i++) {
|
||||
var searchGadget = searchGadgets[i];
|
||||
searchGadget.additionalParams = searchGadget.additionalParams || {};
|
||||
searchGadget.additionalParams["keyword"] = keyword;
|
||||
}
|
||||
}
|
||||
else { // remove these gadgets
|
||||
my.removeGadgets(searchGadgets);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="gadgets-search" class="gadgets-gadget-parent" style="display:inline-block"></div>
|
||||
</#if>
|
||||
</#if>
|
||||
|
||||
</div> <!-- end contentsBrowseGroup -->
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', createVirtualCompilation(), false);
|
||||
|
||||
$('input[type=checkbox]').removeAttr('checked');
|
||||
function showVirtualArticles(){
|
||||
var checkBox = document.getElementById("virtualArticleCheck");
|
||||
if (checkBox.checked == true){
|
||||
$('.searchResult').hide();
|
||||
$('.virtualArticlePart').show();
|
||||
} else {
|
||||
$('.searchResult').show();
|
||||
$('.virtualArticlePart').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function createNewCompilation() {
|
||||
var excerpts = $('.compilationDraftExcerpt').toArray();
|
||||
if (excerpts.length == 0){
|
||||
alert("${i18n().create_compilation_no_excerpts}");
|
||||
return;
|
||||
}
|
||||
var compilationName = window.prompt("${i18n().create_compilation_enter_name_notification}");
|
||||
if (!compilationName){
|
||||
alert("${i18n().create_compilation_no_name_entered_error}");
|
||||
return;
|
||||
}
|
||||
var iframe = document.createElement("iframe");
|
||||
var excerptsCounter = $('.compilationDraftExcerpt').length;
|
||||
iframe.setAttribute("src", "${urls.base}/editRequestDispatch?typeOfNew=https%3A%2F%2Flitvinovg.pro%2Ftext_structures%23compilation&editForm=edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.CompilationGenerator&excerptsCount=" + excerptsCounter);
|
||||
iframe.style.width = "1px";
|
||||
iframe.style.height = "1px";
|
||||
iframe.id="newCompilationIframe";
|
||||
//iframe.style.display="none";
|
||||
document.body.appendChild(iframe);
|
||||
$('#newCompilationIframe').on('load', function(){
|
||||
fillOutForm(compilationName);
|
||||
});
|
||||
}
|
||||
|
||||
function fillOutForm(compilationName){
|
||||
var iframeDoc = document.getElementById('newCompilationIframe').contentWindow.document;
|
||||
var rules = $('#builder').queryBuilder('getRules', { get_flags: true });
|
||||
var query = format_query_string(rules, "", false);
|
||||
iframeDoc.getElementById('queryBuilderRules').value = JSON.stringify(rules);
|
||||
iframeDoc.getElementById('rawQueryString').value = query;
|
||||
|
||||
|
||||
iframeDoc.getElementById('newCompilationLabel').value = compilationName;
|
||||
var excerpts = $('.compilationDraftExcerpt').toArray();
|
||||
for (i = 0;i < excerpts.length;i++){
|
||||
var excerptUri = excerpts[i].getAttribute('partUri');
|
||||
var excerptName = excerpts[i].getAttribute('partName');
|
||||
var number = i + 1;
|
||||
iframeDoc.getElementById("tocLevel" + number + "Name").value = excerptName + " (" + compilationName + ")";
|
||||
iframeDoc.getElementById("tocItem" + number + "Name").value = excerptName + " (" + compilationName + ")";
|
||||
iframeDoc.getElementById("excerpt" + number).value = excerptUri;
|
||||
}
|
||||
$('#newCompilationIframe').off('load');
|
||||
iframeDoc.getElementById('submit').click();
|
||||
$('#newCompilationIframe').on('load', function(){
|
||||
redirectToNewCompilation();
|
||||
});
|
||||
|
||||
}
|
||||
function redirectToNewCompilation(){
|
||||
var newURL = document.getElementById('newCompilationIframe').contentWindow.location.href;
|
||||
window.open(newURL,"_self");
|
||||
}
|
||||
|
||||
function createVirtualCompilation(){
|
||||
let workSet = new Set();
|
||||
let biblioSet = new Set();
|
||||
var workDivs = $('.virtualArticleWork');
|
||||
var biblioDivs = $('.virtualArticleBibliography');
|
||||
biblioDivs.each(function() {
|
||||
biblioSet.add($(this).html());
|
||||
});
|
||||
workDivs.each(function() {
|
||||
workSet.add($(this).html());
|
||||
});
|
||||
var workArr = Array.from(workSet);
|
||||
workArr.sort();
|
||||
var biblioArr = Array.from(biblioSet);
|
||||
biblioArr.sort();
|
||||
if (workArr.length > 0 ) {
|
||||
$('<div class="virtualWorks virtualArticlePart"><button type="button" style="border:none;width: 100%; text-align:left;" class="collapsible">${i18n().sources_excerpt_button_text}</button><div class="virtualWorks"></div></div>').insertAfter($('.virtualArticlePart').last());
|
||||
for (let value of workArr){
|
||||
$('.virtualWorks').last().append( '<div class="work"><p>' + value + '</p></div>' );
|
||||
}
|
||||
}
|
||||
if (biblioArr.length > 0 ) {
|
||||
$('<div class="virtualBibliography virtualArticlePart"><button type="button" style="border:none;width: 100%; text-align:left;" class="collapsible">${i18n().literature_excerpt_button_text}</button><div class="virtualBibliography"></div></div>').insertAfter($('.virtualArticlePart').last());
|
||||
for (let value of biblioArr){
|
||||
$('.virtualBibliography').last().append( '<div class="bibliography"><p>' + value + '</p></div>' );
|
||||
}
|
||||
}
|
||||
$('.virtualWorks').hide();
|
||||
$('.virtualBibliography').hide();
|
||||
$('.virtualArticlePart').hide();
|
||||
var coll = document.getElementsByClassName("collapsible");
|
||||
var i;
|
||||
for (i = 0; i < coll.length; i++) {
|
||||
coll[i].addEventListener("click", function() {
|
||||
this.classList.toggle("active");
|
||||
var content = this.nextElementSibling;
|
||||
if (content.style.display === "block") {
|
||||
content.style.display = "none";
|
||||
} else {
|
||||
content.style.display = "block";
|
||||
}
|
||||
});
|
||||
}
|
||||
createRemoveButtons();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />',
|
||||
'<link rel="stylesheet" href="${urls.base}/css/search.css" />',
|
||||
'<link rel="stylesheet" type="text/css" href="${urls.base}/css/jquery_plugins/qtip/jquery.qtip.min.css" />')}
|
||||
|
||||
${headScripts.add('<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/qtip/jquery.qtip.min.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/tiny_mce/tiny_mce.js"></script>'
|
||||
)}
|
||||
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/searchDownload.js"></script>')}
|
Loading…
Add table
Reference in a new issue