RS, IZ; extracted and murdered ostatus.

This commit is contained in:
Raphael 2010-08-04 16:00:01 -07:00
parent 8abdcf292e
commit 58addca8dd
40 changed files with 57 additions and 893 deletions

View file

@ -1,10 +1,9 @@
class ApplicationController < ActionController::Base
require 'lib/diaspora/ostatus_generator'
protect_from_forgery :except => :receive
layout 'application'
before_filter :set_friends_authors_and_status, :count_requests
before_filter :set_friends_and_status, :count_requests
layout :layout_by_resource
@ -16,9 +15,8 @@ class ApplicationController < ActionController::Base
end
end
def set_friends_authors_and_status
def set_friends_and_status
@friends = Person.friends.all if current_user
@subscribed_persons = Author.all if current_user
@latest_status_message = StatusMessage.newest(current_user) if current_user
end

View file

@ -1,16 +0,0 @@
class AuthorsController < ApplicationController
before_filter :authenticate_user!
def show
@author= Author.where(:id => params[:id]).first
@author_ostatus_posts = @author.ostatus_posts.paginate :page => params[:page], :order => 'published_at DESC'
end
def destroy
current_user.unsubscribe_from_pubsub(params[:id])
flash[:notice] = "unsubscribed person."
redirect_to ostatus_path
end
end

View file

@ -6,7 +6,6 @@ class BlogsController < ApplicationController
respond_to do |format|
format.html
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @blogs)}
end

View file

@ -8,7 +8,6 @@ class BookmarksController < ApplicationController
respond_to do |format|
format.html
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @bookmarks)}
end
end

View file

@ -6,9 +6,4 @@ class DashboardsController < ApplicationController
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
end
def ostatus
@posts = OstatusPost.paginate :page => params[:page], :order => 'published_at DESC'
render :index
end
end

View file

@ -1,7 +1,6 @@
class PublicsController < ApplicationController
require 'lib/diaspora/parser'
include Diaspora::Parser
include Diaspora::OStatusParser
def hcard
@user = User.owner
@ -18,14 +17,6 @@ class PublicsController < ApplicationController
render 'webfinger', :layout => false, :content_type => 'application/xrd+xml'
end
def hubbub
if params['hub.mode'] == 'subscribe' || params['hub.mode'] == 'unsubscribe'
render :text => params['hub.challenge'], :status => 202, :layout => false
else
Diaspora::OStatusParser::process(request.body.read)
end
end
def receive
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
store_objects_from_xml params[:xml]

View file

@ -7,7 +7,6 @@ class StatusMessagesController < ApplicationController
respond_to do |format|
format.html
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @status_messages)}
end
end

View file

@ -17,12 +17,8 @@ module ApplicationHelper
end
def how_long_ago(obj)
if obj.is_a? OstatusPost
"#{time_ago_in_words(obj.published_at)} ago"
else
"#{time_ago_in_words(obj.created_at)} ago."
end
end
def person_url(person)
case person.class.to_s

View file

@ -1,10 +1,6 @@
module DashboardsHelper
def title_for_page
if params[:action] =='ostatus'
'OStatus home'
else
'home'
end
end
end

View file

@ -3,10 +3,8 @@ module RequestsHelper
def subscription_mode(profile)
if diaspora?(profile)
:friend
elsif ostatus?(profile)
:subscribe
else
:subscribe
:none
end
end
@ -14,19 +12,13 @@ module RequestsHelper
profile_contains(profile, 'http://joindiaspora.com/seed_location')
end
def ostatus?(profile)
profile_contains(profile, 'http://ostatus.org/schema/1.0/subscribe')
end
def profile_contains(profile, rel)
profile.links.each{|x| return true if x.rel == rel}
false
end
def subscription_url(action, profile)
if action == :subscribe
profile.links.select{|x| x.rel == 'http://schemas.google.com/g/2010#updates-from'}.first.href
elsif action == :friend
if action == :friend
profile.links.select{|x| x.rel == 'http://joindiaspora.com/seed_location'}.first.href
else
nil
@ -34,14 +26,6 @@ module RequestsHelper
end
def relationship_flow(identifier)
if identifier.include?('.atom')
return {:subscribe => identifier}
end
unless identifier.include?( '@' )
return {:friend => identifier}
end
f = Redfinger.finger(identifier)
action = subscription_mode(f)
url = subscription_url(action, f)

View file

@ -1,30 +0,0 @@
class Author
include MongoMapper::Document
key :service, String
key :feed_url, String
key :avatar_thumbnail, String
key :username, String
key :profile_url, String
key :hub, String
many :ostatus_posts, :class_name => 'OstatusPost', :foreign_key => :author_id
before_save :set_defaults
before_destroy :delete_posts
def self.instantiate(opts)
author = Author.first(:feed_url => opts[:feed_url])
author ||= Author.create(opts)
end
private
def set_defaults
self.avatar_thumbnail = nil if self.avatar_thumbnail == 0
self.service = self.url if self.service == 0
end
def delete_posts
self.ostatus_posts.delete_all
end
end

View file

@ -1,17 +0,0 @@
class OstatusPost
include MongoMapper::Document
key :author_id, ObjectId
key :message, String
key :permalink, String
key :published_at, DateTime
belongs_to :author, :class_name => 'Author'
cattr_reader :per_page
@@per_page = 10
timestamps!
end

View file

@ -1,6 +1,4 @@
class User < Person
require 'lib/diaspora/ostatus_parser'
include Diaspora::OStatusParser
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
@ -95,27 +93,9 @@ class User < Person
end
end
####ostatus######
#
def subscribe_to_pubsub(feed_url)
r = Request.instantiate(:to => feed_url, :from => self)
r.subscribe_to_ostatus(feed_url)
r
end
def unsubscribe_from_pubsub(author_id)
bad_author = Author.first(:id => author_id)
r = Request.instantiate(:to => bad_author.hub, :from => self)
r.unsubscribe_from_ostatus(bad_author.feed_url)
bad_author.destroy
end
def send_request(rel_hash)
if rel_hash[:friend]
self.send_friend_request_to(rel_hash[:friend])
elsif rel_hash[:subscribe]
self.subscribe_to_pubsub(rel_hash[:subscribe])
else
raise "you can't do anything to that url"
end

View file

@ -1,21 +0,0 @@
%h1.big_text
.back
= link_to '⇧ ostatus', ostatus_path
= "#{@author.username}'s stream"
.sub_header
= @author.profile_url
- if @author_ostatus_posts
%ul#stream
- for post in @author_ostatus_posts
= render type_partial(post), :post => post
= will_paginate @author_ostatus_posts
- else
%h3 no posts to display!
#content_bottom
.back
= link_to "⇧ ostatus", ostatus_path
.button.right
= link_to 'Unsubscribe', @author, :confirm => 'Are you sure?', :method => :delete

View file

@ -57,7 +57,6 @@
%ul.nav
%li= link_to "home", root_path
%li= link_to "photos", albums_path
%li= link_to "ostatus", ostatus_path
%li= "|"
%li= link_to "edit profile", edit_user_path(current_user)

View file

@ -1,12 +0,0 @@
%li.message{:id => post.id}
= image_tag post.author.avatar_thumbnail, :class => "person_picture" unless post.author.avatar_thumbnail.nil?
%span.from
= link_to post.author.username, author_path(post.author)
= auto_link post.message
%div.time
= link_to(how_long_ago(post), object_path(post))
from
= link_to post.author.service, post.author.profile_url

View file

@ -1,9 +0,0 @@
%h1.big_text status messages
= render "status_messages/new_status_message", :status_message => @status_message
%ul#stream
- for status_message in @status_messages
= render "status_message", :post => status_message
#pagination
= will_paginate @status_messages

View file

@ -1,17 +0,0 @@
- title "Status Message"
%p
%strong Message:
= @status_message.message
%p
%strong Owner:
= @status_message.person.real_name
%h4= "comments (#{@status_message.comments.count})"
= render "comments/comments", :post => @status_message
%p
= link_to "Destroy", @status_message, :confirm => 'Are you sure?', :method => :delete
|
= link_to "View All", status_messages_path

View file

@ -8,9 +8,4 @@
%br
%br
%h3 following
- for author in @subscribed_persons
%li= link_to author.username, author_path(author)
= link_to "add a new person", requests_path

View file

@ -9,11 +9,6 @@ Diaspora::Application.routes.draw do |map|
resources :photos
resources :albums
resources :authors
resources :ostatus_posts
match 'ostatus', :to => "dashboards#ostatus"
match "/images/files/*path" => "gridfs#serve"
match 'warzombie', :to => "dev_utilities#warzombie"
@ -31,7 +26,6 @@ Diaspora::Application.routes.draw do |map|
#public routes
match 'receive', :to => 'publics#receive'
match 'hubbub', :to => 'publics#hubbub'
match '.well-known/host-meta',:to => 'publics#host_meta'
match 'webfinger', :to => 'publics#webfinger'
match 'hcard', :to => 'publics#hcard'

Binary file not shown.

View file

@ -3,7 +3,4 @@ module Diaspora
autoload :Parser
autoload :Webhooks
autoload :OStatusParser
autoload :OStatusGenerator
end

View file

@ -1,70 +0,0 @@
module Diaspora
module OStatusGenerator
def self.generate(opts= {})
xml = Generate::headers(opts[:current_url])
xml << Generate::author
xml << Generate::endpoints
xml << Generate::subject
xml << Generate::entries(opts[:objects])
xml << Generate::footer
end
module Generate
def self.headers(current_url)
#this is retarded
@@user = User.owner
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<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/">
<generator uri="http://joindiaspora.com/">Diaspora</generator>
<id>#{current_url}</id>
<title>Stream</title>
<subtitle>its a stream </subtitle>
<updated>#{Time.now.xmlschema}</updated>
XML
end
def self.author
<<-XML
<author>
<name>#{@@user.real_name}</name>
<uri>#{@@user.url}</uri>
</author>
XML
end
def self.endpoints
<<-XML
<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
XML
end
def self.subject
<<-XML
<activity:subject>
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
<id>#{@@user.url}</id>
<title>#{@@user.real_name}</title>
<link rel="alternative" type="text/html" href="#{@@user.url}"/>
</activity:subject>
XML
end
def self.entries(objects)
xml = ""
if objects.respond_to? :each
objects.each {|x| xml << x.to_activity}
else
xml << objects.to_activity
end
xml
end
def self.footer
<<-XML.strip
</feed>
XML
end
end
end
end

View file

@ -1,87 +0,0 @@
module Diaspora
module OStatusParser
def self.process(xml)
doc = Nokogiri::HTML(xml)
hash = {}
hash[:author] = self.author(doc)
hash[:author][:hub] = self.hub(doc)
hash[:entry] = self.entry(doc)
author = Author.instantiate(hash[:author])
author.ostatus_posts.create(hash[:entry]) if hash[:entry][:message]
end
def self.author(doc)
return {
:service => self.service(doc),
:feed_url => self.feed_url(doc),
:avatar_thumbnail => self.avatar_thumbnail(doc),
:username => self.username(doc),
:profile_url => self.profile_url(doc)
}
end
def self.entry(doc)
return {
:message => self.message(doc),
:permalink => self.permalink(doc),
:published_at => self.published_at(doc),
:updated_at => self.updated_at(doc)
}
end
def self.hub(xml)
xml = Nokogiri::HTML(xml) if xml.is_a? String
xml.xpath('//link[@rel="hub"]').first.attribute("href").value
end
# Author #########################
def self.service(doc)
self.contents(doc.xpath('//generator'))
end
def self.feed_url(doc)
self.contents(doc.xpath('//id'))
end
def self.avatar_thumbnail(doc)
self.contents(doc.xpath('//logo'))
end
def self.username(doc)
self.contents(doc.xpath('//author/name'))
end
def self.profile_url(doc)
self.contents(doc.xpath('//author/uri'))
end
# Entry ##########################
def self.message(doc)
self.contents(doc.xpath('//entry/title'))
end
def self.permalink(doc)
self.contents(doc.xpath('//entry/id'))
end
def self.published_at(doc)
self.contents(doc.xpath('//entry/published'))
end
def self.updated_at(doc)
self.contents(doc.xpath('//entry/updated'))
end
def self.contents(xpath)
xpath.each{|x| return x.inner_html}
end
end
end

View file

@ -16,18 +16,7 @@ module Diaspora
push_to(people_with_permissions)
end
def subscribe_to_ostatus(feed_url)
@@queue.add_subscription_request(feed_url)
@@queue.process
end
def unsubscribe_from_ostatus(feed_url)
@@queue.add_hub_unsubscribe_request(self.destination_url, self.callback_url+'hubbub', feed_url)
@@queue.process
end
def push_to(recipients)
@@queue.add_hub_notification(APP_CONFIG[:pubsub_server], User.owner.url + self.class.to_s.pluralize.underscore + '.atom')
unless recipients.empty?
recipients.map!{|x| x = x.url + "receive/"}
xml = Post.build_xml_for(self)

View file

@ -12,35 +12,11 @@ class MessageHandler
[*destinations].each{ |dest| @queue.push(Message.new(:get, dest))}
end
def add_subscription_request(feed_url)
@queue.push(Message.new(:ostatus_subscribe, feed_url))
end
def add_post_request(destinations, body)
b = CGI::escape( body )
[*destinations].each{|dest| @queue.push(Message.new(:post, dest, :body => b))}
end
# pubsubhubbub
def add_hub_notification(hub_url, feed_url)
@queue.push(Message.new(:hub_publish, hub_url, :body => feed_url))
end
def add_hub_subscription_request(hub_url, feed_url)
@queue.push(Message.new(:hub_subscribe, hub_url, :body => feed_url))
end
def add_hub_unsubscribe_request(hub, from, feed_url)
@queue.push(Message.new(:hub_unsubscribe, hub, :body => feed_url, :owner_url => from))
end
def process_ostatus_subscription(query_object, http)
hub = Diaspora::OStatusParser::hub(http.response)
add_hub_subscription_request(hub, query_object.destination)
Diaspora::OStatusParser::process(http.response)
end
def process
@queue.pop{ |query|
case query.type
@ -50,22 +26,6 @@ class MessageHandler
when :get
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback {send_to_seed(query, http.response); process}
when :ostatus_subscribe
puts query.destination
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
http.callback { process_ostatus_subscription(query, http); process}
when :hub_publish
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT
http.callback { process}
when :hub_subscribe
http = EventMachine::PubSubHubbub.new(query.destination).subscribe query.body, User.owner.url + 'hubbub', :timeout => TIMEOUT
http.callback { process}
when :hub_unsubscribe
http = EventMachine::PubSubHubbub.new(query.destination).unsubscribe query.body, query.owner_url, :timeout => TIMEOUT
http.callback {process}
else
raise "message is not a type I know!"
end

View file

@ -12,7 +12,6 @@ describe DashboardsController do
Factory.create :person
get :index
assigns[:friends].should == Person.friends.all
assigns[:subscribed_persons] == Author.all
end
end

View file

@ -20,19 +20,4 @@ describe PublicsController do
end
end
describe 'PubSubHubBuB intergration' do
describe 'incoming subscriptions' do
it 'should respond to a incoming subscription request' do
get :hubbub, {'hub.callback' => "http://example.com/",
'hub.mode' => 'subscribe',
'hub.topic' => '/status_messages',
'hub.verify' => 'sync',
'hub.challenge' => 'foobar'}
response.status.should == 202
response.body.should == 'foobar'
end
end
end
end

View file

@ -1,17 +0,0 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe RequestsController do
describe "profile" do
it 'should fetch the public webfinger profile on request' do
pending "Duplicate test"
#post :create {:request => {:destination_url => 'tom@tom.joindiaspora.com'}
url = RequestsController.diaspora_url('http://tom.joindiaspora.com/')
url.should == 'http://tom.joindiaspora.com/'
url = RequestsController.diaspora_url('tom@tom.joindiaspora.com')
url.should == 'http://tom.joindiaspora.com/'
end
end
end

View file

@ -49,10 +49,4 @@ Factory.define :photo do |p|
end
Factory.define :author do |p|
p.hub "http://pubsubhubub.appspot.com/"
p.service "StatusNet"
p.username "danielgrippi"
p.feed_url "http://google.com"
end
Factory.define(:comment) {}

View file

@ -1,166 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/">
<generator uri="http://status.net" version="0.9.3">StatusNet</generator>
<id>http://identi.ca/api/statuses/user_timeline/169966.atom</id>
<title>joindiaspora timeline</title>
<subtitle>Updates from joindiaspora on Identi.ca!</subtitle>
<logo>http://avatar.identi.ca/169966-96-20100426170852.png</logo>
<updated>2010-07-22T01:00:38+00:00</updated>
<author>
<name>joindiaspora</name>
<uri>http://identi.ca/user/169966</uri>
</author>
<link href="http://identi.ca/joindiaspora" rel="alternate" type="text/html"/>
<link href="http://identi.ca/main/sup#169966" rel="http://api.friendfeed.com/2008/03#sup" type="application/json"/>
<link href="http://identi.ca/main/push/hub" rel="hub"/>
<link href="http://identi.ca/main/salmon/user/169966" rel="http://salmon-protocol.org/ns/salmon-replies"/>
<link href="http://identi.ca/main/salmon/user/169966" rel="http://salmon-protocol.org/ns/salmon-mention"/>
<link href="http://identi.ca/api/statuses/user_timeline/169966.atom" rel="self" type="application/atom+xml"/>
<activity:subject>
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
<id>http://identi.ca/user/169966</id>
<title>Diaspora</title>
<link rel="alternate" type="text/html" href="http://identi.ca/joindiaspora"/>
<link rel="avatar" type="image/png" media:width="480" media:height="480" href="http://avatar.identi.ca/169966-480-20100426170851.png"/>
<link rel="avatar" type="image/png" media:width="96" media:height="96" href="http://avatar.identi.ca/169966-96-20100426170852.png"/>
<link rel="avatar" type="image/png" media:width="48" media:height="48" href="http://avatar.identi.ca/169966-48-20100426170852.png"/>
<link rel="avatar" type="image/png" media:width="24" media:height="24" href="http://avatar.identi.ca/169966-24-20100426170852.png"/>
<poco:preferredUsername>joindiaspora</poco:preferredUsername>
<poco:displayName>Diaspora</poco:displayName>
<poco:note>Diaspora is an awesome, distributed, open source social network in the making from some young hackers at NYU</poco:note>
<poco:urls>
<poco:type>homepage</poco:type>
<poco:value>http://joindiaspora.com</poco:value>
<poco:primary>true</poco:primary>
</poco:urls>
</activity:subject>
<entry>
<title>A month of Diaspora in action. First screenshots/video! http://bit.ly/clOFXx</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/39231942"/>
<id>http://identi.ca/notice/39231942</id>
<published>2010-07-02T06:13:11+00:00</published>
<updated>2010-07-02T06:13:11+00:00</updated>
<statusnet:notice_info local_id="39231942" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/38985291"/>
<content type="html">A month of Diaspora in action. First screenshots/video! &lt;a href=&quot;http://bit.ly/clOFXx&quot; title=&quot;http://www.joindiaspora.com/2010/07/01/one-month-in.html&quot; rel=&quot;external&quot;&gt;http://bit.ly/clOFXx&lt;/a&gt;</content>
</entry>
<entry>
<title>http://www.reclaimprivacy.org/ check your FB privacy settings, automagically! !whyisntthisbuiltintofacebook :)</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/32556574"/>
<id>http://identi.ca/notice/32556574</id>
<published>2010-05-17T18:18:28+00:00</published>
<updated>2010-05-17T18:18:28+00:00</updated>
<statusnet:notice_info local_id="32556574" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/32429253"/>
<content type="html">&lt;a href=&quot;http://www.reclaimprivacy.org/&quot; title=&quot;http://www.reclaimprivacy.org/&quot; rel=&quot;external&quot;&gt;http://www.reclaimprivacy.org/&lt;/a&gt; check your FB privacy settings, automagically! !whyisntthisbuiltintofacebook :)</content>
</entry>
<entry>
<title>@cacheson, should already be there, at http://joindiaspora.com/atom.xml... hopefully that will do the trick...</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/31824813"/>
<id>http://identi.ca/notice/31824813</id>
<published>2010-05-11T14:29:38+00:00</published>
<updated>2010-05-11T14:29:38+00:00</updated>
<statusnet:notice_info local_id="31824813" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/31712301"/>
<link rel="ostatus:attention" href="http://identi.ca/user/47185"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/47185&quot; class=&quot;url&quot; title=&quot;Chris Acheson&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;cacheson&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, should already be there, at &lt;a href=&quot;http://joindiaspora.com/atom.xml&quot; title=&quot;http://joindiaspora.com/atom.xml&quot; rel=&quot;external&quot; class=&quot;attachment&quot; id=&quot;attachment-15490501&quot;&gt;http://joindiaspora.com/atom.xml&lt;/a&gt;... hopefully that will do the trick...</content>
<link rel="enclosure" href="http://joindiaspora.com/atom.xml" type="application/xml" length="31902"/>
</entry>
<entry>
<title>@elmom, thanks for your support. we are excited to get started. helsinki is awesome, I hope to go back one day! good luck w/hackerspace!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30760606"/>
<id>http://identi.ca/notice/30760606</id>
<published>2010-05-02T07:06:02+00:00</published>
<updated>2010-05-02T07:06:02+00:00</updated>
<statusnet:notice_info local_id="30760606" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30668263"/>
<link rel="ostatus:attention" href="http://identi.ca/user/101533"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/101533&quot; class=&quot;url&quot; title=&quot;Elmo M&amp;#xE4;ntynen&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;elmom&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, thanks for your support. we are excited to get started. helsinki is awesome, I hope to go back one day! good luck w/hackerspace!</content>
</entry>
<entry>
<title>@tieguy, thanks for the great feedback, here is our response: http://bit.ly/aF2Fpl</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30549323"/>
<id>http://identi.ca/notice/30549323</id>
<published>2010-04-30T06:29:28+00:00</published>
<updated>2010-04-30T06:29:28+00:00</updated>
<statusnet:notice_info local_id="30549323" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30461403"/>
<link rel="ostatus:attention" href="http://identi.ca/user/11"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/11&quot; class=&quot;url&quot; title=&quot;Luis Villa&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;tieguy&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, thanks for the great feedback, here is our response: &lt;a href=&quot;http://bit.ly/aF2Fpl&quot; title=&quot;http://joindiaspora.com/2010/04/30/a-response-to-mr-villa.html&quot; rel=&quot;external&quot;&gt;http://bit.ly/aF2Fpl&lt;/a&gt;</content>
</entry>
<entry>
<title>RT @tieguy @joindiaspora hopefully constructive questions for you: http://ur1.ca/xbvq cc: @mlinksva @rejon @biella@brainbird.net</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30154486"/>
<id>http://identi.ca/notice/30154486</id>
<published>2010-04-27T06:22:14+00:00</published>
<updated>2010-04-27T06:22:14+00:00</updated>
<statusnet:notice_info local_id="30154486" source="web" favorite="false" repeated="false" repeat_of="30152015"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30076242"/>
<ostatus:forward ref="http://identi.ca/notice/30152015" href="http://identi.ca/notice/30152015"></ostatus:forward>
<content type="html">RT @&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/11&quot; class=&quot;url&quot; title=&quot;Luis Villa&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;tieguy&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; @&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/169966&quot; class=&quot;url&quot; title=&quot;Diaspora&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;joindiaspora&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; hopefully constructive questions for you: &lt;a href=&quot;http://ur1.ca/xbvq&quot; title=&quot;http://tieguy.org/blog/2010/04/27/questions-for-the-diaspora/&quot; rel=&quot;external&quot;&gt;http://ur1.ca/xbvq&lt;/a&gt; cc: @&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/8&quot; class=&quot;url&quot; title=&quot;Mike Linksvayer&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;mlinksva&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; @&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/37&quot; class=&quot;url&quot; title=&quot;Jon Phillips&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;rejon&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; @&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://brainbird.net/biella&quot; class=&quot;url&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;biella@brainbird.net&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;</content>
</entry>
<entry>
<title>@tieguy it's on! ;) we have already thought about much of your comments, but give us a day or two to give you a good response.</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30152694"/>
<id>http://identi.ca/notice/30152694</id>
<published>2010-04-27T06:04:30+00:00</published>
<updated>2010-04-27T06:04:30+00:00</updated>
<statusnet:notice_info local_id="30152694" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30074469"/>
<link rel="ostatus:attention" href="http://identi.ca/user/11"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/11&quot; class=&quot;url&quot; title=&quot;Luis Villa&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;tieguy&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; it's on! ;) we have already thought about much of your comments, but give us a day or two to give you a good response.</content>
</entry>
<entry>
<title>@mattkatz00 we really appreciate your kickstarter backing!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089749"/>
<id>http://identi.ca/notice/30089749</id>
<published>2010-04-26T19:32:19+00:00</published>
<updated>2010-04-26T19:32:19+00:00</updated>
<statusnet:notice_info local_id="30089749" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012647"/>
<content type="html">@mattkatz00 we really appreciate your kickstarter backing!</content>
</entry>
<entry>
<title>@danlatorre many thanks for your backing and support!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089410"/>
<id>http://identi.ca/notice/30089410</id>
<published>2010-04-26T19:29:27+00:00</published>
<updated>2010-04-26T19:29:27+00:00</updated>
<statusnet:notice_info local_id="30089410" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012313"/>
<link rel="ostatus:attention" href="http://identi.ca/user/16365"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/16365&quot; class=&quot;url&quot; title=&quot;Daniel Latorre&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;danlatorre&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; many thanks for your backing and support!</content>
</entry>
<entry>
<title>@adwilliamson thanks for backing diaspora!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30089220"/>
<id>http://identi.ca/notice/30089220</id>
<published>2010-04-26T19:27:36+00:00</published>
<updated>2010-04-26T19:27:36+00:00</updated>
<statusnet:notice_info local_id="30089220" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30012129"/>
<content type="html">@adwilliamson thanks for backing diaspora!</content>
</entry>
<entry>
<title>@thisisparker many thanks for your kickstarter backing!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30088868"/>
<id>http://identi.ca/notice/30088868</id>
<published>2010-04-26T19:23:51+00:00</published>
<updated>2010-04-26T19:23:51+00:00</updated>
<statusnet:notice_info local_id="30088868" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/30011788"/>
<link rel="ostatus:attention" href="http://identi.ca/user/27657"/>
<content type="html">@&lt;span class=&quot;vcard&quot;&gt;&lt;a href=&quot;http://identi.ca/user/27657&quot; class=&quot;url&quot; title=&quot;Parker Higgins&quot;&gt;&lt;span class=&quot;fn nickname&quot;&gt;thisisparker&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; many thanks for your kickstarter backing!</content>
</entry>
<entry>
<title>We'll be building the interface for Diaspora to StatusNet, but for now, this will be from the web!</title>
<link rel="alternate" type="text/html" href="http://identi.ca/notice/30074166"/>
<id>http://identi.ca/notice/30074166</id>
<published>2010-04-26T17:07:49+00:00</published>
<updated>2010-04-26T17:07:49+00:00</updated>
<statusnet:notice_info local_id="30074166" source="web" favorite="false" repeated="false"></statusnet:notice_info>
<link rel="ostatus:conversation" href="http://identi.ca/conversation/29997414"/>
<content type="html">We'll be building the interface for Diaspora to StatusNet, but for now, this will be from the web!</content>
</entry>
</feed>

View file

@ -1,2 +0,0 @@
"<?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=\"http://status.net\" version=\"0.9.3\">StatusNet</generator>\n <id>http://identi.ca/api/statuses/user_timeline/217769.atom</id>\n <title>danielgrippi timeline</title>\n <subtitle>Updates from danielgrippi on Identi.ca!</subtitle>\n <logo>http://theme.status.net/0.9.3/identica/default-avatar-profile.png</logo>\n <updated>2010-07-22T22:15:31+00:00</updated>\n<author>\n <name>danielgrippi</name>\n <uri>http://identi.ca/user/217769</uri>\n</author>\n <link href=\"http://identi.ca/danielgrippi\" rel=\"alternate\" type=\"text/html\"/>\n <link href=\"http://identi.ca/main/sup#217769\" rel=\"http://api.friendfeed.com/2008/03#sup\" type=\"application/json\"/>\n <link href=\"http://identi.ca/main/push/hub\" rel=\"hub\"/>\n <link href=\"http://identi.ca/main/salmon/user/217769\" rel=\"http://salmon-protocol.org/ns/salmon-replies\"/>\n <link href=\"http://identi.ca/main/salmon/user/217769\" rel=\"http://salmon-protocol.org/ns/salmon-mention\"/>\n <link href=\"http://identi.ca/api/statuses/user_timeline/217769.atom\" rel=\"self\" type=\"application/atom+xml\"/>\n<activity:subject>\n <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>\n <id>http://identi.ca/user/217769</id>\n <title>Daniel Grippi</title>\n <link rel=\"alternate\" type=\"text/html\" href=\"http://identi.ca/danielgrippi\"/>\n <link rel=\"avatar\" type=\"image/png\" media:width=\"96\" media:height=\"96\" href=\"http://theme.status.net/0.9.3/identica/default-avatar-profile.png\"/>\n <link rel=\"avatar\" type=\"image/png\" media:width=\"48\" media:height=\"48\" href=\"http://theme.status.net/0.9.3/identica/default-avatar-stream.png\"/>\n <link rel=\"avatar\" type=\"image/png\" media:width=\"24\" media:height=\"24\" href=\"http://theme.status.net/0.9.3/identica/default-avatar-mini.png\"/>\n <georss:point>0 0</georss:point>\n<poco:preferredUsername>danielgrippi</poco:preferredUsername>\n<poco:displayName>Daniel Grippi</poco:displayName>\n<poco:note>hey there kids!</poco:note>\n<poco:address>\n <poco:formatted>earth</poco:formatted>\n</poco:address>\n<poco:urls>\n <poco:type>homepage</poco:type>\n <poco:value>http://danielgrippi.com/</poco:value>\n <poco:primary>true</poco:primary>\n</poco:urls>\n</activity:subject>\n<entry>\n <title>SOAP!</title>\n <link rel=\"alternate\" type=\"text/html\" href=\"http://identi.ca/notice/43074747\"/>\n <id>http://identi.ca/notice/43074747</id>\n <published>2010-07-22T22:15:31+00:00</published>\n <updated>2010-07-22T22:15:31+00:00</updated>\n <statusnet:notice_info local_id=\"43074747\" source=\"web\"></statusnet:notice_info>\n <link rel=\"ostatus:conversation\" href=\"http://identi.ca/conversation/42780740\"/>\n <content type=\"html\">SOAP!</content>\n <georss:point>37.7912 -122.401</georss:point>\n</entry>\n</feed>\n"

View file

@ -5,35 +5,22 @@ include RequestsHelper
describe RequestsHelper do
before do
#@tom = Redfinger.finger('tom@tom.joindiaspora.com')
#@evan = Redfinger.finger('evan@status.net')
#@max = Redfinger.finger('mbs348@gmail.com')
@tom = Redfinger.finger('tom@tom.joindiaspora.com')
@evan = Redfinger.finger('evan@status.net')
@max = Redfinger.finger('mbs348@gmail.com')
end
describe "profile" do
it 'should fetch the public webfinger profile on request' do
pending
#post :create {:request => {:destination_url => 'tom@tom.joindiaspora.com'}
url = diaspora_url('http://tom.joindiaspora.com/')
url.should == 'http://tom.joindiaspora.com/'
url = diaspora_url('tom@tom.joindiaspora.com')
url.should == 'http://tom.joindiaspora.com/'
end
it 'should detect how to subscribe to a diaspora or ostatus webfinger profile' do
pending
it 'should detect how to subscribe to a diaspora or webfinger profile' do
subscription_mode(@tom).should == :friend
subscription_mode(@evan).should == :subscribe
subscription_mode(@evan).should == :none
subscription_mode(@max).should == :none
end
it 'should return the correct tag and url for a given address' do
pending
relationship_flow('tom@tom.joindiaspora.com')[:friend].should == 'http://tom.joindiaspora.com/'
relationship_flow('evan@status.net')[:subscribe].should == 'http://evan.status.net/api/statuses/user_timeline/1.atom'
end
end

View file

@ -1,31 +0,0 @@
require File.dirname(__FILE__) + '/../spec_helper'
require 'lib/diaspora/ostatus_generator'
describe Diaspora::OStatusGenerator do
before do
@user = Factory.create(:user)
Diaspora::OStatusGenerator::OWNER = @user
end
describe Diaspora::OStatusGenerator::Generate do
describe "header" do
it 'should generate an OStatus compliant header' do
Diaspora::OStatusGenerator::Generate::headers(:current_url => @user.url).should include @user.url
end
end
describe "status message entry" do
before do
@status_message = Factory.create(:status_message, :message => "feed me")
end
it "should encode to activity stream xml" do
sm_entry = Diaspora::OStatusGenerator::generate(:objects => @status_message, :current_url => "http://diaspora.com/")
sm_entry.should include(@status_message.message)
sm_entry.should include('title')
end
end
end
end

View file

@ -131,83 +131,6 @@ describe MessageHandler do
end
end
describe 'ostatus_subscribe' do
it 'should be able to add a GET query to the queue with required destinations' do
request = FakeHttpRequest.new(:success)
request.should_receive(:get).exactly(1).times.and_return(request)
request.stub!(:callback).and_return(true)
EventMachine::HttpRequest.stub!(:new).and_return(request)
EventMachine.run{
@handler.add_subscription_request("http://evan.status.net/")
@handler.size.should == 1
@handler.process
EventMachine.stop
}
end
end
describe 'hub_publish' do
it 'should correctly queue up a pubsubhub publish request' do
destination = "http://identi.ca/hub/"
feed_location = "http://google.com/"
EventMachine.run {
@handler.add_hub_notification(destination, feed_location)
q = @handler.instance_variable_get(:@queue)
message = ""
q.pop{|m| message = m}
message.destination.should == destination
message.body.should == feed_location
EventMachine.stop
}
end
it 'should notify the hub about new content' do
request = FakeHttpRequest.new(:success)
request.should_receive(:publish).exactly(1).times.and_return(request)
EventMachine::PubSubHubbub.stub!(:new).and_return(request)
EventMachine.run {
@handler.add_hub_notification("http://identi.ca/hub", "http://google.com/feed")
@handler.size.should == 1
@handler.process
@handler.size.should == 0
EventMachine.stop
}
end
end
describe 'hub_subscribe' do
it 'should process an ostatus subscription' do
request = FakeHttpRequest.new(:success)
Diaspora::OStatusParser.stub!(:find_hub).and_return("http://hub.google.com")
MessageHandler.stub!(:add_hub_subscription_request).and_return(true)
Diaspora::OStatusParser.stub!(:process)
Diaspora::OStatusParser.should_receive(:find_hub)
@handler.should_receive(:add_hub_subscription_request)
Diaspora::OStatusParser.should_receive(:process)
g = mock("Message")
g.stub!(:destination).and_return("google")
@handler.process_ostatus_subscription(g, request)
end
end
end
class FakeHttpRequest

View file

@ -1,68 +0,0 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe Diaspora::OStatusParser do
it 'should be able to get the hub of an ostatus feed' do
xml_path = File.dirname(__FILE__) + '/../fixtures/identica_feed.atom'
xml = File.open(xml_path).read
Diaspora::OStatusParser::hub(xml).should == 'http://identi.ca/main/push/hub'
end
describe 'subscriber info' do
before do
#load file
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
@xml = File.open(xml_path).read
@xml = Nokogiri::HTML(@xml)
end
it 'should parse the users service' do
Diaspora::OStatusParser::service(@xml).should == 'StatusNet'
end
it 'should parse the feed_url' do
Diaspora::OStatusParser::feed_url(@xml).should == 'http://identi.ca/api/statuses/user_timeline/217769.atom'
end
it 'should parse the avatar thumbnail' do
Diaspora::OStatusParser::avatar_thumbnail(@xml).should == 'http://theme.status.net/0.9.3/identica/default-avatar-profile.png'
end
it 'should parse the username' do
Diaspora::OStatusParser::username(@xml).should == 'danielgrippi'
end
it 'should parse the profile_url' do
Diaspora::OStatusParser::profile_url(@xml).should == 'http://identi.ca/user/217769'
end
end
describe 'entry' do
before do
#load file
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
@xml = File.open(xml_path).read
@xml = Nokogiri::HTML(@xml)
end
it 'should parse the message' do
Diaspora::OStatusParser::message(@xml).should == 'SOAP!'
end
it 'should parse the permalink' do
Diaspora::OStatusParser::permalink(@xml).should == 'http://identi.ca/notice/43074747'
end
it 'should parse published at date' do
Diaspora::OStatusParser::published_at(@xml).should == '2010-07-22T22:15:31+00:00'
end
it 'should parse the updated at date' do
Diaspora::OStatusParser::updated_at(@xml).should == '2010-07-22T22:15:31+00:00'
end
end
end

View file

@ -1,16 +0,0 @@
require File.dirname(__FILE__) + '/../spec_helper'
include Diaspora::OStatusParser
describe Author do
it 'should create from ostatus compliant xml from the parser' do
xml_path = File.dirname(__FILE__) + '/../fixtures/identica_feed.atom'
xml = File.open(xml_path).read
Author.count.should == 0
Diaspora::OStatusParser.process(xml)
Author.count.should == 1
end
end

View file

@ -1,5 +0,0 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe OstatusPost do
end

View file

@ -13,7 +13,7 @@ describe Photo do
it 'should have a constructor' do
image = File.open(@fixture_name)
photo = Photo.instantiate(:person => @user, :album => @album, :user_file => [image])
photo.save.should be true
photo.created_at.nil?.should be false
photo.image.read.nil?.should be false
end

View file

@ -47,17 +47,6 @@ describe User do
@user.terse_url.should == 'example.com'
end
it 'should be able to unsubscribe from a status.net user' do
author = Factory.create(:author)
Author.all.count.should == 1
q = Request.send :class_variable_get, :@@queue
q.stub!(:add_hub_unsubscribe_request)
q.should_receive(:add_hub_unsubscribe_request)
@user.unsubscribe_from_pubsub(author.id)
Author.all.count.should == 0
end
it 'should be able to update their profile and send it to their friends' do
Factory.create(:person)