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
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
......
......@@ -80,6 +80,13 @@ class User < Person
def mine?(post)
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
......
<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">
<div id="i" class="entity_profile vcard author">
<h2>User profile</h2>
<dl class="entity_nickname">
<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>
<dd>
<a href="<%=@user.url%>" rel="me" class="nickname url uid"><%= @user.real_name%></a>
</dd>
</dl>
<dl class="entity_fn">
</dd>
</dl>
<dl class="entity_fn">
<dt>Full name</dt>
<dd>
<span class="fn"><%= @user.real_name %></span>
</dd>
</dl>
<dl class="entity_url">
</dd>
</dl>
<dl class="entity_url">
<dt>URL</dt>
<dd>
<a href="<%= @user.url%>" rel="me" class="url"><%= @user.url%></a>
</dd>
</dl>
<dl class="entity_note">
</dd>
</dl>
<dl class="entity_note">
<dt>Note</dt>
<dd class="note">Diaspora is awesome! vi is better than emacs!</dd>
</dl>
</dl>
</div>
</div>
</div>
</div>
</div>
</div>
<?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>
<?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>
</XRD>
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>
......
......@@ -2,7 +2,7 @@ class MessageHandler
NUM_TRIES = 3
TIMEOUT = 5 #seconds
def initialize
@queue = EM::Queue.new
end
......@@ -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
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