sufia 0.0.1.pre2 → 0.0.1
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.
- data/Gemfile +2 -5
- data/README.md +44 -12
- data/app/assets/javascripts/{scholarsphere.js → sufia.js} +0 -0
- data/app/assets/stylesheets/{scholarsphere.css → sufia.css} +0 -0
- data/app/controllers/batch_controller.rb +2 -3
- data/app/controllers/batch_edits_controller.rb +4 -4
- data/app/controllers/dashboard_controller.rb +5 -3
- data/app/controllers/generic_files_controller.rb +77 -41
- data/app/controllers/users_controller.rb +9 -21
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +2 -2
- data/app/helpers/sufia_helper.rb +23 -2
- data/app/models/datastreams/file_content_datastream.rb +17 -9
- data/app/models/generic_file.rb +1 -809
- data/app/views/_add_assets_links.html.erb +1 -1
- data/app/views/_user_util_links.html.erb +2 -2
- data/app/views/batch/_metadata.html.erb +16 -16
- data/app/views/batch/edit.html.erb +16 -10
- data/app/views/batch_edits/_metadata.html.erb +16 -16
- data/app/views/catalog/_index_partials/_list_files.html.erb +2 -2
- data/app/views/catalog/index.html.erb +5 -0
- data/app/views/dashboard/_facet_limit.html.erb +1 -1
- data/app/views/dashboard/_facet_pagination.html.erb +4 -4
- data/app/views/dashboard/_facet_selected.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_list_files.html.erb +8 -8
- data/app/views/dashboard/_search_form.html.erb +1 -1
- data/app/views/dashboard/_sort_and_per_page.html.erb +1 -1
- data/app/views/dashboard/index.html.erb +0 -1
- data/app/views/generic_files/_breadcrumbs.html.erb +1 -1
- data/app/views/generic_files/_descriptions.html.erb +3 -3
- data/app/views/generic_files/_field_form +3 -3
- data/app/views/generic_files/_media_display.html.erb +5 -4
- data/app/views/generic_files/_permission.html.erb +5 -5
- data/app/views/generic_files/_versioning.html.erb +1 -1
- data/app/views/generic_files/edit.html.erb +2 -2
- data/app/views/generic_files/show.html.erb +3 -3
- data/app/views/static/versions.html.erb +1 -1
- data/app/views/users/edit.html.erb +5 -3
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +6 -6
- data/config/jetty.yml +6 -0
- data/config/routes.rb +8 -4
- data/features/browse_dashboard_files.feature +11 -1
- data/features/browse_files.feature +6 -5
- data/features/contact_form.feature +4 -0
- data/features/display_dashboard.feature +6 -3
- data/features/ingest_upload_files.feature +2 -2
- data/features/step_definitions/fixture_steps.rb +6 -5
- data/features/step_definitions/scholarsphere.rb +24 -1
- data/features/step_definitions/user_steps.rb +2 -2
- data/features/step_definitions/web_steps.rb +1 -1
- data/features/support/env.rb +26 -0
- data/features/users.feature +18 -0
- data/lib/active_support/core_ext/marshal.rb +22 -0
- data/lib/generators/sufia/sufia_generator.rb +18 -2
- data/lib/generators/sufia/templates/catalog_controller.rb +3 -4
- data/{spec/support → lib/generators/sufia/templates}/config/redis.yml +0 -0
- data/lib/generators/sufia/templates/config/sufia.rb +68 -0
- data/lib/generators/sufia/templates/migrations/add_ldap_attrs_to_user.rb +41 -0
- data/lib/kaminari/helpers/tag.rb +11 -0
- data/lib/sufia.rb +30 -7
- data/lib/sufia/controller.rb +1 -5
- data/lib/sufia/generic_file.rb +200 -0
- data/lib/sufia/generic_file/audit.rb +119 -0
- data/lib/sufia/generic_file/characterization.rb +82 -0
- data/lib/sufia/generic_file/export.rb +339 -0
- data/lib/sufia/generic_file/permissions.rb +64 -0
- data/lib/sufia/generic_file/thumbnail.rb +68 -0
- data/{app/models → lib/sufia/jobs}/audit_job.rb +13 -3
- data/lib/sufia/jobs/batch_update_job.rb +86 -0
- data/lib/sufia/jobs/characterize_job.rb +35 -0
- data/{app/models → lib/sufia/jobs}/content_delete_event_job.rb +3 -1
- data/{app/models → lib/sufia/jobs}/content_deposit_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/content_new_version_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/content_restored_version_event_job.rb +8 -0
- data/{app/models → lib/sufia/jobs}/content_update_event_job.rb +1 -1
- data/{app/models → lib/sufia/jobs}/event_job.rb +7 -3
- data/{app/models → lib/sufia/jobs}/resolrize_job.rb +4 -2
- data/lib/sufia/jobs/transcode_video_job.rb +79 -0
- data/{app/models → lib/sufia/jobs}/unzip_job.rb +11 -3
- data/{app/models → lib/sufia/jobs}/user_edit_profile_event_job.rb +6 -0
- data/{app/models → lib/sufia/jobs}/user_follow_event_job.rb +9 -4
- data/{app/models → lib/sufia/jobs}/user_unfollow_event_job.rb +6 -0
- data/lib/sufia/queue/resque.rb +30 -0
- data/lib/sufia/role_mapper.rb +0 -1
- data/{app/models/characterize_job.rb → lib/sufia/solr_document_behavior.rb} +6 -7
- data/lib/sufia/user.rb +3 -3
- data/lib/sufia/version.rb +1 -1
- data/lib/tasks/fixtures.rake +38 -38
- data/lib/tasks/resque.rake +1 -0
- data/solr_conf/conf/solrconfig.xml +32 -1615
- data/solr_conf/solr.xml +1 -1
- data/spec/active_fedora/unsaved_digital_object_spec.rb +4 -4
- data/spec/config/host_to_vhost_spec.rb +4 -4
- data/spec/controllers/authorities_controller_spec.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +12 -10
- data/spec/controllers/catalog_controller_spec.rb +13 -13
- data/spec/controllers/dashboard_controller_spec.rb +15 -15
- data/spec/controllers/downloads_controller_spec.rb +14 -14
- data/spec/controllers/generic_files_controller_spec.rb +88 -46
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/sessions_controller_spec.rb +1 -1
- data/spec/controllers/single_use_link_controller_spec.rb +18 -18
- data/spec/controllers/users_controller_spec.rb +47 -31
- data/spec/fixtures/countdown.avi +0 -0
- data/spec/fixtures/sufia/.gitignore +1 -0
- data/spec/fixtures/{scholarsphere → sufia}/bg_header.jpg +0 -0
- data/spec/fixtures/sufia/sufia_test1.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere → sufia}/sufia_test1.foxml.erb +2 -2
- data/spec/fixtures/{scholarsphere/scholarsphere_test1.txt → sufia/sufia_test1.txt} +0 -0
- data/spec/fixtures/sufia/sufia_test2.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test2.docx → sufia/sufia_test2.docx} +0 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test2.foxml.erb → sufia/sufia_test2.foxml.erb} +6 -6
- data/spec/fixtures/sufia/sufia_test3.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test3.foxml.erb → sufia/sufia_test3.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test3.xls → sufia/sufia_test3.xls} +0 -0
- data/spec/fixtures/sufia/sufia_test4.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test4.foxml.erb → sufia/sufia_test4.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test4.pdf → sufia/sufia_test4.pdf} +0 -0
- data/spec/fixtures/sufia/sufia_test5.descMeta.txt +19 -0
- data/spec/fixtures/{scholarsphere → sufia}/sufia_test5.foxml.erb +3 -3
- data/spec/fixtures/{scholarsphere/scholarsphere_test5.mp3 → sufia/sufia_test5.mp3} +0 -0
- data/spec/fixtures/sufia/sufia_test5.txt +1 -0
- data/spec/fixtures/sufia/sufia_test6.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere/scholarsphere_test6.foxml.erb → sufia/sufia_test6.foxml.erb} +6 -6
- data/spec/fixtures/{scholarsphere/scholarsphere_test6.jp2 → sufia/sufia_test6.jp2} +0 -0
- data/spec/fixtures/sufia/sufia_test6.txt +1 -0
- data/spec/fixtures/sufia_generic_stub.descMeta.txt +12 -0
- data/spec/fixtures/{scholarsphere_generic_stub.foxml.erb → sufia_generic_stub.foxml.erb} +3 -3
- data/spec/fixtures/sufia_generic_stub.txt +1 -0
- data/spec/lib/sufia/role_mapper_spec.rb +1 -1
- data/spec/models/audit_job_spec.rb +8 -11
- data/spec/models/batch_spec.rb +5 -5
- data/spec/models/batch_update_job_spec.rb +18 -15
- data/spec/models/checksum_audit_log_spec.rb +6 -19
- data/spec/models/event_jobs_spec.rb +23 -23
- data/spec/models/file_content_datastream_spec.rb +14 -14
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file_spec.rb +88 -41
- data/spec/models/single_use_link_spec.rb +3 -3
- data/spec/models/transcode_video_job_spec.rb +30 -0
- data/spec/models/unzip_job_spec.rb +6 -4
- data/spec/rake/{scholarsphere_fixtures_spec.rb → sufia_fixtures_spec.rb} +16 -16
- data/spec/routing/route_spec.rb +4 -8
- data/spec/spec_helper.rb +0 -7
- data/spec/support/Gemfile +4 -2
- data/spec/support/fedora_conf/fedora.fcfg +953 -0
- data/spec/support/lib/generators/test_app_generator.rb +1 -11
- data/sufia.gemspec +5 -3
- data/tasks/{scholarsphere-db.rake → sufia-db.rake} +1 -1
- data/tasks/{scholarsphere-dev.rake → sufia-dev.rake} +7 -3
- data/tasks/{scholarsphere-fixtures.rake → sufia-fixtures.rake} +43 -43
- data/tasks/{scholarsphere.rake → sufia.rake} +2 -2
- metadata +126 -95
- data/app/models/batch_update_job.rb +0 -82
- data/app/models/solr_document.rb +0 -50
- data/lib/sufia/permissions.rb +0 -43
- data/spec/fixtures/scholarsphere/scholarsphere_test1.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test2.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test3.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test4.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test5.descMeta.txt +0 -19
- data/spec/fixtures/scholarsphere/scholarsphere_test5.txt +0 -1
- data/spec/fixtures/scholarsphere/scholarsphere_test6.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/scholarsphere_test6.txt +0 -1
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.foxml.erb +0 -79
- data/spec/fixtures/scholarsphere/sufia_scholarsphere1.txt +0 -1
- data/spec/fixtures/scholarsphere_generic_stub.descMeta.txt +0 -12
- data/spec/fixtures/scholarsphere_generic_stub.txt +0 -1
data/Gemfile
CHANGED
|
@@ -3,21 +3,18 @@ source 'http://rubygems.org'
|
|
|
3
3
|
# Please see scholarsphere.gemspec for dependency information.
|
|
4
4
|
gemspec
|
|
5
5
|
|
|
6
|
-
#gem 'hydra-batch-edit', :git=>'git://github.com/psu-stewardship/hydra-batch-edit.git', :ref => 'b753c7aeac'
|
|
7
|
-
|
|
8
|
-
gem 'mail_form', :git => 'git://github.com/psu-stewardship/mail_form.git', :ref => '50c00f0'
|
|
9
6
|
|
|
7
|
+
#gem 'mail_form', :git => 'git://github.com/psu-stewardship/mail_form.git', :ref => '50c00f0'
|
|
10
8
|
group :development, :test do
|
|
11
9
|
gem 'sqlite3'
|
|
12
10
|
gem 'unicorn-rails'
|
|
13
11
|
gem "debugger"
|
|
14
12
|
gem 'activerecord-import'
|
|
15
|
-
gem "rails_indexes", :git => "git://github.com/warpc/rails_indexes.git", :ref => '4a550270'
|
|
13
|
+
# gem "rails_indexes", :git => "git://github.com/warpc/rails_indexes.git", :ref => '4a550270'
|
|
16
14
|
gem 'selenium-webdriver'
|
|
17
15
|
gem 'headless'
|
|
18
16
|
gem 'rspec-rails', '>= 2.11.0'
|
|
19
17
|
gem 'ruby-prof'
|
|
20
|
-
gem 'mocha', '0.12.4', :require => false
|
|
21
18
|
gem 'cucumber-rails', '~> 1.0', :require => false
|
|
22
19
|
gem 'database_cleaner'
|
|
23
20
|
gem 'capybara'
|
data/README.md
CHANGED
|
@@ -1,37 +1,69 @@
|
|
|
1
1
|
# Sufia
|
|
2
|
+
## Creating an application
|
|
3
|
+
### Generate base Rails install
|
|
4
|
+
```rails new my_app```
|
|
5
|
+
### Add gems to Gemfile
|
|
6
|
+
```
|
|
7
|
+
gem 'blacklight'
|
|
8
|
+
gem 'hydra-head'
|
|
9
|
+
gem 'sufia'
|
|
10
|
+
gem 'jettywrapper'
|
|
11
|
+
```
|
|
12
|
+
Then `bundle install`
|
|
2
13
|
|
|
3
|
-
Run the blacklight, hydra and
|
|
14
|
+
### Run the blacklight, hydra and sufia generators
|
|
4
15
|
```
|
|
5
16
|
rails g blacklight --devise
|
|
6
17
|
rails g hydra:head -f
|
|
7
18
|
rails g sufia -f
|
|
8
19
|
```
|
|
9
20
|
|
|
10
|
-
Run the migrations
|
|
21
|
+
### Run the migrations
|
|
11
22
|
|
|
12
23
|
```
|
|
13
24
|
rake db:migrate
|
|
14
25
|
```
|
|
15
26
|
|
|
16
|
-
|
|
27
|
+
|
|
28
|
+
### If you want to use the assets that ship with Sufia...
|
|
29
|
+
#### add the following to application.css
|
|
17
30
|
```
|
|
18
|
-
|
|
31
|
+
*= require sufia
|
|
19
32
|
```
|
|
20
|
-
|
|
33
|
+
You'll want to ensure you're not loading the blacklight.css, so remove this line ```*= require_tree .```
|
|
21
34
|
|
|
35
|
+
#### Add the following to application.js
|
|
36
|
+
```
|
|
37
|
+
//= require sufia
|
|
38
|
+
```
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
### Start background workers
|
|
24
41
|
```
|
|
25
|
-
|
|
42
|
+
COUNT=4 QUEUE=* rake environment resque:work
|
|
26
43
|
```
|
|
27
|
-
|
|
44
|
+
See https://github.com/defunkt/resque for more options
|
|
45
|
+
|
|
46
|
+
### If you want to enable transcoding of video
|
|
47
|
+
#### Installing ffmpeg on a mac
|
|
48
|
+
Use homebrew:
|
|
28
49
|
```
|
|
29
|
-
|
|
50
|
+
brew install ffmpeg --with-libvpx --with-libvorbis
|
|
30
51
|
```
|
|
31
52
|
|
|
32
|
-
|
|
53
|
+
## Developers:
|
|
54
|
+
This information is for people who want to modify the engine itself, not an application that uses the engine:
|
|
55
|
+
### Create fixtures
|
|
33
56
|
```
|
|
34
|
-
|
|
57
|
+
# start jetty
|
|
58
|
+
git submodule init && git submodule update
|
|
59
|
+
rake jetty:config
|
|
60
|
+
rake jetty:start
|
|
61
|
+
|
|
62
|
+
# load sufia fixtures
|
|
63
|
+
rake sufia:fixtures:create sufia:fixtures:generate
|
|
35
64
|
rake fixtures
|
|
36
|
-
|
|
65
|
+
|
|
66
|
+
# run the tests
|
|
67
|
+
rake clean spec
|
|
68
|
+
bundle exec cucumber fixtures
|
|
37
69
|
```
|
|
File without changes
|
|
File without changes
|
|
@@ -33,13 +33,12 @@ class BatchController < ApplicationController
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def update
|
|
36
|
-
#ScholarSphere::GenericFile::Permissions.parse_permissions(params)
|
|
37
36
|
authenticate_user!
|
|
38
37
|
@batch = Batch.find_or_create(params[:id])
|
|
39
38
|
@batch.status="processing"
|
|
40
39
|
@batch.save
|
|
41
|
-
|
|
40
|
+
Sufia.queue.push(BatchUpdateJob.new(current_user.user_key, params))
|
|
42
41
|
flash[:notice] = 'Your files are being processed by ScholarSphere in the background. The metadata and access controls you specified are being applied. Files will be marked <span class="label label-important" title="Private">Private</span> until this process is complete (shouldn\'t take too long, hang in there!). You may need to refresh your dashboard to see these updates.'
|
|
43
|
-
redirect_to sufia.
|
|
42
|
+
redirect_to sufia.dashboard_index_path
|
|
44
43
|
end
|
|
45
44
|
end
|
|
@@ -36,19 +36,19 @@ class BatchEditsController < ApplicationController
|
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def after_update
|
|
39
|
-
redirect_to
|
|
39
|
+
redirect_to dashboard_index_path unless request.xhr?
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def update_document(obj)
|
|
43
43
|
super
|
|
44
44
|
obj.date_modified = Time.now.ctime
|
|
45
|
-
obj.set_visibility(params)
|
|
45
|
+
obj.set_visibility(params[:visibility])
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def update
|
|
49
49
|
# keep the batch around if we are doing ajax calls
|
|
50
50
|
batch_sav = batch.dup if request.xhr?
|
|
51
|
-
catalog_index_path =
|
|
51
|
+
catalog_index_path = dashboard_index_path
|
|
52
52
|
type = params["update_type"]
|
|
53
53
|
if (type == "update")
|
|
54
54
|
#params["generic_file"].reject! {|k,v| (v.blank? || (v.respond_to?(:length) && v.length==1 && v.first.blank?))}
|
|
@@ -74,4 +74,4 @@ class BatchEditsController < ApplicationController
|
|
|
74
74
|
render :update_edit
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
end
|
|
77
|
+
end
|
|
@@ -19,18 +19,20 @@ class DashboardController < ApplicationController
|
|
|
19
19
|
include Blacklight::Configurable # comply with BL 3.7
|
|
20
20
|
include Hydra::Controller::ControllerBehavior
|
|
21
21
|
include ActionView::Helpers::DateHelper
|
|
22
|
+
include BlacklightAdvancedSearch::ParseBasicQ
|
|
23
|
+
include BlacklightAdvancedSearch::Controller
|
|
22
24
|
|
|
23
25
|
# This is needed as of BL 3.7
|
|
24
26
|
self.copy_blacklight_config_from(CatalogController)
|
|
25
27
|
|
|
26
28
|
before_filter :authenticate_user!
|
|
27
|
-
before_filter :
|
|
29
|
+
before_filter :enforce_show_permissions, :only=>:show
|
|
28
30
|
before_filter :enforce_viewing_context_for_show_requests, :only=>:show
|
|
29
31
|
|
|
30
32
|
# This applies appropriate access controls to all solr queries (the internal method of this is overidden bellow to only include edit files)
|
|
31
|
-
DashboardController.solr_search_params_logic
|
|
33
|
+
DashboardController.solr_search_params_logic += [:add_access_controls_to_solr_params]
|
|
32
34
|
# This filters out objects that you want to exclude from search results, like FileAssets
|
|
33
|
-
DashboardController.solr_search_params_logic
|
|
35
|
+
DashboardController.solr_search_params_logic += [:exclude_unwanted_models]
|
|
34
36
|
|
|
35
37
|
def index
|
|
36
38
|
extra_head_content << view_context.auto_discovery_link_tag(:rss, sufia.url_for(params.merge(:format => 'rss')), :title => "RSS for results")
|
|
@@ -63,12 +63,8 @@ class GenericFilesController < ApplicationController
|
|
|
63
63
|
def destroy
|
|
64
64
|
pid = @generic_file.noid
|
|
65
65
|
@generic_file.delete
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
rescue Redis::CannotConnectError
|
|
69
|
-
logger.error "Redis is down!"
|
|
70
|
-
end
|
|
71
|
-
redirect_to sufia.dashboard_path, :notice => render_to_string(:partial=>'generic_files/asset_deleted_flash', :locals => { :generic_file => @generic_file })
|
|
66
|
+
Sufia.queue.push(ContentDeleteEventJob.new(pid, current_user.user_key))
|
|
67
|
+
redirect_to sufia.dashboard_index_path, :notice => render_to_string(:partial=>'generic_files/asset_deleted_flash', :locals => { :generic_file => @generic_file })
|
|
72
68
|
end
|
|
73
69
|
|
|
74
70
|
# routed to /files (POST)
|
|
@@ -93,11 +89,7 @@ class GenericFilesController < ApplicationController
|
|
|
93
89
|
else
|
|
94
90
|
create_and_save_generic_file
|
|
95
91
|
if @generic_file
|
|
96
|
-
|
|
97
|
-
Resque.enqueue(ContentDepositEventJob, @generic_file.pid, current_user.user_key)
|
|
98
|
-
rescue Redis::CannotConnectError
|
|
99
|
-
logger.error "Redis is down!"
|
|
100
|
-
end
|
|
92
|
+
Sufia.queue.push(ContentDepositEventJob.new(@generic_file.pid, current_user.user_key))
|
|
101
93
|
respond_to do |format|
|
|
102
94
|
format.html {
|
|
103
95
|
retval = render :json => [@generic_file.to_jq_upload].to_json,
|
|
@@ -153,47 +145,26 @@ class GenericFilesController < ApplicationController
|
|
|
153
145
|
revision = @generic_file.content.get_version(params[:revision])
|
|
154
146
|
@generic_file.add_file_datastream(revision.content, :dsid => 'content')
|
|
155
147
|
version_event = true
|
|
156
|
-
|
|
157
|
-
Resque.enqueue(ContentRestoredVersionEventJob, @generic_file.pid, current_user.user_key, params[:revision])
|
|
158
|
-
rescue Redis::CannotConnectError
|
|
159
|
-
logger.error "Redis is down!"
|
|
160
|
-
end
|
|
148
|
+
Sufia.queue.push(ContentRestoredVersionEventJob.new(@generic_file.pid, current_user.user_key, params[:revision]))
|
|
161
149
|
end
|
|
162
150
|
|
|
163
151
|
if params.has_key?(:filedata)
|
|
164
152
|
return unless virus_check(params[:filedata]) == 0
|
|
165
153
|
add_posted_blob_to_asset(@generic_file, params[:filedata])
|
|
166
154
|
version_event = true
|
|
167
|
-
|
|
168
|
-
Resque.enqueue(ContentNewVersionEventJob, @generic_file.pid, current_user.user_key)
|
|
169
|
-
rescue Redis::CannotConnectError
|
|
170
|
-
logger.error "Redis is down!"
|
|
171
|
-
end
|
|
155
|
+
Sufia.queue.push(ContentNewVersionEventJob.new(@generic_file.pid, current_user.user_key))
|
|
172
156
|
end
|
|
173
157
|
@generic_file.update_attributes(params[:generic_file].reject { |k,v| %w{ Filedata Filename revision part_of date_modified date_uploaded format }.include? k})
|
|
174
|
-
@generic_file.set_visibility(params)
|
|
158
|
+
@generic_file.set_visibility(params[:visibility])
|
|
175
159
|
@generic_file.date_modified = Time.now.ctime
|
|
176
160
|
@generic_file.save
|
|
177
161
|
# do not trigger an update event if a version event has already been triggered
|
|
178
|
-
|
|
179
|
-
Resque.enqueue(ContentUpdateEventJob, @generic_file.pid, current_user.user_key) unless version_event
|
|
180
|
-
rescue Redis::CannotConnectError
|
|
181
|
-
logger.error "Redis is down!"
|
|
182
|
-
end
|
|
162
|
+
Sufia.queue.push(ContentUpdateEventJob.new(@generic_file.pid, current_user.user_key)) unless version_event
|
|
183
163
|
record_version_committer(@generic_file, current_user)
|
|
184
164
|
redirect_to sufia.edit_generic_file_path(:tab => params[:redirect_tab]), :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })
|
|
185
165
|
|
|
186
166
|
end
|
|
187
167
|
|
|
188
|
-
# routed to /files/:id/permissions (POST)
|
|
189
|
-
def permissions
|
|
190
|
-
Sufia::GenericFile::Permissions.parse_permissions(params)
|
|
191
|
-
@generic_file.update_attributes(params[:generic_file].reject { |k,v| %w{ Filedata Filename revision}.include? k})
|
|
192
|
-
@generic_file.save
|
|
193
|
-
Resque.enqueue(ContentUpdateEventJob, @generic_file.pid, current_user.user_key)
|
|
194
|
-
redirect_to sufia.edit_generic_file_path, :notice => render_to_string(:partial=>'generic_files/asset_updated_flash', :locals => { :generic_file => @generic_file })
|
|
195
|
-
end
|
|
196
|
-
|
|
197
168
|
protected
|
|
198
169
|
def record_version_committer(generic_file, user)
|
|
199
170
|
version = generic_file.content.latest_version
|
|
@@ -267,11 +238,76 @@ class GenericFilesController < ApplicationController
|
|
|
267
238
|
end
|
|
268
239
|
|
|
269
240
|
record_version_committer(@generic_file, current_user)
|
|
270
|
-
|
|
271
|
-
Resque.enqueue(UnzipJob, @generic_file.pid) if file.content_type == 'application/zip'
|
|
272
|
-
rescue Redis::CannotConnectError
|
|
273
|
-
logger.error "Redis is down!"
|
|
274
|
-
end
|
|
241
|
+
Sufia.queue.push(UnzipJob.new(@generic_file.pid)) if file.content_type == 'application/zip'
|
|
275
242
|
return @generic_file
|
|
276
243
|
end
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
############################ to get rid of deprication warnings. Need to fix #################
|
|
248
|
+
# Controller "before" filter that delegates enforcement based on the controller action
|
|
249
|
+
# Action-specific implementations are enforce_index_permissions, enforce_show_permissions, etc.
|
|
250
|
+
# @param [Hash] opts (optional, not currently used)
|
|
251
|
+
#
|
|
252
|
+
# @example
|
|
253
|
+
# class CatalogController < ApplicationController
|
|
254
|
+
# before_filter :enforce_access_controls
|
|
255
|
+
# end
|
|
256
|
+
#
|
|
257
|
+
# @deprecated HYDRA-886 Blacklight is now using Catalog#update to store pagination info, so we don't want to enforce_edit_permissions on it. Instead just call before_filter :enforce_show_permissions, :only=>:show. Move all Edit/Update/Delete methods into non-catalog backed controllers.
|
|
258
|
+
def enforce_access_controls(opts={})
|
|
259
|
+
controller_action = params[:action].to_s
|
|
260
|
+
delegate_method = "enforce_#{controller_action}_permissions"
|
|
261
|
+
if self.respond_to?(delegate_method.to_sym, true)
|
|
262
|
+
self.send(delegate_method.to_sym)
|
|
263
|
+
else
|
|
264
|
+
true
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
# Controller "before" filter for enforcing access controls on edit actions
|
|
270
|
+
# @param [Hash] opts (optional, not currently used)
|
|
271
|
+
def enforce_edit_permissions(opts={})
|
|
272
|
+
logger.debug("Enforcing edit permissions")
|
|
273
|
+
load_permissions_from_solr
|
|
274
|
+
if !can? :edit, params[:id]
|
|
275
|
+
session[:viewing_context] = "browse"
|
|
276
|
+
raise Hydra::AccessDenied.new("You do not have sufficient privileges to edit this document. You have been redirected to the read-only view.", :edit, params[:id])
|
|
277
|
+
else
|
|
278
|
+
session[:viewing_context] = "edit"
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
## This method is here for you to override
|
|
283
|
+
def enforce_create_permissions(opts={})
|
|
284
|
+
logger.debug("Enforcing create permissions")
|
|
285
|
+
if !can? :create, ActiveFedora::Base.new
|
|
286
|
+
raise Hydra::AccessDenied.new "You do not have sufficient privileges to create a new document."
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
## proxies to enforce_edit_permssions. This method is here for you to override
|
|
291
|
+
def enforce_update_permissions(opts={})
|
|
292
|
+
enforce_edit_permissions(opts)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
## proxies to enforce_edit_permssions. This method is here for you to override
|
|
296
|
+
def enforce_destroy_permissions(opts={})
|
|
297
|
+
enforce_edit_permissions(opts)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
## proxies to enforce_edit_permssions. This method is here for you to override
|
|
301
|
+
def enforce_new_permissions(opts={})
|
|
302
|
+
enforce_create_permissions(opts)
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
# Controller "before" filter for enforcing access controls on index actions
|
|
306
|
+
# Currently does nothing, instead relies on
|
|
307
|
+
# @param [Hash] opts (optional, not currently used)
|
|
308
|
+
def enforce_index_permissions(opts={})
|
|
309
|
+
# Do nothing. Relies on enforce_search_permissions being included in the Controller's solr_search_params_logic
|
|
310
|
+
return true
|
|
311
|
+
end
|
|
312
|
+
|
|
277
313
|
end
|
|
@@ -50,41 +50,29 @@ class UsersController < ApplicationController
|
|
|
50
50
|
@user.populate_attributes if params[:update_directory]
|
|
51
51
|
@user.avatar = nil if params[:delete_avatar]
|
|
52
52
|
unless @user.save
|
|
53
|
-
redirect_to sufia.edit_profile_path(@user.to_s), alert: @user.errors.full_messages
|
|
53
|
+
redirect_to sufia.edit_profile_path(URI.escape(@user.to_s,'@.')), alert: @user.errors.full_messages
|
|
54
54
|
return
|
|
55
55
|
end
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
rescue Redis::CannotConnectError
|
|
59
|
-
logger.error "Redis is down!"
|
|
60
|
-
end
|
|
61
|
-
redirect_to sufia.profile_path(@user.to_s), notice: "Your profile has been updated"
|
|
56
|
+
Sufia.queue.push(UserEditProfileEventJob.new(@user.user_key))
|
|
57
|
+
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), notice: "Your profile has been updated"
|
|
62
58
|
end
|
|
63
59
|
|
|
64
60
|
# Follow a user
|
|
65
61
|
def follow
|
|
66
62
|
unless current_user.following?(@user)
|
|
67
63
|
current_user.follow(@user)
|
|
68
|
-
|
|
69
|
-
Resque.enqueue(UserFollowEventJob, current_user.user_key, @user.user_key)
|
|
70
|
-
rescue Redis::CannotConnectError
|
|
71
|
-
logger.error "Redis is down!"
|
|
72
|
-
end
|
|
64
|
+
Sufia.queue.push(UserFollowEventJob.new(current_user.user_key, @user.user_key))
|
|
73
65
|
end
|
|
74
|
-
redirect_to sufia.profile_path(@user.to_s), notice: "You are following #{@user.to_s}"
|
|
66
|
+
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), notice: "You are following #{@user.to_s}"
|
|
75
67
|
end
|
|
76
68
|
|
|
77
69
|
# Unfollow a user
|
|
78
70
|
def unfollow
|
|
79
71
|
if current_user.following?(@user)
|
|
80
72
|
current_user.stop_following(@user)
|
|
81
|
-
|
|
82
|
-
Resque.enqueue(UserUnfollowEventJob, current_user.user_key, @user.user_key)
|
|
83
|
-
rescue Redis::CannotConnectError
|
|
84
|
-
logger.error "Redis is down!"
|
|
85
|
-
end
|
|
73
|
+
Sufia.queue.push(UserUnfollowEventJob.new(current_user.user_key, @user.user_key))
|
|
86
74
|
end
|
|
87
|
-
redirect_to sufia.profile_path(@user.to_s), notice: "You are no longer following #{@user.to_s}"
|
|
75
|
+
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), notice: "You are no longer following #{@user.to_s}"
|
|
88
76
|
end
|
|
89
77
|
|
|
90
78
|
private
|
|
@@ -94,11 +82,11 @@ class UsersController < ApplicationController
|
|
|
94
82
|
end
|
|
95
83
|
|
|
96
84
|
def user_is_current_user
|
|
97
|
-
redirect_to sufia.profile_path(@user.to_s), alert: "You cannot edit #{@user.to_s}\'s profile" unless @user == current_user
|
|
85
|
+
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), alert: "You cannot edit #{@user.to_s}\'s profile" unless @user == current_user
|
|
98
86
|
end
|
|
99
87
|
|
|
100
88
|
def user_not_current_user
|
|
101
|
-
redirect_to sufia.profile_path(@user.to_s), alert: "You cannot follow or unfollow yourself" if @user == current_user
|
|
89
|
+
redirect_to sufia.profile_path(URI.escape(@user.to_s,'@.')), alert: "You cannot follow or unfollow yourself" if @user == current_user
|
|
102
90
|
end
|
|
103
91
|
|
|
104
92
|
def get_sort
|
|
@@ -33,7 +33,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
|
33
33
|
render_constraint_element(label,
|
|
34
34
|
localized_params[:q],
|
|
35
35
|
:classes => ["query"],
|
|
36
|
-
:remove =>
|
|
36
|
+
:remove => dashboard_index_path(localized_params.merge(:q=>nil, :action=>'index')))
|
|
37
37
|
else
|
|
38
38
|
render_constraint_element(label,
|
|
39
39
|
localized_params[:q],
|
|
@@ -60,7 +60,7 @@ module Blacklight::RenderConstraintsHelperBehavior
|
|
|
60
60
|
if params[:controller] == 'dashboard'
|
|
61
61
|
render_constraint_element( facet_field_labels[facet],
|
|
62
62
|
val,
|
|
63
|
-
:remove =>
|
|
63
|
+
:remove => dashboard_index_path(remove_facet_params(facet, val, localized_params)),
|
|
64
64
|
:classes => ["filter", "filter-" + facet.parameterize]
|
|
65
65
|
) + "\n"
|
|
66
66
|
else
|
data/app/helpers/sufia_helper.rb
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
module SufiaHelper
|
|
16
17
|
|
|
17
18
|
# link_back_to_dashboard(:label=>'Back to Search')
|
|
@@ -20,7 +21,7 @@ module SufiaHelper
|
|
|
20
21
|
query_params = session[:search] ? session[:search].dup : {}
|
|
21
22
|
query_params.delete :counter
|
|
22
23
|
query_params.delete :total
|
|
23
|
-
link_url =
|
|
24
|
+
link_url = dashboard_index_path + "?" + query_params.to_query
|
|
24
25
|
link_to opts[:label], link_url
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -29,7 +30,7 @@ module SufiaHelper
|
|
|
29
30
|
p.delete :page
|
|
30
31
|
p.delete :action
|
|
31
32
|
p[:q]=query
|
|
32
|
-
link_url =
|
|
33
|
+
link_url = dashboard_index_path(p)
|
|
33
34
|
link_to(query, link_url)
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -81,4 +82,24 @@ module SufiaHelper
|
|
|
81
82
|
chat_id
|
|
82
83
|
end
|
|
83
84
|
end
|
|
85
|
+
|
|
86
|
+
# Override to remove the label class (easier integration with bootstrap)
|
|
87
|
+
# and handles arrays
|
|
88
|
+
def render_facet_value(facet_solr_field, item, options ={})
|
|
89
|
+
if item.is_a? Array
|
|
90
|
+
render_array_facet_value(facet_solr_field, item, options)
|
|
91
|
+
end
|
|
92
|
+
path =sufia.url_for(add_facet_params_and_redirect(facet_solr_field, item.value).merge(:only_path=>true))
|
|
93
|
+
(link_to_unless(options[:suppress_link], item.value, path, :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# link_back_to_catalog(:label=>'Back to Search')
|
|
97
|
+
# Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
|
|
98
|
+
def link_back_to_catalog(opts={:label=>t('blacklight.back_to_search')})
|
|
99
|
+
query_params = session[:search] ? session[:search].dup : {}
|
|
100
|
+
query_params.delete :counter
|
|
101
|
+
query_params.delete :total
|
|
102
|
+
link_url = sufia.url_for(query_params)
|
|
103
|
+
link_to opts[:label], link_url
|
|
104
|
+
end
|
|
84
105
|
end
|