diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java index 510cb2532..b74979164 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java @@ -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 { diff --git a/webapp/web/css/search.css b/webapp/web/css/search.css index 35b6857eb..b3717888a 100644 --- a/webapp/web/css/search.css +++ b/webapp/web/css/search.css @@ -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; } \ No newline at end of file diff --git a/webapp/web/images/download-icon.png b/webapp/web/images/download-icon.png new file mode 100644 index 000000000..dd3213204 Binary files /dev/null and b/webapp/web/images/download-icon.png differ diff --git a/webapp/web/js/searchDownload.js b/webapp/web/js/searchDownload.js new file mode 100644 index 000000000..7d9da55a8 --- /dev/null +++ b/webapp/web/js/searchDownload.js @@ -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: '
Download the results from this search
download results in XML format
download results in CSV format

close' + }, + 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; + }); +}); \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/search/search-csvResults.ftl b/webapp/web/templates/freemarker/body/search/search-csvResults.ftl index 8cd910e05..0656e8e6a 100644 --- a/webapp/web/templates/freemarker/body/search/search-csvResults.ftl +++ b/webapp/web/templates/freemarker/body/search/search-csvResults.ftl @@ -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} - +URI, Name +<#list individuals as individual> +"${individual.uri}","${individual.name}" + diff --git a/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl b/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl index e5e14dc95..5d96408bd 100644 --- a/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl +++ b/webapp/web/templates/freemarker/body/search/search-pagedResults.ftl @@ -2,21 +2,27 @@ <#-- Template for displaying paged search results --> -

+ + +

<#escape x as x?html> Search results for '${querytext}' <#if classGroupName?has_content>limited to type '${classGroupName}' <#if typeName?has_content>limited to type '${typeName}' - - XML/RDF Results - - +

+ + Download Results + + Not the results you expected? -
+
<#-- Refinement links --> <#if classGroupLinks?has_content> @@ -100,3 +106,8 @@
${stylesheets.add('')} + +${headScripts.add('', + '')} + +${scripts.add('')}