diff --git a/Gemfile b/Gemfile index 3f2a6250..16945081 100644 --- a/Gemfile +++ b/Gemfile @@ -2,13 +2,16 @@ source 'https://rubygems.org' +# needed for Jekyll +gem 'jekyll' +gem 'webrick', '~> 1.7' + +# needed for Rake tasks +gem 'rake' +gem 'csv' +gem 'fileutils' +gem 'mini_magick' unless Gem.win_platform? gem 'image_optim' gem 'image_optim_pack' end -gem 'csv' -gem 'jekyll' -gem 'mini_magick' -gem 'rake' - -gem 'webrick', '~> 1.7' diff --git a/Rakefile b/Rakefile index 49da0212..c9e15a58 100644 --- a/Rakefile +++ b/Rakefile @@ -1,21 +1,16 @@ # frozen_string_literal: true -# CollectionBuilder-CSV helper tasks - -require 'csv' -require 'fileutils' -require 'image_optim' unless Gem.win_platform? -require 'mini_magick' - ############################################################################### -# TASK: deploy +# +# CollectionBuilder Rake Utilities +# +# See "docs/rake_tasks/" for documentation. +# See "rakelib" for individual rake tasks! +# ############################################################################### -desc 'Build site with production env' -task :deploy do - ENV['JEKYLL_ENV'] = 'production' - system('bundle', 'exec', 'jekyll', 'build') -end +require 'csv' +require 'fileutils' ############################################################################### # Helper Functions @@ -36,128 +31,3 @@ def prompt_user_for_confirmation(message) end response end - -def process_and_optimize_image(filename, file_type, output_filename, size, density) - image_optim = ImageOptim.new(svgo: false) unless Gem.win_platform? - if filename == output_filename && file_type == :image && !Gem.win_platform? - puts "Optimizing: #{filename}" - begin - image_optim.optimize_image!(output_filename) - rescue StandardError => e - puts "Error optimizing #{filename}: #{e.message}" - end - elsif filename == output_filename && file_type == :pdf - puts "Skipping: #{filename}" - else - puts "Creating: #{output_filename}" - begin - if file_type == :pdf - inputfile = "#{filename}[0]" - magick = MiniMagick::Tool::Convert.new - magick.density(density) - magick << inputfile - magick.resize(size) - magick.flatten - magick << output_filename - magick.call - else - image = MiniMagick::Image.open(filename) - image.format('jpg') - image.resize(size) - image.flatten - image.write(output_filename) - end - image_optim.optimize_image!(output_filename) unless Gem.win_platform? - rescue StandardError => e - puts "Error creating #{filename}: #{e.message}" - end - end -end - -############################################################################### -# TASK: generate_derivatives -############################################################################### - -desc 'Generate derivative image files from collection objects' -task :generate_derivatives, [:thumbs_size, :small_size, :density, :missing, :compress_originals] do |_t, args| - # set default arguments - # default image size is based on max pixel width they will appear in the base template features - args.with_defaults( - thumbs_size: '450x', - small_size: '800x800', - density: '300', - missing: 'true', - compress_originals: 'false' - ) - - # set the folder locations - objects_dir = 'objects' - thumb_image_dir = 'objects/thumbs' - small_image_dir = 'objects/small' - - # Ensure that the output directories exist. - [thumb_image_dir, small_image_dir].each do |dir| - FileUtils.mkdir_p(dir) unless Dir.exist?(dir) - end - - # support these file types - EXTNAME_TYPE_MAP = { - '.jpeg' => :image, - '.jpg' => :image, - '.pdf' => :pdf, - '.png' => :image, - '.tif' => :image, - '.tiff' => :image - }.freeze - - # CSV output - list_name = File.join(objects_dir, 'object_list.csv') - field_names = 'filename,object_location,image_small,image_thumb'.split(',') - CSV.open(list_name, 'w') do |csv| - csv << field_names - - # Iterate over all files in the objects directory. - Dir.glob(File.join(objects_dir, '*')).each do |filename| - # Skip subdirectories and the README.md file. - if File.directory?(filename) || File.basename(filename) == 'README.md' || File.basename(filename) == 'object_list.csv' - next - end - - # Determine the file type and skip if unsupported. - extname = File.extname(filename).downcase - file_type = EXTNAME_TYPE_MAP[extname] - unless file_type - puts "Skipping file with unsupported extension: #{filename}" - csv << ["#{File.basename(filename)}", "/#{filename}", nil, nil] - next - end - - # Get the lowercase filename without any leading path and extension. - base_filename = File.basename(filename, '.*').downcase - - # Optimize the original image. - if args.compress_originals == 'true' - puts "Optimizing: #{filename}" - process_and_optimize_image(filename, file_type, filename, nil, nil) - end - - # Generate the thumb image. - thumb_filename = File.join(thumb_image_dir, "#{base_filename}_th.jpg") - if args.missing == 'false' || !File.exist?(thumb_filename) - process_and_optimize_image(filename, file_type, thumb_filename, args.thumbs_size, args.density) - else - puts "Skipping: #{thumb_filename} already exists" - end - - # Generate the small image. - small_filename = File.join([small_image_dir, "#{base_filename}_sm.jpg"]) - if (args.missing == 'false') || !File.exist?(small_filename) - process_and_optimize_image(filename, file_type, small_filename, args.small_size, args.density) - else - puts "Skipping: #{small_filename} already exists" - end - csv << ["#{File.basename(filename)}", "/#{filename}", "/#{small_filename}", "/#{thumb_filename}"] - end - end - puts "\e[32mSee '#{list_name}' for list of objects and derivatives created.\e[0m" -end diff --git a/_config.yml b/_config.yml index 2b455864..ce02d957 100644 --- a/_config.yml +++ b/_config.yml @@ -25,7 +25,7 @@ tagline: Prototype for working with Oral History as Data items in CollectionBuil # this description might appear in search result lists, keep around 160 characters max description: "CB-OHD is a mix of CollectionBuilder-CSV and Oral History as Data (OHD)." # if you want a different description to appear in the footer only, define it here, or leave blank to use description -footer_description: "cb-oralhistory rocks!" +# footer_description: "cb-oralhistory rocks!" # keywords, a short list of subjects describing the collection, separated by semicolon, to appear in rich markup keywords: oral histories;digital collections # creator of the digital collection, to appear in meta tags; we typically use our GitHub usernames but feel free to just use your name @@ -80,7 +80,7 @@ organization-logo-nav: https://cdil.lib.uidaho.edu/assets/img/logo.png # (this is done automatically by gh-pages build) # # ignore stuff -exclude: [docs/, Rakefile, README.md, LICENSE, CITATION.cff, CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md] +exclude: [docs/, Rakefile, rakelib/, README.md, LICENSE, CITATION.cff, CODE_OF_CONDUCT.md, CONTRIBUTING.md, SECURITY.md] # compress CSS output sass: style: compressed diff --git a/_data/demo-compoundobjects-metadata.csv b/_data/demo-compoundobjects-metadata.csv index 8b8faabc..6867177c 100644 --- a/_data/demo-compoundobjects-metadata.csv +++ b/_data/demo-compoundobjects-metadata.csv @@ -36,7 +36,7 @@ demo_014,demo_013,Peeled Tree View 1,,,,,,,,,,,Image;StillImage,image/jpeg,,,,im demo_015,demo_013,Peeled Tree View 2,,,,,,,,,,,Image;StillImage,image/jpeg,,,,image,https://webpages.uidaho.edu/Library/twrs/objects/DSC_0137.JPG,https://webpages.uidaho.edu/Library/twrs/objects/small/dsc_0137_sm.jpg,https://webpages.uidaho.edu/Library/twrs/objects/thumbs/dsc_0137_th.jpg,log cross section showing where tree bark was peeled, demo_016,demo_013,Peeled Tree View 3,,,,,,,,,,,Image;StillImage,image/jpeg,,,,image,https://webpages.uidaho.edu/Library/twrs/objects/DSC_0138.JPG,https://webpages.uidaho.edu/Library/twrs/objects/small/dsc_0138_sm.jpg,https://webpages.uidaho.edu/Library/twrs/objects/thumbs/dsc_0138_th.jpg,log cross section showing where tree bark was peeled, demo_017,,Hell's Half Acre Lookout 360 Image,Keeping Watch,2021-07-13,,Example panorama. 360 Image of the Interior of Hell's Half Acre Fire Tower,,Hell's Half Acre,45.64579,-114.62838,,,Image;StillImage,image/jpeg,eng,,,panorama,/objects/hells_half_theta.jpg,https://cdil.lib.uidaho.edu/keeping-watch/objects/small/hells_half_theta_sm.jpg,https://cdil.lib.uidaho.edu/keeping-watch/objects/thumbs/hells_half_theta_th.jpg,interior of a fire lookout tower with map in center and windows in all directions, -demo_018,,"Spokane's Great Restaurant, Washington","Mitchell, Edward H.",1909,,"Example postcard using display template 'multiple.' Postcard is of the Davenport Hotel's Restaurant in Spokane, Washington.",restaurants; automobiles; buildings; picture postcards; flagpoles; flags,"Spokane, WA",47.65710758,-117.4249084,"PG 9, Postcard Collection, University of Idaho Library Special Collections and Archives, http://www.lib.uidaho.edu/special-collections/",Postcard_038,record,postcard,eng,"Educational use includes non-commercial use of text and images in materials for teaching and research purposes. Digital reproduction rights granted by University of Idaho Library. For other uses beyond educational use, please contact University of Idaho Library Special Collections and Archives Department at libspec@uidaho.edu.",http://rightsstatements.org/vocab/InC-EDU/1.0/,multiple,,/objects/small/210a_sm.jpg,/objects/thumbs/210a_th.jpg,historic colorized postcard depicting a fancy multi-story white building with several early cars parked in front, +demo_018,,"Spokane's Great Restaurant, Washington","Mitchell, Edward H.",1909,,"Example postcard using display template 'multiple.' Postcard is of the Davenport Hotel's Restaurant in Spokane, Washington.",restaurants; automobiles; buildings; picture postcards; flagpoles; flags,"Spokane, WA",47.65710758,-117.4249084,"PG 9, Postcard Collection, University of Idaho Library Special Collections and Archives, http://www.lib.uidaho.edu/special-collections/",Postcard_038,record,multiple,eng,"Educational use includes non-commercial use of text and images in materials for teaching and research purposes. Digital reproduction rights granted by University of Idaho Library. For other uses beyond educational use, please contact University of Idaho Library Special Collections and Archives Department at libspec@uidaho.edu.",http://rightsstatements.org/vocab/InC-EDU/1.0/,multiple,,/objects/small/210a_sm.jpg,/objects/thumbs/210a_th.jpg,historic colorized postcard depicting a fancy multi-story white building with several early cars parked in front, demo_019,demo_018,postcard front,,,,,,,,,,210a,Image;StillImage,image/jpeg,,,,image,/objects/210a.jpg,/objects/small/210a_sm.jpg,/objects/thumbs/210a_th.jpg,historic colorized postcard depicting a fancy multi-story white building with several early cars parked in front, demo_020,demo_018,postcard back,,,,,,,,,,210b,Image;StillImage,image/jpeg,,,,image,/objects/210b.jpg,/objects/small/210b_sm.jpg,/objects/thumbs/210b_th.jpg,"back of historic postcard dated Sept 5, 1909 with very difficult to read cursive writing in pencil", demo_021,,"Jennie Eva Hughes, the First Black Graduate of the University of Idaho",,1899,yes,"Example compound object. Items from the Black History at University of Idaho that feature Jennie Eva Hughes, the first black graduate of the University of Idaho",Jennie Eva Hughes; Black History; University of Idaho,"Moscow, ID",46.725562,-117.009633,Black History at the University of Idaho Digital Collection,,record,compound_object,eng,,,compound_object,,https://www.lib.uidaho.edu/blackhistory/objects/small/ma2000_29_001_sm.jpg,https://www.lib.uidaho.edu/blackhistory/objects/thumbs/ma2000_29_001_th.jpg,"University of Idaho enrollment form filled in with handwritten cursive script saying ""Jennie Eva Hughes, Sept 23, 1898""", diff --git a/_data/theme.yml b/_data/theme.yml index 5c6ec22b..d13fb8dc 100644 --- a/_data/theme.yml +++ b/_data/theme.yml @@ -72,7 +72,6 @@ metadata-facets-fields: "subject,interviewer,format" map-child-objects: true # true / false - if true, and if child item has latitude and longitude, child objects will be displayed on map timeline-child-objects: true # true / false - if true, and if child object has date, child objects will appear as thumbnails on timeline page data-child-objects: false # true / false - if true, child objects will appear linked in table on data page -carousel-child-objects: false # true / false - if true, child objects will appear on homepage carousel browse-child-objects: false # true / false - if true, child objects will appear on browse page and child objects' metadata will populate cloud pages like Subjects page and Locations page, as well as featured terms boxes on the home page search-child-objects: true # true / false - if true, child objects will appear on on search page along with parent objects diff --git a/_includes/collection-nav.html b/_includes/collection-nav.html index 1b386864..21853bc7 100644 --- a/_includes/collection-nav.html +++ b/_includes/collection-nav.html @@ -12,7 +12,7 @@