-
Notifications
You must be signed in to change notification settings - Fork 8
Discogs Feature
Item view pages may display supplemental data and image sourced from Discogs.
Examples:
The code that implements this linked data display was adapted from work produced by the Linked Data for Production (LD4P) project. Original LD4P3 documentation can be found for this feature on the LD4P3 Confluence: Production: Discogs.
When the user clicks on a work to display the item view page, the CornellCatalog library class checks whether the work is a musical recording. If it is, it calls the "process_discogs" method in the Discogs library class, passing the solr document as an argument. The Discogs library calls the Discogs API to do a search. If a match is found, the url for the Discogs image and the Discogs ID for the work are both saved as global variables. The ID is placed in a javascript tag in the show.html.erb template, while the image url is used with an "img" tag in the _show_metadata.html.erb template and sources in the image. The javascript in the discogs.js file uses the Discogs ID to kick off an Ajax call, which goes through the get_discogs method in the Discogs library class. This time the Discogs API returns the metadata it has for the recording and this information is stored as global variables. These variables are rendered using the get_discogs.js.erb template.
Also worth noting: the "Highlight the Discogs data" link uses the same discogs.js file, as does the "more/less" feature that appears for Discogs metadata that is particularly long. This recording, Paramont: the Rise and Fall, contains two examples of the "more/less" feature.
The Discogs API requires a key/secret combination. These are defined in the .env file:
# Discogs integration
DISCOGS_KEY=EXAMPLE_KEY
DISCOGS_SECRET=EXAMPLE_SECRET
The bulk of this code is found:
- app/assets/javascripts/linked_data/discogs.js
- app/views/catalog/get_discogs.js.erb
- lib/blacklight_cornell/discogs.rb
- lib/blacklight_cornell/cornell_catalog.rb - CornellCatalog#show
- app/helpers/cornell_catalog_helper.rb - CornellCatalogHelper#format_discogs_image
- app/views/catalog/_show_default.html.erb
- app/views/catalog/_show_metadata.html.erb
- app/views/catalog/show.html.erb