blacklight 3.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- 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,31 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
3
|
+
Code licensed under the BSD License:
|
4
|
+
http://developer.yahoo.net/yui/license.txt
|
5
|
+
version: 2.6.0
|
6
|
+
*/
|
7
|
+
html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}del,ins{text-decoration:none;}
|
8
|
+
|
9
|
+
/*
|
10
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
11
|
+
Code licensed under the BSD License:
|
12
|
+
http://developer.yahoo.net/yui/license.txt
|
13
|
+
version: 2.6.0
|
14
|
+
*/
|
15
|
+
h1{font-size:138.5%;}h2{font-size:123.1%;}h3{font-size:108%;}h1,h2,h3{margin:1em 0;}h1,h2,h3,h4,h5,h6,strong{font-weight:bold;}abbr,acronym{border-bottom:1px dotted #000;cursor:help;} em{font-style:italic;}blockquote,ul,ol,dl{margin:1em;}ol,ul,dl{margin-left:2em;}ol li{list-style:decimal outside;}ul li{list-style:disc outside;}dl dd{margin-left:1em;}th,td{border:1px solid #000;padding:.5em;}th{font-weight:bold;text-align:center;}caption{margin-bottom:.5em;text-align:center;}p,fieldset,table,pre{margin-bottom:1em;}input[type=text],input[type=password],textarea{width:12.25em;*width:11.9em;}
|
16
|
+
|
17
|
+
/*
|
18
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
19
|
+
Code licensed under the BSD License:
|
20
|
+
http://developer.yahoo.net/yui/license.txt
|
21
|
+
version: 2.6.0
|
22
|
+
*/
|
23
|
+
body{font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}select,input,button,textarea{font:99% arial,helvetica,clean,sans-serif;}table{font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;}
|
24
|
+
|
25
|
+
/*
|
26
|
+
Copyright (c) 2008, Yahoo! Inc. All rights reserved.
|
27
|
+
Code licensed under the BSD License:
|
28
|
+
http://developer.yahoo.net/yui/license.txt
|
29
|
+
version: 2.6.0
|
30
|
+
*/
|
31
|
+
body{text-align:center;}#ft{clear:both;}#doc,#doc2,#doc3,#doc4,.yui-t1,.yui-t2,.yui-t3,.yui-t4,.yui-t5,.yui-t6,.yui-t7{margin:auto;text-align:left;width:57.69em;*width:56.25em;min-width:750px;}#doc2{width:73.076em;*width:71.25em;}#doc3{margin:auto 10px;width:auto;}#doc4{width:74.923em;*width:73.05em;}.yui-b{position:relative;}.yui-b{_position:static;}#yui-main .yui-b{position:static;}#yui-main,.yui-g .yui-u .yui-g{width:100%;}{width:100%;}.yui-t1 #yui-main,.yui-t2 #yui-main,.yui-t3 #yui-main{float:right;margin-left:-25em;}.yui-t4 #yui-main,.yui-t5 #yui-main,.yui-t6 #yui-main{float:left;margin-right:-25em;}.yui-t1 .yui-b{float:left;width:12.30769em;*width:12.00em;}.yui-t1 #yui-main .yui-b{margin-left:13.30769em;*margin-left:13.05em;}.yui-t2 .yui-b{float:left;width:13.8461em;*width:13.50em;}.yui-t2 #yui-main .yui-b{margin-left:14.8461em;*margin-left:14.55em;}.yui-t3 .yui-b{float:left;width:23.0769em;*width:22.50em;}.yui-t3 #yui-main .yui-b{margin-left:24.0769em;*margin-left:23.62em;}.yui-t4 .yui-b{float:right;width:13.8456em;*width:13.50em;}.yui-t4 #yui-main .yui-b{margin-right:14.8456em;*margin-right:14.55em;}.yui-t5 .yui-b{float:right;width:18.4615em;*width:18.00em;}.yui-t5 #yui-main .yui-b{margin-right:19.4615em;*margin-right:19.125em;}.yui-t6 .yui-b{float:right;width:23.0769em;*width:22.50em;}.yui-t6 #yui-main .yui-b{margin-right:24.0769em;*margin-right:23.62em;}.yui-t7 #yui-main .yui-b{display:block;margin:0 0 1em 0;}#yui-main .yui-b{float:none;width:auto;}.yui-gb .yui-u,.yui-g .yui-gb .yui-u,.yui-gb .yui-g,.yui-gb .yui-gb,.yui-gb .yui-gc,.yui-gb .yui-gd,.yui-gb .yui-ge,.yui-gb .yui-gf,.yui-gc .yui-u,.yui-gc .yui-g,.yui-gd .yui-u{float:left;}.yui-g .yui-u,.yui-g .yui-g,.yui-g .yui-gb,.yui-g .yui-gc,.yui-g .yui-gd,.yui-g .yui-ge,.yui-g .yui-gf,.yui-gc .yui-u,.yui-gd .yui-g,.yui-g .yui-gc .yui-u,.yui-ge .yui-u,.yui-ge .yui-g,.yui-gf .yui-g,.yui-gf .yui-u{float:right;}.yui-g div.first,.yui-gb div.first,.yui-gc div.first,.yui-gd div.first,.yui-ge div.first,.yui-gf div.first,.yui-g .yui-gc div.first,.yui-g .yui-ge div.first,.yui-gc div.first div.first{float:left;}.yui-g .yui-u,.yui-g .yui-g,.yui-g .yui-gb,.yui-g .yui-gc,.yui-g .yui-gd,.yui-g .yui-ge,.yui-g .yui-gf{width:49.1%;}.yui-gb .yui-u,.yui-g .yui-gb .yui-u,.yui-gb .yui-g,.yui-gb .yui-gb,.yui-gb .yui-gc,.yui-gb .yui-gd,.yui-gb .yui-ge,.yui-gb .yui-gf,.yui-gc .yui-u,.yui-gc .yui-g,.yui-gd .yui-u{width:32%;margin-left:1.99%;}.yui-gb .yui-u{*margin-left:1.9%;*width:31.9%;}.yui-gc div.first,.yui-gd .yui-u{width:66%;}.yui-gd div.first{width:32%;}.yui-ge div.first,.yui-gf .yui-u{width:74.2%;}.yui-ge .yui-u,.yui-gf div.first{width:24%;}.yui-g .yui-gb div.first,.yui-gb div.first,.yui-gc div.first,.yui-gd div.first{margin-left:0;}.yui-g .yui-g .yui-u,.yui-gb .yui-g .yui-u,.yui-gc .yui-g .yui-u,.yui-gd .yui-g .yui-u,.yui-ge .yui-g .yui-u,.yui-gf .yui-g .yui-u{width:49%;*width:48.1%;*margin-left:0;}.yui-g .yui-g .yui-u{width:48.1%;}.yui-g .yui-gb div.first,.yui-gb .yui-gb div.first{*margin-right:0;*width:32%;_width:31.7%;}.yui-g .yui-gc div.first,.yui-gd .yui-g{width:66%;}.yui-gb .yui-g div.first{*margin-right:4%;_margin-right:1.3%;}.yui-gb .yui-gc div.first,.yui-gb .yui-gd div.first{*margin-right:0;}.yui-gb .yui-gb .yui-u,.yui-gb .yui-gc .yui-u{*margin-left:1.8%;_margin-left:4%;}.yui-g .yui-gb .yui-u{_margin-left:1.0%;}.yui-gb .yui-gd .yui-u{*width:66%;_width:61.2%;}.yui-gb .yui-gd div.first{*width:31%;_width:29.5%;}.yui-g .yui-gc .yui-u,.yui-gb .yui-gc .yui-u{width:32%;_float:right;margin-right:0;_margin-left:0;}.yui-gb .yui-gc div.first{width:66%;*float:left;*margin-left:0;}.yui-gb .yui-ge .yui-u,.yui-gb .yui-gf .yui-u{margin:0;}.yui-gb .yui-gb .yui-u{_margin-left:.7%;}.yui-gb .yui-g div.first,.yui-gb .yui-gb div.first{*margin-left:0;}.yui-gc .yui-g .yui-u,.yui-gd .yui-g .yui-u{*width:48.1%;*margin-left:0;} .yui-gb .yui-gd div.first{width:32%;}.yui-g .yui-gd div.first{_width:29.9%;}.yui-ge .yui-g{width:24%;}.yui-gf .yui-g{width:74.2%;}.yui-gb .yui-ge div.yui-u,.yui-gb .yui-gf div.yui-u{float:right;}.yui-gb .yui-ge div.first,.yui-gb .yui-gf div.first{float:left;}.yui-gb .yui-ge .yui-u,.yui-gb .yui-gf div.first{*width:24%;_width:20%;}.yui-gb .yui-ge div.first,.yui-gb .yui-gf .yui-u{*width:73.5%;_width:65.5%;}.yui-ge div.first .yui-gd .yui-u{width:65%;}.yui-ge div.first .yui-gd div.first{width:32%;}#bd:after,.yui-g:after,.yui-gb:after,.yui-gc:after,.yui-gd:after,.yui-ge:after,.yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd,.yui-g,.yui-gb,.yui-gc,.yui-gd,.yui-ge,.yui-gf{zoom:1;}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class SolrDocument
|
2
|
+
|
3
|
+
include Blacklight::Solr::Document
|
4
|
+
|
5
|
+
# The following shows how to setup this blacklight document to display marc documents
|
6
|
+
extension_parameters[:marc_source_field] = :marc_display
|
7
|
+
extension_parameters[:marc_format_type] = :marcxml
|
8
|
+
use_extension( Blacklight::Solr::Document::Marc) do |document|
|
9
|
+
document.key?( :marc_display )
|
10
|
+
end
|
11
|
+
|
12
|
+
# Email uses the semantic field mappings below to generate the body of an email.
|
13
|
+
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
14
|
+
|
15
|
+
# SMS uses the semantic field mappings below to generate the body of an SMS email.
|
16
|
+
SolrDocument.use_extension( Blacklight::Solr::Document::Sms )
|
17
|
+
|
18
|
+
# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
|
19
|
+
# Semantic mappings of solr stored fields. Fields may be multi or
|
20
|
+
# single valued. See Blacklight::Solr::Document::ExtendableClassMethods#field_semantics
|
21
|
+
# and Blacklight::Solr::Document#to_semantic_values
|
22
|
+
# Recommendation: Use field names from Dublin Core
|
23
|
+
use_extension( Blacklight::Solr::Document::DublinCore)
|
24
|
+
field_semantics.merge!(
|
25
|
+
:title => "title_display",
|
26
|
+
:author => "author_display",
|
27
|
+
:language => "language_facet",
|
28
|
+
:format => "format"
|
29
|
+
)
|
30
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
namespace :blacklight do
|
2
|
+
|
3
|
+
# task to clean out old, unsaved searches
|
4
|
+
# rake blacklight:delete_old_searches[days_old]
|
5
|
+
# example cron entry to delete searches older than 7 days at 2:00 AM every day:
|
6
|
+
# 0 2 * * * cd /path/to/your/app && /path/to/rake blacklight:delete_old_searches[7] RAILS_ENV=your_env
|
7
|
+
desc "Removes entries in the searches table that are older than the number of days given."
|
8
|
+
task :delete_old_searches, :days_old, :needs => :environment do |t, args|
|
9
|
+
Search.delete_old_searches(args[:days_old].to_i)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
# Rake tasks for Blacklight plugin
|
15
|
+
|
16
|
+
# if you would like to see solr startup messages on STDERR
|
17
|
+
# when starting solr test server during functional tests use:
|
18
|
+
#
|
19
|
+
# rake SOLR_CONSOLE=true
|
20
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'test_solr_server.rb'))
|
21
|
+
|
22
|
+
|
23
|
+
SOLR_PARAMS = {
|
24
|
+
:quiet => ENV['SOLR_CONSOLE'] ? false : true,
|
25
|
+
:jetty_home => ENV['SOLR_JETTY_HOME'] || File.expand_path('./jetty'),
|
26
|
+
:jetty_port => ENV['SOLR_JETTY_PORT'] || 8888,
|
27
|
+
:solr_home => ENV['SOLR_HOME'] || File.expand_path('./jetty/solr')
|
28
|
+
}
|
29
|
+
|
30
|
+
NO_JETTY_MSG = "In order to use solr:spec, you much checkout Blacklight-jetty from our github repository, and place it in the root of your application under the directory /jetty. \n prompt> git clone git@github.com:projectblacklight/blacklight-jetty.git jetty \n You will also need to pupulate your test instance of solr with test data. You can do this with: \n prompt> rake solr:marc:index_test_data RAILS_ENV=test"
|
31
|
+
|
32
|
+
namespace :solr do
|
33
|
+
|
34
|
+
desc "Calls RSpec Examples wrapped in the test instance of Solr"
|
35
|
+
task :spec do
|
36
|
+
raise NO_JETTY_MSG unless File.exists? SOLR_PARAMS[:jetty_home]
|
37
|
+
# wrap tests with a test-specific Solr server
|
38
|
+
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
39
|
+
rm_f "coverage.data"
|
40
|
+
Rake::Task["rake:spec"].invoke
|
41
|
+
#puts `ps aux | grep start.jar`
|
42
|
+
end
|
43
|
+
raise "test failures: #{error}" if error
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Calls Cucumber Features wrapped in the test instance of Solr"
|
47
|
+
task :features do
|
48
|
+
# wrap tests with a test-specific Solr server
|
49
|
+
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
50
|
+
Rake::Task["cucumber:all"].invoke
|
51
|
+
#puts `ps aux | grep start.jar`
|
52
|
+
end
|
53
|
+
raise "test failures: #{error}" if error
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Runs all features and specs"
|
57
|
+
task :all do
|
58
|
+
error = TestSolrServer.wrap(SOLR_PARAMS) do
|
59
|
+
Rake::Task["rake:spec"].invoke
|
60
|
+
Rake::Task["cucumber:all"].invoke
|
61
|
+
end
|
62
|
+
raise "test failures: #{error}" if error
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
end
|
38
|
+
desc 'Alias for cucumber:ok'
|
39
|
+
task :cucumber => 'cucumber:ok'
|
40
|
+
|
41
|
+
task :default => :cucumber
|
42
|
+
|
43
|
+
task :features => :cucumber do
|
44
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
48
|
+
task :cucumber do
|
49
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
blacklight_plugin_dir = "#{File.dirname(__FILE__)}/../.."
|
2
|
+
|
3
|
+
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
|
4
|
+
rspec_gem_dir = nil
|
5
|
+
Dir["#{blacklight_plugin_dir}/vendor/gems/*"].each do |subdir|
|
6
|
+
rspec_gem_dir = subdir if subdir.gsub("#{blacklight_plugin_dir}/vendor/gems/","") =~ /^(\w+-)?rspec-(\d+)/ && File.exist?("#{subdir}/lib/spec/rake/spectask.rb")
|
7
|
+
end
|
8
|
+
rspec_plugin_dir = File.expand_path(File.dirname(__FILE__) + '/../../vendor/plugins/rspec')
|
9
|
+
|
10
|
+
if rspec_gem_dir && (test ?d, rspec_plugin_dir)
|
11
|
+
raise "\n#{'*'*50}\nYou have rspec installed in both vendor/gems and vendor/plugins\nPlease pick one and dispose of the other.\n#{'*'*50}\n\n"
|
12
|
+
end
|
13
|
+
|
14
|
+
if rspec_gem_dir
|
15
|
+
$LOAD_PATH.unshift("#{rspec_gem_dir}/lib")
|
16
|
+
elsif File.exist?(rspec_plugin_dir)
|
17
|
+
$LOAD_PATH.unshift("#{rspec_plugin_dir}/lib")
|
18
|
+
end
|
19
|
+
|
20
|
+
# Don't load rspec if running "rake gems:*"
|
21
|
+
unless ARGV.any? {|a| a =~ /^gems/}
|
22
|
+
|
23
|
+
begin
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
rescue MissingSourceFile
|
26
|
+
module Spec
|
27
|
+
module Rake
|
28
|
+
class SpecTask
|
29
|
+
def initialize(name)
|
30
|
+
task name do
|
31
|
+
# if rspec-rails is a configured gem, this will output helpful material and exit ...
|
32
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
|
33
|
+
|
34
|
+
# ... otherwise, do this:
|
35
|
+
raise <<-MSG
|
36
|
+
|
37
|
+
#{"*" * 80}
|
38
|
+
* You are trying to run an rspec rake task defined in
|
39
|
+
* #{__FILE__},
|
40
|
+
* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
|
41
|
+
#{"*" * 80}
|
42
|
+
MSG
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Rake.application.instance_variable_get('@tasks').delete('default')
|
51
|
+
|
52
|
+
spec_prereq = File.exist?(File.join(::Rails.root.to_s, 'config', 'database.yml')) ? "db:test:prepare" : :noop
|
53
|
+
task :noop do
|
54
|
+
end
|
55
|
+
|
56
|
+
# task :default => :spec
|
57
|
+
task :stats => "spec:statsetup"
|
58
|
+
|
59
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
60
|
+
Spec::Rake::SpecTask.new(:spec => spec_prereq) do |t|
|
61
|
+
t.spec_opts = ['--options', "\"#{blacklight_plugin_dir}/spec/spec.opts\""]
|
62
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
63
|
+
t.rcov = true
|
64
|
+
t.rcov_opts = lambda do
|
65
|
+
IO.readlines("#{blacklight_plugin_dir}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
namespace :spec do
|
70
|
+
desc "Run all specs in spec directory with RCov (excluding plugin specs)"
|
71
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
72
|
+
t.spec_opts = ['--options', "\"#{blacklight_plugin_dir}/spec/spec.opts\""]
|
73
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
74
|
+
t.rcov = true
|
75
|
+
t.rcov_opts = lambda do
|
76
|
+
IO.readlines("#{blacklight_plugin_dir}/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Print Specdoc for all specs (excluding plugin specs)"
|
81
|
+
Spec::Rake::SpecTask.new(:doc) do |t|
|
82
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
83
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Print Specdoc for all plugin examples"
|
87
|
+
Spec::Rake::SpecTask.new(:plugin_doc) do |t|
|
88
|
+
t.spec_opts = ["--format", "specdoc", "--dry-run"]
|
89
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*')
|
90
|
+
end
|
91
|
+
|
92
|
+
[:models, :controllers, :views, :helpers, :lib, :integration].each do |sub|
|
93
|
+
desc "Run the code examples in spec/#{sub}"
|
94
|
+
Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
|
95
|
+
t.spec_opts = ['--options', "\"#{blacklight_plugin_dir}/spec/spec.opts\""]
|
96
|
+
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "Run the code examples in vendor/plugins (except RSpec's own)"
|
101
|
+
Spec::Rake::SpecTask.new(:plugins => spec_prereq) do |t|
|
102
|
+
t.spec_opts = ['--options', "\"#{blacklight_plugin_dir}/spec/spec.opts\""]
|
103
|
+
t.spec_files = FileList['vendor/plugins/**/spec/**/*_spec.rb'].exclude('vendor/plugins/rspec/*').exclude("vendor/plugins/rspec-rails/*")
|
104
|
+
end
|
105
|
+
|
106
|
+
namespace :plugins do
|
107
|
+
desc "Runs the examples for rspec_on_rails"
|
108
|
+
Spec::Rake::SpecTask.new(:rspec_on_rails) do |t|
|
109
|
+
t.spec_opts = ['--options', "\"#{blacklight_plugin_dir}/spec/spec.opts\""]
|
110
|
+
t.spec_files = FileList['vendor/plugins/rspec-rails/spec/**/*_spec.rb']
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Setup specs for stats
|
115
|
+
task :statsetup do
|
116
|
+
require 'code_statistics'
|
117
|
+
::STATS_DIRECTORIES << %w(Model\ specs spec/models) if File.exist?('spec/models')
|
118
|
+
::STATS_DIRECTORIES << %w(View\ specs spec/views) if File.exist?('spec/views')
|
119
|
+
::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers) if File.exist?('spec/controllers')
|
120
|
+
::STATS_DIRECTORIES << %w(Helper\ specs spec/helpers) if File.exist?('spec/helpers')
|
121
|
+
::STATS_DIRECTORIES << %w(Library\ specs spec/lib) if File.exist?('spec/lib')
|
122
|
+
::STATS_DIRECTORIES << %w(Routing\ specs spec/routing) if File.exist?('spec/routing')
|
123
|
+
::STATS_DIRECTORIES << %w(Integration\ specs spec/integration) if File.exist?('spec/integration')
|
124
|
+
::CodeStatistics::TEST_TYPES << "Model specs" if File.exist?('spec/models')
|
125
|
+
::CodeStatistics::TEST_TYPES << "View specs" if File.exist?('spec/views')
|
126
|
+
::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
|
127
|
+
::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
|
128
|
+
::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
|
129
|
+
::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
|
130
|
+
::CodeStatistics::TEST_TYPES << "Integration specs" if File.exist?('spec/integration')
|
131
|
+
end
|
132
|
+
|
133
|
+
namespace :db do
|
134
|
+
namespace :fixtures do
|
135
|
+
desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z."
|
136
|
+
task :load => :environment do
|
137
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
138
|
+
base_dir = File.join(Rails.root, 'spec', 'fixtures')
|
139
|
+
fixtures_dir = ENV['FIXTURES_DIR'] ? File.join(base_dir, ENV['FIXTURES_DIR']) : base_dir
|
140
|
+
|
141
|
+
require 'active_record/fixtures'
|
142
|
+
(ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/).map {|f| File.join(fixtures_dir, f) } : Dir.glob(File.join(fixtures_dir, '*.{yml,csv}'))).each do |fixture_file|
|
143
|
+
Fixtures.create_fixtures(File.dirname(fixture_file), File.basename(fixture_file, '.*'))
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
namespace :server do
|
150
|
+
daemonized_server_pid = File.expand_path("#{blacklight_plugin_dir}/tmp/pids/spec_server.pid")
|
151
|
+
|
152
|
+
desc "start spec_server."
|
153
|
+
task :start do
|
154
|
+
if File.exist?(daemonized_server_pid)
|
155
|
+
$stderr.puts "spec_server is already running."
|
156
|
+
else
|
157
|
+
$stderr.puts %Q{Starting up spec_server ...}
|
158
|
+
FileUtils.mkdir_p('tmp/pids') unless test ?d, 'tmp/pids'
|
159
|
+
system("ruby", "script/spec_server", "--daemon", "--pid", daemonized_server_pid)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "stop spec_server."
|
164
|
+
task :stop do
|
165
|
+
unless File.exist?(daemonized_server_pid)
|
166
|
+
$stderr.puts "No server running."
|
167
|
+
else
|
168
|
+
$stderr.puts "Shutting down spec_server ..."
|
169
|
+
system("kill", "-s", "TERM", File.read(daemonized_server_pid).strip) &&
|
170
|
+
File.delete(daemonized_server_pid)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
desc "restart spec_server."
|
175
|
+
task :restart => [:stop, :start]
|
176
|
+
|
177
|
+
desc "check if spec server is running"
|
178
|
+
task :status do
|
179
|
+
if File.exist?(daemonized_server_pid)
|
180
|
+
$stderr.puts %Q{spec_server is running (PID: #{File.read(daemonized_server_pid).gsub("\n","")})}
|
181
|
+
else
|
182
|
+
$stderr.puts "No server running."
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# -*- coding: undecided -*-
|
2
|
+
# Rake tasks for the SolrMarc Java indexer.
|
3
|
+
# Marc Record defaults to indexing lc_records.utf8.mrc
|
4
|
+
# config.properties defaults to config/demo_config.properties (in the plugin, not the rails app)
|
5
|
+
|
6
|
+
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
namespace :solr do
|
12
|
+
namespace :marc do
|
13
|
+
|
14
|
+
|
15
|
+
desc "Index the supplied test data into Solr"
|
16
|
+
task :index_test_data do
|
17
|
+
ENV['MARC_FILE'] = locate_path("spec", "data", "test_data.utf8.mrc")
|
18
|
+
|
19
|
+
Rake::Task[ "solr:marc:index:work" ].invoke
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Index marc data using SolrMarc. Available environment variables: MARC_RECORDS_PATH, CONFIG_PATH, SOLR_MARC_MEM_ARGS"
|
23
|
+
task :index => "index:work"
|
24
|
+
|
25
|
+
namespace :index do
|
26
|
+
|
27
|
+
task :work do
|
28
|
+
solrmarc_arguments = compute_arguments
|
29
|
+
|
30
|
+
# If no marc records given, display :info task
|
31
|
+
if (ENV["NOOP"] || (!solrmarc_arguments["MARC_FILE"]))
|
32
|
+
Rake::Task[ "solr:marc:index:info" ].execute
|
33
|
+
else
|
34
|
+
commandStr = solrmarc_command_line( solrmarc_arguments )
|
35
|
+
puts commandStr
|
36
|
+
puts
|
37
|
+
`#{commandStr}`
|
38
|
+
end
|
39
|
+
|
40
|
+
end # work
|
41
|
+
|
42
|
+
desc "Shows more info about the solr:marc:index task."
|
43
|
+
task :info do
|
44
|
+
solrmarc_arguments = compute_arguments
|
45
|
+
puts <<-EOS
|
46
|
+
Solr to write to is taken from current environment in config/solr.yml,
|
47
|
+
key :replicate_master_url is supported, taking precedence over :url
|
48
|
+
for where to write to.
|
49
|
+
|
50
|
+
Possible environment variables, with settings as invoked. You can set these
|
51
|
+
variables on the command line, eg:
|
52
|
+
rake solr:marc:index MARC_FILE=/some/file.mrc
|
53
|
+
|
54
|
+
MARC_FILE: #{solrmarc_arguments["MARC_FILE"] || "[marc records path needed]"}
|
55
|
+
|
56
|
+
CONFIG_PATH: #{solrmarc_arguments[:config_properties_path]}
|
57
|
+
Defaults to RAILS_ROOT/config/SolrMarc/config(-RAILS_ENV).properties
|
58
|
+
or else RAILS_ROOT/vendor/plugins/blacklight/SolrMarc/config ...
|
59
|
+
|
60
|
+
Note that SolrMarc search path includes directory of config_path,
|
61
|
+
so translation_maps and index_scripts dirs will be found there.
|
62
|
+
|
63
|
+
SOLRMARC_JAR_PATH: #{solrmarc_arguments[:solrmarc_jar_path]}
|
64
|
+
|
65
|
+
SOLRMARC_MEM_ARGS: #{solrmarc_arguments[:solrmarc_mem_arg]}
|
66
|
+
|
67
|
+
SolrMarc command that will be run:
|
68
|
+
|
69
|
+
#{solrmarc_command_line(solrmarc_arguments)}
|
70
|
+
EOS
|
71
|
+
end
|
72
|
+
end # index
|
73
|
+
end # :marc
|
74
|
+
end # :solr
|
75
|
+
|
76
|
+
# Computes arguments to Solr, returns hash
|
77
|
+
# Calculate default args based on location of rake file itself,
|
78
|
+
# which we assume to be in the plugin, or in the Rails executing
|
79
|
+
# this rake task, at RAILS_ROOT.
|
80
|
+
def compute_arguments
|
81
|
+
|
82
|
+
arguments = {}
|
83
|
+
|
84
|
+
arguments["MARC_FILE"] = ENV["MARC_FILE"]
|
85
|
+
|
86
|
+
|
87
|
+
app_site_path = File.expand_path(File.join(Rails.root, "config", "SolrMarc"))
|
88
|
+
plugin_site_path = File.expand_path(File.join(Rails.root, "vendor", "plugins", "blacklight", "config", "SolrMarc"))
|
89
|
+
|
90
|
+
|
91
|
+
# Find config in local app or plugin, possibly based on our RAILS_ENV (::Rails.env)
|
92
|
+
arguments[:config_properties_path] = ENV['CONFIG_PATH']
|
93
|
+
unless arguments[:config_properties_path]
|
94
|
+
[ File.join(app_site_path, "config-#{::Rails.env}.properties" ),
|
95
|
+
File.join( app_site_path, "config.properties"),
|
96
|
+
File.join( plugin_site_path, "config-#{::Rails.env}.properties"),
|
97
|
+
File.join( plugin_site_path, "config.properties"),
|
98
|
+
].each do |file_path|
|
99
|
+
if File.exists?(file_path)
|
100
|
+
arguments[:config_properties_path] = file_path
|
101
|
+
break
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
#java mem arg is from env, or default
|
107
|
+
|
108
|
+
arguments[:solrmarc_mem_arg] = ENV['SOLRMARC_MEM_ARGS'] || '-Xmx512m'
|
109
|
+
|
110
|
+
# SolrMarc is embedded in the plugin, or could be a custom
|
111
|
+
# one in local app.
|
112
|
+
arguments[:solrmarc_jar_path] = ENV['SOLRMARC_JAR_PATH'] || locate_path("lib", "SolrMarc.jar")
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
# Solr URL, find from solr.yml, app or plugin
|
118
|
+
# use :replicate_master_url for current env if present, otherwise :url
|
119
|
+
# for current env.
|
120
|
+
solr_yml_path = locate_path("config", "solr.yml")
|
121
|
+
if ( File.exists?( solr_yml_path ))
|
122
|
+
solr_config = YAML::load(File.open(solr_yml_path))
|
123
|
+
arguments[:solr_url] = solr_config[ ::Rails.env ]['url'] if solr_config[::Rails.env]
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
return arguments
|
128
|
+
end
|
129
|
+
|
130
|
+
def solrmarc_command_line(arguments)
|
131
|
+
cmd = "java #{arguments[:solrmarc_mem_arg]} "
|
132
|
+
cmd += " -Dsolr.hosturl=#{arguments[:solr_url]} " unless arguments[:solr_url].blank?
|
133
|
+
cmd += " -jar #{arguments[:solrmarc_jar_path]} #{arguments[:config_properties_path]} #{arguments["MARC_FILE"]}"
|
134
|
+
return cmd
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def locate_path(*subpath_fragments)
|
139
|
+
local_root = File.expand_path File.join(File.dirname(__FILE__), '..', '..')
|
140
|
+
puts "The local_root is #{local_root}"
|
141
|
+
subpath = subpath_fragments.join('/')
|
142
|
+
base_match = [Rails.root, local_root].find do |base|
|
143
|
+
File.exists? File.join(base, subpath)
|
144
|
+
end
|
145
|
+
File.join(base_match.to_s, subpath) if base_match
|
146
|
+
end
|
147
|
+
|
148
|
+
|