From a273249c74fbe9fccb06b238b1e15b729da48d91 Mon Sep 17 00:00:00 2001 From: Andrew Carpenter Date: Fri, 27 Jan 2012 10:58:12 -0800 Subject: [PATCH] first pass at CSV search output --- app/controllers/entries/search_controller.rb | 6 ++++ app/searches/entry_search.rb | 2 +- app/stylesheets/design/_buttons.scss | 11 +----- app/stylesheets/design/_search.scss | 27 ++++++++++++-- app/stylesheets/ie6.scss | 6 ---- app/views/entries/search/header.html.erb | 8 +++-- app/views/entries/search/show.csv.erb | 22 ++++++++++++ .../public_inspection/search/header.html.erb | 6 ++-- .../page_specific/search/search.js | 35 ------------------- 9 files changed, 63 insertions(+), 60 deletions(-) create mode 100644 app/views/entries/search/show.csv.erb diff --git a/app/controllers/entries/search_controller.rb b/app/controllers/entries/search_controller.rb index ef6761b60..5a4819967 100644 --- a/app/controllers/entries/search_controller.rb +++ b/app/controllers/entries/search_controller.rb @@ -18,6 +18,12 @@ def show @entries = @search.results render :template => 'entries/index.rss.builder' end + wants.csv do + @search.per_page = 100 + @entries = @search.results + filename = @search.summary.gsub(/\W+/, '_').sub(/_$/,'').downcase + headers['Content-Disposition'] = "attachment; filename=\"#{filename}.csv\"" + end end end diff --git a/app/searches/entry_search.rb b/app/searches/entry_search.rb index 130148b17..7bd1d193d 100644 --- a/app/searches/entry_search.rb +++ b/app/searches/entry_search.rb @@ -95,7 +95,7 @@ def model def find_options { - :select => "id, title, publication_date, document_number, granule_class, document_file_path, abstract, length, start_page, end_page", + :select => "id, title, publication_date, document_number, granule_class, document_file_path, abstract, length, start_page, end_page, citation", :include => :agencies, } end diff --git a/app/stylesheets/design/_buttons.scss b/app/stylesheets/design/_buttons.scss index 5181290e8..678bf142a 100644 --- a/app/stylesheets/design/_buttons.scss +++ b/app/stylesheets/design/_buttons.scss @@ -81,8 +81,8 @@ BUTTONS / ICONS +.other_formats, .rss, -.help_link, .add_to_calendar, a.subscription { color: #6e6e6e; @@ -112,15 +112,6 @@ a.subscription:hover { background: sprite-image('icons/icon_subscribe_hover.png', 0, 0, 50px) no-repeat; color: #B88659; } -.help_link { - background: sprite-image('icons/icon_info.png', 0, 3px, 50px) no-repeat; - display: block; - height: image-height('icons/icon_info.png'); - padding-bottom: 3px; - } -.help_link:hover { - background: sprite-image('icons/icon_info_hover.png', 0, 3px, 50px) no-repeat; - } .add_to_calendar { background: sprite-image('icons/add_to_calendar_half.png', 0, 0, 50px) no-repeat; line-height: image-height('icons/add_to_calendar_half.png'); diff --git a/app/stylesheets/design/_search.scss b/app/stylesheets/design/_search.scss index 7169f659e..43d09a0c2 100644 --- a/app/stylesheets/design/_search.scss +++ b/app/stylesheets/design/_search.scss @@ -52,6 +52,19 @@ PAGE ELEMENTS position: absolute; right: 2em; top: 1.2em; + text-align: right; + } +.search_bar .actions .other_formats, .search_bar .actions .subscription { + font-size: 15px; + } +.search_bar .actions .other_formats { + display: block; + } +.search_bar .actions .other_formats a { + color: #6E6E6E; + } +.search_bar .actions .other_formats a:hover { + color: #B88659; } .search_bar .button { background-color: #fff; @@ -701,16 +714,24 @@ ADVANCED SEARCH margin-left: 16.75em; margin-top: 2em; } -#toggle_advanced { +.search_bar .options { + width: 410px; clear: both; - cursor: pointer; - display: none; float: left; margin-left: 5em; +} +#toggle_advanced { + cursor: pointer; + float: left; + display: none; } .has_js #toggle_advanced { display: block; } +.search_bar .options .help_link { + float: right; +} + select.bsmSelect { display: none !important; /* important needed for IE */ } diff --git a/app/stylesheets/ie6.scss b/app/stylesheets/ie6.scss index cead88f90..325e26aeb 100644 --- a/app/stylesheets/ie6.scss +++ b/app/stylesheets/ie6.scss @@ -251,12 +251,6 @@ SEARCH .regulations .results { width: auto; } .regulations .results li { border-bottom: 2px solid #eee; margin-bottom: 15px; padding-bottom: 15px; } -.help_link { - background: image-url('icons/ie6/icon_info.png') no-repeat left 3px; - float: left; - } -.help_link:hover { background: image-url('icons/ie6/icon_info_hover.png') no-repeat left 3px; } - .matching_citation_header { background: image-url('icons/ie6/icon_article.png') no-repeat left top; } #main .formtastic .string label, diff --git a/app/views/entries/search/header.html.erb b/app/views/entries/search/header.html.erb index 8ece4a1da..cdc3c31e1 100644 --- a/app/views/entries/search/header.html.erb +++ b/app/views/entries/search/header.html.erb @@ -22,12 +22,14 @@
<%= link_to 'Subscribe', new_subscription_path(:subscription => {:search_conditions => conditions_for_subscription}), :class => 'subscription' %> <%= add_template('subscription_modal', 'subscription-modal') %> + Other Formats: <%= link_to 'CSV', entries_search_path(params.except(:controller, :action, :quiet).merge(:format => :csv)) %>, + <%= link_to 'JSON', api_v1_entries_url(params.except(:controller, :action, :quiet)) %> +
+
+ <%= link_to "Show Advanced Search", '#advanced', :id => :toggle_advanced %> <%= link_to 'Learn More', entries_search_help_path, :class => 'help_link' %> - <%# link_to 'Widget', widget_instructions_path(params.except(:action, :controller)), :class => 'button widget spawn_modal notext', :id => 'widget' %>
- Show Advanced Search -
<%= render :partial => "advanced", :locals => {:f => f} %> diff --git a/app/views/entries/search/show.csv.erb b/app/views/entries/search/show.csv.erb new file mode 100644 index 000000000..4cb6bd2ef --- /dev/null +++ b/app/views/entries/search/show.csv.erb @@ -0,0 +1,22 @@ +<%= FasterCSV.generate do |csv| + csv << [ + 'FR Citation', + 'Document Number', + 'Title', + 'Publication Date', + 'Document Type', + 'Agencies', + 'URL' + ] + @entries.each do |entry| + csv << [ + entry.citation, + entry.document_number, + entry.title, + entry.publication_date, + entry.entry_type, + entry.agencies.excluding_parents.map(&:name).join(', '), + short_entry_url(entry) + ] + end + end %> diff --git a/app/views/public_inspection/search/header.html.erb b/app/views/public_inspection/search/header.html.erb index 0824351ba..6d0d164bd 100644 --- a/app/views/public_inspection/search/header.html.erb +++ b/app/views/public_inspection/search/header.html.erb @@ -21,11 +21,13 @@
<%= link_to 'Subscribe', new_subscription_path(:subscription => {:search_conditions => conditions_for_subscription}), :class => 'subscription' %> <%= add_template('subscription_modal', 'subscription-modal') %> - <%= link_to 'Learn More', entries_search_help_path, :class => 'help_link' %> <%# link_to 'Widget', widget_instructions_path(params.except(:action, :controller)), :class => 'button widget spawn_modal notext', :id => 'widget' %>
- Show Advanced Search +
+ <%= link_to 'Show Advanced Search', '#advanced', :id => "toggle_advanced" %> + <%= link_to 'Learn More', entries_search_help_path, :class => 'help_link' %> +
diff --git a/public/javascripts/page_specific/search/search.js b/public/javascripts/page_specific/search/search.js index 103d5cfa3..fc48bddce 100644 --- a/public/javascripts/page_specific/search/search.js +++ b/public/javascripts/page_specific/search/search.js @@ -265,39 +265,4 @@ $(document).ready(function () { $(window).bind('hashchange', function(){ toggleAdvanced(location.hash === "#advanced"); }).trigger('hashchange'); - - // $('.help_link').live('click', - // function () { - // load_help(); - // $('#help_modal').centerScreen().jqmShow(); - // return false; - // }); - // - // function load_help() { - // if ($('#help_modal').size() == 0) { - // - // $.ajax({ - // url: '/entries/search/help?no_layout=1', - // dataType: 'html', - // complete: function(xhr, textStatus) { - // //called when complete - // }, - // success: function(data, textStatus, xhr) { - // $("#help_modal").append(data); - // }, - // error: function(xhr, textStatus, errorThrown) { - // //called when there is an error - // } - // }); - // - // - // $('#help_modal').jqm({ - // modal: true, - // toTop: true - // }); - // } - // } - - - });