Permalink
Browse files

Fixed film file links, added more version links, and depiction for ma…

…in thumbnail
  • Loading branch information...
1 parent de4cda4 commit 3f53207245f63aa742b489245f8bc89649c40e55 @ldodds committed Aug 22, 2011
Showing with 24 additions and 2 deletions.
  1. +1 −0 bin/cache.rb
  2. +23 −2 lib/FilmFiles.rb
View
@@ -1,4 +1,5 @@
require 'rubygems'
+
require 'open-uri'
require 'json'
View
@@ -12,7 +12,7 @@ def initialize(film, data)
@film = film
@id = film.fields["identifier"]
- @uri = RDF::URI.new( Util.canonicalize( "/film//#{film.fields["identifier"]}" ) )
+ @uri = RDF::URI.new( Util.canonicalize( "/film/#{film.fields["identifier"]}" ) )
@files = []
@root.find("file").each do |tag|
@@ -61,6 +61,11 @@ def generate_statements()
original = RDF::URI.new( "#{BASE_URL}/#{@id}/#{file["original"]}" )
add_statement( uri, RDF::DC.isFormatOf, original )
add_statement( original, RDF::DC.hasFormat, uri )
+
+ #also say its a version of the film
+ add_statement( uri, RDF::DC.isVersionOf, @uri )
+ add_statement( @uri, RDF::DC.hasVersion, uri )
+
end
format = RDF::URI.new( Util.canonicalize( "/format/#{Util.slug(file["format"])}"))
@@ -79,8 +84,24 @@ def generate_statements()
end
- #FIXME sort thumbnails?
+ thumbs = []
+ @files.each do |file|
+ case file["format"]
+ when "Thumbnail"
+ uri = RDF::URI.new( "#{BASE_URL}/#{@id}/#{file["name"]}" )
+ thumbs << uri
+ end
+ end
+ thumbs.sort!()
+ if thumbs.length > 0
+ if thumbs.length == 1
+ add_statement( @uri, RDF::FOAF.depiction, thumbs.first )
+ else
+ add_statement( @uri, RDF::FOAF.depiction, thumbs[1] )
+ end
+ end
+
end

0 comments on commit 3f53207

Please sign in to comment.