blacklight 3.0pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/.gitmodules +6 -0
- data/.yardopts +4 -0
- data/Gemfile +4 -0
- data/LICENSE +14 -0
- data/README.rdoc +168 -0
- data/Rakefile +9 -0
- data/app/controllers/bookmarks_controller.rb +98 -0
- data/app/controllers/feedback_controller.rb +37 -0
- data/app/controllers/folder_controller.rb +49 -0
- data/app/controllers/saved_searches_controller.rb +45 -0
- data/app/controllers/search_history_controller.rb +25 -0
- data/app/helpers/blacklight_helper.rb +606 -0
- data/app/helpers/bookmarks_helper.rb +3 -0
- data/app/helpers/catalog_helper.rb +65 -0
- data/app/helpers/feedback_helper.rb +2 -0
- data/app/helpers/hash_as_hidden_fields.rb +57 -0
- data/app/helpers/render_constraints_helper.rb +120 -0
- data/app/helpers/saved_searches_helper.rb +2 -0
- data/app/helpers/search_history_helper.rb +2 -0
- data/app/models/bookmark.rb +6 -0
- data/app/models/record_mailer.rb +43 -0
- data/app/models/search.rb +19 -0
- data/app/views/_flash_msg.html.erb +6 -0
- data/app/views/_user_util_links.html.erb +13 -0
- data/app/views/bookmarks/index.html.erb +33 -0
- data/app/views/catalog/_bookmark_control.html.erb +25 -0
- data/app/views/catalog/_bookmark_form.html.erb +8 -0
- data/app/views/catalog/_citation.html.erb +15 -0
- data/app/views/catalog/_constraints.html.erb +7 -0
- data/app/views/catalog/_constraints_element.html.erb +33 -0
- data/app/views/catalog/_did_you_mean.html.erb +10 -0
- data/app/views/catalog/_document_list.html.erb +30 -0
- data/app/views/catalog/_email_form.html.erb +11 -0
- data/app/views/catalog/_facet_limit.html.erb +33 -0
- data/app/views/catalog/_facet_pagination.html.erb +28 -0
- data/app/views/catalog/_facets.html.erb +9 -0
- data/app/views/catalog/_folder_control.html.erb +12 -0
- data/app/views/catalog/_home.html.erb +6 -0
- data/app/views/catalog/_home_text.html.erb +6 -0
- data/app/views/catalog/_index_partials/_default.erb +11 -0
- data/app/views/catalog/_marc_view.html.erb +33 -0
- data/app/views/catalog/_opensearch_response_metadata.html.erb +3 -0
- data/app/views/catalog/_previous_next_doc.html.erb +6 -0
- data/app/views/catalog/_refworks_form.html.erb +7 -0
- data/app/views/catalog/_results_pagination.html.erb +11 -0
- data/app/views/catalog/_search_form.html.erb +14 -0
- data/app/views/catalog/_show_partials/_default.html.erb +9 -0
- data/app/views/catalog/_show_sidebar.html.erb +1 -0
- data/app/views/catalog/_show_tools.html.erb +46 -0
- data/app/views/catalog/_sms_form.html.erb +23 -0
- data/app/views/catalog/_solr_request.html.erb +5 -0
- data/app/views/catalog/_sort_and_per_page.html.erb +20 -0
- data/app/views/catalog/_unapi_microformat.html.erb +1 -0
- data/app/views/catalog/citation.html.erb +1 -0
- data/app/views/catalog/email.erb +1 -0
- data/app/views/catalog/endnote.endnote.erb +1 -0
- data/app/views/catalog/facet.html.erb +28 -0
- data/app/views/catalog/index.atom.builder +108 -0
- data/app/views/catalog/index.html.erb +37 -0
- data/app/views/catalog/index.rss.builder +19 -0
- data/app/views/catalog/librarian_view.html.erb +3 -0
- data/app/views/catalog/opensearch.json.erb +0 -0
- data/app/views/catalog/opensearch.xml.erb +11 -0
- data/app/views/catalog/send_email_record.erb +0 -0
- data/app/views/catalog/show.endnote.erb +1 -0
- data/app/views/catalog/show.html.erb +42 -0
- data/app/views/catalog/show.refworks.erb +1 -0
- data/app/views/catalog/sms.erb +1 -0
- data/app/views/catalog/unapi.xml.builder +6 -0
- data/app/views/feedback/complete.html.erb +3 -0
- data/app/views/feedback/show.html.erb +20 -0
- data/app/views/folder/_tools.html.erb +23 -0
- data/app/views/folder/index.html.erb +44 -0
- data/app/views/layouts/blacklight.html.erb +49 -0
- data/app/views/record_mailer/email_record.erb +6 -0
- data/app/views/record_mailer/sms_record.erb +4 -0
- data/app/views/saved_searches/index.html.erb +27 -0
- data/app/views/search_history/index.html.erb +23 -0
- data/blacklight.gemspec +50 -0
- data/config.ru +4 -0
- data/config/routes.rb +54 -0
- data/db/seeds.rb +7 -0
- data/features/generators.feature +77 -0
- data/features/support/aruba.rb +9 -0
- data/install.rb +0 -0
- data/install/solr.yml +8 -0
- data/lib/blacklight.rb +121 -0
- data/lib/blacklight/catalog.rb +311 -0
- data/lib/blacklight/comma_link_renderer.rb +27 -0
- data/lib/blacklight/configurable.rb +46 -0
- data/lib/blacklight/controller.rb +121 -0
- data/lib/blacklight/engine.rb +32 -0
- data/lib/blacklight/exceptions.rb +13 -0
- data/lib/blacklight/marc.rb +46 -0
- data/lib/blacklight/marc/citation.rb +251 -0
- data/lib/blacklight/search_fields.rb +107 -0
- data/lib/blacklight/solr.rb +7 -0
- data/lib/blacklight/solr/document.rb +239 -0
- data/lib/blacklight/solr/document/dublin_core.rb +40 -0
- data/lib/blacklight/solr/document/email.rb +15 -0
- data/lib/blacklight/solr/document/marc.rb +84 -0
- data/lib/blacklight/solr/document/marc_export.rb +430 -0
- data/lib/blacklight/solr/document/sms.rb +13 -0
- data/lib/blacklight/solr/facet_paginator.rb +93 -0
- data/lib/blacklight/solr_helper.rb +413 -0
- data/lib/blacklight/user.rb +55 -0
- data/lib/blacklight/version.rb +3 -0
- data/lib/colorize.rb +196 -0
- data/lib/generators/blacklight/blacklight_generator.rb +134 -0
- data/lib/generators/blacklight/templates/SolrMarc.jar +0 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +8 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +37 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +37 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +97 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +47 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +126 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +1 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +407 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +56 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +379 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +50 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +101 -0
- data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +490 -0
- data/lib/generators/blacklight/templates/config/blacklight_config.rb +245 -0
- data/lib/generators/blacklight/templates/config/solr.yml +6 -0
- data/lib/generators/blacklight/templates/migrations/add_user_types_to_bookmarks_searches.rb +11 -0
- data/lib/generators/blacklight/templates/migrations/create_bookmarks.rb +17 -0
- data/lib/generators/blacklight/templates/migrations/create_searches.rb +15 -0
- data/lib/generators/blacklight/templates/migrations/remove_editable_fields_from_bookmarks.rb +11 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/bg.png +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/border.png +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/bul_sq_gry.gif +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/checkmark.gif +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/logo.png +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/magnifying_glass.gif +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/remove.gif +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/separator.gif +0 -0
- data/lib/generators/blacklight/templates/public/images/blacklight/start_over.gif +0 -0
- data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +485 -0
- data/lib/generators/blacklight/templates/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/lib/generators/blacklight/templates/public/javascripts/jquery-ui-1.8.1.custom.min.js +756 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +487 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_558fd0_500x100.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_2e4f81_256x240.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/lib/generators/blacklight/templates/public/stylesheets/jquery/ui-lightness/jquery-ui-1.8.1.custom.css +486 -0
- data/lib/generators/blacklight/templates/public/stylesheets/yui.css +31 -0
- data/lib/generators/blacklight/templates/solr_document.rb +30 -0
- data/lib/railties/blacklight.rake +66 -0
- data/lib/railties/cucumber.rake +53 -0
- data/lib/railties/rspec.rake +188 -0
- data/lib/railties/solr_marc.rake +148 -0
- data/lib/railties/test_solr_server.rb +130 -0
- data/spec/helpers/catalog_helper_spec.rb +111 -0
- data/spec/views/catalog/_sms_form.html.erb_spec.rb +19 -0
- data/tasks/blacklight_tasks.rake +4 -0
- data/uninstall.rb +1 -0
- metadata +431 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module CatalogHelper
|
|
2
|
+
#
|
|
3
|
+
# shortcut for built-in Rails helper, "number_with_delimiter"
|
|
4
|
+
#
|
|
5
|
+
def format_num(num); number_with_delimiter(num) end
|
|
6
|
+
|
|
7
|
+
#
|
|
8
|
+
# Displays the "showing X through Y of N" message. Not sure
|
|
9
|
+
# why that's called "page_entries_info". Not entirely sure
|
|
10
|
+
# what collection argument is supposed to duck-type too, but
|
|
11
|
+
# an RSolr::Ext::Response works. Perhaps it duck-types to something
|
|
12
|
+
# from will_paginate?
|
|
13
|
+
def page_entries_info(collection, options = {})
|
|
14
|
+
start = (collection.current_page - 1) * collection.per_page + 1
|
|
15
|
+
total_hits = @response.total
|
|
16
|
+
start_num = format_num(start)
|
|
17
|
+
end_num = format_num(start + collection.size - 1)
|
|
18
|
+
total_num = format_num(total_hits)
|
|
19
|
+
# end_num = total_num if total_hits < (start + collection.per_page - 1)
|
|
20
|
+
|
|
21
|
+
entry_name = options[:entry_name] ||
|
|
22
|
+
(collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
|
|
23
|
+
|
|
24
|
+
if collection.total_pages < 2
|
|
25
|
+
case collection.size
|
|
26
|
+
when 0; "No #{h(entry_name.pluralize)} found".html_safe
|
|
27
|
+
when 1; "Displaying <b>1</b> #{h(entry_name)}".html_safe
|
|
28
|
+
else; "Displaying <b>all #{total_num}</b> #{entry_name.pluralize}".html_safe
|
|
29
|
+
end
|
|
30
|
+
else
|
|
31
|
+
"Displaying #{h(entry_name.pluralize)} <b>#{start_num} - #{end_num}</b> of <b>#{total_num}</b>".html_safe
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Like the mysteriously named #page_entry_info above, but for an individual
|
|
36
|
+
# item show page. Displays "showing X of Y items" message.
|
|
37
|
+
# Code should call this method rather than interrogating session directly,
|
|
38
|
+
# because implementation of where this data is stored/retrieved may change.
|
|
39
|
+
def item_page_entry_info
|
|
40
|
+
"Showing item <b>#{session[:search][:counter].to_i} of #{format_num(session[:search][:total])}</b> from your search.".html_safe
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Look up search field user-displayable label
|
|
44
|
+
# based on params[:qt] and configuration.
|
|
45
|
+
def search_field_label(params)
|
|
46
|
+
h( Blacklight.label_for_search_field(params[:search_field]) )
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Export to Refworks URL, called in _show_tools
|
|
50
|
+
def refworks_export_url(document = @document)
|
|
51
|
+
"http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(application_name)}&filter=MARC%20Format&encoding=65001&url=#{CGI.escape(catalog_path(document[:id], :format => 'refworks_marc_txt', :only_path => false))}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def render_document_class(document = @document)
|
|
55
|
+
'blacklight-' + document.get(Blacklight.config[:index][:record_display_type]).parameterize rescue nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def render_document_sidebar_partial(document = @document)
|
|
59
|
+
render :partial => 'show_sidebar'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def has_search_parameters?
|
|
63
|
+
!params[:q].blank? or !params[:f].blank? or !params[:search_field].blank?
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Rails Helper methods to take a hash and turn it to form <input type="hidden">
|
|
2
|
+
# fields, works with hash nested with other hashes and arrays, standard rails
|
|
3
|
+
# serialization style. Oddly while Hash#to_query will do this for a URL
|
|
4
|
+
# query parameters, there seems to be no built in way to do it to create
|
|
5
|
+
# hidden form fields instead.
|
|
6
|
+
#
|
|
7
|
+
# Code taken from http://marklunds.com/articles/one/314
|
|
8
|
+
#
|
|
9
|
+
# This is used to serialize a complete current query from current params
|
|
10
|
+
# to form fields used for sort and change per-page
|
|
11
|
+
module HashAsHiddenFields
|
|
12
|
+
|
|
13
|
+
# Writes out zero or more <input type="hidden"> elements, completely
|
|
14
|
+
# representing a hash passed in using Rails-style request parameters
|
|
15
|
+
# for hashes nested with arrays and other hashes.
|
|
16
|
+
def hash_as_hidden_fields(hash)
|
|
17
|
+
|
|
18
|
+
hidden_fields = []
|
|
19
|
+
flatten_hash(hash).each do |name, value|
|
|
20
|
+
value = [value] if !value.is_a?(Array)
|
|
21
|
+
value.each do |v|
|
|
22
|
+
hidden_fields << hidden_field_tag(name, v.to_s, :id => nil)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
hidden_fields.join("\n").html_safe
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
protected
|
|
30
|
+
|
|
31
|
+
def flatten_hash(hash = params, ancestor_names = [])
|
|
32
|
+
flat_hash = {}
|
|
33
|
+
hash.each do |k, v|
|
|
34
|
+
names = Array.new(ancestor_names)
|
|
35
|
+
names << k
|
|
36
|
+
if v.is_a?(Hash)
|
|
37
|
+
flat_hash.merge!(flatten_hash(v, names))
|
|
38
|
+
else
|
|
39
|
+
key = flat_hash_key(names)
|
|
40
|
+
key += "[]" if v.is_a?(Array)
|
|
41
|
+
flat_hash[key] = v
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
flat_hash
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def flat_hash_key(names)
|
|
49
|
+
names = Array.new(names)
|
|
50
|
+
name = names.shift.to_s.dup
|
|
51
|
+
names.each do |n|
|
|
52
|
+
name << "[#{n}]"
|
|
53
|
+
end
|
|
54
|
+
name
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# All methods in here are 'api' that may be over-ridden by plugins and local
|
|
2
|
+
# code, so method signatures and semantics should not be changed casually.
|
|
3
|
+
# implementations can be of course.
|
|
4
|
+
#
|
|
5
|
+
# Includes methods for rendering contraints graphically on the
|
|
6
|
+
# search results page (render_constraints(_*)), and also
|
|
7
|
+
# for rendering more textually on Search History page
|
|
8
|
+
# (render_search_to_s(_*))
|
|
9
|
+
module RenderConstraintsHelper
|
|
10
|
+
|
|
11
|
+
# Render actual constraints, not including header or footer
|
|
12
|
+
# info.
|
|
13
|
+
def render_constraints(localized_params = params)
|
|
14
|
+
(render_constraints_query(localized_params) + render_constraints_filters(localized_params)).html_safe
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def render_constraints_query(localized_params = params)
|
|
18
|
+
# So simple don't need a view template, we can just do it here.
|
|
19
|
+
if (!localized_params[:q].blank?)
|
|
20
|
+
label =
|
|
21
|
+
if (localized_params[:search_field] == Blacklight.default_search_field[:key] or localized_params[:search_field].blank? )
|
|
22
|
+
nil
|
|
23
|
+
else
|
|
24
|
+
Blacklight.label_for_search_field(localized_params[:search_field])
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
render_constraint_element(label,
|
|
28
|
+
localized_params[:q],
|
|
29
|
+
:classes => ["query"],
|
|
30
|
+
:remove => catalog_index_path(localized_params.merge(:q=>nil, :action=>'index')))
|
|
31
|
+
else
|
|
32
|
+
"".html_safe
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def render_constraints_filters(localized_params = params)
|
|
37
|
+
return "".html_safe unless localized_params[:f]
|
|
38
|
+
content = ""
|
|
39
|
+
localized_params[:f].each_pair do |facet,values|
|
|
40
|
+
values.each do |val|
|
|
41
|
+
content << render_constraint_element( facet_field_labels[facet],
|
|
42
|
+
val,
|
|
43
|
+
:remove => catalog_index_path(remove_facet_params(facet, val, localized_params)),
|
|
44
|
+
:classes => ["filter", "filter-" + facet.parameterize]
|
|
45
|
+
) + "\n"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return content.html_safe
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Render a label/value constraint on the screen. Can be called
|
|
53
|
+
# by plugins and such to get application-defined rendering.
|
|
54
|
+
#
|
|
55
|
+
# Can be over-ridden locally to render differently if desired,
|
|
56
|
+
# although in most cases you can just change CSS instead.
|
|
57
|
+
#
|
|
58
|
+
# Can pass in nil label if desired.
|
|
59
|
+
#
|
|
60
|
+
# options:
|
|
61
|
+
# [:remove]
|
|
62
|
+
# url to execute for a 'remove' action
|
|
63
|
+
# [:classes]
|
|
64
|
+
# can be an array of classes to add to container span for constraint.
|
|
65
|
+
# [:escape_label]
|
|
66
|
+
# default true, HTML escape.
|
|
67
|
+
# [:escape_value]
|
|
68
|
+
# default true, HTML escape.
|
|
69
|
+
def render_constraint_element(label, value, options = {})
|
|
70
|
+
render(:partial => "catalog/constraints_element", :locals => {:label => label, :value => value, :options => options})
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Simpler textual version of constraints, used on Search History page.
|
|
75
|
+
# Theoretically can may be DRY'd up with results page render_constraints,
|
|
76
|
+
# maybe even using the very same HTML with different CSS?
|
|
77
|
+
# But too tricky for now, too many changes to existing CSS. TODO.
|
|
78
|
+
def render_search_to_s(params)
|
|
79
|
+
render_search_to_s_q(params) +
|
|
80
|
+
render_search_to_s_filters(params)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def render_search_to_s_q(params)
|
|
84
|
+
return "".html_safe if params[:q].blank?
|
|
85
|
+
|
|
86
|
+
label = (params[:search_field] == Blacklight.default_search_field[:key]) ?
|
|
87
|
+
nil :
|
|
88
|
+
Blacklight.label_for_search_field(params[:search_field])
|
|
89
|
+
|
|
90
|
+
render_search_to_s_element(label , params[:q] )
|
|
91
|
+
end
|
|
92
|
+
def render_search_to_s_filters(params)
|
|
93
|
+
return "".html_safe unless params[:f]
|
|
94
|
+
|
|
95
|
+
params[:f].collect do |facet_field, value_list|
|
|
96
|
+
render_search_to_s_element(Blacklight.config[:facet][:labels][facet_field],
|
|
97
|
+
value_list.collect do |value|
|
|
98
|
+
render_filter_value(value)
|
|
99
|
+
end.join(content_tag(:span, 'and', :class =>'label')).html_safe
|
|
100
|
+
)
|
|
101
|
+
end.join(" \n ").html_safe
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# value can be Array, in which case elements are joined with
|
|
105
|
+
# 'and'. Pass in option :escape_value => false to pass in pre-rendered
|
|
106
|
+
# html for value. key with escape_key if needed.
|
|
107
|
+
def render_search_to_s_element(key, value, options = {})
|
|
108
|
+
content_tag(:span, render_filter_name(key) + render_filter_value(value), :class => 'constraint')
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def render_filter_name name
|
|
112
|
+
return "".html_safe if name.blank?
|
|
113
|
+
content_tag(:span, h(name) + ":", :class => 'filterName')
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def render_filter_value value
|
|
117
|
+
content_tag(:span, h(value), :class => 'filterValue')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Only works for documents with a #to_marc right now.
|
|
2
|
+
class RecordMailer < ActionMailer::Base
|
|
3
|
+
|
|
4
|
+
def email_record(documents, details, from_host, url_gen_params)
|
|
5
|
+
#raise ArgumentError.new("RecordMailer#email_record only works with documents with a #to_marc") unless document.respond_to?(:to_marc)
|
|
6
|
+
|
|
7
|
+
recipients details[:to]
|
|
8
|
+
if documents.size == 1
|
|
9
|
+
subject = "Item Record: #{documents.first.to_semantic_values[:title] rescue 'N/A'}"
|
|
10
|
+
else
|
|
11
|
+
subject = "Item records"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
@documents = documents
|
|
15
|
+
@message = details[:message]
|
|
16
|
+
@url_gen_params = url_gen_params
|
|
17
|
+
|
|
18
|
+
mail(:to => details[:to], :from => "no-reply@" << from_host, :subject => subject)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def sms_record(documents, details, from_host, url_gen_params)
|
|
22
|
+
if sms_mapping[details[:carrier]]
|
|
23
|
+
to = "#{details[:to]}@#{sms_mapping[details[:carrier]]}"
|
|
24
|
+
end
|
|
25
|
+
@documents = documents
|
|
26
|
+
@host = from_host
|
|
27
|
+
@url_gen_params = url_gen_params
|
|
28
|
+
mail(:to => to, :from => "no-reply@" << from_host, :subject => "")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
protected
|
|
32
|
+
|
|
33
|
+
def sms_mapping
|
|
34
|
+
{'virgin' => 'vmobl.com',
|
|
35
|
+
'att' => 'txt.att.net',
|
|
36
|
+
'verizon' => 'vtext.com',
|
|
37
|
+
'nextel' => 'messaging.nextel.com',
|
|
38
|
+
'sprint' => 'messaging.sprintpcs.com',
|
|
39
|
+
'tmobile' => 'tmomail.net',
|
|
40
|
+
'alltel' => 'message.alltel.com',
|
|
41
|
+
'cricket' => 'mms.mycricket.com'}
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Search < ActiveRecord::Base
|
|
2
|
+
|
|
3
|
+
belongs_to :user
|
|
4
|
+
|
|
5
|
+
serialize :query_params
|
|
6
|
+
|
|
7
|
+
# A Search instance is considered a saved search if it has a user_id.
|
|
8
|
+
def saved?
|
|
9
|
+
self.user_id?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# delete old, unsaved searches
|
|
13
|
+
def self.delete_old_searches(days_old)
|
|
14
|
+
raise ArgumentError.new('days_old is expected to be a number') unless days_old.is_a?(Numeric)
|
|
15
|
+
raise ArgumentError.new('days_old is expected to be greater than 0') if days_old <= 0
|
|
16
|
+
self.destroy_all(['created_at < ? AND user_id IS NULL', Date.today - days_old])
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<% if current_user %>
|
|
2
|
+
<%= link_to "Log Out", destroy_user_session_path %> [<%= link_to current_user, edit_user_registration_path %>]
|
|
3
|
+
<% if current_user.last_search_url %>
|
|
4
|
+
| <%= link_to('View your last search', catalog_index_path(current_user.last_search_url)) %><% end %> |
|
|
5
|
+
<%= link_to 'Your Bookmarks', bookmarks_path %> |
|
|
6
|
+
<%= link_to "Saved Searches", saved_searches_path %>
|
|
7
|
+
<% else %>
|
|
8
|
+
<%= link_to 'Login', new_user_session_path %>
|
|
9
|
+
<% end %>
|
|
10
|
+
|
|
|
11
|
+
<%= link_to "Selected Items", folder_index_path %> (<span id="folder_number"><%= "#{session[:folder_document_ids] ? session[:folder_document_ids].length : 0}" %></span>)
|
|
12
|
+
|
|
|
13
|
+
<%= link_to "Search History", search_history_path %>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<h1>Bookmarks</h1>
|
|
2
|
+
|
|
3
|
+
<%- if current_user.blank? -%>
|
|
4
|
+
|
|
5
|
+
<h2>Please log in to see your bookmarks.</h2>
|
|
6
|
+
|
|
7
|
+
<%- elsif @bookmarks.blank? -%>
|
|
8
|
+
|
|
9
|
+
<h2>You have no bookmarks</h2>
|
|
10
|
+
|
|
11
|
+
<%- else -%>
|
|
12
|
+
|
|
13
|
+
<%= will_paginate @bookmarks %>
|
|
14
|
+
<div id="userBookmarks">
|
|
15
|
+
<p>
|
|
16
|
+
<%= link_to "Clear Bookmarks", clear_bookmarks_path, :method => :delete, :confirm => "Clear your bookmarks?" %>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<h2>Your Bookmarks</h2>
|
|
20
|
+
|
|
21
|
+
<table class="zebra">
|
|
22
|
+
<% @bookmarks.each do |bm| %>
|
|
23
|
+
<tr>
|
|
24
|
+
<td><%= link_to h(bm.title), catalog_path(bm.document_id) %></td>
|
|
25
|
+
<td><%= button_to 'Remove', {:controller => "bookmarks", :action => "destroy", :id => bm.document_id},
|
|
26
|
+
:method => :delete, :confirm => 'Remove this bookmark?' %></td>
|
|
27
|
+
</tr>
|
|
28
|
+
<% end %>
|
|
29
|
+
</table>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<% end %>
|
|
33
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<% if current_user %>
|
|
2
|
+
<%- existing_bookmark = current_user.existing_bookmark_for(document[:id]) -%>
|
|
3
|
+
<%-
|
|
4
|
+
# Note these two forms are pretty similar but for different :methods, classes, and labels.
|
|
5
|
+
# but it was simpler to leave them seperate instead of DRYing them, got confusing trying that.
|
|
6
|
+
# the data-doc-id attribute is used by our JS that converts to a checkbox/label.
|
|
7
|
+
-%>
|
|
8
|
+
<% unless existing_bookmark %>
|
|
9
|
+
|
|
10
|
+
<%= form_tag( bookmark_path( document[:id]), :method => :put, :class => "bookmark_toggle", "data-doc-id" => document[:id], :title=> document[document_show_link_field] ) do %>
|
|
11
|
+
<%= hidden_field(:bookmark, :title, :value => document[document_show_link_field] ) %>
|
|
12
|
+
<%= submit_tag("Bookmark", :id => "bookmark_toggle_#{document[:id]}", :class => "bookmark_add") %>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
<% else %>
|
|
16
|
+
|
|
17
|
+
<%= form_tag( bookmark_path( document[:id]), :method => :delete, :class => "bookmark_toggle", "data-doc-id" => document[:id], :title=> document[document_show_link_field]) do %>
|
|
18
|
+
<%= hidden_field(:bookmark, :title, :value => document[document_show_link_field] ) %>
|
|
19
|
+
<%= submit_tag("Remove bookmark", :id => "bookmark_toggle_#{document[:id]}", :class => "bookmark_remove") %>
|
|
20
|
+
<% end %>
|
|
21
|
+
|
|
22
|
+
<% end %>
|
|
23
|
+
<% else %>
|
|
24
|
+
|
|
25
|
+
<% end %>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%= form_tag '/bookmarks', :name => "bookmarks" do %>
|
|
2
|
+
<% documents.each_with_index do |document, index| %>
|
|
3
|
+
<%= hidden_field_tag "bookmarks[#{index}][document_id]", document.get(:id)%>
|
|
4
|
+
<%= hidden_field_tag "bookmarks[#{index}][title]", h(document[document_show_link_field])%>
|
|
5
|
+
<% end %>
|
|
6
|
+
<%= link_to_function "Add to Bookmarks", "document.bookmarks.submit()" %>
|
|
7
|
+
<%= submit_tag 'Add to Bookmarks', :class => 'hide' %>
|
|
8
|
+
<% end %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<% @documents.each do |document| %>
|
|
2
|
+
|
|
3
|
+
<h1><%= citation_title(document) %></h1>
|
|
4
|
+
|
|
5
|
+
<% if document.respond_to?(:export_as_mla_citation_txt) %>
|
|
6
|
+
<h4>MLA</h4>
|
|
7
|
+
<%= document.send(:export_as_mla_citation_txt).html_safe %><br/><br/>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% if document.respond_to?(:export_as_apa_citation_txt) %>
|
|
11
|
+
<h4>APA</h4>
|
|
12
|
+
<%= document.send(:export_as_apa_citation_txt).html_safe %>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
<% end %>
|