-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial skeleton for ServicesController * initial version of Zotero bibliography service * Add the ServicesController for the BibliographyService. * Add the BibliographyService model to persist exhibit specific service configurations. * Inject a concern to Spotlight::Exhibit to add the has_one :bibliography_service relationship * Add the Bibliography service edit form. * Override Spotlight's configuration_sidebar partial to add our Services link. * Regen .rubocop_todo.yml * Add breadcrumbs to the Service configuration page. * Rename BibliographyService service to SyncBibliographyService. * update spotlight dependency to master to use 6d04466c4521e44a41307e5fb04f87ec51595455 * Add service to hookup Zotero API and API Configuration classes for sync (#454) * move modules included into SyncBibliographyService into namespaced classes * refactor of ZoteroApi::Client to simplify for accessing bibs by druid * provide for a sorted bibliography to be returned for each druid * Remove errant view copied into the spec directory. * Add logic to the SyncBibliographyService class. * Add a comment to the ZoteroApi::Client class. * Add a job to invoke the bibliography service sync and hook it into the create action. * Sync the bibliography service when the configuration has been updated. * Autogen rubocop_todo. * adds display of bibliography information on show page * view bib as ul/li * setup sync button to work * use form-control-static for styling instead of our own * use f.primary instead of explicitly specifying btn classes * move bibliography_service assignment logic from controller to model * nix custom find method on Bibliography * make druid regex configurable * Push update + bibliography sync to the BibliographyService class. * handle cases where an author is not present, or partial author * exclude fixtures from rubocop * add migration to change sidecar data to MEDIUMTEXT * set the production log level for sidekiq to WARN * add *_tsi field and use that for bibliography
- Loading branch information
1 parent
8bb2055
commit ef17505
Showing
47 changed files
with
1,323 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ AllCops: | |
- 'db/**/*' | ||
- 'config/**/*' | ||
- 'vendor/**/*' | ||
- 'spec/fixtures/**/*' | ||
|
||
Rails: | ||
Enabled: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,74 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2017-01-23 13:59:29 -0800 using RuboCop version 0.47.1. | ||
# on 2017-03-19 00:57:52 -0700 using RuboCop version 0.47.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 1 | ||
# Offense count: 4 | ||
Metrics/AbcSize: | ||
Max: 19 | ||
|
||
# Offense count: 30 | ||
# Offense count: 41 | ||
# Configuration parameters: CountComments, ExcludedMethods. | ||
Metrics/BlockLength: | ||
Exclude: | ||
- 'Rakefile' | ||
- '**/*.rake' | ||
- 'spec/**/*.rb' | ||
- 'app/controllers/catalog_controller.rb' | ||
- 'app/models/spotlight/dor/indexer.rb' | ||
Max: 639 | ||
|
||
# Offense count: 1 | ||
# Offense count: 4 | ||
# Configuration parameters: CountComments. | ||
Metrics/MethodLength: | ||
Max: 11 | ||
Max: 87 | ||
|
||
# Offense count: 2 | ||
RSpec/AnyInstance: | ||
Exclude: | ||
- 'spec/features/exhibit_spec.rb' | ||
- 'spec/models/dor_harvester_spec.rb' | ||
- 'spec/services/sync_bibliography_service_spec.rb' | ||
|
||
# Offense count: 2 | ||
# Offense count: 4 | ||
# Configuration parameters: Max. | ||
RSpec/ExampleLength: | ||
Exclude: | ||
- 'spec/features/bibliography_service_feature_spec.rb' | ||
- 'spec/models/spotlight/dor/indexer_spec.rb' | ||
|
||
# Offense count: 23 | ||
# Offense count: 2 | ||
# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
# SupportedStyles: have_received, receive | ||
RSpec/MessageSpies: | ||
Exclude: | ||
- 'spec/models/zotero_api/client_spec.rb' | ||
|
||
# Offense count: 37 | ||
RSpec/MultipleExpectations: | ||
Max: 5 | ||
Max: 7 | ||
|
||
# Offense count: 21 | ||
# Offense count: 28 | ||
# Configuration parameters: Max. | ||
RSpec/NestedGroups: | ||
Exclude: | ||
- 'spec/models/spotlight/dor/indexer_spec.rb' | ||
- 'spec/models/zotero_api/client_spec.rb' | ||
- 'spec/requests/bibliography_service_spec.rb' | ||
- 'spec/services/dor_solr_document_builder_spec.rb' | ||
|
||
# Offense count: 4 | ||
# Offense count: 8 | ||
RSpec/SubjectStub: | ||
Exclude: | ||
- 'spec/models/dor_harvester_spec.rb' | ||
- 'spec/models/spotlight/dor/indexer_spec.rb' | ||
- 'spec/models/zotero_api/client_spec.rb' | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: EnforcedStyle, SupportedStyles. | ||
# SupportedStyles: nested, compact | ||
Style/ClassAndModuleChildren: | ||
Exclude: | ||
- 'app/models/spotlight/dor/indexer.rb' | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: MinBodyLength. | ||
Style/GuardClause: | ||
Exclude: | ||
- 'app/services/sync_bibliography_service.rb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.show-document { | ||
h3 { | ||
color: $brand-primary; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
### | ||
# A controller to handle any external services that need to be configured by an admin | ||
class ServicesController < Spotlight::ApplicationController | ||
before_action :authenticate_user! | ||
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit | ||
before_action :build_resource | ||
load_and_authorize_resource :bibliography_service, through: :exhibit, singleton: true | ||
|
||
def edit | ||
add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), [spotlight, @exhibit] | ||
add_breadcrumb t(:'spotlight.configuration.sidebar.header'), spotlight.exhibit_dashboard_path(@exhibit) | ||
add_breadcrumb t(:'services.menu_link'), edit_exhibit_services_path(@exhibit) | ||
end | ||
|
||
def update | ||
if @bibliography_service.update_and_sync_bibliography(update_params) | ||
redirect_to edit_exhibit_services_path(@exhibit), notice: I18n.t('services.update.notice') | ||
else | ||
redirect_to edit_exhibit_services_path(@exhibit), alert: I18n.t('services.update.error') | ||
end | ||
end | ||
|
||
def create | ||
if @bibliography_service.update_and_sync_bibliography(update_params) | ||
redirect_to edit_exhibit_services_path(@exhibit), notice: I18n.t('services.create.notice') | ||
else | ||
redirect_to edit_exhibit_services_path(@exhibit), alert: I18n.t('services.create.error') | ||
end | ||
end | ||
|
||
def sync | ||
@exhibit.sync_bibliography | ||
redirect_to edit_exhibit_services_path(@exhibit), notice: I18n.t('services.sync.started') | ||
end | ||
|
||
private | ||
|
||
def build_resource | ||
@bibliography_service = @exhibit.bibliography_service || @exhibit.build_bibliography_service | ||
end | ||
|
||
def update_params | ||
params.require(:bibliography_service).permit(:header, :api_id, :api_type) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## | ||
# Background job to sync bibliography service | ||
class SyncBibliographyServiceJob < ActiveJob::Base | ||
def perform(exhibit) | ||
SyncBibliographyService.new(exhibit).sync | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# The bibliography service configurations for an exhibit | ||
class BibliographyService < ActiveRecord::Base | ||
belongs_to :exhibit, class_name: Spotlight::Exhibit | ||
delegate :sync_bibliography, to: :exhibit | ||
|
||
def header | ||
super || I18n.t('services.bibliography_service.default_header') | ||
end | ||
|
||
def initial_sync_complete? | ||
sync_completed_at.present? | ||
end | ||
|
||
def api_settings_changed? | ||
api_id_previously_changed? || api_type_previously_changed? | ||
end | ||
|
||
def mark_as_updated! | ||
update(sync_completed_at: DateTime.current) | ||
end | ||
|
||
def update_and_sync_bibliography(update_params) | ||
updated = update(update_params) | ||
return unless updated | ||
sync_bibliography if api_settings_changed? | ||
updated | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## | ||
# A concern to be mixed into SolrDocument for accessing a document's | ||
# bibliography | ||
module BibliographyConcern | ||
def bibliography | ||
fetch(Settings.zotero_api.solr_document_field, nil) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## | ||
# A concern to be mixed into the Spotlight::Exhibit | ||
# class in order to add ActiveRecord relationship(s) | ||
module ExhibitExtension | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
has_one :bibliography_service | ||
end | ||
|
||
def sync_bibliography | ||
SyncBibliographyServiceJob.perform_later(self) | ||
end | ||
end |
Oops, something went wrong.