sufia 3.7.2 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +3 -0
- data/README.md +88 -11
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/old_main_tulips.jpg +0 -0
- data/app/assets/javascripts/contact_form.js +0 -16
- data/app/assets/javascripts/jquery.blacklightTagCloud.js +44 -0
- data/app/assets/javascripts/jquery.tagcloud.js +116 -0
- data/app/assets/javascripts/jquery.tinysort.min.js +7 -0
- data/app/assets/javascripts/sufia.js +41 -44
- data/app/assets/javascripts/sufia/edit_metadata.js +1 -1
- data/app/assets/javascripts/sufia/editor.js +12 -0
- data/app/assets/javascripts/sufia/featured_works.js +64 -0
- data/app/assets/javascripts/sufia/fileupload.js +1 -1
- data/app/assets/javascripts/sufia/multiForm.js +1 -1
- data/app/assets/javascripts/sufia/permissions.js +4 -8
- data/app/assets/javascripts/sufia/single_use_link.js +1 -2
- data/app/assets/javascripts/sufia/trophy.js +42 -27
- data/app/assets/javascripts/terms_of_service.js +1 -1
- data/app/assets/stylesheets/dashboard.css.scss +81 -40
- data/app/assets/stylesheets/featured.css.scss +16 -0
- data/app/assets/stylesheets/fileupload/{jquery.fileupload-ui.css → jquery.fileupload-ui.css.erb} +2 -2
- data/app/assets/stylesheets/{generic_files.css → generic_files.css.erb} +6 -7
- data/app/assets/stylesheets/header.css.scss +93 -0
- data/app/assets/stylesheets/home-page.css.scss +50 -0
- data/app/assets/stylesheets/nestable.css.scss +111 -0
- data/app/assets/stylesheets/styles.css.scss +106 -0
- data/app/assets/stylesheets/sufia.css.scss +13 -8
- data/app/assets/stylesheets/tagcloud.css +83 -0
- data/app/assets/stylesheets/usage-stats.css +30 -0
- data/app/controllers/batch_controller.rb +0 -1
- data/app/controllers/concerns/sufia/catalog.rb +64 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +16 -13
- data/app/controllers/content_blocks_controller.rb +8 -0
- data/app/controllers/featured_work_lists_controller.rb +16 -0
- data/app/controllers/featured_works_controller.rb +26 -0
- data/app/controllers/mailbox_controller.rb +1 -1
- data/app/controllers/pages_controller.rb +7 -0
- data/app/controllers/single_use_links_viewer_controller.rb +2 -5
- data/app/controllers/tinymce_assets_controller.rb +12 -0
- data/app/helpers/content_block_helper.rb +21 -0
- data/app/helpers/generic_file_helper.rb +2 -2
- data/app/helpers/sufia_helper.rb +8 -4
- data/app/helpers/trophy_helper.rb +15 -7
- data/app/models/content_block.rb +2 -0
- data/app/models/featured_work_list.rb +42 -0
- data/app/models/tinymce_asset.rb +3 -0
- data/app/uploaders/tinymce_asset_uploader.rb +51 -0
- data/app/views/_add_assets_links.html.erb +0 -16
- data/app/views/_controls.html.erb +17 -0
- data/app/views/_flash_msg.html.erb +2 -18
- data/app/views/_footer.html.erb +10 -15
- data/app/views/_ga.html.erb +0 -16
- data/app/views/_logo.html.erb +2 -2
- data/app/views/_masthead.html.erb +9 -36
- data/app/views/_user_util_links.html.erb +16 -11
- data/app/views/advanced/_advanced_search_facets.html.erb +0 -16
- data/app/views/advanced/_advanced_search_fields.html.erb +0 -16
- data/app/views/advanced/_advanced_search_help.html.erb +0 -16
- data/app/views/advanced/_facet_layout.html.erb +0 -16
- data/app/views/advanced/_facet_limit.html.erb +0 -16
- data/app/views/advanced/index.html.erb +2 -18
- data/app/views/batch/_metadata.html.erb +3 -3
- data/app/views/batch/edit.html.erb +4 -21
- data/app/views/catalog/_facet_limit.html.erb +11 -12
- data/app/views/catalog/_featured_researcher.html.erb +2 -0
- data/app/views/catalog/_home.html.erb +6 -2
- data/app/views/catalog/_home_content.html.erb +36 -0
- data/app/views/catalog/_home_header.html.erb +15 -0
- data/app/views/catalog/_recent_document.html.erb +1 -1
- data/app/views/catalog/_recents.html.erb +3 -4
- data/app/views/catalog/_search_form.html.erb +13 -9
- data/app/views/catalog/_tagcloud.html.erb +7 -0
- data/app/views/catalog/index.html.erb +4 -10
- data/app/views/contact_form/create.html.erb +0 -16
- data/app/views/contact_form/new.html.erb +0 -16
- data/app/views/dashboard/_constraints.html.erb +3 -19
- data/app/views/dashboard/_did_you_mean.html.erb +0 -16
- data/app/views/dashboard/_document_list.html.erb +0 -16
- data/app/views/dashboard/_facet_layout.html.erb +1 -17
- data/app/views/dashboard/_facet_limit.html.erb +5 -5
- data/app/views/dashboard/_facet_selected.html.erb +1 -17
- data/app/views/dashboard/_facets.html.erb +0 -18
- data/app/views/dashboard/_heading.html.erb +1 -1
- data/app/views/dashboard/_index_partials/_default_group.html.erb +7 -23
- data/app/views/dashboard/_index_partials/_list_files.html.erb +62 -57
- data/app/views/dashboard/_search_form.html.erb +10 -7
- data/app/views/dashboard/_show_partials/_default.html.erb +0 -18
- data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -16
- data/app/views/dashboard/_show_partials/_facets.html.erb +0 -16
- data/app/views/dashboard/_sort_and_per_page.html.erb +10 -9
- data/app/views/dashboard/facet.html.erb +4 -19
- data/app/views/dashboard/index.html.erb +27 -49
- data/app/views/error/401.html.erb +1 -17
- data/app/views/error/404.html.erb +0 -16
- data/app/views/error/500.html.erb +0 -16
- data/app/views/error/single_use_error.html.erb +1 -17
- data/app/views/generic_files/_asset_deleted_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_permissions_denial_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_saved_flash.html.erb +0 -16
- data/app/views/generic_files/_asset_updated_flash.html.erb +0 -16
- data/app/views/generic_files/_breadcrumbs.html.erb +0 -16
- data/app/views/generic_files/_browse_everything.html.erb +24 -0
- data/app/views/generic_files/_descriptions.html.erb +1 -1
- data/app/views/generic_files/_field_form.html.erb +5 -5
- data/app/views/generic_files/_media_display.html.erb +3 -3
- data/app/views/generic_files/_permission_form.html.erb +5 -5
- data/app/views/generic_files/_rights_modal.html.erb +13 -29
- data/app/views/generic_files/_show_actions.html.erb +13 -1
- data/app/views/generic_files/_versioning.html.erb +14 -10
- data/app/views/generic_files/citation.html.erb +0 -16
- data/app/views/generic_files/edit.html.erb +10 -12
- data/app/views/generic_files/edit_fields/_default.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_description.html.erb +1 -1
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +2 -3
- data/app/views/generic_files/edit_fields/_rights.html.erb +1 -1
- data/app/views/generic_files/new.html.erb +11 -26
- data/app/views/generic_files/show.html.erb +7 -25
- data/app/views/generic_files/stats.html.erb +141 -0
- data/app/views/homepage/_featured.html.erb +11 -0
- data/app/views/homepage/_featured_fields.html.erb +18 -0
- data/app/views/homepage/_featured_works.html.erb +17 -0
- data/app/views/homepage/_sortable_featured.html.erb +26 -0
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/_homepage_sidebar2.html.erb +14 -0
- data/app/views/layouts/error.html.erb +3 -21
- data/app/views/layouts/homepage.html.erb +8 -37
- data/app/views/layouts/sufia-dashboard.html.erb +46 -0
- data/app/views/layouts/sufia-one-column.html.erb +8 -24
- data/app/views/layouts/sufia-two-column.html.erb +9 -8
- data/app/views/pages/show.html.erb +4 -0
- data/app/views/single_use_links_viewer/show.html.erb +2 -2
- data/app/views/static/agreement.html.erb +0 -17
- data/app/views/static/help.html.erb +0 -17
- data/app/views/static/mendeley.html.erb +0 -16
- data/app/views/static/subject_libraries.html.erb +0 -17
- data/app/views/static/terms.html.erb +0 -16
- data/app/views/static/zotero.html.erb +0 -16
- data/app/views/users/_activity_log.html.erb +2 -2
- data/app/views/users/_contributions.html.erb +6 -2
- data/app/views/users/_follower_modal.html.erb +2 -2
- data/app/views/users/_following_modal.html.erb +2 -2
- data/app/views/users/_left_sidebar.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +1 -1
- data/app/views/users/_notify_number.html.erb +1 -1
- data/app/views/users/_profile_actions.html.erb +3 -3
- data/app/views/users/_profile_tabs.html.erb +1 -1
- data/app/views/users/_search_form.html.erb +3 -2
- data/app/views/users/_social_media_info.html.erb +3 -3
- data/app/views/users/_trophy_edit.html.erb +2 -2
- data/app/views/users/_user_info.html.erb +27 -27
- data/app/views/users/_vitals.html.erb +2 -2
- data/app/views/users/edit.html.erb +39 -39
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/show.html.erb +7 -9
- data/config/locales/sufia.en.yml +15 -7
- data/config/routes.rb +12 -9
- data/lib/generators/sufia/sufia_generator.rb +18 -15
- data/lib/generators/sufia/templates/catalog_controller.rb +11 -73
- data/lib/generators/sufia/templates/config/tinymce.yml +7 -0
- data/lib/sufia.rb +7 -0
- data/lib/sufia/downloads_controller_behavior.rb +3 -4
- data/lib/sufia/files_controller_behavior.rb +38 -27
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/batch_controller_spec.rb +1 -1
- data/spec/controllers/batch_edits_controller_spec.rb +5 -5
- data/spec/controllers/catalog_controller_spec.rb +37 -58
- data/spec/controllers/content_blocks_controller_spec.rb +37 -0
- data/spec/controllers/downloads_controller_spec.rb +3 -11
- data/spec/controllers/featured_work_lists_controller_spec.rb +20 -0
- data/spec/controllers/featured_works_controller_spec.rb +50 -0
- data/spec/controllers/generic_files_controller_spec.rb +74 -9
- data/spec/controllers/mailbox_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +25 -0
- data/spec/controllers/single_use_links_controller_spec.rb +1 -1
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +1 -1
- data/spec/controllers/tinymce_assets_controller_spec.rb +39 -0
- data/spec/controllers/users_controller_spec.rb +3 -8
- data/spec/factories/content_blocks.rb +4 -0
- data/spec/factories/featured_works.rb +4 -0
- data/spec/factories/generic_files.rb +46 -39
- data/spec/factories/users.rb +18 -18
- data/spec/features/browse_dashboard_files_spec.rb +6 -7
- data/spec/features/browse_files_spec.rb +9 -6
- data/spec/features/cloud_upload_spec.rb +18 -0
- data/spec/features/single_use_links_spec.rb +2 -3
- data/spec/helpers/content_block_helper_spec.rb +31 -0
- data/spec/helpers/generic_file_helper_spec.rb +3 -3
- data/spec/helpers/sufia_helper_spec.rb +13 -81
- data/spec/helpers/trophy_helper_spec.rb +39 -0
- data/spec/jobs/import_url_job_spec.rb +1 -1
- data/spec/jobs/ingest_local_file_job_spec.rb +1 -1
- data/spec/lib/sufia/usage_statistics_spec.rb +75 -0
- data/spec/models/ability_spec.rb +31 -0
- data/spec/models/active_fedora_pid_based_job_spec.rb +1 -1
- data/spec/models/audit_job_spec.rb +1 -1
- data/spec/models/batch_spec.rb +1 -1
- data/spec/models/batch_update_job_spec.rb +1 -1
- data/spec/models/event_jobs_spec.rb +1 -1
- data/spec/models/featured_work_list_spec.rb +23 -0
- data/spec/models/featured_work_spec.rb +42 -0
- data/spec/models/fits_datastream_spec.rb +2 -2
- data/spec/models/generic_file/reload_on_save_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +4 -4
- data/spec/models/generic_file_spec.rb +41 -40
- data/spec/models/pageview.rb +19 -0
- data/spec/models/properties_datastream_spec.rb +2 -2
- data/spec/models/solr_document_spec.rb +9 -0
- data/spec/models/user_spec.rb +2 -2
- data/spec/routing/featured_works_route_spec.rb +16 -0
- data/spec/routing/route_spec.rb +10 -15
- data/spec/spec_helper.rb +3 -0
- data/spec/support/lib/generators/test_app_generator.rb +19 -8
- data/spec/views/dashboard/facet_limit.html.erb_spec.rb +2 -2
- data/spec/views/generic_file/show.html.erb_spec.rb +44 -0
- data/spec/views/generic_file/stats.html.erb_spec.rb +47 -0
- data/spec/views/users/_follower_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/_following_modal.html.erb_spec.rb +18 -0
- data/spec/views/users/index.html.erb_spec.rb +1 -1
- data/sufia-models/app/models/batch.rb +1 -1
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +30 -0
- data/sufia-models/app/models/concerns/sufia/user.rb +1 -1
- data/sufia-models/app/models/datastreams/batch_rdf_datastream.rb +4 -7
- data/sufia-models/app/models/datastreams/fits_datastream.rb +3 -0
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +53 -51
- data/sufia-models/app/models/datastreams/properties_datastream.rb +1 -15
- data/sufia-models/app/models/featured_work.rb +22 -0
- data/sufia-models/app/models/sufia/pageview.rb +9 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/id_service.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/services/sufia}/noid.rb +0 -0
- data/sufia-models/app/services/sufia/usage_statistics.rb +73 -0
- data/sufia-models/config/locales/sufia.en.yml +3 -4
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +23 -8
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +9 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +6 -0
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +11 -2
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +10 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +12 -0
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +8 -0
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +19 -0
- data/sufia-models/lib/sufia/ability.rb +34 -0
- data/sufia-models/lib/sufia/models/engine.rb +5 -3
- data/sufia-models/lib/sufia/models/generic_file.rb +4 -2
- data/sufia-models/lib/sufia/models/generic_file/export.rb +3 -3
- data/sufia-models/lib/sufia/models/generic_file/featured.rb +14 -0
- data/sufia-models/lib/sufia/models/solr_document_behavior.rb +11 -4
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +6 -5
- data/sufia.gemspec +6 -4
- data/tasks/release.rake +1 -0
- data/tasks/sufia-dev.rake +5 -1
- data/vendor/assets/javascripts/flot/excanvas.js +1428 -0
- data/vendor/assets/javascripts/flot/jquery.flot.js +3137 -0
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +360 -0
- data/vendor/assets/javascripts/flot/jquery.flot.time.js +431 -0
- data/vendor/assets/javascripts/nestable.js +647 -0
- data/vendor/assets/javascripts/video.js +135 -126
- data/{app → vendor}/assets/stylesheets/video-js.css.erb +7 -6
- metadata +155 -33
- data/app/assets/stylesheets/application-bootstrap.css.erb +0 -295
- data/app/assets/stylesheets/audio-js.css +0 -3
- data/app/assets/stylesheets/blacklight_more_facets.css +0 -427
- data/app/assets/stylesheets/bootstrap.min.css.erb +0 -1433
- data/app/assets/stylesheets/contact_form.css +0 -4
- data/app/assets/stylesheets/reset_body.css +0 -4
- data/app/assets/stylesheets/trophy.css +0 -7
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -84
- data/app/helpers/facets_helper.rb +0 -3
- data/app/helpers/sufia/facets_helper_behavior.rb +0 -23
- data/app/views/catalog/_home_text.html.erb +0 -10
- data/app/views/generic_files/_dropbox_import.html.erb +0 -3
- data/app/views/generic_files/upload/_dropbox_chooser.html.erb +0 -39
- data/app/views/static/about.html.erb +0 -21
- data/spec/helpers/render_constraints_helper_behavior_spec.rb +0 -42
data/lib/sufia.rb
CHANGED
@@ -3,9 +3,13 @@ require 'blacklight'
|
|
3
3
|
require 'blacklight_advanced_search'
|
4
4
|
require 'hydra/head'
|
5
5
|
require 'hydra-batch-edit'
|
6
|
+
require 'browse-everything'
|
6
7
|
require 'sufia/models'
|
7
8
|
|
8
9
|
require 'rails_autolink'
|
10
|
+
require 'font-awesome-sass-rails'
|
11
|
+
require 'tinymce-rails'
|
12
|
+
require 'tinymce-rails-imageupload'
|
9
13
|
|
10
14
|
module Sufia
|
11
15
|
extend ActiveSupport::Autoload
|
@@ -19,9 +23,12 @@ module Sufia
|
|
19
23
|
#{config.root}/app/models/datastreams
|
20
24
|
#{Hydra::Engine.root}/app/models/concerns
|
21
25
|
)
|
26
|
+
|
27
|
+
config.assets.paths << config.root.join('vendor', 'assets', 'fonts')
|
22
28
|
end
|
23
29
|
|
24
30
|
autoload :Controller
|
31
|
+
autoload :Ability
|
25
32
|
autoload :HttpHeaderAuth
|
26
33
|
autoload :FilesControllerBehavior
|
27
34
|
autoload :BatchEditsControllerBehavior
|
@@ -7,10 +7,10 @@ module Sufia
|
|
7
7
|
# module mixes in normalize_identifier method
|
8
8
|
include Sufia::Noid
|
9
9
|
|
10
|
-
# moved check into the routine so we can handle the user with no access
|
11
|
-
prepend_before_filter :normalize_identifier
|
10
|
+
# moved check into the routine so we can handle the user with no access
|
11
|
+
prepend_before_filter :normalize_identifier
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def datastream_name
|
15
15
|
if datastream.dsid == self.class.default_content_dsid
|
16
16
|
params[:filename] || asset.label
|
@@ -18,6 +18,5 @@ module Sufia
|
|
18
18
|
params[:datastream_id]
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
22
21
|
end
|
23
22
|
end
|
@@ -9,19 +9,18 @@ module Sufia
|
|
9
9
|
|
10
10
|
included do
|
11
11
|
include Hydra::Controller::ControllerBehavior
|
12
|
-
include Blacklight::Configurable
|
13
|
-
include Sufia::Noid # for normalize_identifier method
|
12
|
+
include Blacklight::Configurable
|
13
|
+
include Sufia::Noid # for normalize_identifier method
|
14
14
|
include Sufia::FilesController::LocalIngestBehavior
|
15
15
|
extend Sufia::FilesController::UploadCompleteBehavior
|
16
16
|
|
17
17
|
layout "sufia-one-column"
|
18
|
-
|
19
|
-
# This is needed as of BL 3.7
|
18
|
+
|
20
19
|
self.copy_blacklight_config_from(CatalogController)
|
21
20
|
|
22
21
|
# Catch permission errors
|
23
22
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied do |exception|
|
24
|
-
if
|
23
|
+
if exception.action == :edit
|
25
24
|
redirect_to(sufia.url_for({:action=>'show'}), :alert => "You do not have sufficient privileges to edit this document")
|
26
25
|
elsif current_user and current_user.persisted?
|
27
26
|
redirect_to root_url, :alert => exception.message
|
@@ -31,13 +30,13 @@ module Sufia
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
# actions: audit, index, create, new, edit, show, update,
|
33
|
+
# actions: audit, index, create, new, edit, show, update,
|
34
|
+
# destroy, permissions, citation, stats
|
35
35
|
before_filter :authenticate_user!, :except => [:show, :citation]
|
36
36
|
before_filter :has_access?, :except => [:show]
|
37
37
|
prepend_before_filter :normalize_identifier, :except => [:index, :create, :new]
|
38
38
|
load_resource :only=>[:audit]
|
39
39
|
load_and_authorize_resource :except=>[:index, :audit]
|
40
|
-
|
41
40
|
end
|
42
41
|
|
43
42
|
# routed to /files/new
|
@@ -52,6 +51,19 @@ module Sufia
|
|
52
51
|
@groups = current_user.groups
|
53
52
|
end
|
54
53
|
|
54
|
+
# routed to /files/:id/stats
|
55
|
+
def stats
|
56
|
+
path = sufia.generic_file_path(Sufia::Noid.noidify(params[:id]))
|
57
|
+
# Pull back results from GA, filter them for path, and hashify
|
58
|
+
@created = DateTime.parse(::GenericFile.find(params[:id]).create_date)
|
59
|
+
results_list = Sufia::UsageStatistics.profile.pageview(
|
60
|
+
start_date: @created,
|
61
|
+
end_date: DateTime.now,
|
62
|
+
sort: 'date').for_path(path)
|
63
|
+
@stats_json = Sufia::UsageStatistics.as_flot_json(results_list)
|
64
|
+
@pageviews = Sufia::UsageStatistics.total_pageviews(results_list)
|
65
|
+
end
|
66
|
+
|
55
67
|
# routed to /files/:id (DELETE)
|
56
68
|
def destroy
|
57
69
|
pid = @generic_file.noid
|
@@ -64,30 +76,31 @@ module Sufia
|
|
64
76
|
def create
|
65
77
|
if params[:local_file].present?
|
66
78
|
perform_local_ingest
|
79
|
+
elsif params[:selected_files].present?
|
80
|
+
create_from_browse_everything(params)
|
67
81
|
else
|
68
|
-
|
69
|
-
when 'dropbox'
|
70
|
-
create_from_url(params)
|
71
|
-
else
|
72
|
-
create_from_upload(params)
|
73
|
-
end
|
82
|
+
create_from_upload(params)
|
74
83
|
end
|
75
84
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
next if db_file.blank?
|
82
|
-
# do not remove ::
|
83
|
-
@generic_file = ::GenericFile.new
|
84
|
-
@generic_file.import_url = db_file
|
85
|
-
@generic_file.label = File.basename(db_file)
|
86
|
-
create_metadata(@generic_file)
|
87
|
-
Sufia.queue.push(ImportUrlJob.new(@generic_file.pid))
|
85
|
+
|
86
|
+
def create_from_browse_everything(params)
|
87
|
+
params[:selected_files].each_pair do |index, file_info|
|
88
|
+
next if file_info.blank? || file_info["url"].blank?
|
89
|
+
create_file_from_url(file_info["url"])
|
88
90
|
end
|
89
91
|
redirect_to self.class.upload_complete_path( params[:batch_id])
|
90
92
|
end
|
93
|
+
|
94
|
+
# Generic utility for creating GenericFile from a URL
|
95
|
+
# Used in to import files using URLs from a file picker like browse_everything
|
96
|
+
def create_file_from_url(url, batch_id=nil)
|
97
|
+
@generic_file = ::GenericFile.new
|
98
|
+
@generic_file.import_url = url
|
99
|
+
@generic_file.label = File.basename(url)
|
100
|
+
create_metadata(@generic_file)
|
101
|
+
Sufia.queue.push(ImportUrlJob.new(@generic_file.pid))
|
102
|
+
return @generic_file
|
103
|
+
end
|
91
104
|
|
92
105
|
def create_from_upload(params)
|
93
106
|
# check error condition No files
|
@@ -171,7 +184,6 @@ module Sufia
|
|
171
184
|
|
172
185
|
protected
|
173
186
|
|
174
|
-
|
175
187
|
def json_error(error, name=nil, additional_arguments={})
|
176
188
|
args = {:error => error}
|
177
189
|
args[:name] = name if name
|
@@ -226,7 +238,6 @@ module Sufia
|
|
226
238
|
@generic_file.relative_path = params[:relative_path] if params[:relative_path]
|
227
239
|
end
|
228
240
|
|
229
|
-
|
230
241
|
# this is provided so that implementing application can override this behavior and map params to different attributes
|
231
242
|
def update_metadata
|
232
243
|
@generic_file.attributes = @generic_file.sanitize_attributes(params[:generic_file])
|
data/lib/sufia/version.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe BatchController do
|
4
4
|
before do
|
5
5
|
controller.stub(:has_access?).and_return(true)
|
6
|
-
@user = FactoryGirl.find_or_create(:
|
6
|
+
@user = FactoryGirl.find_or_create(:jill)
|
7
7
|
sign_in @user
|
8
8
|
User.any_instance.stub(:groups).and_return([])
|
9
9
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe BatchEditsController do
|
4
4
|
before do
|
5
5
|
controller.stub(:has_access?).and_return(true)
|
6
|
-
@user = FactoryGirl.find_or_create(:
|
6
|
+
@user = FactoryGirl.find_or_create(:jill)
|
7
7
|
sign_in @user
|
8
8
|
User.any_instance.stub(:groups).and_return([])
|
9
9
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
@@ -14,9 +14,9 @@ describe BatchEditsController do
|
|
14
14
|
|
15
15
|
describe "edit" do
|
16
16
|
before do
|
17
|
-
@one = GenericFile.new(:creator=>"Fred", :language=>'en')
|
17
|
+
@one = GenericFile.new(:creator=>"Fred", :language=>'en')#, :resource_type=>'foo')
|
18
18
|
@one.apply_depositor_metadata('mjg36')
|
19
|
-
@two = GenericFile.new(:creator=>"Wilma", :publisher=>'Rand McNally', :language=>'en')
|
19
|
+
@two = GenericFile.new(:creator=>"Wilma", :publisher=>'Rand McNally', :language=>'en', :resource_type=>'bar')
|
20
20
|
@two.apply_depositor_metadata('mjg36')
|
21
21
|
@one.save!
|
22
22
|
@two.save!
|
@@ -27,14 +27,14 @@ describe BatchEditsController do
|
|
27
27
|
it "should be successful" do
|
28
28
|
get :edit
|
29
29
|
response.should be_successful
|
30
|
-
assigns[:terms].should == [:creator, :contributor, :description, :tag, :rights, :publisher,
|
30
|
+
assigns[:terms].should == [:creator, :contributor, :description, :tag, :rights, :publisher,
|
31
31
|
:date_created, :subject, :language, :identifier, :based_near, :related_url]
|
32
32
|
assigns[:show_file].creator.should == ["Fred", "Wilma"]
|
33
33
|
assigns[:show_file].publisher.should == ["Rand McNally"]
|
34
34
|
assigns[:show_file].language.should == ["en"]
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
describe "update" do
|
39
39
|
before do
|
40
40
|
@one = GenericFile.new(:creator=>"Fred", :language=>'en')
|
@@ -1,98 +1,77 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CatalogController do
|
4
|
+
let(:user) { FactoryGirl.find_or_create(:jill) }
|
4
5
|
before do
|
5
6
|
GenericFile.any_instance.stub(:characterize_if_changed).and_yield
|
6
|
-
|
7
|
-
sign_in @user
|
8
|
-
User.any_instance.stub(:groups).and_return([])
|
9
|
-
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
10
|
-
end
|
11
|
-
after do
|
12
|
-
@user.delete
|
7
|
+
sign_in user
|
13
8
|
end
|
9
|
+
|
14
10
|
describe "#index" do
|
15
11
|
before (:all) do
|
16
|
-
GenericFile.
|
17
|
-
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', read_groups:['public'])
|
12
|
+
GenericFile.delete_all
|
13
|
+
@gf1 = GenericFile.new(title:'Test Document PDF', filename:'test.pdf', tag:'rocks', read_groups:['public'])
|
18
14
|
@gf1.apply_depositor_metadata('mjg36')
|
19
15
|
@gf1.save
|
20
|
-
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', contributor:'Contrib1', read_groups:['public'])
|
16
|
+
@gf2 = GenericFile.new(title:'Test 2 Document', filename:'test2.doc', tag:'clouds', contributor:'Contrib1', read_groups:['public'])
|
21
17
|
@gf2.apply_depositor_metadata('mjg36')
|
22
18
|
@gf2.save
|
23
19
|
end
|
20
|
+
|
24
21
|
after (:all) do
|
25
22
|
@gf1.delete
|
26
23
|
@gf2.delete
|
27
24
|
end
|
25
|
+
|
28
26
|
describe "term search" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
it "should find pdf files" do
|
33
|
-
response.should be_success
|
27
|
+
it "should find records" do
|
28
|
+
get :index, q: "pdf"
|
29
|
+
expect(response).to be_success
|
34
30
|
response.should render_template('catalog/index')
|
35
31
|
assigns(:document_list).map(&:id).should == [@gf1.id]
|
36
|
-
|
37
32
|
assigns(:document_list).count.should eql(1)
|
38
33
|
assigns(:document_list).first['desc_metadata__title_tesim'].should == ['Test Document PDF']
|
39
34
|
end
|
35
|
+
it "should search keywords" do
|
36
|
+
get :index, q: "rocks"
|
37
|
+
assigns(:document_list).map(&:id).should == [@gf1.id]
|
38
|
+
end
|
40
39
|
end
|
40
|
+
|
41
41
|
describe "facet search" do
|
42
42
|
before do
|
43
43
|
# TODO: this is not how a facet query is done.
|
44
|
-
|
44
|
+
get :index, :q=>"{f=desc_metadata__contributor_tesim}Contrib1"
|
45
45
|
end
|
46
46
|
it "should find facet files" do
|
47
|
-
response.
|
47
|
+
expect(response).to be_success
|
48
48
|
response.should render_template('catalog/index')
|
49
49
|
assigns(:document_list).count.should eql(1)
|
50
50
|
end
|
51
51
|
end
|
52
|
-
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
sleep 1 # make sure next file is not at the same time compare
|
64
|
-
@gf3 = GenericFile.new(title:'Generic File 3', contributor:'contributor 3', resource_type:'type 3', read_groups:['public'])
|
65
|
-
@gf3.apply_depositor_metadata('mjg36')
|
66
|
-
@gf3.save!
|
67
|
-
sleep 1 # make sure next file is not at the same time compare
|
68
|
-
@gf4 = GenericFile.new(title:'Generic File 4', contributor:'contributor 4', resource_type:'type 4', read_groups:['public'])
|
69
|
-
@gf4.apply_depositor_metadata('mjg36')
|
70
|
-
@gf4.save!
|
71
|
-
xhr :get, :recent
|
72
|
-
end
|
53
|
+
describe "without search" do
|
54
|
+
it "should set featured researcher" do
|
55
|
+
get :index
|
56
|
+
expect(response).to be_success
|
57
|
+
assigns(:featured_researcher).tap do |researcher|
|
58
|
+
expect(researcher).to be_kind_of ContentBlock
|
59
|
+
expect(researcher.name).to eq 'featured_researcher'
|
60
|
+
end
|
61
|
+
end
|
73
62
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
@gf4.delete
|
79
|
-
end
|
63
|
+
context "with featured works" do
|
64
|
+
before do
|
65
|
+
FeaturedWork.create!(generic_file_id: @gf1.id)
|
66
|
+
end
|
80
67
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
lgf1 = assigns(:recent_documents)[0]
|
88
|
-
lgf4 = assigns(:recent_documents)[3]
|
89
|
-
lgf4['desc_metadata__title_tesim'].should == ['Generic File 4']
|
90
|
-
lgf4['desc_metadata__contributor_tesim'].should == ['contributor 4']
|
91
|
-
lgf4['desc_metadata__resource_type_tesim'].should == ['type 4']
|
68
|
+
it "should set featured works" do
|
69
|
+
get :index
|
70
|
+
expect(response).to be_success
|
71
|
+
expect(assigns(:featured_work_list)).to be_kind_of FeaturedWorkList
|
72
|
+
end
|
73
|
+
end
|
92
74
|
|
93
|
-
lgf1['desc_metadata__title_tesim'].should == ['Generic File 1']
|
94
|
-
lgf1['desc_metadata__contributor_tesim'].should == ['contributor 1']
|
95
|
-
lgf1['desc_metadata__resource_type_tesim'].should == ['type 1']
|
96
75
|
end
|
97
76
|
end
|
98
77
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ContentBlocksController do
|
4
|
+
describe "#update" do
|
5
|
+
let(:content_block) { FactoryGirl.create(:content_block) }
|
6
|
+
before { request.env["HTTP_REFERER"] = "whence_i_came" }
|
7
|
+
|
8
|
+
context "when not logged in" do
|
9
|
+
it "should redirect to root path" do
|
10
|
+
patch :update, id: content_block, content_block: { value: 'foo' }
|
11
|
+
expect(response).to redirect_to main_app.new_user_session_path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when logged in" do
|
16
|
+
let(:user) { FactoryGirl.create(:user) }
|
17
|
+
before { controller.stub(current_user: user) }
|
18
|
+
|
19
|
+
context "as a user in the admin group" do
|
20
|
+
before { user.should_receive(:groups).and_return( ['admin', 'registered']) }
|
21
|
+
|
22
|
+
it "should save" do
|
23
|
+
patch :update, id: content_block, content_block: { value: 'foo' }
|
24
|
+
expect(response).to redirect_to "whence_i_came"
|
25
|
+
expect(assigns[:content_block].value).to eq 'foo'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "as a user without permission" do
|
30
|
+
it "should redirect to root path" do
|
31
|
+
patch :update, id: content_block, content_block: { value: 'foo' }
|
32
|
+
expect(response).to redirect_to root_path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -21,10 +21,6 @@ describe DownloadsController do
|
|
21
21
|
User.any_instance.stub(:groups).and_return([])
|
22
22
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
23
23
|
end
|
24
|
-
after do
|
25
|
-
arch = FactoryGirl.find(:archivist) rescue
|
26
|
-
arch.delete if arch
|
27
|
-
end
|
28
24
|
describe "show" do
|
29
25
|
it "should default to returning configured default download" do
|
30
26
|
DownloadsController.default_content_dsid.should == "content"
|
@@ -64,20 +60,16 @@ describe DownloadsController do
|
|
64
60
|
|
65
61
|
describe "when not logged in as reader" do
|
66
62
|
before do
|
67
|
-
sign_in FactoryGirl.find_or_create(:
|
63
|
+
sign_in FactoryGirl.find_or_create(:jill)
|
68
64
|
User.any_instance.stub(:groups).and_return([])
|
69
65
|
controller.stub(:clear_session_user) ## Don't clear out the authenticated session
|
70
66
|
end
|
71
|
-
|
72
|
-
user = FactoryGirl.find(:user) rescue
|
73
|
-
user.delete if user
|
74
|
-
end
|
75
|
-
|
67
|
+
|
76
68
|
describe "show" do
|
77
69
|
it "should deny access" do
|
78
70
|
get "show", :id => "test1"
|
79
71
|
response.should redirect_to root_path
|
80
|
-
flash[:alert].should ==
|
72
|
+
flash[:alert].should == 'You are not authorized to access this page.'
|
81
73
|
end
|
82
74
|
end
|
83
75
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FeaturedWorkListsController do
|
4
|
+
describe "#create" do
|
5
|
+
before do
|
6
|
+
expect(controller).to receive(:authorize!).with(:update, FeaturedWork)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:feature1) { FactoryGirl.create(:featured_work) }
|
10
|
+
let(:feature2) { FactoryGirl.create(:featured_work) }
|
11
|
+
|
12
|
+
it "should be successful" do
|
13
|
+
post :create, format: :json, featured_work_list: {
|
14
|
+
featured_works_attributes: [{id: feature1.id, order: "2"},
|
15
|
+
{id: feature2.id, order: "1"}]
|
16
|
+
}
|
17
|
+
expect(feature1.reload.order).to eq 2
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|