temp route for atom feed. also, public atom currently displays all posts.

This commit is contained in:
danielvincent 2010-09-27 18:34:47 -07:00
parent df800dc87e
commit 3b8ddf76a3
4 changed files with 20 additions and 7 deletions

View file

@ -4,7 +4,9 @@
class PublicsController < ApplicationController
require File.expand_path('../../../lib/diaspora/parser', __FILE__)
require File.expand_path('../../../lib/diaspora/ostatus_builder', __FILE__)
include Diaspora::Parser
include Diaspora::OstatusBuilder
layout false
def hcard
@ -40,4 +42,9 @@ class PublicsController < ApplicationController
@user.receive_salmon params[:xml]
end
def public
user = User.find_by_username(params[:username])
render :xml => Diaspora::OstatusBuilder::build(user)
end
end

View file

@ -32,6 +32,8 @@ Diaspora::Application.routes.draw do
match 'get_to_the_choppa', :to => redirect("/signup")
#public routes
#
match 'public/:username', :to => 'publics#public'
match 'webfinger', :to => 'publics#webfinger'
match 'hcard/users/:id', :to => 'publics#hcard'

View file

@ -5,7 +5,7 @@
module Diaspora
module OstatusBuilder
def build(user)
def self.build(user)
if @user = User.find_by_id(user.id)
xml = ""
xml << create_headers
@ -16,8 +16,8 @@ module Diaspora
else raise "Invalid user sent to builder" end
end
def create_headers
<<-XML
def self.create_headers
<<-XML.strip
<?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>
@ -32,13 +32,13 @@ module Diaspora
XML
end
def create_endpoints
def self.create_endpoints
<<-XML
<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
XML
end
def create_subject
def self.create_subject
<<-XML
<activity:subject>
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
@ -49,7 +49,7 @@ module Diaspora
XML
end
def create_body
def self.create_body
@user.raw_visible_posts.all.inject do |xml,curr|
if curr.respond_to?(:to_activity)
unless xml
@ -61,7 +61,7 @@ module Diaspora
end
end
def create_footer
def self.create_footer
<<-XML
</feed>
XML

View file

@ -14,5 +14,9 @@ describe Diaspora::OstatusBuilder do
let!(:atom) { Diaspora::OstatusBuilder::build(user) }
it 'should include a users posts' do
atom.should include status_message.message
end
end