-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from pulibrary/issues-364-jrgriffiniii-epheme…
…ra-project-manifest Ensures that Ephemera Projects have IIIF Manifests
- Loading branch information
Showing
35 changed files
with
566 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,36 @@ | ||
# frozen_string_literal: true | ||
class EphemeraProjectChangeSet < Valkyrie::ChangeSet | ||
validates :title, presence: true | ||
validates :title, :slug, presence: true | ||
property :title, multiple: false | ||
property :member_ids, multiple: true, required: false, type: Types::Strict::Array.member(Valkyrie::Types::ID) | ||
property :slug, multiple: false, required: true | ||
validate :slug_unique? | ||
validate :slug_valid? | ||
|
||
def primary_terms | ||
[:title] | ||
[:title, :slug] | ||
end | ||
|
||
def slug_valid? | ||
return if Slug.new(Array.wrap(slug).first).valid? | ||
errors.add(:slug, 'contains invalid characters, please only use alphanumerics, dashes, and underscores') | ||
end | ||
|
||
def slug_unique? | ||
return unless slug_exists? | ||
errors.add(:slug, 'is already in use by another project') | ||
end | ||
|
||
private | ||
|
||
def metadata_adapter | ||
Valkyrie.config.metadata_adapter | ||
end | ||
delegate :query_service, to: :metadata_adapter | ||
|
||
def slug_exists? | ||
slug_value = Array.wrap(slug).first | ||
results = query_service.custom_queries.find_by_string_property(property: :slug, value: slug_value).to_a | ||
!results.empty? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# frozen_string_literal: true | ||
class IndexCollectionDecorator < Valkyrie::ResourceDecorator | ||
def iiif_manifest_attributes | ||
[] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# frozen_string_literal: true | ||
# Model for exposing IIIF Manifests for all Collection resources | ||
class IndexCollection | ||
# Decorates the object (as this is not a Valkyrie::Resource) | ||
# @return [IndexCollectionDecorator] an instance of the decorator | ||
def decorate | ||
IndexCollectionDecorator.new(self) | ||
end | ||
|
||
def logical_structure | ||
[] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.