Class: Diaspora::OstatusBuilder

Inherits:
Object
  • Object
show all
Includes:
Webhooks
Defined in:
lib/diaspora/ostatus_builder.rb

Instance Method Summary (collapse)

Methods included from Webhooks

#receive, #subscribers, #to_diaspora_xml, #x

Constructor Details

- (OstatusBuilder) initialize(user, posts)

A new instance of OstatusBuilder



24
25
26
27
# File 'lib/diaspora/ostatus_builder.rb', line 24

def initialize(user, posts)
  @user = user
  @posts = posts
end

Instance Method Details

- (Object) create_body



66
67
68
69
70
71
72
73
74
# File 'lib/diaspora/ostatus_builder.rb', line 66

def create_body
  @posts.inject("") do |xml,curr|
    if curr.respond_to?(:to_activity)
      xml + curr.to_activity(:author => @user.person)
    else
      xml
    end
  end
end

- (Object) create_endpoints



58
59
60
# File 'lib/diaspora/ostatus_builder.rb', line 58

def create_endpoints
  "<link href=\"\#{AppConfig[:pubsub_server]}\" rel=\"hub\"/>\n<link href=\"\#{@user.public_url}.atom\" rel=\"self\" type=\"application/atom+xml\"/>\n"
end


76
77
78
# File 'lib/diaspora/ostatus_builder.rb', line 76

def create_footer
  "</feed>\n"
end

- (Object) create_headers



29
30
31
# File 'lib/diaspora/ostatus_builder.rb', line 29

def create_headers
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed xml:lang=\"en-US\" xmlns=\"http://www.w3.org/2005/Atom\" 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/\">\n<generator uri=\"\#{AppConfig[:pod_url]}\">Diaspora</generator>\n<id>\#{@user.public_url}.atom</id>\n<title>\#{x(@user.name)}'s Public Feed</title>\n<subtitle>Updates from \#{x(@user.name)} on Diaspora</subtitle>\n<logo>\#{@user.person.profile.image_url(:thumb_small)}</logo>\n<updated>\#{Time.now.xmlschema}</updated>\n"
end

- (Object) create_subject



43
44
45
# File 'lib/diaspora/ostatus_builder.rb', line 43

def create_subject
  "<author>\n<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>\n<name>\#{x(@user.name)}</name>\n<uri>\#{AppConfig[:pod_url]}people/\#{@user.person.id}</uri>\n<link rel=\"alternate\" type=\"text/html\" href=\"\#{@user.public_url}\" />\n<poco:preferredUsername>\#{x(@user.username)}</poco:preferredUsername>\n<poco:displayName>\#{x(@user.person.name)}</poco:displayName>\n<link rel=\"avatar\" type=\"image/jpeg\" media:width=\"100\" media:height=\"100\" href=\"\#{@user.profile.image_url}\"/>\n</author>\n"
end