tulibraries/dplah

Custom Prefix Will Fail If Token Does Not Have a Custom Prefix

Opened this issue · 1 comments

skng5 commented

This returns nil if the provider is not UPENN.

https://github.com/tulibraries/dplah/blob/develop/lib/thumbnail_utils.rb#L138-L149

The define_thumbnail_pattern method will throw an error because it changes the the token1 string to nil.

if !provider.thumbnail_token_1.blank?
token_1 = obj.send(provider.thumbnail_token_1).find {|i| i.exclude?("http")}
token_1 = custom_thumbnail_prefixing(token_1, provider)
asset_url = asset_url.gsub("$1", token_1)
end

skng5 commented

Something like this may work better:

  def custom_thumbnail_prefixing(token, provider)
    case provider.endpoint_url
      when "http://dla.library.upenn.edu/dla/wheeler/oai-pmh.xml"
        token = token.gsub("WHEELER_","wheeler_")
      when "http://dla.library.upenn.edu/dla/holyland/oai-pmh.xml"
        token = token.gsub("HOLYLAND_","")
      when "http://dla.library.upenn.edu/dla/archives/oai-pmh.xml"
        token = token.gsub("ARCHIVES_","archives_")
      else
        token
      end
  end