hyrax-iiif_av 0.2.0 → 0.4.0
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 +5 -5
- data/.circleci/config.yml +48 -0
- data/.github/workflows/release.yml +33 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +17 -1
- data/CONTRIBUTING.md +181 -0
- data/README.md +33 -36
- data/app/controllers/concerns/hyrax/iiif_av/auth_controller_behavior.rb +53 -0
- data/app/controllers/concerns/hyrax/iiif_av/controller_behavior.rb +20 -7
- data/app/controllers/hyrax/iiif_av/iiif_av_controller.rb +88 -0
- data/app/presenters/concerns/hyrax/iiif_av/displays_content.rb +64 -17
- data/app/presenters/concerns/hyrax/iiif_av/displays_iiif_av.rb +1 -1
- data/config/locales/en.yml +10 -0
- data/config/routes.rb +6 -0
- data/hyrax-iiif_av.gemspec +7 -6
- data/lib/generators/hyrax/iiif_av/install_generator.rb +32 -1
- data/lib/hyrax/iiif_av/configuration.rb +9 -0
- data/lib/hyrax/iiif_av/spec/shared_specs/controller_behavior.rb +1 -1
- data/lib/hyrax/iiif_av/spec/shared_specs/displays_content.rb +38 -33
- data/lib/hyrax/iiif_av/version.rb +1 -1
- metadata +47 -20
- data/bin/rails +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 60db1204a3be6e2045adea2459d963caa13baadec61fd4cfdc541babf9e05bab
|
4
|
+
data.tar.gz: f751f0a1f73f67b34fd321ac4d1f3b714575b8b2a2ea3fb320993501078d8bb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4aad636182df8ce8acc9c9f6f233f46bd5f70dfcec9a76d7c01583d6ec85602734da94ed4134042885664daad451aabbac511d9d02807cc344645780630a07ea
|
7
|
+
data.tar.gz: b2e5d4821b51707a04c60c8cc94b601f8600cdfd80a477361983cef33f423adacd73be366d01cb97ecd893824b0dcee14551cf1859bae75a33187418e3ee22d0
|
@@ -0,0 +1,48 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
samvera: samvera/circleci-orb@1.0
|
4
|
+
jobs:
|
5
|
+
bundle_and_test:
|
6
|
+
parameters:
|
7
|
+
ruby_version:
|
8
|
+
type: string
|
9
|
+
default: 3.4.4
|
10
|
+
bundler_version:
|
11
|
+
type: string
|
12
|
+
default: 2.6.7
|
13
|
+
|
14
|
+
executor:
|
15
|
+
name: 'samvera/ruby_fcrepo_solr'
|
16
|
+
ruby_version: << parameters.ruby_version >>
|
17
|
+
solr_version: 7-slim
|
18
|
+
|
19
|
+
working_directory: ~/project
|
20
|
+
|
21
|
+
environment:
|
22
|
+
ENGINE_CART_RAILS_OPTIONS: --skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-coffee --skip-puma --skip-test
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- samvera/cached_checkout
|
26
|
+
|
27
|
+
- samvera/bundle:
|
28
|
+
ruby_version: << parameters.ruby_version >>
|
29
|
+
bundler_version: << parameters.bundler_version >>
|
30
|
+
|
31
|
+
- samvera/engine_cart_generate:
|
32
|
+
cache_key: v2-internal-test-app-{{ checksum "hyrax-iiif_av.gemspec" }}-{{ checksum "spec/test_app_templates/lib/generators/test_app_generator.rb" }}-{{ checksum "lib/generators/hyrax/iiif_av/install_generator.rb" }}
|
33
|
+
|
34
|
+
- samvera/install_solr_core:
|
35
|
+
solr_config_path: .internal_test_app/solr/conf
|
36
|
+
|
37
|
+
- samvera/bundle:
|
38
|
+
ruby_version: << parameters.ruby_version >>
|
39
|
+
bundler_version: << parameters.bundler_version >>
|
40
|
+
|
41
|
+
- samvera/parallel_rspec
|
42
|
+
|
43
|
+
workflows:
|
44
|
+
ci:
|
45
|
+
jobs:
|
46
|
+
- bundle_and_test:
|
47
|
+
name: ruby3-4
|
48
|
+
ruby_version: 3.4.4
|
@@ -0,0 +1,33 @@
|
|
1
|
+
name: Release Gem
|
2
|
+
on:
|
3
|
+
workflow_dispatch:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v*
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
push:
|
10
|
+
if: github.repository == 'samvera-labs/hyrax-iiif_av'
|
11
|
+
name: Push gem to RubyGems.org
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
permissions:
|
15
|
+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
|
16
|
+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
|
17
|
+
|
18
|
+
environment: release
|
19
|
+
|
20
|
+
steps:
|
21
|
+
# Set up
|
22
|
+
- uses: actions/checkout@v5
|
23
|
+
with:
|
24
|
+
persist-credentials: false
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
bundler-cache: true
|
29
|
+
ruby-version: ruby
|
30
|
+
|
31
|
+
# Release
|
32
|
+
- uses: rubygems/release-gem@v1
|
33
|
+
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -2,7 +2,7 @@ inherit_gem:
|
|
2
2
|
bixby: bixby_default.yml
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
TargetRubyVersion: 2.
|
5
|
+
TargetRubyVersion: 2.4
|
6
6
|
DisplayCopNames: true
|
7
7
|
|
8
8
|
Naming/FileName:
|
@@ -20,7 +20,11 @@ Metrics/BlockLength:
|
|
20
20
|
- 'lib/hyrax/iiif_av/spec/shared_specs/displays_content.rb'
|
21
21
|
- 'lib/hyrax/iiif_av/spec/shared_specs/displays_iiif_av.rb'
|
22
22
|
- 'spec/controllers/generic_works_controller_spec.rb'
|
23
|
+
- 'spec/controllers/iiif_av_controller_spec.rb'
|
24
|
+
- 'spec/factories/users.rb'
|
23
25
|
- 'spec/helpers/iiif_av_helper_spec.rb'
|
26
|
+
- 'spec/requests/auth_controller_behavior_spec.rb'
|
27
|
+
- 'spec/support/features/session_helpers.rb'
|
24
28
|
|
25
29
|
RSpec/VerifiedDoubles:
|
26
30
|
Exclude:
|
@@ -31,3 +35,15 @@ RSpec/VerifiedDoubles:
|
|
31
35
|
RSpec/ExampleLength:
|
32
36
|
Exclude:
|
33
37
|
- 'lib/hyrax/iiif_av/spec/shared_specs/displays_content.rb'
|
38
|
+
|
39
|
+
Metrics/ModuleLength:
|
40
|
+
Exclude:
|
41
|
+
- 'app/presenters/concerns/hyrax/iiif_av/displays_content.rb'
|
42
|
+
|
43
|
+
Metrics/MethodLength:
|
44
|
+
Exclude:
|
45
|
+
- 'app/presenters/concerns/hyrax/iiif_av/displays_content.rb'
|
46
|
+
|
47
|
+
Rails/OutputSafety:
|
48
|
+
Exclude:
|
49
|
+
- 'app/controllers/hyrax/iiif_av/iiif_av_controller.rb'
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
# How to Contribute
|
2
|
+
|
3
|
+
We want your help to make the Samvera community great. There are a few guidelines
|
4
|
+
that we need contributors to follow so that we can have a chance of
|
5
|
+
keeping on top of things.
|
6
|
+
|
7
|
+
## Code of Conduct
|
8
|
+
|
9
|
+
The Samvera Community is dedicated to providing a welcoming and positive
|
10
|
+
experience for all its members, whether they are at a formal gathering, in
|
11
|
+
a social setting, or taking part in activities online. Please see our
|
12
|
+
[Code of Conduct](CODE_OF_CONDUCT.md) for more information.
|
13
|
+
|
14
|
+
## Language
|
15
|
+
|
16
|
+
The language we use matters. Today, tomorrow, and for years to come
|
17
|
+
people will read the code we write. They will judge us for our
|
18
|
+
design, logic, and the words we use to describe the system.
|
19
|
+
|
20
|
+
Our words should be accessible. Favor descriptive words that give
|
21
|
+
meaning while avoiding reinforcing systemic inequities. For example,
|
22
|
+
in the Samvera community, we should favor using allowed_list instead
|
23
|
+
of whitelist, denied_list instead of blacklist, or source/copy
|
24
|
+
instead of master/slave.
|
25
|
+
|
26
|
+
We're going to get it wrong, but this is a call to keep working to
|
27
|
+
make it right. View our code and the words we choose as a chance to
|
28
|
+
have a conversation. A chance to grow an understanding of the systems
|
29
|
+
we develop as well as the systems in which we live.
|
30
|
+
|
31
|
+
See [“Blacklists” and “whitelists”: a salutary warning concerning the
|
32
|
+
prevalence of racist language in discussions of predatory
|
33
|
+
publishing](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6148600/) for
|
34
|
+
further details.
|
35
|
+
|
36
|
+
## Contribution Tasks
|
37
|
+
|
38
|
+
- Reporting Issues
|
39
|
+
- Making Changes
|
40
|
+
- Documenting Code
|
41
|
+
- Committing Changes
|
42
|
+
- Submitting Changes
|
43
|
+
- Reviewing and Merging Changes
|
44
|
+
|
45
|
+
### Reporting Issues
|
46
|
+
|
47
|
+
- Make sure you have a [GitHub account](https://github.com/signup/free)
|
48
|
+
- Submit a [Github issue](https://github.com/samvera-labs/hyrax-iiif_av/issues/) by:
|
49
|
+
- Clearly describing the issue
|
50
|
+
- Provide a descriptive summary
|
51
|
+
- Explain the expected behavior
|
52
|
+
- Explain the actual behavior
|
53
|
+
- Provide steps to reproduce the actual behavior
|
54
|
+
|
55
|
+
### Making Changes
|
56
|
+
|
57
|
+
- Fork the repository on GitHub
|
58
|
+
- Create a topic branch from where you want to base your work.
|
59
|
+
- This is usually the `main` branch.
|
60
|
+
- To quickly create a topic branch based on `main`; `git branch fix/main/my_contribution main`
|
61
|
+
- Then checkout the new branch with `git checkout fix/main/my_contribution`.
|
62
|
+
- Please avoid working directly on the `main` branch.
|
63
|
+
- Please do not create a branch called `master`. (See note below.)
|
64
|
+
- You may find the [hub suite of commands](https://github.com/defunkt/hub) helpful
|
65
|
+
- Make sure you have added sufficient tests and documentation for your changes.
|
66
|
+
- Test functionality with RSpec; Test features / UI with Capybara.
|
67
|
+
- Run _all_ the tests to assure nothing else was accidentally broken.
|
68
|
+
|
69
|
+
NOTE: This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct)
|
70
|
+
and [language recommendations](#language).
|
71
|
+
Please **_do not_** create a branch called `master` for this repository or as part of
|
72
|
+
your pull request; the branch will either need to be removed or renamed before it can
|
73
|
+
be considered for inclusion in the code base and history of this repository.
|
74
|
+
|
75
|
+
### Documenting Code
|
76
|
+
|
77
|
+
- All new public methods, modules, and classes should include inline documentation in [YARD](http://yardoc.org/).
|
78
|
+
- Documentation should seek to answer the question "why does this code exist?"
|
79
|
+
- Document private / protected methods as desired.
|
80
|
+
- If you are working in a file with no prior documentation, do try to document as you gain understanding of the code.
|
81
|
+
- If you don't know exactly what a bit of code does, it is extra likely that it needs to be documented. Take a stab at it and ask for feedback in your pull request. You can use the 'blame' button on GitHub to identify the original developer of the code and @mention them in your comment.
|
82
|
+
- This work greatly increases the usability of the code base and supports the on-ramping of new committers.
|
83
|
+
- We will all be understanding of one another's time constraints in this area.
|
84
|
+
- [Getting started with YARD](http://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md)
|
85
|
+
|
86
|
+
### Committing changes
|
87
|
+
|
88
|
+
- Make commits of logical units.
|
89
|
+
- Check for unnecessary whitespace with `git diff --check` before committing.
|
90
|
+
- Make sure your commit messages are [well formed](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
91
|
+
- 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)
|
92
|
+
|
93
|
+
```
|
94
|
+
Present tense short summary (50 characters or less)
|
95
|
+
|
96
|
+
More detailed description, if necessary. It should be wrapped to 72
|
97
|
+
characters. Try to be as descriptive as you can, even if you think that
|
98
|
+
the commit content is obvious, it may not be obvious to others. You
|
99
|
+
should add such description also if it's already present in bug tracker,
|
100
|
+
it should not be necessary to visit a webpage to check the history.
|
101
|
+
|
102
|
+
Include Closes #<issue-number> when relavent.
|
103
|
+
|
104
|
+
Description can have multiple paragraphs and you can use code examples
|
105
|
+
inside, just indent it with 4 spaces:
|
106
|
+
|
107
|
+
class PostsController
|
108
|
+
def index
|
109
|
+
respond_to do |wants|
|
110
|
+
wants.html { render 'index' }
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
You can also add bullet points:
|
116
|
+
|
117
|
+
- you can use dashes or asterisks
|
118
|
+
|
119
|
+
- also, try to indent next line of a point for readability, if it's too
|
120
|
+
long to fit in 72 characters
|
121
|
+
```
|
122
|
+
|
123
|
+
- Make sure you have added the necessary tests for your changes.
|
124
|
+
- Run _all_ the tests to assure nothing else was accidentally broken.
|
125
|
+
- When you are ready to submit a pull request
|
126
|
+
|
127
|
+
### Submitting Changes
|
128
|
+
|
129
|
+
- Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
130
|
+
- Make sure your branch is up to date with its parent branch (i.e. main)
|
131
|
+
- `git checkout main`
|
132
|
+
- `git pull --rebase`
|
133
|
+
- `git checkout <your-branch>`
|
134
|
+
- `git rebase main`
|
135
|
+
- It is a good idea to run your tests again.
|
136
|
+
- If you've made more than one commit take a moment to consider whether squashing commits together would help improve their logical grouping.
|
137
|
+
- [Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
138
|
+
- `git rebase --interactive main` ([See Github help](https://help.github.com/articles/interactive-rebase))
|
139
|
+
- 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.
|
140
|
+
- Push your changes to a topic branch in your fork of the repository.
|
141
|
+
- Submit a pull request from your fork to the project.
|
142
|
+
|
143
|
+
### Reviewing and Merging Changes
|
144
|
+
|
145
|
+
We adopted [Github's Pull Request Review](https://help.github.com/articles/about-pull-request-reviews/) for our repositories.
|
146
|
+
Common checks that may occur in our repositories:
|
147
|
+
|
148
|
+
1. [CircleCI](https://circleci.com/gh/samvera) - where our automated tests are running
|
149
|
+
2. RuboCop/Bixby - where we check for style violations
|
150
|
+
3. Approval Required - Github enforces at least one person approve a pull request. Also, all reviewers that have chimed in must approve.
|
151
|
+
4. CodeClimate - is our code remaining healthy (at least according to static code analysis)
|
152
|
+
|
153
|
+
If one or more of the required checks failed (or are incomplete), the code should not be merged (and the UI will not allow it). If all of the checks have passed, then anyone on the project (including the pull request submitter) may merge the code.
|
154
|
+
|
155
|
+
_Example: Carolyn submits a pull request, Justin reviews the pull request and approves. However, Justin is still waiting on other checks (CI tests are usually the culprit), so he does not merge the pull request. Eventually, all of the checks pass. At this point, Carolyn or anyone else may merge the pull request._
|
156
|
+
|
157
|
+
#### Things to Consider When Reviewing
|
158
|
+
|
159
|
+
First, the person contributing the code is putting themselves out there. Be mindful of what you say in a review.
|
160
|
+
|
161
|
+
- Ask clarifying questions
|
162
|
+
- State your understanding and expectations
|
163
|
+
- Provide example code or alternate solutions, and explain why
|
164
|
+
|
165
|
+
This is your chance for a mentoring moment of another developer. Take time to give an honest and thorough review of what has changed. Things to consider:
|
166
|
+
|
167
|
+
- Does the commit message explain what is going on?
|
168
|
+
- Does the code changes have tests? _Not all changes need new tests, some changes are refactorings_
|
169
|
+
- Do new or changed methods, modules, and classes have documentation?
|
170
|
+
- Does the commit contain more than it should? Are two separate concerns being addressed in one commit?
|
171
|
+
- Does the description of the new/changed specs match your understanding of what the spec is doing?
|
172
|
+
- Did the Continuous Integration tests complete successfully?
|
173
|
+
|
174
|
+
If you are uncertain, bring other contributors into the conversation by assigning them as a reviewer.
|
175
|
+
|
176
|
+
# Additional Resources
|
177
|
+
|
178
|
+
- [General GitHub documentation](http://help.github.com/)
|
179
|
+
- [GitHub pull request documentation](https://help.github.com/articles/about-pull-requests/)
|
180
|
+
- [Pro Git](http://git-scm.com/book) is both a free and excellent book about Git.
|
181
|
+
- [A Git Config for Contributing](http://ndlib.github.io/practices/my-typical-per-project-git-config/)
|
data/README.md
CHANGED
@@ -1,43 +1,40 @@
|
|
1
1
|
# hyrax-iiif_av
|
2
2
|
Hyrax plugin for IIIF Presentation 3.0 Audiovisual support
|
3
3
|
|
4
|
-
#
|
5
|
-
1.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
# Generated controller for GenericWork
|
11
|
-
class GenericWorksController < ApplicationController
|
12
|
-
# Adds Hyrax behaviors to the controller.
|
13
|
-
include Hyrax::WorksControllerBehavior
|
14
|
-
include Hyrax::BreadcrumbsForWorks
|
15
|
-
include Hyrax::IiifAv::ControllerBehavior
|
16
|
-
self.curation_concern_type = ::GenericWork
|
17
|
-
|
18
|
-
# Use this line if you want to use a custom presenter
|
19
|
-
self.show_presenter = Hyrax::GenericWorkPresenter
|
20
|
-
end
|
21
|
-
end
|
4
|
+
# How to use this plugin
|
5
|
+
1. Add `hyrax-iiif_av` to your `Gemfile` and `bundle install`
|
6
|
+
|
7
|
+
2. Run generator passing your work type:
|
8
|
+
```
|
9
|
+
rails g hyrax:iiif_av:add_to_work_type MyWorkType
|
22
10
|
```
|
11
|
+
Notice that this generator includes mixins in the work controller and work show presenter.
|
23
12
|
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
# Generated via
|
27
|
-
# `rails generate hyrax:work GenericWork`
|
28
|
-
module Hyrax
|
29
|
-
class GenericWorkPresenter < Hyrax::WorkShowPresenter
|
30
|
-
include Hyrax::IiifAv::DisplaysIiifAv
|
31
|
-
|
32
|
-
Hyrax::MemberPresenterFactory.file_presenter_class = Hyrax::IiifAv::IiifFileSetPresenter
|
33
|
-
|
34
|
-
# Optional override to select iiif viewer to render
|
35
|
-
# default :avalon for AV, :universal_viewer for images
|
36
|
-
def iiif_viewer
|
37
|
-
:universal_viewer
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
13
|
+
3. (Optional) Run avalon player generator:
|
41
14
|
```
|
15
|
+
rails g hyrax:iiif_av:install_avalon_player
|
16
|
+
```
|
17
|
+
This will install `webpacker`, `react-rails`, and the avalon player (view partial, react JS, and yarn dependency). This might take a while.
|
18
|
+
|
19
|
+
4. Ingest audiovisual content and see a IIIF viewer render on the work show page.
|
20
|
+
|
21
|
+
For a walkthrough of this in a demo application try running through this repository's README: https://github.com/avalonmediasystem/connect2018-workshop
|
22
|
+
|
23
|
+
|
24
|
+
# Set up dev / test environment
|
25
|
+
This project uses engine cart for testing and development purposes. To generate the .internal_test_app directory do the following
|
26
|
+
|
27
|
+
```bash
|
28
|
+
export ENGINE_CART_RAILS_OPTIONS="--skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-coffee --skip-puma --skip-test"
|
29
|
+
bundle exec rake engine_cart:generate
|
30
|
+
```
|
31
|
+
|
32
|
+
Spec and rubocop can then be run using the `rake` command.
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/samvera-labs/hyrax-iiif_av>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
37
|
+
|
38
|
+
If you're working on PR for this project, create a feature branch off of `main`.
|
42
39
|
|
43
|
-
|
40
|
+
This repository follows the [Samvera Community Code of Conduct](https://samvera.atlassian.net/wiki/spaces/samvera/pages/405212316/Code+of+Conduct) and [language recommendations](https://github.com/samvera-labs/hyrax-iiif_av/blob/main/CONTRIBUTING.md#language). Please ***do not*** create a branch called `master` for this repository or as part of your pull request; the branch will either need to be removed or renamed before it can be considered for inclusion in the code base and history of this repository.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2011-2018, The Trustees of Indiana University and Northwestern
|
4
|
+
# University. Additional copyright may be held by others, as reflected in
|
5
|
+
# the commit history.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
# --- END LICENSE_HEADER BLOCK ---
|
19
|
+
|
20
|
+
module Hyrax
|
21
|
+
module IiifAv
|
22
|
+
module AuthControllerBehavior
|
23
|
+
extend ActiveSupport::Concern
|
24
|
+
|
25
|
+
def after_sign_in_path_for(resource_or_scope)
|
26
|
+
return Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_sign_in_path if referer_iiif_login? || request_iiif_login?
|
27
|
+
super
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def referer_iiif_login?
|
33
|
+
# When going through the login form
|
34
|
+
referer_uri_string = request.env.fetch("HTTP_REFERER", nil)
|
35
|
+
return false unless referer_uri_string.present?
|
36
|
+
referer_uri = URI(referer_uri_string)
|
37
|
+
# Don't worry about referers that come from a different site (includings where the IIIF viewer is embedded)
|
38
|
+
return false if referer_uri.host.present? && referer_uri.host != request.host
|
39
|
+
query_params = Rack::Utils.parse_query(referer_uri.query)
|
40
|
+
query_params && ActiveModel::Type::Boolean.new.cast(query_params["iiif_auth_login"])
|
41
|
+
end
|
42
|
+
|
43
|
+
def request_iiif_login?
|
44
|
+
# When already logged in
|
45
|
+
request_uri_string = request.env.fetch("REQUEST_URI", nil)
|
46
|
+
return false unless request_uri_string.present?
|
47
|
+
request_uri = URI(request_uri_string)
|
48
|
+
query_params = Rack::Utils.parse_query(request_uri.query)
|
49
|
+
ActiveModel::Type::Boolean.new.cast(query_params["iiif_auth_login"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -26,19 +26,24 @@ module Hyrax
|
|
26
26
|
prepend_view_path(Hyrax::IiifAv::Engine.view_path)
|
27
27
|
end
|
28
28
|
|
29
|
-
IIIF_PRESENTATION_2_MIME = 'application/json;profile=http://iiif.io/api/presentation/2/context.json'
|
30
|
-
IIIF_PRESENTATION_3_MIME = 'application/json;profile=http://iiif.io/api/presentation/3/context.json'
|
29
|
+
IIIF_PRESENTATION_2_MIME = 'application/ld+json;profile="http://iiif.io/api/presentation/2/context.json"'
|
30
|
+
IIIF_PRESENTATION_3_MIME = 'application/ld+json;profile="http://iiif.io/api/presentation/3/context.json"'
|
31
31
|
|
32
32
|
def manifest
|
33
33
|
add_iiif_header
|
34
|
-
|
34
|
+
|
35
|
+
headers['Access-Control-Allow-Origin'] = '*'
|
36
|
+
|
37
|
+
json = iiif_manifest_builder.manifest_for(presenter: iiif_manifest_presenter, iiif_manifest_factory: manifest_factory)
|
38
|
+
|
39
|
+
render json: json
|
35
40
|
end
|
36
41
|
|
37
42
|
private
|
38
43
|
|
39
44
|
# @return true if the request is for IIIF version 3; false otherwise
|
40
45
|
def iiif_version_3?
|
41
|
-
|
46
|
+
iiif_manifest_presenter.respond_to?(:iiif_version) ? iiif_manifest_presenter.iiif_version == 3 : false
|
42
47
|
end
|
43
48
|
|
44
49
|
def iiif_mime
|
@@ -50,11 +55,19 @@ module Hyrax
|
|
50
55
|
headers['Content-Type'] = iiif_mime
|
51
56
|
end
|
52
57
|
|
53
|
-
|
58
|
+
# Override this method to return classes instead of instances
|
59
|
+
# This forces the manifest action to call Hyrax::ManifestBuilderService.manifest_for
|
60
|
+
# which allows for the passing in of the manifest factory
|
61
|
+
def iiif_manifest_builder
|
62
|
+
self.class.iiif_manifest_builder ||
|
63
|
+
(Flipflop.cache_work_iiif_manifest? ? Hyrax::CachingIiifManifestBuilder : Hyrax::ManifestBuilderService)
|
64
|
+
end
|
65
|
+
|
66
|
+
def manifest_factory
|
54
67
|
if iiif_version_3?
|
55
|
-
::IIIFManifest::V3::ManifestFactory
|
68
|
+
::IIIFManifest::V3::ManifestFactory
|
56
69
|
else
|
57
|
-
::IIIFManifest::ManifestFactory
|
70
|
+
::IIIFManifest::ManifestFactory
|
58
71
|
end
|
59
72
|
end
|
60
73
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module IiifAv
|
4
|
+
class IiifAvController < ApplicationController
|
5
|
+
include Blacklight::Base
|
6
|
+
include Blacklight::AccessControls::Catalog
|
7
|
+
|
8
|
+
def content
|
9
|
+
file_set_id = params[:id]
|
10
|
+
label = params[:label]
|
11
|
+
if request.head?
|
12
|
+
return head :ok if valid_token? || can?(:read, params[:id])
|
13
|
+
return head :unauthorized
|
14
|
+
else
|
15
|
+
return head :unauthorized unless presenter
|
16
|
+
return redirect_to hyrax.download_path(file_set_id, file: label, locale: nil) unless stream_urls[label]
|
17
|
+
redirect_to stream_urls[label]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def auth_token
|
22
|
+
return head :unauthorized unless can? :read, params[:id]
|
23
|
+
response.set_header('Content-Security-Policy', 'frame-ancestors *')
|
24
|
+
render html: auth_token_html_response(generate_auth_token)
|
25
|
+
end
|
26
|
+
|
27
|
+
# This route is meant to be used with devise's `after_sign_in_path_for` as part of the IIIF Auth flow
|
28
|
+
# See the override of `after_sign_in_path_for` in Hyrax::IiifAv::AuthControllerBehavior
|
29
|
+
def sign_in
|
30
|
+
render inline: "<html><head><script>window.close();</script></head><body></body></html>".html_safe
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def generate_auth_token
|
36
|
+
# This is the same method used by ActiveRecord::SecureToken
|
37
|
+
token = SecureRandom.base58(24)
|
38
|
+
Rails.cache.write("iiif_auth_token-#{token}", params[:id])
|
39
|
+
token
|
40
|
+
end
|
41
|
+
|
42
|
+
def auth_token_html_response(token)
|
43
|
+
message = { messageId: params[:messageId], accessToken: token }
|
44
|
+
origin = Rails::Html::FullSanitizer.new.sanitize(params[:origin])
|
45
|
+
"<html><body><script>window.parent.postMessage(#{message.to_json}, \"#{origin}\");</script></body></html>".html_safe
|
46
|
+
end
|
47
|
+
|
48
|
+
def valid_token?
|
49
|
+
auth_token = request.headers['Authorization']&.sub('Bearer ', '')&.strip
|
50
|
+
resource_id = Rails.cache.read("iiif_auth_token-#{auth_token}")
|
51
|
+
params[:id] == resource_id
|
52
|
+
end
|
53
|
+
|
54
|
+
# Override of Blacklight::RequestBuilders
|
55
|
+
def search_builder_class
|
56
|
+
Hyrax::FileSetSearchBuilder
|
57
|
+
end
|
58
|
+
|
59
|
+
def presenter
|
60
|
+
@presenter ||= begin
|
61
|
+
_, document_list = search_results(params)
|
62
|
+
curation_concern = document_list.first
|
63
|
+
return nil unless curation_concern
|
64
|
+
# Use the show presenter configured in the FileSetsController
|
65
|
+
Hyrax::FileSetsController.show_presenter.new(curation_concern, current_ability, request)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Duplicated here from Hyrax::IiifAv::DisplaysContent
|
70
|
+
def stream_urls
|
71
|
+
@stream_urls ||= begin
|
72
|
+
return {} unless presenter.solr_document['derivatives_metadata_ssi'].present?
|
73
|
+
files_metadata = JSON.parse(presenter.solr_document['derivatives_metadata_ssi'])
|
74
|
+
file_locations = files_metadata.select { |f| f['file_location_uri'].present? }
|
75
|
+
return {} unless file_locations.present?
|
76
|
+
streams = {}
|
77
|
+
file_locations.each do |f|
|
78
|
+
streams[f['label']] = Hyrax::IiifAv.config.iiif_av_url_builder.call(
|
79
|
+
f['file_location_uri'],
|
80
|
+
request.base_url
|
81
|
+
)
|
82
|
+
end
|
83
|
+
streams
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -47,11 +47,24 @@ module Hyrax
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def image_content
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
return nil unless latest_file_id
|
51
|
+
|
52
|
+
url_builder = Hyrax.config.iiif_image_url_builder
|
53
|
+
url = if url_builder.arity == 4
|
54
|
+
url_builder.call(
|
55
|
+
latest_file_id,
|
56
|
+
request.base_url,
|
57
|
+
Hyrax.config.iiif_image_size_default,
|
58
|
+
# In Hyrax 3, Hyrax.config.iiif_image_url_builder takes a format argument
|
59
|
+
image_format(alpha_channels)
|
60
|
+
)
|
61
|
+
else
|
62
|
+
url_builder.call(
|
63
|
+
latest_file_id,
|
64
|
+
request.base_url,
|
65
|
+
Hyrax.config.iiif_image_size_default
|
66
|
+
)
|
67
|
+
end
|
55
68
|
|
56
69
|
# Look at the request and target prezi 2 or 3 for images
|
57
70
|
parent.iiif_version == 3 ? image_content_v3(url) : image_content_v2(url)
|
@@ -60,18 +73,20 @@ module Hyrax
|
|
60
73
|
def image_content_v3(url)
|
61
74
|
# @see https://github.com/samvera-labs/iiif_manifest
|
62
75
|
IIIFManifest::V3::DisplayContent.new(url,
|
63
|
-
|
64
|
-
|
76
|
+
format: image_format(alpha_channels),
|
77
|
+
width: width,
|
78
|
+
height: height,
|
65
79
|
type: 'Image',
|
66
|
-
iiif_endpoint: iiif_endpoint(
|
80
|
+
iiif_endpoint: iiif_endpoint(latest_file_id))
|
67
81
|
end
|
68
82
|
|
69
83
|
def image_content_v2(url)
|
70
84
|
# @see https://github.com/samvera-labs/iiif_manifest
|
71
85
|
IIIFManifest::DisplayImage.new(url,
|
72
|
-
|
73
|
-
|
74
|
-
|
86
|
+
format: image_format(alpha_channels),
|
87
|
+
width: width,
|
88
|
+
height: height,
|
89
|
+
iiif_endpoint: iiif_endpoint(latest_file_id))
|
75
90
|
end
|
76
91
|
|
77
92
|
def video_content
|
@@ -84,13 +99,15 @@ module Hyrax
|
|
84
99
|
end
|
85
100
|
end
|
86
101
|
|
87
|
-
def video_display_content(
|
88
|
-
IIIFManifest::V3::DisplayContent.new(
|
102
|
+
def video_display_content(_url, label = '')
|
103
|
+
IIIFManifest::V3::DisplayContent.new(Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(solr_document.id, label: label, host: request.base_url),
|
89
104
|
label: label,
|
90
105
|
width: Array(solr_document.width).first.try(:to_i),
|
91
106
|
height: Array(solr_document.height).first.try(:to_i),
|
92
107
|
duration: Array(solr_document.duration).first.try(:to_i) / 1000.0,
|
93
|
-
type: 'Video'
|
108
|
+
type: 'Video',
|
109
|
+
format: solr_document.mime_type,
|
110
|
+
auth_service: auth_service)
|
94
111
|
end
|
95
112
|
|
96
113
|
def audio_content
|
@@ -102,11 +119,13 @@ module Hyrax
|
|
102
119
|
end
|
103
120
|
end
|
104
121
|
|
105
|
-
def audio_display_content(
|
106
|
-
IIIFManifest::V3::DisplayContent.new(
|
122
|
+
def audio_display_content(_url, label = '')
|
123
|
+
IIIFManifest::V3::DisplayContent.new(Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(solr_document.id, label: label, host: request.base_url),
|
107
124
|
label: label,
|
108
125
|
duration: Array(solr_document.duration).first.try(:to_i) / 1000.0,
|
109
|
-
type: 'Sound'
|
126
|
+
type: 'Sound',
|
127
|
+
format: solr_document.mime_type,
|
128
|
+
auth_service: auth_service)
|
110
129
|
end
|
111
130
|
|
112
131
|
def download_path(extension)
|
@@ -128,6 +147,34 @@ module Hyrax
|
|
128
147
|
end
|
129
148
|
streams
|
130
149
|
end
|
150
|
+
|
151
|
+
def auth_service
|
152
|
+
{
|
153
|
+
"context": "http://iiif.io/api/auth/1/context.json",
|
154
|
+
"@id": Rails.application.routes.url_helpers.new_user_session_url(host: request.base_url, iiif_auth_login: true),
|
155
|
+
"@type": "AuthCookieService1",
|
156
|
+
"confirmLabel": I18n.t('iiif_av.auth.confirmLabel'),
|
157
|
+
"description": I18n.t('iiif_av.auth.description'),
|
158
|
+
"failureDescription": I18n.t('iiif_av.auth.failureDescription'),
|
159
|
+
"failureHeader": I18n.t('iiif_av.auth.failureHeader'),
|
160
|
+
"header": I18n.t('iiif_av.auth.header'),
|
161
|
+
"label": I18n.t('iiif_av.auth.label'),
|
162
|
+
"profile": "http://iiif.io/api/auth/1/login",
|
163
|
+
"service": [
|
164
|
+
{
|
165
|
+
"@id": Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_auth_token_url(id: id, host: request.base_url),
|
166
|
+
"@type": "AuthTokenService1",
|
167
|
+
"profile": "http://iiif.io/api/auth/1/token"
|
168
|
+
},
|
169
|
+
{
|
170
|
+
"@id": Rails.application.routes.url_helpers.destroy_user_session_url(host: request.base_url),
|
171
|
+
"@type": "AuthLogoutService1",
|
172
|
+
"label": I18n.t('iiif_av.auth.logoutLabel'),
|
173
|
+
"profile": "http://iiif.io/api/auth/1/logout"
|
174
|
+
}
|
175
|
+
]
|
176
|
+
}
|
177
|
+
end
|
131
178
|
end
|
132
179
|
end
|
133
180
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
en:
|
2
|
+
iiif_av:
|
3
|
+
auth:
|
4
|
+
confirmLabel: "Login"
|
5
|
+
description: "You must log in to view this content."
|
6
|
+
failureDescription: "<a href=\"http://example.org/policy\">Access Policy</a>"
|
7
|
+
failureHeader: "Authentication Failed"
|
8
|
+
header: "Please Log In"
|
9
|
+
label: "Login Required"
|
10
|
+
logoutLabel: "Log out"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
Hyrax::IiifAv::Engine.routes.draw do
|
3
|
+
get '/iiif_av/content/:id/:label', to: 'iiif_av#content', as: :iiif_av_content
|
4
|
+
get '/iiif_av/auth_token/:id', to: 'iiif_av#auth_token', as: :iiif_av_auth_token
|
5
|
+
get '/iiif_av/sign_in', to: 'iiif_av#sign_in', as: :iiif_av_sign_in
|
6
|
+
end
|
data/hyrax-iiif_av.gemspec
CHANGED
@@ -16,18 +16,19 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.license = 'Apache-2.0'
|
17
17
|
|
18
18
|
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
-
f.match(%r{^(test|spec|features)/})
|
19
|
+
f.match(%r{^(test|spec|features)/}) || f == 'bin/rails'
|
20
20
|
end
|
21
21
|
|
22
|
-
s.add_dependency "rails", "
|
22
|
+
s.add_dependency "rails", ">= 5.1", "< 8.0"
|
23
23
|
s.add_dependency "blacklight"
|
24
|
-
s.add_dependency "hyrax", "
|
25
|
-
s.add_dependency "iiif_manifest", "
|
24
|
+
s.add_dependency "hyrax", ">= 3.5", "< 6.0"
|
25
|
+
s.add_dependency "iiif_manifest", "> 0.5"
|
26
26
|
|
27
27
|
s.add_development_dependency 'bixby'
|
28
28
|
s.add_development_dependency 'coffee-rails'
|
29
|
-
s.add_development_dependency 'engine_cart', '~> 2.
|
30
|
-
s.add_development_dependency '
|
29
|
+
s.add_development_dependency 'engine_cart', '~> 2.2'
|
30
|
+
s.add_development_dependency 'factory_bot'
|
31
31
|
s.add_development_dependency 'rails-controller-testing'
|
32
32
|
s.add_development_dependency 'rspec-rails', '~> 3.8'
|
33
|
+
s.add_development_dependency 'rspec_junit_formatter'
|
33
34
|
end
|
@@ -6,7 +6,38 @@ module Hyrax
|
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
|
-
|
9
|
+
def install_rack_cors
|
10
|
+
gem 'rack-cors'
|
11
|
+
Bundler.with_clean_env do
|
12
|
+
run "bundle install"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def enable_cors
|
17
|
+
insert_into_file 'config/application.rb', after: 'class Application < Rails::Application' do
|
18
|
+
"\n" \
|
19
|
+
" require 'rack/cors'\n" \
|
20
|
+
" config.middleware.insert_before 0, Rack::Cors do\n" \
|
21
|
+
" allow do\n" \
|
22
|
+
" origins '*'\n" \
|
23
|
+
" resource '/concern/*/*/manifest*', headers: :any, methods: [:head, :get]\n" \
|
24
|
+
" resource '/iiif_av/*', headers: :any, methods: [:head, :get], expose: ['Content-Security-Policy']\n" \
|
25
|
+
" resource '/downloads/*', headers: :any, methods: [:head, :get]\n" \
|
26
|
+
" end\n" \
|
27
|
+
" end\n" \
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def mount_routes
|
32
|
+
route "mount Hyrax::IiifAv::Engine, at: '/'"
|
33
|
+
end
|
34
|
+
|
35
|
+
def override_devise_redirect_path
|
36
|
+
insert_into_file 'app/controllers/application_controller.rb', after: 'include Hyrax::Controller' do
|
37
|
+
"\n" \
|
38
|
+
" include Hyrax::IiifAv::AuthControllerBehavior"
|
39
|
+
end
|
40
|
+
end
|
10
41
|
end
|
11
42
|
end
|
12
43
|
end
|
@@ -16,6 +16,15 @@ module Hyrax
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
attr_writer :iiif_av_url_builder
|
19
|
+
|
20
|
+
# A symbol that represents the viewer to render for AV items.
|
21
|
+
# Defaults to :avalon. Known to work with :universal_viewer as well
|
22
|
+
|
23
|
+
# @return [:symbol] viewer partial name
|
24
|
+
def iiif_av_viewer
|
25
|
+
@iiif_av_viewer ||= :avalon
|
26
|
+
end
|
27
|
+
attr_writer :iiif_av_viewer
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
@@ -30,7 +30,7 @@ RSpec.shared_examples "IiifAv::ControllerBehavior" do
|
|
30
30
|
let(:manifest_factory3) { instance_double("IIIFManifest::V3::ManifestBuilder", to_h: { test: 'manifest3' }) }
|
31
31
|
|
32
32
|
before do
|
33
|
-
allow(controller).to receive(:
|
33
|
+
allow(controller).to receive(:iiif_manifest_presenter).and_return(presenter)
|
34
34
|
allow(IIIFManifest::ManifestFactory).to receive(:new).with(presenter).and_return(manifest_factory2)
|
35
35
|
allow(IIIFManifest::V3::ManifestFactory).to receive(:new).with(presenter).and_return(manifest_factory3)
|
36
36
|
request.headers['Accept'] = mime
|
@@ -15,6 +15,7 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
15
15
|
allow(ability).to receive(:can?).with(:read, solr_document.id).and_return(read_permission)
|
16
16
|
allow(presenter).to receive(:parent).and_return(parent_presenter)
|
17
17
|
allow(presenter).to receive(:title).and_return(title)
|
18
|
+
allow(presenter).to receive(:latest_file_id).and_return(id)
|
18
19
|
end
|
19
20
|
|
20
21
|
describe '#display_content' do
|
@@ -40,9 +41,9 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
context "when the file is a sound recording" do
|
43
|
-
let(:solr_document) { SolrDocument.new(id: '12345', duration_tesim: 1000) }
|
44
|
-
let(:mp3_url) { "http://test.host/
|
45
|
-
let(:ogg_url) { "http://test.host/
|
44
|
+
let(:solr_document) { SolrDocument.new(id: '12345', duration_tesim: 1000, mime_type_ssi: 'audio/mp3') }
|
45
|
+
let(:mp3_url) { "http://test.host/iiif_av/content/#{solr_document.id}/mp3" }
|
46
|
+
let(:ogg_url) { "http://test.host/iiif_av/content/#{solr_document.id}/ogg" }
|
46
47
|
|
47
48
|
before do
|
48
49
|
allow(solr_document).to receive(:audio?).and_return(true)
|
@@ -52,6 +53,7 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
52
53
|
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
53
54
|
expect(content.length).to eq 2
|
54
55
|
expect(content.map(&:type)).to all(eq 'Sound')
|
56
|
+
expect(content.map(&:format)).to all(eq 'audio/mp3')
|
55
57
|
expect(content.map(&:duration)).to all(eq 1.000)
|
56
58
|
expect(content.map(&:label)).to match_array(['mp3', 'ogg'])
|
57
59
|
expect(content.map(&:url)).to match_array([mp3_url, ogg_url])
|
@@ -59,9 +61,9 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
59
61
|
end
|
60
62
|
|
61
63
|
context "when the file is a video" do
|
62
|
-
let(:solr_document) { SolrDocument.new(id: '12345', width_is: 640, height_is: 480, duration_tesim: 1000) }
|
63
|
-
let(:mp4_url) { "http://test.host/
|
64
|
-
let(:webm_url) { "http://test.host/
|
64
|
+
let(:solr_document) { SolrDocument.new(id: '12345', width_is: 640, height_is: 480, duration_tesim: 1000, mime_type_ssi: 'video/mp4') }
|
65
|
+
let(:mp4_url) { "http://test.host/iiif_av/content/#{id}/mp4" }
|
66
|
+
let(:webm_url) { "http://test.host/iiif_av/content/#{id}/webm" }
|
65
67
|
|
66
68
|
before do
|
67
69
|
allow(solr_document).to receive(:video?).and_return(true)
|
@@ -71,6 +73,7 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
71
73
|
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
72
74
|
expect(content.length).to eq 2
|
73
75
|
expect(content.map(&:type)).to all(eq 'Video')
|
76
|
+
expect(content.map(&:format)).to all(eq 'video/mp4')
|
74
77
|
expect(content.map(&:width)).to all(eq 640)
|
75
78
|
expect(content.map(&:height)).to all(eq 480)
|
76
79
|
expect(content.map(&:duration)).to all(eq 1.000)
|
@@ -83,11 +86,11 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
83
86
|
let(:file_set_id) { 'abcdefg' }
|
84
87
|
let(:derivatives_metadata) do
|
85
88
|
[
|
86
|
-
{ id: '1', label: 'high', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, '
|
87
|
-
{ id: '2', label: 'medium', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, '
|
89
|
+
{ id: '1', label: 'high', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, 'high.mp3') },
|
90
|
+
{ id: '2', label: 'medium', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, 'medium.mp3') }
|
88
91
|
]
|
89
92
|
end
|
90
|
-
let(:solr_document) { SolrDocument.new(id:
|
93
|
+
let(:solr_document) { SolrDocument.new(id: file_set_id, duration_tesim: 1000, derivatives_metadata_ssi: derivatives_metadata.to_json) }
|
91
94
|
|
92
95
|
before do
|
93
96
|
allow(solr_document).to receive(:audio?).and_return(true)
|
@@ -97,29 +100,8 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
97
100
|
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
98
101
|
expect(content.length).to eq 2
|
99
102
|
expect(content.map(&:label)).to match_array(['high', 'medium'])
|
100
|
-
expect(content.map(&:url)).to match_array([Hyrax::Engine.routes.url_helpers.
|
101
|
-
Hyrax::Engine.routes.url_helpers.
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'with custom av url builder' do
|
105
|
-
let(:custom_builder) do
|
106
|
-
->(file_location_uri, _base_url) { "http://streaming.example.com/stream/#{File.basename(file_location_uri)}" }
|
107
|
-
end
|
108
|
-
|
109
|
-
around do |example|
|
110
|
-
default_builder = Hyrax::IiifAv.config.iiif_av_url_builder
|
111
|
-
Hyrax::IiifAv.config.iiif_av_url_builder = custom_builder
|
112
|
-
example.run
|
113
|
-
Hyrax::IiifAv.config.iiif_av_url_builder = default_builder
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'creates an array of content objects with metadata' do
|
117
|
-
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
118
|
-
expect(content.length).to eq 2
|
119
|
-
expect(content.map(&:label)).to match_array(['high', 'medium'])
|
120
|
-
expect(content.map(&:url)).to match_array(['http://streaming.example.com/stream/g-high.mp3.high.mp3',
|
121
|
-
'http://streaming.example.com/stream/g-medium.mp3.medium.mp3'])
|
122
|
-
end
|
103
|
+
expect(content.map(&:url)).to match_array([Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(file_set_id, label: 'high', host: request.base_url),
|
104
|
+
Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_content_url(file_set_id, label: 'medium', host: request.base_url)])
|
123
105
|
end
|
124
106
|
end
|
125
107
|
|
@@ -151,7 +133,7 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
151
133
|
|
152
134
|
context 'with custom image url builder' do
|
153
135
|
let(:custom_builder) do
|
154
|
-
->(file_id, base_url, _size) { "#{base_url}/downloads/#{file_id.split('/').first}" }
|
136
|
+
->(file_id, base_url, _size, _format) { "#{base_url}/downloads/#{file_id.split('/').first}" }
|
155
137
|
end
|
156
138
|
|
157
139
|
around do |example|
|
@@ -184,6 +166,29 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
184
166
|
end
|
185
167
|
end
|
186
168
|
end
|
169
|
+
|
170
|
+
context 'auth_service' do
|
171
|
+
let(:solr_document) { SolrDocument.new(id: '12345', duration_tesim: 1000) }
|
172
|
+
let(:auth_service) { content.first.auth_service }
|
173
|
+
|
174
|
+
before do
|
175
|
+
allow(solr_document).to receive(:audio?).and_return(true)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'provides a cookie auth service' do
|
179
|
+
expect(auth_service[:@id]).to eq Rails.application.routes.url_helpers.new_user_session_url(host: request.base_url, iiif_auth_login: true)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'provides a token service' do
|
183
|
+
token_service = auth_service[:service].find { |s| s[:@type] == "AuthTokenService1" }
|
184
|
+
expect(token_service[:@id]).to eq Hyrax::IiifAv::Engine.routes.url_helpers.iiif_av_auth_token_url(id: solr_document.id, host: request.base_url)
|
185
|
+
end
|
186
|
+
|
187
|
+
it 'provides a logout service' do
|
188
|
+
logout_service = auth_service[:service].find { |s| s[:@type] == "AuthLogoutService1" }
|
189
|
+
expect(logout_service[:@id]).to eq Rails.application.routes.url_helpers.destroy_user_session_url(host: request.base_url)
|
190
|
+
end
|
191
|
+
end
|
187
192
|
end
|
188
193
|
end
|
189
194
|
end
|
metadata
CHANGED
@@ -1,32 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrax-iiif_av
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Colvard
|
8
8
|
- Brian Keese
|
9
9
|
- Ying Feng
|
10
10
|
- Phuong Dinh
|
11
|
-
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rails
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
18
|
requirements:
|
20
|
-
- - "
|
19
|
+
- - ">="
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: '5.1'
|
22
|
+
- - "<"
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '8.0'
|
23
25
|
type: :runtime
|
24
26
|
prerelease: false
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
26
28
|
requirements:
|
27
|
-
- - "
|
29
|
+
- - ">="
|
28
30
|
- !ruby/object:Gem::Version
|
29
31
|
version: '5.1'
|
32
|
+
- - "<"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '8.0'
|
30
35
|
- !ruby/object:Gem::Dependency
|
31
36
|
name: blacklight
|
32
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,28 +50,34 @@ dependencies:
|
|
45
50
|
name: hyrax
|
46
51
|
requirement: !ruby/object:Gem::Requirement
|
47
52
|
requirements:
|
48
|
-
- - "
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '3.5'
|
56
|
+
- - "<"
|
49
57
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
58
|
+
version: '6.0'
|
51
59
|
type: :runtime
|
52
60
|
prerelease: false
|
53
61
|
version_requirements: !ruby/object:Gem::Requirement
|
54
62
|
requirements:
|
55
|
-
- - "
|
63
|
+
- - ">="
|
56
64
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
65
|
+
version: '3.5'
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '6.0'
|
58
69
|
- !ruby/object:Gem::Dependency
|
59
70
|
name: iiif_manifest
|
60
71
|
requirement: !ruby/object:Gem::Requirement
|
61
72
|
requirements:
|
62
|
-
- - "
|
73
|
+
- - ">"
|
63
74
|
- !ruby/object:Gem::Version
|
64
75
|
version: '0.5'
|
65
76
|
type: :runtime
|
66
77
|
prerelease: false
|
67
78
|
version_requirements: !ruby/object:Gem::Requirement
|
68
79
|
requirements:
|
69
|
-
- - "
|
80
|
+
- - ">"
|
70
81
|
- !ruby/object:Gem::Version
|
71
82
|
version: '0.5'
|
72
83
|
- !ruby/object:Gem::Dependency
|
@@ -103,16 +114,16 @@ dependencies:
|
|
103
114
|
requirements:
|
104
115
|
- - "~>"
|
105
116
|
- !ruby/object:Gem::Version
|
106
|
-
version: '2.
|
117
|
+
version: '2.2'
|
107
118
|
type: :development
|
108
119
|
prerelease: false
|
109
120
|
version_requirements: !ruby/object:Gem::Requirement
|
110
121
|
requirements:
|
111
122
|
- - "~>"
|
112
123
|
- !ruby/object:Gem::Version
|
113
|
-
version: '2.
|
124
|
+
version: '2.2'
|
114
125
|
- !ruby/object:Gem::Dependency
|
115
|
-
name:
|
126
|
+
name: factory_bot
|
116
127
|
requirement: !ruby/object:Gem::Requirement
|
117
128
|
requirements:
|
118
129
|
- - ">="
|
@@ -153,6 +164,20 @@ dependencies:
|
|
153
164
|
- - "~>"
|
154
165
|
- !ruby/object:Gem::Version
|
155
166
|
version: '3.8'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec_junit_formatter
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
156
181
|
description: Hyrax plugin for IIIF Presentation 3.0 audiovisual support
|
157
182
|
email:
|
158
183
|
- cjcolvar@indiana.edu
|
@@ -163,20 +188,26 @@ executables: []
|
|
163
188
|
extensions: []
|
164
189
|
extra_rdoc_files: []
|
165
190
|
files:
|
191
|
+
- ".circleci/config.yml"
|
192
|
+
- ".github/workflows/release.yml"
|
166
193
|
- ".gitignore"
|
167
194
|
- ".rspec"
|
168
195
|
- ".rubocop.yml"
|
169
196
|
- ".travis.yml"
|
197
|
+
- CONTRIBUTING.md
|
170
198
|
- Gemfile
|
171
199
|
- LICENSE
|
172
200
|
- README.md
|
173
201
|
- Rakefile
|
202
|
+
- app/controllers/concerns/hyrax/iiif_av/auth_controller_behavior.rb
|
174
203
|
- app/controllers/concerns/hyrax/iiif_av/controller_behavior.rb
|
204
|
+
- app/controllers/hyrax/iiif_av/iiif_av_controller.rb
|
175
205
|
- app/models/hyrax/iiif_av/manifest_range.rb
|
176
206
|
- app/presenters/concerns/hyrax/iiif_av/displays_content.rb
|
177
207
|
- app/presenters/concerns/hyrax/iiif_av/displays_iiif_av.rb
|
178
208
|
- app/presenters/hyrax/iiif_av/iiif_file_set_presenter.rb
|
179
|
-
-
|
209
|
+
- config/locales/en.yml
|
210
|
+
- config/routes.rb
|
180
211
|
- hyrax-iiif_av.gemspec
|
181
212
|
- lib/generators/hyrax/iiif_av/add_to_work_type_generator.rb
|
182
213
|
- lib/generators/hyrax/iiif_av/install_avalon_player_generator.rb
|
@@ -192,11 +223,9 @@ files:
|
|
192
223
|
- lib/hyrax/iiif_av/spec/shared_specs/displays_iiif_av.rb
|
193
224
|
- lib/hyrax/iiif_av/version.rb
|
194
225
|
- lib/tasks/hyrax/iiif_av_tasks.rake
|
195
|
-
homepage:
|
196
226
|
licenses:
|
197
227
|
- Apache-2.0
|
198
228
|
metadata: {}
|
199
|
-
post_install_message:
|
200
229
|
rdoc_options: []
|
201
230
|
require_paths:
|
202
231
|
- lib
|
@@ -211,9 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
240
|
- !ruby/object:Gem::Version
|
212
241
|
version: '0'
|
213
242
|
requirements: []
|
214
|
-
|
215
|
-
rubygems_version: 2.6.14
|
216
|
-
signing_key:
|
243
|
+
rubygems_version: 3.6.9
|
217
244
|
specification_version: 4
|
218
245
|
summary: Hyrax plugin for IIIF Presentation 3.0 audiovisual support
|
219
246
|
test_files: []
|
data/bin/rails
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
# This command will automatically be run when you run "rails" with Rails gems
|
4
|
-
# installed from the root of your application.
|
5
|
-
|
6
|
-
ENGINE_ROOT = File.expand_path('..', __dir__)
|
7
|
-
ENGINE_PATH = File.expand_path('../lib/hyrax/iiif_av/engine', __dir__)
|
8
|
-
# APP_PATH = File.expand_path('../.internal_test_app/config/application', __dir__)
|
9
|
-
|
10
|
-
# Set up gems listed in the Gemfile.
|
11
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
12
|
-
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
13
|
-
|
14
|
-
require 'rails/all'
|
15
|
-
require 'rails/engine/commands'
|