Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
bb4d5cad59
10 changed files with 98 additions and 51 deletions
|
|
@ -3,6 +3,13 @@ class BlogsController < ApplicationController
|
|||
|
||||
def index
|
||||
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.atom {render :xml => Diaspora::XML::generate(:current_url => request.url, :objects => @blogs)}
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@ class BookmarksController < ApplicationController
|
|||
def index
|
||||
@bookmark = Bookmark.new
|
||||
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.atom {render :xml => Diaspora::XML::generate(:current_url => request.url, :objects => @bookmarks)}
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
|||
|
|
@ -81,6 +81,13 @@ class User < Person
|
|||
self == post.person
|
||||
end
|
||||
|
||||
def terse_url
|
||||
terse= self.url.gsub(/https?:\/\//, '')
|
||||
terse.gsub!(/www\./, '')
|
||||
terse = terse.chop! if terse[-1, 1] == '/'
|
||||
terse
|
||||
end
|
||||
|
||||
def do_bad_things
|
||||
self.password_confirmation = self.password
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
<body id="hcard">
|
||||
<div id="wrap">
|
||||
<div id="core">
|
||||
<dl id="site_nav_local_views">
|
||||
<dt>Local views</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div id="content">
|
||||
<h1><%=@user.real_name%></h1>
|
||||
<div id="content_inner">
|
||||
|
|
@ -35,5 +28,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||
<hm:Host xmlns='http://host-meta.net/xrd/1.0'><%=@user.url%></hm:Host>
|
||||
<hm:Host><%= @user.terse_url %></hm:Host>
|
||||
<Link rel='lrdd'
|
||||
template='<%=@user.url%>webfinger/?q={uri}'>
|
||||
template='<%=@user.url%>webfinger?q={uri}'>
|
||||
<Title>Resource Descriptor</Title>
|
||||
</Link>
|
||||
</XRD>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
|
||||
<Subject>acct:<%=@user.email%></Subject>
|
||||
<Alias>http://www.identi.ca/user/169966</Alias>
|
||||
<Alias>"<%=@user.url%>hcard"</Alias>
|
||||
<Link rel="http://microformats.org/profile/hcard" type="text/html" href="<%=@user.url%>hcard"/>
|
||||
<Link rel="http://schemas.google.com/g/2010#updates-from" type="application/atom+xml" href="<%=@user.url%>status_messages.atom"/>
|
||||
<!--<Link rel="http://ostatus.org/schema/1.0/subscribe" template="http://identi.ca/main/ostatussub?profile={uri}"/>--!>
|
||||
</XRD>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
development:
|
||||
debug: false
|
||||
socket_port: 8080
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
||||
test:
|
||||
debug: false
|
||||
socket_port: 8081
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
||||
production:
|
||||
debug: false
|
||||
socket_port: 8080
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
|
|
|||
|
|
@ -57,15 +57,15 @@ module Diaspora
|
|||
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 = self.class.build_xml_for([self])
|
||||
@@queue.add_post_request( recipients, xml )
|
||||
|
||||
@@queue.add_hub_notification('http://pubsubhubbub.appspot.com/publish/', User.owner.url + self.class.to_s.pluralize.underscore )
|
||||
|
||||
@@queue.process
|
||||
end
|
||||
@@queue.process
|
||||
end
|
||||
|
||||
def push_to_url(url)
|
||||
|
|
@ -97,8 +97,6 @@ module Diaspora
|
|||
|
||||
module XML
|
||||
|
||||
OWNER = User.owner
|
||||
|
||||
def self.generate(opts= {})
|
||||
xml = Generate::headers(opts[:current_url])
|
||||
xml << Generate::author
|
||||
|
|
@ -110,10 +108,12 @@ module Diaspora
|
|||
|
||||
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="#{OWNER.url}">Diaspora</generator>
|
||||
<generator uri="http://joindiaspora.com/">Diaspora</generator>
|
||||
<id>#{current_url}</id>
|
||||
<title>Stream</title>
|
||||
<subtitle>its a stream </subtitle>
|
||||
|
|
@ -124,15 +124,15 @@ module Diaspora
|
|||
def self.author
|
||||
<<-XML
|
||||
<author>
|
||||
<name>#{OWNER.real_name}</name>
|
||||
<uri>#{OWNER.url}</uri>
|
||||
<name>#{@@user.real_name}</name>
|
||||
<uri>#{@@user.url}</uri>
|
||||
</author>
|
||||
XML
|
||||
end
|
||||
|
||||
def self.endpoints
|
||||
<<-XML
|
||||
<link href="http://pubsubhubbub.appspot.com/" rel="hub"/>
|
||||
<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
|
||||
XML
|
||||
end
|
||||
|
||||
|
|
@ -140,9 +140,9 @@ module Diaspora
|
|||
<<-XML
|
||||
<activity:subject>
|
||||
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
||||
<id>#{OWNER.url}</id>
|
||||
<title>#{OWNER.real_name}</title>
|
||||
<link rel="alternative" type="text/html" href="#{OWNER.url}"/>
|
||||
<id>#{@@user.url}</id>
|
||||
<title>#{@@user.real_name}</title>
|
||||
<link rel="alternative" type="text/html" href="#{@@user.url}"/>
|
||||
</activity:subject>
|
||||
XML
|
||||
end
|
||||
|
|
@ -164,15 +164,45 @@ module Diaspora
|
|||
def self.StatusMessage_build_entry(status_message)
|
||||
<<-XML
|
||||
<entry>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||
<title>#{status_message.message}</title>
|
||||
<link rel="alternate" type="text/html" href="#{OWNER.url}status_messages/#{status_message.id}"/>
|
||||
<id>#{OWNER.url}status_messages/#{status_message.id}</id>
|
||||
<link rel="alternate" type="text/html" href="#{@@user.url}status_messages/#{status_message.id}"/>
|
||||
<id>#{@@user.url}status_messages/#{status_message.id}</id>
|
||||
<published>#{status_message.created_at.xmlschema}</published>
|
||||
<updated>#{status_message.updated_at.xmlschema}</updated>
|
||||
</entry>
|
||||
XML
|
||||
end
|
||||
|
||||
def self.Bookmark_build_entry(bookmark)
|
||||
<<-XML
|
||||
<entry>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||
<title>#{bookmark.title}</title>
|
||||
<link rel="alternate" type="text/html" href="#{@@user.url}bookmarks/#{bookmark.id}"/>
|
||||
<link rel="related" type="text/html" href="#{bookmark.link}"/>
|
||||
<id>#{@@user.url}bookmarks/#{bookmark.id}</id>
|
||||
<published>#{bookmark.created_at.xmlschema}</published>
|
||||
<updated>#{bookmark.updated_at.xmlschema}</updated>
|
||||
</entry>
|
||||
XML
|
||||
end
|
||||
|
||||
|
||||
def self.Blog_build_entry(blog)
|
||||
<<-XML
|
||||
<entry>
|
||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||
<title>#{blog.title}</title>
|
||||
<content>#{blog.body}</content>
|
||||
<link rel="alternate" type="text/html" href="#{@@user.url}blogs/#{blog.id}"/>
|
||||
<id>#{@@user.url}blogs/#{blog.id}</id>
|
||||
<published>#{blog.created_at.xmlschema}</published>
|
||||
<updated>#{blog.updated_at.xmlschema}</updated>
|
||||
</entry>
|
||||
XML
|
||||
end
|
||||
|
||||
def self.footer
|
||||
<<-XML.strip
|
||||
</feed>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class MessageHandler
|
|||
http.callback {send_to_seed(query, http.response); process}
|
||||
when :pubhub
|
||||
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT
|
||||
http.callback { puts "boner city" + http.response ; process}
|
||||
http.callback { process}
|
||||
else
|
||||
raise "message is not a type I know!"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,4 +41,10 @@ describe User do
|
|||
@user.send_friend_request_to( @friend.url ).should be nil
|
||||
end
|
||||
|
||||
|
||||
it 'should be able to give me the terse url for webfinger' do
|
||||
user = Factory.create(:user)
|
||||
user.terse_url.should == 'example.com'
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue