umlaut 3.0.0alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +7 -0
- data/README.md +49 -0
- data/Rakefile +37 -0
- data/app/assets/images/error.gif +0 -0
- data/app/assets/images/export_bg_bot.gif +0 -0
- data/app/assets/images/export_bg_mid.gif +0 -0
- data/app/assets/images/export_bg_top.gif +0 -0
- data/app/assets/images/famfamfam/book_open.png +0 -0
- data/app/assets/images/famfamfam/cross.png +0 -0
- data/app/assets/images/famfamfam/page_sound.gif +0 -0
- data/app/assets/images/famfamfam/page_text.gif +0 -0
- data/app/assets/images/famfamfam/page_up.gif +0 -0
- data/app/assets/images/famfamfam/page_white.png +0 -0
- data/app/assets/images/famfamfam/readme.html +1495 -0
- data/app/assets/images/famfamfam/tiny_cross.png +0 -0
- data/app/assets/images/frame_remove.gif +0 -0
- data/app/assets/images/ico_go.gif +0 -0
- data/app/assets/images/jhu_findit.gif +0 -0
- data/app/assets/images/list_closed.png +0 -0
- data/app/assets/images/list_open.png +0 -0
- data/app/assets/images/more_info.gif +0 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/images/request.gif +0 -0
- data/app/assets/images/spinner.gif +0 -0
- data/app/assets/javascripts/umlaut/ajax_windows.js +35 -0
- data/app/assets/javascripts/umlaut/ensure_window_size.js.erb +34 -0
- data/app/assets/javascripts/umlaut/expand_contract_toggle.js +25 -0
- data/app/assets/javascripts/umlaut/search_autocomplete.js +46 -0
- data/app/assets/javascripts/umlaut/simple_visible_toggle.js +8 -0
- data/app/assets/javascripts/umlaut/update_html.js +152 -0
- data/app/assets/javascripts/umlaut.js +17 -0
- data/app/assets/stylesheets/umlaut.css +857 -0
- data/app/controllers/application_controller.rb +14 -0
- data/app/controllers/export_email_controller.rb +123 -0
- data/app/controllers/js_helper_controller.rb +10 -0
- data/app/controllers/link_router_controller.rb +87 -0
- data/app/controllers/open_search_controller.rb +9 -0
- data/app/controllers/resolve_controller.rb +288 -0
- data/app/controllers/resource_controller.rb +83 -0
- data/app/controllers/search_controller.rb +328 -0
- data/app/controllers/search_methods/sfx3.rb +148 -0
- data/app/controllers/search_methods/sfx4.rb +257 -0
- data/app/controllers/search_methods/sfx_api.rb +47 -0
- data/app/controllers/store_controller.rb +64 -0
- data/app/controllers/umlaut/controller_behavior.rb +20 -0
- data/app/controllers/umlaut/controller_logic.rb +96 -0
- data/app/controllers/umlaut/error_handling.rb +48 -0
- data/app/controllers/umlaut_controller.rb +112 -0
- data/app/helpers/application_helper.rb +4 -0
- data/app/helpers/emailer_helper.rb +43 -0
- data/app/helpers/export_email_helper.rb +34 -0
- data/app/helpers/open_search_helper.rb +7 -0
- data/app/helpers/resolve_helper.rb +225 -0
- data/app/helpers/search_helper.rb +50 -0
- data/app/helpers/umlaut/footer_helper.rb +64 -0
- data/app/helpers/umlaut/helper.rb +62 -0
- data/app/helpers/umlaut/html_head_helper.rb +37 -0
- data/app/helpers/umlaut/url_generation.rb +77 -0
- data/app/mailers/emailer.rb +48 -0
- data/app/models/clickthrough.rb +2 -0
- data/app/models/collection.rb +259 -0
- data/app/models/crossref_lookup.rb +2 -0
- data/app/models/dispatched_service.rb +58 -0
- data/app/models/permalink.rb +29 -0
- data/app/models/referent.rb +473 -0
- data/app/models/referent_value.rb +14 -0
- data/app/models/request.rb +449 -0
- data/app/models/service_response.rb +179 -0
- data/app/models/service_store.rb +59 -0
- data/app/models/service_type_value.rb +58 -0
- data/app/models/service_wave.rb +150 -0
- data/app/models/sfx_db/az_additional_title.rb +11 -0
- data/app/models/sfx_db/az_letter_group.rb +11 -0
- data/app/models/sfx_db/az_title.rb +38 -0
- data/app/models/sfx_db/az_title_v2.rb +34 -0
- data/app/models/sfx_db/isbn.rb +12 -0
- data/app/models/sfx_db/issn.rb +12 -0
- data/app/models/sfx_db/object.rb +35 -0
- data/app/models/sfx_db/object_portfolio.rb +6 -0
- data/app/models/sfx_db/publisher.rb +10 -0
- data/app/models/sfx_db/sfx_db_base.rb +54 -0
- data/app/models/sfx_db/target.rb +9 -0
- data/app/models/sfx_db/target_service.rb +10 -0
- data/app/models/sfx_db/title.rb +10 -0
- data/app/models/sfx_db.rb +10 -0
- data/app/models/sfx_url.rb +35 -0
- data/app/views/emailer/citation.text.erb +28 -0
- data/app/views/emailer/short_citation.text.erb +8 -0
- data/app/views/export_email/_email.html.erb +25 -0
- data/app/views/export_email/_send_email.html.erb +3 -0
- data/app/views/export_email/_send_txt.html.erb +3 -0
- data/app/views/export_email/_txt.html.erb +62 -0
- data/app/views/export_email/email.html.erb +3 -0
- data/app/views/export_email/send_email.html.erb +1 -0
- data/app/views/export_email/send_txt.html.erb +1 -0
- data/app/views/export_email/txt.html.erb +3 -0
- data/app/views/js_helper/loader.erb.js +13 -0
- data/app/views/layouts/umlaut.html.erb +52 -0
- data/app/views/open_search/index.html.erb +9 -0
- data/app/views/resolve/_api_in_progress.xml.erb +21 -0
- data/app/views/resolve/_background_progress.html.erb +51 -0
- data/app/views/resolve/_background_updater.html.erb +38 -0
- data/app/views/resolve/_citation.html.erb +87 -0
- data/app/views/resolve/_coins.html.erb +1 -0
- data/app/views/resolve/_compact_citation.html.erb +33 -0
- data/app/views/resolve/_cover_image.html.erb +35 -0
- data/app/views/resolve/_fulltext.html.erb +55 -0
- data/app/views/resolve/_help.html.erb +17 -0
- data/app/views/resolve/_holding.html.erb +91 -0
- data/app/views/resolve/_related_items.html.erb +35 -0
- data/app/views/resolve/_search_inside.html.erb +62 -0
- data/app/views/resolve/_section_display.html.erb +49 -0
- data/app/views/resolve/_service_errors.html.erb +29 -0
- data/app/views/resolve/_standard_response_item.html.erb +89 -0
- data/app/views/resolve/api.xml.builder +72 -0
- data/app/views/resolve/background_status.html.erb +26 -0
- data/app/views/resolve/index.html.erb +73 -0
- data/app/views/resolve/partial_html_sections.xml.erb +30 -0
- data/app/views/search/_a_to_z.html.erb +6 -0
- data/app/views/search/_citation.html.erb +94 -0
- data/app/views/search/_pager.html.erb +60 -0
- data/app/views/search/books.html.erb +103 -0
- data/app/views/search/journal_search.html.erb +90 -0
- data/app/views/search/journals.html.erb +167 -0
- data/app/views/search/opensearch_description.rxml +10 -0
- data/app/views/testing/index.html.erb +1 -0
- data/app/views/umlaut/README +5 -0
- data/app/views/umlaut/error.html.erb +45 -0
- data/db/migrate/01_umlaut_init.rb +113 -0
- data/db/orig_fixed_data/service_type_values.yml +120 -0
- data/db/seeds.rb +7 -0
- data/lib/CronTab.rb +192 -0
- data/lib/aws_product_sign.rb +146 -0
- data/lib/exlibris/aleph/patron.rb +64 -0
- data/lib/exlibris/aleph/record.rb +54 -0
- data/lib/exlibris/aleph/rest_api.rb +29 -0
- data/lib/exlibris/primo/holding.rb +192 -0
- data/lib/exlibris/primo/rsrc.rb +17 -0
- data/lib/exlibris/primo/searcher.rb +276 -0
- data/lib/exlibris/primo/source/aleph.rb +46 -0
- data/lib/exlibris/primo/source/distribution/nyu_aleph.rb +323 -0
- data/lib/exlibris/primo/toc.rb +17 -0
- data/lib/exlibris/primo_ws.rb +140 -0
- data/lib/generators/templates/umlaut_services.yml +237 -0
- data/lib/generators/umlaut/asset_hooks_generator.rb +44 -0
- data/lib/generators/umlaut/install_generator.rb +110 -0
- data/lib/hip3/bib.rb +291 -0
- data/lib/hip3/bib_searcher.rb +302 -0
- data/lib/hip3/custom_field_lookup.rb +44 -0
- data/lib/hip3/holding.rb +50 -0
- data/lib/hip3/item.rb +65 -0
- data/lib/hip3/receipt.rb +7 -0
- data/lib/hip3/serial_copy.rb +82 -0
- data/lib/holding.rb +32 -0
- data/lib/marc_helper.rb +254 -0
- data/lib/metadata_helper.rb +312 -0
- data/lib/opensearch_feed.rb +398 -0
- data/lib/opensearch_query.rb +98 -0
- data/lib/referent_filter.rb +16 -0
- data/lib/referent_filters/dissertation_catch.rb +45 -0
- data/lib/section_renderer.rb +503 -0
- data/lib/service.rb +336 -0
- data/lib/service_adaptors/ajax_export.rb +37 -0
- data/lib/service_adaptors/amazon.rb +412 -0
- data/lib/service_adaptors/blacklight.rb +327 -0
- data/lib/service_adaptors/book_finder.rb +40 -0
- data/lib/service_adaptors/bx.rb +51 -0
- data/lib/service_adaptors/cover_thing.rb +73 -0
- data/lib/service_adaptors/elsevier_cover.rb +57 -0
- data/lib/service_adaptors/email_export.rb +10 -0
- data/lib/service_adaptors/ezproxy.rb +171 -0
- data/lib/service_adaptors/google_book_search.rb +442 -0
- data/lib/service_adaptors/gpo.rb +124 -0
- data/lib/service_adaptors/hathi_trust.rb +308 -0
- data/lib/service_adaptors/hip3_service.rb +150 -0
- data/lib/service_adaptors/hip_holding_search.rb +237 -0
- data/lib/service_adaptors/internet_archive.rb +488 -0
- data/lib/service_adaptors/isbn_db.rb +86 -0
- data/lib/service_adaptors/isi.rb +258 -0
- data/lib/service_adaptors/jcr.rb +146 -0
- data/lib/service_adaptors/opac.rb +351 -0
- data/lib/service_adaptors/open_library.rb +316 -0
- data/lib/service_adaptors/open_library_cover.rb +73 -0
- data/lib/service_adaptors/primo_service.rb +392 -0
- data/lib/service_adaptors/primo_source.rb +78 -0
- data/lib/service_adaptors/pubmed.rb +133 -0
- data/lib/service_adaptors/request_to_fixture.rb +68 -0
- data/lib/service_adaptors/scopus.rb +295 -0
- data/lib/service_adaptors/sfx-new.rb +557 -0
- data/lib/service_adaptors/sfx.rb +566 -0
- data/lib/service_adaptors/sfx_backchannel_record.rb +69 -0
- data/lib/service_adaptors/txt_holding_export.rb +32 -0
- data/lib/service_adaptors/ulrichs_cover.rb +57 -0
- data/lib/service_adaptors/ulrichs_link.rb +47 -0
- data/lib/service_adaptors/worldcat.rb +116 -0
- data/lib/service_adaptors/worldcat_identities.rb +591 -0
- data/lib/tasks/umlaut.rake +134 -0
- data/lib/umlaut/default_configuration.rb +5 -0
- data/lib/umlaut/routes.rb +136 -0
- data/lib/umlaut/version.rb +3 -0
- data/lib/umlaut.rb +37 -0
- data/lib/umlaut_configurable.rb +343 -0
- data/lib/umlaut_http.rb +100 -0
- data/lib/xml_schema_helper.rb +109 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/umlaut_controller.rb +112 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database-jhu.yml +44 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +34 -0
- data/test/dummy/config/environments/production.rb +60 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +61 -0
- data/test/dummy/config/umlaut_services.yml +237 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20111228211210_umlaut_init.rb +113 -0
- data/test/dummy/db/schema.rb +124 -0
- data/test/dummy/log/development.log +12981 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C5F/340/sprockets%2F99692920160b7a279b86a80415b79db7 +0 -0
- data/test/dummy/tmp/cache/assets/C70/4D0/sprockets%2F034ad2036e623081bd352800786dfe80 +0 -0
- data/test/dummy/tmp/cache/assets/C73/920/sprockets%2Fd371318f22900492fd180f17c5e2a504 +9268 -0
- data/test/dummy/tmp/cache/assets/C80/980/sprockets%2Fc94807409c1523d43e18d25f35d93c41 +0 -0
- data/test/dummy/tmp/cache/assets/C8F/780/sprockets%2Fe47e28558116fb5f8038754e60d1961d +11769 -0
- data/test/dummy/tmp/cache/assets/CAA/EB0/sprockets%2F1d179210e8b76f1ea63c802688a015e4 +9271 -0
- data/test/dummy/tmp/cache/assets/CBB/9C0/sprockets%2F706f28923fb754cad04b9107c89986a1 +0 -0
- data/test/dummy/tmp/cache/assets/CBF/B60/sprockets%2F08ca89671549936265dcb673bf02e36f +0 -0
- data/test/dummy/tmp/cache/assets/CC9/9F0/sprockets%2F306166316e2cafd13c15e62b51a2339d +0 -0
- data/test/dummy/tmp/cache/assets/CF6/F20/sprockets%2F5b2ffa1103079dfd555197838f87a99f +0 -0
- data/test/dummy/tmp/cache/assets/CF7/2B0/sprockets%2F25a7c73655bd3598173b39d9f98bcd46 +862 -0
- data/test/dummy/tmp/cache/assets/CFE/080/sprockets%2F37fe9f4255baddbd549a659914929398 +0 -0
- data/test/dummy/tmp/cache/assets/D22/060/sprockets%2F9aec77b768e91a802d284271c58e2f7e +21357 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D33/6D0/sprockets%2F500129c57f1146e556ec3aacd6cd38c1 +0 -0
- data/test/dummy/tmp/cache/assets/D33/FD0/sprockets%2F2ba0b4e6334a77b923e5f770381bb2bf +0 -0
- data/test/dummy/tmp/cache/assets/D42/C20/sprockets%2Fbcf14e437b1582bf93b77670acf8e090 +21353 -0
- data/test/dummy/tmp/cache/assets/D50/A30/sprockets%2F7d8b294ac433db5d056538f8cf7c66b9 +0 -0
- data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +872 -0
- data/test/dummy/tmp/cache/assets/D65/590/sprockets%2Fc1bb92fc3406a126b7dd302edc96d629 +0 -0
- data/test/dummy/tmp/cache/assets/D71/6B0/sprockets%2Fde558b71b494cf09b1bf055c8dff0353 +0 -0
- data/test/dummy/tmp/cache/assets/D72/610/sprockets%2Fa8c708eeb30ef93de34d755d4f45d023 +859 -0
- data/test/dummy/tmp/cache/assets/D76/AD0/sprockets%2Fe2158cde93188cf5ab6457bc6d6602ec +0 -0
- data/test/dummy/tmp/cache/assets/D7A/E40/sprockets%2F9622ffcc499a57627cd1bb18fe31b8e4 +11772 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
- data/test/dummy/tmp/cache/assets/D9B/770/sprockets%2F8aacf02eb7dbb0949704b28f27b87e0b +0 -0
- data/test/dummy/tmp/cache/assets/DA6/A80/sprockets%2F92e26d8e58d5bcc8b8f6c25d1b05b9c1 +0 -0
- data/test/dummy/tmp/cache/assets/DE8/790/sprockets%2Fd1333bde2b9aafcc712d11dd09ab35d8 +0 -0
- data/test/dummy/tmp/cache/assets/DF7/F30/sprockets%2F7bc16c4109b17fabe29f8ddbbf732d1c +374 -0
- data/test/dummy/tmp/cache/assets/E03/570/sprockets%2F493bdc0ac14cd4f57fdfe4253f992bde +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E0B/4B0/sprockets%2F7988df51a61c81ce6ede4a2d4c8cce4f +377 -0
- data/test/dummy/tmp/cache/assets/E5F/960/sprockets%2Fdc007b6cad5c7ef08e33ec28cfff0ef6 +0 -0
- data/test/fixtures/dispatched_services.yml +5 -0
- data/test/fixtures/permalinks.yml +5 -0
- data/test/fixtures/referent_values.yml +1734 -0
- data/test/fixtures/referents.yml +156 -0
- data/test/fixtures/requests.yml +284 -0
- data/test/fixtures/service_responses.yml +5 -0
- data/test/fixtures/sfx_urls.yml +4 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +10 -0
- data/test/umlaut_test.rb +7 -0
- data/test/unit/aleph_patron_test.rb +39 -0
- data/test/unit/aleph_record_benchmarks.rb +28 -0
- data/test/unit/aleph_record_test.rb +30 -0
- data/test/unit/aws_product_sign_test.rb +93 -0
- data/test/unit/collection_test.rb +76 -0
- data/test/unit/google_book_search_test.rb +101 -0
- data/test/unit/primo_searcher_test.rb +403 -0
- data/test/unit/primo_service_test.rb +939 -0
- data/test/unit/primo_ws_test.rb +131 -0
- data/test/unit/service_response_test.rb +9 -0
- data/test/unit/service_test.rb +33 -0
- metadata +580 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
# A mix-in for Rails controllers with some standard error recovery
|
2
|
+
# logic.
|
3
|
+
module Umlaut::ErrorHandling
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
# Only custom errors in production
|
8
|
+
unless Rails.application.config.consider_all_requests_local
|
9
|
+
|
10
|
+
# generic catch-all comes first, later ones will take priority
|
11
|
+
rescue_from Exception, :with => :handle_general_error
|
12
|
+
|
13
|
+
rescue_from ::StoreController::NotFound, ActiveRecord::RecordNotFound, :with => :handle_404_error
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def handle_general_error(exception)
|
21
|
+
log_error_with_context(exception)
|
22
|
+
|
23
|
+
@page_title = "Error!"
|
24
|
+
render "error", :status => 500
|
25
|
+
end
|
26
|
+
|
27
|
+
# Just returns a generic 404 page.
|
28
|
+
# Uses generic 404 page already stored in public/404.html as rails convention.
|
29
|
+
def handle_404_error(exception=nil)
|
30
|
+
render :file=>File.join(Rails.root ,"public/404.html"), :layout=>false, :status=>404
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def log_error_with_context(exception, severity = :fatal)
|
35
|
+
message = "\n#{exception.class} (#{exception.message}):\n"
|
36
|
+
message << " uri: #{request.fullpath}\n\n"
|
37
|
+
message << " params: #{params.inspect}\n\n"
|
38
|
+
message << " Referer: #{request.referer}\n" if request.referer
|
39
|
+
message << " User-Agent: #{request.user_agent}\n"
|
40
|
+
message << " Client IP: #{request.remote_addr}\n\n"
|
41
|
+
|
42
|
+
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
|
43
|
+
message << " " << Rails.backtrace_cleaner.clean(exception.backtrace).join("\n ")
|
44
|
+
|
45
|
+
logger.send(severity, "#{message}\n\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'umlaut'
|
2
|
+
require 'umlaut_configurable'
|
3
|
+
|
4
|
+
# Superclass for all Umlaut controllers, to hold default behavior,
|
5
|
+
# also hold global configuration. It's a superclass rather than a module,
|
6
|
+
# so we can use Rails 3 hieararchical superclass view lookup too if we want,
|
7
|
+
# for general umlaut views. And also so local app can over-ride
|
8
|
+
# methods here once, and have it apply to all Umlaut controllers.
|
9
|
+
# But there's not much magic in here or anything, the
|
10
|
+
# common behavior is ordinary methods available to be called, mostly.
|
11
|
+
#
|
12
|
+
# This class is copied into the local app -- the default implementation
|
13
|
+
# does nothing but 'include Umlaut::ControllerBehavior'
|
14
|
+
#
|
15
|
+
# You will ordinarily set config here, and can also over-ride
|
16
|
+
# methods from Umlaut::ControllerBehavior if desired. Or add
|
17
|
+
# additional helpers to over-ride Umlaut helpers if needed.
|
18
|
+
class UmlautController < ApplicationController
|
19
|
+
include Umlaut::ControllerBehavior
|
20
|
+
|
21
|
+
# Some suggested configuration. More config keys
|
22
|
+
# are available, see UmlautConfigurable.set_default_configuration!
|
23
|
+
# implementation for list. Configuration actually uses
|
24
|
+
# a Confstruct object.
|
25
|
+
|
26
|
+
umlaut_config.configure do
|
27
|
+
# app_name 'Find It'
|
28
|
+
|
29
|
+
# URL to image to use for link resolver in some self-links,
|
30
|
+
# OR name of image asset in local app.
|
31
|
+
#link_img_url "http//something"
|
32
|
+
|
33
|
+
# Sometimes Umlaut sends out email, what email addr should it be from?
|
34
|
+
# from_email_addr 'no_reply@umlaut.example.com'
|
35
|
+
|
36
|
+
# Local layout for UmlautController's, instead of
|
37
|
+
# built in 'umlaut' layout?
|
38
|
+
# layout "application"
|
39
|
+
|
40
|
+
# A help url used on error page and a few other places.
|
41
|
+
# help_url "http://www.library.jhu.edu/services/askalib/index.html"
|
42
|
+
|
43
|
+
# If OpenURL came from manual entry of title/ISSN, and no match is found in
|
44
|
+
# link resolver knowledge base, display a warning to the user of potential
|
45
|
+
# typo?
|
46
|
+
# entry_not_in_kb_warning true
|
47
|
+
|
48
|
+
# rfr_ids used for umlaut generated pages.
|
49
|
+
# rfr_ids do
|
50
|
+
# opensearch "info:sid/umlaut.code4lib.org:opensearch"
|
51
|
+
# citation "info:sid/umlaut.code4lib.org:citation"
|
52
|
+
# azlist 'info:sid/umlaut.code4lib.org:azlist'
|
53
|
+
# end
|
54
|
+
|
55
|
+
# Referent filters. Sort of like SFX source parsers.
|
56
|
+
# hash, key is regexp to match a sid, value is filter object
|
57
|
+
# (see lib/referent_filters )
|
58
|
+
# add_referent_filters!( :match => /.*/, :filter => DissertationCatch.new )
|
59
|
+
|
60
|
+
# How many seconds between updates of the background updater for background
|
61
|
+
# services?
|
62
|
+
# poll_wait_seconds 4
|
63
|
+
|
64
|
+
# Configuration for the 'search' functions -- A-Z lookup
|
65
|
+
# and citation entry.
|
66
|
+
search do
|
67
|
+
# Is your SFX database connection, defined in database.yml under
|
68
|
+
# sfx_db and used for A-Z searches, Sfx3 or Sfx4? Other SearchMethods
|
69
|
+
# in addition to SFX direct db may be provided later.
|
70
|
+
#az_search_method SearchMethods::Sfx4
|
71
|
+
#az_search_method SearchMethods::Sfx3
|
72
|
+
|
73
|
+
# When talking directly to the SFX A-Z list database, you may
|
74
|
+
# need to set this, if you have multiple A-Z profiles configured
|
75
|
+
# and don't want to use the 'default.
|
76
|
+
# sfx_az_profile "default"
|
77
|
+
|
78
|
+
# can set to "_blank" etc.
|
79
|
+
# result_link_target nil
|
80
|
+
end
|
81
|
+
|
82
|
+
# config only relevant to SFX use
|
83
|
+
sfx do
|
84
|
+
# base sfx url to use for search actions, error condition backup,
|
85
|
+
# and some other purposes. For search actions (A-Z), direct database
|
86
|
+
# connection to your SFX db also needs to be defined in database.yml
|
87
|
+
# sfx_base_url 'http://sfx.library.jhu.edu:8000/jhu_sfx?'
|
88
|
+
#
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
# Umlaut tries to figure out from the SFX knowledge base
|
93
|
+
# which hosts are "SFX controlled", to avoid duplicating SFX
|
94
|
+
# urls with urls from catalog. But sometimes it misses some, or
|
95
|
+
# alternate hostnames for some. Regexps matching against
|
96
|
+
# urls can be included here. Eg,
|
97
|
+
# AppConfig::Base.additional_sfx_controlled_urls = [
|
98
|
+
# %r{^http://([^\.]\.)*pubmedcentral\.com}
|
99
|
+
# ]
|
100
|
+
# additional_sfx_controlled_urls = []
|
101
|
+
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# Advanced topic, you can declaratively configure
|
106
|
+
# what sections of the resolve page are output where
|
107
|
+
# and how using resolve_sections and add_resolve_sections!
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module EmailerHelper
|
2
|
+
include ApplicationHelper
|
3
|
+
|
4
|
+
# returns a plain text short citation
|
5
|
+
def brief_citation(request, options = {})
|
6
|
+
|
7
|
+
options[:include_labels] ||= false
|
8
|
+
|
9
|
+
rv =""
|
10
|
+
|
11
|
+
|
12
|
+
cite = request.referent.to_citation
|
13
|
+
|
14
|
+
title = truncate(cite[:title].strip, :length => 70, :seperator => '...')
|
15
|
+
|
16
|
+
rv << (cite[:title_label].strip + ": ")if options[:include_labels]
|
17
|
+
rv << title
|
18
|
+
rv << "\n"
|
19
|
+
|
20
|
+
if cite[:author]
|
21
|
+
rv << "Author: " if options[:include_labels]
|
22
|
+
rv << cite[:author].strip
|
23
|
+
rv << "\n"
|
24
|
+
end
|
25
|
+
if cite[:subtitle]
|
26
|
+
rv << (cite[:subtitle_label].strip + ": ") if options[:include_labels]
|
27
|
+
rv << cite[:subtitle].strip
|
28
|
+
rv << "\n"
|
29
|
+
end
|
30
|
+
|
31
|
+
pub = []
|
32
|
+
pub << date_format(cite[:date]) unless cite[:date].blank?
|
33
|
+
pub << 'Vol: '+cite[:volume].strip unless cite[:volume].blank?
|
34
|
+
pub << 'Iss: '+cite[:issue].strip unless cite[:issue].blank?
|
35
|
+
pub << 'p. '+cite[:page].strip unless cite[:page].blank?
|
36
|
+
if pub.length > 0
|
37
|
+
rv << "Published: " if options[:include_labels]
|
38
|
+
rv << pub.join(' ')
|
39
|
+
end
|
40
|
+
|
41
|
+
return rv
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ExportEmailHelper
|
2
|
+
include EmailerHelper
|
3
|
+
|
4
|
+
def formatted_txt_holding_status(view_data)
|
5
|
+
output = ""
|
6
|
+
|
7
|
+
output << view_data[:collection_str] if view_data[:collection_str]
|
8
|
+
output << " " + view_data[:call_number] if view_data[:call_number]
|
9
|
+
output << " " + view_data[:status] if view_data[:status]
|
10
|
+
|
11
|
+
return output
|
12
|
+
end
|
13
|
+
|
14
|
+
def formatted_html_holding_status(view_data)
|
15
|
+
output = "".html_safe
|
16
|
+
|
17
|
+
|
18
|
+
if view_data[:collection_str]
|
19
|
+
output << content_tag("span", view_data[:collection_str], :class => "collection")
|
20
|
+
end
|
21
|
+
if view_data[:call_number]
|
22
|
+
output << " ".html_safe << content_tag("span", view_data[:call_number], :class => "call_no")
|
23
|
+
end
|
24
|
+
if view_data[:status]
|
25
|
+
output << " ".html_safe << content_tag("span", view_data[:status], :class => "status")
|
26
|
+
end
|
27
|
+
|
28
|
+
return output
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
module OpenSearchHelper
|
2
|
+
|
3
|
+
def opensearch_template_url
|
4
|
+
url_for(:controller => "search", :action => "journal_search", :rfr_id => umlaut_config.lookup('rfr_id.opensearch'), :'umlaut.title_search_type' => 'contains', :only_path => false ) + '&rft.jtitle={searchTerms}'
|
5
|
+
end
|
6
|
+
|
7
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
module ResolveHelper
|
2
|
+
# some useful methods started out as helper methods, but now are in the
|
3
|
+
# Request model. We delegate them for convenience and backwards compat.
|
4
|
+
delegate :get_service_type,
|
5
|
+
:failed_service_dispatches,
|
6
|
+
:service_type_in_progress?,
|
7
|
+
:service_types_in_progress?,
|
8
|
+
:any_services_in_progress?,
|
9
|
+
:title_level_citation?, :to => :@user_request
|
10
|
+
|
11
|
+
|
12
|
+
#backwards compat, should be called title_level_citation? delegated
|
13
|
+
# to @user_request above, but some
|
14
|
+
alias title_level_request? title_level_citation?
|
15
|
+
|
16
|
+
# Will render an Umlaut HTML section. See SectionRenderer.
|
17
|
+
# Argument can be:
|
18
|
+
# 1. An already initialized SectionRenderer
|
19
|
+
# 2. :id => X, will load Section description hash from the resolve_sections
|
20
|
+
# configuration, finding description hash with :div_id == X.
|
21
|
+
# 3. A complete section description hash. Ordinarily only used when that
|
22
|
+
# complete hash was previously looked up from resolve_sections config.
|
23
|
+
#
|
24
|
+
# For documentation of possible values in the section descripton hash,
|
25
|
+
# see SectionRenderer.
|
26
|
+
def render_section(arguments = {})
|
27
|
+
if arguments.kind_of?( SectionRenderer )
|
28
|
+
presenter = arguments
|
29
|
+
else
|
30
|
+
presenter = SectionRenderer.new(@user_request, arguments )
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
render(:partial => "section_display",
|
35
|
+
:locals =>
|
36
|
+
{:presenter => presenter } )
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def app_name
|
41
|
+
return umlaut_config.app_name
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
# size can be 'small', 'medium', or 'large.
|
46
|
+
# returns a ServiceResponse object, or nil.
|
47
|
+
def cover_image_response(size='medium')
|
48
|
+
cover_images = get_service_type('cover_image')
|
49
|
+
cover_images.each do |service_response|
|
50
|
+
return service_response if service_response.service_data[:size] == size
|
51
|
+
end
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
# Did this come from citation linker style entry?
|
58
|
+
# We check the referrer.
|
59
|
+
def user_entered_citation?(uml_request)
|
60
|
+
return false unless uml_request && uml_request.referrer_id
|
61
|
+
|
62
|
+
id = uml_request.referrer_id
|
63
|
+
return id == 'info:sid/sfxit.com:citation' || id == umlaut_config.lookup("rfr_ids.citation") || id == umlaut_config.lookup('rfr_ids.opensearch')
|
64
|
+
end
|
65
|
+
|
66
|
+
def display_not_found_warning?(uml_request)
|
67
|
+
metadata = uml_request.referent.metadata
|
68
|
+
display_manually_entered_typo_warning = umlaut_config.lookup!("entry_not_in_kb_warning", false)
|
69
|
+
|
70
|
+
return (metadata['genre'] != 'book' && metadata['object_id'].blank? && user_entered_citation?(@user_request) && display_manually_entered_typo_warning)
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# Generate content in an expand-contract block, with a heading that
|
75
|
+
# you can click on to show/hide it. Actual content in block.
|
76
|
+
# Example, in view:
|
77
|
+
# <% expand_contract_section("My Content", "div_id_to_use") do %>
|
78
|
+
# this will be hidden and shown
|
79
|
+
# <% end %>
|
80
|
+
def expand_contract_section(arg_heading, id, options={}, &block)
|
81
|
+
expanded = (params["umlaut.show_#{id}"] == "true") || options[:initial_expand] || false
|
82
|
+
|
83
|
+
icon = image_tag( ( expanded ? "list_open.png" : "list_closed.png"),
|
84
|
+
:alt => "",
|
85
|
+
:class => "toggle_icon",
|
86
|
+
:border => "0")
|
87
|
+
heading = content_tag(:span,( expanded ? "Hide " : "Show "), :class=>'expand_contract_action_label') + arg_heading
|
88
|
+
|
89
|
+
|
90
|
+
link_params = params.merge('umlaut.request_id' => @user_request.id,
|
91
|
+
"umlaut_show_#{id}" => (! expanded).to_s )
|
92
|
+
|
93
|
+
# Make sure a self-referencing link from partial_html_sections
|
94
|
+
# really goes to full HTML view.
|
95
|
+
link_params[:action] = "index" if link_params[:action] == "partial_html_sections"
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
return content_tag(:div, :class => "expand_contract_section") do
|
100
|
+
link_to( icon + heading, link_params,
|
101
|
+
:anchor => "#{id}_toggle_link",
|
102
|
+
:id => "#{id}_toggle_link",
|
103
|
+
:class => "expand_contract_toggle" ) + "\n" +
|
104
|
+
content_tag(:div, :id => id,
|
105
|
+
:class => "expand_contract_content",
|
106
|
+
:style => ("display: none;" unless expanded),
|
107
|
+
&block)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
# Code-generating helper to add a "More" link to a list, with a maximum
|
114
|
+
# number of items to show before 'more'. AJAXy show, with unobtrusive
|
115
|
+
# degredation when no javascript.
|
116
|
+
# Based on the idea here for a helper that takes a block. Uses
|
117
|
+
# expand_contract_section for actual hidden overflow. Will split list
|
118
|
+
# into two different <ul>'s, one before the cut and one after. Will generate
|
119
|
+
# <ul> tags itself.
|
120
|
+
# http://blog.zmok.net/articles/2008/04/22/block-level-helpers-in-ruby-on-rails
|
121
|
+
#
|
122
|
+
# id: id to use for HTML div for hidden part of list. Other ids
|
123
|
+
# will be based on this id too.
|
124
|
+
# list: your list
|
125
|
+
# limit: how many lines to show before cut off. Default 5. Note that
|
126
|
+
# at least two items will always be included in 'more'. If cutoff
|
127
|
+
# is 5 and your list is 5, all 5 will be shown. If cut-off is 5
|
128
|
+
# and list is 6, 4 items will be shown, with more. This is five
|
129
|
+
# total lines if the 'more' is considered a line.
|
130
|
+
# block: will be passed |item, index|, should generate html for that
|
131
|
+
# item in block.
|
132
|
+
#
|
133
|
+
# Example, in a view:
|
134
|
+
# <% list_with_limit("div_id_for_list", list, :limit=>10) do |item, index| %>
|
135
|
+
# <li>Item Number: <%= index %>: <%= item.title %></li>
|
136
|
+
# <% end %>
|
137
|
+
def list_with_limit(id, list, options = {}, &block)
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
# backwards compatible to when third argument was just a number
|
142
|
+
# for limit.
|
143
|
+
options = {:limit => options} unless options.kind_of?(Hash)
|
144
|
+
options[:limit] ||= 5
|
145
|
+
|
146
|
+
return "" if list.empty?
|
147
|
+
|
148
|
+
|
149
|
+
content = "".html_safe
|
150
|
+
|
151
|
+
content <<
|
152
|
+
content_tag(:ul, :class => ("" || options[:ul_class])) do
|
153
|
+
list.enum_for(:each_with_index).collect do |item, index|
|
154
|
+
capture(item, index, &block) unless list.length > options[:limit] && index >= options[:limit]-2
|
155
|
+
end.join(" \n ").html_safe
|
156
|
+
end
|
157
|
+
|
158
|
+
if (list.length > options[:limit] )
|
159
|
+
content <<
|
160
|
+
expand_contract_section("#{list.length - options[:limit] + 1} more", id) do
|
161
|
+
content_tag(:ul, :class=>options[:ul_class]) do
|
162
|
+
list.slice(options[:limit]-1..list.length-1).enum_for(:each_with_index).each do |item, index|
|
163
|
+
yield(item, index)
|
164
|
+
end.join(" \n ").html_safe
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
return content
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
def link_to_toggle_debug_info(name = "[D]", options = {})
|
174
|
+
javascript = " jQuery('.debug_info').toggle();"
|
175
|
+
|
176
|
+
return link_to_function(name, javascript, options)
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Methods to grab SectionRenderer definitions from config. Caching in
|
181
|
+
# class-level variables.
|
182
|
+
#
|
183
|
+
@@bg_update_sections = nil
|
184
|
+
@@partial_update_sections = nil
|
185
|
+
|
186
|
+
# Called by background updater to get a list of all sections configured
|
187
|
+
# in application config parameter resolve_sections to be included in
|
188
|
+
# background updates.
|
189
|
+
def bg_update_sections
|
190
|
+
unless (@@bg_update_sections)
|
191
|
+
@@bg_update_sections = umlaut_config.lookup!("resolve_sections", []).find_all do |section|
|
192
|
+
section[:bg_update] != false
|
193
|
+
end
|
194
|
+
end
|
195
|
+
@@bg_update_sections
|
196
|
+
end
|
197
|
+
|
198
|
+
# Called by partial_html_sections action to get a list of all sections
|
199
|
+
# that should be included in the partial_html_sections api response.
|
200
|
+
def partial_html_sections
|
201
|
+
unless (@@partial_update_sections)
|
202
|
+
@@partial_update_sections = umlaut_config.lookup!("resolve_sections", []).find_all do |section|
|
203
|
+
section[:partial_html_api] != false
|
204
|
+
end
|
205
|
+
end
|
206
|
+
@@partial_update_sections
|
207
|
+
end
|
208
|
+
|
209
|
+
# Called by resolve/index view to find sections configured
|
210
|
+
# in application config resolve_sections list for a specific
|
211
|
+
# part of the page. :main, :sidebar, or :resource_info.
|
212
|
+
def html_sections(area)
|
213
|
+
umlaut_config.lookup!("resolve_sections", []).find_all do |section|
|
214
|
+
section[:html_area] == area
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def html_section_by_div_id(div_id)
|
219
|
+
umlaut_config.lookup!("resolve_sections", []).find do |defn|
|
220
|
+
defn[:div_id] == div_id
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
end
|