lib/prophecy/manifest.rb in prophecy-0.2.4 vs lib/prophecy/manifest.rb in prophecy-0.2.5
- old
+ new
@@ -45,22 +45,26 @@
ret = @book.chapters.select{|ch| ch.render_path == @path.to_s }.first
ret.id if ret
end
def media_type
- ret = MIME::Types.type_for(File.basename(@path)).first.to_s
+ ret = ""
+ # first, use the known list
+ ext = File.extname(@path)
+ types = {
+ '.ncx' => 'application/x-dtbncx+xml',
+ '.ttf' => 'application/x-font-ttf',
+ }
+ if types.has_key?(ext)
+ ret = types[ext]
+ end
+ # if not, ask from MIME::Types
+ ret = MIME::Types.type_for(File.basename(@path)).first.to_s if ret == ""
if ret == ""
- ext = File.extname(@path)
- types = {
- '.ncx' => 'application/x-dtbncx+xml',
- }
- if types.has_key?(ext)
- ret = types[ext]
- else
- warn "Can't determine media type for: #{@path}"
- raise "Unknown Media Type"
- end
+ warn "Can't determine media type for: #{@path}"
+ raise "Unknown Media Type"
end
+
ret
end
def to_s
@path.to_s