blacklight 4.9.0 → 5.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.travis.yml +22 -12
  4. data/Gemfile +3 -40
  5. data/LICENSE +1 -2
  6. data/README.md +1 -2
  7. data/Rakefile +0 -4
  8. data/VERSION +1 -1
  9. data/app/assets/images/blacklight/logo.png +0 -0
  10. data/app/assets/javascripts/blacklight/ajax_modal.js +190 -0
  11. data/app/assets/javascripts/blacklight/blacklight.js +7 -17
  12. data/app/assets/javascripts/blacklight/checkbox_submit.js +1 -1
  13. data/app/assets/stylesheets/blacklight/{_blacklight_base.scss → _blacklight_base.css.scss} +0 -21
  14. data/app/assets/stylesheets/blacklight/_bookmark.css.scss +4 -0
  15. data/app/assets/stylesheets/blacklight/_catalog.css.scss +192 -0
  16. data/app/assets/stylesheets/blacklight/_facets.css.scss +141 -0
  17. data/app/assets/stylesheets/blacklight/{_group.scss → _group.css.scss} +1 -1
  18. data/app/assets/stylesheets/blacklight/_header.css.scss +44 -0
  19. data/app/assets/stylesheets/blacklight/_layout.css.scss +5 -0
  20. data/app/assets/stylesheets/blacklight/{_modal.scss → _modal.css.scss} +7 -7
  21. data/app/assets/stylesheets/blacklight/_search_history.css.scss +20 -0
  22. data/app/assets/stylesheets/blacklight/{blacklight.scss → blacklight.css.scss} +0 -0
  23. data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +14 -0
  24. data/app/controllers/bookmarks_controller.rb +0 -4
  25. data/app/controllers/feedback_controller.rb +0 -4
  26. data/app/helpers/blacklight/blacklight_helper_behavior.rb +45 -155
  27. data/app/helpers/blacklight/catalog_helper_behavior.rb +8 -41
  28. data/app/helpers/blacklight/facets_helper_behavior.rb +20 -43
  29. data/app/helpers/blacklight/hash_as_hidden_fields_helper_behavior.rb +2 -9
  30. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +9 -14
  31. data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +6 -6
  32. data/app/views/_flash_msg.html.erb +9 -2
  33. data/app/views/_user_util_links.html.erb +29 -15
  34. data/app/views/bookmarks/_tools.html.erb +4 -7
  35. data/app/views/bookmarks/index.html.erb +3 -2
  36. data/app/views/catalog/_citation.html.erb +1 -1
  37. data/app/views/catalog/_constraints.html.erb +1 -1
  38. data/app/views/catalog/_constraints_element.html.erb +12 -8
  39. data/app/views/catalog/_did_you_mean.html.erb +2 -2
  40. data/app/views/catalog/_document_header.html.erb +3 -3
  41. data/app/views/catalog/_email_form.html.erb +10 -10
  42. data/app/views/catalog/_facet_layout.html.erb +11 -3
  43. data/app/views/catalog/_facet_limit.html.erb +7 -7
  44. data/app/views/catalog/_facet_pagination.html.erb +8 -7
  45. data/app/views/catalog/_facet_pivot.html.erb +3 -1
  46. data/app/views/catalog/_facets.html.erb +12 -9
  47. data/app/views/catalog/_paginate_compact.html.erb +1 -7
  48. data/app/views/catalog/_per_page_widget.html.erb +5 -8
  49. data/app/views/catalog/_previous_next_doc.html.erb +11 -9
  50. data/app/views/catalog/_refworks_form.html.erb +3 -4
  51. data/app/views/catalog/_results_pagination.html.erb +1 -1
  52. data/app/views/catalog/_search_form.html.erb +16 -14
  53. data/app/views/catalog/_show_sidebar.html.erb +7 -9
  54. data/app/views/catalog/_show_tools.html.erb +13 -7
  55. data/app/views/catalog/_sms_form.html.erb +8 -8
  56. data/app/views/catalog/_sort_and_per_page.html.erb +4 -6
  57. data/app/views/catalog/_sort_widget.html.erb +5 -6
  58. data/app/views/catalog/email.html.erb +1 -1
  59. data/app/views/catalog/facet.html.erb +2 -8
  60. data/app/views/catalog/index.html.erb +11 -6
  61. data/app/views/catalog/show.html.erb +5 -5
  62. data/app/views/catalog/sms.html.erb +1 -1
  63. data/app/views/catalog/sms_sent.html.erb +1 -1
  64. data/app/views/feedback/complete.html.erb +2 -2
  65. data/app/views/feedback/show.html.erb +1 -1
  66. data/app/views/kaminari/blacklight/_paginator.html.erb +1 -1
  67. data/app/views/kaminari/blacklight_compact/_paginator.html.erb +25 -5
  68. data/app/views/layouts/blacklight.html.erb +23 -23
  69. data/app/views/saved_searches/index.html.erb +2 -2
  70. data/app/views/search_history/index.html.erb +5 -7
  71. data/app/views/shared/_header_navbar.html.erb +23 -23
  72. data/blacklight.gemspec +10 -13
  73. data/config/locales/blacklight.en.yml +1 -12
  74. data/config/locales/blacklight.fr.yml +1 -12
  75. data/gemfiles/rails3.gemfile +21 -0
  76. data/gemfiles/rails4.gemfile +20 -0
  77. data/lib/blacklight.rb +0 -8
  78. data/lib/blacklight/base.rb +0 -2
  79. data/lib/blacklight/catalog.rb +6 -32
  80. data/lib/blacklight/catalog/search_context.rb +8 -48
  81. data/lib/blacklight/configurable.rb +2 -1
  82. data/lib/blacklight/configuration.rb +1 -2
  83. data/lib/blacklight/configuration/facet_field.rb +0 -2
  84. data/lib/blacklight/engine.rb +3 -3
  85. data/lib/blacklight/legacy_controller_methods.rb +1 -64
  86. data/lib/blacklight/rails/routes.rb +17 -0
  87. data/lib/blacklight/routes.rb +46 -40
  88. data/lib/blacklight/solr.rb +1 -0
  89. data/lib/blacklight/solr/document.rb +21 -42
  90. data/lib/blacklight/solr/facet_paginator.rb +30 -54
  91. data/lib/blacklight/solr/request.rb +45 -0
  92. data/lib/blacklight/solr_helper.rb +16 -53
  93. data/lib/blacklight/solr_response.rb +0 -6
  94. data/lib/blacklight/user.rb +2 -7
  95. data/lib/blacklight/utils.rb +1 -9
  96. data/lib/generators/blacklight/assets_generator.rb +0 -14
  97. data/lib/generators/blacklight/blacklight_generator.rb +17 -14
  98. data/lib/generators/blacklight/templates/blacklight.css.scss +3 -0
  99. data/lib/generators/blacklight/templates/catalog_controller.rb +4 -1
  100. data/lib/railties/blacklight.rake +3 -1
  101. data/solr/sample_solr_documents.yml +641 -0
  102. data/spec/controllers/application_controller_spec.rb +5 -21
  103. data/spec/controllers/bookmarks_controller_spec.rb +11 -11
  104. data/spec/controllers/catalog_controller_spec.rb +122 -119
  105. data/spec/controllers/search_history_controller_spec.rb +8 -8
  106. data/spec/features/alternate_controller_spec.rb +5 -5
  107. data/spec/features/facets_spec.rb +9 -0
  108. data/spec/features/record_view_spec.rb +1 -1
  109. data/spec/features/search_filters_spec.rb +97 -41
  110. data/spec/features/search_results_spec.rb +14 -17
  111. data/spec/features/search_sort_spec.rb +1 -1
  112. data/spec/helpers/blacklight_helper_spec.rb +170 -285
  113. data/spec/helpers/catalog_helper_spec.rb +57 -96
  114. data/spec/helpers/facets_helper_spec.rb +130 -152
  115. data/spec/helpers/hash_as_hidden_fields_spec.rb +9 -15
  116. data/spec/helpers/render_constraints_helper_spec.rb +5 -5
  117. data/spec/helpers/search_history_constraints_helper_spec.rb +21 -21
  118. data/spec/lib/blacklight/routes_spec.rb +25 -0
  119. data/spec/lib/blacklight/solr/request_spec.rb +37 -0
  120. data/spec/lib/blacklight/solr_response/group_response_spec.rb +2 -2
  121. data/spec/lib/blacklight_configurable_spec.rb +16 -16
  122. data/spec/lib/blacklight_configuration_spec.rb +132 -132
  123. data/spec/lib/blacklight_email_spec.rb +4 -4
  124. data/spec/lib/blacklight_sms_spec.rb +4 -4
  125. data/spec/lib/blacklight_solr_document_dublin_core_spec.rb +6 -6
  126. data/spec/lib/blacklight_solr_document_more_like_this_spec.rb +4 -4
  127. data/spec/lib/blacklight_solr_document_spec.rb +36 -36
  128. data/spec/lib/blacklight_solr_response_spec.rb +43 -48
  129. data/spec/lib/blacklight_spec.rb +6 -14
  130. data/spec/lib/blacklight_user_spec.rb +5 -9
  131. data/spec/lib/facet_paginator_spec.rb +59 -51
  132. data/spec/lib/search_fields_spec.rb +13 -13
  133. data/spec/lib/solr_helper_spec.rb +258 -304
  134. data/spec/lib/tasks/blacklight_task_spec.rb +1 -1
  135. data/spec/lib/utils_spec.rb +16 -46
  136. data/spec/models/bookmark_spec.rb +6 -7
  137. data/spec/models/record_mailer_spec.rb +16 -16
  138. data/spec/models/search_spec.rb +8 -8
  139. data/spec/models/solr_document_spec.rb +6 -77
  140. data/spec/routing/catalog_routing_spec.rb +16 -10
  141. data/spec/spec_helper.rb +7 -7
  142. data/spec/support/assert_difference.rb +2 -2
  143. data/spec/support/features.rb +0 -11
  144. data/spec/support/features/session_helpers.rb +3 -3
  145. data/spec/support/include_text.rb +2 -2
  146. data/spec/test_app_templates/Gemfile.extra +10 -2
  147. data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -18
  148. data/spec/views/catalog/_constraints_element.html.erb_spec.rb +13 -13
  149. data/spec/views/catalog/_document.html.erb_spec.rb +1 -1
  150. data/spec/views/catalog/_document_list.html.erb_spec.rb +1 -1
  151. data/spec/views/catalog/_facets.html.erb_spec.rb +13 -14
  152. data/spec/views/catalog/_index_default.erb_spec.rb +21 -21
  153. data/spec/views/catalog/_search_header.erb_spec.rb +1 -1
  154. data/spec/views/catalog/_show_default.erb_spec.rb +21 -21
  155. data/spec/views/catalog/_show_sidebar.erb_spec.rb +7 -7
  156. data/spec/views/catalog/_thumbnail_default.erb_spec.rb +3 -3
  157. data/spec/views/catalog/index.atom.builder_spec.rb +29 -29
  158. data/spec/views/catalog/index.html.erb_spec.rb +6 -7
  159. data/tasks/blacklight.rake +8 -2
  160. metadata +84 -180
  161. data/app/assets/javascripts/blacklight/css_dropdowns.js +0 -10
  162. data/app/assets/javascripts/blacklight/facet_expand_contract.js +0 -41
  163. data/app/assets/javascripts/blacklight/lightbox_dialog.js +0 -70
  164. data/app/assets/javascripts/blacklight/select_submit.js +0 -27
  165. data/app/assets/javascripts/blacklight/zebra_stripe.js +0 -13
  166. data/app/assets/javascripts/improved-modal/bootstrap-modal.js +0 -355
  167. data/app/assets/javascripts/improved-modal/bootstrap-modalmanager.js +0 -370
  168. data/app/assets/stylesheets/blacklight/_bookmark.scss +0 -33
  169. data/app/assets/stylesheets/blacklight/_catalog.scss +0 -255
  170. data/app/assets/stylesheets/blacklight/_dropdown.scss +0 -57
  171. data/app/assets/stylesheets/blacklight/_facets.scss +0 -197
  172. data/app/assets/stylesheets/blacklight/_footer.scss +0 -0
  173. data/app/assets/stylesheets/blacklight/_header.scss +0 -53
  174. data/app/assets/stylesheets/blacklight/_layout.scss +0 -10
  175. data/app/assets/stylesheets/blacklight/_mixins.scss +0 -0
  176. data/app/assets/stylesheets/blacklight/_print.scss +0 -0
  177. data/app/assets/stylesheets/blacklight/_responsive.scss +0 -3
  178. data/app/assets/stylesheets/blacklight/_search_history.scss +0 -42
  179. data/app/assets/stylesheets/blacklight/blacklight_defaults.scss +0 -49
  180. data/app/assets/stylesheets/blacklight/responsive_partials/_catalog.scss +0 -5
  181. data/app/assets/stylesheets/blacklight/responsive_partials/_facets.scss +0 -37
  182. data/app/assets/stylesheets/blacklight/responsive_partials/_header.scss +0 -30
  183. data/app/assets/stylesheets/improved-modal/bootstrap-modal.css +0 -217
  184. data/app/helpers/blacklight/html_head_helper_behavior.rb +0 -118
  185. data/app/helpers/html_head_helper.rb +0 -3
  186. data/app/views/catalog/_bookmark_form.html.erb +0 -7
  187. data/app/views/catalog/_marc_view.html.erb +0 -32
  188. data/app/views/catalog/librarian_view.html.erb +0 -10
  189. data/config/routes.rb +0 -17
  190. data/doc/Atom-Responses.md +0 -90
  191. data/doc/Blacklight-3.0-Release-Notes-And-Upgrade-Guide.md +0 -107
  192. data/doc/Blacklight-3.2-Release-Notes-and-Upgrade-Guide.md +0 -191
  193. data/doc/Blacklight-3.3-release-notes-and-upgrade-guide.md +0 -37
  194. data/doc/Blacklight-3.4-release-notes-and-upgrade-guide.md +0 -27
  195. data/doc/Blacklight-3.5-release-notes-and-upgrade-guide.md +0 -44
  196. data/doc/Blacklight-3.6-release-notes-and-upgrade-guide.md +0 -25
  197. data/doc/Blacklight-3.7-release-notes-and-upgrade-guide.md +0 -80
  198. data/doc/Blacklight-3.8-release-notes-and-upgrade-guide.md +0 -11
  199. data/doc/Blacklight-4.0-release-notes-and-upgrade-guide.md +0 -135
  200. data/doc/Blacklight-4.1-release-notes-and-upgrade-guide.md +0 -17
  201. data/doc/Blacklight-4.2-release-notes-and-upgrade-guide.md +0 -25
  202. data/doc/Blacklight-4.3-release-notes-and-upgrade-guide.md +0 -21
  203. data/doc/Blacklight-4.4-release-notes-and-upgrade-guide.md +0 -41
  204. data/doc/Blacklight-Add-ons.md +0 -28
  205. data/doc/Blacklight-configuration.md +0 -411
  206. data/doc/Blacklight-on-Heroku.md +0 -135
  207. data/doc/Code4Lib-2014.md +0 -48
  208. data/doc/Community-principles.md +0 -44
  209. data/doc/Configuring-and-Customizing-Blacklight.md +0 -271
  210. data/doc/Configuring-rails-routes.md +0 -13
  211. data/doc/Contributing-to-Blacklight.md +0 -25
  212. data/doc/Examples.md +0 -94
  213. data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -141
  214. data/doc/FAQs.md +0 -1
  215. data/doc/Home.md +0 -80
  216. data/doc/How-to-release-a-version.md +0 -29
  217. data/doc/Indexing-your-data-into-solr.md +0 -32
  218. data/doc/Integration-with-Rails-Footnotes.md +0 -20
  219. data/doc/Internationalization.md +0 -32
  220. data/doc/JSON-API.md +0 -17
  221. data/doc/Pagination.md +0 -51
  222. data/doc/Providing-your-own-view-templates.md +0 -109
  223. data/doc/Quickstart.md +0 -115
  224. data/doc/README_SOLR.md +0 -245
  225. data/doc/Release-Notes-And-Upgrade-Guides.md +0 -20
  226. data/doc/Roadmap.md +0 -43
  227. data/doc/Sunspot-for-indexing.md +0 -46
  228. data/doc/Theming.md +0 -64
  229. data/doc/User-Authentication.md +0 -60
  230. data/doc/testing.md +0 -57
  231. data/lib/SolrMarc.jar +0 -0
  232. data/lib/blacklight/mash.rb +0 -19
  233. data/lib/blacklight/solr/document/marc.rb +0 -71
  234. data/lib/blacklight/solr/document/marc_export.rb +0 -590
  235. data/lib/generators/blacklight/marc_generator.rb +0 -66
  236. data/lib/generators/blacklight/templates/blacklight.scss +0 -4
  237. data/lib/generators/blacklight/templates/config/SolrMarc/config-test.properties +0 -37
  238. data/lib/generators/blacklight/templates/config/SolrMarc/config.properties +0 -37
  239. data/lib/generators/blacklight/templates/config/SolrMarc/index.properties +0 -97
  240. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/dewey.bsh +0 -47
  241. data/lib/generators/blacklight/templates/config/SolrMarc/index_scripts/format.bsh +0 -126
  242. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/README_MAPS +0 -1
  243. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/callnumber_map.properties +0 -407
  244. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/composition_era_map.properties +0 -56
  245. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/country_map.properties +0 -379
  246. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/format_map.properties +0 -50
  247. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/instrument_map.properties +0 -101
  248. data/lib/generators/blacklight/templates/config/SolrMarc/translation_maps/language_map.properties +0 -490
  249. data/lib/railties/solr_marc.rake +0 -162
  250. data/spec/data/test_data.utf8.mrc +0 -1
  251. data/spec/features/librarian_view_spec.rb +0 -13
  252. data/spec/helpers/html_head_helper_spec.rb +0 -164
  253. data/spec/lib/blacklight_solr_document_marc_spec.rb +0 -89
  254. data/spec/lib/marc_export_spec.rb +0 -746
  255. data/spec/lib/tasks/solr_marc_task_spec.rb +0 -60
  256. data/spec/requests/alternate_controller_spec.rb +0 -16
  257. data/spec/routing/routes_spec.rb +0 -20
  258. data/spec/views/catalog/_constraints.html.erb_spec.rb +0 -33
  259. data/spec/views/catalog/_paginate_compact.html.erb_spec.rb +0 -49
  260. data/test_support/data/test_data.utf8.mrc +0 -1
@@ -1,17 +0,0 @@
1
- Feature added in v4.5
2
-
3
- By default the search page, the show page, and the facet list page can return JSON responses provided you set the format suffix:
4
-
5
- Search results
6
- `/catalog.json?search_field=all_fields&q=auckland`
7
-
8
- Facet list
9
- `/catalog/facet/subject_topic_facet.json`
10
-
11
- Single record
12
- `/catalog/2009002600.json`
13
-
14
-
15
- If you wish to alter the format of the returned JSON, you can override `render_search_results_as_json` and `render_facet_list_as_json` methods in CatalogController.
16
-
17
- See: https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/catalog.rb#L175-L191
@@ -1,51 +0,0 @@
1
- Blacklight uses [kaminari](https://github.com/amatsuda/kaminari) for providing pagination of Solr responses.
2
-
3
- One motivation for this is so a pagination view theme can be provided that you can use for your custom code with ordinary ActiveRecord or anything else kaminari can handle, to have consistency between the rest of your app's pagination and Blacklight's Solr response pagination.
4
-
5
- ## How it works
6
-
7
- The Blacklight #paginate_params helper method takes an RSolr::Response, and converts it to something Kaminari #paginate can handle. (Basically just by translating some attribute names). So you could call:
8
-
9
- paginate( paginate_params(@response) ) # where @response is an RSolr::Response
10
-
11
- But there's a shortcut Blacklight helper method which compacts this, #paginate_rsolr_response:
12
-
13
- paginate_rsolr_response @response, :theme => 'blacklight'
14
-
15
- The `theme => 'blacklight'` part will be passed through kaminari, and tell kaminari to use the theme that the Blacklight plugin supplies at [app/views/kaminari/blacklight](https://github.com/projectblacklight/blacklight/tree/master/app/views/kaminari/blacklight)
16
-
17
- Any other arguments of ordinary kaminari paginate can also be passed in there. If all client code uses #paginate_solr_response, it also provides a 'hook' for local apps to completely over-ride pagination rendering, perhaps not even using kaminari.
18
-
19
- Additionally, we sometimes want to output a "Showing X through Y of N" message, which kaminari doesnt' have a way to do by default, so we just provide our own way in a Blacklight view helper method, which takes a RSolr::Response too:
20
-
21
- render_pagination_info(@response)
22
-
23
- ## Changing the kaminari theme
24
-
25
- If you want to change how pagination links are rendered, the easiest/cleanest thing to do is to over-ride the 'blacklight' theme that the Blacklight plugin defines. Copy the view templates in Blacklight source at app/views/kaminari/blacklight to your own local app/views/kaminari/blacklight. You actually only need to copy files you'll want to modify, templates not overridden with a local copy will still be found by kaminari from the Blacklight gem. You can use any techniques available for creating a kaminari theme when editing these files, including over-riding more kaminari view templates if available. See the kaminari documentation.
26
-
27
- There are other ways you could change how Blacklight pagination renders, but by doing it this way, any code (in core Blacklight or additional plugins you install) that tries to render pagination using kaminari with 'blacklight' theme will get your locally defined theme.
28
-
29
- The "pagination info" (showing X through Y of N) is not part of the kaminari theme, but just a blacklight view helper method, #render_pagination_info. To change this, just over-ride this method [[over-ride locally|CUSTOMIZING]] like any other Blacklight view helper method.
30
-
31
- ## Using kaminari theme for your own pagination
32
-
33
- Your local app may show pagination of ActiveRecord objects, that you'd like to appear consistent with other Blacklight pagination. Just use kaminari to show the pagination HTML, with the theme :blacklight. This technique can be used for anything kaminari can paginate, such as Mongoid et al, in addition to ActiveRecord. Fetch the ActiveRecords using ordinary kaminari techniques (see kaminari docs) and then:
34
-
35
- paginate @my_active_records, :theme => 'blacklight'
36
-
37
- That's it. There's currently no great way to display the #render_pagination_info for anything but RSolr::Response.
38
-
39
- ## Changing the default kaminari pagination options
40
-
41
- Sometimes you you just want to tweak a few things with pagination and it doesn't require crawling into the RSolr response or creating a kaminari theme. Here's how you do that.
42
-
43
- First, generate the kaminari config initializer:
44
-
45
- rails g kaminari:config
46
-
47
- You will get a file in config/initializers/kaminari_config.rb that is mostly commented out. The config options are mostly self-explanatory, but let's say that you don't like that Blacklight gives you 4 pages of links on either side of the current page. Uncomment:
48
-
49
- # config.window = 4
50
-
51
- and change 4 to whatever number is preferable. More information on the kaminari general configuration options is available here: https://github.com/amatsuda/kaminari#general-configuration-options
@@ -1,109 +0,0 @@
1
- > TODO: Validate this page for Blacklight 4.x!
2
-
3
- # Customizing the User Interface
4
- ## Layouts
5
-
6
- The built-in Blacklight controllers all by default use a Rails view layout called "blacklight", that lives in the Blacklight source. This ends up being a bit confusing, but is the best way we have at present to have out of the box default using a layout with full functionality, without stepping on a possibly existing local 'application' layout.
7
-
8
- To change what layout the Blacklight controllers use, simply implement a method #layout_name in your local application_controller.rb that returns the name of the layout you'd like them to use.
9
-
10
- ```ruby
11
- # [from app/controllers/application_controller.rb]
12
- class ApplicationController < ActionController::Base
13
- ...
14
- def layout_name
15
- "application"
16
- end
17
- ...
18
- end
19
- ```
20
-
21
- When implementing your own layout instead of using the stock one, you may want to look at the Blacklight app/views/layouts/blacklight.html.erb file to see what helper methods are called there, to maintain full Blacklight functionality you may want to call these same helper methods.
22
-
23
- * `render_head_content` renders content within the
24
- html `<head>` tag, which includes document-specific alternative
25
- formats as well as tags generated by plugins, etc.
26
- * `sidebar_items` renders features including sidebar content, e.g. facet
27
- lists.
28
- * flash messages
29
- * user util links
30
-
31
- ## Overriding Views (templates and partials)
32
- As a Rails Engine, you can easily override views in your app. You can see what views and partials are provided by looking in `[[./app/views|https://github.com/projectblacklight/blacklight/tree/master/app/views]]` inside the Blacklight source.
33
-
34
- Once you find the view you'd like to change, you should create a file with the same name and relative path in your own application (e.g. if you wanted to override [[./app/views/catalog/_show_partials/_default.html.erb|https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_show_partials/_default.html.erb]] you would create ./app/views/catalog/_show_partials/_default.html.erb in your local application. Frequently, you will start by copying the existing Blacklight view and modifying it from there.
35
-
36
- It is generally recommended that you override as little as possible, in order to maximize your forward compatibility. Look to override either a small, focused partial template, or a helper method of partial template called from a larger template, so your application's version can call out to those same helpers or partial templates within blacklight core code.
37
-
38
- ## Overriding the CatalogController
39
- Overriding the Blacklight `CatalogController` implementation is easy, and the skeleton of the `CatalogController` is generated into your application for you when you install Blacklight.
40
-
41
- See the [[Extending or Modifying Blacklight Search Behavior]] for tips and approaches to customizing the catalog.
42
-
43
- ## Overriding Other Controllers
44
-
45
- 1. Find the controller you're interested in blacklight's app/controllers/ .
46
- 2. Create a file with the same name in your local app/controllers.
47
- 3. This file requires the original class, and then re-opens it to add more methods.
48
-
49
- ```ruby
50
- require "#{Blacklight.controllers_dir}/some_controller"
51
-
52
- class SomeController < ApplicationController
53
- # custom code goes here
54
- end
55
- ```
56
-
57
- In that "custom code goes here", you can redefine certain methods (action methods or otherwise) to do something different. You can also add new methods (again action methods or otherwise), etc.
58
-
59
- It's kind of hard to call 'super' to call original functionality:
60
-
61
- * the ruby language features here make 'super' unavailable, although you can work around that confusingly with the rails #alias_method_chain method.
62
- * but more importantly, action methods in particular don't really suit themselves to being over-ridden and called by super, because the original implementation often does something you'd want to change but there's no easy way to 'undo' -- calling 'render', which can only be called once.
63
-
64
- So basically, if you find yourself wanting to access some functionaltiy in the original implementation of a method that you also want to over-ride -- the best solution is probably to refactor Blacklight core code to put that functionality in a subsidiary method, so you can over-ride the action method entirely but call that logic from core. Action methods should be short and sweet anyway.
65
-
66
-
67
- ## Custom View Helpers
68
-
69
- (This is accurate for Blacklight 3.1.1 and subsequent. Before that, things were messier).
70
-
71
- One of the most common things you might need to do is create a view helper -- especially to override some Blacklight behavior implemented in it's own view helpers. The first step is looking at Blacklight source to determine what view helper method you want to override.
72
-
73
- Blacklight comes packaged with several view helper modules. There is a BlacklightHelper in (blacklight source) app/helpers/blacklight_helper.rb , and several others that correspond to specific controller. (Note, depending on version of Rails and configuration, all helpers may get loaded for every request, even ones that are named to correspond only to a particular other controller).
74
-
75
- If you simply created a local helper with the same name as a helper in Blacklight, that will end up preventing the Blacklight helper from being loaded at all though, which is not what you want to do to override.
76
-
77
- We've structured each Blacklight view helper module into two parts to make it easy to selectively over-ride methods. For instance, here's Blacklight's app/helpers/blacklight_helper.rb:
78
-
79
- ```ruby
80
- module BlacklightHelper
81
- include Blacklight::BlacklightHelperBehavior
82
- end
83
- ```
84
-
85
- Now, the actual methods will be found in app/helpers/blacklight/blacklight_helper_behavior.rb instead.
86
-
87
- If you want to over-ride a helper method, copy the wrapper blacklight_helper into your local app, with the 'include' line, and now you can individually over-ride methods from BlacklightHelperBehavior, and the other methods you don't over-ride will still have their default implementation.
88
-
89
- YOUR `app/helpers/blacklight_helper.rb`
90
-
91
- ```ruby
92
- module BlacklightHelper
93
- include Blacklight::BlacklightHelperBehavior
94
-
95
- def application_name
96
- "Bestest University Search"
97
- end
98
- end
99
- ```
100
-
101
- One helper you might want to over-ride for customization is #render_document_partial (currently defined in [[blacklight_helper|https://github.com/projectblacklight/blacklight/blob/master/app/helpers/blacklight_helper.rb]]), which you can over-ride to choose differnet local partial views to display a document on search results or detail page, possibly varying depending on type of document according to your own local logic.
102
-
103
- ## Adding in your own CSS or Javascript
104
-
105
- Within your local application, you can use the [[Rails Asset Pipeline|http://guides.rubyonrails.org/asset_pipeline.html]] to manipulate javascript and css documents.
106
-
107
- **todo??** better instructions for over-riding BL's built in CSS using SASS? (jrochkind thought jamesws wrote such already, but can't find them now)
108
-
109
- The Blacklight generator added a file to your app at `./app/assets/stylesheets/blacklight_themes/standard.css.scss`, elements of the BL default theme can be customized or over-ridden there. If there's something you want to do but aren't sur e the best way, feel free to ask on the listserv.
@@ -1,115 +0,0 @@
1
- Blacklight is a Ruby on Rails Engine plugin, meaning it provides a small application that runs inside an existing Ruby on Rails project. For notes on upgrading Blacklight, check out our [[Release Notes And Upgrade Guides]] index.
2
-
3
- This Quickstart will walk you through installing Blacklight and Solr, and indexing a sample set of records. If you want information about configuring Blacklight to use an existing Solr index with your data in it, see the [[Blacklight configuration]] document.
4
-
5
- ## Pre-requisites
6
- * Ruby 1.9 or higher (consider using [[RVM|https://rvm.beginrescueend.com/rvm/install/]] or [[RBEnv|http://rbenv.org/]] to manage your Ruby version).
7
- * Java 1.5 or higher (in order to run solr under a java servlet container)
8
- * **For Windows users**: You may want to use [RailsInstaller](http://railsinstaller.org/) to get a Ruby on Rails environment.
9
-
10
- > NOTE: We run our continuous integration tests against Ruby 1.9.3, Ruby 2.0 and JRuby (running in 1.9 mode) using the latest release of Rails on a Redhat Linux machine. While Blacklight may work with older versions of Ruby, we can't commit ourselves to supporting them.
11
-
12
- In addition, you should have the Bundler and Rails ruby gems installed:
13
-
14
- ```bash
15
- $ gem install bundler
16
- $ gem install rails
17
- ```
18
-
19
- ## Install and Use
20
-
21
- 1. Create a new rails 3 application
22
-
23
- ```bash
24
- $ rails new my_app
25
- # create
26
- # create README
27
- # create Rakefile
28
- # create config.ru
29
- # create .gitignore
30
- # create Gemfile
31
- # [...]
32
-
33
- $ cd my_app
34
- ```
35
-
36
- Rails automatically created an `public/index.html` file. However, Blacklight will provide a default `root` route for your application, so you probably want to remove it:
37
-
38
- ```bash
39
- $ rm public/index.html
40
- ```
41
-
42
- 2. Append this line to your application's `Gemfile`
43
-
44
- ```ruby
45
- gem 'blacklight'
46
- ```
47
-
48
- Especially if you are running on Linux, you may have to add `gem 'therubyracer'` to your gemfile, to get a Javascript runtime needed by the asset pipeline.
49
-
50
- then, update the bundle
51
-
52
- ```bash
53
- $ bundle install
54
- ```
55
-
56
- 3. Install blacklight using Devise for user authentication:
57
-
58
- ```bash
59
- $ rails generate blacklight --devise
60
- ```
61
- If you would prefer to integrate with an alternative user authentication provider, see the [[User Authentication]] documentation. You can also install with no support for logged in users simply by omitting the devise install, and generating blacklight with `rails generate blacklight` (no --devise argument).
62
-
63
- 4. Run your database migrations to create Blacklight's database tables:
64
-
65
- ```bash
66
- $ rake db:migrate
67
- ```
68
-
69
- 5. You will need to install and configure Solr. You can install
70
- Blacklight's example Solr configuration (using the jetty servlet container) that is configured to work with
71
- the Blacklight defaults:
72
-
73
- ```bash
74
- $ rails generate blacklight:jetty
75
- ```
76
-
77
- **For Windows Users: ** This step will only work on *nix platforms. You can manually download and extract a tagged version of [blacklight-jetty](https://github.com/projectblacklight/blacklight-jetty/tags). After extracting the file, you need to update the `config/jetty.yml` file to add the `jetty_home` key to your test environment, e.g.:
78
-
79
- ```yaml
80
- test:
81
- jetty_port: <%= ENV['TEST_JETTY_PORT'] || 8888 %>
82
- jetty_home: <%= ENV['TEST_JETTY_PATH'] || File.join(Rails.root, 'test_jetty') %>
83
- startup_wait: 15
84
- ```
85
-
86
-
87
- 6. Make sure your Solr server is running. If you installed the Blacklight demo Solr/Jetty package, you can start the Jetty/Solr server using:
88
-
89
- ```bash
90
- $ cd jetty; java -jar start.jar &
91
- ```
92
-
93
- 6. Index some data. You can index test MARC records provided Blacklight running:
94
-
95
- ```bash
96
- $ rake solr:marc:index_test_data
97
- ```
98
-
99
- 7. Start up your application
100
-
101
- ```bash
102
- $ rails server
103
- ```
104
-
105
- Visit the catalog at [[http://localhost:3000/catalog]].
106
-
107
- [[https://github.com/projectblacklight/projectblacklight.github.com/raw/master/images/home.png|frame|alt=Blacklight home page]]
108
-
109
- You should see the Blacklight interface with 30 MARC records for testing. Additional MARC records are available from the [[blacklight-data|https://github.com/projectblacklight/blacklight-data]] repository. These can be ingested into Solr using SolrMarc,
110
-
111
- ```bash
112
- $ rake solr:marc:index MARC_FILE=(path to file)
113
- ```
114
-
115
- See [[Configuring and Customizing Blacklight]] for information about how to customize the Blacklight user interface, search experience, and more.
@@ -1,245 +0,0 @@
1
- #Solr in Blacklight
2
-
3
- ##Setting up Solr
4
-
5
- Blacklight uses Solr as its "search engine".
6
- More information about Solr is available at the Solr web site ( http://lucene.apache.org/solr/)
7
-
8
- There are three sections to this document:
9
- * Getting Solr
10
- * Configuring Solr
11
- * schema.xml
12
- * solrconfig.xml
13
- * SolrMARC
14
-
15
- ### Getting Solr
16
- Blacklight distributes a pre-configured version of Solr (with the Jetty
17
- container) as [[blacklight-jetty|https://github.com/projectblacklight/blacklight-jetty/tags]].
18
-
19
- You can also use an existing Solr index (with some minor modifications).
20
- If you want to start from a new version of Solr, follow the directions from the [[Solr tutorial|http://lucene.apache.org/solr/tutorial.html]]
21
-
22
- You should now have a usable copy of Solr.
23
-
24
- ### Configuring Solr
25
- ####Solr Schema.xml
26
-
27
- Between the `schema.xml` and `solrconfig.xml` you can change and tune the search behavior following directions from the [[Solr wiki|http://wiki.apache.org/solr/]]. Solr comes with example schema and solrconfig files, which you can use as a starting point for configuring your local Solr application.
28
-
29
- Blacklight expects a uniqueKey field within your Solr index,
30
- traditionally called `id`. The name of the unique key field can be
31
- configured in your application's `SolrDocument`.
32
-
33
- ##### Blacklight community "best practices"
34
-
35
- Solr uses a schema.xml file to define document fields (among other things). These fields store data for searching and for result display. You can find the example/solr/conf/schema.xml file in the Solr distribution you just downloaded and uncompressed.
36
-
37
- Documentation about the Solr schema.xml file is available at (http://wiki.apache.org/solr/SchemaXml).
38
-
39
- The default schema.xml file comes with some preset fields made to work with
40
- the example data. If you don't already have a schema.xml setup, we
41
- recommend using a simplified "fields" section like this:
42
- ```xml
43
- <fields>
44
- <field name="id" type="string" indexed="true" stored="true" required="true" />
45
- <field name="text" type="text" indexed="true" stored="false" multiValued="true"/>
46
- <field name="timestamp" type="date" indexed="true" stored="true" default="NOW" multiValued="false"/>
47
- <field name="spell" type="textSpell" indexed="true" stored="true" multiValued="true"/>
48
- <dynamicField name="*_i" type="sint" indexed="true" stored="true"/>
49
- <dynamicField name="*_s" type="string" indexed="true" stored="true" multiValued="true"/>
50
- <dynamicField name="*_l" type="slong" indexed="true" stored="true"/>
51
- <dynamicField name="*_t" type="text" indexed="true" stored="true" multiValued="true"/>
52
- <dynamicField name="*_b" type="boolean" indexed="true" stored="true"/>
53
- <dynamicField name="*_f" type="sfloat" indexed="true" stored="true"/>
54
- <dynamicField name="*_d" type="sdouble" indexed="true" stored="true"/>
55
- <dynamicField name="*_dt" type="date" indexed="true" stored="true"/>
56
- <dynamicField name="random*" type="random" />
57
- <dynamicField name="*_facet" type="string" indexed="true" stored="true" multiValued="true" />
58
- <dynamicField name="*_display" type="string" indexed="false" stored="true" />
59
- </fields>
60
- ```
61
-
62
- Additionally, replace all of the tags after the "fields" section, and before
63
- the `</schema>` tag with this:
64
-
65
- ```xml
66
- <uniqueKey>id</uniqueKey>
67
- <defaultSearchField>text</defaultSearchField>
68
- <solrQueryParser defaultOperator="OR"/>
69
- <copyField source="*_facet" dest="text"/>
70
- ```
71
-
72
- Now you have a basic schema.xml file ready. Other fields can be specified, including a primary document title (`title_display`) and format (`format`), but these are easily configured in your application's `CatalogController`.
73
-
74
- Fields that are "indexed" are searchable.
75
-
76
- Fields that are "stored" are can be viewed/displayed from the Solr search
77
- results.
78
-
79
- The fields with asterisks ('*') in their names are "dynamic" fields. These
80
- allow you to create arbitrary tags at index time.
81
-
82
- The *_facet field can be used for creating your facets. When you index,
83
- simply define a field with _facet on the end:
84
- category_facet
85
-
86
- The *_display field can be used for storing text that doesn't need to be
87
- indexed. An example would be the raw MARC for a record's detail view:
88
- raw_marc_display
89
-
90
- For text that will be queried (and possibly displayed), use the *_t type
91
- field for tokenized text (text broken into pieces/words) or the *_s type
92
- for queries that should exactly match the field contents:
93
- description_t
94
- url_s
95
-
96
- The Blacklight application is generic enough to work with any Solr schema, but to
97
- manipulate the search results and single record displays, you'll need to know the
98
- stored fields in your indexed documents.
99
-
100
- For more information, refer to the Solr documentation:
101
- http://wiki.apache.org/solr/SchemaXml
102
-
103
-
104
- #####solrconfig.xml
105
-
106
- Solr uses the solrconfig.xml file to define searching configurations, set cache options, etc.
107
- You can find the examples/solr/conf/solrconfig.xml in the distribution directory you just uncompressed.
108
-
109
- Documentation about the solrconfig.xml file is available at (http://wiki.apache.org/solr/SolrConfigXml).
110
-
111
- Blacklight expects two request handlers to be defined -- one to handle
112
- general search requests and one to handle single-document lookup. The
113
- names of these request handlers are configurable, but are called
114
- "search" and "document" respectively, out of the box.
115
-
116
-
117
- #####Solr Search Request Handlers
118
-
119
- When Blacklight does a collection search, it sends a request to a Solr
120
- request handler named "search". The most important settings in this handler
121
- definition are the "fl" param (field list) and the facet params.
122
-
123
- The "fl" param specifies which fields are returned in a Solr response.
124
- The facet related params set up the faceting mechanism.
125
-
126
- Find out more about the basic params:
127
- http://wiki.apache.org/solr/DisMaxRequestHandler
128
-
129
- Find out more about the faceting params:
130
- http://wiki.apache.org/solr/SimpleFacetParameters
131
-
132
-
133
- ######How the "fl" param works in Blacklight's request handlers
134
-
135
- Blacklight comes with a set of "default" views for rendering each document
136
- in a search results page. This view simply loops through all of the fields
137
- returned in each document in the Solr response. The "fl" (field list) param
138
- tells Solr which fields to include in the documents in the response ...
139
- and these are the fields rendered in the Blacklight default views.
140
- Thus, the fields you want rendered must be specified in "fl". Note that
141
- only "stored" fields will be available; if you want a field to be rendered
142
- in the result, it must be "stored" per the field definition in schema.xml.
143
-
144
- The "fl" parameter definition in the "search" handler looks like this:
145
- ```xml
146
- <str name="fl">id,score,author_display,(....lots of other fields)</str>
147
- ```
148
- You may also use an asterisk plus "score":
149
- ```xml
150
- <str name="fl">*,score</str>
151
- ```
152
-
153
- ######How the facet params work in Blacklight's request handlers
154
-
155
- In the search results view, Blacklight will look into the Solr response for
156
- facets. If you specify any facet.field params in your "search" handler,
157
- they will automatically get displayed in the facets list:
158
- ```xml
159
- <str name="facet.field">format</str>
160
- <str name="facet.field">language_facet</str>
161
- ```
162
-
163
-
164
- #####Blacklight's "search" request handler: for search results
165
-
166
- When Blacklight displays a list of search results, it uses a Solr request
167
- handler named "search." Thus, the field list (fl param) for the "search"
168
- request handler should be tailored to what will be displayed in a search
169
- results page. Generally, this will not include fields containing a large
170
- quantity of text. The facet param should contain the facets to be
171
- displayed with the search results.
172
- ```xml
173
-
174
- <requestHandler name="search" class="solr.SearchHandler" >
175
- <lst name="defaults">
176
- <str name="defType">dismax</str>
177
- <str name="echoParams">explicit</str>
178
- <!-- list fields to be returned in the "fl" param -->
179
- <str name="fl">*,score</str>
180
-
181
- <str name="facet">on</str>
182
- <str name="facet.mincount">1</str>
183
- <str name="facet.limit">10</str>
184
-
185
- <!-- list fields to be displayed as facets here. -->
186
- <str name="facet.field">format</str>
187
- <str name="facet.field">language_facet</str>
188
-
189
- <str name="q.alt">*:*</str>
190
- </lst>
191
- </requestHandler>
192
- ```
193
-
194
- #####Blacklight's "document" request handler: for a single record
195
-
196
- When Blacklight displays a single record it uses a Solr request handler
197
- named "document". The "document" handler doesn't necessarily need to be
198
- different than the "search" handler, but it can be used to control which
199
- fields are available to display a single document. In the example below,
200
- there is no faceting set (facets are not displayed with a single record)
201
- and the "rows" param is set to 1 (since there will only be a single record).
202
- Also, the field list ("fl" param) could include fields containing large
203
- text values if they are desired for record display. Is is acceptable to
204
- include large amounts of data, because this handler should only be used
205
- to query for one document:
206
-
207
- <requestHandler name="document" class="solr.SearchHandler">
208
- <lst name="defaults">
209
- <str name="echoParams">explicit</str>
210
- <str name="fl">*</str>
211
- <str name="rows">1</str>
212
- <str name="q">{!raw f=id v=$id}</str>
213
- <!-- use id=blah instead of q=id:blah -->
214
- </lst>
215
- </requestHandler>
216
-
217
- A Solr query for a single record might look like this:
218
- http://(yourSolrBaseUrl)/solr/select?id=my_doc_id&qt=document
219
-
220
-
221
- ####Blacklight Solr Schema and Solrconfig File Templates
222
-
223
- Blacklight provides schema.xml and solrconfig.xml files as starting points:
224
-
225
- https://github.com/projectblacklight/blacklight-jetty/blob/master/solr/blacklight-core/conf/schema.xml
226
-
227
- https://github.com/projectblacklight/blacklight-jetty/blob/master/solr/blacklight-core/conf/solrconfig.xml
228
-
229
- #SolrMARC: from Marc data to Solr documents
230
-
231
- The SolrMARC project is designed to create a Solr index from raw MARC data.
232
- It can be configured easily and used with the basic parsing and indexing
233
- supplied. It is also readily customized for a site's unique requirements.
234
-
235
- The project software and documentation is available at [[http://code.google.com/p/solrmarc]]
236
-
237
- Blacklight comes with an embedded SolrMarc, with some default config that matches the default Blacklight setup, and provides some rake tasks to easily index docs with SolrMarc according to your app's environment. There is no need to manually install/configure SolrMarc yourself. From your application's home directory simply run:
238
- ```bash
239
- rake solr:marc:index:info
240
- ```
241
- to see options. Run `rake solr:marc:index` to actually do indexing. Like all rake tasks, by default this will use your 'development' environment; add "RAILS_ENV=production" to instead index to the solr you've labelled production in your config/solr.yml file.
242
-
243
- The solrmarc config files are in your app's config/SolrMarc directory, you can edit them there for local config.
244
-
245
- If you'd like to use a different or more recent version of SolrMarc.jar, you can put it in your app at ./solr_marc/SolrMarc.jar, and the built-in rake tasks will use your local SolrMarc.jar instead of the one bundled with Blacklight.