atrium 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +13 -0
- data/.gitmodules +3 -0
- data/.rvmrc +32 -0
- data/GETTING_STARTED.textile +109 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +320 -0
- data/Guardfile +10 -0
- data/README.mkd +56 -0
- data/Rakefile +6 -0
- data/app/assets/images/atrium/ajax-loader.gif +0 -0
- data/app/assets/images/atrium/lightbox-ico-loading.gif +0 -0
- data/app/assets/images/atrium/logo.png +0 -0
- data/app/assets/javascripts/atrium/atrium.js +281 -0
- data/app/assets/javascripts/chosen.jquery.js +899 -0
- data/app/assets/javascripts/ckeditor.warning.js +65 -0
- data/app/assets/javascripts/ckeditor/config.js.coffee +6 -0
- data/app/assets/javascripts/ckeditor/jquery.generateId.js +13 -0
- data/app/assets/javascripts/ckeditor/jquery.jeditable.ckeditor.js +59 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/application_link.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/dialogs/linkItem.js +1470 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/plugin.js +16 -0
- data/app/assets/javascripts/ckeditor/plugins/linkItem/ui_toolbar_pencil.png +0 -0
- data/app/assets/javascripts/jquery.colorbox.js +864 -0
- data/app/assets/javascripts/jquery.jeditable.js +543 -0
- data/app/assets/stylesheets/atrium/atrium.css +216 -0
- data/app/assets/stylesheets/atrium/chosen-sprite.png +0 -0
- data/app/assets/stylesheets/atrium/chosen.css +367 -0
- data/app/assets/stylesheets/colorbox.css +42 -0
- data/app/assets/stylesheets/controls.png +0 -0
- data/app/assets/stylesheets/loading.gif +0 -0
- data/app/controllers/atrium/base_controller.rb +25 -0
- data/app/controllers/atrium/collection_exhibit_order_controller.rb +21 -0
- data/app/controllers/atrium/collections_controller.rb +165 -0
- data/app/controllers/atrium/customization_controller.rb +41 -0
- data/app/controllers/atrium/descriptions_controller.rb +177 -0
- data/app/controllers/atrium/exhibit_facet_order_controller.rb +19 -0
- data/app/controllers/atrium/exhibits_controller.rb +108 -0
- data/app/controllers/atrium/showcases_controller.rb +193 -0
- data/app/helpers/atrium/base_helper.rb +6 -0
- data/app/models/ability.rb +14 -0
- data/app/models/atrium/browse_level.rb +41 -0
- data/app/models/atrium/collection.rb +121 -0
- data/app/models/atrium/description.rb +128 -0
- data/app/models/atrium/essay.rb +21 -0
- data/app/models/atrium/exhibit.rb +58 -0
- data/app/models/atrium/search/facet.rb +29 -0
- data/app/models/atrium/search/facet_selection.rb +17 -0
- data/app/models/atrium/showcase.rb +173 -0
- data/app/models/atrium/showcase/facet_selection.rb +21 -0
- data/app/models/atrium/showcase/item.rb +19 -0
- data/app/models/role_mapper.rb +23 -0
- data/app/views/_user_util_links.html.erb +25 -0
- data/app/views/atrium/collections/_bookmark_control.html.erb +25 -0
- data/app/views/atrium/collections/_browse_index.html.erb +20 -0
- data/app/views/atrium/collections/_collection_items_index.html.erb +10 -0
- data/app/views/atrium/collections/_document.html.erb +24 -0
- data/app/views/atrium/collections/_document_list.html.erb +6 -0
- data/app/views/atrium/collections/_edit_navigation.html.erb +20 -0
- data/app/views/atrium/collections/_folder_control.html.erb +12 -0
- data/app/views/atrium/collections/_form.html.erb +93 -0
- data/app/views/atrium/collections/_listing.html.erb +18 -0
- data/app/views/atrium/collections/_navigation.html.erb +45 -0
- data/app/views/atrium/collections/_results_pagination.html.erb +9 -0
- data/app/views/atrium/collections/_sort_and_per_page.html.erb +23 -0
- data/app/views/atrium/collections/edit.html.erb +5 -0
- data/app/views/atrium/collections/new.html.erb +6 -0
- data/app/views/atrium/collections/show.html.erb +22 -0
- data/app/views/atrium/descriptions/_form.html.erb +64 -0
- data/app/views/atrium/descriptions/edit.html.erb +4 -0
- data/app/views/atrium/descriptions/index.html.erb +4 -0
- data/app/views/atrium/descriptions/new.html.erb +2 -0
- data/app/views/atrium/descriptions/show.html.erb +20 -0
- data/app/views/atrium/exhibits/_bookmark_control.html.erb +25 -0
- data/app/views/atrium/exhibits/_folder_control.html.erb +12 -0
- data/app/views/atrium/exhibits/_form.html.erb +108 -0
- data/app/views/atrium/exhibits/edit.html.erb +9 -0
- data/app/views/atrium/exhibits/new.html.erb +6 -0
- data/app/views/atrium/exhibits/show.html.erb +26 -0
- data/app/views/atrium/showcases/_showcase_navigation.html.erb +23 -0
- data/app/views/atrium/showcases/show.html.erb +1 -0
- data/app/views/catalog/_collection_home_text.html.erb +6 -0
- data/app/views/catalog/_constraints.html.erb +9 -0
- data/app/views/catalog/_default_collection_text.html.erb +18 -0
- data/app/views/catalog/_default_home_text.html.erb +6 -0
- data/app/views/catalog/_home_text.html.erb +6 -0
- data/app/views/catalog/_index_partials/_description.html.erb +8 -0
- data/app/views/catalog/_search_form.html.erb +66 -0
- data/app/views/catalog/_show_partials/_description.html.erb +15 -0
- data/app/views/catalog/browse_show.html.erb +18 -0
- data/app/views/catalog/index.html.erb +35 -0
- data/app/views/catalog/list_description.html.erb +24 -0
- data/app/views/catalog/list_item.html.erb +3 -0
- data/app/views/layouts/atrium.html.erb +86 -0
- data/app/views/layouts/atrium_themes/default.html.erb +4 -0
- data/app/views/layouts/item_listing.html.erb +36 -0
- data/app/views/listing/_document.html.erb +27 -0
- data/app/views/listing/_document_list.html.erb +3 -0
- data/app/views/listing/_item_search.html.erb +27 -0
- data/app/views/shared/_banner.html.erb +5 -0
- data/app/views/shared/_collection_complete_list.html.erb +33 -0
- data/app/views/shared/_collection_search_form.html.erb +12 -0
- data/app/views/shared/_collection_title_header.html.erb +3 -0
- data/app/views/shared/_featured_sources.html.erb +20 -0
- data/app/views/shared/_list_descriptions.html.erb +38 -0
- data/app/views/shared/_navigation_browse_levels.html.erb +34 -0
- data/app/views/shared/_showcase_configure_menu.html.erb +22 -0
- data/app/views/shared/_top_navigation.html.erb +9 -0
- data/atrium.gemspec +76 -0
- data/config/routes.rb +12 -0
- data/init.rb +3 -0
- data/lib/application_controller.rb +24 -0
- data/lib/atrium.rb +42 -0
- data/lib/atrium/application_helper.rb +24 -0
- data/lib/atrium/atrium_helper_behavior.rb +162 -0
- data/lib/atrium/catalog.rb +203 -0
- data/lib/atrium/collections_helper.rb +139 -0
- data/lib/atrium/controller.rb +10 -0
- data/lib/atrium/descriptions_helper.rb +23 -0
- data/lib/atrium/engine.rb +12 -0
- data/lib/atrium/layout_helper.rb +13 -0
- data/lib/atrium/routes.rb +99 -0
- data/lib/atrium/solr_helper.rb +440 -0
- data/lib/atrium/version.rb +3 -0
- data/lib/generators/atrium/assets_generator.rb +44 -0
- data/lib/generators/atrium/atrium_generator.rb +149 -0
- data/lib/generators/atrium/cucumber_support_generator.rb +29 -0
- data/lib/generators/atrium/templates/config/role_map_cucumber.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_development.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_production.yml +2 -0
- data/lib/generators/atrium/templates/config/role_map_test.yml +2 -0
- data/lib/generators/atrium/templates/config/solr.yml +10 -0
- data/lib/generators/atrium/templates/db/seeds.rb +87 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_browse_levels.rb +18 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_collections.rb +20 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_descriptions.rb +16 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_essays.rb +15 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_exhibits.rb +16 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_search_facets.rb +14 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcase_facet_selections.rb +15 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcase_items.rb +17 -0
- data/lib/generators/atrium/templates/migrations/create_atrium_showcases.rb +16 -0
- data/lib/generators/atrium/templates/themes/example.html.erb +21 -0
- data/lib/railties/all_tests.rake +23 -0
- data/lib/railties/atrium_cucumber.rake +121 -0
- data/lib/railties/index.rake +37 -0
- data/tasks/atrium.rake +268 -0
- data/tasks/atrium_rspec.rake +91 -0
- data/test_support/etc/Gemfile +33 -0
- data/test_support/etc/bundle_config +3 -0
- data/test_support/etc/rvmrc +32 -0
- data/test_support/features/atrium_collections.feature +162 -0
- data/test_support/features/atrium_exhibits.feature +164 -0
- data/test_support/features/step_definitions/atrium_collection_steps.rb +102 -0
- data/test_support/features/step_definitions/atrium_exhibit_steps.rb +53 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +6 -0
- data/test_support/features/step_definitions/error_steps.rb +5 -0
- data/test_support/features/step_definitions/folder_steps.rb +27 -0
- data/test_support/features/step_definitions/general_steps.rb +50 -0
- data/test_support/features/step_definitions/record_view_steps.rb +12 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +22 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +29 -0
- data/test_support/features/step_definitions/search_history_steps.rb +9 -0
- data/test_support/features/step_definitions/search_result_steps.rb +114 -0
- data/test_support/features/step_definitions/search_steps.rb +103 -0
- data/test_support/features/step_definitions/user_steps.rb +5 -0
- data/test_support/features/step_definitions/web_steps.rb +213 -0
- data/test_support/features/support/env.rb +67 -0
- data/test_support/features/support/paths.rb +76 -0
- data/test_support/features/support/selectors.rb +40 -0
- data/test_support/fixtures/atrium_exhibits.yml +3 -0
- data/test_support/spec/controllers/atrium/base_controller_spec.rb +13 -0
- data/test_support/spec/controllers/atrium/collection_exhibit_order_controller_spec.rb +29 -0
- data/test_support/spec/controllers/atrium/collections_controller_spec.rb +185 -0
- data/test_support/spec/controllers/atrium/customization_controller_spec.rb +38 -0
- data/test_support/spec/controllers/atrium/descriptions_controller_spec.rb +150 -0
- data/test_support/spec/controllers/atrium/exhibit_facet_order_controller_spec.rb +36 -0
- data/test_support/spec/controllers/atrium/exhibits_controller_spec.rb +192 -0
- data/test_support/spec/controllers/atrium/showcases_controller_spec.rb +185 -0
- data/test_support/spec/helpers/atrium_collections_helper_spec.rb +147 -0
- data/test_support/spec/helpers/atrium_description_helper_spec.rb +47 -0
- data/test_support/spec/helpers/atrium_solr_helper_spec.rb +512 -0
- data/test_support/spec/models/atrium/browse_level_spec.rb +31 -0
- data/test_support/spec/models/atrium/collection_spec.rb +30 -0
- data/test_support/spec/models/atrium/description_spec.rb +67 -0
- data/test_support/spec/models/atrium/essay_spec.rb +12 -0
- data/test_support/spec/models/atrium/exhibit_spec.rb +76 -0
- data/test_support/spec/models/atrium/search/facet_selection_spec.rb +24 -0
- data/test_support/spec/models/atrium/search/facet_spec.rb +11 -0
- data/test_support/spec/models/atrium/search_facet_spec.rb +54 -0
- data/test_support/spec/models/atrium/showcase/facet_selection_spec.rb +15 -0
- data/test_support/spec/models/atrium/showcase/item_spec.rb +12 -0
- data/test_support/spec/models/atrium/showcase_facet_selection_spec.rb +65 -0
- data/test_support/spec/models/atrium/showcase_spec.rb +134 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/routing/atrium/collections_routing_spec.rb +33 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +47 -0
- data/test_support/spec/support/be_accessible_matcher.rb +8 -0
- data/test_support/spec/support/be_routed_mixin.rb +7 -0
- data/test_support/tmp/step_definitions/catalog_index_steps.rb +14 -0
- data/test_support/tmp/step_definitions/edit_document_steps.rb +67 -0
- data/test_support/tmp/step_definitions/hydra_metadata_steps.rb +3 -0
- data/test_support/tmp/step_definitions/hydra_steps.rb +8 -0
- data/test_support/tmp/step_definitions/search_steps.rb +86 -0
- data/test_support/tmp/step_definitions/searching_steps.rb +22 -0
- data/test_support/tmp/step_definitions/select_steps.rb +8 -0
- data/test_support/tmp/step_definitions/show_document_steps.rb +73 -0
- data/test_support/tmp/step_definitions/user_steps.rb +15 -0
- data/test_support/tmp/step_definitions/web_steps.rb +273 -0
- data/test_support/tmp/support/env.rb +54 -0
- data/test_support/tmp/support/paths.rb +57 -0
- metadata +1047 -0
@@ -0,0 +1,139 @@
|
|
1
|
+
module Atrium::CollectionsHelper
|
2
|
+
|
3
|
+
# Standard display of a facet value in a list. Used in both _facets sidebar
|
4
|
+
# partial and catalog/facet expanded list. Will output facet value name as
|
5
|
+
# a link to add that to your restrictions, with count in parens.
|
6
|
+
# first arg item is a facet value item from rsolr-ext.
|
7
|
+
# options consist of:
|
8
|
+
# :suppress_link => true # do not make it a link, used for an already selected value for instance
|
9
|
+
def get_browse_facet_path(facet_solr_field, value, browse_facets, exhibit_number, exhibit_id, opts={})
|
10
|
+
p = HashWithIndifferentAccess.new
|
11
|
+
p.merge!(:f=>params[:f].dup) if params[:f]
|
12
|
+
if params[:collection_id]
|
13
|
+
#p.merge!(:id=>params[:collection_id])
|
14
|
+
p.merge!(:collection_id=>params[:collection_id])
|
15
|
+
elsif params[:id] && params[:controller] == "atrium_collections"
|
16
|
+
#p.merge!(:id=>params[:id])
|
17
|
+
p.merge!(:collection_id=>params[:id])
|
18
|
+
#p.merge!(:controller=>params[:controller])
|
19
|
+
end
|
20
|
+
#if params[:edit_showcase]
|
21
|
+
# p.merge!(:edit_showcase=>true)
|
22
|
+
#end
|
23
|
+
p.merge!(:id=>exhibit_id)
|
24
|
+
p = remove_related_facet_params(facet_solr_field, p, browse_facets, exhibit_number)
|
25
|
+
p = add_browse_facet_params(facet_solr_field,value,p)
|
26
|
+
#it should only return a path for current facet selection plus parent selected values so if generating for multiple levels, than need to ignore some potentially
|
27
|
+
#params[:action] == "edit" ? edit_atrium_collection_path(p.merge!({:class=>"browse_facet_select"})) : atrium_collection_path(p.merge!({:class=>"browse_facet_select"}))
|
28
|
+
atrium_exhibit_path(p.merge!({:class=>"browse_facet_select"}))
|
29
|
+
end
|
30
|
+
|
31
|
+
def add_browse_facet_params(field, value, p=HashWithIndifferentAccess.new)
|
32
|
+
p[:f]||={}
|
33
|
+
p[:f][field] ||= []
|
34
|
+
p[:f][field].push(value)
|
35
|
+
p
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_exhibit_set_number(exhibit_id)
|
39
|
+
Atrium::Exhibit.find(exhibit_id).set_number
|
40
|
+
end
|
41
|
+
|
42
|
+
# Standard display of a SELECTED facet value, no link, special span
|
43
|
+
# with class, and 'remove' button.
|
44
|
+
def get_selected_browse_facet_path(facet_solr_field, value, browse_facets, exhibit_number, exhibit_id, opts={})
|
45
|
+
value = [value] unless value.is_a? Array
|
46
|
+
p = HashWithIndifferentAccess.new
|
47
|
+
p.merge!(:f=>params[:f].dup) if params[:f]
|
48
|
+
p = remove_related_facet_params(facet_solr_field, p, browse_facets, exhibit_number)
|
49
|
+
if params[:collection_id]
|
50
|
+
p.merge!(:id=>params[:collection_id])
|
51
|
+
p.merge!(:collection_id=>params[:collection_id])
|
52
|
+
elsif params[:id] && params[:controller] == "atrium_collections"
|
53
|
+
p.merge!(:id=>params[:id])
|
54
|
+
p.merge!(:collection_id=>params[:id])
|
55
|
+
p.merge!(:controller=>params[:controller])
|
56
|
+
end
|
57
|
+
#if params[:edit_showcase]
|
58
|
+
# p.merge!(:edit_showcase=>true)
|
59
|
+
#end
|
60
|
+
p.merge!(:id=>exhibit_id)
|
61
|
+
# params[:action] == "edit" ? edit_atrium_collection_path(p) : atrium_collection_path(p)
|
62
|
+
atrium_exhibit_path(p)
|
63
|
+
end
|
64
|
+
|
65
|
+
#Remove current selected facet plus any child facets selected
|
66
|
+
def remove_related_facet_params(solr_facet_field, p, browse_facets, exhibit_number)
|
67
|
+
if params[:exhibit_number] && params[:exhibit_number].to_i != exhibit_number.to_i
|
68
|
+
p.delete(:f) if p[:f]
|
69
|
+
elsif browse_facets.include?(solr_facet_field)
|
70
|
+
#iterate through browseable facets from current on down
|
71
|
+
index = browse_facets.index(solr_facet_field)
|
72
|
+
if p[:f]
|
73
|
+
browse_facets.slice(index, browse_facets.length - index).each do |f|
|
74
|
+
p[:f].delete(f)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
p
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_selected_browse_facets(browse_facets)
|
82
|
+
selected = {}
|
83
|
+
if params[:f]
|
84
|
+
browse_facets.each do |facet|
|
85
|
+
selected.merge!({facet.to_sym=>params[:f][facet].first}) if params[:f][facet]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
selected
|
89
|
+
end
|
90
|
+
|
91
|
+
def grouped_result_count(response, facet_name=nil, facet_value=nil)
|
92
|
+
if facet_name && facet_value
|
93
|
+
facet = response.facets.detect {|f| f.name == facet_name}
|
94
|
+
facet_item = facet.items.detect {|i| i.value == facet_value} if facet
|
95
|
+
count = facet_item ? facet_item.hits : 0
|
96
|
+
else
|
97
|
+
count = response.docs.total
|
98
|
+
end
|
99
|
+
pluralize(count, 'document')
|
100
|
+
end
|
101
|
+
|
102
|
+
def get_collections_list
|
103
|
+
Atrium::Collection.find(:all)
|
104
|
+
end
|
105
|
+
|
106
|
+
# Return the link to browse an collection
|
107
|
+
# @return [String] a formatted url to be used in href's etc.
|
108
|
+
def browse_collection_link
|
109
|
+
atrium_collection_path(get_collection_id)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns the current collection id in the parameters.
|
113
|
+
# If the current controller is atrium_collections it expects the collection id to be in params[:id]
|
114
|
+
# Otherwise, it expects it to be in params[:collection_id]
|
115
|
+
# @return [String] the collection id
|
116
|
+
def get_collection_id
|
117
|
+
params[:controller] == "atrium_collections" ? params[:id] : params[:collection_id]
|
118
|
+
end
|
119
|
+
|
120
|
+
# Return the link to edit an collection
|
121
|
+
# @param [String] a css class to use in the link if necessary
|
122
|
+
# @return [String] a formatted url to be used in href's etc.
|
123
|
+
def edit_collection_link(css_class=nil)
|
124
|
+
edit_atrium_collection_path(get_collection_id, :class => css_class, :render_search=>"false")
|
125
|
+
end
|
126
|
+
|
127
|
+
def get_customize_page_path
|
128
|
+
if params[:controller] == "atrium/exhibits"
|
129
|
+
exhibit=Atrium::Exhibit.find(params[:id])
|
130
|
+
path = new_atrium_exhibit_showcases_path(exhibit, :facet_selection => params[:f])
|
131
|
+
elsif params[:controller] == "atrium/collections"
|
132
|
+
collection=Atrium::Collection.find(params[:id])
|
133
|
+
path= new_atrium_collection_showcases_path(collection)
|
134
|
+
end
|
135
|
+
return path
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Atrium::DescriptionsHelper
|
2
|
+
|
3
|
+
def get_description_for_showcase(showcase)
|
4
|
+
solr_desc_arr=[]
|
5
|
+
showcase.descriptions.each do |desc|
|
6
|
+
solr_desc_arr<< desc.description_solr_id unless desc.description_solr_id.blank?
|
7
|
+
end
|
8
|
+
@description_hash={}
|
9
|
+
unless solr_desc_arr.empty?
|
10
|
+
p = params.dup
|
11
|
+
params.delete :f
|
12
|
+
params.delete :q
|
13
|
+
desc_response, desc_documents = get_solr_response_for_field_values("id",solr_desc_arr.uniq)
|
14
|
+
desc_documents.each do |doc|
|
15
|
+
@description_hash[doc["id"]]= doc["description_content_s"].blank? ? "" : doc["description_content_s"].first
|
16
|
+
end
|
17
|
+
params.merge!(:f=>p[:f])
|
18
|
+
params.merge!(:q=>p[:q])
|
19
|
+
end
|
20
|
+
return @description_hash
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "atrium"
|
2
|
+
require "rails"
|
3
|
+
module Atrium
|
4
|
+
class Engine < Rails::Engine
|
5
|
+
|
6
|
+
# AtriumHelper is needed by all helpers, so we inject it
|
7
|
+
# into action view base here.
|
8
|
+
initializer 'atrium.helpers' do |app|
|
9
|
+
ActionView::Base.send :include, Atrium::BaseHelper
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This module is a controller level mixin that helps render the appropriate layout for the given context
|
2
|
+
module Atrium::LayoutHelper
|
3
|
+
def current_layout
|
4
|
+
@atrium_collection ? @atrium_collection.theme_path : 'atrium'
|
5
|
+
end
|
6
|
+
|
7
|
+
def collection_theme_if_present
|
8
|
+
unless params[:collection_id].blank?
|
9
|
+
@atrium_collection ||= Atrium::Collection.find(params[:collection_id])
|
10
|
+
end
|
11
|
+
current_layout
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
module Atrium
|
3
|
+
class Routes
|
4
|
+
|
5
|
+
def initialize(router, options)
|
6
|
+
@router = router
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def draw
|
11
|
+
route_sets.each do |r|
|
12
|
+
self.send(r)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def add_routes &blk
|
19
|
+
@router.instance_exec(@options, &blk)
|
20
|
+
end
|
21
|
+
|
22
|
+
def route_sets
|
23
|
+
(@options[:only] || default_route_sets) - (@options[:except] || [])
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_route_sets
|
27
|
+
[:atrium_collections, :catalog, :get]
|
28
|
+
end
|
29
|
+
|
30
|
+
module RouteSets
|
31
|
+
|
32
|
+
def atrium_collections
|
33
|
+
add_routes do |options|
|
34
|
+
namespace :atrium do
|
35
|
+
resources :collections, :exhibits do
|
36
|
+
resource :showcases, :only => [:new]
|
37
|
+
end
|
38
|
+
resources :showcases, :only => [:show]
|
39
|
+
resources :descriptions do
|
40
|
+
resource :essays
|
41
|
+
end
|
42
|
+
end
|
43
|
+
match 'atrium_collections/:id/exhibit_order', :to => 'atrium/collection_exhibit_order#index', :as => 'atrium_collection_exhibit_order'
|
44
|
+
match 'atrium_collections/:id/exhibit_order/update', :to => 'atrium/collection_exhibit_order#update', :as => 'update_atrium_collection_exhibit_order', :via => :post
|
45
|
+
match 'atrium_collections/:collection_id/catalog', :to => 'catalog#index', :as => 'atrium_collection_home', :via => :get
|
46
|
+
match 'atrium_collections/configure/:id', :to => 'atrium/collections#home_page_text_config', :as => 'atrium_collection_text_configure'
|
47
|
+
match 'atrium_collections/set_scope/:id', :to => 'atrium/collections#set_collection_scope', :as => 'atrium_set_collection_scope'
|
48
|
+
match 'atrium_collections/unset_scope/:id', :to => 'atrium/collections#unset_collection_scope', :as => 'atrium_unset_collection_scope'
|
49
|
+
match 'atrium_exhibits/:id/facet_order', :to => 'atrium/exhibit_facet_order#index', :as => 'atrium_exhibit_facet_order'
|
50
|
+
match 'atrium_exhibits/:id/facet_order/update', :to => 'atrium/exhibit_facet_order#update', :as => 'update_atrium_exhibit_facet_order', :via => :post
|
51
|
+
match 'atrium_exhibits/set_scope/:id', :to => 'atrium/exhibits#set_exhibit_scope', :as => 'atrium_set_exhibit_scope'
|
52
|
+
match 'atrium_exhibits/unset_scope/:id', :to => 'atrium/exhibits#unset_exhibit_scope', :as => 'atrium_unset_exhibit_scope'
|
53
|
+
match 'atrium_exhibits/:id/showcases/:showcase_id', :to => 'atrium/exhibits#show', :as => 'atrium_exhibit_showcase'
|
54
|
+
match 'atrium_showcases/featured/:id', :to => 'atrium/showcases#featured', :as => 'atrium_showcase_featured'
|
55
|
+
match 'atrium_showcases/refresh/:id', :to => 'atrium/showcases#refresh_showcase', :as => 'atrium_showcase_refresh'
|
56
|
+
match 'atrium_collections/:collection_id/catalog/:id', :to => 'catalog#show', :as => 'atrium_collection_catalog'
|
57
|
+
match 'atrium_collections/:collection_id/browse/:id', :to => 'catalog#show', :as => 'atrium_collection_browse', :defaults=>{:atrium_collection_browse=>true}
|
58
|
+
match 'atrium_collections/:collection_id/exhibits/:exhibit_id/browse/:id', :to => 'catalog#show', :as => 'atrium_collection_exhibit_browse', :defaults=>{:atrium_exhibit_browse=>true}
|
59
|
+
match 'atrium_collections/:id/showcases/:showcase_id', :to => 'atrium/collections#show', :as => 'atrium_collection_showcase'
|
60
|
+
match 'atrium_exhibits/:exhibit_id/browse/:id', :to => 'catalog#show', :as => 'atrium_exhibit_browse', :defaults=>{:atrium_exhibit_browse=>true}
|
61
|
+
match 'atrium_showcases/:showcase_id/descriptions', :to => 'atrium/descriptions#index', :as => 'atrium_descriptions', :via => :get
|
62
|
+
match 'atrium_showcases/:showcase_id/descriptions', :to => 'atrium/descriptions#create', :as => 'atrium_descriptions', :via => :post
|
63
|
+
match 'atrium_showcases/:showcase_id/descriptions/new', :to => 'atrium/descriptions#new', :as => 'new_atrium_description'
|
64
|
+
match 'atrium/customization/start', :to => 'atrium/customization#start', :as => 'start_atrium_customization'
|
65
|
+
match 'atrium/customization/stop', :to => 'atrium/customization#stop', :as => 'stop_atrium_customization'
|
66
|
+
match 'atrium_descriptions/add/:showcase_id', :to => 'atrium/descriptions#add_from_solr', :as => 'atrium_descriptions_add'
|
67
|
+
match 'atrium_descriptions/link/:showcase_id', :to => 'atrium/descriptions#save_ids_to_descriptions', :as => 'atrium_descriptions_link'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def catalog
|
72
|
+
add_routes do |options|
|
73
|
+
match 'catalog/:id/edit', :to => 'catalog#edit', :as => 'edit_catalog'
|
74
|
+
# The delete method renders a confirmation page with a button to submit actual destroy request
|
75
|
+
match 'catalog/:id/delete', :to => 'catalog#delete', :as => 'delete_catalog'
|
76
|
+
### The rest of these routes are defined in blacklight
|
77
|
+
#resources :catalog, :id=> /.+/
|
78
|
+
# resources :catalog, :only => [:index, :show], :controller => "hydra_head/catalog", :path_prefix => HydraHead::Engine.config.mount_at, :as => "hydra_head", :id=> /.+/
|
79
|
+
#match 'catalog/:id', :to => "hydra_head/catalog#show", :path_prefix => HydraHead::Engine.config.mount_at, :as => "catalog", :id => /.+/
|
80
|
+
#match 'catalog/:id', :to => "hydra_head/catalog#show", :id => /.+/
|
81
|
+
# match 'about', :to => 'catalog#about', :as => 'about'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
def get
|
87
|
+
add_routes do |options|
|
88
|
+
resources :get, :only=>:show
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
include RouteSets
|
95
|
+
|
96
|
+
#match 'generic_contents_object/content/:container_id', :to => 'generic_content_objects#create', :as => 'generic_content_object', :via => :post
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,440 @@
|
|
1
|
+
# This module is a controller level mixin that uses Blacklight::SolrHelper to make calls to solr in an collection context
|
2
|
+
module Atrium::SolrHelper
|
3
|
+
|
4
|
+
def grouped_result_count(response, facet_name=nil, facet_value=nil)
|
5
|
+
if facet_name && facet_value
|
6
|
+
facet = response.facets.detect {|f| f.name == facet_name}
|
7
|
+
facet_item = facet.items.detect {|i| i.value == facet_value} if facet
|
8
|
+
count = facet_item ? facet_item.hits : 0
|
9
|
+
else
|
10
|
+
count = response.docs.total
|
11
|
+
end
|
12
|
+
pluralize(count, 'document')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return the link to browse an collection
|
16
|
+
# @return [String] a formatted url to be used in href's etc.
|
17
|
+
def browse_collection_link
|
18
|
+
atrium_collection_path(get_collection_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the current collection id in the parameters.
|
22
|
+
# If the current controller is atrium_collections it expects the collection id to be in params[:id]
|
23
|
+
# Otherwise, it expects it to be in params[:collection_id]
|
24
|
+
# @return [String] the collection id
|
25
|
+
def get_collection_id
|
26
|
+
params[:controller] == "atrium_collections" ? params[:id] : params[:collection_id]
|
27
|
+
end
|
28
|
+
|
29
|
+
# Return the link to edit an collection
|
30
|
+
# @param [String] a css class to use in the link if necessary
|
31
|
+
# @return [String] a formatted url to be used in href's etc.
|
32
|
+
def edit_collection_link(css_class=nil)
|
33
|
+
edit_atrium_collection_path(get_collection_id, :class => css_class, :render_search=>"false")
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns the current atrium_collection instance variable
|
37
|
+
# @return [Atrium::Collection]
|
38
|
+
def atrium_collection
|
39
|
+
@atrium_collection
|
40
|
+
end
|
41
|
+
|
42
|
+
# Returns the current exhibit instance variable
|
43
|
+
# @return [Atrium::Exhibit]
|
44
|
+
def exhibit
|
45
|
+
@exhibit
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns the current browse_levels instance variable
|
49
|
+
# @return [Array] Array of Atrium::BrowseLevel for current Atrium::Collection
|
50
|
+
def exhibits
|
51
|
+
@exhibits
|
52
|
+
end
|
53
|
+
|
54
|
+
# Returns the current Blacklight solr response for results that should be displayed in current browse navigation scope
|
55
|
+
# @return [RSolr::Ext::Response]
|
56
|
+
def browse_response
|
57
|
+
@browse_response
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns the current document list from Blacklight solr response for results that should be displayed in current browse navigation scope
|
61
|
+
# @return [Array] array of SolrDocument returned by search result
|
62
|
+
def browse_document_list
|
63
|
+
@browse_document_list
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns the current extra controller params used in the query to Solr for Browsing response results
|
67
|
+
# @return [Hash]
|
68
|
+
def current_extra_controller_params
|
69
|
+
@extra_controller_params
|
70
|
+
end
|
71
|
+
|
72
|
+
# Initialize the collection and browse instance variables for a current collection scope. To initialize
|
73
|
+
# anything it expects params[:id] to the be collection id if the current controller is "atrium_collections".
|
74
|
+
# If it sees params[:collection_id] defined that will be used. If neither are present then nothing will
|
75
|
+
# be initialized.
|
76
|
+
# If possibled the following will be initialized:
|
77
|
+
# @atrium_collection [Atrium::Collection] The collection object
|
78
|
+
# @browse_levels [Array] The array of Atrium::BrowseLevel objects for this collection
|
79
|
+
# @browse_response [Solr::Response] The response from solr for current collection browse scope (will include any filters/facets applied by browse)
|
80
|
+
# @browse_document_list [Array] An array of SolrDocuments for the current browse scope
|
81
|
+
#
|
82
|
+
def __initialize_collection(collection_id)
|
83
|
+
|
84
|
+
unless collection_id
|
85
|
+
logger.error("Could not initialize collection. If controller is 'atrium_collections' than :id must be defined. Otherwise, :collection_id must be defined. Params were: #{params.inspect}")
|
86
|
+
return
|
87
|
+
end
|
88
|
+
|
89
|
+
begin
|
90
|
+
@atrium_collection = Atrium::Collection.find(collection_id) if @atrium_collection.nil?
|
91
|
+
#raise "No collection was found with id: #{collection_id}" if @atrium_collection.nil?
|
92
|
+
@exhibits = @atrium_collection.exhibits
|
93
|
+
if params[:exhibit_number]
|
94
|
+
exhibit_index = params[:exhibit_number].to_i
|
95
|
+
@exhibit = @exhibits.fetch(exhibit_index-1) if @exhibits && exhibit_index && exhibit_index <= @exhibits.size
|
96
|
+
elsif params[:exhibit_id]
|
97
|
+
@exhibit = Atrium::Exhibit.find(params[:exhibit_id])
|
98
|
+
end
|
99
|
+
##logger.debug("Collection: #{@atrium_collection}")
|
100
|
+
@extra_controller_params ||= {}
|
101
|
+
params[:browse_level_id] ? @browse_level = Atrium::BrowseLevel.find(params[:browse_level_id]): @browse_level = get_current_browse_level(@exhibit)
|
102
|
+
@extra_controller_params = prepare_extra_controller_params_for_collection_query(@atrium_collection,@exhibit,@browse_level,params,@extra_controller_params)
|
103
|
+
(@response, @document_list) = get_search_results(params, @extra_controller_params)
|
104
|
+
@images = get_all_children(@document_list, "is_part_of_s")
|
105
|
+
#@members = get_all_children(@document_list, "is_member_of_s")
|
106
|
+
#reset to just filters in collection filter
|
107
|
+
@extra_controller_params = reset_extra_controller_params_after_collection_query(@atrium_collection,@exhibit,@browse_level,@extra_controller_params)
|
108
|
+
@browse_response = @response
|
109
|
+
@browse_document_list = @document_list
|
110
|
+
##logger.debug("Collection: #{@atrium_collection}, Exhibit: #{@atrium_collection.exhibits}")
|
111
|
+
@collection_showcase = Atrium::Showcase.with_selected_facets(@atrium_collection.id,@atrium_collection.class.name, params[:f]).first
|
112
|
+
##logger.debug("Collection level showcase: #{@collection_showcase.inspect}")
|
113
|
+
rescue Exception=>e
|
114
|
+
logger.error("Could not initialize collection information for id #{collection_id}. Reason - #{e.to_s}")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# added as part of solr search params to exclude items from search result
|
119
|
+
# as :f, to solr as appropriate :fq query.
|
120
|
+
def add_exclude_fq_to_solr(solr_parameters, user_params)
|
121
|
+
# :fq, map from :f.
|
122
|
+
##logger.debug("Solr exclude!!!: #{solr_parameters.inspect}, #{user_params.inspect}")
|
123
|
+
if ( user_params[:exclude])
|
124
|
+
exclude_request_params = user_params[:exclude]
|
125
|
+
##logger.debug("user_params[:exclude]!!!: #{user_params[:exclude].inspect}")
|
126
|
+
solr_parameters[:fq] ||= []
|
127
|
+
exclude_request_params.each_pair do |facet_field, value_list|
|
128
|
+
value_list ||= []
|
129
|
+
value_list = [value_list] unless value_list.respond_to? :each
|
130
|
+
value_list.each do |value|
|
131
|
+
exclude_query="-(#{facet_value_to_fq_string(facet_field, value)})"
|
132
|
+
solr_parameters[:fq] << exclude_query
|
133
|
+
##logger.debug("Solr exclude!!!: #{exclude_query.inspect}, #{solr_parameters.inspect}, #{user_params.inspect}")
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def get_current_filter_query_params(collection,exhibit,browse_level)
|
140
|
+
#params[:exclude]={:f=>{"collection_0_did_0_unittitle_0_imprint_0_publisher_facet"=>["Continental Currency"]}}
|
141
|
+
filter_query_params = nil
|
142
|
+
ex_filter_query_params = solr_search_params(collection.filter_query_params) if collection && !collection.filter_query_params.nil?
|
143
|
+
exhibit_filter_query_params = solr_search_params(exhibit.filter_query_params) if exhibit && !exhibit.filter_query_params.nil?
|
144
|
+
bl_filter_query_params = solr_search_params(browse_level.filter_query_params) if browse_level && !browse_level.filter_query_params.nil?
|
145
|
+
bl_exclude_query_params = solr_search_params(browse_level.exclude_query_params) if browse_level && !browse_level.exclude_query_params.nil?
|
146
|
+
##logger.debug("##### Exclude: #{bl_exclude_query_params.inspect}")
|
147
|
+
queries = []
|
148
|
+
queries << ex_filter_query_params[:q] if (ex_filter_query_params && ex_filter_query_params[:q])
|
149
|
+
queries << exhibit_filter_query_params[:q] if (exhibit_filter_query_params && exhibit_filter_query_params[:q])
|
150
|
+
queries << bl_filter_query_params[:q] if (bl_filter_query_params && bl_filter_query_params[:q])
|
151
|
+
fq = []
|
152
|
+
fq.concat(ex_filter_query_params[:fq]) if (ex_filter_query_params && ex_filter_query_params[:fq])
|
153
|
+
#mixin exhibit facet filters
|
154
|
+
if exhibit_filter_query_params && exhibit_filter_query_params[:fq]
|
155
|
+
exhibit_filter_query_params[:fq].each do |fq_param|
|
156
|
+
fq << fq_param unless fq.include?(fq_param)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
#mixin browse level facet filters
|
160
|
+
if bl_filter_query_params && bl_filter_query_params[:fq]
|
161
|
+
bl_filter_query_params[:fq].each do |fq_param|
|
162
|
+
fq << fq_param unless fq.include?(fq_param)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
if bl_exclude_query_params && bl_exclude_query_params[:fq]
|
166
|
+
bl_exclude_query_params[:fq].each do |fq_exclude_param|
|
167
|
+
fq << fq_exclude_param unless fq.include?(fq_exclude_param)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
unless fq.empty? && queries.empty?
|
172
|
+
filter_query_params = {}
|
173
|
+
filter_query_params.merge!(:fq=>fq) unless fq.empty?
|
174
|
+
filter_query_params.merge!(:q=>queries.join(" AND ")) unless queries.empty?
|
175
|
+
end
|
176
|
+
filter_query_params
|
177
|
+
end
|
178
|
+
|
179
|
+
# This method will get extra controller params that are necessary to apply an
|
180
|
+
# collection scope filter. If there are facets selected in the collection filter and
|
181
|
+
# a menu item is selected it will combine the facet selection from params into
|
182
|
+
# extra controller params to ensure that both are in the query correctly.
|
183
|
+
|
184
|
+
def prepare_extra_controller_params_for_collection_query(collection,exhibit,browse_level,params, extra_controller_params)
|
185
|
+
extra_controller_params ||= {}
|
186
|
+
filter_query_params = get_current_filter_query_params(collection,exhibit,browse_level)
|
187
|
+
queries = []
|
188
|
+
#build_lucene_query will be defined if hydra is present to add hydra rights into query etc, otherwise it will be ignored
|
189
|
+
queries << build_lucene_query(params[:q]) if respond_to?(:build_lucene_query)
|
190
|
+
queries << filter_query_params[:q] if (filter_query_params && filter_query_params[:q])
|
191
|
+
queries << params[:q] if params[:q]
|
192
|
+
queries.empty? ? q = params[:q] : q = queries.join(" AND ")
|
193
|
+
extra_controller_params.merge!(:q=>q) unless q.nil?
|
194
|
+
extra_controller_params.merge!(:fq=>filter_query_params[:fq]) if filter_query_params && filter_query_params[:fq]
|
195
|
+
#merge in user params before doing query to correctly handle facets in both extra controller params and params
|
196
|
+
if (extra_controller_params && extra_controller_params[:fq])
|
197
|
+
session_search_params = solr_search_params(params)
|
198
|
+
if session_search_params[:fq]
|
199
|
+
extra_controller_params[:fq].each do |extra_param|
|
200
|
+
#only add if it is not already in params
|
201
|
+
session_search_params[:fq] << extra_param unless session_search_params[:fq].include?(extra_param)
|
202
|
+
end
|
203
|
+
extra_controller_params.merge!(:fq=>session_search_params[:fq])
|
204
|
+
end
|
205
|
+
end
|
206
|
+
extra_controller_params
|
207
|
+
end
|
208
|
+
|
209
|
+
def reset_extra_controller_params_after_collection_query(collection,exhibit,browse_level,extra_controller_params)
|
210
|
+
extra_controller_params ||= {}
|
211
|
+
filter_query_params = get_current_filter_query_params(collection,exhibit,browse_level)
|
212
|
+
extra_controller_params.merge!(:fq=>filter_query_params[:fq]) if filter_query_params && filter_query_params[:fq]
|
213
|
+
extra_controller_params
|
214
|
+
end
|
215
|
+
|
216
|
+
# Returns an array of Atrium::Exhibit objects with its BrowseLevel objects populated with current display
|
217
|
+
# data. It is expected that it will be used for generating current navigation controls when browsing an collection.
|
218
|
+
# All possible browse levels will be present but values will only be filled in for levels that should be
|
219
|
+
# in view. It will fill in values for the top browse level, and then will only fill in values for the second browse level
|
220
|
+
# if something is selected, and so on for any deeper browse levels. If no label is defined
|
221
|
+
# for a browse level, it will fill in the default label for the browse level facet.
|
222
|
+
# If nothing is selected in the first level, there will be no second element. This pattern
|
223
|
+
# continues as it maintains the state for a user drilling into the content by expanding and collapses
|
224
|
+
# browse category values at each browse level. This method calls get_browse_level_data
|
225
|
+
# to actually retrieve the array of data after it makes sure a response for browse information
|
226
|
+
# has come back from Blacklight Solr
|
227
|
+
# @return [Array] An array of Atrium::Exhibit objects defind for an collection with BrowseLevel objects populated with view data
|
228
|
+
# @example Get First Browse Level data
|
229
|
+
# You would access the first level of the first browse set as follows:
|
230
|
+
#
|
231
|
+
# top_browse_level = exhibits.first.browse_levels.first
|
232
|
+
# #get menu values to display
|
233
|
+
# top_browse_level.values
|
234
|
+
# #get label for the browse category
|
235
|
+
# top_browse_level.label
|
236
|
+
# #check if level has a selected value
|
237
|
+
# top_browse_level.selected?
|
238
|
+
#
|
239
|
+
# One should use the above methods to generate data for expand/collapse controls, breadcrumbs, etc.
|
240
|
+
def get_exhibit_navigation_data
|
241
|
+
##logger.debug("get_exhibit_navigation_data browse response: #{browse_response.inspect}")
|
242
|
+
initialize_collection if atrium_collection.nil?
|
243
|
+
browse_data = []
|
244
|
+
unless atrium_collection.nil? || atrium_collection.exhibits.nil?
|
245
|
+
atrium_collection.exhibits.each do |exhibit|
|
246
|
+
if exhibit.respond_to?(:browse_levels) && !exhibit.browse_levels.nil?
|
247
|
+
updated_browse_levels = get_browse_level_data(atrium_collection,exhibit,exhibit.browse_levels,browse_response,current_extra_controller_params,true)
|
248
|
+
##logger.debug("Updated Browse Levels: #{updated_browse_levels.inspect}")
|
249
|
+
exhibit.browse_levels.each_index do |index|
|
250
|
+
##logger.debug("#{exhibit.browse_levels.inspect}")
|
251
|
+
exhibit.browse_levels.fetch(index).values = updated_browse_levels.fetch(index).values
|
252
|
+
exhibit.browse_levels.fetch(index).label = updated_browse_levels.fetch(index).label
|
253
|
+
exhibit.browse_levels.fetch(index).selected = updated_browse_levels.fetch(index).selected
|
254
|
+
end
|
255
|
+
exhibit.browse_levels.flatten!(1)
|
256
|
+
browse_data << exhibit
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
##logger.debug("Before BrowseData: #{browse_data.inspect}")
|
261
|
+
|
262
|
+
browse_data=[] if check_for_scope(browse_data)
|
263
|
+
@exhibit_navigation_data=browse_data
|
264
|
+
|
265
|
+
##logger.debug("After BrowseData: #{browse_data.inspect}")
|
266
|
+
browse_data
|
267
|
+
end
|
268
|
+
|
269
|
+
private
|
270
|
+
|
271
|
+
def check_for_scope(exhibit_list)
|
272
|
+
scoped_to_items=false
|
273
|
+
if atrium_collection && atrium_collection.filter_query_params && atrium_collection.filter_query_params[:solr_doc_ids]
|
274
|
+
scoped_to_items=true
|
275
|
+
end
|
276
|
+
return scoped_to_items
|
277
|
+
end
|
278
|
+
|
279
|
+
# This is a private method and should not be called directly.
|
280
|
+
# get_exhibit_navigation_data calls this method to fill out the browse_level_navigation_data array
|
281
|
+
# This method calls itself recursively as it generates the current browse state data.
|
282
|
+
# It returns the browse levels array with its browse level objects passed in updated
|
283
|
+
# with any values, label, and selected value if one is selected. It will fill in values
|
284
|
+
# for the top browse level, and then will only fill in values for the second browse level
|
285
|
+
# if something is selected, and so on for any deeper browse levels. If no label is defined
|
286
|
+
# for a browse level, it will fill in the default label for the browse level facet.
|
287
|
+
# @param [Atrium::Collection] The current collection
|
288
|
+
# @param [Atrium::Exhibit] the current exhibit
|
289
|
+
# @params [Array] The current browse levels (will reduce as this method recurses)
|
290
|
+
# @param [SolrResponse] the browse response from solr
|
291
|
+
# @param [Hash] the extra controller params that need to be passed to solr if we query for another response if necessary to get child level data
|
292
|
+
# @param [Boolean] true if the top level of the exhibit
|
293
|
+
# @return [Array] An array of update BrowseLevel objects that are enhanced with current navigation data such as selected, values, and label filled in
|
294
|
+
# The relevant attributes of a BrowseLevel are
|
295
|
+
# :solr_facet_name [String] the facet used as the category for that browse level
|
296
|
+
# :label [String] browse level category label
|
297
|
+
# :values [Array] values to display for the browse level
|
298
|
+
# :selected [String] the selected value if one
|
299
|
+
def get_browse_level_data(collection, exhibit, browse_levels, response, extra_controller_params={},top_level=false)
|
300
|
+
exhibit_number = exhibit.set_number
|
301
|
+
updated_browse_levels = []
|
302
|
+
unless browse_levels.nil? || browse_levels.empty?
|
303
|
+
browse_level = browse_levels.first
|
304
|
+
browse_facet_name = browse_level.solr_facet_name
|
305
|
+
browse_level.label = facet_field_labels[browse_facet_name] if (browse_level.label.nil? || browse_level.label.blank?)
|
306
|
+
#always add whether there should be values set or not
|
307
|
+
updated_browse_levels << browse_level
|
308
|
+
if params.has_key?(:f) && !params[:f].nil?
|
309
|
+
temp = params[:f].dup
|
310
|
+
unless top_level && !params[:f][browse_facet_name] && !params[:f][browse_facet_name.to_s]
|
311
|
+
browse_levels.each_with_index do |cur_browse_level,index|
|
312
|
+
params[:f].delete(cur_browse_level.solr_facet_name)
|
313
|
+
end
|
314
|
+
else
|
315
|
+
params[:f] = {}
|
316
|
+
end
|
317
|
+
extra_controller_params = prepare_extra_controller_params_for_collection_query(collection,exhibit,browse_level,params,extra_controller_params)
|
318
|
+
(response_without_f_param, @new_document_list) = get_search_results(params,extra_controller_params)
|
319
|
+
extra_controller_params = reset_extra_controller_params_after_collection_query(collection,exhibit,browse_level,extra_controller_params)
|
320
|
+
params[:f] = temp
|
321
|
+
else
|
322
|
+
extra_controller_params = prepare_extra_controller_params_for_collection_query(collection,exhibit,browse_level,params,extra_controller_params)
|
323
|
+
(response_without_f_param, @new_document_list) = get_search_results(params,extra_controller_params)
|
324
|
+
extra_controller_params = reset_extra_controller_params_after_collection_query(collection,exhibit,browse_level,extra_controller_params)
|
325
|
+
end
|
326
|
+
display_facet = response_without_f_param.facets.detect {|f| f.name == browse_facet_name}
|
327
|
+
display_facet_with_f = response.facets.detect {|f| f.name == browse_facet_name}
|
328
|
+
unless display_facet.nil?
|
329
|
+
level_has_selected = false
|
330
|
+
if display_facet.items.any?
|
331
|
+
display_facet.items.each do |item|
|
332
|
+
if facet_in_params?(display_facet.name, item.value )
|
333
|
+
level_has_selected = true
|
334
|
+
updated_browse_levels.first.selected = item.value
|
335
|
+
if browse_levels.length > 1
|
336
|
+
updated_browse_levels << get_browse_level_data(collection,exhibit,browse_levels.slice(1,browse_levels.length-1), response, extra_controller_params)
|
337
|
+
#make sure to flatten any nested arrays from recursive calls
|
338
|
+
updated_browse_levels.flatten!(1)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
updated_browse_levels.first.values << item.value
|
342
|
+
end
|
343
|
+
end
|
344
|
+
#check if facet_in_params and if not just add rest of levels so all are represented since nothing below will be selected
|
345
|
+
unless level_has_selected
|
346
|
+
updated_browse_levels << browse_levels.slice(1,browse_levels.length-1)
|
347
|
+
updated_browse_levels.flatten!(1)
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
updated_browse_levels
|
352
|
+
end
|
353
|
+
|
354
|
+
def get_atrium_showcase(exhibit_id, facet_hash={})
|
355
|
+
atrium_showcase= Atrium::Showcase.with_selected_facets(exhibit_id,facet_hash)
|
356
|
+
return atrium_showcase
|
357
|
+
end
|
358
|
+
|
359
|
+
# Checks if a browse level has been navigated to for a exhibit
|
360
|
+
# @param [Atrium::Exhibit] The current exhibit in view
|
361
|
+
# @return [Atrium::BrowseLevel] It will return a browse level that is selected, otherwise it will return nil
|
362
|
+
def get_current_browse_level(exhibit)
|
363
|
+
cur_browse_level = nil
|
364
|
+
if exhibit
|
365
|
+
#keep recursing until lowest level that has a facet selected is found
|
366
|
+
exhibit.browse_levels.each do |browse_level|
|
367
|
+
cur_browse_level = browse_level if browse_level.solr_facet_name && facet_selected?(browse_level.solr_facet_name)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
cur_browse_level
|
371
|
+
end
|
372
|
+
|
373
|
+
def facet_selected?(facet_name)
|
374
|
+
params[:f].include?(facet_name) if params[:f]
|
375
|
+
end
|
376
|
+
|
377
|
+
def display_solr_essay(pid)
|
378
|
+
##logger.debug("description: #{pid.inspect}")
|
379
|
+
response, document = get_solr_response_for_doc_id(pid)
|
380
|
+
content = render_document_show_field_value :document => document, :field => 'description_content_s'
|
381
|
+
##logger.debug("Content:#{content}")
|
382
|
+
return content.html_safe
|
383
|
+
end
|
384
|
+
|
385
|
+
def get_all_children(doc_list, relationship_field_names, opts={})
|
386
|
+
@child_hash={}
|
387
|
+
parent_arr=[]
|
388
|
+
modified_arr=[]
|
389
|
+
#logger.debug("Get children for list: #{doc_list.count}")
|
390
|
+
doc_list.each_with_index do |doc, i|
|
391
|
+
parent_arr<< doc["id"] unless (doc["id"].blank?)
|
392
|
+
end
|
393
|
+
parent_arr.each do |id|
|
394
|
+
rel_id="info:fedora/#{id}"
|
395
|
+
modified_arr<< rel_id
|
396
|
+
end
|
397
|
+
#logger.debug("Get children for list: #{parent_arr.inspect}, #{modified_arr.inspect}")
|
398
|
+
p = params.dup
|
399
|
+
params.delete(:f)
|
400
|
+
params.delete(:page)
|
401
|
+
params.delete(:q)
|
402
|
+
params.delete(:fq)
|
403
|
+
params.delete(:per_page)
|
404
|
+
params[:rows] = 1000
|
405
|
+
params[:per_page] = 1000
|
406
|
+
response, response_list = get_solr_response_for_field_values(relationship_field_names,modified_arr) ##get child pages
|
407
|
+
#response, is_member_response_list = get_solr_response_for_field_values("is_member_of_s",modified_arr) ## get any child components
|
408
|
+
logger.debug("Relationship:#{relationship_field_names.inspect}, Children count:#{response_list.count}")
|
409
|
+
params.delete(:rows)
|
410
|
+
params[:f] = p[:f]
|
411
|
+
params[:page] = p[:page]
|
412
|
+
params[:q] = p[:q]
|
413
|
+
params[:fq] = p[:fq]
|
414
|
+
params[:per_page] = p[:per_page]
|
415
|
+
parent_arr.each do |parent|
|
416
|
+
##logger.debug("Processing id: #{parent.inspect}")
|
417
|
+
child_arr=[]
|
418
|
+
member_arr=[]
|
419
|
+
response_list.each do |doc|
|
420
|
+
parent_id = doc[relationship_field_names].first.split("/").last
|
421
|
+
if parent_id.eql?(parent)
|
422
|
+
#logger.debug("is_part_response_list parent #{doc[relationship_field_names.to_s].inspect}, id: #{doc["id"].inspect} ")
|
423
|
+
child_arr<<doc
|
424
|
+
end
|
425
|
+
end
|
426
|
+
#is_member_response_list.each do |doc|
|
427
|
+
# parent_id = doc["is_member_of_s"].first.split("/").last
|
428
|
+
# if parent_id.eql?(parent)
|
429
|
+
# ##logger.debug("is_member_of_s_response_list parent #{doc["is_member_of_s"].inspect}, id: #{doc["id"].inspect} ")
|
430
|
+
# member_arr<<doc
|
431
|
+
# end
|
432
|
+
#end
|
433
|
+
#@image_hash[parent]=image_arr
|
434
|
+
#@member_hash[parent]=member_arr
|
435
|
+
@child_hash[parent]=child_arr
|
436
|
+
end
|
437
|
+
#return [@image_hash, @member_hash ]
|
438
|
+
return @child_hash
|
439
|
+
end
|
440
|
+
end
|