Fix problem with atom feed entry titles being too long

This commit is contained in:
JMSilla 2012-02-18 16:18:54 +00:00
parent 097a8b409d
commit 1fe15654c5

View file

@ -0,0 +1,40 @@
atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
'xmlns:georss' => 'http://www.georss.org/georss',
'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
'xmlns:media' => 'http://purl.org/syndication/atommedia',
'xmlns:poco' => 'http://portablecontacts.net/spec/1.0',
'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
'xmlns:statusnet' => 'http://status.net/schema/api/1/',
:id => "#{@user.public_url}.atom",
:root_url => "#{@user.public_url}"}) do |feed|
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig[:pod_url]}"
feed.title "#{@user.name}'s Public Feed"
feed.subtitle "Updates from #{@user.name} on Diaspora"
feed.logo "#{@user.person.profile.image_url(:thumb_small)}"
feed.updated @posts[0].created_at if @posts.length > 0
feed.tag! :link, :rel => 'avatar', :type => 'image/jpeg', 'media:width' => '100',
'media:height' => '100', :href => "#{@user.profile.image_url}"
feed.tag! :link, :href => "#{AppConfig[:pubsub_server]}", :rel => 'hub'
feed.author do |author|
author.name @user.name
author.uri local_or_remote_person_path(@user.person, :absolute => true)
author.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/person'
author.tag! 'poco:preferredUsername', @user.username
author.tag! 'poco:displayName', @user.person.name
end
@posts.each do |post|
feed.entry post, :url => "#{@user.person.url}p/#{post.id}",
:id => "#{@user.person.url}p/#{post.id}" do |entry|
entry.title truncate(post.formatted_message(:plain_text => true), :length => 50)
entry.content post.formatted_message(:plain_text => true), :type => 'html'
entry.tag! 'activity:verb', 'http://activitystrea.ms/schema/1.0/post'
entry.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/note'
end
end
end