diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 27a5c8690..4a548de06 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -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 diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index 2f62d5cd3..1c7b8d986 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 952fa67b3..4c22fcabd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/publics/hcard.erb b/app/views/publics/hcard.erb index e544a8592..34f88866e 100644 --- a/app/views/publics/hcard.erb +++ b/app/views/publics/hcard.erb @@ -1,39 +1,30 @@ - -
-
- -
-

<%=@user.real_name%>

-
-
-

User profile

-
+
+

<%=@user.real_name%>

+
+
+

User profile

+
Nickname
<%= @user.real_name%> -
-
-
+ +
+
Full name
<%= @user.real_name %> -
-
-
+ +
+
URL
<%= @user.url%> -
-
-
+ +
+
Note
Diaspora is awesome! vi is better than emacs!
-
+
+
+
-
-
- - diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb index 3b6280e5c..53d8aeba4 100644 --- a/app/views/publics/host_meta.erb +++ b/app/views/publics/host_meta.erb @@ -1,9 +1,9 @@ - <%=@user.url%> + <%= @user.terse_url %> + template='<%=@user.url%>webfinger?q={uri}'> Resource Descriptor diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index e2f20467f..8ad41e0e7 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,10 +1,7 @@ acct:<%=@user.email%> - http://www.identi.ca/user/169966 + "<%=@user.url%>hcard" - - - - + diff --git a/config/app_config.yml b/config/app_config.yml index 526feac11..0c87b6b4c 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -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/' diff --git a/lib/common.rb b/lib/common.rb index 652e140b5..f2fb5c29a 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -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 -Diaspora +Diaspora #{current_url} Stream its a stream @@ -124,15 +124,15 @@ module Diaspora def self.author <<-XML -#{OWNER.real_name} -#{OWNER.url} +#{@@user.real_name} +#{@@user.url} XML end def self.endpoints <<-XML - + XML end @@ -140,9 +140,9 @@ module Diaspora <<-XML http://activitystrea.ms/schema/1.0/person -#{OWNER.url} -#{OWNER.real_name} - +#{@@user.url} +#{@@user.real_name} + XML end @@ -164,15 +164,45 @@ module Diaspora def self.StatusMessage_build_entry(status_message) <<-XML +http://activitystrea.ms/schema/1.0/post #{status_message.message} - -#{OWNER.url}status_messages/#{status_message.id} + +#{@@user.url}status_messages/#{status_message.id} #{status_message.created_at.xmlschema} #{status_message.updated_at.xmlschema} XML end + def self.Bookmark_build_entry(bookmark) + <<-XML + +http://activitystrea.ms/schema/1.0/post +#{bookmark.title} + + +#{@@user.url}bookmarks/#{bookmark.id} +#{bookmark.created_at.xmlschema} +#{bookmark.updated_at.xmlschema} + + XML + end + + + def self.Blog_build_entry(blog) + <<-XML + +http://activitystrea.ms/schema/1.0/post +#{blog.title} +#{blog.body} + +#{@@user.url}blogs/#{blog.id} +#{blog.created_at.xmlschema} +#{blog.updated_at.xmlschema} + + XML + end + def self.footer <<-XML.strip diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 95c6eb650..641627383 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8c0f1cf7b..854cde20b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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