sufia 4.0.0.beta2 → 4.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +6 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/folder.png +0 -0
- data/app/assets/javascripts/sufia.js +5 -0
- data/app/assets/javascripts/sufia/app.js +1 -0
- data/app/assets/javascripts/sufia/batch_select_all.js +1 -2
- data/app/assets/javascripts/sufia/dashboard_actions.js +13 -0
- data/app/assets/javascripts/sufia/editor.js +1 -1
- data/app/assets/javascripts/sufia/ga_events.js +10 -0
- data/app/assets/javascripts/sufia/search.js +67 -0
- data/app/assets/stylesheets/dashboard.css.scss +15 -1
- data/app/assets/stylesheets/sufia.css.scss +12 -0
- data/app/controllers/authorities_controller.rb +4 -4
- data/app/controllers/batch_controller.rb +4 -4
- data/app/controllers/collections_controller.rb +44 -0
- data/{lib → app/controllers/concerns}/sufia/batch_edits_controller_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/catalog.rb +9 -45
- data/{lib → app/controllers/concerns}/sufia/controller.rb +11 -21
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +34 -6
- data/{lib → app/controllers/concerns}/sufia/downloads_controller_behavior.rb +0 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +35 -0
- data/{lib → app/controllers/concerns}/sufia/files_controller/local_ingest_behavior.rb +19 -7
- data/{lib → app/controllers/concerns}/sufia/files_controller/upload_complete_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +219 -0
- data/app/controllers/concerns/sufia/homepage_controller.rb +41 -0
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +3 -2
- data/app/controllers/dashboard/collections_controller.rb +19 -0
- data/app/controllers/dashboard/files_controller.rb +13 -0
- data/app/controllers/dashboard/highlights_controller.rb +20 -0
- data/app/controllers/dashboard/lists_controller.rb +13 -0
- data/app/controllers/dashboard/shares_controller.rb +19 -0
- data/app/controllers/directory_controller.rb +8 -8
- data/app/controllers/featured_work_lists_controller.rb +1 -1
- data/app/controllers/homepage_controller.rb +4 -0
- data/app/controllers/single_use_links_controller.rb +6 -6
- data/app/controllers/single_use_links_viewer_controller.rb +6 -6
- data/app/controllers/static_controller.rb +4 -3
- data/app/helpers/batch_edits_helper.rb +3 -6
- data/app/helpers/content_block_helper.rb +7 -2
- data/app/helpers/generic_file_helper.rb +33 -39
- data/app/helpers/records_helper.rb +4 -0
- data/app/helpers/sufia/blacklight_override.rb +11 -0
- data/app/helpers/sufia/records_helper_behavior.rb +38 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +109 -0
- data/{sufia-models/lib/sufia/models → app/models/concerns/sufia}/solr_document_behavior.rb +6 -1
- data/app/models/contact_form.rb +13 -13
- data/app/uploaders/tinymce_asset_uploader.rb +2 -2
- data/app/views/_controls.html.erb +1 -1
- data/app/views/_flash_msg.html.erb +2 -8
- data/app/views/_ga.html.erb +4 -0
- data/app/views/_user_util_links.html.erb +7 -7
- data/app/views/advanced/_advanced_search_facets.html.erb +1 -1
- data/app/views/advanced/_advanced_search_fields.html.erb +2 -2
- data/app/views/advanced/_advanced_search_form.html.erb +12 -12
- data/app/views/batch/_metadata.html.erb +12 -12
- data/app/views/batch/_more_metadata.html.erb +1 -2
- data/app/views/batch/edit.html.erb +5 -5
- data/app/views/batch_edits/_check_all.html.erb +1 -1
- data/app/views/batch_edits/_delete_selected.html.erb +2 -3
- data/app/views/batch_edits/edit.html.erb +20 -21
- data/app/views/catalog/_bookmark_control.html.erb +7 -8
- data/app/views/catalog/_constraints_element.html.erb +2 -2
- data/app/views/catalog/_delete_partials/_default.html.erb +9 -12
- data/app/views/catalog/_document.html.erb +5 -5
- data/app/views/catalog/_document_list.html.erb +2 -2
- data/app/views/catalog/_edit_partials/_default.html.erb +6 -9
- data/app/views/catalog/_edit_partials/_default_details.html.erb +2 -4
- data/app/views/catalog/_email_form.html.erb +1 -1
- data/app/views/catalog/_facet_limit.html.erb +6 -7
- data/app/views/catalog/_facet_selected.html.erb +3 -3
- data/app/views/catalog/_folder_control.html.erb +7 -8
- data/app/views/catalog/_index_default.html.erb +2 -2
- data/app/views/catalog/_index_header_default.html.erb +20 -0
- data/app/views/catalog/_index_partials/_default_group.html.erb +1 -1
- data/app/views/catalog/_index_partials/_list_files.html.erb +5 -2
- data/app/views/catalog/_refworks_form.html.erb +2 -2
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +24 -9
- data/app/views/catalog/_show_default.html.erb +2 -2
- data/app/views/catalog/_show_partials/_default.html.erb +4 -5
- data/app/views/catalog/_show_partials/_default_details.html.erb +5 -5
- data/app/views/catalog/_show_partials/_facets.html.erb +7 -7
- data/app/views/catalog/_show_tools.html.erb +6 -6
- data/app/views/catalog/_sms_form.html.erb +1 -1
- data/app/views/catalog/_sort_and_per_page.html.erb +8 -14
- data/app/views/catalog/citation.html.erb +1 -1
- data/app/views/catalog/email.erb +1 -1
- data/app/views/catalog/index.html.erb +16 -27
- data/app/views/catalog/recent.js.erb +1 -1
- data/app/views/catalog/show.html.erb +2 -2
- data/app/views/catalog/sms.erb +1 -1
- data/app/views/collections/_action_menu.html.erb +24 -0
- data/app/views/collections/_batch_edits_actions.html.erb +3 -0
- data/app/views/collections/_button_for_creating_empty_collection.html.erb +3 -0
- data/app/views/collections/_dashboard_document_list.html.erb +6 -0
- data/app/views/collections/_document_list.html.erb +10 -0
- data/app/views/collections/_edit_actions.html.erb +5 -0
- data/app/views/collections/_edit_descriptions.html.erb +20 -0
- data/app/views/collections/_form.html.erb +24 -0
- data/app/views/collections/_form_for_select_collection.html.erb +34 -0
- data/app/views/collections/_media_display.html.erb +1 -0
- data/app/views/collections/_paginate.html.erb +6 -0
- data/app/views/collections/_search_collection_dashboard_form.html.erb +10 -0
- data/app/views/collections/_show_actions.html.erb +7 -0
- data/app/views/collections/_show_descriptions.html.erb +8 -0
- data/app/views/collections/_show_fields.html.erb +0 -0
- data/app/views/collections/_single_item_action_fields.html.erb +6 -0
- data/app/views/collections/_sort_and_per_page.html.erb +29 -0
- data/app/views/collections/_view_type_group.html.erb +13 -0
- data/app/views/collections/edit.html.erb +30 -0
- data/app/views/collections/show.html.erb +32 -0
- data/app/views/contact_form/new.html.erb +13 -13
- data/app/views/dashboard/_action_menu.html.erb +29 -0
- data/app/views/dashboard/_collection_action_menu.html.erb +15 -0
- data/app/views/dashboard/_document_list.html.erb +1 -1
- data/app/views/dashboard/_facet_limit.html.erb +2 -2
- data/app/views/dashboard/_facet_pagination.html.erb +12 -12
- data/app/views/dashboard/_facet_selected.html.erb +2 -2
- data/app/views/dashboard/_facets.html.erb +2 -0
- data/app/views/dashboard/_index_partials/_default_group.html.erb +9 -2
- data/app/views/dashboard/_index_partials/_list_collections.html.erb +45 -0
- data/app/views/dashboard/_index_partials/_list_files.html.erb +5 -25
- data/app/views/dashboard/_results_pagination.html.erb +1 -1
- data/app/views/dashboard/_search_form.html.erb +2 -2
- data/app/views/dashboard/_show_partials/_default.html.erb +3 -3
- data/app/views/dashboard/_show_partials/_default_details.html.erb +5 -5
- data/app/views/dashboard/_show_partials/_facets.html.erb +6 -6
- data/app/views/dashboard/_sort_and_per_page.html.erb +24 -8
- data/app/views/dashboard/facet.html.erb +3 -3
- data/app/views/dashboard/index.html.erb +18 -41
- data/app/views/dashboard/lists/index.html.erb +59 -0
- data/app/views/generic_files/_breadcrumbs.html.erb +4 -4
- data/app/views/generic_files/_descriptions.html.erb +4 -4
- data/app/views/generic_files/_field_form.html.erb +5 -5
- data/app/views/generic_files/_flot_stats.js.erb +120 -0
- data/app/views/generic_files/_media_display.html.erb +14 -4
- data/app/views/generic_files/_permission.html.erb +3 -3
- data/app/views/generic_files/_permission_form.html.erb +20 -21
- data/app/views/generic_files/_show_actions.html.erb +13 -10
- data/app/views/generic_files/_show_details.html.erb +16 -9
- data/app/views/generic_files/_versioning.html.erb +3 -3
- data/app/views/generic_files/edit.html.erb +7 -7
- data/app/views/generic_files/edit_fields/_default.html.erb +3 -4
- data/app/views/generic_files/edit_fields/_description.html.erb +3 -4
- data/app/views/generic_files/edit_fields/_resource_type.html.erb +1 -3
- data/app/views/generic_files/edit_fields/_rights.html.erb +3 -5
- data/app/views/generic_files/edit_fields/_suffix.html.erb +1 -1
- data/app/views/generic_files/show.html.erb +3 -3
- data/app/views/generic_files/stats.html.erb +8 -124
- data/app/views/generic_files/upload/_alerts.html.erb +2 -4
- data/app/views/generic_files/upload/_form.html.erb +1 -1
- data/app/views/generic_files/upload/_local_file_import_chooser.html.erb +1 -1
- data/app/views/generic_files/upload/_tos_checkbox.html.erb +1 -1
- data/app/views/homepage/_featured.html.erb +3 -1
- data/app/views/{catalog → homepage}/_featured_researcher.html.erb +0 -0
- data/app/views/{catalog → homepage}/_home.html.erb +1 -0
- data/app/views/{catalog → homepage}/_home_content.html.erb +4 -4
- data/app/views/homepage/_home_header.html.erb +12 -0
- data/app/views/homepage/_marketing.html.erb +4 -0
- data/app/views/{catalog → homepage}/_recent_document.html.erb +10 -5
- data/app/views/homepage/_recents.html.erb +15 -0
- data/app/views/homepage/_sortable_featured.html.erb +3 -1
- data/app/views/{catalog → homepage}/_tagcloud.html.erb +0 -0
- data/app/views/homepage/index.html.erb +1 -0
- data/app/views/kaminari/blacklight/_first_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_last_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_next_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_page.html.erb +1 -1
- data/app/views/kaminari/blacklight/_prev_page.html.erb +1 -1
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/error.html.erb +2 -2
- data/app/views/layouts/homepage.html.erb +4 -4
- data/app/views/layouts/sufia-dashboard.html.erb +7 -7
- data/app/views/layouts/sufia-one-column.html.erb +4 -4
- data/app/views/layouts/sufia-two-column.html.erb +7 -7
- data/app/views/mailbox/index.html.erb +2 -2
- data/app/views/pages/show.html.erb +1 -0
- data/app/views/records/_edit_field.html.erb +18 -0
- data/app/views/records/edit_fields/_description.html.erb +10 -0
- data/app/views/records/edit_fields/_resource_type.html.erb +7 -0
- data/app/views/records/edit_fields/_rights.html.erb +6 -0
- data/app/views/records/edit_fields/_suffix.html.erb +9 -0
- data/app/views/records/edit_fields/_type.html.erb +13 -0
- data/app/views/single_use_links/new_download.html.erb +1 -1
- data/app/views/users/_activity.html.erb +1 -1
- data/app/views/users/_contributions.html.erb +3 -1
- data/app/views/users/_left_sidebar.html.erb +1 -1
- data/app/views/users/_notify_link.html.erb +2 -2
- data/app/views/users/_profile.html.erb +2 -2
- data/app/views/users/_search_form.html.erb +3 -3
- data/app/views/users/edit.html.erb +15 -15
- data/app/views/users/index.html.erb +3 -3
- data/app/views/users/notifications_number.js.erb +1 -1
- data/config/locales/sufia.en.yml +13 -2
- data/config/routes.rb +56 -20
- data/db/seeds.rb +2 -2
- data/lib/generators/sufia/sufia_generator.rb +14 -4
- data/lib/generators/sufia/templates/catalog_controller.rb +98 -97
- data/lib/generators/sufia/templates/sufia_helper.rb +5 -0
- data/lib/sufia.rb +4 -0
- data/spec/{models/generic_file/actions_spec.rb → actors/generic_file/actor_spec.rb} +2 -2
- data/spec/controllers/authorities_controller_spec.rb +7 -7
- data/spec/controllers/batch_controller_spec.rb +22 -23
- data/spec/controllers/batch_edits_controller_spec.rb +4 -4
- data/spec/controllers/catalog_controller_spec.rb +27 -37
- data/spec/controllers/collections_controller_spec.rb +179 -0
- data/spec/controllers/dashboard/collections_controller_spec.rb +71 -0
- data/spec/controllers/dashboard/files_controller_spec.rb +71 -0
- data/spec/controllers/dashboard/highlights_controller_spec.rb +66 -0
- data/spec/controllers/dashboard/shares_controller_spec.rb +78 -0
- data/spec/controllers/dashboard_controller_spec.rb +0 -47
- data/spec/controllers/downloads_controller_spec.rb +10 -11
- data/spec/controllers/generic_files_controller_spec.rb +147 -118
- data/spec/controllers/homepage_controller_spec.rb +57 -0
- data/spec/controllers/mailbox_controller_spec.rb +3 -3
- data/spec/controllers/single_use_links_viewer_controller_spec.rb +3 -3
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +0 -1
- data/spec/features/browse_dashboard_files_spec.rb +5 -1
- data/spec/features/collection_spec.rb +232 -0
- data/spec/features/display_dashboard_spec.rb +1 -0
- data/spec/features/notifications_spec.rb +1 -1
- data/spec/features/search_spec.rb +22 -0
- data/spec/features/single_use_links_spec.rb +2 -2
- data/spec/features/users_spec.rb +1 -1
- data/spec/fixtures/charter.docx +0 -0
- data/spec/helpers/records_helper_spec.rb +61 -0
- data/spec/helpers/sufia_helper_spec.rb +40 -2
- data/spec/{models → jobs}/active_fedora_pid_based_job_spec.rb +0 -0
- data/spec/{models → jobs}/audit_job_spec.rb +0 -2
- data/spec/{models → jobs}/batch_update_job_spec.rb +2 -2
- data/spec/jobs/characterize_job_spec.rb +25 -0
- data/spec/jobs/create_derivatives_job_spec.rb +186 -0
- data/spec/{models → jobs}/event_jobs_spec.rb +0 -1
- data/spec/jobs/import_url_job_spec.rb +36 -14
- data/spec/jobs/ingest_local_file_job_spec.rb +2 -2
- data/spec/lib/sufia/analytics_spec.rb +29 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/models/batch_spec.rb +3 -9
- data/spec/models/checksum_audit_log_spec.rb +5 -6
- data/spec/models/collection_spec.rb +24 -0
- data/spec/models/download_spec.rb +21 -0
- data/spec/models/featured_work_list_spec.rb +0 -1
- data/spec/models/file_content_datastream_spec.rb +8 -14
- data/spec/models/file_usage_spec.rb +91 -0
- data/spec/models/fits_datastream_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +2 -2
- data/spec/models/generic_file_rdf_datastream_spec.rb +12 -0
- data/spec/models/generic_file_spec.rb +150 -168
- data/spec/models/local_authority_spec.rb +9 -9
- data/spec/models/{pageview.rb → pageview_spec.rb} +0 -0
- data/spec/models/single_use_link_spec.rb +32 -35
- data/spec/routing/route_spec.rb +19 -3
- data/spec/spec_helper.rb +28 -6
- data/spec/support/features/session_helpers.rb +5 -6
- data/spec/support/lib/generators/test_app_generator.rb +6 -0
- data/spec/views/generic_file/edit.html.erb_spec.rb +4 -4
- data/spec/views/generic_file/show.html.erb_spec.rb +45 -17
- data/spec/views/generic_file/stats.html.erb_spec.rb +26 -7
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +98 -0
- data/sufia-models/app/models/batch.rb +3 -3
- data/sufia-models/app/models/checksum_audit_log.rb +3 -3
- data/sufia-models/app/models/collection.rb +41 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file.rb +33 -43
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/accessible_attributes.rb +3 -3
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/audit.rb +12 -18
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/characterization.rb +1 -8
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +26 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/export.rb +13 -13
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/featured.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/metadata.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/mime_types.rb +15 -1
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/permissions.rb +5 -1
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/reload_on_save.rb +0 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/trophies.rb +0 -0
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +16 -0
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/virus_check.rb +2 -3
- data/sufia-models/{lib/sufia/models → app/models/concerns/sufia}/generic_file/web_form.rb +9 -2
- data/sufia-models/app/models/concerns/sufia/properties_datastream_behavior.rb +3 -4
- data/sufia-models/app/models/concerns/sufia/user.rb +2 -2
- data/sufia-models/app/models/datastreams/fits_datastream.rb +137 -136
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +6 -0
- data/sufia-models/app/models/datastreams/paranoid_rights_datastream.rb +3 -3
- data/sufia-models/app/models/file_usage.rb +53 -0
- data/sufia-models/app/models/follow.rb +2 -4
- data/sufia-models/app/models/geo_names_resource.rb +5 -7
- data/sufia-models/app/models/local_authority.rb +14 -14
- data/sufia-models/app/models/single_use_link.rb +1 -1
- data/sufia-models/app/models/sufia/download.rb +9 -0
- data/sufia-models/app/models/trophy.rb +1 -1
- data/sufia-models/app/services/sufia/{usage_statistics.rb → analytics.rb} +1 -24
- data/sufia-models/app/services/sufia/id_service.rb +2 -2
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +5 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +1 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +5 -3
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +6 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +2 -3
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +20 -20
- data/sufia-models/lib/sufia/ability.rb +1 -1
- data/sufia-models/lib/sufia/models/engine.rb +3 -9
- data/sufia-models/lib/sufia/models/file_content/versions.rb +3 -3
- data/sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb +6 -2
- data/sufia-models/lib/sufia/models/jobs/batch_update_job.rb +6 -10
- data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +1 -13
- data/sufia-models/lib/sufia/models/jobs/create_derivatives_job.rb +14 -0
- data/sufia-models/lib/sufia/models/jobs/import_url_job.rb +27 -23
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +1 -1
- data/sufia-models/sufia-models.gemspec +1 -1
- data/sufia.gemspec +7 -2
- data/tasks/jetty.rake +4 -4
- data/tasks/release.rake +8 -8
- data/tasks/sufia-db.rake +4 -4
- data/tasks/sufia-dev.rake +11 -5
- metadata +226 -95
- data/app/helpers/sufia_helper.rb +0 -93
- data/app/views/catalog/_bookmark_form.html.erb +0 -8
- data/app/views/catalog/_home_header.html.erb +0 -15
- data/app/views/catalog/_recents.html.erb +0 -17
- data/app/views/dashboard/_index_partials/_thumbnail_display.html.erb +0 -9
- data/app/views/layouts/_homepage_sidebar2.html.erb +0 -14
- data/lib/sufia/files_controller_behavior.rb +0 -253
- data/spec/helpers/generic_file_helper_spec.rb +0 -28
- data/spec/lib/sufia/usage_statistics_spec.rb +0 -75
- data/spec/models/characterize_job_spec.rb +0 -93
- data/spec/models/transcode_audio_job_spec.rb +0 -85
- data/spec/models/transcode_video_job_spec.rb +0 -31
- data/spec/views/dashboard/index_partials/_thumbnail_display.html.erb_spec.rb +0 -22
- data/sufia-models/lib/sufia/models/generic_file/actions.rb +0 -50
- data/sufia-models/lib/sufia/models/generic_file/derivatives.rb +0 -31
- data/sufia-models/lib/sufia/models/generic_file/thumbnail.rb +0 -37
- data/sufia-models/lib/sufia/models/generic_file/versions.rb +0 -16
- data/sufia-models/lib/sufia/models/jobs/transcode_audio_job.rb +0 -15
- data/sufia-models/lib/sufia/models/jobs/transcode_video_job.rb +0 -15
data/app/helpers/sufia_helper.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
module SufiaHelper
|
2
|
-
|
3
|
-
# link_back_to_dashboard(:label=>'Back to Search')
|
4
|
-
# Create a link back to the dashboard screen, keeping the user's facet, query and paging choices intact by using session.
|
5
|
-
def link_back_to_dashboard(opts={:label=>'Back to Search'})
|
6
|
-
query_params = session[:search] ? session[:search].dup : {}
|
7
|
-
query_params.delete :counter
|
8
|
-
query_params.delete :total
|
9
|
-
link_url = dashboard_index_path + "?" + query_params.to_query
|
10
|
-
link_to opts[:label], link_url
|
11
|
-
end
|
12
|
-
|
13
|
-
def link_to_dashboard_query(query)
|
14
|
-
p = params.dup
|
15
|
-
p.delete :page
|
16
|
-
p.delete :action
|
17
|
-
p[:q]=query
|
18
|
-
link_url = dashboard_index_path(p)
|
19
|
-
link_to(query, link_url)
|
20
|
-
end
|
21
|
-
|
22
|
-
def display_user_name(recent_document)
|
23
|
-
return "no display name" unless recent_document.depositor
|
24
|
-
return User.find_by_user_key(recent_document.depositor).name rescue recent_document.depositor
|
25
|
-
end
|
26
|
-
|
27
|
-
def number_of_deposits(user)
|
28
|
-
ActiveFedora::Base.where(Solrizer.solr_name('depositor', :stored_searchable) => user.user_key).count
|
29
|
-
end
|
30
|
-
|
31
|
-
def link_to_facet(field, field_string)
|
32
|
-
link_to(field, add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"}))
|
33
|
-
end
|
34
|
-
|
35
|
-
# @param values [Array] The values to display
|
36
|
-
# @param solr_field [String] The name of the solr field to link to without its suffix (:facetable)
|
37
|
-
# @param empty_message [String] ('No value entered') The message to display if no values are passed in.
|
38
|
-
# @param separator [String] (', ') The value to join with.
|
39
|
-
def link_to_facet_list(values, solr_field, empty_message="No value entered", separator=", ")
|
40
|
-
return empty_message if values.blank?
|
41
|
-
facet_field = Solrizer.solr_name(solr_field, :facetable)
|
42
|
-
safe_join(values.map{ |item| link_to_facet(item, facet_field) }, separator)
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def link_to_field(fieldname, fieldvalue, displayvalue = nil)
|
47
|
-
p = {:search_field=>'advanced', fieldname=>'"'+fieldvalue+'"'}
|
48
|
-
link_url = catalog_index_path(p)
|
49
|
-
display = displayvalue.blank? ? fieldvalue: displayvalue
|
50
|
-
link_to(display, link_url)
|
51
|
-
end
|
52
|
-
|
53
|
-
def iconify_auto_link(text, showLink = true)
|
54
|
-
auto_link(text) do |value|
|
55
|
-
link = "<i class='icon-external-link'></i> #{value}<br />" if showLink
|
56
|
-
link = "<i class='icon-external-link'></i> <br />" unless showLink
|
57
|
-
link
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def link_to_profile(login)
|
62
|
-
user = User.find_by_user_key(login)
|
63
|
-
return login if user.nil?
|
64
|
-
|
65
|
-
text = if user.respond_to? :name
|
66
|
-
user.name
|
67
|
-
else
|
68
|
-
login
|
69
|
-
end
|
70
|
-
|
71
|
-
link_to text, Sufia::Engine.routes.url_helpers.profile_path(user)
|
72
|
-
end
|
73
|
-
|
74
|
-
def linkify_chat_id(chat_id)
|
75
|
-
if chat_id.end_with? '@chat.psu.edu'
|
76
|
-
"<a href=\"xmpp:#{chat_id}\">#{chat_id}</a>"
|
77
|
-
else
|
78
|
-
chat_id
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
# Create a link back to the index screen, keeping the user's facet, query and paging choices intact by using session.
|
83
|
-
# We should be able to do away with this method in Blacklight 5
|
84
|
-
# @example
|
85
|
-
# link_back_to_catalog(:label=>'Back to Search')
|
86
|
-
def link_back_to_catalog(opts={:label=>nil})
|
87
|
-
scope = opts.delete(:route_set) || self
|
88
|
-
query_params = current_search_session.try(:query_params) || {}
|
89
|
-
link_url = scope.url_for(query_params)
|
90
|
-
opts[:label] ||= t('blacklight.back_to_search')
|
91
|
-
link_to opts[:label], link_url
|
92
|
-
end
|
93
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
<%= form_tag '/bookmarks', :name => "bookmarks" do %>
|
2
|
-
<% documents.each_with_index do |document, index| %>
|
3
|
-
<%= hidden_field_tag "bookmarks[#{index}][document_id]", document.get(:id)%>
|
4
|
-
<%= hidden_field_tag "bookmarks[#{index}][title]", h(document[document_show_link_field])%>
|
5
|
-
<% end %>
|
6
|
-
<%= link_to_function "Add to Bookmarks", "document.bookmarks.submit()" %>
|
7
|
-
<%= submit_tag 'Add to Bookmarks', :class => 'hide' %>
|
8
|
-
<% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
<div class="home_call_action col-xs-12 col-sm-4 pull-right">
|
2
|
-
<div class="home_share_work">
|
3
|
-
<%= link_to "<i class=\"icon-file\"></i> #{t('sufia.share_button')}".html_safe, sufia.new_generic_file_path, :class => "btn btn-primary btn-lg btn-block", :id => "contribute_link" %>
|
4
|
-
<p class="text-center"><a href="/terms/">Terms of Use</a></p>
|
5
|
-
</div><!-- /.home_share_work -->
|
6
|
-
</div><!-- /.col-xs-3 -->
|
7
|
-
<div class="col-xs-12 col-sm-8">
|
8
|
-
<div class="col-sm-offset-2 col-sm-9 col-md-offset-1 home_marketing_text">
|
9
|
-
<h2>Share. Manage. Preserve.</h2>
|
10
|
-
<p>Raise the profile of your research and boost its impact with Sufia!</p>
|
11
|
-
</div>
|
12
|
-
</div>
|
13
|
-
|
14
|
-
|
15
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<% msg = 'Login to see your recently added documents' if msg.blank? and current_user.blank? %>
|
2
|
-
<% msg = 'You have no documents to display. Contribute some of your documents!' if msg.blank? %>
|
3
|
-
<div>
|
4
|
-
<% if recent_documents.blank? %>
|
5
|
-
<% msg = 'Login to see your recently added documents' if msg.blank? and current_user.blank? %>
|
6
|
-
<% msg = 'You have no documents to display. Contribute some of your documents!' if msg.blank? %>
|
7
|
-
<h3><%= msg %></h3>
|
8
|
-
<% else %>
|
9
|
-
|
10
|
-
<div id="recent_docs">
|
11
|
-
<table class="table table-bordered table-striped">
|
12
|
-
<%= render :partial => "recent_document", :collection => recent_documents, :locals=>{:display_thumbs=> display_thumbs, :display_access=> display_access} %>
|
13
|
-
</table>
|
14
|
-
</div>
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
</div>
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<% width = 36 if width.blank? %>
|
2
|
-
<% if document.image? || document.pdf? || document.video? %>
|
3
|
-
<% path = sufia.download_path(document.noid, {datastream_id: 'thumbnail'}) %>
|
4
|
-
<% elsif document.audio? %>
|
5
|
-
<% path = "audio.png" %>
|
6
|
-
<% else %>
|
7
|
-
<% path = "default.png" %>
|
8
|
-
<% end %>
|
9
|
-
<%= link_to image_tag(path, {width: width}), sufia.generic_file_path(document) %>
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<h2 class="heading1">Contribute</h2>
|
2
|
-
<%= link_to "<i class=\"icon-file\"></i> #{t('sufia.share_button')}".html_safe, sufia.new_generic_file_path, :class => "btn btn-primary btn-large", :id => "contribute_link" %>
|
3
|
-
<div class="row center"> <a href="/terms/">Terms of Use</a></div><br />
|
4
|
-
<%- if blacklight_config.respond_to?(:tag_cloud_field_name) && blacklight_config.tag_cloud_field_name %>
|
5
|
-
<div class="row">
|
6
|
-
<h2 class="heading1 pull-left">Explore</h2>
|
7
|
-
<%= render partial:'catalog/tagcloud', locals:{tag_cloud_field_name:blacklight_config.tag_cloud_field_name}%>
|
8
|
-
</div>
|
9
|
-
<%- end %>
|
10
|
-
<div class="row"> </div>
|
11
|
-
<div class="row">
|
12
|
-
<h2 class="heading1">My Latest</h2>
|
13
|
-
<%= render :partial=>'/catalog/recents', :locals => {:recent_documents=>@recent_user_documents, :display_thumbs=>false, :display_access=>true} %>
|
14
|
-
</row>
|
@@ -1,253 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
module FilesController
|
3
|
-
autoload :LocalIngestBehavior, 'sufia/files_controller/local_ingest_behavior'
|
4
|
-
autoload :UploadCompleteBehavior, 'sufia/files_controller/upload_complete_behavior'
|
5
|
-
end
|
6
|
-
module FilesControllerBehavior
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
extend Sufia::FilesController::UploadCompleteBehavior
|
9
|
-
|
10
|
-
included do
|
11
|
-
include Hydra::Controller::ControllerBehavior
|
12
|
-
include Blacklight::Configurable
|
13
|
-
include Sufia::Noid # for normalize_identifier method
|
14
|
-
include Sufia::FilesController::LocalIngestBehavior
|
15
|
-
extend Sufia::FilesController::UploadCompleteBehavior
|
16
|
-
|
17
|
-
layout "sufia-one-column"
|
18
|
-
|
19
|
-
self.copy_blacklight_config_from(CatalogController)
|
20
|
-
|
21
|
-
# Catch permission errors
|
22
|
-
rescue_from Hydra::AccessDenied, CanCan::AccessDenied do |exception|
|
23
|
-
if exception.action == :edit
|
24
|
-
redirect_to(sufia.url_for({:action=>'show'}), :alert => "You do not have sufficient privileges to edit this document")
|
25
|
-
elsif current_user and current_user.persisted?
|
26
|
-
redirect_to root_url, :alert => exception.message
|
27
|
-
else
|
28
|
-
session["user_return_to"] = request.url
|
29
|
-
redirect_to new_user_session_url, :alert => exception.message
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# actions: audit, index, create, new, edit, show, update,
|
34
|
-
# destroy, permissions, citation, stats
|
35
|
-
before_filter :authenticate_user!, :except => [:show, :citation]
|
36
|
-
before_filter :has_access?, :except => [:show]
|
37
|
-
prepend_before_filter :normalize_identifier, :except => [:index, :create, :new]
|
38
|
-
load_resource :only=>[:audit]
|
39
|
-
load_and_authorize_resource :except=>[:index, :audit]
|
40
|
-
end
|
41
|
-
|
42
|
-
# routed to /files/new
|
43
|
-
def new
|
44
|
-
@generic_file = ::GenericFile.new
|
45
|
-
@batch_noid = Sufia::Noid.noidify(Sufia::IdService.mint)
|
46
|
-
end
|
47
|
-
|
48
|
-
# routed to /files/:id/edit
|
49
|
-
def edit
|
50
|
-
@generic_file.initialize_fields
|
51
|
-
@groups = current_user.groups
|
52
|
-
end
|
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
|
-
|
67
|
-
# routed to /files/:id (DELETE)
|
68
|
-
def destroy
|
69
|
-
pid = @generic_file.noid
|
70
|
-
@generic_file.destroy
|
71
|
-
Sufia.queue.push(ContentDeleteEventJob.new(pid, current_user.user_key))
|
72
|
-
redirect_to self.class.destroy_complete_path(params), :notice => render_to_string(:partial=>'generic_files/asset_deleted_flash', :locals => { :generic_file => @generic_file })
|
73
|
-
end
|
74
|
-
|
75
|
-
# routed to /files (POST)
|
76
|
-
def create
|
77
|
-
if params[:local_file].present?
|
78
|
-
perform_local_ingest
|
79
|
-
elsif params[:selected_files].present?
|
80
|
-
create_from_browse_everything(params)
|
81
|
-
else
|
82
|
-
create_from_upload(params)
|
83
|
-
end
|
84
|
-
end
|
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"])
|
90
|
-
end
|
91
|
-
redirect_to self.class.upload_complete_path( params[:batch_id])
|
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
|
104
|
-
|
105
|
-
def create_from_upload(params)
|
106
|
-
# check error condition No files
|
107
|
-
return json_error("Error! No file to save") if !params.has_key?(:files)
|
108
|
-
|
109
|
-
file = params[:files].detect {|f| f.respond_to?(:original_filename) }
|
110
|
-
if !file
|
111
|
-
json_error "Error! No file for upload", 'unknown file', :status => :unprocessable_entity
|
112
|
-
elsif (empty_file?(file))
|
113
|
-
json_error "Error! Zero Length File!", file.original_filename
|
114
|
-
elsif (!terms_accepted?)
|
115
|
-
json_error "You must accept the terms of service!", file.original_filename
|
116
|
-
else
|
117
|
-
process_file(file)
|
118
|
-
end
|
119
|
-
rescue => error
|
120
|
-
logger.error "GenericFilesController::create rescued #{error.class}\n\t#{error.to_s}\n #{error.backtrace.join("\n")}\n\n"
|
121
|
-
json_error "Error occurred while creating generic file."
|
122
|
-
ensure
|
123
|
-
# remove the tempfile (only if it is a temp file)
|
124
|
-
file.tempfile.delete if file.respond_to?(:tempfile)
|
125
|
-
end
|
126
|
-
|
127
|
-
# routed to /files/:id/citation
|
128
|
-
def citation
|
129
|
-
end
|
130
|
-
|
131
|
-
# routed to /files/:id
|
132
|
-
def show
|
133
|
-
respond_to do |format|
|
134
|
-
format.html {
|
135
|
-
@events = @generic_file.events(100)
|
136
|
-
}
|
137
|
-
format.endnote { render :text => @generic_file.export_as_endnote }
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
# routed to /files/:id/audit (POST)
|
142
|
-
def audit
|
143
|
-
render :json=>@generic_file.audit
|
144
|
-
end
|
145
|
-
|
146
|
-
# routed to /files/:id (PUT)
|
147
|
-
def update
|
148
|
-
version_event = false
|
149
|
-
|
150
|
-
if params.has_key?(:revision) and params[:revision] != @generic_file.content.latest_version.versionID
|
151
|
-
revision = @generic_file.content.get_version(params[:revision])
|
152
|
-
@generic_file.add_file(revision.content, datastream_id, revision.label)
|
153
|
-
version_event = true
|
154
|
-
Sufia.queue.push(ContentRestoredVersionEventJob.new(@generic_file.pid, current_user.user_key, params[:revision]))
|
155
|
-
end
|
156
|
-
|
157
|
-
if params.has_key?(:filedata)
|
158
|
-
file = params[:filedata]
|
159
|
-
@generic_file.add_file(file, datastream_id, file.original_filename)
|
160
|
-
version_event = true
|
161
|
-
end
|
162
|
-
|
163
|
-
# only update metadata if there is a generic_file object which is not the case for version updates
|
164
|
-
update_metadata if params[:generic_file]
|
165
|
-
|
166
|
-
#always save the file so the new version or metadata gets recorded
|
167
|
-
if @generic_file.save
|
168
|
-
# do not trigger an update event if a version event has already been triggered
|
169
|
-
if version_event
|
170
|
-
Sufia.queue.push(ContentNewVersionEventJob.new(@generic_file.pid, current_user.user_key)) if params.has_key?(:filedata)
|
171
|
-
else
|
172
|
-
Sufia.queue.push(ContentUpdateEventJob.new(@generic_file.pid, current_user.user_key))
|
173
|
-
end
|
174
|
-
@generic_file.record_version_committer(current_user)
|
175
|
-
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 })
|
176
|
-
else
|
177
|
-
render action: 'edit'
|
178
|
-
end
|
179
|
-
rescue => error
|
180
|
-
flash[:error] = error.message
|
181
|
-
logger.error "GenericFilesController::update rescued #{error.class}\n\t#{error.message}\n #{error.backtrace.join("\n")}\n\n"
|
182
|
-
render action: 'edit'
|
183
|
-
end
|
184
|
-
|
185
|
-
protected
|
186
|
-
|
187
|
-
def json_error(error, name=nil, additional_arguments={})
|
188
|
-
args = {:error => error}
|
189
|
-
args[:name] = name if name
|
190
|
-
render additional_arguments.merge({:json => [args]})
|
191
|
-
end
|
192
|
-
|
193
|
-
def empty_file?(file)
|
194
|
-
(file.respond_to?(:tempfile) && file.tempfile.size == 0) || (file.respond_to?(:size) && file.size == 0)
|
195
|
-
end
|
196
|
-
|
197
|
-
def process_file(file)
|
198
|
-
@generic_file = ::GenericFile.new
|
199
|
-
update_metadata_from_upload_screen
|
200
|
-
create_metadata(@generic_file)
|
201
|
-
Sufia::GenericFile::Actions.create_content(@generic_file, file, file.original_filename, datastream_id, current_user)
|
202
|
-
respond_to do |format|
|
203
|
-
format.html {
|
204
|
-
render :json => [@generic_file.to_jq_upload],
|
205
|
-
:content_type => 'text/html',
|
206
|
-
:layout => false
|
207
|
-
}
|
208
|
-
format.json {
|
209
|
-
render :json => [@generic_file.to_jq_upload]
|
210
|
-
}
|
211
|
-
end
|
212
|
-
rescue ActiveFedora::RecordInvalid => af
|
213
|
-
flash[:error] = af.message
|
214
|
-
json_error "Error creating generic file: #{af.message}"
|
215
|
-
end
|
216
|
-
|
217
|
-
# override this method if you want to change how the terms are accepted on upload.
|
218
|
-
def terms_accepted?
|
219
|
-
params[:terms_of_service] == '1'
|
220
|
-
end
|
221
|
-
|
222
|
-
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
223
|
-
# @deprecated use @generic_file.initialize_fields instead
|
224
|
-
def initialize_fields(file)
|
225
|
-
file.initialize_fields
|
226
|
-
end
|
227
|
-
|
228
|
-
ActiveSupport::Deprecation.deprecate_methods(FilesControllerBehavior, :initialize_fields)
|
229
|
-
|
230
|
-
# The name of the datastream where we store the file data
|
231
|
-
def datastream_id
|
232
|
-
'content'
|
233
|
-
end
|
234
|
-
|
235
|
-
# this is provided so that implementing application can override this behavior and map params to different attributes
|
236
|
-
def update_metadata_from_upload_screen
|
237
|
-
# Relative path is set by the jquery uploader when uploading a directory
|
238
|
-
@generic_file.relative_path = params[:relative_path] if params[:relative_path]
|
239
|
-
end
|
240
|
-
|
241
|
-
# this is provided so that implementing application can override this behavior and map params to different attributes
|
242
|
-
def update_metadata
|
243
|
-
@generic_file.attributes = @generic_file.sanitize_attributes(params[:generic_file])
|
244
|
-
@generic_file.visibility = params[:visibility]
|
245
|
-
@generic_file.date_modified = DateTime.now
|
246
|
-
end
|
247
|
-
|
248
|
-
def create_metadata(file)
|
249
|
-
Sufia::GenericFile::Actions.create_metadata(file, current_user, params[:batch_id])
|
250
|
-
end
|
251
|
-
|
252
|
-
end
|
253
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe GenericFileHelper do
|
4
|
-
it "draws add button" do
|
5
|
-
helper.add_field(:test).should ==
|
6
|
-
"<button class=\"adder btn\" id=\"additional_test_submit\" name=\"additional_test\">+<span class=\"sr-only\">add another test</span></button>"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "draws subtract button" do
|
10
|
-
helper.subtract_field(:test).should ==
|
11
|
-
"<button class=\"remover btn\" id=\"additional_test_submit\" name=\"additional_test\">-<span class=\"sr-only\">add another test</span></button>"
|
12
|
-
end
|
13
|
-
|
14
|
-
it "draws help_icon" do
|
15
|
-
str = String.new(helper.help_icon(:tag))
|
16
|
-
doc = Nokogiri::HTML(str)
|
17
|
-
a = doc.xpath('//a').first
|
18
|
-
|
19
|
-
a.attr('data-content').should == "Words or phrases you select to describe what the file is about. These are used to search for content. <em>This is a required field</em>."
|
20
|
-
a.attr('data-original-title').should == "Keyword"
|
21
|
-
a.attr('id').should == "generic_file_tag_help"
|
22
|
-
i = a.children.first
|
23
|
-
i.attr('class').should == 'glyphicon glyphicon-question-sign icon-large'
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Sufia::UsageStatistics do
|
4
|
-
before do
|
5
|
-
token = OAuth2::AccessToken.new(nil, nil)
|
6
|
-
allow(subject).to receive(:token).and_return(token)
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'responds to :config' do
|
10
|
-
expect(subject).to respond_to(:config)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'reads its config from a yaml file' do
|
14
|
-
expect(subject.config.keys.sort).to eql ['app_name', 'app_version', 'client_email', 'privkey_path', 'privkey_secret']
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'responds to :user' do
|
18
|
-
expect(subject).to respond_to(:user)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'instantiates a user' do
|
22
|
-
expect(subject.user).to be_a(Legato::User)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'responds to :profile' do
|
26
|
-
expect(subject).to respond_to(:profile)
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'querying' do
|
30
|
-
before do
|
31
|
-
profile = Legato::Management::Profile.new({"id" => 12345, "name" => "Profile 1", "accountId" => "12345", "webPropertyId" => "UA-12345-2", "timezone" => "America/Chicago"}, subject.user)
|
32
|
-
allow(subject).to receive(:profile).and_return(profile)
|
33
|
-
end
|
34
|
-
|
35
|
-
let(:query) { Sufia::UsageStatistics.profile.pageview }
|
36
|
-
|
37
|
-
it 'returns a query object' do
|
38
|
-
expect(query).to be_a(Legato::Query)
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'results' do
|
42
|
-
before(:all) do
|
43
|
-
@system_timezone = ENV['TZ']
|
44
|
-
ENV['TZ'] = 'UTC'
|
45
|
-
end
|
46
|
-
|
47
|
-
after(:all) do
|
48
|
-
ENV['TZ'] = @system_timezone
|
49
|
-
end
|
50
|
-
|
51
|
-
# Mock and stub Google Analytics results
|
52
|
-
before do
|
53
|
-
@mock_query = double('query')
|
54
|
-
allow(@mock_query).to receive(:collection).and_return([
|
55
|
-
OpenStruct.new(date: '2014-01-01', pageviews: 4),
|
56
|
-
OpenStruct.new(date: '2014-01-02', pageviews: 8),
|
57
|
-
OpenStruct.new(date: '2014-01-03', pageviews: 6),
|
58
|
-
OpenStruct.new(date: '2014-01-04', pageviews: 10),
|
59
|
-
OpenStruct.new(date: '2014-01-05', pageviews: 2)])
|
60
|
-
allow(@mock_query).to receive(:map).and_return(@mock_query.collection.map(&:marshal_dump))
|
61
|
-
allow(Sufia::UsageStatistics.profile).to receive(:pageview).and_return(@mock_query)
|
62
|
-
end
|
63
|
-
|
64
|
-
let(:results) { @mock_query }
|
65
|
-
|
66
|
-
it 'converts results to json' do
|
67
|
-
expect(subject.as_flot_json(results)).to eql('[[1388534400000,4],[1388620800000,8],[1388707200000,6],[1388793600000,10],[1388880000000,2]]')
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'calculates total page views' do
|
71
|
-
expect(subject.total_pageviews(results)).to eql(30)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|