Skip to content

Commit

Permalink
Merge pull request #60 from minicomp/default-variants-patch
Browse files Browse the repository at this point in the history
ensure default variants are added to metadata for theme use
  • Loading branch information
mnyrop authored Sep 10, 2020
2 parents 38a5b38 + ed58553 commit 3266ae5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/wax_tasks/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ module WaxTasks
class Asset
attr_reader :id, :path

DEFAULT_VARIANTS = { 'thumbnail' => 250, 'full' => 1140 }.freeze


def initialize(path, pid, variants)
@path = path
@pid = pid
@id = asset_id
@variants = DEFAULT_VARIANTS.merge variants
@variants = variants
end

#
Expand Down
10 changes: 9 additions & 1 deletion lib/wax_tasks/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Collection
include Collection::Images

IMAGE_DERIVATIVE_DIRECTORY = 'img/derivatives'
DEFAULT_VARIANTS = { 'thumbnail' => 250, 'fullwidth' => 1140 }.freeze

#
#
Expand All @@ -28,7 +29,14 @@ def initialize(name, config, source, collections_dir, ext)
@iiif_derivative_source = Utils.safe_join source, IMAGE_DERIVATIVE_DIRECTORY, 'iiif'
@simple_derivative_source = Utils.safe_join source, IMAGE_DERIVATIVE_DIRECTORY, 'simple'
@search_fields = %w[pid label thumbnail permalink collection]
@image_variants = @config.dig('images', 'variants') || {}
@image_variants = image_variants
end

#
#
def image_variants
vars = @config.dig('images', 'variants') || {}
DEFAULT_VARIANTS.merge vars
end

#
Expand Down
2 changes: 1 addition & 1 deletion lib/wax_tasks/collection/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def consolidate_records(original, new)
lost_record_pids.each do |pid|
new << original.find { |r| r.pid == pid }
end
new.sort_by(&:order)
new
end

#
Expand Down
6 changes: 5 additions & 1 deletion lib/wax_tasks/record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ def keys
@hash.keys
end

#
# PATCH :: rename 'fullwidth' to 'full' to
# (1) avoid breaking wax_iiif with special 'full' variant label
# (2) avoid breaking wax_theme which still expects 'full' to provide an image path
# this can be deprecated when a new version of wax_theme looks for another fullsize key
#
def set(key, value)
key = 'full' if key == 'fullwidth'
@hash[key] = value
end

Expand Down

0 comments on commit 3266ae5

Please sign in to comment.