qa-ldf 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a041941c4cc97c0e5ae28e4b5e903efda839d4a6
4
- data.tar.gz: 334742157564ae3694f9dba28268c4671c49316b
3
+ metadata.gz: '047933471f76112e031df405332e2a5f04fa1c7d'
4
+ data.tar.gz: a1833f2d2b71add456f05851d942eed20c5aaadc
5
5
  SHA512:
6
- metadata.gz: 150ef0cca7b17dc7917721228a44d90bebc82504394b1fc1d557bc214f4e874ea18fd348a48ad08be8a6328b2e805a6dd67170fdd4703a5a659af1db56bbf00b
7
- data.tar.gz: 51b2d4aff7d73cc6c5921b6f0f4beb57dadc2b8d06df6a82f6c8d1e8e2bcd4a44face76d2c34ffc971333d23a6d340ba49a70c7be122a8f1106bc86187173906
6
+ metadata.gz: e08391060280e3d0b76e71c4317d48bdc83ffaafd6b596b72edf88d7c0ee5d7964cc6bf65e9b8ce94fd3d12499cbdb8bd0c26cbbb180470010f8d2de2ab2c682
7
+ data.tar.gz: 88cb5f80635c7175576c90c56d618731cc591aa4ad701bc205da2b04b0bc498b0b54972f608b63f4fdbb0777bf74ec326ce11dd287e842ad88116469af11cd06
data/README.md CHANGED
@@ -86,6 +86,10 @@ In a Hydra app, the best place to put this is in an initializer, e.g. `config/in
86
86
 
87
87
  The cache server uses [RDF Datasets](http://www.hydra-cg.com/spec/latest/linked-data-fragments/#datasets) to manage sperate cache spaces. The root dataset is at the server root (`http://example.com/ldcache`, above), and additional datasets are available at any `dataset/*` path following from the root. The `Qa::LDF` authorities are configured to use independent datasets, so each authority corresponds to a cache space of its own. Each dataset provides its own description at its base path, and is queryable with `?subject=` queries as demonstrated above.
88
88
 
89
+ #### Selecting a Triplestore Backend
90
+
91
+ The caching server provides several backends for persistent storage, we recommend using the Marmotta backend, but a Blazegraph backend (untested with this gem) is also provided. Read the [ActiveTriples::LinkedDataFragments documentation on backend configuration](https://github.com/ActiveTriples/linked-data-fragments#configuration) for more.
92
+
89
93
  #### LDF caching as an external service.
90
94
 
91
95
  The LDF caching server can run independently from your Hydra application as a lightweight, generic [Rack](http://www.rubydoc.info/github/rack/rack/file/SPEC) application, or as a standalone Rails app. You may want to deploy the server in this way so it can run on separate hardware, or to segregate Linked Data "follow your nose" network traffic.
@@ -117,13 +121,59 @@ Faceted Application of Subject Terminology
117
121
  Configuring authorities
118
122
  -----------------------
119
123
 
120
-
121
124
  ### [TK] Models.
122
125
 
123
126
  ### Forms
124
127
 
125
128
  Autocomplete handling for Questioning Authority is provided by Sufia/Hyrax. To this handling, we add a custom dropdown for selecting from multiple authorities in a field.
126
129
 
130
+ # Hyrax Autocomplete
131
+
132
+ You've got a `Work` in Hyrax and it has a `Creator` field. Wouldn't it be nice to have autocomplete on that form with a controlled vocabulary? Hyrax has this functionality, but you need to set some things up first.
133
+
134
+ The most basic way a field is associated with a particular autocomplete data source is with a data attribute on the element. The `data-autocomplete-url` attribute stores a path to the data source. To add one to an existing field create a partial for the field in `app/views/records/edit_fields/`.
135
+
136
+ In the partial, specify the data source:
137
+
138
+ ```erb
139
+ <%=
140
+ f.input key,
141
+ as: :multi_value,
142
+ input_html: {
143
+ class: 'form-control',
144
+ data: { 'autocomplete-url' => "/authorities/search/loc/names",
145
+ 'autocomplete' => key }
146
+ } ,
147
+ required: f.object.required?(key) %>
148
+ ```
149
+
150
+ Hyrax comes with [Questioning Authority](https://github.com/projecthydra-labs/questioning_authority) which provides some RESTful endpoints that you can use as autocomplete sources. Checkout the QA README for a list of the authorities that it comes with (you can even make your own).
151
+
152
+ When the Hyrax form for your `Work` loads the autocomplete JavaScript is initialized for certain fields. For the `Creator` field that we created a partial for, all we needed to was add the data attribute and the autocomplete is activated.
153
+
154
+ If the field is not one of the default fields, you'll need to run this to activate autocomplete on the field:
155
+
156
+ ```js
157
+ var Autocomplete = require('hyrax/autocomplete');
158
+ var autocomplete = new Autocomplete({
159
+ "autocompleteFields":
160
+ ["subject","language","creator","based_near","work"]
161
+ });
162
+ $('.multi_value.form-group').manage_fields({
163
+ add: function(e, element) {
164
+ autocomplete.fieldAdded(element)
165
+ }
166
+ });
167
+ autocomplete.setup();
168
+ ```
169
+
170
+ You just need to pass the fields when creating an Autocomplete instance.
171
+
172
+ Autocomplete in Hyrax currently uses jQuery UI Autocomplete. Hyrax stores the [jQuery UI Autocomplete options and source](http://jqueryui.com/autocomplete/#remote-jsonp) in ES6 classes. Unless you need to make specific query that requires you to change the options and source, the JS will use a default query from [default.es6](https://github.com/projecthydra-labs/hyrax/blob/master/app/assets/javascripts/hyrax/autocomplete/default.es6). This should just work with the QA vocabs.
173
+
174
+ The autocomplete for the `Work` field requires different a different source and options so it has a different class: [work.es6](https://github.com/projecthydra-labs/hyrax/blob/master/app/assets/javascripts/hyrax/autocomplete/work.es6).
175
+ After creating your own class, you will need to import it and an additional case to the autocomplete method in [autocomplete.es6](https://github.com/projecthydra-labs/hyrax/blob/master/app/assets/javascripts/hyrax/autocomplete.es6)
176
+
127
177
  #### Adding Controlled Vocabulary Dropdown Options
128
178
 
129
179
  To create your own dropdown with authorities you extend the `QASelectService` class. By convention, we place this in `app/services`.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -37,7 +37,12 @@ module Qa
37
37
  responses = parent_service.search(query)
38
38
 
39
39
  responses.map do |result|
40
- result['id'] = apply_namespace(result['id'])
40
+ if result.keys.first.is_a?(Symbol)
41
+ result[:id] = apply_namespace(result[:id])
42
+ else
43
+ result['id'] = apply_namespace(result['id'])
44
+ end
45
+
41
46
  result
42
47
  end
43
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qa-ldf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Johnson