atrium 0.0.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. data/.gitignore +13 -0
  2. data/.gitmodules +3 -0
  3. data/.rvmrc +32 -0
  4. data/GETTING_STARTED.textile +109 -0
  5. data/Gemfile +4 -0
  6. data/Gemfile.lock +320 -0
  7. data/Guardfile +10 -0
  8. data/README.mkd +56 -0
  9. data/Rakefile +6 -0
  10. data/app/assets/images/atrium/ajax-loader.gif +0 -0
  11. data/app/assets/images/atrium/lightbox-ico-loading.gif +0 -0
  12. data/app/assets/images/atrium/logo.png +0 -0
  13. data/app/assets/javascripts/atrium/atrium.js +281 -0
  14. data/app/assets/javascripts/chosen.jquery.js +899 -0
  15. data/app/assets/javascripts/ckeditor.warning.js +65 -0
  16. data/app/assets/javascripts/ckeditor/config.js.coffee +6 -0
  17. data/app/assets/javascripts/ckeditor/jquery.generateId.js +13 -0
  18. data/app/assets/javascripts/ckeditor/jquery.jeditable.ckeditor.js +59 -0
  19. data/app/assets/javascripts/ckeditor/plugins/linkItem/application_link.png +0 -0
  20. data/app/assets/javascripts/ckeditor/plugins/linkItem/dialogs/linkItem.js +1470 -0
  21. data/app/assets/javascripts/ckeditor/plugins/linkItem/plugin.js +16 -0
  22. data/app/assets/javascripts/ckeditor/plugins/linkItem/ui_toolbar_pencil.png +0 -0
  23. data/app/assets/javascripts/jquery.colorbox.js +864 -0
  24. data/app/assets/javascripts/jquery.jeditable.js +543 -0
  25. data/app/assets/stylesheets/atrium/atrium.css +216 -0
  26. data/app/assets/stylesheets/atrium/chosen-sprite.png +0 -0
  27. data/app/assets/stylesheets/atrium/chosen.css +367 -0
  28. data/app/assets/stylesheets/colorbox.css +42 -0
  29. data/app/assets/stylesheets/controls.png +0 -0
  30. data/app/assets/stylesheets/loading.gif +0 -0
  31. data/app/controllers/atrium/base_controller.rb +25 -0
  32. data/app/controllers/atrium/collection_exhibit_order_controller.rb +21 -0
  33. data/app/controllers/atrium/collections_controller.rb +165 -0
  34. data/app/controllers/atrium/customization_controller.rb +41 -0
  35. data/app/controllers/atrium/descriptions_controller.rb +177 -0
  36. data/app/controllers/atrium/exhibit_facet_order_controller.rb +19 -0
  37. data/app/controllers/atrium/exhibits_controller.rb +108 -0
  38. data/app/controllers/atrium/showcases_controller.rb +193 -0
  39. data/app/helpers/atrium/base_helper.rb +6 -0
  40. data/app/models/ability.rb +14 -0
  41. data/app/models/atrium/browse_level.rb +41 -0
  42. data/app/models/atrium/collection.rb +121 -0
  43. data/app/models/atrium/description.rb +128 -0
  44. data/app/models/atrium/essay.rb +21 -0
  45. data/app/models/atrium/exhibit.rb +58 -0
  46. data/app/models/atrium/search/facet.rb +29 -0
  47. data/app/models/atrium/search/facet_selection.rb +17 -0
  48. data/app/models/atrium/showcase.rb +173 -0
  49. data/app/models/atrium/showcase/facet_selection.rb +21 -0
  50. data/app/models/atrium/showcase/item.rb +19 -0
  51. data/app/models/role_mapper.rb +23 -0
  52. data/app/views/_user_util_links.html.erb +25 -0
  53. data/app/views/atrium/collections/_bookmark_control.html.erb +25 -0
  54. data/app/views/atrium/collections/_browse_index.html.erb +20 -0
  55. data/app/views/atrium/collections/_collection_items_index.html.erb +10 -0
  56. data/app/views/atrium/collections/_document.html.erb +24 -0
  57. data/app/views/atrium/collections/_document_list.html.erb +6 -0
  58. data/app/views/atrium/collections/_edit_navigation.html.erb +20 -0
  59. data/app/views/atrium/collections/_folder_control.html.erb +12 -0
  60. data/app/views/atrium/collections/_form.html.erb +93 -0
  61. data/app/views/atrium/collections/_listing.html.erb +18 -0
  62. data/app/views/atrium/collections/_navigation.html.erb +45 -0
  63. data/app/views/atrium/collections/_results_pagination.html.erb +9 -0
  64. data/app/views/atrium/collections/_sort_and_per_page.html.erb +23 -0
  65. data/app/views/atrium/collections/edit.html.erb +5 -0
  66. data/app/views/atrium/collections/new.html.erb +6 -0
  67. data/app/views/atrium/collections/show.html.erb +22 -0
  68. data/app/views/atrium/descriptions/_form.html.erb +64 -0
  69. data/app/views/atrium/descriptions/edit.html.erb +4 -0
  70. data/app/views/atrium/descriptions/index.html.erb +4 -0
  71. data/app/views/atrium/descriptions/new.html.erb +2 -0
  72. data/app/views/atrium/descriptions/show.html.erb +20 -0
  73. data/app/views/atrium/exhibits/_bookmark_control.html.erb +25 -0
  74. data/app/views/atrium/exhibits/_folder_control.html.erb +12 -0
  75. data/app/views/atrium/exhibits/_form.html.erb +108 -0
  76. data/app/views/atrium/exhibits/edit.html.erb +9 -0
  77. data/app/views/atrium/exhibits/new.html.erb +6 -0
  78. data/app/views/atrium/exhibits/show.html.erb +26 -0
  79. data/app/views/atrium/showcases/_showcase_navigation.html.erb +23 -0
  80. data/app/views/atrium/showcases/show.html.erb +1 -0
  81. data/app/views/catalog/_collection_home_text.html.erb +6 -0
  82. data/app/views/catalog/_constraints.html.erb +9 -0
  83. data/app/views/catalog/_default_collection_text.html.erb +18 -0
  84. data/app/views/catalog/_default_home_text.html.erb +6 -0
  85. data/app/views/catalog/_home_text.html.erb +6 -0
  86. data/app/views/catalog/_index_partials/_description.html.erb +8 -0
  87. data/app/views/catalog/_search_form.html.erb +66 -0
  88. data/app/views/catalog/_show_partials/_description.html.erb +15 -0
  89. data/app/views/catalog/browse_show.html.erb +18 -0
  90. data/app/views/catalog/index.html.erb +35 -0
  91. data/app/views/catalog/list_description.html.erb +24 -0
  92. data/app/views/catalog/list_item.html.erb +3 -0
  93. data/app/views/layouts/atrium.html.erb +86 -0
  94. data/app/views/layouts/atrium_themes/default.html.erb +4 -0
  95. data/app/views/layouts/item_listing.html.erb +36 -0
  96. data/app/views/listing/_document.html.erb +27 -0
  97. data/app/views/listing/_document_list.html.erb +3 -0
  98. data/app/views/listing/_item_search.html.erb +27 -0
  99. data/app/views/shared/_banner.html.erb +5 -0
  100. data/app/views/shared/_collection_complete_list.html.erb +33 -0
  101. data/app/views/shared/_collection_search_form.html.erb +12 -0
  102. data/app/views/shared/_collection_title_header.html.erb +3 -0
  103. data/app/views/shared/_featured_sources.html.erb +20 -0
  104. data/app/views/shared/_list_descriptions.html.erb +38 -0
  105. data/app/views/shared/_navigation_browse_levels.html.erb +34 -0
  106. data/app/views/shared/_showcase_configure_menu.html.erb +22 -0
  107. data/app/views/shared/_top_navigation.html.erb +9 -0
  108. data/atrium.gemspec +76 -0
  109. data/config/routes.rb +12 -0
  110. data/init.rb +3 -0
  111. data/lib/application_controller.rb +24 -0
  112. data/lib/atrium.rb +42 -0
  113. data/lib/atrium/application_helper.rb +24 -0
  114. data/lib/atrium/atrium_helper_behavior.rb +162 -0
  115. data/lib/atrium/catalog.rb +203 -0
  116. data/lib/atrium/collections_helper.rb +139 -0
  117. data/lib/atrium/controller.rb +10 -0
  118. data/lib/atrium/descriptions_helper.rb +23 -0
  119. data/lib/atrium/engine.rb +12 -0
  120. data/lib/atrium/layout_helper.rb +13 -0
  121. data/lib/atrium/routes.rb +99 -0
  122. data/lib/atrium/solr_helper.rb +440 -0
  123. data/lib/atrium/version.rb +3 -0
  124. data/lib/generators/atrium/assets_generator.rb +44 -0
  125. data/lib/generators/atrium/atrium_generator.rb +149 -0
  126. data/lib/generators/atrium/cucumber_support_generator.rb +29 -0
  127. data/lib/generators/atrium/templates/config/role_map_cucumber.yml +2 -0
  128. data/lib/generators/atrium/templates/config/role_map_development.yml +2 -0
  129. data/lib/generators/atrium/templates/config/role_map_production.yml +2 -0
  130. data/lib/generators/atrium/templates/config/role_map_test.yml +2 -0
  131. data/lib/generators/atrium/templates/config/solr.yml +10 -0
  132. data/lib/generators/atrium/templates/db/seeds.rb +87 -0
  133. data/lib/generators/atrium/templates/migrations/create_atrium_browse_levels.rb +18 -0
  134. data/lib/generators/atrium/templates/migrations/create_atrium_collections.rb +20 -0
  135. data/lib/generators/atrium/templates/migrations/create_atrium_descriptions.rb +16 -0
  136. data/lib/generators/atrium/templates/migrations/create_atrium_essays.rb +15 -0
  137. data/lib/generators/atrium/templates/migrations/create_atrium_exhibits.rb +16 -0
  138. data/lib/generators/atrium/templates/migrations/create_atrium_search_facets.rb +14 -0
  139. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_facet_selections.rb +15 -0
  140. data/lib/generators/atrium/templates/migrations/create_atrium_showcase_items.rb +17 -0
  141. data/lib/generators/atrium/templates/migrations/create_atrium_showcases.rb +16 -0
  142. data/lib/generators/atrium/templates/themes/example.html.erb +21 -0
  143. data/lib/railties/all_tests.rake +23 -0
  144. data/lib/railties/atrium_cucumber.rake +121 -0
  145. data/lib/railties/index.rake +37 -0
  146. data/tasks/atrium.rake +268 -0
  147. data/tasks/atrium_rspec.rake +91 -0
  148. data/test_support/etc/Gemfile +33 -0
  149. data/test_support/etc/bundle_config +3 -0
  150. data/test_support/etc/rvmrc +32 -0
  151. data/test_support/features/atrium_collections.feature +162 -0
  152. data/test_support/features/atrium_exhibits.feature +164 -0
  153. data/test_support/features/step_definitions/atrium_collection_steps.rb +102 -0
  154. data/test_support/features/step_definitions/atrium_exhibit_steps.rb +53 -0
  155. data/test_support/features/step_definitions/bookmarks_steps.rb +6 -0
  156. data/test_support/features/step_definitions/error_steps.rb +5 -0
  157. data/test_support/features/step_definitions/folder_steps.rb +27 -0
  158. data/test_support/features/step_definitions/general_steps.rb +50 -0
  159. data/test_support/features/step_definitions/record_view_steps.rb +12 -0
  160. data/test_support/features/step_definitions/saved_searches_steps.rb +22 -0
  161. data/test_support/features/step_definitions/search_facets_steps.rb +29 -0
  162. data/test_support/features/step_definitions/search_history_steps.rb +9 -0
  163. data/test_support/features/step_definitions/search_result_steps.rb +114 -0
  164. data/test_support/features/step_definitions/search_steps.rb +103 -0
  165. data/test_support/features/step_definitions/user_steps.rb +5 -0
  166. data/test_support/features/step_definitions/web_steps.rb +213 -0
  167. data/test_support/features/support/env.rb +67 -0
  168. data/test_support/features/support/paths.rb +76 -0
  169. data/test_support/features/support/selectors.rb +40 -0
  170. data/test_support/fixtures/atrium_exhibits.yml +3 -0
  171. data/test_support/spec/controllers/atrium/base_controller_spec.rb +13 -0
  172. data/test_support/spec/controllers/atrium/collection_exhibit_order_controller_spec.rb +29 -0
  173. data/test_support/spec/controllers/atrium/collections_controller_spec.rb +185 -0
  174. data/test_support/spec/controllers/atrium/customization_controller_spec.rb +38 -0
  175. data/test_support/spec/controllers/atrium/descriptions_controller_spec.rb +150 -0
  176. data/test_support/spec/controllers/atrium/exhibit_facet_order_controller_spec.rb +36 -0
  177. data/test_support/spec/controllers/atrium/exhibits_controller_spec.rb +192 -0
  178. data/test_support/spec/controllers/atrium/showcases_controller_spec.rb +185 -0
  179. data/test_support/spec/helpers/atrium_collections_helper_spec.rb +147 -0
  180. data/test_support/spec/helpers/atrium_description_helper_spec.rb +47 -0
  181. data/test_support/spec/helpers/atrium_solr_helper_spec.rb +512 -0
  182. data/test_support/spec/models/atrium/browse_level_spec.rb +31 -0
  183. data/test_support/spec/models/atrium/collection_spec.rb +30 -0
  184. data/test_support/spec/models/atrium/description_spec.rb +67 -0
  185. data/test_support/spec/models/atrium/essay_spec.rb +12 -0
  186. data/test_support/spec/models/atrium/exhibit_spec.rb +76 -0
  187. data/test_support/spec/models/atrium/search/facet_selection_spec.rb +24 -0
  188. data/test_support/spec/models/atrium/search/facet_spec.rb +11 -0
  189. data/test_support/spec/models/atrium/search_facet_spec.rb +54 -0
  190. data/test_support/spec/models/atrium/showcase/facet_selection_spec.rb +15 -0
  191. data/test_support/spec/models/atrium/showcase/item_spec.rb +12 -0
  192. data/test_support/spec/models/atrium/showcase_facet_selection_spec.rb +65 -0
  193. data/test_support/spec/models/atrium/showcase_spec.rb +134 -0
  194. data/test_support/spec/rcov.opts +3 -0
  195. data/test_support/spec/routing/atrium/collections_routing_spec.rb +33 -0
  196. data/test_support/spec/spec.opts +4 -0
  197. data/test_support/spec/spec_helper.rb +47 -0
  198. data/test_support/spec/support/be_accessible_matcher.rb +8 -0
  199. data/test_support/spec/support/be_routed_mixin.rb +7 -0
  200. data/test_support/tmp/step_definitions/catalog_index_steps.rb +14 -0
  201. data/test_support/tmp/step_definitions/edit_document_steps.rb +67 -0
  202. data/test_support/tmp/step_definitions/hydra_metadata_steps.rb +3 -0
  203. data/test_support/tmp/step_definitions/hydra_steps.rb +8 -0
  204. data/test_support/tmp/step_definitions/search_steps.rb +86 -0
  205. data/test_support/tmp/step_definitions/searching_steps.rb +22 -0
  206. data/test_support/tmp/step_definitions/select_steps.rb +8 -0
  207. data/test_support/tmp/step_definitions/show_document_steps.rb +73 -0
  208. data/test_support/tmp/step_definitions/user_steps.rb +15 -0
  209. data/test_support/tmp/step_definitions/web_steps.rb +273 -0
  210. data/test_support/tmp/support/env.rb +54 -0
  211. data/test_support/tmp/support/paths.rb +57 -0
  212. metadata +1047 -0
@@ -0,0 +1,12 @@
1
+ Rails.application.routes.draw do
2
+
3
+ # Routes for the Atrium application are defined in Atrium::Routes
4
+ #
5
+ # These routes can be injected into your Rails application by adding
6
+ # Atrium.add_routes(self)
7
+ # to the application's ./config/routes.rb. The injected routes can be
8
+ # customized as well, e.g.:
9
+ # Atrium.add_routes(self, :only => [:collection]) # will only load collection routes
10
+ # Atrium.add_routes(self, :except => [:catalog]) # will not load catalog routes
11
+ end
12
+
data/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ # Include hook code here
2
+ require "atrium"
3
+ Atrium.extend Blacklight::Configurable # not sure why this isn't being executed in lib/atrium.rb
@@ -0,0 +1,24 @@
1
+ module Atrium
2
+ ## Define ControllerMethods
3
+ module Controller
4
+ ## this one manages the usual self.included, klass_eval stuff
5
+ extend ActiveSupport::Concern
6
+ require 'cancan'
7
+
8
+ included do
9
+ before_filter :method_for_before_filtering
10
+ end
11
+
12
+ module InstanceMethods
13
+ def method_for_before_filtering
14
+ #puts "Filtering before"
15
+ end
16
+
17
+ def method_not_a_filter
18
+ puts "not used as a filter"
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ ::ActionController::Base.send :include, Atrium::Controller
@@ -0,0 +1,42 @@
1
+ require "blacklight"
2
+ module Atrium
3
+ require 'atrium/engine' if defined?(Rails)
4
+ require 'application_controller'
5
+
6
+ require 'atrium/version'
7
+ require 'atrium/routes'
8
+
9
+ require 'ckeditor-rails'
10
+ require 'devise'
11
+ require 'loggable'
12
+
13
+ include Loggable
14
+
15
+ def self.version
16
+ Atrium::VERSION
17
+ end
18
+
19
+ def self.root
20
+ @root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
21
+ end
22
+
23
+ # If you put this in your application's routes.rb, it will add the Atrium routes to the app.
24
+ # The atrium generator puts this in routes.rb for you by default.
25
+ # See {Atrium::Routes} for information about how to modify which routes are generated.
26
+ # @example
27
+ # # in config/routes.rb
28
+ # MyAppName::Application.routes.draw do
29
+ # Blacklight.add_routes(self)
30
+ # HydraHead.add_routes(self)
31
+ # Atrium.add_routes(self)
32
+ # end
33
+ def self.add_routes(router, options = {})
34
+ Atrium::Routes.new(router, options).draw
35
+ end
36
+
37
+ end
38
+
39
+ require 'atrium/application_helper.rb'
40
+ require 'atrium/collections_helper.rb'
41
+ require 'atrium/descriptions_helper.rb'
42
+ require 'atrium/solr_helper.rb'
@@ -0,0 +1,24 @@
1
+ module Atrium::ApplicationHelper
2
+ def thumbnail_class( document )
3
+ display_thumnail( document ) ? ' with-thumbnail' : ''
4
+ end
5
+
6
+ def top_level_showcase(exhibit_id)
7
+ showcases = Atrium::Showcase.find_by_atrium_exhibit_id(exhibit_id)
8
+ showcase = showcases.first unless showcases.empty?
9
+ end
10
+
11
+ def is_editing?
12
+ session[:edit_showcase].blank? ? false : true
13
+ end
14
+
15
+ def get_essay_from_description(desc_hash, desc_id)
16
+ if !desc_hash.nil?
17
+ return desc_hash[desc_id]
18
+ else
19
+ logger.error("hash is blank for some reason. Please check")
20
+ return ""
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,162 @@
1
+
2
+ module Atrium::AtriumHelperBehavior
3
+ include BlacklightHelper
4
+ include FacetsHelper
5
+
6
+ def application_name
7
+ 'Atrium Application'
8
+ end
9
+
10
+ # An array of strings to be added to HTML HEAD section of view.
11
+ def extra_head_content
12
+ @extra_head_content ||= []
13
+ end
14
+
15
+
16
+ # Array, where each element is an array of arguments to
17
+ # Rails stylesheet_link_tag helper. See
18
+ # ApplicationHelper#render_head_content for details.
19
+ def stylesheet_links
20
+ @stylesheet_links ||= []
21
+ end
22
+
23
+ # Array, where each element is an array of arguments to
24
+ # Rails javascript_include_tag helper. See
25
+ # ApplicationHelper#render_head_content for details.
26
+ def javascript_includes
27
+ @javascript_includes ||= []
28
+ end
29
+
30
+ # used in the catalog/_facets partial
31
+ #def facet_field_names
32
+ # if params[:collection_id] && params[:controller] == 'catalog' && params[:action] = 'index'
33
+ # logger.debug("Into get facets")
34
+ # collection = @atrium_collection? @atrium_collection : Atrium::Collection.find(params[:collection_id])
35
+ # if collection
36
+ # collection.search_facets.collect {|f| f.name}
37
+ # end
38
+ # else
39
+ # super
40
+ # end
41
+ #end
42
+
43
+ def render_facet_limit(display_facet, options = {})
44
+ if params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter] || params[:add_featured] || params[:exclude_browse_level_filter]
45
+ if display_facet.is_a? String or display_facet.is_a? Symbol
46
+ $stderr.puts "............... DEPRECATION WARNING: Blacklight::FacetsHelper#render_facet_limit: use #render_facet_partials to render facets by field name"
47
+ return render_facet_partials([display_facet])
48
+ end
49
+ options = options.dup
50
+ options[:partial] ||= facet_partial_name(display_facet)
51
+ options[:layout] ||= "facet_layout" unless options.has_key?(:layout)
52
+ options[:locals] ||= {}
53
+ options[:locals][:solr_field] ||= display_facet.name
54
+ options[:locals][:solr_fname] ||= display_facet.name # DEPRECATED
55
+ options[:locals][:facet_field] ||= facet_configuration_for_field(display_facet.name)
56
+ options[:locals][:display_facet] ||= display_facet
57
+ render(options)
58
+ else
59
+ super
60
+ end
61
+ end
62
+
63
+ # link_to_document(doc, :label=>'VIEW', :counter => 3)
64
+ # Use the catalog_path RESTful route to create a link to the show page for a specific item.
65
+ # catalog_path accepts a HashWithIndifferentAccess object. The solr query params are stored in the session,
66
+ # so we only need the +counter+ param here. We also need to know if we are viewing to document as part of search results.
67
+ def link_to_document(doc, opts={:label=>blacklight_config.index.show_link.to_sym, :counter => nil, :results_view => true})
68
+ logger.debug("Atrium link_to_document Label: #{opts[:label]}")
69
+ collection_id = params[:controller] == "atrium/collections" ? params[:id] : params[:collection_id]
70
+ exhibit_id = params[:controller] == "atrium_exhibits" ? params[:id] : params[:exhibit_id]
71
+ label = render_document_index_label doc, opts
72
+ args = {}
73
+ args.merge!(:f=>params[:f]) if params[:f]
74
+ #&& params[:controller] != "catalog"
75
+ #try to retrieve collection id if not set
76
+ if exhibit_id && !collection_id
77
+ begin
78
+ exhibit = Atrium::Exhibit.find(exhibit_id)
79
+ collection_id = exhibit.collection.id if exhibit && exhibit.collection
80
+ rescue
81
+ end
82
+ end
83
+ args.merge!(:'data-counter' => opts[:counter])
84
+ if exhibit_id && collection_id
85
+ #link_to_with_data(label, atrium_collection_exhibit_browse_path(collection_id, exhibit_id, doc.id, args), {:method => :put, :class => label.parameterize, :data => opts}).html_safe
86
+ label = render_document_index_label doc, opts
87
+ logger.debug("URL: #{atrium_collection_exhibit_browse_path(collection_id, exhibit_id, doc.id, args).inspect}")
88
+ link_to label, atrium_collection_exhibit_browse_path(collection_id, exhibit_id, doc.id, args)
89
+ #elsif exhibit_id
90
+ # link_to_with_data(label, atrium_exhibit_browse_path(exhibit_id, doc.id, args), {:method => :put, :class => label.parameterize, :data => opts}).html_safe
91
+ elsif collection_id
92
+ params[:controller] == "catalog" ? current_path = atrium_collection_catalog_path(collection_id, doc.id, args) : current_path = atrium_collection_browse_path(collection_id, doc.id, args)
93
+ label = render_document_index_label doc, opts
94
+ link_to label, current_path, :'data-counter' => opts[:counter]
95
+ #link_to_with_data(label, current_path, {:method => :put, :class => label.parameterize, :data => opts}).html_safe
96
+ else
97
+ logger.debug("call supper")
98
+ super
99
+ end
100
+
101
+ end
102
+
103
+ # If collection is defined and in an collection browse view
104
+ # then do not set limit on facet values displayed.
105
+ # Otherwise use code lifted from catalog controller in blacklight plugin
106
+ def facet_limit_for(facet_field)
107
+
108
+ #if (params[:collection_id] && !params[:render_search].blank?)
109
+ if params[:controller] == "catalog"
110
+ super
111
+ else
112
+ nil
113
+ end
114
+ end
115
+
116
+ # Overriding so that it will not show facet constraints if selecting
117
+ # featured items because we should not be able to remove facet selections
118
+ # that are setting proper search scope for a browse page
119
+ def render_constraints(localized_params = params)
120
+ if params[:add_featured]
121
+ (render_constraints_query(localized_params)).html_safe
122
+ else
123
+ (render_constraints_query(localized_params) + render_constraints_filters(localized_params)).html_safe
124
+ end
125
+ end
126
+
127
+ # Override this from BlacklightHelper so we can have a link back to browsing a collection
128
+ # Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
129
+ def link_back_to_catalog(opts={:label=>'Back to Search'})
130
+ if params[:atrium_collection_browse]
131
+ params[:controller] == "atrium_collections" ? collection_id = params[:id] : collection_id = params[:collection_id]
132
+ link_to "Back to Browse Collection", atrium_collection_path(collection_id)
133
+ elsif params[:atrium_exhibit_browse]
134
+ params[:controller] == "atrium_exhibits" ? exhibit_id = params[:id] : exhibit_id = params[:exhibit_id]
135
+ link_to "Back to Browse Exhibit", atrium_exhibit_path(exhibit_id,:f=>params[:f])
136
+ else
137
+ super
138
+ end
139
+ end
140
+
141
+ def save_collection_id_in_session(collection_id)
142
+ session[:collection_id] = collection_id
143
+ end
144
+
145
+ def save_exhibit_id_in_session(exhibit_id)
146
+ session[:exhibit_id] = exhibit_id
147
+ end
148
+
149
+ def set_edit_showcase_in_session
150
+ logger.debug("Setting edit showcase")
151
+ session[:edit_showcase] = true
152
+ end
153
+
154
+ def get_start_over_path
155
+ if (params[:collection_id])
156
+ atrium_collection_home_path(params[:collection_id])
157
+ else
158
+ catalog_index_path
159
+ end
160
+ end
161
+
162
+ end
@@ -0,0 +1,203 @@
1
+ require 'blacklight/catalog'
2
+ require 'atrium/layout_helper'
3
+
4
+ # Include this module into any of your Blacklight Catalog classes (ie. CatalogController) to add Atrium functionality
5
+ #
6
+ # This module will only work if you also include Blacklight::Catalog in the Controller you're extending.
7
+ # The atrium rails generator will create the CatalogController for you in app/controllers/catalog_controller.rb
8
+ # @example
9
+ # require 'blacklight/catalog'
10
+ # require 'atrium/catalog'
11
+ # class CustomCatalogController < ApplicationController
12
+ # include Blacklight::Catalog
13
+ # include Atrium::Catalog
14
+ # end
15
+ module Atrium::Catalog
16
+ extend ActiveSupport::Concern
17
+ include Blacklight::Catalog
18
+ include Atrium::SolrHelper
19
+ include Atrium::LayoutHelper
20
+ include BlacklightHelper
21
+
22
+ def self.included(klass)
23
+ klass.before_filter :initialize_collection
24
+ klass.layout :collection_theme_if_present
25
+ end
26
+
27
+ def show
28
+ super
29
+ if params[:atrium_collection_browse] || params[:atrium_exhibit_browse]
30
+ @exhibit_navigation_data = get_exhibit_navigation_data
31
+ ##logger.debug("render browse_show")
32
+ #render "browse_show"
33
+ end
34
+ end
35
+
36
+ def browse_show
37
+ end
38
+
39
+ def index
40
+ #put in atrium index code here
41
+ if params[:save_collection_filter_button]
42
+ #logger.debug("pressed save collection filter button")
43
+ if @atrium_collection
44
+ if !session[:folder_document_ids].blank?
45
+ @atrium_collection.collection_items ||= Hash.new
46
+ selected_document_ids = session[:folder_document_ids]
47
+ collection_items={}
48
+ collection_items[:solr_doc_ids]=selected_document_ids.join(',')
49
+ #@atrium_collection.update_attributes(:collection_items=>collection_items)
50
+ @atrium_collection.update_attributes(:filter_query_params=>collection_items)
51
+ session[:folder_document_ids] = session[:copy_folder_document_ids]
52
+ session[:copy_folder_document_ids]=nil
53
+ #logger.debug("@@atrium_collection: #{@atrium_collection.inspect},Selected Items: #{@atrium_collection.filter_query_params.inspect}, folders_selected: #{session[:folder_document_ids].inspect}")
54
+ else
55
+ filter_query_params = search_session.clone
56
+ filter_query_params.delete(:save_collection_filter_button)
57
+ filter_query_params.delete(:collection_id)
58
+ filter_query_params.delete :action
59
+ filter_query_params.delete :id
60
+ filter_query_params.delete :controller
61
+ filter_query_params.delete :utf8
62
+ @atrium_collection.update_attributes(:filter_query_params=>filter_query_params)
63
+ end
64
+ redirect_to edit_atrium_collection_path(@atrium_collection.id)
65
+ else
66
+ redirect_to new_atrium_collection_path
67
+ end
68
+ elsif params[:save_exhibit_filter_button]
69
+ params[:exhibit_id] ? exhibit_id = params[:exhibit_id] : exhibit_id = params[:edit_exhibit_filter]
70
+ @exhibit = Atrium::Exhibit.find(exhibit_id) if exhibit_id
71
+ #logger.debug("pressed save exhibit filter button")
72
+ if @exhibit
73
+ if !session[:folder_document_ids].blank?
74
+ selected_document_ids = session[:folder_document_ids]
75
+ exhibit_items={}
76
+ exhibit_items[:solr_doc_ids]=selected_document_ids.join(',')
77
+ @exhibit.update_attributes(:filter_query_params=>exhibit_items)
78
+ session[:folder_document_ids] = session[:copy_folder_document_ids]
79
+ session[:copy_folder_document_ids]=nil
80
+ #logger.debug("exhibit: #{@exhibit.inspect},Selected Items: #{@exhibit.filter_query_params.inspect}, folders_selected: #{session[:folder_document_ids].inspect}")
81
+ else
82
+ filter_query_params = search_session.clone
83
+ filter_query_params.delete(:save_exhibit_filter_button)
84
+ filter_query_params.delete(:collection_id)
85
+ filter_query_params.delete(:exhibit_id)
86
+ filter_query_params.delete :action
87
+ filter_query_params.delete :id
88
+ filter_query_params.delete :controller
89
+ filter_query_params.delete :utf8
90
+ @exhibit.update_attributes(:filter_query_params=>filter_query_params)
91
+ end
92
+ redirect_to edit_atrium_exhibit_path(@exhibit.id)
93
+ else
94
+ redirect_to new_atrium_exhibit_path
95
+ end
96
+ elsif params[:save_browse_level_filter_button]
97
+ params[:browse_level_id] ? browse_level_id = params[:browse_level_id] : browse_level_id = params[:edit_browse_level_filter]
98
+ @browse_level = Atrium::BrowseLevel.find(browse_level_id) if browse_level_id
99
+ #logger.debug("pressed save browse level filter button")
100
+ if @browse_level
101
+ filter_query_params = search_session.clone
102
+ filter_query_params.delete(:save_browse_level_filter_button)
103
+ filter_query_params.delete(:collection_id)
104
+ filter_query_params.delete(:browse_level_id)
105
+ @browse_level.update_attributes(:filter_query_params=>filter_query_params)
106
+ redirect_to edit_atrium_exhibit_path(@browse_level.atrium_exhibit_id)
107
+ else
108
+ redirect_to new_atrium_exhibit_path
109
+ end
110
+ elsif params[:save_browse_level_exclude_button]
111
+ params[:browse_level_id] ? browse_level_id = params[:browse_level_id] : browse_level_id = params[:edit_browse_level_filter]
112
+ @browse_level = Atrium::BrowseLevel.find(browse_level_id) if browse_level_id
113
+ #logger.debug("pressed save browse level filter button")
114
+ if @browse_level
115
+ filter_query_params = search_session.clone
116
+ filter_query_params[:exclude] = filter_query_params[:f]
117
+ filter_query_params.delete(:f)
118
+ filter_query_params.delete(:save_browse_level_exclude_button)
119
+ filter_query_params.delete(:collection_id)
120
+ filter_query_params.delete(:browse_level_id)
121
+ @browse_level.update_attributes(:exclude_query_params=>filter_query_params)
122
+ redirect_to edit_atrium_exhibit_path(@browse_level.atrium_exhibit_id)
123
+ else
124
+ redirect_to new_atrium_exhibit_path
125
+ end
126
+ else
127
+ delete_or_assign_search_session_params if !params[:add_description]
128
+
129
+ extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
130
+ extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
131
+
132
+ @extra_controller_params ||= {}
133
+ if params[:exhibit_id]
134
+ @exhibit = Atrium::Exhibit.find(params[:exhibit_id])
135
+ @atrium_collection = @exhibit.collection if @exhibit
136
+ end
137
+
138
+ if params[:browse_level_id]
139
+ @browse_level = Atrium::BrowseLevel.find(params[:browse_level_id])
140
+ @exhibit = @browse_level.exhibit if @browse_level
141
+ @atrium_collection = @exhibit.collection if @exhibit
142
+ end
143
+
144
+ #do not mixin whatever level I am on if I am editing the settings
145
+ collection = @atrium_collection unless params[:edit_collection_filter]
146
+ exhibit = @exhibit unless params[:edit_exhibit_filter] || params[:edit_collection_filter]
147
+ browse_level = @browse_level unless params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter]
148
+ #logger.debug("collection is: #{collection.inspect}")
149
+ #logger.debug("exhibit is: #{exhibit.inspect}")
150
+ #logger.debug("browse level is: #{browse_level.inspect}")
151
+ #logger.debug("params before search are: #{params.inspect}")
152
+ if params[:add_description] || params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter] || params[:CKEditor]
153
+ @extra_controller_params={}
154
+ else
155
+ @extra_controller_params = prepare_extra_controller_params_for_collection_query(collection,exhibit,browse_level,params,@extra_controller_params) if collection || exhibit || browse_level
156
+ end
157
+
158
+ logger.debug("extra params before search are: #{@extra_controller_params.inspect}")
159
+ (@response, @document_list) = get_search_results(params,@extra_controller_params)
160
+ @images = get_all_children(@document_list, "is_part_of_s")
161
+ #@members = get_all_children(@document_list, "is_member_of_s")
162
+
163
+ #reset to settings before was merged with user params
164
+ @extra_controller_params = reset_extra_controller_params_after_collection_query(collection,exhibit,browse_level,@extra_controller_params) if collection || exhibit || browse_level
165
+ @filters = params[:f] || []
166
+ search_session[:total] = @response.total unless @response.nil?
167
+
168
+ if params[:CKEditor] || params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter] || params[:add_featured]
169
+ render "list_item", :layout=> "item_listing"
170
+ elsif params[:add_description]
171
+ render "list_description", :layout=> "item_listing"
172
+ end
173
+
174
+ respond_to do |format|
175
+ format.html { save_current_search_params unless params[:edit_exhibit_filter] || params[:edit_collection_filter] || params[:edit_browse_level_filter]}
176
+ format.rss { render :layout => false }
177
+ format.atom { render :layout => false }
178
+ end
179
+ end
180
+ end
181
+
182
+ def initialize_collection
183
+ if collection_id = determine_collection_id
184
+ return __initialize_collection( collection_id )
185
+ else
186
+ return false
187
+ end
188
+ end
189
+
190
+ #protected :initialize_collection
191
+
192
+ private
193
+
194
+ def determine_collection_id
195
+ if params.has_key? :collection_id
196
+ return params[:collection_id]
197
+ elsif params.has_key? :collection_number
198
+ return params[:collection_number]
199
+ end
200
+ end
201
+
202
+ end
203
+