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,430 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Written for use with Blacklight::Solr::Document::Marc, but you can use
|
|
3
|
+
# it for your own custom Blacklight document Marc extension too -- just
|
|
4
|
+
# include this module in any document extension (or any other class)
|
|
5
|
+
# that provides a #to_marc returning a ruby-marc object. This module will add
|
|
6
|
+
# in export_as translation methods for a variety of formats.
|
|
7
|
+
module Blacklight::Solr::Document::MarcExport
|
|
8
|
+
|
|
9
|
+
def self.register_export_formats(document)
|
|
10
|
+
document.will_export_as(:xml)
|
|
11
|
+
document.will_export_as(:marc, "application/marc")
|
|
12
|
+
# marcxml content type:
|
|
13
|
+
# http://tools.ietf.org/html/draft-denenberg-mods-etc-media-types-00
|
|
14
|
+
document.will_export_as(:marcxml, "application/marcxml+xml")
|
|
15
|
+
document.will_export_as(:openurl_ctx_kev, "application/x-openurl-ctx-kev")
|
|
16
|
+
document.will_export_as(:refworks_marc_txt, "text/plain")
|
|
17
|
+
document.will_export_as(:endnote, "application/x-endnote-refer")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def export_as_marc
|
|
22
|
+
to_marc.to_marc
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def export_as_marcxml
|
|
26
|
+
to_marc.to_xml.to_s
|
|
27
|
+
end
|
|
28
|
+
alias_method :export_as_xml, :export_as_marcxml
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# TODO This exporting as formatted citation thing should be re-thought
|
|
32
|
+
# redesigned at some point to be more general purpose, but this
|
|
33
|
+
# is in-line with what we had before, but at least now attached
|
|
34
|
+
# to the document extension where it belongs.
|
|
35
|
+
def export_as_apa_citation_txt
|
|
36
|
+
apa_citation( to_marc )
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def export_as_mla_citation_txt
|
|
40
|
+
mla_citation( to_marc )
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Exports as an OpenURL KEV (key-encoded value) query string.
|
|
44
|
+
# For use to create COinS, among other things. COinS are
|
|
45
|
+
# for Zotero, among other things. TODO: This is wierd and fragile
|
|
46
|
+
# code, it should use ruby OpenURL gem instead to work a lot
|
|
47
|
+
# more sensibly. The "format" argument was in the old marc.marc.to_zotero
|
|
48
|
+
# call, but didn't neccesarily do what it thought it did anyway. Left in
|
|
49
|
+
# for now for backwards compatibilty, but should be replaced by
|
|
50
|
+
# just ruby OpenURL.
|
|
51
|
+
def export_as_openurl_ctx_kev(format = nil)
|
|
52
|
+
title = to_marc.find{|field| field.tag == '245'}
|
|
53
|
+
author = to_marc.find{|field| field.tag == '100'}
|
|
54
|
+
corp_author = to_marc.find{|field| field.tag == '110'}
|
|
55
|
+
publisher_info = to_marc.find{|field| field.tag == '260'}
|
|
56
|
+
edition = to_marc.find{|field| field.tag == '250'}
|
|
57
|
+
isbn = to_marc.find{|field| field.tag == '020'}
|
|
58
|
+
issn = to_marc.find{|field| field.tag == '022'}
|
|
59
|
+
unless format.nil?
|
|
60
|
+
format.is_a?(Array) ? format = format[0].downcase.strip : format = format.downcase.strip
|
|
61
|
+
end
|
|
62
|
+
export_text = ""
|
|
63
|
+
if format == 'book'
|
|
64
|
+
export_text << "ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&rft.genre=book&"
|
|
65
|
+
export_text << "rft.btitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&"
|
|
66
|
+
export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&"
|
|
67
|
+
export_text << "rft.au=#{(author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a'])}&"
|
|
68
|
+
export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&" unless corp_author.blank?
|
|
69
|
+
export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&"
|
|
70
|
+
export_text << "rft.place=#{(publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a'])}&"
|
|
71
|
+
export_text << "rft.pub=#{(publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b'])}&"
|
|
72
|
+
export_text << "rft.edition=#{(edition.nil? or edition['a'].nil?) ? "" : CGI::escape(edition['a'])}&"
|
|
73
|
+
export_text << "rft.isbn=#{(isbn.nil? or isbn['a'].nil?) ? "" : isbn['a']}"
|
|
74
|
+
elsif (format =~ /journal/i) # checking using include because institutions may use formats like Journal or Journal/Magazine
|
|
75
|
+
export_text << "ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&rft.genre=article&"
|
|
76
|
+
export_text << "rft.title=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&"
|
|
77
|
+
export_text << "rft.atitle=#{(title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a'])}+#{(title.nil? or title['b'].nil?) ? "" : CGI::escape(title['b'])}&"
|
|
78
|
+
export_text << "rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}&" unless corp_author.blank?
|
|
79
|
+
export_text << "rft.date=#{(publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c'])}&"
|
|
80
|
+
export_text << "rft.issn=#{(issn.nil? or issn['a'].nil?) ? "" : issn['a']}"
|
|
81
|
+
else
|
|
82
|
+
export_text << "ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Adc&rfr_id=info%3Asid%2Fblacklight.rubyforge.org%3Agenerator&"
|
|
83
|
+
export_text << "rft.title=" + ((title.nil? or title['a'].nil?) ? "" : CGI::escape(title['a']))
|
|
84
|
+
export_text << ((title.nil? or title['b'].nil?) ? "" : CGI.escape(" ") + CGI::escape(title['b']))
|
|
85
|
+
export_text << "&rft.creator=" + ((author.nil? or author['a'].nil?) ? "" : CGI::escape(author['a']))
|
|
86
|
+
export_text << "&rft.aucorp=#{CGI::escape(corp_author['a']) if corp_author['a']}+#{CGI::escape(corp_author['b']) if corp_author['b']}" unless corp_author.blank?
|
|
87
|
+
export_text << "&rft.date=" + ((publisher_info.nil? or publisher_info['c'].nil?) ? "" : CGI::escape(publisher_info['c']))
|
|
88
|
+
export_text << "&rft.place=" + ((publisher_info.nil? or publisher_info['a'].nil?) ? "" : CGI::escape(publisher_info['a']))
|
|
89
|
+
export_text << "&rft.pub=" + ((publisher_info.nil? or publisher_info['b'].nil?) ? "" : CGI::escape(publisher_info['b']))
|
|
90
|
+
export_text << "&rft.format=" + (format.nil? ? "" : CGI::escape(format))
|
|
91
|
+
end
|
|
92
|
+
export_text unless export_text.blank?
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# This format used to be called 'refworks', which wasn't really
|
|
97
|
+
# accurate, sounds more like 'refworks tagged format'. Which this
|
|
98
|
+
# is not, it's instead some weird under-documented Refworks
|
|
99
|
+
# proprietary marc-ish in text/plain format. See
|
|
100
|
+
# http://robotlibrarian.billdueber.com/sending-marcish-data-to-refworks/
|
|
101
|
+
def export_as_refworks_marc_txt
|
|
102
|
+
# plugin/gem weirdness means we do need to manually require
|
|
103
|
+
# here.
|
|
104
|
+
# As of 11 May 2010, Refworks has a problem with UTF-8 if it's decomposed,
|
|
105
|
+
# it seems to want C form normalization, although RefWorks support
|
|
106
|
+
# couldn't tell me that. -jrochkind
|
|
107
|
+
# DHF: moved this require a little lower in the method.
|
|
108
|
+
# require 'unicode'
|
|
109
|
+
|
|
110
|
+
fields = to_marc.find_all { |f| ('000'..'999') === f.tag }
|
|
111
|
+
text = "LEADER #{to_marc.leader}"
|
|
112
|
+
fields.each do |field|
|
|
113
|
+
unless ["940","999"].include?(field.tag)
|
|
114
|
+
if field.is_a?(MARC::ControlField)
|
|
115
|
+
text << "#{field.tag} #{field.value}\n"
|
|
116
|
+
else
|
|
117
|
+
text << "#{field.tag} "
|
|
118
|
+
text << (field.indicator1 ? field.indicator1 : " ")
|
|
119
|
+
text << (field.indicator2 ? field.indicator2 : " ")
|
|
120
|
+
text << " "
|
|
121
|
+
field.each {|s| s.code == 'a' ? text << "#{s.value}" : text << " |#{s.code}#{s.value}"}
|
|
122
|
+
text << "\n"
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
if Blacklight.jruby?
|
|
128
|
+
require 'java'
|
|
129
|
+
java_import java.text.Normalizer
|
|
130
|
+
Normalizer.normalize(text, Normalizer::Form::NFC).to_s
|
|
131
|
+
else
|
|
132
|
+
require 'unicode'
|
|
133
|
+
Unicode.normalize_C(text)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Endnote Import Format. See the EndNote User Guide at:
|
|
138
|
+
# http://www.endnote.com/support/enx3man-terms-win.asp
|
|
139
|
+
# Chapter 7: Importing Reference Data into EndNote / Creating a Tagged “EndNote Import” File
|
|
140
|
+
#
|
|
141
|
+
# Note: This code is copied from what used to be in the previous version
|
|
142
|
+
# in ApplicationHelper#render_to_endnote. It does NOT produce very good
|
|
143
|
+
# endnote import format; the %0 is likely to be entirely illegal, the
|
|
144
|
+
# rest of the data is barely correct but messy. TODO, a new version of this,
|
|
145
|
+
# or better yet just an export_as_ris instead, which will be more general
|
|
146
|
+
# purpose.
|
|
147
|
+
def export_as_endnote()
|
|
148
|
+
end_note_format = {
|
|
149
|
+
"%A" => "100.a",
|
|
150
|
+
"%C" => "260.a",
|
|
151
|
+
"%D" => "260.c",
|
|
152
|
+
"%E" => "700.a",
|
|
153
|
+
"%I" => "260.b",
|
|
154
|
+
"%J" => "440.a",
|
|
155
|
+
"%@" => "020.a",
|
|
156
|
+
"%_@" => "022.a",
|
|
157
|
+
"%T" => "245.a,245.b",
|
|
158
|
+
"%U" => "856.u",
|
|
159
|
+
"%7" => "250.a"
|
|
160
|
+
}
|
|
161
|
+
marc_obj = to_marc
|
|
162
|
+
|
|
163
|
+
# TODO. This was inherited functionality (although refactored),
|
|
164
|
+
# but it wasn't actually clear that :display_type would
|
|
165
|
+
# be used this way. This should be rewritten to guess
|
|
166
|
+
# from actual Marc instead, probably.
|
|
167
|
+
format_str = Blacklight.config[:show][:display_type]
|
|
168
|
+
format_str = format_str[0] if format_str.kind_of?(Array)
|
|
169
|
+
format_str = format_str.titlecase
|
|
170
|
+
|
|
171
|
+
text = ''
|
|
172
|
+
text << "%0 #{ format_str }\n"
|
|
173
|
+
# If there is some reliable way of getting the language of a record we can add it here
|
|
174
|
+
#text << "%G #{record['language'].first}\n"
|
|
175
|
+
end_note_format.each do |key,value|
|
|
176
|
+
values = value.split(",")
|
|
177
|
+
first_value = values[0].split('.')
|
|
178
|
+
if values.length > 1
|
|
179
|
+
second_value = values[1].split('.')
|
|
180
|
+
else
|
|
181
|
+
second_value = []
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
if marc_obj[first_value[0].to_s]
|
|
185
|
+
marc_obj.find_all{|f| (first_value[0].to_s) === f.tag}.each do |field|
|
|
186
|
+
if field[first_value[1]].to_s or field[second_value[1]].to_s
|
|
187
|
+
text << "#{key.gsub('_','')}"
|
|
188
|
+
if field[first_value[1]].to_s
|
|
189
|
+
text << " #{field[first_value[1]].to_s}"
|
|
190
|
+
end
|
|
191
|
+
if field[second_value[1]].to_s
|
|
192
|
+
text << " #{field[second_value[1]].to_s}"
|
|
193
|
+
end
|
|
194
|
+
text << "\n"
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
text
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
## DEPRECATED stuff left in for backwards compatibility, but should
|
|
203
|
+
# be gotten rid of eventually.
|
|
204
|
+
|
|
205
|
+
def to_zotero(format)
|
|
206
|
+
warn("[DEPRECATION] Simply call document.export_as_openurl_kev to get an openURL kev context object suitable for including in a COinS; then have view code make the span for the COinS. ")
|
|
207
|
+
"<span class=\"Z3988\" title=\"#{export_as_openurl_kev(format)}\"></span>"
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def to_apa
|
|
211
|
+
warn("[DEPRECATION] Call document.export_as_apa_citation instead.")
|
|
212
|
+
export_as_apa_citation
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def to_mla
|
|
216
|
+
warn("[DEPRECATION] Call document.export_as_mla_citation instead.")
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
protected
|
|
222
|
+
|
|
223
|
+
def mla_citation(record)
|
|
224
|
+
text = ''
|
|
225
|
+
authors_final = []
|
|
226
|
+
|
|
227
|
+
#setup formatted author list
|
|
228
|
+
authors = get_author_list(record)
|
|
229
|
+
|
|
230
|
+
if authors.length < 4
|
|
231
|
+
authors.each do |l|
|
|
232
|
+
if l == authors.first #first
|
|
233
|
+
authors_final.push(l)
|
|
234
|
+
elsif l == authors.last #last
|
|
235
|
+
authors_final.push(", and " + name_reverse(l) + ".")
|
|
236
|
+
else #all others
|
|
237
|
+
authors_final.push(", " + name_reverse(l))
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
text += authors_final.join
|
|
241
|
+
unless text.blank?
|
|
242
|
+
if text[-1,1] != "."
|
|
243
|
+
text += ". "
|
|
244
|
+
else
|
|
245
|
+
text += " "
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
else
|
|
249
|
+
text += authors.first + ", et al. "
|
|
250
|
+
end
|
|
251
|
+
# setup title
|
|
252
|
+
title = setup_title_info(record)
|
|
253
|
+
if !title.nil?
|
|
254
|
+
text += "<i>" + mla_citation_title(title) + "</i> "
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Edition
|
|
258
|
+
edition_data = setup_edition(record)
|
|
259
|
+
text += edition_data + " " unless edition_data.nil?
|
|
260
|
+
|
|
261
|
+
# Publication
|
|
262
|
+
text += setup_pub_info(record) + ", " unless setup_pub_info(record).nil?
|
|
263
|
+
|
|
264
|
+
# Get Pub Date
|
|
265
|
+
text += setup_pub_date(record) unless setup_pub_date(record).nil?
|
|
266
|
+
if text[-1,1] != "."
|
|
267
|
+
text += "." unless text.nil? or text.blank?
|
|
268
|
+
end
|
|
269
|
+
text
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def apa_citation(record)
|
|
273
|
+
text = ''
|
|
274
|
+
authors_list = []
|
|
275
|
+
authors_list_final = []
|
|
276
|
+
|
|
277
|
+
#setup formatted author list
|
|
278
|
+
authors = get_author_list(record)
|
|
279
|
+
authors.each do |l|
|
|
280
|
+
authors_list.push(abbreviate_name(l)) unless l.blank?
|
|
281
|
+
end
|
|
282
|
+
authors_list.each do |l|
|
|
283
|
+
if l == authors_list.first #first
|
|
284
|
+
authors_list_final.push(l.strip)
|
|
285
|
+
elsif l == authors_list.last #last
|
|
286
|
+
authors_list_final.push(", & " + l.strip)
|
|
287
|
+
else #all others
|
|
288
|
+
authors_list_final.push(", " + l.strip)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
text += authors_list_final.join
|
|
292
|
+
unless text.blank?
|
|
293
|
+
if text[-1,1] != "."
|
|
294
|
+
text += ". "
|
|
295
|
+
else
|
|
296
|
+
text += " "
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
# Get Pub Date
|
|
300
|
+
text += "(" + setup_pub_date(record) + "). " unless setup_pub_date(record).nil?
|
|
301
|
+
|
|
302
|
+
# setup title info
|
|
303
|
+
title = setup_title_info(record)
|
|
304
|
+
text += "<i>" + title + "</i> " unless title.nil?
|
|
305
|
+
|
|
306
|
+
# Edition
|
|
307
|
+
edition_data = setup_edition(record)
|
|
308
|
+
text += edition_data + " " unless edition_data.nil?
|
|
309
|
+
|
|
310
|
+
# Publisher info
|
|
311
|
+
text += setup_pub_info(record) unless setup_pub_info(record).nil?
|
|
312
|
+
unless text.blank?
|
|
313
|
+
if text[-1,1] != "."
|
|
314
|
+
text += "."
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
text
|
|
318
|
+
end
|
|
319
|
+
def setup_pub_date(record)
|
|
320
|
+
if !record.find{|f| f.tag == '260'}.nil?
|
|
321
|
+
pub_date = record.find{|f| f.tag == '260'}
|
|
322
|
+
if pub_date.find{|s| s.code == 'c'}
|
|
323
|
+
date_value = pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9]/, "") unless pub_date.find{|s| s.code == 'c'}.value.gsub(/[^0-9]/, "").blank?
|
|
324
|
+
end
|
|
325
|
+
return nil unless !date_value.nil?
|
|
326
|
+
end
|
|
327
|
+
date_value
|
|
328
|
+
end
|
|
329
|
+
def setup_pub_info(record)
|
|
330
|
+
text = ''
|
|
331
|
+
pub_info_field = record.find{|f| f.tag == '260'}
|
|
332
|
+
if !pub_info_field.nil?
|
|
333
|
+
a_pub_info = pub_info_field.find{|s| s.code == 'a'}
|
|
334
|
+
b_pub_info = pub_info_field.find{|s| s.code == 'b'}
|
|
335
|
+
a_pub_info = clean_end_punctuation(a_pub_info.value.strip) unless a_pub_info.nil?
|
|
336
|
+
b_pub_info = b_pub_info.value.strip unless b_pub_info.nil?
|
|
337
|
+
text += a_pub_info.strip unless a_pub_info.nil?
|
|
338
|
+
if !a_pub_info.nil? and !b_pub_info.nil?
|
|
339
|
+
text += ": "
|
|
340
|
+
end
|
|
341
|
+
text += b_pub_info.strip unless b_pub_info.nil?
|
|
342
|
+
end
|
|
343
|
+
return nil if text.strip.blank?
|
|
344
|
+
clean_end_punctuation(text.strip)
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
def mla_citation_title(text)
|
|
348
|
+
no_upcase = ["a","an","and","but","by","for","it","of","the","to","with"]
|
|
349
|
+
new_text = []
|
|
350
|
+
word_parts = text.split(" ")
|
|
351
|
+
word_parts.each do |w|
|
|
352
|
+
if !no_upcase.include? w
|
|
353
|
+
new_text.push(w.capitalize)
|
|
354
|
+
else
|
|
355
|
+
new_text.push(w)
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
new_text.join(" ")
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
def setup_title_info(record)
|
|
362
|
+
text = ''
|
|
363
|
+
title_info_field = record.find{|f| f.tag == '245'}
|
|
364
|
+
if !title_info_field.nil?
|
|
365
|
+
a_title_info = title_info_field.find{|s| s.code == 'a'}
|
|
366
|
+
b_title_info = title_info_field.find{|s| s.code == 'b'}
|
|
367
|
+
a_title_info = clean_end_punctuation(a_title_info.value.strip) unless a_title_info.nil?
|
|
368
|
+
b_title_info = clean_end_punctuation(b_title_info.value.strip) unless b_title_info.nil?
|
|
369
|
+
text += a_title_info unless a_title_info.nil?
|
|
370
|
+
if !a_title_info.nil? and !b_title_info.nil?
|
|
371
|
+
text += ": "
|
|
372
|
+
end
|
|
373
|
+
text += b_title_info unless b_title_info.nil?
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
return nil if text.strip.blank?
|
|
377
|
+
clean_end_punctuation(text.strip) + "."
|
|
378
|
+
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def clean_end_punctuation(text)
|
|
382
|
+
if [".",",",":",";","/"].include? text[-1,1]
|
|
383
|
+
return text[0,text.length-1]
|
|
384
|
+
end
|
|
385
|
+
text
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def setup_edition(record)
|
|
389
|
+
edition_field = record.find{|f| f.tag == '250'}
|
|
390
|
+
edition_code = edition_field.find{|s| s.code == 'a'} unless edition_field.nil?
|
|
391
|
+
edition_data = edition_code.value unless edition_code.nil?
|
|
392
|
+
if edition_data.nil? or edition_data == '1st ed.'
|
|
393
|
+
return nil
|
|
394
|
+
else
|
|
395
|
+
return edition_data
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
def get_author_list(record)
|
|
400
|
+
author_list = []
|
|
401
|
+
authors_primary = record.find{|f| f.tag == '100'}
|
|
402
|
+
author_primary = authors_primary.find{|s| s.code == 'a'}.value unless authors_primary.nil? rescue ''
|
|
403
|
+
author_list.push(clean_end_punctuation(author_primary)) unless author_primary.nil?
|
|
404
|
+
authors_secondary = record.find_all{|f| ('700') === f.tag}
|
|
405
|
+
if !authors_secondary.nil?
|
|
406
|
+
authors_secondary.each do |l|
|
|
407
|
+
author_list.push(clean_end_punctuation(l.find{|s| s.code == 'a'}.value)) unless l.find{|s| s.code == 'a'}.value.nil?
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
author_list.uniq!
|
|
412
|
+
author_list
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def abbreviate_name(name)
|
|
416
|
+
name_parts = name.split(", ")
|
|
417
|
+
first_name_parts = name_parts.last.split(" ")
|
|
418
|
+
temp_name = name_parts.first + ", " + first_name_parts.first[0,1] + "."
|
|
419
|
+
first_name_parts.shift
|
|
420
|
+
temp_name += " " + first_name_parts.join(" ") unless first_name_parts.empty?
|
|
421
|
+
temp_name
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def name_reverse(name)
|
|
425
|
+
name = clean_end_punctuation(name)
|
|
426
|
+
temp_name = name.split(", ")
|
|
427
|
+
return temp_name.last + " " + temp_name.first
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# This module provides the body of an email export based on the document's semantic values
|
|
2
|
+
module Blacklight::Solr::Document::Sms
|
|
3
|
+
|
|
4
|
+
# Return a text string that will be the body of the email
|
|
5
|
+
def to_sms_text
|
|
6
|
+
semantics = self.to_semantic_values
|
|
7
|
+
body = ""
|
|
8
|
+
body << semantics[:title].first unless semantics[:title].blank?
|
|
9
|
+
body << " by #{semantics[:author].first}" unless semantics[:author].blank?
|
|
10
|
+
return body unless body.blank?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Blacklight::Solr
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Pagination for facet values -- works by setting the limit to max
|
|
5
|
+
# displayable. You have to ask Solr for limit+1, to get enough
|
|
6
|
+
# results to see if 'more' are available'. That is, the all_facet_values
|
|
7
|
+
# arg in constructor should be the result of asking solr for limit+1
|
|
8
|
+
# values.
|
|
9
|
+
# This is a workaround for the fact that Solr itself can't compute
|
|
10
|
+
# the total values for a given facet field,
|
|
11
|
+
# so we cannot know how many "pages" there are.
|
|
12
|
+
#
|
|
13
|
+
class FacetPaginator
|
|
14
|
+
# What request keys will we use for the parameters need. Need to
|
|
15
|
+
# make sure they do NOT conflict with catalog/index request params,
|
|
16
|
+
# and need to make them accessible in a list so we can easily
|
|
17
|
+
# strip em out before redirecting to catalog/index.
|
|
18
|
+
# class variable (via class-level ivar)
|
|
19
|
+
@request_keys = {:sort => :'catalog_facet.sort', :offset => :'catalog_facet.offset', :limit => :'catalog_facet.limit'}
|
|
20
|
+
class << self; attr_accessor :request_keys end # create a class method
|
|
21
|
+
def request_keys ; self.class.request_keys ; end # shortcut
|
|
22
|
+
|
|
23
|
+
attr_reader :total, :items, :offset, :limit, :sort
|
|
24
|
+
|
|
25
|
+
# all_facet_values is a list of facet value objects returned by solr,
|
|
26
|
+
# asking solr for n+1 facet values.
|
|
27
|
+
# options:
|
|
28
|
+
# :limit => number to display per page, or (default) nil. Nil means
|
|
29
|
+
# display all with no previous or next.
|
|
30
|
+
# :offset => current item offset, default 0
|
|
31
|
+
# :sort => 'count' or 'index', solr tokens for facet value sorting, default 'count'.
|
|
32
|
+
def initialize(all_facet_values, arguments)
|
|
33
|
+
# to_s.to_i will conveniently default to 0 if nil
|
|
34
|
+
@offset = arguments[:offset].to_s.to_i
|
|
35
|
+
@limit = arguments[:limit].to_s.to_i if arguments[:limit]
|
|
36
|
+
# count is solr's default
|
|
37
|
+
@sort = arguments[:sort] || "count"
|
|
38
|
+
|
|
39
|
+
total = all_facet_values.size
|
|
40
|
+
if (@limit)
|
|
41
|
+
@items = all_facet_values.slice(0, @limit)
|
|
42
|
+
@has_next = total > @limit
|
|
43
|
+
@has_previous = @offset > 0
|
|
44
|
+
else # nil limit
|
|
45
|
+
@items = all_facet_values
|
|
46
|
+
@has_next = false
|
|
47
|
+
@has_previous = false
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def has_next?
|
|
52
|
+
@has_next
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Pass in your current request params, returns a param hash
|
|
56
|
+
# suitable to passing to an ActionHelper method (resource-based url_for, or
|
|
57
|
+
# link_to or url_for) navigating to the next facet value batch. Returns nil
|
|
58
|
+
# if there is no has_next?
|
|
59
|
+
def params_for_next_url(params)
|
|
60
|
+
return nil unless has_next?
|
|
61
|
+
|
|
62
|
+
return params.merge(request_keys[:offset] => offset + limit )
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def has_previous?
|
|
66
|
+
@has_previous
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Pass in your current request params, returns a param hash
|
|
70
|
+
# suitable to passing to an ActionHelper method (resource-based url_for, or
|
|
71
|
+
# link_to or url_for) navigating to the previous facet value batch. Returns
|
|
72
|
+
# nil if there is no has_previous?
|
|
73
|
+
def params_for_previous_url(params)
|
|
74
|
+
return nil unless has_previous?
|
|
75
|
+
|
|
76
|
+
return params.merge(request_keys[:offset] => offset - limit )
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Pass in a desired solr facet solr key ('count' or 'index', see
|
|
80
|
+
# http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit
|
|
81
|
+
# under facet.sort ), and your current request params.
|
|
82
|
+
# Get back params suitable to passing to an ActionHelper method for
|
|
83
|
+
# creating a url, to resort by that method.
|
|
84
|
+
def params_for_resort_url(sort_method, params)
|
|
85
|
+
# When resorting, we've got to reset the offset to start at beginning,
|
|
86
|
+
# no way to make it make sense otherwise.
|
|
87
|
+
return params.merge(request_keys[:sort] => sort_method,
|
|
88
|
+
request_keys[:offset] => 0)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
end
|