hydra-core 6.0.0.pre7 → 6.0.0.pre8

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,7 +26,6 @@ class HeadGenerator < Rails::Generators::Base
26
26
 
27
27
  # Copy all files in templates/config directory to host config
28
28
  def create_configuration_files
29
- #CatalogController
30
29
  copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
31
30
 
32
31
  # Initializers
@@ -36,7 +35,6 @@ class HeadGenerator < Rails::Generators::Base
36
35
  "\n config[:user_model] = '#{model_name.classify}'"
37
36
  end
38
37
 
39
-
40
38
  copy_file "config/initializers/action_dispatch_http_upload_monkey_patch.rb", "config/initializers/action_dispatch_http_upload_monkey_patch.rb"
41
39
 
42
40
  # Role Mappings
@@ -46,50 +44,10 @@ class HeadGenerator < Rails::Generators::Base
46
44
  copy_file "config/role_map_test.yml", "config/role_map_test.yml"
47
45
 
48
46
  # Fedora & Solr YAML files
49
- begin
50
- invoke('active_fedora:config')
51
- rescue NoMethodError
52
- # Looks like we are falling back on the old way of doing this
53
- copy_file "config/fedora.yml", "config/fedora.yml"
54
- copy_file "config/solr.yml", "config/solr.yml"
55
- copy_file "config/jetty.yml", "config/jetty.yml"
56
- # Fedora & Solr Config files
57
- directory "fedora_conf"
58
- directory "solr_conf"
59
- end
60
- end
61
-
62
- # Register mimetypes required by hydra-head
63
- def add_mime_types
64
- puts "Updating Mime Types"
65
- insert_into_file "config/initializers/mime_types.rb", :before => 'Mime::Type.register_alias "text/plain", :refworks_marc_txt' do <<EOF
66
- # Mime Types Added By Hydra Head:
67
-
68
- # Mime::Type.register "text/html", :html
69
- # Mime::Type.register "application/pdf", :pdf
70
- # Mime::Type.register "image/jpeg2000", :jp2
71
- Mime::Type.register_alias "text/html", :textile
72
- Mime::Type.register_alias "text/html", :inline
73
-
74
- EOF
75
- end
47
+ invoke('active_fedora:config')
48
+ copy_file "config/jetty.yml", "config/jetty.yml"
76
49
  end
77
50
 
78
- #
79
- # Migrations
80
- #
81
-
82
- # Implement the required interface for Rails::Generators::Migration.
83
- # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
84
- def self.next_migration_number(dirname)
85
- unless @prev_migration_nr
86
- @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
87
- else
88
- @prev_migration_nr += 1
89
- end
90
- @prev_migration_nr.to_s
91
- end
92
-
93
51
  # Add Hydra behaviors to the user model
94
52
  def inject_hydra_user_behavior
95
53
  file_path = "app/models/#{model_name.underscore}.rb"
@@ -103,28 +61,6 @@ EOF
103
61
  end
104
62
  end
105
63
 
106
- # Add Hydra behaviors and Filters to CatalogController
107
- def inject_hydra_catalog_behavior
108
- puts "Adding Hydra behaviors to CatalogController"
109
- controller_name = "catalog_controller"
110
- file_path = "app/controllers/#{controller_name.underscore}.rb"
111
- if File.exists?(file_path)
112
- insert_into_file file_path, :after => 'include Blacklight::Catalog' do
113
- "\n # Extend Blacklight::Catalog with Hydra behaviors (primarily editing)." +
114
- "\n include Hydra::Controller::ControllerBehavior\n" +
115
- "\n # These before_filters apply the hydra access controls" +
116
- "\n before_filter :enforce_show_permissions, :only=>:show" +
117
- "\n # This applies appropriate access controls to all solr queries" +
118
- "\n CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]" +
119
- "\n # This filters out objects that you want to exclude from search results, like FileAssets" +
120
- "\n CatalogController.solr_search_params_logic += [:exclude_unwanted_models]"
121
-
122
- end
123
- else
124
- puts " \e[31mFailure\e[0m Could not find #{model_name.underscore}.rb. To add Hydra behaviors to your Blacklight::Catalog Controllers, you must include the Hydra::Controller::ControllerBehavior module in the Controller class definition. See the Hydra::Controller::ControllerBehavior section in the Hydra API Docs for more info."
125
- end
126
- end
127
-
128
64
  # Inject call to HydraHead.add_routes in config/routes.rb
129
65
  def inject_hydra_routes
130
66
  insert_into_file "config/routes.rb", :after => 'Blacklight.add_routes(self)' do
@@ -133,23 +69,5 @@ EOF
133
69
  end
134
70
  end
135
71
 
136
- # Add Hydra to the application controller
137
- def inject_hydra_controller_behavior
138
- puts "Adding Hydra behaviors to ApplicationController"
139
- controller_name = "ApplicationController"
140
- file_path = "app/controllers/#{controller_name.underscore}.rb"
141
- if File.exists?(file_path)
142
- insert_into_file file_path, :after => 'include Blacklight::Controller' do
143
- " \n# Adds Hydra behaviors into the application controller \n" +
144
- " include Hydra::Controller::ControllerBehavior\n"
145
- end
146
- else
147
- puts " \e[31mFailure\e[0m Could not find #{model_name.underscore}.rb. To add Hydra behaviors to your Blacklight::Catalog Controllers, you must include the Hydra::Controller::ControllerBehavior module in the Controller class definition. See the Hydra::Controller::ControllerBehavior section in the Hydra API Docs for more info."
148
- end
149
- end
150
-
151
-
152
-
153
-
154
72
  end # HeadGenerator
155
73
  end # Hydra
@@ -4,6 +4,14 @@ require 'blacklight/catalog'
4
4
  class CatalogController < ApplicationController
5
5
 
6
6
  include Blacklight::Catalog
7
+ include Hydra::Controller::ControllerBehavior
8
+ # These before_filters apply the hydra access controls
9
+ before_filter :enforce_show_permissions, :only=>:show
10
+ # This applies appropriate access controls to all solr queries
11
+ CatalogController.solr_search_params_logic += [:add_access_controls_to_solr_params]
12
+ # This filters out objects that you want to exclude from search results, like FileAssets
13
+ CatalogController.solr_search_params_logic += [:exclude_unwanted_models]
14
+
7
15
 
8
16
  configure_blacklight do |config|
9
17
  config.default_solr_params = {
@@ -39,13 +47,13 @@ class CatalogController < ApplicationController
39
47
  #
40
48
  # :show may be set to false if you don't want the facet to be drawn in the
41
49
  # facet bar
42
- config.add_facet_field 'object_type_tsim', :label => 'Format'
43
- config.add_facet_field 'pub_tsim', :label => 'Publication Year'
44
- config.add_facet_field 'subject_topic_tsim', :label => 'Topic', :limit => 20
45
- config.add_facet_field 'language_tsim', :label => 'Language', :limit => true
46
- config.add_facet_field 'lc_1letter_tsim', :label => 'Call Number'
47
- config.add_facet_field 'subject_geo_tsim', :label => 'Region'
48
- config.add_facet_field 'subject_era_tsim', :label => 'Era'
50
+ config.add_facet_field solr_name('object_type', :facetable), :label => 'Format'
51
+ config.add_facet_field solr_name('pub_date', :facetable), :label => 'Publication Year'
52
+ config.add_facet_field solr_name('subject_topic', :facetable), :label => 'Topic', :limit => 20
53
+ config.add_facet_field solr_name('language', :facetable), :label => 'Language', :limit => true
54
+ config.add_facet_field solr_name('lc1_letter', :facetable), :label => 'Call Number'
55
+ config.add_facet_field solr_name('subject_geo', :facetable), :label => 'Region'
56
+ config.add_facet_field solr_name('subject_era', :facetable), :label => 'Era'
49
57
 
50
58
  # Have BL send all facet field names to Solr, which has been the default
51
59
  # previously. Simply remove these lines if you'd rather use Solr request
@@ -57,32 +65,32 @@ class CatalogController < ApplicationController
57
65
 
58
66
  # solr fields to be displayed in the index (search results) view
59
67
  # The ordering of the field names is the order of the display
60
- config.add_index_field 'title_tsim', :label => 'Title:'
61
- config.add_index_field 'title_vern_tsim', :label => 'Title:'
62
- config.add_index_field 'author_tsim', :label => 'Author:'
63
- config.add_index_field 'author_vern_tsim', :label => 'Author:'
64
- config.add_index_field 'format', :label => 'Format:'
65
- config.add_index_field 'language_facet', :label => 'Language:'
66
- config.add_index_field 'published_tsim', :label => 'Published:'
67
- config.add_index_field 'published_vern_tsim', :label => 'Published:'
68
- config.add_index_field 'lc_callnum_tsim', :label => 'Call number:'
68
+ config.add_index_field solr_name('title', :stored_searchable, type: :string), :label => 'Title:'
69
+ config.add_index_field solr_name('title_vern', :stored_searchable, type: :string), :label => 'Title:'
70
+ config.add_index_field solr_name('author', :stored_searchable, type: :string), :label => 'Author:'
71
+ config.add_index_field solr_name('author_vern', :stored_searchable, type: :string), :label => 'Author:'
72
+ config.add_index_field solr_name('format', :symbol), :label => 'Format:'
73
+ config.add_index_field solr_name('language', :stored_searchable, type: :string), :label => 'Language:'
74
+ config.add_index_field solr_name('published', :stored_searchable, type: :string), :label => 'Published:'
75
+ config.add_index_field solr_name('published_vern', :stored_searchable, type: :string), :label => 'Published:'
76
+ config.add_index_field solr_name('lc_callnum', :stored_searchable, type: :string), :label => 'Call number:'
69
77
 
70
78
  # solr fields to be displayed in the show (single result) view
71
79
  # The ordering of the field names is the order of the display
72
- config.add_show_field 'title_tsim', :label => 'Title:'
73
- config.add_show_field 'title_vern_tsim', :label => 'Title:'
74
- config.add_show_field 'subtitle_tsim', :label => 'Subtitle:'
75
- config.add_show_field 'subtitle_vern_tsim', :label => 'Subtitle:'
76
- config.add_show_field 'author_tsim', :label => 'Author:'
77
- config.add_show_field 'author_vern_tsim', :label => 'Author:'
78
- config.add_show_field 'format', :label => 'Format:'
79
- config.add_show_field 'url_fulltext_tsim', :label => 'URL:'
80
- config.add_show_field 'url_suppl_tsim', :label => 'More Information:'
81
- config.add_show_field 'language_facet', :label => 'Language:'
82
- config.add_show_field 'published_tsim', :label => 'Published:'
83
- config.add_show_field 'published_vern_tsim', :label => 'Published:'
84
- config.add_show_field 'lc_callnum_tsim', :label => 'Call number:'
85
- config.add_show_field 'isbn_tsim', :label => 'ISBN:'
80
+ config.add_show_field solr_name('title', :stored_searchable, type: :string), :label => 'Title:'
81
+ config.add_show_field solr_name('title_vern', :stored_searchable, type: :string), :label => 'Title:'
82
+ config.add_show_field solr_name('subtitle', :stored_searchable, type: :string), :label => 'Subtitle:'
83
+ config.add_show_field solr_name('subtitle_vern', :stored_searchable, type: :string), :label => 'Subtitle:'
84
+ config.add_show_field solr_name('author', :stored_searchable, type: :string), :label => 'Author:'
85
+ config.add_show_field solr_name('author_vern', :stored_searchable, type: :string), :label => 'Author:'
86
+ config.add_show_field solr_name('format', :symbol), :label => 'Format:'
87
+ config.add_show_field solr_name('url_fulltext_tsim', :stored_searchable, type: :string), :label => 'URL:'
88
+ config.add_show_field solr_name('url_suppl_tsim', :stored_searchable, type: :string), :label => 'More Information:'
89
+ config.add_show_field solr_name('language', :stored_searchable, type: :string), :label => 'Language:'
90
+ config.add_show_field solr_name('published', :stored_searchable, type: :string), :label => 'Published:'
91
+ config.add_show_field solr_name('published_vern', :stored_searchable, type: :string), :label => 'Published:'
92
+ config.add_show_field solr_name('lc_callnum', :stored_searchable, type: :string), :label => 'Call number:'
93
+ config.add_show_field solr_name('isbn', :stored_searchable, type: :string), :label => 'ISBN:'
86
94
 
87
95
  # "fielded" search configuration. Used by pulldown among other places.
88
96
  # For supported keys in hash, see rdoc for Blacklight::SearchFields
@@ -20,7 +20,5 @@ if Hydra.respond_to?(:configure)
20
20
  :embargo_release_date => ActiveFedora::SolrService.solr_name("embargo_release_date", Solrizer::Descriptor.new(:date, :stored, :indexed))
21
21
  }
22
22
 
23
- # specify the user model
24
- config[:user_model] = 'User'
25
23
  end
26
24
  end
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "6.0.0.pre7"
2
+ VERSION = "6.0.0.pre8"
3
3
  end
4
4
 
@@ -34,5 +34,11 @@ module Hydra::Controller::ControllerBehavior
34
34
  def user_key
35
35
  current_user.user_key if current_user
36
36
  end
37
-
37
+
38
+ module ClassMethods
39
+ # get the solr name for a field with this name and using the given solrizer descriptor
40
+ def solr_name(name, *opts)
41
+ ActiveFedora::SolrService.solr_name(name, *opts)
42
+ end
43
+ end
38
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.pre7
4
+ version: 6.0.0.pre8
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-02-04 00:00:00.000000000 Z
13
+ date: 2013-02-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -179,7 +179,7 @@ dependencies:
179
179
  requirements:
180
180
  - - '='
181
181
  - !ruby/object:Gem::Version
182
- version: 6.0.0.pre7
182
+ version: 6.0.0.pre8
183
183
  type: :runtime
184
184
  prerelease: false
185
185
  version_requirements: !ruby/object:Gem::Requirement
@@ -187,7 +187,7 @@ dependencies:
187
187
  requirements:
188
188
  - - '='
189
189
  - !ruby/object:Gem::Version
190
- version: 6.0.0.pre7
190
+ version: 6.0.0.pre8
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: sqlite3
193
193
  requirement: !ruby/object:Gem::Requirement