Skip to content

Commit

Permalink
prune jekyll source dir from paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mnyrop committed Jul 21, 2023
1 parent dda8dc2 commit 5921f04
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/wax_tasks/collection/images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def write_simple_derivatives
next if File.exist? path

d.img.write path
item.record.set d.label, "/#{path}" if item.record?
item.record.set d.label, Utils.prune_dir("/#{path}", @site_source) if item.record?
end
bar.increment!
bar.write
Expand All @@ -69,7 +69,7 @@ def write_simple_derivatives
#
def iiif_builder(dir)
build_opts = {
base_url: "{{ '/' | absolute_url }}#{dir}",
base_url: "{{ '' | absolute_url }}#{Utils.prune_dir(dir, @site_source)}",
output_dir: dir,
collection_label: @name,
variants: @image_variants.dup.tap { |h| h.delete 'full' }
Expand All @@ -79,7 +79,7 @@ def iiif_builder(dir)

#
#
def add_font_matter_to_json_files(dir)
def add_front_matter_to_json_files(dir)
Dir.glob("#{dir}/**/*.json").each do |f|
Utils.add_yaml_front_matter_to_file f
end
Expand All @@ -97,10 +97,10 @@ def add_iiif_results_to_records(records, manifests)
json = JSON.parse manifest.to_json
@image_variants.each do |k, _v|
value = json.fetch k, ''
record.set k, "/#{Utils.content_clean(value)}" unless value.empty?
record.set k, "#{Utils.content_clean(value)}" unless value.empty?
end

record.set 'manifest', "/#{Utils.content_clean(manifest.id)}"
record.set 'manifest', "#{Utils.content_clean(manifest.id)}"
record
end.compact
end
Expand All @@ -115,10 +115,10 @@ def write_iiif_derivatives
builder.load iiif_data

puts Rainbow("Generating IIIF derivatives for collection '#{@name}'\nThis might take awhile.").cyan
builder.process_data
builder.process_data
records = items.map(&:record).compact

add_font_matter_to_json_files @iiif_derivative_source
add_front_matter_to_json_files @iiif_derivative_source
add_iiif_results_to_records records, builder.manifests
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/wax_tasks/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,9 @@ def self.add_yaml_front_matter_to_file(file)
f.puts filestring
end
end

def self.prune_dir(path, dir)
path.gsub(dir, '').gsub(/\/+/, '/')
end
end
end

0 comments on commit 5921f04

Please sign in to comment.