hydra-collections 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/CONTRIBUTING.md +113 -0
- data/Changelog.md +105 -0
- data/LICENSE.txt +12 -19
- data/README.md +67 -22
- data/{lib → app/controllers/concerns}/hydra/collections_controller_behavior.rb +29 -38
- data/app/helpers/collections_helper.rb +10 -0
- data/app/helpers/collections_search_helper.rb +6 -30
- data/{lib → app/models/concerns}/hydra/collection.rb +0 -8
- data/app/views/collections/_button_for_delete_collection.html.erb +1 -1
- data/app/views/collections/_button_remove_from_collection.html.erb +1 -1
- data/app/views/collections/_form.html.erb +2 -6
- data/app/views/collections/_form_for_select_destination_collection.html.erb +21 -0
- data/app/views/collections/_single_item_action_fields.html.erb +1 -1
- data/gemfiles/rails3.gemfile +6 -0
- data/gemfiles/rails4.gemfile +6 -0
- data/hydra-collections.gemspec +1 -0
- data/lib/hydra/collections/collectible.rb +1 -1
- data/lib/hydra/collections/selects_collections.rb +17 -5
- data/lib/hydra/collections/version.rb +1 -1
- data/lib/hydra/datastreams/collection_rdf_datastream.rb +0 -7
- data/lib/hydra-collections.rb +20 -7
- data/spec/controllers/accepts_batches_spec.rb +4 -4
- data/spec/controllers/collections_controller_spec.rb +46 -27
- data/spec/controllers/other_collections_controller_spec.rb +74 -0
- data/spec/controllers/selects_collections_spec.rb +11 -0
- data/spec/helpers/collections_helper_spec.rb +98 -40
- data/spec/helpers/collections_search_helper_spec.rb +5 -34
- data/spec/models/collection_spec.rb +30 -2
- data/spec/spec_helper.rb +7 -0
- data/tasks/hydra-collections-dev.rake +12 -6
- metadata +31 -7
- data/lib/hydra/collections.rb +0 -14
- data/spec/support/Gemfile +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a23c9e212041b2816a048695daa5248aad7430d4
|
4
|
+
data.tar.gz: 1fe561ef9cdf68b337e1940484c9abfabfeab8ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0281f3b8a8de3e273d261803addccf4a5755f654e5e4b19236030aab299992b491b19abcb7e4fa7de7451220a664db640e80e37b613505ba62d0a886b264b2c5
|
7
|
+
data.tar.gz: 767db121ed138d32b5c49c5cec0de22f159470ee661f91251cdaf45375f47f446c6851d20bad742d2efad825b6613d0cb09cf916b6e4069dca887fb448eab9f3
|
data/.travis.yml
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
-
|
3
|
+
- 2.0.0
|
4
|
+
gemfile:
|
5
|
+
- gemfiles/rails3.gemfile
|
6
|
+
- gemfiles/rails4.gemfile
|
4
7
|
notifications:
|
5
8
|
email:
|
6
9
|
recipients:
|
@@ -12,5 +15,6 @@ notifications:
|
|
12
15
|
irc:
|
13
16
|
channels:
|
14
17
|
- "irc.freenode.org#scholarsphere"
|
18
|
+
- "irc.freenode.org#projecthydra"
|
15
19
|
template:
|
16
20
|
- "%{repository}//%{branch}@%{commit} by %{author}: %{message} - %{build_url}"
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# How to Contribute
|
2
|
+
|
3
|
+
We want your help to make Project Hydra great.
|
4
|
+
There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
5
|
+
|
6
|
+
## Hydra Project Intellectual Property Licensing and Ownership
|
7
|
+
|
8
|
+
All code contributors must have an Individual Contributor License Agreement (iCLA) on file with the Hydra Project Steering Group.
|
9
|
+
If the contributor works for an institution, the institution must have a Corporate Contributor License Agreement (cCLA) on file.
|
10
|
+
|
11
|
+
https://wiki.duraspace.org/display/hydra/Hydra+Project+Intellectual+Property+Licensing+and+Ownership
|
12
|
+
|
13
|
+
You should also add yourself to the `CONTRIBUTORS.md` file in the root of the project.
|
14
|
+
|
15
|
+
## Contribution Tasks
|
16
|
+
|
17
|
+
* Reporting Issues
|
18
|
+
* Making Changes
|
19
|
+
* Submitting Changes
|
20
|
+
* Merging Changes
|
21
|
+
|
22
|
+
### Reporting Issues
|
23
|
+
|
24
|
+
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
25
|
+
* Submit a [Github issue](./issues) by:
|
26
|
+
* Clearly describing the issue
|
27
|
+
* Provide a descriptive summary
|
28
|
+
* Explain the expected behavior
|
29
|
+
* Explain the actual behavior
|
30
|
+
* Provide steps to reproduce the actual behavior
|
31
|
+
|
32
|
+
### Making Changes
|
33
|
+
|
34
|
+
* Fork the repository on GitHub
|
35
|
+
* Create a topic branch from where you want to base your work.
|
36
|
+
* This is usually the master branch.
|
37
|
+
* To quickly create a topic branch based on master; `git branch fix/master/my_contribution master`
|
38
|
+
* Then checkout the new branch with `git checkout fix/master/my_contribution`.
|
39
|
+
* Please avoid working directly on the `master` branch.
|
40
|
+
* You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
41
|
+
* Make commits of logical units.
|
42
|
+
* Your commit should include a high level description of your work in HISTORY.textile
|
43
|
+
* Check for unnecessary whitespace with `git diff --check` before committing.
|
44
|
+
* Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
45
|
+
* If you created an issue, you can close it by including "Closes #issue" in your commit message. See [Github's blog post for more details](https://github.com/blog/1386-closing-issues-via-commit-messages)
|
46
|
+
|
47
|
+
```
|
48
|
+
Present tense short summary (50 characters or less)
|
49
|
+
|
50
|
+
More detailed description, if necessary. It should be wrapped to 72
|
51
|
+
characters. Try to be as descriptive as you can, even if you think that
|
52
|
+
the commit content is obvious, it may not be obvious to others. You
|
53
|
+
should add such description also if it's already present in bug tracker,
|
54
|
+
it should not be necessary to visit a webpage to check the history.
|
55
|
+
|
56
|
+
Include Closes #<issue-number> when relavent.
|
57
|
+
|
58
|
+
Description can have multiple paragraphs and you can use code examples
|
59
|
+
inside, just indent it with 4 spaces:
|
60
|
+
|
61
|
+
class PostsController
|
62
|
+
def index
|
63
|
+
respond_with Post.limit(10)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
You can also add bullet points:
|
68
|
+
|
69
|
+
- you can use dashes or asterisks
|
70
|
+
|
71
|
+
- also, try to indent next line of a point for readability, if it's too
|
72
|
+
long to fit in 72 characters
|
73
|
+
```
|
74
|
+
|
75
|
+
* Make sure you have added the necessary tests for your changes.
|
76
|
+
* Run _all_ the tests to assure nothing else was accidentally broken.
|
77
|
+
* When you are ready to submit a pull request
|
78
|
+
|
79
|
+
### Submitting Changes
|
80
|
+
|
81
|
+
[Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
82
|
+
|
83
|
+
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
84
|
+
* Make sure your branch is up to date with its parent branch (i.e. master)
|
85
|
+
* `git checkout master`
|
86
|
+
* `git pull --rebase`
|
87
|
+
* `git checkout <your-branch>`
|
88
|
+
* `git rebase master`
|
89
|
+
* It is likely a good idea to run your tests again.
|
90
|
+
* Squash the commits for your branch into one commit
|
91
|
+
* `git rebase --interactive HEAD~<number-of-commits>` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
92
|
+
* To determine the number of commits on your branch: `git log master..<your-branch> --oneline | wc -l`
|
93
|
+
* Squashing your branch's changes into one commit is "good form" and helps the person merging your request to see everything that is going on.
|
94
|
+
* Push your changes to a topic branch in your fork of the repository.
|
95
|
+
* Submit a pull request from your fork to the project.
|
96
|
+
|
97
|
+
### Merging Changes
|
98
|
+
|
99
|
+
* It is considered "poor from" to merge your own request.
|
100
|
+
* Please take the time to review the changes and get a sense of what is being changed. Things to consider:
|
101
|
+
* Does the commit message explain what is going on?
|
102
|
+
* Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
|
103
|
+
* Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
104
|
+
* Did the Travis tests complete successfully?
|
105
|
+
* If you are uncertain, bring other contributors into the conversation by creating a comment that includes their @username.
|
106
|
+
* If you like the pull request, but want others to chime in, create a +1 comment and tag a user.
|
107
|
+
|
108
|
+
# Additional Resources
|
109
|
+
|
110
|
+
* [General GitHub documentation](http://help.github.com/)
|
111
|
+
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
112
|
+
* [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
113
|
+
* [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/Changelog.md
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
|
3
|
+
* 2013-09-30: Refactor to load modules after engine is initialized (concerns)
|
4
|
+
[Justin Coyne]
|
5
|
+
|
6
|
+
* 2013-09-23: remove cruft [Justin Coyne]
|
7
|
+
|
8
|
+
* 2013-09-19: Updating CONTRIBUTING.md as per Hydra v6.0.0 [Jeremy Friesen]
|
9
|
+
|
10
|
+
* 2013-08-23: Fix a rails 4 deprecation [Justin Coyne]
|
11
|
+
|
12
|
+
* 2013-08-23: Simplify collections controller [Justin Coyne]
|
13
|
+
|
14
|
+
* 2013-08-22: Allow for member query to include sort and per page information
|
15
|
+
from the parameters [Carolyn Cole]
|
16
|
+
|
17
|
+
* 2013-08-22: change line wrapping of examples [ci skip] [Justin Coyne]
|
18
|
+
|
19
|
+
* 2013-08-22: Fix language formatting [ci skip] [Justin Coyne]
|
20
|
+
|
21
|
+
* 2013-08-22: Fix code formatting [ci skip] [Justin Coyne]
|
22
|
+
|
23
|
+
* 2013-08-22: Link to code examples [ci skip] [Justin Coyne]
|
24
|
+
|
25
|
+
* 2013-08-22: What is a hydra-collection. [ci skip] [Justin Coyne]
|
26
|
+
|
27
|
+
* 2013-08-22: completing documentation for update-batches [Carolyn Cole]
|
28
|
+
|
29
|
+
* 2013-07-30: The filter for include_collection_ids should always work, even if
|
30
|
+
there are no members [Justin Coyne]
|
31
|
+
|
32
|
+
* 2013-07-30: Adding as collection to remove so the operation will work with any
|
33
|
+
class collection [Carolyn Cole]
|
34
|
+
|
35
|
+
* 2013-07-29: Allow items to be moved between collections. [Justin Coyne]
|
36
|
+
|
37
|
+
* 2013-07-26: tidying up spec example [Matt Zumwalt]
|
38
|
+
|
39
|
+
* 2013-07-24: removing call to collection find since load_and_authorize has
|
40
|
+
already done the find [Carolyn Cole]
|
41
|
+
|
42
|
+
* 2013-07-23: Make sure the @collection instance varriable is set even if the
|
43
|
+
collection class name is not Collection [Carolyn Cole]
|
44
|
+
|
45
|
+
* 2013-07-19: Test button_for_remove_from_collection with rails3 and 4 [Justin
|
46
|
+
Coyne]
|
47
|
+
|
48
|
+
* 2013-07-19: Allowing the collection class to be of any name [Carolyn Cole]
|
49
|
+
|
50
|
+
* 2013-07-18: Created a hidden field helper [Justin Coyne]
|
51
|
+
|
52
|
+
* 2013-07-18: Remove registering LocalAuthority This code was always erroring
|
53
|
+
with `uninitialized constant Hydra::CollectionRdfDatastream::LocalAuthority`
|
54
|
+
and giving a misleading warning. [Justin Coyne]
|
55
|
+
|
56
|
+
* 2013-07-17: Remove the user factory generated by devise [Justin Coyne]
|
57
|
+
|
58
|
+
* 2013-07-17: Use the gemfile that rails generates for testing [Justin Coyne]
|
59
|
+
|
60
|
+
* 2013-07-17: Relax testing gemspec [Justin Coyne]
|
61
|
+
|
62
|
+
* 2013-07-17: Update README.md [Edwin Shin]
|
63
|
+
|
64
|
+
* 2013-07-17: Fix gemspec version requirement [Justin Coyne]
|
65
|
+
|
66
|
+
* 2013-07-17: Update README.md [Edwin Shin]
|
67
|
+
|
68
|
+
* 2013-07-17: Loosen the spec so that we can do development on rails 3.2 or 4.0
|
69
|
+
[Justin Coyne]
|
70
|
+
|
71
|
+
* 2013-07-17: Check for existence, rather than lack of an error [Justin Coyne]
|
72
|
+
|
73
|
+
* 2013-07-17: Stub is deprecated, replace with double() [Justin Coyne]
|
74
|
+
|
75
|
+
* 2013-07-17: Fix facet helper so that it shows the collection name [Justin
|
76
|
+
Coyne]
|
77
|
+
|
78
|
+
* 2013-07-12: Updating to compile with new ruby version and rspec version.
|
79
|
+
[Carolyn Cole]
|
80
|
+
|
81
|
+
* 2013-07-17: Loosen the spec so that we can do development on rails 3.2 or 4.0
|
82
|
+
[Justin Coyne]
|
83
|
+
|
84
|
+
* 2013-07-17: Check for existence, rather than lack of an error [Justin Coyne]
|
85
|
+
|
86
|
+
* 2013-07-17: Stub is deprecated, replace with double() [Justin Coyne]
|
87
|
+
|
88
|
+
* 2013-07-17: Fix facet helper so that it shows the collection name [Justin
|
89
|
+
Coyne]
|
90
|
+
|
91
|
+
* 2013-07-12: Updating to compile with new ruby version and rspec version.
|
92
|
+
[Carolyn Cole]
|
93
|
+
|
94
|
+
* 2013-07-09: Add build notifications to #projecthydra IRC channel now that the
|
95
|
+
gem is governed by the community, and trigger the first CI build [Michael J.
|
96
|
+
Giarlo]
|
97
|
+
|
98
|
+
* 2013-07-09: fix relative link to LICENSE file in README [Michael J. Giarlo]
|
99
|
+
|
100
|
+
* 2013-07-09: README links to the license, and gemnasium/travis/etc. links now
|
101
|
+
point at the new code location [Michael J. Giarlo]
|
102
|
+
|
103
|
+
* 2013-07-09: Updates license and README per new community conventions [Michael
|
104
|
+
J. Giarlo]
|
105
|
+
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,15 @@
|
|
1
|
-
Copyright
|
1
|
+
Copyright © 2013 The Pennsylvania State University
|
2
|
+
Copyright © 2013 Data Curation Experts
|
3
|
+
Additional copyright may be held by others, as reflected in the commit history.
|
2
4
|
|
3
|
-
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
4
8
|
|
5
|
-
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Hydra::Collections [![Version](https://badge.fury.io/rb/hydra-collections.png)](http://badge.fury.io/rb/hydra-collections) [![Build Status](https://travis-ci.org/
|
1
|
+
# Hydra::Collections [![Version](https://badge.fury.io/rb/hydra-collections.png)](http://badge.fury.io/rb/hydra-collections) [![Build Status](https://travis-ci.org/projecthydra/hydra-collections.png?branch=master)](https://travis-ci.org/projecthydra/hydra-collections) [![Dependency Status](https://gemnasium.com/projecthydra/hydra-collections.png)](https://gemnasium.com/projecthydra/hydra-collections)
|
2
2
|
|
3
|
-
Add collections to your Hydra application
|
3
|
+
Add collections to your Hydra application. These collections are typically created by depositors (instead of librarians or curators). Any collectible item can belong to many different collections. The collection does not confer access rights onto any of the members of the collections.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -20,12 +20,15 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
### Mount the engine to get the routes in config/routes.rb
|
22
22
|
|
23
|
-
mount Hydra::Collections::Engine => '/'
|
23
|
+
mount Hydra::Collections::Engine => '/'
|
24
24
|
|
25
25
|
### Call button_create_collection view helper in your search result page template.
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
First add `helper :collections` to your `catalog_controller.rb`
|
27
|
+
|
28
|
+
Next, we recommend putting the view helper in catalog/[_sort_and_per_page.html.erb](https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/_sort_and_per_page.html.erb) which you will manually override in you app.
|
29
|
+
```erb
|
30
|
+
<%= button_for_create_collection %>
|
31
|
+
```
|
29
32
|
|
30
33
|
### Any time you want to refer to the routes from hydra-collections use collections.
|
31
34
|
collections.new_collections_path
|
@@ -49,6 +52,19 @@ end
|
|
49
52
|
|
50
53
|
Any items that include the `Hydra::Collections::Collectible` module can look up which collections they belong to via `.collections`. The `index_collection_pids` puts the pids of all associated collections into the `collection` facet.
|
51
54
|
|
55
|
+
### Make the Collection show as a facet in your CatalogController
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
class CatalogController < ApplicationController
|
59
|
+
include Blacklight::Catalog
|
60
|
+
...
|
61
|
+
configure_blacklight do |config|
|
62
|
+
...
|
63
|
+
config.add_facet_field solr_name("collection", :facetable), label: "Collection", helper_method: :collection_name
|
64
|
+
end
|
65
|
+
end
|
66
|
+
```
|
67
|
+
|
52
68
|
### Make your Controller Accept a Batch
|
53
69
|
|
54
70
|
Add `include Hydra::Collections::AcceptsBatches` to the collections you would like to process batches of models
|
@@ -60,7 +76,7 @@ Example:
|
|
60
76
|
class BatchEditsController < ApplicationController
|
61
77
|
include Hydra::Collections::AcceptsBatches
|
62
78
|
...
|
63
|
-
|
79
|
+
|
64
80
|
def update
|
65
81
|
batch.each do |doc_id|
|
66
82
|
obj = ActiveFedora::Base.find(doc_id, :cast=>true)
|
@@ -68,44 +84,64 @@ class BatchEditsController < ApplicationController
|
|
68
84
|
obj.save
|
69
85
|
end
|
70
86
|
flash[:notice] = "Batch update complete"
|
71
|
-
after_update
|
87
|
+
after_update
|
72
88
|
end
|
73
89
|
|
74
90
|
end
|
75
91
|
```
|
76
92
|
### Include the javascript to discover checked batch items
|
77
93
|
|
78
|
-
|
94
|
+
add to your application.js
|
95
|
+
```js
|
96
|
+
//= require hydra/batch_select
|
97
|
+
//= require hydra_collections
|
98
|
+
```
|
79
99
|
|
80
|
-
### Display
|
100
|
+
### Display Hydra-collections in you views
|
101
|
+
Take a look at the helpers located in:
|
102
|
+
* [app/helpers/collections_helper.rb](/app/helpers/collections_helper.rb)
|
103
|
+
* [app/helpers/batch_select_helper.rb](/app/helpers/batch_select_helper.rb)
|
104
|
+
* [app/helpers/collections_search_helper.rb](/app/helpers/collections_search_helper.rb)
|
105
|
+
|
106
|
+
#### Examples
|
81
107
|
|
82
|
-
|
108
|
+
##### Display a selection checkbox in each document partial
|
83
109
|
|
84
|
-
|
85
|
-
|
110
|
+
include ```<%= button_for_add_to_batch document %>```
|
111
|
+
|
112
|
+
Example:
|
113
|
+
```erb
|
114
|
+
<% # views/catalog/_document_header.html.erb -%>
|
115
|
+
|
86
116
|
<% # header bar for doc items in index view -%>
|
87
117
|
<div class="documentHeader clearfix">
|
88
118
|
<%= button_for_add_to_batch(document) %>
|
89
|
-
|
90
119
|
...
|
91
120
|
</div>
|
92
121
|
|
93
122
|
```
|
94
123
|
|
95
124
|
|
96
|
-
|
125
|
+
##### Update your view to submit a Batch
|
97
126
|
|
98
|
-
include
|
99
127
|
Add `submits-batches` class to your view input to initialize batch processing
|
100
128
|
|
101
|
-
Example:
|
102
|
-
```
|
103
|
-
<%= button_to label, edit_batch_edits_path, :
|
129
|
+
Example:
|
130
|
+
```erb
|
131
|
+
<%= button_to label, edit_batch_edits_path, method: :get, class: "btn submits-batches",
|
132
|
+
'data-behavior'=>'batch-edit', id: 'batch-edit' %>
|
104
133
|
```
|
105
134
|
|
106
|
-
|
135
|
+
##### Update your action view to submit changes to the batch
|
107
136
|
|
108
|
-
Add `updates-batches` class to your
|
137
|
+
Add `updates-batches` class to your button for submitting the batch
|
138
|
+
|
139
|
+
Example:
|
140
|
+
```erb
|
141
|
+
<%= button_to label, collections.collection_path(collection_id), method: :put,
|
142
|
+
class: "btn btn-primary updates-collection submits-batches collection-update",
|
143
|
+
'data-behavior'=>'hydra-collections', id: 'hydra-collection-update' %>
|
144
|
+
```
|
109
145
|
|
110
146
|
|
111
147
|
## Contributing
|
@@ -126,8 +162,17 @@ In order to make modifications to the gem code and run the tests, clone the repo
|
|
126
162
|
$ git submodule update
|
127
163
|
$ rake jetty:config
|
128
164
|
$ rake jetty:start
|
129
|
-
$ rake clean
|
165
|
+
$ rake clean
|
130
166
|
$ rake spec
|
131
167
|
```
|
132
168
|
|
169
|
+
## License
|
170
|
+
|
171
|
+
The hydra-collections source code is freely available under the Apache 2.0 license.
|
172
|
+
[Read the copyright statement and license](/LICENSE.txt).
|
173
|
+
|
174
|
+
## Acknowledgements
|
175
|
+
|
176
|
+
This software has been developed by and is brought to you by the Hydra community. Learn more at the [Project Hydra website](http://projecthydra.org)
|
133
177
|
|
178
|
+
![Project Hydra Logo](https://github.com/uvalib/libra-oa/blob/a6564a9e5c13b7873dc883367f5e307bf715d6cf/public/images/powered_by_hydra.png?raw=true)
|
@@ -1,19 +1,3 @@
|
|
1
|
-
require 'blacklight'
|
2
|
-
|
3
|
-
# -*- coding: utf-8 -*-
|
4
|
-
# Copyright © 2012 The Pennsylvania State University
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
1
|
include Blacklight::SolrHelper
|
18
2
|
|
19
3
|
module Hydra
|
@@ -21,10 +5,9 @@ module Hydra
|
|
21
5
|
extend ActiveSupport::Concern
|
22
6
|
|
23
7
|
included do
|
24
|
-
include
|
25
|
-
include Blacklight::Configurable # comply with BL 3.7
|
26
|
-
include Blacklight::Controller
|
8
|
+
include Blacklight::Configurable
|
27
9
|
include Hydra::Collections::AcceptsBatches
|
10
|
+
include Hydra::Collections::SelectsCollections
|
28
11
|
|
29
12
|
# This is needed as of BL 3.7
|
30
13
|
self.copy_blacklight_config_from(CatalogController)
|
@@ -43,21 +26,22 @@ module Hydra
|
|
43
26
|
|
44
27
|
# actions: audit, index, create, new, edit, show, update, destroy, permissions, citation
|
45
28
|
before_filter :authenticate_user!, :except => [:show]
|
46
|
-
load_and_authorize_resource :except=>[:index]
|
47
|
-
before_filter :query_collection_members, only:[:show, :edit]
|
29
|
+
load_and_authorize_resource :except=>[:index], instance_name: :collection
|
48
30
|
|
49
31
|
#This includes only the collection members in the search
|
50
32
|
self.solr_search_params_logic += [:include_collection_ids]
|
51
33
|
end
|
52
34
|
|
53
35
|
def new
|
54
|
-
#@collection = ::Collection.new
|
55
36
|
end
|
56
37
|
|
57
38
|
def show
|
39
|
+
query_collection_members
|
58
40
|
end
|
59
|
-
|
41
|
+
|
60
42
|
def edit
|
43
|
+
query_collection_members
|
44
|
+
find_collections
|
61
45
|
end
|
62
46
|
|
63
47
|
def after_create
|
@@ -88,8 +72,11 @@ module Hydra
|
|
88
72
|
end
|
89
73
|
|
90
74
|
def after_update
|
75
|
+
if flash[:notice].nil?
|
76
|
+
flash[:notice] = 'Collection was successfully updated.'
|
77
|
+
end
|
91
78
|
respond_to do |format|
|
92
|
-
format.html { redirect_to collections.collection_path(@collection)
|
79
|
+
format.html { redirect_to collections.collection_path(@collection) }
|
93
80
|
format.json { render json: @collection, status: :updated, location: @collection }
|
94
81
|
end
|
95
82
|
end
|
@@ -102,7 +89,6 @@ module Hydra
|
|
102
89
|
end
|
103
90
|
|
104
91
|
def update
|
105
|
-
@collection = ::Collection.find(params[:id])
|
106
92
|
process_member_changes
|
107
93
|
@collection.update_attributes(params[:collection].except(:members))
|
108
94
|
if @collection.save
|
@@ -128,7 +114,6 @@ module Hydra
|
|
128
114
|
end
|
129
115
|
|
130
116
|
def destroy
|
131
|
-
@collection = ::Collection.find(params[:id])
|
132
117
|
if @collection.destroy
|
133
118
|
after_destroy(params[:id])
|
134
119
|
else
|
@@ -141,15 +126,13 @@ module Hydra
|
|
141
126
|
# Queries Solr for members of the collection.
|
142
127
|
# Populates @response and @member_docs similar to Blacklight Catalog#index populating @response and @documents
|
143
128
|
def query_collection_members
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@response = Blacklight::SolrResponse.new({'responseHeader'=>{'status'=>0,'QTime'=>5,'params'=>{'wt'=>'ruby','q'=>'xxzxas'}},'response'=>{'numFound'=>0,'start'=>0,'maxScore'=>0.0,'docs'=>[]},'facet_counts'=>{'facet_queries'=>{},'facet_fields'=>{'active_fedora_model_ssi'=>[],'object_type_si'=>[]},'facet_dates'=>{},'facet_ranges'=>{}},'spellcheck'=>{'suggestions'=>['correctlySpelled',false]}},"")
|
152
|
-
end
|
129
|
+
query = params[:cq]
|
130
|
+
|
131
|
+
#default the rows to 100 if not specified then merge in the user parameters and the attach the collection query
|
132
|
+
solr_params = {rows:100}.merge(params.symbolize_keys).merge({:q => query})
|
133
|
+
|
134
|
+
# run the solr query to find the collections
|
135
|
+
(@response, @member_docs) = get_search_results(solr_params)
|
153
136
|
end
|
154
137
|
|
155
138
|
def process_member_changes
|
@@ -168,9 +151,15 @@ module Hydra
|
|
168
151
|
when "remove"
|
169
152
|
change_members.each do |member|
|
170
153
|
@collection.members.delete(member)
|
171
|
-
#puts "removing pid"
|
172
|
-
#@collection.remove_relationship(:has_collection_member, "info:fedora/#{pid}")
|
173
154
|
end
|
155
|
+
when "move"
|
156
|
+
@destination_collection = ::Collection.find(params[:destination_collection_id])
|
157
|
+
change_members.each do |member|
|
158
|
+
@collection.members.delete(member)
|
159
|
+
@destination_collection.members << member
|
160
|
+
end
|
161
|
+
@destination_collection.save
|
162
|
+
flash[:notice] = "Successfully moved #{change_members.count} files to #{@destination_collection.title} Collection."
|
174
163
|
when Array
|
175
164
|
@collection.members.replace(change_members)
|
176
165
|
#@collection.clear_relationship(:has_collection_member)
|
@@ -189,7 +178,9 @@ module Hydra
|
|
189
178
|
# include filters into the query to only include the collection memebers
|
190
179
|
def include_collection_ids(solr_parameters, user_parameters)
|
191
180
|
solr_parameters[:fq] ||= []
|
192
|
-
if @collection.member_ids.
|
181
|
+
if @collection.member_ids.empty?
|
182
|
+
solr_parameters[:fq] << '{!lucene}-id:[* TO *]' # Don't match anything
|
183
|
+
else
|
193
184
|
query = @collection.member_ids.map{|id| 'id:"'+id+'"'}.join " OR "
|
194
185
|
solr_parameters[:fq] << query
|
195
186
|
end
|
@@ -40,5 +40,15 @@ module CollectionsHelper
|
|
40
40
|
def single_item_action_form_fields(form, document, action)
|
41
41
|
render partial:'/collections/single_item_action_fields', locals:{form:form, document:document, action: action}
|
42
42
|
end
|
43
|
+
|
44
|
+
def hidden_collection_members
|
45
|
+
_erbout = ''
|
46
|
+
if params[:batch_document_ids].present?
|
47
|
+
params[:batch_document_ids].each do |batch_item|
|
48
|
+
_erbout.concat hidden_field_tag("batch_document_ids[]", batch_item)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
_erbout.html_safe
|
52
|
+
end
|
43
53
|
|
44
54
|
end
|
@@ -1,34 +1,10 @@
|
|
1
1
|
# View Helper methods for Hydra Collections in search results
|
2
2
|
module CollectionsSearchHelper
|
3
|
-
|
3
|
+
|
4
|
+
# @param [String] collection_pid the pid of a collection
|
5
|
+
# @return [String] the title of the collection if available, otherwise its pid
|
4
6
|
def collection_name(collection_pid)
|
5
|
-
|
6
|
-
escaped_pid = collection_pid.sub(':', '\:')
|
7
|
-
solr_opts = {params: {:q=>"id:#{escaped_pid}"}}
|
8
|
-
result = Blacklight.solr.get("select", solr_opts)
|
9
|
-
docs = result["response"]["docs"]
|
10
|
-
|
11
|
-
if docs
|
12
|
-
if docs.first[Solrizer.solr_name(:title, :displayable)]
|
13
|
-
res = docs.first[Solrizer.solr_name(:title, :displayable)]
|
14
|
-
res.kind_of?(Array) ? res.first : res
|
15
|
-
else
|
16
|
-
logger.warn "#{docs.first['id']} does not have a #{Solrizer.solr_name(:title, :displayable)} in solr"
|
17
|
-
docs.first['id']
|
18
|
-
end
|
19
|
-
else
|
20
|
-
'Not Found'
|
21
|
-
end
|
7
|
+
Collection.load_instance_from_solr(collection_pid).title || collection_pid
|
22
8
|
end
|
23
|
-
|
24
|
-
|
25
|
-
if facet == Solrizer.solr_name(:collection, :facetable)
|
26
|
-
collection_name(value)
|
27
|
-
elsif ['release_date_desc_facet', 'last_update_date_desc_facet'].include? facet
|
28
|
-
Narm::DateFacet.decode(value)
|
29
|
-
else
|
30
|
-
value
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
9
|
+
|
10
|
+
end
|
@@ -5,7 +5,6 @@ module Hydra
|
|
5
5
|
module Collection
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
extend ActiveSupport::Autoload
|
8
|
-
autoload :Permissions
|
9
8
|
include Hydra::ModelMethods # for access to apply_depositor_metadata
|
10
9
|
include Hydra::ModelMixins::RightsMetadata
|
11
10
|
include Hydra::Collections::Collectible
|
@@ -34,13 +33,6 @@ module Hydra
|
|
34
33
|
before_destroy :remove_all_members
|
35
34
|
end
|
36
35
|
|
37
|
-
# TODO: Move this override into ScholarSphere
|
38
|
-
#def to_solr(solr_doc={}, opts={})
|
39
|
-
# super(solr_doc, opts)
|
40
|
-
# solr_doc[Solrizer.solr_name("noid", :sortable, :type => :text)] = noid
|
41
|
-
# return solr_doc
|
42
|
-
#end
|
43
|
-
|
44
36
|
def terms_for_editing
|
45
37
|
terms_for_display - [:date_modified, :date_uploaded]
|
46
38
|
end
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<%# button for deleting a collections %>
|
2
2
|
<%# collection -- collection to be deleted %>
|
3
|
-
<%= button_to label, collections.collection_path(collection.id), :confirm
|
3
|
+
<%= button_to label, collections.collection_path(collection.id), data:{confirm: confirm, behavior: 'hydra-collections'}, method: :delete, class: "btn btn-primary collection-delete", id: 'hydra-collection-add' %>
|
4
4
|
|