@@ 66,7 66,9 @@ end
module MRO
module Atom
class Basic
+ attr_reader :authors
def initialize
+ @authors = []
@xml = ''
end
def id= v
@@ 82,12 84,11 @@ module MRO
class Feed < Basic
attr_writer :xslt
- attr_reader :links, :authors, :entries
+ attr_reader :links, :entries
def initialize
super
@links = []
- @authors = []
@entries = []
yield self
self
@@ 163,6 164,9 @@ END_OF_XSLT
def to_xml
s = '<entry>'
s <<= @xml
+ s <<= '<author>'
+ s <<= self.authors.join('')
+ s <<= '</author>'
s <<= self.links.join('')
s <<= self.categories.join('')
s <<= '</entry>'
@@ 189,9 193,7 @@ END_OF_XSLT
end
class Person < String
def initialize h
- name = h[:name]
- h.delete :name
- super "<name #{h.map{|k,v| "#{k.to_xml}='#{v.to_xml}'"}.join(' ')}>#{name.to_xml}</name>"
+ super h.map{|k,v| "<#{k}>#{v.to_xml}</#{k}>"}.join(' ')
end
end
class Generator < String
@@ 346,9 348,11 @@ module MRO
feed = Atom::Feed.new do |f|
f.xslt = xslt_url
f.title = @ALBUM_NAME
- f.links << Atom::Link.new(:href => @ATOM_URL, :rel => :self)
- f.generator = Atom::Generator.new(:uri => 'http://purl.mro.name/iPhoto2Atom', :name => 'iPhoto2Atom')
- f.authors << Atom::Person.new(:name => 'John Doe')
+ f.links << Atom::Link.new(:href => @ATOM_URL, :rel => :self, :type => 'application/atom+xml')
+ f.links << Atom::Link.new(:href => @ATOM_URL, :rel => :alternate, :type => 'text/html')
+ f.generator = Atom::Generator.new(:uri => 'http://purl.mro.name/Photos2Atom', :name => 'iPhoto2Atom')
+ artist = {:name => 'John Doe', :uri => 'http://example.com/~jd'}
+ f.authors << Atom::Person.new(artist)
f.id = @BASE_URL # "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6"
prev = nil
@IPHOTO.find_images_for_album(@ALBUM_NAME) do |row|
@@ 387,7 391,8 @@ module MRO
e.updated = create_date
maxDate = create_date if create_date > maxDate
e.title = row[0] || row[1] # fallback to master name
- e.summary = row[10]
+ e.summary = (row[10] || '').strip # is mandatory if content/@src
+ e.authors << Atom::Person.new(artist)
# use Rating ?
dir2pxls.each do |dir,h|
dst = File.join(@ATOM_DIR, dir, "#{sha}.#{dst_fmt}") # (destination) file extension not part of sha.
@@ 409,8 414,8 @@ module MRO
# https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/sips.1.html
cyear = [create_date.year, Time.now.year].uniq.join('-')
properties = {
- :copyright => "© #{cyear}, Marcus Rohrmoser, http://mro.name/me",
- :artist => 'http://mro.name/me',
+ :copyright => "© #{cyear}, #{artist[:name]}, #{artist[:uri]}",
+ :artist => artist[:name],
:description => [e.title, e.summary].collect{|s| '' == s ? nil : s}.compact.collect{|s| s.strip}.join(' / '),
:format => dst_fmt,
:formatOptions => h[:quality],
@@ 428,9 433,10 @@ module MRO
else
$stderr.write '.'
end
- e.links << Atom::Link.new(:href => (@ATOM_URL + (dir + '/') + "#{sha}.#{dst_fmt}"), :rel => h[:rel], :length => File.size(dst) )
+ e.links << Atom::Link.new(:href => (@ATOM_URL + (dir + '/') + "#{sha}.#{dst_fmt}"), :rel => h[:rel], :length => File.size(dst), :type => "image/#{dst_fmt}" )
end
- e.content = Atom::Content::External.new :src => (@ATOM_URL + ('1600p' + '/') + "#{sha}.#{dst_fmt}").to_s, :type => "image/#{dst_fmt}"
+ e.links << Atom::Link.new(:href => (@ATOM_URL + ('1600p' + '/') + "#{sha}.#{dst_fmt}"), :type => "image/#{dst_fmt}" )
+ e.content = Atom::Content::External.new :src => (@ATOM_URL + ('1600p' + '/') + "#{sha}.#{dst_fmt}"), :type => "image/#{dst_fmt}"
e.media_thumbnail = Media::Thumbnail.new :url => (@ATOM_URL + ('200p' + '/') + "#{sha}.#{dst_fmt}")
@IPHOTO.find_keywords_for_image_version_id(row[8]) do |keywor|
e.categories << Atom::Category.new( :scheme => @BASE_URL, :term => keywor, :label => keywor )