Page tree
Skip to end of metadata
Go to start of metadata

In release 3, Avalon introduced hooks to allow institutions to define permalinks (e.g., using a Handle server, DOI, or other durable link generating system) to resources. These links show up on the item/preview page in the Share this resource tab.

Permalinks are generated only for published Media Objects. When a Media Object is published, or a published Media Object is modified, Avalon makes sure that a permalink exists for the Media Object (Item) and for each of its component files (Sections).

To define how permalinks are generated, create a file in config/initializers (e.g., config/initializers/generate_permalink.rb) following this template:

Permalink.on_generate do |obj,url_for_obj|
  # Create a permanent link resource that will resolve/redirect to 
  # url_for_obj and return that resource as a URL string. e.g., 
  return "http://permalinkresolver.example.edu/media/#{obj.pid}"
end

To create permalinks for Media Objects (Items) only, and not direct links to sections:

Permalink.on_generate do |obj,url_for_obj|
  if obj.is_a? MediaObject
    return "http://permalinkresolver.example.edu/media/#{obj.pid}"
  else
    return nil
  end
end

 

It's also possible to use a generic route for permalinks.  The pid for an object can be substituted into the object controller route (i.e. /object/avalon:1).  The controller will redirect the browser to the resource.

Permalink.on_generate do |obj,url_for_obj|
  if obj.is_a? MediaObject
    return "http://permalinkresolver.example.edu/object/#{obj.pid}"
  else
    return nil
  end
end
  • No labels