https://github.com/curationexperts/ldc-qa-demo
A Hydra (Hyrax) application demonstrating a linked data cache for controlled vocabularies.
https://github.com/curationexperts/ldc-qa-demo
Last synced: about 1 month ago
JSON representation
A Hydra (Hyrax) application demonstrating a linked data cache for controlled vocabularies.
- Host: GitHub
- URL: https://github.com/curationexperts/ldc-qa-demo
- Owner: curationexperts
- Created: 2017-01-15T02:57:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T20:28:41.000Z (about 8 years ago)
- Last Synced: 2024-11-04T08:37:37.436Z (6 months ago)
- Language: Ruby
- Size: 158 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-starred - curationexperts/ldc-qa-demo - A Hydra (Hyrax) application demonstrating a linked data cache for controlled vocabularies. (others)
README
# Controlled Vocabulary Demo
This is a demonstration of linked controlled vocabularies in Hyrax. This
application uses a
[Linked Data Fragments](https://github.com/ActiveTriples/linked-data-fragments)
based caching approach to support query of both web-based and local controlled
vocabularies.# Adding Controlled Vocabulary Dropdown Options
To create your own dropdown with authorities you extend the `QASelectService` class. In this project it's done at: `/chf/app/services/hyrax/name_authorities.rb`
```ruby
module Hyrax
# Provide select options for the copyright status (edm:rights) field
class NameAuthorities < QaSelectService
def initialize
super('names')
end
end
end
```You initialize the service with the name of a YAML file `names.yml` that contains a list of authorities:
```yaml
terms:
- id: /authorities/search/loc/names
term: LOC Names
active: true
- id: /authorities/search/assign_fast/all
term: FAST
active: true
```Then in the partials for the input field at `/app/views/records/edit_fields/_creator.html.erb`:
```erb
<% name_authorities = Hyrax::NameAuthorities.new %><%=
f.input key,
as: :multi_value,
input_html: {
class: 'form-control',
data: { 'autocomplete-url' => "/authorities/search/loc/names",
'autocomplete' => key }
} ,
required: f.object.required?(key) %><%= f.input key, collection: name_authorities.select_active_options, label: false %>
```