Skip to content
Extraits de code Groupes Projets
Valider bb4d5cad rédigé par Raphael's avatar Raphael
Parcourir les fichiers

Merge branch 'master' of github.com:diaspora/diaspora_rails

parents fa46fb31 b3bb9f8d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -3,6 +3,13 @@ class BlogsController < ApplicationController ...@@ -3,6 +3,13 @@ class BlogsController < ApplicationController
def index def index
@blogs = Blog.paginate :page => params[:page], :order => 'created_at DESC' @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 end
def show def show
......
...@@ -4,6 +4,12 @@ class BookmarksController < ApplicationController ...@@ -4,6 +4,12 @@ class BookmarksController < ApplicationController
def index def index
@bookmark = Bookmark.new @bookmark = Bookmark.new
@bookmarks = Bookmark.paginate :page => params[:page], :order => 'created_at DESC' @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 end
def edit def edit
......
...@@ -80,6 +80,13 @@ class User < Person ...@@ -80,6 +80,13 @@ class User < Person
def mine?(post) def mine?(post)
self == post.person self == post.person
end 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 def do_bad_things
self.password_confirmation = self.password self.password_confirmation = self.password
......
<body id="hcard"> <div id="content">
<div id="wrap"> <h1><%=@user.real_name%></h1>
<div id="core"> <div id="content_inner">
<dl id="site_nav_local_views"> <div id="i" class="entity_profile vcard author">
<dt>Local views</dt> <h2>User profile</h2>
<dd></dd> <dl class="entity_nickname">
</dl>
<div id="content">
<h1><%=@user.real_name%></h1>
<div id="content_inner">
<div id="i" class="entity_profile vcard author">
<h2>User profile</h2>
<dl class="entity_nickname">
<dt>Nickname</dt> <dt>Nickname</dt>
<dd> <dd>
<a href="<%=@user.url%>" rel="me" class="nickname url uid"><%= @user.real_name%></a> <a href="<%=@user.url%>" rel="me" class="nickname url uid"><%= @user.real_name%></a>
</dd> </dd>
</dl> </dl>
<dl class="entity_fn"> <dl class="entity_fn">
<dt>Full name</dt> <dt>Full name</dt>
<dd> <dd>
<span class="fn"><%= @user.real_name %></span> <span class="fn"><%= @user.real_name %></span>
</dd> </dd>
</dl> </dl>
<dl class="entity_url"> <dl class="entity_url">
<dt>URL</dt> <dt>URL</dt>
<dd> <dd>
<a href="<%= @user.url%>" rel="me" class="url"><%= @user.url%></a> <a href="<%= @user.url%>" rel="me" class="url"><%= @user.url%></a>
</dd> </dd>
</dl> </dl>
<dl class="entity_note"> <dl class="entity_note">
<dt>Note</dt> <dt>Note</dt>
<dd class="note">Diaspora is awesome! vi is better than emacs!</dd> <dd class="note">Diaspora is awesome! vi is better than emacs!</dd>
</dl> </dl>
</div>
</div>
</div> </div>
</div>
</div>
</div>
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0' <XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
xmlns:hm='http://host-meta.net/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' <Link rel='lrdd'
template='<%=@user.url%>webfinger/?q={uri}'> template='<%=@user.url%>webfinger?q={uri}'>
<Title>Resource Descriptor</Title> <Title>Resource Descriptor</Title>
</Link> </Link>
</XRD> </XRD>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"> <XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
<Subject>acct:<%=@user.email%></Subject> <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://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://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>
</XRD>
development: development:
debug: false debug: false
socket_port: 8080 socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'
test: test:
debug: false debug: false
socket_port: 8081 socket_port: 8081
pubsub_server: 'https://pubsubhubbub.appspot.com/'
production: production:
debug: false debug: false
socket_port: 8080 socket_port: 8080
pubsub_server: 'https://pubsubhubbub.appspot.com/'
...@@ -57,15 +57,15 @@ module Diaspora ...@@ -57,15 +57,15 @@ module Diaspora
end end
def push_to(recipients) 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? unless recipients.empty?
recipients.map!{|x| x = x.url + "receive/"} recipients.map!{|x| x = x.url + "receive/"}
xml = self.class.build_xml_for([self]) xml = self.class.build_xml_for([self])
@@queue.add_post_request( recipients, xml ) @@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 end
@@queue.process
end end
def push_to_url(url) def push_to_url(url)
...@@ -97,8 +97,6 @@ module Diaspora ...@@ -97,8 +97,6 @@ module Diaspora
module XML module XML
OWNER = User.owner
def self.generate(opts= {}) def self.generate(opts= {})
xml = Generate::headers(opts[:current_url]) xml = Generate::headers(opts[:current_url])
xml << Generate::author xml << Generate::author
...@@ -110,10 +108,12 @@ module Diaspora ...@@ -110,10 +108,12 @@ module Diaspora
module Generate module Generate
def self.headers(current_url) def self.headers(current_url)
#this is retarded
@@user = User.owner
<<-XML <<-XML
<?xml version="1.0" encoding="UTF-8"?> <?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/"> <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> <id>#{current_url}</id>
<title>Stream</title> <title>Stream</title>
<subtitle>its a stream </subtitle> <subtitle>its a stream </subtitle>
...@@ -124,15 +124,15 @@ module Diaspora ...@@ -124,15 +124,15 @@ module Diaspora
def self.author def self.author
<<-XML <<-XML
<author> <author>
<name>#{OWNER.real_name}</name> <name>#{@@user.real_name}</name>
<uri>#{OWNER.url}</uri> <uri>#{@@user.url}</uri>
</author> </author>
XML XML
end end
def self.endpoints def self.endpoints
<<-XML <<-XML
<link href="http://pubsubhubbub.appspot.com/" rel="hub"/> <link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
XML XML
end end
...@@ -140,9 +140,9 @@ module Diaspora ...@@ -140,9 +140,9 @@ module Diaspora
<<-XML <<-XML
<activity:subject> <activity:subject>
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type> <activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
<id>#{OWNER.url}</id> <id>#{@@user.url}</id>
<title>#{OWNER.real_name}</title> <title>#{@@user.real_name}</title>
<link rel="alternative" type="text/html" href="#{OWNER.url}"/> <link rel="alternative" type="text/html" href="#{@@user.url}"/>
</activity:subject> </activity:subject>
XML XML
end end
...@@ -164,15 +164,45 @@ module Diaspora ...@@ -164,15 +164,45 @@ module Diaspora
def self.StatusMessage_build_entry(status_message) def self.StatusMessage_build_entry(status_message)
<<-XML <<-XML
<entry> <entry>
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
<title>#{status_message.message}</title> <title>#{status_message.message}</title>
<link rel="alternate" type="text/html" href="#{OWNER.url}status_messages/#{status_message.id}"/> <link rel="alternate" type="text/html" href="#{@@user.url}status_messages/#{status_message.id}"/>
<id>#{OWNER.url}status_messages/#{status_message.id}</id> <id>#{@@user.url}status_messages/#{status_message.id}</id>
<published>#{status_message.created_at.xmlschema}</published> <published>#{status_message.created_at.xmlschema}</published>
<updated>#{status_message.updated_at.xmlschema}</updated> <updated>#{status_message.updated_at.xmlschema}</updated>
</entry> </entry>
XML XML
end 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 def self.footer
<<-XML.strip <<-XML.strip
</feed> </feed>
......
...@@ -2,7 +2,7 @@ class MessageHandler ...@@ -2,7 +2,7 @@ class MessageHandler
NUM_TRIES = 3 NUM_TRIES = 3
TIMEOUT = 5 #seconds TIMEOUT = 5 #seconds
def initialize def initialize
@queue = EM::Queue.new @queue = EM::Queue.new
end end
...@@ -32,7 +32,7 @@ class MessageHandler ...@@ -32,7 +32,7 @@ class MessageHandler
http.callback {send_to_seed(query, http.response); process} http.callback {send_to_seed(query, http.response); process}
when :pubhub when :pubhub
http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT http = EventMachine::PubSubHubbub.new(query.destination).publish query.body, :timeout => TIMEOUT
http.callback { puts "boner city" + http.response ; process} http.callback { process}
else else
raise "message is not a type I know!" raise "message is not a type I know!"
end end
......
...@@ -41,4 +41,10 @@ describe User do ...@@ -41,4 +41,10 @@ describe User do
@user.send_friend_request_to( @friend.url ).should be nil @user.send_friend_request_to( @friend.url ).should be nil
end 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 end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter