Fixed controller for CSV output, added button and coorsponding js and png
This commit is contained in:
parent
96bed7ce03
commit
32395cbac2
6 changed files with 86 additions and 13 deletions
|
@ -105,12 +105,13 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
|||
boolean wasCSVRequested = isRequestedFormatCSV(vreq);
|
||||
if( !wasXmlRequested && !wasCSVRequested){
|
||||
super.doGet(vreq,response);
|
||||
}else if (wasXMLRequested){
|
||||
}else if (wasXmlRequested){
|
||||
try {
|
||||
ResponseValues rvalues = processRequest(vreq);
|
||||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("text/xml;charset=UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=search.xml");
|
||||
writeTemplate(rvalues.getTemplateName(), rvalues.getMap(), request, response);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
|
@ -121,6 +122,7 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
|||
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentType("text/csv;charset=UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=search.csv");
|
||||
writeTemplate(rvalues.getTemplateName(), rvalues.getMap(), request, response);
|
||||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
|
@ -134,8 +136,9 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
|||
//There may be other non-html formats in the future
|
||||
Format format = getFormat(vreq);
|
||||
boolean wasXmlRequested = Format.XML == format;
|
||||
boolean wasCSVRequested = Format.CSV == format;
|
||||
log.debug("Requested format was " + (wasXmlRequested ? "xml" : "html"));
|
||||
boolean wasHtmlRequested = ! wasXmlRequested;
|
||||
boolean wasHtmlRequested = ! (wasXmlRequested || wasCSVRequested);
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -79,7 +79,22 @@ ul.searchTips li {
|
|||
}
|
||||
span#searchHelp {
|
||||
float:right;
|
||||
margin-top:-45px;
|
||||
margin-top:10px;
|
||||
font-size:.825em;
|
||||
padding-right:32px
|
||||
}
|
||||
|
||||
span#downloadResults {
|
||||
float:left;
|
||||
margin-top:10px;
|
||||
font-size:.825em;
|
||||
padding-left:10px
|
||||
}
|
||||
|
||||
img#downloadIcon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.download-url {
|
||||
padding: 5px 25px 5px;
|
||||
}
|
BIN
webapp/web/images/download-icon.png
Normal file
BIN
webapp/web/images/download-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
44
webapp/web/js/searchDownload.js
Normal file
44
webapp/web/js/searchDownload.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
$(document).ready(function(){
|
||||
// This function creates and styles the "qTip" tooltip that displays the resource uri and the rdf link when the user clicks the uri/rdf icon.
|
||||
$('span#downloadResults').children('img#downloadIcon').each(function()
|
||||
{
|
||||
$(this).qtip(
|
||||
{
|
||||
content: {
|
||||
prerender: true, // We need this for the .click() event listener on 'a.close'
|
||||
text: '<h5>Download the results from this search</h5> <h5 class ="download-url"><a href="' + urlsBase + '/search?querytext=' + queryText +'&xml=1&hitsPerPage=500">download results in XML format</a></h5><h5 class ="download-url"><a href="' + urlsBase + '/search?querytext=' + queryText +'&csv=1&hitsPerPage=500">download results in CSV format</a></h5><br /><a class="close" href="#">close</a>'
|
||||
},
|
||||
position: {
|
||||
corner: {
|
||||
target: 'bottomLeft',
|
||||
tooltip: 'topLeft'
|
||||
}
|
||||
},
|
||||
show: {
|
||||
when: {event: 'click'}
|
||||
},
|
||||
hide: {
|
||||
fixed: true, // Make it fixed so it can be hovered over and interacted with
|
||||
when: {
|
||||
target: $('a.close'),
|
||||
event: 'click'
|
||||
}
|
||||
},
|
||||
style: {
|
||||
padding: '1em',
|
||||
width: 350,
|
||||
backgroundColor: '#f1f2ee'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Prevent close link for URI qTip from requesting bogus '#' href
|
||||
$('a.close').click(function() {
|
||||
$('#downloadIcon').qtip("hide");
|
||||
return false;
|
||||
});
|
||||
});
|
|
@ -1,5 +1,5 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
URI, Name
|
||||
<#list individuals as individual>
|
||||
${individual.uri?xml},${individual.name?xml}
|
||||
"${individual.uri}","${individual.name}"
|
||||
</#list>
|
||||
|
|
|
@ -2,21 +2,27 @@
|
|||
|
||||
<#-- Template for displaying paged search results -->
|
||||
|
||||
<h2>
|
||||
|
||||
|
||||
<h2 style="float:left">
|
||||
<#escape x as x?html>
|
||||
Search results for '${querytext}'
|
||||
<#if classGroupName?has_content>limited to type '${classGroupName}'</#if>
|
||||
<#if typeName?has_content>limited to type '${typeName}'</#if>
|
||||
</#escape>
|
||||
<span id="downloadResults">
|
||||
<img src="images/share-uri-icon.png" alt="XML/RDF Results" />
|
||||
|
||||
</span>
|
||||
<script>
|
||||
var queryText = '${querytext}'
|
||||
var urlsBase = '${urls.base}'
|
||||
</script>
|
||||
</h2>
|
||||
|
||||
<span id="downloadResults" title="Download Results">
|
||||
<img id="downloadIcon" src="images/download-icon.png" alt="Download Results" />
|
||||
</span>
|
||||
|
||||
<span id="searchHelp"><a href="${urls.base}/searchHelp" title="search help">Not the results you expected?</a></span>
|
||||
|
||||
<div class="contentsBrowseGroup">
|
||||
<div class="contentsBrowseGroup" style="clear:left">
|
||||
|
||||
<#-- Refinement links -->
|
||||
<#if classGroupLinks?has_content>
|
||||
|
@ -100,3 +106,8 @@
|
|||
</div> <!-- end contentsBrowseGroup -->
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/search.css" />')}
|
||||
|
||||
${headScripts.add('<script type="text/javascript" src="${urls.base}/js/jquery_plugins/qtip/jquery.qtip-1.0.0-rc3.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