sufia 0.0.1.pre1 → 0.0.1.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -2
- data/Gemfile +2 -1
- data/README.md +19 -15
- data/Rakefile +2 -0
- data/app/controllers/batch_controller.rb +2 -3
- data/app/controllers/contact_form_controller.rb +1 -0
- data/app/controllers/dashboard_controller.rb +2 -2
- data/app/controllers/generic_files_controller.rb +24 -12
- data/app/controllers/mailbox_controller.rb +2 -2
- data/app/controllers/single_use_link_controller.rb +5 -5
- data/app/controllers/users_controller.rb +10 -10
- data/app/helpers/{application_helper.rb → sufia_helper.rb} +5 -13
- data/app/models/audit_job.rb +3 -4
- data/app/models/batch.rb +2 -0
- data/app/models/batch_update_job.rb +4 -6
- data/app/models/checksum_audit_log.rb +2 -0
- data/app/models/contact_form.rb +2 -0
- data/app/models/content_delete_event_job.rb +1 -1
- data/app/models/content_deposit_event_job.rb +2 -2
- data/app/models/content_new_version_event_job.rb +2 -2
- data/app/models/content_restored_version_event_job.rb +2 -2
- data/app/models/content_update_event_job.rb +2 -2
- data/app/models/datastreams/properties_datastream.rb +1 -1
- data/app/models/domain_term.rb +1 -0
- data/app/models/event_job.rb +1 -1
- data/app/models/generic_file.rb +5 -4
- data/app/models/local_authority.rb +1 -0
- data/app/models/local_authority_entry.rb +1 -0
- data/app/models/single_use_link.rb +2 -2
- data/app/models/user_edit_profile_event_job.rb +1 -1
- data/app/models/user_follow_event_job.rb +2 -2
- data/app/models/user_unfollow_event_job.rb +2 -2
- data/app/models/version_committer.rb +1 -0
- data/app/views/_footer.html.erb +21 -0
- data/app/views/_logo.html.erb +3 -0
- data/app/views/_masthead.html.erb +38 -0
- data/app/views/_user_util_links.html.erb +14 -43
- data/app/views/catalog/_document_list.html.erb +0 -7
- data/app/views/catalog/_home_text.html.erb +4 -4
- data/app/views/catalog/_recent_document.html.erb +5 -5
- data/app/views/contact_form/_directions.html.erb +4 -0
- data/app/views/contact_form/new.html.erb +2 -4
- data/app/views/dashboard/_document_list.html.erb +1 -8
- data/app/views/dashboard/_facets.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_list_files.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +6 -6
- data/app/views/dashboard/_search_form.html.erb +1 -1
- data/app/views/dashboard/index.html.erb +26 -25
- data/app/views/generic_files/_media_display.html.erb +5 -5
- data/app/views/generic_files/_permission.html.erb +11 -11
- data/app/views/generic_files/edit.html.erb +10 -8
- data/app/views/generic_files/show.html.erb +16 -12
- data/app/views/layouts/error.html.erb +2 -53
- data/app/views/layouts/hydra-head.html.erb +2 -21
- data/app/views/mailbox/index.html.erb +1 -1
- data/app/views/static/about.html.erb +2 -65
- data/app/views/static/help.html.erb +1 -721
- data/app/views/users/_search_form.html.erb +1 -1
- data/app/views/users/edit.html.erb +6 -3
- data/config/locales/sufia.en.yml +6 -0
- data/config/routes.rb +1 -3
- data/features/browse_dashboard_files.feature +1 -1
- data/features/display_dashboard.feature +1 -1
- data/features/step_definitions/fixture_steps.rb +2 -2
- data/features/step_definitions/user_steps.rb +12 -8
- data/features/support/env.rb +9 -0
- data/features/support/paths.rb +21 -21
- data/lib/generators/sufia/sufia_generator.rb +46 -4
- data/lib/generators/sufia/templates/catalog_controller.rb +2 -2
- data/lib/generators/sufia/templates/config/redis_config.rb +20 -0
- data/lib/generators/sufia/templates/config/sufia.rb +29 -0
- data/lib/generators/sufia/templates/migrations/add_groups_to_users.rb +0 -4
- data/lib/sufia.rb +22 -15
- data/lib/sufia/active_fedora/redis.rb +49 -0
- data/lib/{generators/sufia/templates/config/active_record_base_redis.rb → sufia/active_record/redis.rb} +1 -16
- data/lib/sufia/controller.rb +1 -2
- data/lib/sufia/http_header_auth.rb +9 -0
- data/lib/sufia/role_mapper.rb +1 -0
- data/lib/sufia/user.rb +24 -6
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/fixtures.rake +245 -0
- data/spec/.gitignore +1 -0
- data/spec/active_fedora/unsaved_digital_object_spec.rb +2 -2
- data/spec/config/host_to_vhost_spec.rb +8 -8
- data/spec/controllers/batch_controller_spec.rb +6 -6
- data/spec/controllers/catalog_controller_spec.rb +2 -0
- data/spec/controllers/dashboard_controller_spec.rb +13 -10
- data/spec/controllers/downloads_controller_spec.rb +8 -8
- data/spec/controllers/generic_files_controller_spec.rb +46 -44
- data/spec/controllers/mailbox_controller_spec.rb +6 -12
- data/spec/controllers/sessions_controller_spec.rb +8 -6
- data/spec/controllers/single_use_link_controller_spec.rb +9 -14
- data/spec/controllers/users_controller_spec.rb +49 -49
- data/spec/{factories.rb → factories/users.rb} +6 -3
- data/spec/fixtures/scholarsphere/scholarsphere_test2.foxml.erb +2 -2
- data/spec/fixtures/scholarsphere/scholarsphere_test3.foxml.erb +2 -2
- data/spec/fixtures/scholarsphere/scholarsphere_test4.foxml.erb +2 -2
- data/spec/fixtures/scholarsphere/scholarsphere_test6.foxml.erb +2 -2
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.descMeta.txt +12 -0
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.foxml.erb +79 -0
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.txt +1 -0
- data/spec/fixtures/scholarsphere/{scholarsphere_test1.foxml.erb → sufia_test1.foxml.erb} +6 -6
- data/spec/fixtures/scholarsphere/{scholarsphere_test5.foxml.erb → sufia_test5.foxml.erb} +5 -5
- data/spec/fixtures/scholarsphere_generic_stub.foxml.erb +5 -5
- data/spec/lib/{scholarsphere → sufia}/id_service_spec.rb +5 -5
- data/spec/lib/{scholarsphere → sufia}/role_mapper_spec.rb +5 -2
- data/spec/models/audit_job_spec.rb +1 -1
- data/spec/models/batch_spec.rb +2 -2
- data/spec/models/batch_update_job_spec.rb +5 -5
- data/spec/models/checksum_audit_log_spec.rb +1 -1
- data/spec/models/event_jobs_spec.rb +19 -19
- data/spec/models/file_content_datastream_spec.rb +6 -6
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file_spec.rb +8 -9
- data/spec/models/local_authority_spec.rb +3 -3
- data/spec/models/single_use_link_spec.rb +5 -5
- data/spec/models/unzip_job_spec.rb +1 -1
- data/spec/models/user_spec.rb +5 -26
- data/spec/rake/scholarsphere_fixtures_spec.rb +13 -12
- data/spec/routing/route_spec.rb +4 -41
- data/spec/spec_helper.rb +14 -4
- data/spec/support/Gemfile +21 -0
- data/spec/support/config/redis.yml +6 -0
- data/spec/support/lib/generators/test_app_generator.rb +40 -0
- data/sufia.gemspec +4 -2
- data/tasks/cucumber.rake +0 -6
- data/tasks/jetty.rake +40 -0
- data/tasks/scholarsphere-dev.rake +57 -17
- data/tasks/scholarsphere-fixtures.rake +16 -63
- metadata +74 -55
- data/.rvmrc +0 -59
- data/LICENSE +0 -22
- data/app/assets/images/site_images/logo_psuss_logotype.png +0 -0
- data/app/assets/images/site_images/logo_psuss_shield.png +0 -0
- data/lib/generators/sufia/templates/config/active_fedora_base_redis.rb +0 -54
- data/lib/sufia/ldap.rb +0 -123
- data/spec/fixtures/hydra_test_default_partials.foxml.xml +0 -80
- data/spec/fixtures/hydra_test_generic_content.foxml.xml +0 -138
- data/spec/fixtures/hydra_test_generic_image.foxml.xml +0 -395
- data/spec/fixtures/hydra_test_no_model.foxml.xml +0 -79
- data/spec/fixtures/hydrangea_fixture_archivist_only_mods_article.foxml.xml +0 -1212
- data/spec/fixtures/hydrangea_fixture_file_asset1.foxml.xml +0 -4946
- data/spec/fixtures/hydrangea_fixture_mods_article1.foxml.xml +0 -234
- data/spec/fixtures/hydrangea_fixture_mods_article2.foxml.xml +0 -177
- data/spec/fixtures/hydrangea_fixture_mods_article3.foxml.xml +0 -170
- data/spec/fixtures/hydrangea_fixture_mods_dataset1.foxml.xml +0 -187
- data/spec/fixtures/hydrangea_fixture_uploaded_svg1.foxml.xml +0 -676
- data/spec/fixtures/hydrus_admin_class1.foxml.xml +0 -176
- data/spec/fixtures/libra-oa_1.foxml.xml +0 -2324
- data/spec/fixtures/libra-oa_2.foxml.xml +0 -2422
- data/spec/fixtures/libra-oa_7.foxml.xml +0 -1735
@@ -15,7 +15,7 @@ limitations under the License.
|
|
15
15
|
%>
|
16
16
|
|
17
17
|
<div style="float: right;" >
|
18
|
-
<%= form_tag profiles_path, :method => :search, :class => "well form-search" do %>
|
18
|
+
<%= form_tag sufia.profiles_path, :method => :search, :class => "well form-search" do %>
|
19
19
|
<label class="accessible-hidden">Search Users</label>
|
20
20
|
<%= text_field_tag :uq, params[:uq], :class => "q", :placeholder => "Search Users", :size => '30', :type => "search", :id => "user_search" %>
|
21
21
|
<%= hidden_field_tag :sort, params[:sort], :id => 'user_sort' %>
|
@@ -14,8 +14,11 @@ See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
15
15
|
%>
|
16
16
|
|
17
|
-
<%
|
18
|
-
|
17
|
+
<% content_for :head do %>
|
18
|
+
|
19
|
+
<% javascript_include_tag 'bootstrap-tooltip.js'%>
|
20
|
+
<% javascript_include_tag 'bootstrap-popover.js'%>
|
21
|
+
<% end %>
|
19
22
|
|
20
23
|
<% content_for :local_js do %>
|
21
24
|
// initialize popover helpers
|
@@ -51,7 +54,7 @@ $("a[rel=popover]").popover();
|
|
51
54
|
<div class="controls">
|
52
55
|
<label class="checkbox">
|
53
56
|
<%= check_box_tag 'update_directory' %> Yes
|
54
|
-
<a href="#" id="refresh_directory_help" rel="popover" data-content="The information displayed in your profile comes from
|
57
|
+
<a href="#" id="refresh_directory_help" rel="popover" data-content="The information displayed in your profile comes from <%=t('sufia.institution_name') %>'s central directory (LDAP) and is cached by <%=t('sufia.product_name') %>. If you have updated that information and don't see those changes in your <%=t('sufia.product_name') %> profile, check the box and save your profile." data-original-title="Refresh Directory Info"><i class="icon-question-sign icon-large"></i></a>
|
55
58
|
</label>
|
56
59
|
</div>
|
57
60
|
</div>
|
data/config/routes.rb
CHANGED
@@ -6,9 +6,6 @@ Sufia::Engine.routes.draw do
|
|
6
6
|
|
7
7
|
match 'batch_edits/clear' => 'batch_edits#clear', :as => :batch_edits_clear
|
8
8
|
|
9
|
-
# add batch edit routes
|
10
|
-
Hydra::BatchEdit.add_routes(self)
|
11
|
-
|
12
9
|
# Route path-less requests to the index view of catalog
|
13
10
|
root :to => "catalog#index"
|
14
11
|
|
@@ -31,6 +28,7 @@ Sufia::Engine.routes.draw do
|
|
31
28
|
resources :downloads, :only => "show"
|
32
29
|
|
33
30
|
# Login/logout route to destroy session
|
31
|
+
# can just be in the PSU scholarsphere
|
34
32
|
match 'logout' => 'sessions#destroy', :as => :destroy_user_session
|
35
33
|
match 'login' => 'sessions#new', :as => :new_user_session
|
36
34
|
|
@@ -2,7 +2,7 @@ Feature: Browse Dashboard files
|
|
2
2
|
|
3
3
|
Scenario: Browse via Fixtures
|
4
4
|
Given I load scholarsphere fixtures
|
5
|
-
Given I am logged in as "archivist2"
|
5
|
+
Given I am logged in as "archivist2@example.com"
|
6
6
|
And I follow "dashboard"
|
7
7
|
And I follow "more Keywords"
|
8
8
|
And I follow "keyf"
|
@@ -34,7 +34,7 @@ Feature: As an authenticate and authorized
|
|
34
34
|
@javascript
|
35
35
|
Scenario: I have files on my dashboard I should see icons
|
36
36
|
Given I load scholarsphere fixtures
|
37
|
-
And I am logged in as "archivist1"
|
37
|
+
And I am logged in as "archivist1@example.com"
|
38
38
|
And I follow "dashboard"
|
39
39
|
Then I should see "Test Document Text"
|
40
40
|
Given I follow "Delete"
|
@@ -15,7 +15,7 @@
|
|
15
15
|
require "rake"
|
16
16
|
|
17
17
|
def loaded_files_excluding_current_rake_file
|
18
|
-
$".reject { |file| file.include? "lib/tasks/
|
18
|
+
$".reject { |file| file.include? "lib/tasks/fixtures" }
|
19
19
|
end
|
20
20
|
|
21
21
|
def activefedora_path
|
@@ -25,7 +25,7 @@ end
|
|
25
25
|
Given /^I load scholarsphere fixtures$/ do
|
26
26
|
@rake = Rake::Application.new
|
27
27
|
Rake.application = @rake
|
28
|
-
Rake.application.rake_require("lib/tasks/
|
28
|
+
Rake.application.rake_require("lib/tasks/fixtures", ["."], loaded_files_excluding_current_rake_file)
|
29
29
|
Rake.application.rake_require("lib/tasks/active_fedora", [activefedora_path], loaded_files_excluding_current_rake_file)
|
30
30
|
Rake::Task.define_task(:environment)
|
31
31
|
@rake['scholarsphere:fixtures:refresh'].invoke
|
@@ -17,15 +17,19 @@
|
|
17
17
|
# @example
|
18
18
|
# I am logged in as "archivist1@example.com"
|
19
19
|
Given /^I (?:am )?log(?:ged)? in as "([^\"]*)"$/ do |login|
|
20
|
-
driver_name = "rack_test_authenticated_header_#{login}".to_s
|
21
|
-
Capybara.register_driver(driver_name) do |app|
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
User.
|
26
|
-
|
27
|
-
|
20
|
+
# driver_name = "rack_test_authenticated_header_#{login}".to_s
|
21
|
+
# Capybara.register_driver(driver_name) do |app|
|
22
|
+
# Capybara::RackTest::Driver.new(app, headers: { 'REMOTE_USER' => login })
|
23
|
+
# end
|
24
|
+
#Capybara.current_driver = driver_name
|
25
|
+
user = User.where(:email=>login).first || FactoryGirl.create(:user, :email=>login)
|
26
|
+
User.find_by_user_key(login).should_not be_nil
|
28
27
|
visit "/"
|
28
|
+
step %{And I click the anchor "Login"}
|
29
|
+
fill_in 'Email', with: login
|
30
|
+
fill_in 'Password', with: 'password'
|
31
|
+
click_button 'Sign in'
|
32
|
+
|
29
33
|
step %{And I click the anchor "#{login}"}
|
30
34
|
step %{I should see a link to "ingest" with label "upload"}
|
31
35
|
step %{I should see a link to "dashboard" with label "dashboard"}
|
data/features/support/env.rb
CHANGED
@@ -4,6 +4,15 @@
|
|
4
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
7
|
+
#require 'capybara'
|
8
|
+
ENV["RAILS_ENV"] ||= "test"
|
9
|
+
require File.expand_path("../../../spec/internal/config/environment.rb", __FILE__)
|
10
|
+
ENV["RAILS_ROOT"] ||= File.dirname(__FILE__) + "../../../spec/internal"
|
11
|
+
|
12
|
+
|
13
|
+
FactoryGirl.definition_file_paths = [File.expand_path("../../../spec/factories", __FILE__)]
|
14
|
+
FactoryGirl.find_definitions
|
15
|
+
|
7
16
|
require 'cucumber/rails'
|
8
17
|
|
9
18
|
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
data/features/support/paths.rb
CHANGED
@@ -28,61 +28,61 @@ module NavigationHelpers
|
|
28
28
|
when /the search page/
|
29
29
|
'/catalog'
|
30
30
|
when /ingest/
|
31
|
-
new_generic_file_path
|
31
|
+
sufia.new_generic_file_path
|
32
32
|
when /logout/
|
33
|
-
destroy_user_session_path
|
33
|
+
sufia.destroy_user_session_path
|
34
34
|
when /my account info/
|
35
|
-
edit_user_registration_path
|
35
|
+
sufia.edit_user_registration_path
|
36
36
|
when /the base search page/
|
37
37
|
'/catalog?q=&search_field=search&action=index&controller=catalog&commit=search'
|
38
38
|
when /the document page for id (.+)/
|
39
|
-
catalog_path($1)
|
39
|
+
sufia.catalog_path($1)
|
40
40
|
when /the edit page for id (.+)/
|
41
|
-
edit_catalog_path($1)
|
41
|
+
sufia.edit_catalog_path($1)
|
42
42
|
when /the catalog index page/
|
43
|
-
catalog_index_path
|
43
|
+
sufia.catalog_index_path
|
44
44
|
# Add more mappings here.
|
45
45
|
# Here is a more fancy example:
|
46
46
|
#
|
47
47
|
# when /^(.*)'s profile page$/i
|
48
48
|
# user_profile_path(User.find_by_login($1))
|
49
49
|
when /dashboard/
|
50
|
-
dashboard_path
|
50
|
+
sufia.dashboard_path
|
51
51
|
|
52
52
|
when /the edit document page for (.*)$/i
|
53
|
-
edit_catalog_path($1)
|
53
|
+
sufia.edit_catalog_path($1)
|
54
54
|
when /the show document page for (.*)$/i
|
55
|
-
catalog_path($1)
|
55
|
+
sufia.catalog_path($1)
|
56
56
|
when /the delete confirmation page for (.*)$/i
|
57
|
-
delete_catalog_path($1)
|
57
|
+
sufia.delete_catalog_path($1)
|
58
58
|
|
59
59
|
when /the file (?:asset )?list page for (.*)$/i
|
60
|
-
asset_file_assets_path($1)
|
60
|
+
sufia.asset_file_assets_path($1)
|
61
61
|
when /the file asset creation page for (.*)$/i
|
62
|
-
asset_file_assets_path($1)
|
62
|
+
sufia.asset_file_assets_path($1)
|
63
63
|
when /the deletable file list page for (.*)/i
|
64
|
-
asset_file_assets_path($1, :deletable=>"true",:layout=>"false")
|
64
|
+
sufia.asset_file_assets_path($1, :deletable=>"true",:layout=>"false")
|
65
65
|
when /the file asset (.*) with (.*) as its container$/i
|
66
|
-
asset_file_asset_path($2, $1)
|
66
|
+
sufia.asset_file_asset_path($2, $1)
|
67
67
|
when /the file asset (.*)$/i
|
68
|
-
file_asset_path($1)
|
68
|
+
sufia.file_asset_path($1)
|
69
69
|
when /the permissions page for (.*)$/i
|
70
|
-
asset_permissions_path($1)
|
70
|
+
sufia.asset_permissions_path($1)
|
71
71
|
|
72
72
|
when /new (.*) page$/i
|
73
|
-
new_asset_path(:content_type => $1)
|
73
|
+
sufia.new_asset_path(:content_type => $1)
|
74
74
|
when /the asset (.*)$/i
|
75
|
-
asset_path($1)
|
75
|
+
sufia.asset_path($1)
|
76
76
|
when /show asset page for (.*)$/i
|
77
|
-
asset_path($1)
|
77
|
+
sufia.asset_path($1)
|
78
78
|
|
79
79
|
|
80
80
|
when /the (\d+)(?:st|nd|rd|th) (person|organization|conference) entry in (.*)$/i
|
81
81
|
# contributor_id = "#{$2}_#{$1.to_i-1}"
|
82
|
-
asset_contributor_path($3, $2, $1.to_i-1, :content_type=>"mods_asset")
|
82
|
+
sufia.asset_contributor_path($3, $2, $1.to_i-1, :content_type=>"mods_asset")
|
83
83
|
|
84
84
|
when /the edit (.*) page for (.*)$/i
|
85
|
-
edit_catalog_path($2,:wf_step=>$1)
|
85
|
+
sufia.edit_catalog_path($2,:wf_step=>$1)
|
86
86
|
else
|
87
87
|
begin
|
88
88
|
page_name =~ /the (.*) page/
|
@@ -11,6 +11,11 @@ class SufiaGenerator < Rails::Generators::Base
|
|
11
11
|
desc """
|
12
12
|
This generator makes the following changes to your application:
|
13
13
|
1. Creates several database migrations if they do not exist in /db/migrate
|
14
|
+
2. Adds user behavior to the user model
|
15
|
+
3. Adds controller behavior to the application controller
|
16
|
+
4. Creates the sufia.rb configuration file
|
17
|
+
5. Copies the catalog controller into the local app
|
18
|
+
6. Generates mailboxer
|
14
19
|
"""
|
15
20
|
|
16
21
|
# Implement the required interface for Rails::Generators::Migration.
|
@@ -34,8 +39,36 @@ add_groups_to_users.rb create_local_authorities.rb}.each do |f|
|
|
34
39
|
end
|
35
40
|
end
|
36
41
|
|
42
|
+
# Add behaviors to the user model
|
43
|
+
def inject_sufia_user_behavior
|
44
|
+
file_path = "app/models/#{model_name.underscore}.rb"
|
45
|
+
if File.exists?(file_path)
|
46
|
+
inject_into_class file_path, model_name.classify do
|
47
|
+
"# Connects this user object to Sufia behaviors. " +
|
48
|
+
"\n include Sufia::User\n"
|
49
|
+
end
|
50
|
+
else
|
51
|
+
puts " \e[31mFailure\e[0m Sufia requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g sufia client"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Add behaviors to the application controller
|
56
|
+
def inject_sufia_controller_behavior
|
57
|
+
controller_name = "ApplicationController"
|
58
|
+
file_path = "app/controllers/application_controller.rb"
|
59
|
+
if File.exists?(file_path)
|
60
|
+
insert_into_file file_path, :after => 'include Hydra::Controller::ControllerBehavior' do
|
61
|
+
" \n# Adds Sufia behaviors into the application controller \n" +
|
62
|
+
" include Sufia::Controller\n"
|
63
|
+
end
|
64
|
+
else
|
65
|
+
puts " \e[31mFailure\e[0m Could not find #{file_path}. To add Sufia behaviors to your Controllers, you must include the Sufia::Controller module in the Controller class definition."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
37
69
|
def create_configuration_files
|
38
70
|
copy_file "config/sufia.rb", "config/initializers/sufia.rb"
|
71
|
+
copy_file "config/redis_config.rb", "config/initializers/redis_config.rb"
|
39
72
|
end
|
40
73
|
|
41
74
|
def catalog_controller
|
@@ -43,11 +76,20 @@ add_groups_to_users.rb create_local_authorities.rb}.each do |f|
|
|
43
76
|
end
|
44
77
|
|
45
78
|
|
79
|
+
# The engine routes have to come after the devise routes so that /users/sign_in will work
|
46
80
|
def inject_routes
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
81
|
+
routing_code = "Hydra::BatchEdit.add_routes(self)"
|
82
|
+
sentinel = /HydraHead.add_routes\(self\)/
|
83
|
+
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
84
|
+
|
85
|
+
routing_code = "mount Sufia::Engine => '/'"
|
86
|
+
sentinel = /devise_for :users/
|
87
|
+
inject_into_file 'config/routes.rb', "\n #{routing_code}\n", { :after => sentinel, :verbose => false }
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
def install_mailboxer
|
92
|
+
generate "mailboxer:install"
|
51
93
|
end
|
52
94
|
|
53
95
|
private
|
@@ -47,7 +47,7 @@ class CatalogController < ApplicationController
|
|
47
47
|
def recent
|
48
48
|
if user_signed_in?
|
49
49
|
# grab other people's documents
|
50
|
-
(resp, doc_list) = get_search_results(:q =>'{!lucene q.op=AND df=depositor_t}-'+current_user.
|
50
|
+
(resp, doc_list) = get_search_results(:q =>'{!lucene q.op=AND df=depositor_t}-'+current_user.user_key, :sort=>"system_create_dt desc", :rows=>3)
|
51
51
|
else
|
52
52
|
# grab any documents we do not know who you are
|
53
53
|
(resp, doc_list) = get_search_results(:q =>'', :sort=>"system_create_dt desc", :rows=>3)
|
@@ -57,7 +57,7 @@ class CatalogController < ApplicationController
|
|
57
57
|
|
58
58
|
def recent_me
|
59
59
|
if user_signed_in?
|
60
|
-
(resp, doc_list) = get_search_results(:q =>'{!lucene q.op=AND df=depositor_t}'+current_user.
|
60
|
+
(resp, doc_list) = get_search_results(:q =>'{!lucene q.op=AND df=depositor_t}'+current_user.user_key, :sort=>"system_create_dt desc", :rows=>3)
|
61
61
|
@recent_user_documents = doc_list[0..3]
|
62
62
|
else
|
63
63
|
@recent_user_documents = nil
|
@@ -12,6 +12,26 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
if defined?(PhusionPassenger)
|
16
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
17
|
+
# We're in smart spawning mode.
|
18
|
+
if forked
|
19
|
+
# Re-establish redis connection
|
20
|
+
require 'redis'
|
21
|
+
config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
22
|
+
|
23
|
+
# The important two lines
|
24
|
+
$redis.client.disconnect if $redis
|
25
|
+
$redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
|
26
|
+
Resque.redis.client.reconnect if Resque.redis
|
27
|
+
end
|
28
|
+
end
|
29
|
+
else
|
30
|
+
config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
|
31
|
+
$redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
|
32
|
+
end
|
33
|
+
|
34
|
+
|
15
35
|
# Code borrowed from Obie's Redis patterns talk at RailsConf'12
|
16
36
|
Nest.class_eval do
|
17
37
|
def initialize(key, redis=$redis)
|
@@ -1,3 +1,32 @@
|
|
1
|
+
|
2
|
+
require 'sufia/http_header_auth'
|
3
|
+
|
4
|
+
# TODO move this method to HttpAuth initializer
|
5
|
+
# Returns an array containing the vhost 'CoSign service' value and URL
|
1
6
|
Sufia.config do |config|
|
2
7
|
config.id_namespace = "sufia"
|
8
|
+
config.fits_path = "fits.sh"
|
9
|
+
config.fits_to_desc_mapping= {
|
10
|
+
:file_title => :title,
|
11
|
+
:file_author => :creator
|
12
|
+
}
|
13
|
+
|
14
|
+
config.max_days_between_audits = 7
|
15
|
+
|
16
|
+
# TODO move these to an HttpAuth initializer
|
17
|
+
# Map hostnames onto vhosts
|
18
|
+
config.hosts_vhosts_map = {
|
19
|
+
'fedora1test' => 'https://scholarsphere-integration.dlt.psu.edu:8443/',
|
20
|
+
'fedora2test' => 'https://scholarsphere-test.dlt.psu.edu/',
|
21
|
+
'ss1stage' => 'https://scholarsphere-staging.dlt.psu.edu/',
|
22
|
+
'ss2stage' => 'https://scholarsphere-staging.dlt.psu.edu/',
|
23
|
+
'ss1prod' => 'https://scholarsphere.psu.edu/',
|
24
|
+
'ss2prod' => 'https://scholarsphere.psu.edu/'
|
25
|
+
}
|
26
|
+
|
27
|
+
# TODO move these to an HttpAuth initializer
|
28
|
+
config.logout_url = "https://webaccess.psu.edu/cgi-bin/logout?#{Sufia::HttpHeaderAuth.get_vhost_by_host(config)[1]}"
|
29
|
+
config.login_url = "https://webaccess.psu.edu?cosign-#{Sufia::HttpHeaderAuth.get_vhost_by_host(config)[0]}&#{Sufia::HttpHeaderAuth.get_vhost_by_host(config)[1]}"
|
3
30
|
end
|
31
|
+
|
32
|
+
|
@@ -16,14 +16,10 @@ class AddGroupsToUsers < ActiveRecord::Migration
|
|
16
16
|
def self.up
|
17
17
|
add_column :users, :group_list, :text
|
18
18
|
add_column :users, :groups_last_update, :datetime
|
19
|
-
add_column :users, :ldap_available, :boolean
|
20
|
-
add_column :users, :ldap_last_update, :datetime
|
21
19
|
end
|
22
20
|
|
23
21
|
def self.down
|
24
22
|
remove_column :users, :group_list
|
25
23
|
remove_column :users, :groups_last_update
|
26
|
-
remove_column :users, :ldap_available
|
27
|
-
remove_column :users, :ldap_last_update
|
28
24
|
end
|
29
25
|
end
|
data/lib/sufia.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "sufia/version"
|
2
2
|
require 'blacklight'
|
3
|
+
require 'blacklight_advanced_search'
|
3
4
|
require 'hydra/head'
|
4
5
|
require 'hydra-batch-edit'
|
5
6
|
require 'resque/server'
|
@@ -8,11 +9,24 @@ require 'mailboxer'
|
|
8
9
|
require 'acts_as_follower'
|
9
10
|
require 'paperclip'
|
10
11
|
require 'will_paginate'
|
12
|
+
require 'nest'
|
13
|
+
require 'RMagick'
|
14
|
+
require 'activerecord-import'
|
11
15
|
|
16
|
+
autoload :Zip, 'zipruby'
|
12
17
|
module Sufia
|
13
18
|
|
14
19
|
class Engine < ::Rails::Engine
|
15
20
|
engine_name 'sufia'
|
21
|
+
|
22
|
+
initializer "Patch active_fedora" do
|
23
|
+
require 'sufia/active_fedora/redis'
|
24
|
+
end
|
25
|
+
|
26
|
+
initializer "Patch active_record" do
|
27
|
+
require 'sufia/active_record/redis'
|
28
|
+
end
|
29
|
+
|
16
30
|
end
|
17
31
|
|
18
32
|
class ResqueAdmin
|
@@ -20,7 +34,7 @@ module Sufia
|
|
20
34
|
current_user = request.env['warden'].user
|
21
35
|
return false if current_user.blank?
|
22
36
|
# TODO code a group here that makes sense
|
23
|
-
current_user.groups.include? 'umg/up.dlt.scholarsphere-admin'
|
37
|
+
#current_user.groups.include? 'umg/up.dlt.scholarsphere-admin'
|
24
38
|
end
|
25
39
|
end
|
26
40
|
|
@@ -32,19 +46,12 @@ module Sufia
|
|
32
46
|
return @@config
|
33
47
|
end
|
34
48
|
|
35
|
-
autoload :Controller,
|
36
|
-
autoload :
|
37
|
-
autoload :
|
38
|
-
autoload :
|
39
|
-
autoload :
|
40
|
-
autoload :
|
41
|
-
autoload :
|
49
|
+
autoload :Controller, 'sufia/controller'
|
50
|
+
autoload :Utils, 'sufia/utils'
|
51
|
+
autoload :User, 'sufia/user'
|
52
|
+
autoload :ModelMethods, 'sufia/model_methods'
|
53
|
+
autoload :Noid, 'sufia/noid'
|
54
|
+
autoload :IdService, 'sufia/id_service'
|
55
|
+
autoload :HttpHeaderAuth,'sufia/http_header_auth'
|
42
56
|
end
|
43
57
|
|
44
|
-
module ActiveFedora
|
45
|
-
class UnsavedDigitalObject
|
46
|
-
def assign_pid
|
47
|
-
@pid ||= Sufia::IdService.mint
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|