hydra-core 5.0.0.pre4 → 5.0.0.pre6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,4 @@
1
1
  <%= render :partial=>'search_form' %>
2
2
  <%= render :partial=>'home_text' %>
3
3
 
4
- <% sidebar_items << capture do %>
5
- <%= render :partial=>'facets' %>
6
- <% end %>
4
+ <%= sidebar_items.join('').html_safe %>
@@ -1,6 +1,6 @@
1
- <tr class="document <%= cycle("even","odd") %>">
1
+ <tr class="document">
2
2
  <td>
3
- <%= link_to_document(document, :label => blacklight_config.show.heading.to_sym, :counter => (counter + 1 + @response.params[:start].to_i)) %>
3
+ <%= link_to_document(document, :label => blacklight_config.show.heading.to_sym) %>
4
4
  </td>
5
5
  <td>
6
6
 
@@ -12,7 +12,7 @@
12
12
  <%= document.document_type(blacklight_config.show.display_type) %>
13
13
  </td>
14
14
  <td>
15
- <%= get_file_asset_count(document)%>
15
+ <%= document.get_file_asset_count()%>
16
16
  </td>
17
17
  <td>
18
18
  Created
@@ -18,4 +18,3 @@
18
18
  <div class="<%= params[:action]%>_details">
19
19
  <%= render :partial => "#{params[:controller]}/_#{params[:action]}_partials/default_details", :locals => {:document => document}%>
20
20
  </div>
21
- <%= async_load_tag(hydra_asset_downloads_path(params[:id]), 'downloads') %>
data/hydra-core.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency "rails", '~>3.2.3'
22
22
  gem.add_dependency "blacklight", '~>3.4'
23
23
  gem.add_dependency "devise"
24
- gem.add_dependency "active-fedora", '~>4.1'
24
+ gem.add_dependency "active-fedora", '~>4.6.0.rc1'
25
25
  gem.add_dependency 'RedCloth', '=4.2.9'
26
26
  gem.add_dependency 'block_helpers'
27
27
  gem.add_dependency 'sanitize'
@@ -30,7 +30,13 @@ class HeadGenerator < Rails::Generators::Base
30
30
  copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
31
31
 
32
32
  # Initializers
33
- copy_file "config/initializers/hydra_config.rb", "config/initializers/hydra_config.rb"
33
+ file_path = "config/initializers/hydra_config.rb"
34
+ copy_file "config/initializers/hydra_config.rb", file_path
35
+ insert_into_file file_path, :after => '# specify the user model' do
36
+ "\n config[:user_model] = '#{model_name.classify}'"
37
+ end
38
+
39
+
34
40
  copy_file "config/initializers/action_dispatch_http_upload_monkey_patch.rb", "config/initializers/action_dispatch_http_upload_monkey_patch.rb"
35
41
 
36
42
  # Role Mappings
@@ -35,5 +35,7 @@ if Hydra.respond_to?(:configure)
35
35
  :owner => "depositor_t",
36
36
  :embargo_release_date => "embargo_release_date_dt"
37
37
  }
38
+
39
+ # specify the user model
38
40
  end
39
41
  end
data/lib/hydra-core.rb CHANGED
@@ -16,3 +16,12 @@ module HydraHead
16
16
  HydraHead::Routes.new(router, options).draw
17
17
  end
18
18
  end
19
+
20
+ ActiveSupport.on_load(:after_initialize) do
21
+ begin
22
+ puts "Requiring SolrDocumentExtension"
23
+ SolrDocument.use_extension Hydra::ModelMixins::SolrDocumentExtension
24
+ rescue NameError
25
+ puts "Couldn't find SolrDocument"
26
+ end
27
+ end
@@ -24,67 +24,23 @@ module HydraHead
24
24
  end
25
25
 
26
26
  def default_route_sets
27
- [:catalog, :superuser, :permissions, :assets_with_all_nested_routes]
27
+ [:assets_with_all_nested_routes]
28
28
  end
29
29
 
30
30
  module RouteSets
31
-
32
-
33
31
  def assets_with_all_nested_routes
34
32
  add_routes do |options|
35
- match "withdraw", :to => "hydra/assets#withdraw", :as => "withdraw"
36
33
  namespace :hydra do
37
34
  resources :file_assets
38
35
  resources :assets do
39
- # this is to remove documents from SOLR but not from Fedora.
40
- resources :contributors, :only=>[:new,:create]
41
- match '/contributors', :to => 'contributors#update', :as => 'update_contributors'
42
- # We would need to include the rails JS files (or implement our own) if we want this to work w/ DELETE because we delete from a link not a button.
43
- #match 'contributors/:contributor_type/:index', :to => 'contributors#destroy', :as => 'connect', :via => 'delete'
44
- match 'contributors/:contributor_type/:index', :to => 'contributors#destroy', :as => 'connect'
45
- # There is no ContributorsController#show
46
- match 'contributors/:contributor_type/:index', :to => 'contributors#show', :as => 'contributor', :via => 'get'
47
36
  resources :file_assets
48
- resources :downloads, :only=>[:index]
49
- resources :grants, :only=>[:new,:create]
50
- resources :permissions
51
- # Allow updates to assets/:asset_id/permissions (no :id necessary)
52
- match '/permissions', :to => 'permissions#update', :as => 'update_group_permissions'
53
37
  end
54
38
  end
55
- match "generic_contents_object/content/:container_id", :to=>"generic_content_objects#create", :as=>'generic_content_object', :via => 'post'
56
39
  end
57
40
  end
58
-
59
- def permissions
60
- add_routes do |options|
61
- namespace :hydra do
62
- resources :permissions
63
- end
64
- end
65
- end
66
-
67
-
68
- def superuser
69
- add_routes do |options|
70
- match 'superuser', :to => 'user_sessions#superuser', :as => 'superuser'
71
- end
72
- end
73
-
74
- def catalog
75
- add_routes do |options|
76
- match 'catalog/:id/edit', :to => 'catalog#edit', :as => 'edit_catalog'
77
- # The delete method renders a confirmation page with a button to submit actual destroy request
78
- match 'catalog/:id/delete', :to => 'catalog#delete', :as => 'delete_catalog'
79
- end
80
- end
81
-
82
-
83
-
84
-
85
41
  end
42
+
86
43
  include RouteSets
87
44
 
88
- #match 'generic_contents_object/content/:container_id', :to => 'generic_content_objects#create', :as => 'generic_content_object', :via => :post
89
45
  end
90
46
  end
@@ -1,4 +1,4 @@
1
1
  module HydraHead
2
- VERSION = "5.0.0.pre4"
2
+ VERSION = "5.0.0.pre6"
3
3
  end
4
4
 
data/lib/hydra.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'hydra-access-controls'
2
- # Hydra libraries
2
+
3
3
  module Hydra
4
4
  extend ActiveSupport::Autoload
5
5
  autoload :GlobalConfigurable
@@ -15,12 +15,3 @@ module Hydra
15
15
  end
16
16
  autoload :Models
17
17
  end
18
-
19
- # require these models once the hydra module has been set up, so that all autoloads take place
20
- #require 'hydra-file-access'
21
-
22
- begin
23
- SolrDocument.use_extension Hydra::ModelMixins::SolrDocumentExtension
24
- rescue NameError
25
- end
26
-
@@ -1,4 +1,3 @@
1
- # will move to lib/hydra/controller / upload_behavior.rb in release 5.x
2
1
  module Hydra::Controller::UploadBehavior
3
2
 
4
3
  # Creates a File Asset, adding the posted blob to the File Asset's datastreams and saves the File Asset
@@ -18,7 +18,9 @@ module Hydra::ModelMixins
18
18
  i += 1
19
19
  end
20
20
  end
21
+ def get_file_asset_count()
22
+ ActiveFedora::Base.count(:conditions=>"is_part_of_t:#{ActiveFedora::Base.quote_for_solr(id)}")
23
+ end
21
24
  end
22
25
  end
23
26
 
24
- SolrDocument.use_extension Hydra::ModelMixins::SolrDocumentExtension
@@ -26,9 +26,6 @@ describe CatalogController do
26
26
  it "should map {:controller=>'catalog', :action=>'show', :id=>'test:3'} to GET /catalog/test:3" do
27
27
  { :get => "/catalog/test:3" }.should route_to(:controller => 'catalog', :action => 'show', :id=>'test:3')
28
28
  end
29
- it "should map {:controller=>'catalog', :action=>'edit', :id=>'test:3'} to GET /catalog/test:3" do
30
- { :get => "/catalog/test:3/edit" }.should route_to(:controller => 'catalog', :action => 'edit', :id=>'test:3')
31
- end
32
29
 
33
30
  it "should map catalog_path" do
34
31
  # catalog_path.should == '/catalog'
@@ -68,16 +65,6 @@ describe CatalogController do
68
65
  get :index
69
66
  assigns(:document_list).count.should == @public_only_results.docs.count
70
67
  end
71
- it "should return all documents if role does have permissions" do
72
- pending "Need to put documents into solr"
73
- mock_user = FactoryGirl.build(:user, :email=>"BigWig@example.com")
74
- mock_user.stub(:is_being_superuser?).and_return(true)
75
- controller.stub(:current_user).and_return(mock_user)
76
- get :index
77
- ### This fails when there are more than 10 public documents in the solr index
78
- ### TODO: instead, expect a certain query(especially the :fq component) to solr
79
- assigns(:document_list).count.should > @public_only_results.docs.count
80
- end
81
68
  end
82
69
  end
83
70
 
@@ -35,17 +35,12 @@ describe CatalogController do
35
35
  describe "Home Page" do
36
36
 
37
37
  it "Should have Valid HTML when not logged in" do
38
- controller.stub(:current_user).and_return(nil)
39
38
  get("index", "controller"=>"catalog")
40
39
  document_check(response.body)
41
40
  end
42
41
 
43
42
  it "Should have Valid HTML when I'm logged in" do
44
- mock_user = FactoryGirl.build(:user, :email=>"archivist1@example.com")
45
- mock_user.stub(:can_be_superuser?).and_return(true)
46
- mock_user.stub(:is_being_superuser?).and_return(true)
47
-
48
- sign_in mock_user
43
+ sign_in FactoryGirl.build(:user, :email=>"archivist1@example.com")
49
44
  get("index", "controller"=>"catalog")
50
45
  document_check(response.body)
51
46
  end
@@ -55,8 +50,6 @@ describe CatalogController do
55
50
 
56
51
  before(:each) do
57
52
  mock_user = FactoryGirl.build(:user, :email=>"archivist1@example.com")
58
- mock_user.stub(:can_be_superuser?).and_return(true)
59
- mock_user.stub(:is_being_superuser?).and_return(true)
60
53
  sign_in mock_user
61
54
  end
62
55
 
@@ -1,6 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FacetsHelper do
4
+ let(:blacklight_config) { Blacklight::Configuration.new }
5
+
6
+ before(:each) do
7
+ helper.stub(:blacklight_config).and_return blacklight_config
8
+ end
9
+
4
10
 
5
11
  describe "render_selected_facet_value" do
6
12
  it "should be html_safe and not have the remove link" do
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe Hydra::ModelMixins::SolrDocumentExtension do
4
+ before do
5
+ @doc = SolrDocument.new(:id=>'changeme:99')
6
+ end
7
+
8
+ it "should get_file_asset_count" do
9
+
10
+ mock_result = {'response'=>{'numFound'=>0}}
11
+ ActiveFedora::SolrService.should_receive(:query).with("is_part_of_t:\"changeme\\:99\"", :rows=>0, :raw=>true).and_return(mock_result)
12
+ @doc.get_file_asset_count.should == 0
13
+ end
14
+ end
@@ -7,8 +7,6 @@ class GenericContent < ActiveFedora::Base
7
7
  # FIXME: should this have "include Hydra::ModelMixins::CommonMetadata" instead?
8
8
  has_metadata :name => "rightsMetadata", :type => Hydra::Datastream::RightsMetadata
9
9
 
10
- #has_metadata :name => "descMetadata", :type => Hydra::Datastream::ModsGenericContent
11
-
12
10
  # A place to put extra metadata values, e.g. the user id of the object depositor (for permissions)
13
11
  has_metadata :name => "properties", :type => Hydra::Datastream::Properties
14
12
 
data/tasks/rspec.rake CHANGED
@@ -18,7 +18,7 @@ task :fixtures do
18
18
  end
19
19
 
20
20
 
21
- describe "Create the test rails app"
21
+ desc "Create the test rails app"
22
22
  task :generate do
23
23
  unless File.exists?('spec/internal/Rakefile')
24
24
  puts "Generating rails app"
@@ -40,7 +40,7 @@ task :generate do
40
40
  puts "Running specs"
41
41
  end
42
42
 
43
- describe "Clean out the test rails app"
43
+ desc "Clean out the test rails app"
44
44
  task :clean do
45
45
  puts "Removing sample rails app"
46
46
  `rm -rf spec/internal`
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: 5.0.0.pre4
4
+ version: 5.0.0.pre6
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: 2012-10-06 00:00:00.000000000 Z
13
+ date: 2012-10-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -67,7 +67,7 @@ dependencies:
67
67
  requirements:
68
68
  - - ~>
69
69
  - !ruby/object:Gem::Version
70
- version: '4.1'
70
+ version: 4.6.0.rc1
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: '4.1'
78
+ version: 4.6.0.rc1
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: RedCloth
81
81
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +179,7 @@ dependencies:
179
179
  requirements:
180
180
  - - '='
181
181
  - !ruby/object:Gem::Version
182
- version: 5.0.0.pre4
182
+ version: 5.0.0.pre6
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: 5.0.0.pre4
190
+ version: 5.0.0.pre6
191
191
  - !ruby/object:Gem::Dependency
192
192
  name: sqlite3
193
193
  requirement: !ruby/object:Gem::Requirement
@@ -319,21 +319,17 @@ files:
319
319
  - app/models/mods_asset.rb
320
320
  - app/views/_flash_msg.html.erb
321
321
  - app/views/catalog/_citation.html.erb
322
- - app/views/catalog/_constraints_element.html.erb
323
322
  - app/views/catalog/_delete_partials/_default.html.erb
324
323
  - app/views/catalog/_edit_partials/_default.html.erb
325
324
  - app/views/catalog/_edit_partials/_default_details.html.erb
326
- - app/views/catalog/_facets.html.erb
327
325
  - app/views/catalog/_home.html.erb
328
326
  - app/views/catalog/_home_text.html.erb
329
327
  - app/views/catalog/_index_partials/_default.html.erb
330
328
  - app/views/catalog/_index_partials/_default_details.html.erb
331
- - app/views/catalog/_opensearch_response_metadata.html.erb
332
329
  - app/views/catalog/_show_partials/_default.html.erb
333
330
  - app/views/catalog/_show_partials/_default_details.html.erb
334
331
  - app/views/catalog/_show_partials/_facets.html.erb
335
332
  - app/views/catalog/_sms_form.html.erb
336
- - app/views/catalog/_sort_and_per_page.html.erb
337
333
  - app/views/catalog/_uva_tabs.html.erb
338
334
  - app/views/catalog/about.html.erb
339
335
  - app/views/catalog/show.html.erb
@@ -391,6 +387,7 @@ files:
391
387
  - spec/lib/global_configurable_spec.rb
392
388
  - spec/lib/model_methods_spec.rb
393
389
  - spec/lib/repository_controller_behavior_spec.rb
390
+ - spec/lib/solr_document_extension_spec.rb
394
391
  - spec/models/mods_asset_spec.rb
395
392
  - spec/models/solr_document_spec.rb
396
393
  - spec/models/user_spec.rb
@@ -447,6 +444,7 @@ test_files:
447
444
  - spec/lib/global_configurable_spec.rb
448
445
  - spec/lib/model_methods_spec.rb
449
446
  - spec/lib/repository_controller_behavior_spec.rb
447
+ - spec/lib/solr_document_extension_spec.rb
450
448
  - spec/models/mods_asset_spec.rb
451
449
  - spec/models/solr_document_spec.rb
452
450
  - spec/models/user_spec.rb
@@ -1,34 +0,0 @@
1
- <%# This view is overridden to change the alt attribute to be a title in the link_to below in order to conform to the HTML5 validity standard. This should ultimately be fixed in Blacklight. -%>
2
- <%- # local params:
3
- # label
4
- # value
5
- # options =>
6
- # :remove => url for a remove constraint link
7
- # :classes => array of classes to add to container span
8
- options ||= {}
9
- options[:escape_label] = true unless options.has_key?(:escape_label)
10
- options[:escape_value] = true unless options.has_key?(:escape_value)
11
- -%>
12
-
13
- <span class="appliedFilter constraint <%= options[:classes].join(" ") if options[:classes] %>">
14
- <%- unless label.blank? -%>
15
- <span class="filterName"><%= options[:escape_label] ? h(label) : label %></span>
16
- <%- end -%>
17
- <%- unless value.blank? -%>
18
- <span class="filterValue"><%= options[:escape_value] ? h(value) : value %></span>
19
- <%- end -%>
20
- <%- unless options[:remove].blank? -%>
21
- <% accessible_remove_label =
22
- if label.blank?
23
- "Remove constraint #{options[:escape_value] ? h(value) : value}"
24
- else
25
- "Remove constraint #{options[:escape_value] ? h(value) : value}: #{options[:escape_value] ? h(value) : value}"
26
- end
27
- %>
28
- <%= link_to(accessible_remove_label,
29
- options[:remove],
30
- :class=>'btnRemove imgReplace',
31
- :title=>'remove'
32
- ) %>
33
- <%- end -%>
34
- </span>
@@ -1,37 +0,0 @@
1
- <% # main container for facets/limits menu -%>
2
- <div id="facets" class="facets">
3
- <% facet_field_names.each do |solr_fname| %>
4
-
5
- <% next if solr_fname == 'person_full_name_cid_facet' %>
6
- <div>
7
- <% display_facet = @response.facets.detect {|f| f.name == solr_fname} -%>
8
- <% if display_facet && display_facet.items.length > 0 %>
9
- <h3 id="facet_<%= facet_field_labels[solr_fname].downcase.gsub(/ /, '_') -%>"><%= facet_field_labels[solr_fname] -%></h3>
10
- <ul>
11
- <% paginator =
12
- Blacklight::Solr::FacetPaginator.new(display_facet.items,
13
- :limit => facet_limit_for(solr_fname))
14
- %>
15
- <% paginator.items.each do |item| -%>
16
- <li>
17
- <% if facet_in_params?( solr_fname, item.value ) %>
18
- <%= render_selected_facet_value(solr_fname, item) %>
19
- <% else %>
20
- <% if item.value.blank? %>
21
- <%#= render_facet_value(solr_fname, ["Unknown",item.hits]) %>
22
- <% else %>
23
- <%= render_facet_value(solr_fname, item) %>
24
- <% end %>
25
- <% end -%>
26
- </li>
27
- <% end %>
28
-
29
- <% if(paginator.has_next?) %>
30
- <li class="more_facets_link"><%= link_to('more »', params.merge(:id => solr_fname, :action=>"facet"), :class => "more_facets_link") %></li>
31
- <% end %>
32
-
33
- </ul>
34
- <% end %>
35
- </div>
36
- <% end %>
37
- </div>
@@ -1,2 +0,0 @@
1
- <!-- Suppressing opensearch tags (to maintain html5 validity) by overriding views/catalog/_opensearch_response_metadata.html.erb with an empty file. To undo this, just delete the file. -->
2
-
@@ -1,23 +0,0 @@
1
- <div id="sortAndPerPage">
2
- <% unless @response.response['numFound'] < 2 %>
3
- <%= form_tag catalog_index_path, :method=>:get, :class=>'per_page' do %>
4
- <%= label_tag(:per_page, "Show") %>
5
- <%= select_tag(:per_page, options_for_select(['10', '20', '50', '100'], h(params[:per_page])), :title => "Number of results to display per page", :onchange => 'this.form.submit()') %>
6
- per page
7
- <%= search_as_hidden_fields(:omit_keys => [:page, :per_page]) %>
8
-
9
- <noscript><%= submit_tag 'update' %></noscript>
10
- <% end %>
11
-
12
- <%= form_tag catalog_index_path, :method=>:get, :class=>'sort', :id => "sort_form" do %>
13
- <%= label_tag 'sort', 'Sort by' %>
14
- <%= select_tag(:sort, options_for_select(sort_fields, h(params[:sort])), :onchange => 'this.form.submit()') %>
15
-
16
- <%= search_as_hidden_fields(:omit_keys => [:page, :sort]) %>
17
-
18
- <noscript><%= submit_tag 'sort results' %></noscript>
19
- <% end %>
20
- <% end %>
21
-
22
-
23
- </div>