Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Add documentation to Publishable#public_relationships
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed May 16, 2018
1 parent c001cee commit b9646b3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/dor/models/concerns/publishable.rb
Expand Up @@ -24,9 +24,9 @@ def thumb
{image_type: 'local', finder: "/contentMetadata/resource[@type='page' or @type='image']/file[#{mime_type_finder}]"}, # finally find the first page or image resource of mimetype jp2
{image_type: 'external', finder: "/contentMetadata/resource[@type='page' or @type='image']/externalFile[#{mime_type_finder}]"} # same thing for external file
]

thumb_xpath_finders.each do |search_path|
thumb_files = cm.xpath(search_path[:finder]) # look for a thumb
thumb_files = cm.xpath(search_path[:finder]) # look for a thumb
if thumb_files.size > 0 # if we find one, return the filename based on whether it is a local file or external file
if search_path[:image_type] == 'local'
thumb_image="#{remove_druid_prefix}/#{thumb_files[0]['id']}"
Expand All @@ -35,8 +35,8 @@ def thumb
end
break # break out of the loop so we stop searching
end
end
end

thumb_image
end

Expand All @@ -49,15 +49,17 @@ def encoded_thumb
thumb_filename=thumb_image.split(/#{pid_regex}[\/]/).last # everything after the druid
"#{thumb_druid}%2F#{ERB::Util.url_encode(thumb_filename)}"
end

# Return a full qualified thumbnail image URL if the thumb is computable
# @return [String] fully qualified image URL for the computed thumbnail, e.g. https://stacks.stanford.edu/image/iiif/oo000oo0001%2Ffilenamewith%20space/full
def thumb_url
return unless encoded_thumb
thumb_basename=File.basename(encoded_thumb, File.extname(encoded_thumb)) # strip the extension for URL generation
"https://#{Dor::Config.stacks.host}/image/iiif/#{thumb_basename}/full/!400,400/0/default.jpg"
end


# strips away the relationships that should not be shown in public desc metadata
# @return [Nokogiri::XML]
def public_relationships
include_elements = ['fedora:isMemberOf', 'fedora:isMemberOfCollection', 'fedora:isConstituentOf']
rels_doc = Nokogiri::XML(datastreams['RELS-EXT'].content)
Expand Down

0 comments on commit b9646b3

Please sign in to comment.