-
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.
This brings a 1140 page manifest from 11 seconds to 2.6 seconds to generate.
- Loading branch information
1 parent
0e21483
commit 1545262
Showing
6 changed files
with
191 additions
and
27 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
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,124 @@ | ||
# frozen_string_literal: true | ||
class ManifestBuilder | ||
class Service | ||
attr_reader :inner_hash | ||
def initialize | ||
@inner_hash = initial_attributes | ||
end | ||
|
||
delegate :[]=, :[], :as_json, :to_json, to: :inner_hash | ||
|
||
def initial_attributes | ||
{} | ||
end | ||
end | ||
|
||
class FasterIIIFManifest < Service | ||
def label=(label) | ||
inner_hash["label"] = label | ||
end | ||
|
||
def description=(description) | ||
inner_hash["description"] = description | ||
end | ||
|
||
def viewing_hint=(viewing_hint) | ||
inner_hash["viewingHint"] = viewing_hint | ||
end | ||
|
||
def sequences | ||
inner_hash["sequences"] || [] | ||
end | ||
|
||
def sequences=(sequences) | ||
inner_hash["sequences"] = sequences | ||
end | ||
|
||
def metadata=(metadata) | ||
inner_hash["metadata"] = metadata | ||
end | ||
|
||
def see_also=(see_also) | ||
inner_hash["seeAlso"] = see_also | ||
end | ||
|
||
def license=(license) | ||
inner_hash["license"] = license | ||
end | ||
|
||
def initial_attributes | ||
{ | ||
"@context" => "http://iiif.io/api/presentation/2/context.json", | ||
"@type" => "sc:Manifest" | ||
} | ||
end | ||
|
||
class Sequence < Service | ||
def canvases | ||
inner_hash["canvases"] || [] | ||
end | ||
|
||
def canvases=(canvases) | ||
inner_hash["canvases"] = canvases | ||
end | ||
|
||
def initial_attributes | ||
{ | ||
"@type" => "sc:Sequence" | ||
} | ||
end | ||
end | ||
|
||
class Canvas < Service | ||
def label=(label) | ||
inner_hash["label"] = label | ||
end | ||
|
||
def images | ||
inner_hash["images"] || [] | ||
end | ||
|
||
def images=(images) | ||
inner_hash["images"] = images | ||
end | ||
|
||
def initial_attributes | ||
{ | ||
"@type" => "sc:Canvas" | ||
} | ||
end | ||
end | ||
|
||
class Range < Service | ||
end | ||
|
||
class Resource < Service | ||
def service=(service) | ||
inner_hash['service'] = service | ||
end | ||
|
||
def initial_attributes | ||
{ | ||
"@type" => "sc:Range" | ||
} | ||
end | ||
end | ||
|
||
class Annotation < Service | ||
def resource=(resource) | ||
inner_hash["resource"] = resource | ||
end | ||
|
||
def resource | ||
inner_hash["resource"] | ||
end | ||
|
||
def initial_attributes | ||
{ | ||
"@type" => "oa:Annotation", | ||
"motivation" => "sc:painting" | ||
} | ||
end | ||
end | ||
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