Commit 91ba6447 authored by danielgrippi's avatar danielgrippi Committed by Dennis Collinson

add acts_as_api to the models directly for now. the 'root node' problem...

add acts_as_api to the models directly for now.  the 'root node' problem (posts : {}) breaks backbone.  wip
parent 2a133817
......@@ -73,6 +73,7 @@ gem 'jammit', '0.6.5'
gem 'json', '1.5.2'
gem 'vanna', :git => 'git://github.com/MikeSofaer/vanna.git'
gem 'acts_as_api'
# localization
......
......@@ -85,6 +85,10 @@ GEM
activemodel (= 3.0.11)
activesupport (= 3.0.11)
activesupport (3.0.11)
acts_as_api (0.3.11)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
rack (>= 1.1.0)
addressable (2.2.4)
archive-tar-minitar (0.5.2)
arel (2.0.10)
......@@ -450,6 +454,7 @@ DEPENDENCIES
SystemTimer (= 1.2.3)
activerecord-import
acts-as-taggable-on!
acts_as_api
addressable (= 2.2.4)
bundler (>= 1.0.0)
capistrano (~> 2.9.0)
......
......@@ -13,7 +13,8 @@ class MultisController < ApplicationController
respond_with do |format|
format.html{ default_stream_action(Stream::Multi) }
format.json{ render :json => stream(Stream::Multi).stream_posts.to_json(:include => {:author => {:include => :profile}}) }
#format.json{ render :json => stream(Stream::Multi).stream_posts.to_json(:include => {:author => {:include => :profile}}) }
format.json{ render_for_api :backbone, :json => stream(Stream::Multi).stream_posts }
end
end
end
......@@ -10,13 +10,25 @@ class Person < ActiveRecord::Base
include Encryptor::Public
include Diaspora::Guid
# NOTE API V1 to be extracted
acts_as_api
api_accessible :post do |t|
t.add :id
t.add :name
t.add lambda { |person|
{:small => person.profile.image_url(:small),
:medium => person.profile.image_url(:medium),
:large => person.profile.image_url(:large) }
}, :as => :avatar
end
xml_attr :diaspora_handle
xml_attr :url
xml_attr :profile, :as => Profile
xml_attr :exported_key
has_one :profile, :dependent => :destroy
delegate :last_name, :to => :profile
delegate :last_name, :image_url, :to => :profile
accepts_nested_attributes_for :profile
before_validation :downcase_diaspora_handle
......
......@@ -9,6 +9,16 @@ class Post < ActiveRecord::Base
include Diaspora::Commentable
include Diaspora::Shareable
# NOTE API V1 to be extracted
acts_as_api
api_accessible :backbone do |t|
t.add :id
t.add :guid
t.add :text
t.add :created_at
t.add :author, :template => :post
end
xml_attr :provider_display_name
has_many :mentions, :dependent => :destroy
......
......@@ -29,10 +29,10 @@ class Profile < ActiveRecord::Base
before_save :strip_names
after_validation :strip_names
validates :first_name, :length => { :maximum => 32 }
validates :last_name, :length => { :maximum => 32 }
validates_format_of :first_name, :with => /\A[^;]+\z/, :allow_blank => true
validates_format_of :last_name, :with => /\A[^;]+\z/, :allow_blank => true
validate :max_tags
......
<% var post = typeof(status_message) === "undefined" ? (typeof(reshare) === "undefined" ? photo : reshare) : status_message; %>
<div id="<%= post.guid %>" class="stream_element">
<div id="<%= guid %>" class="stream_element">
<div class="right controls">
<a href="#" class="block_user control_icon">
<img src="/images/icons/ignoreuser.png">
......@@ -15,32 +13,32 @@
<div class="sm_body">
<a href="/people/<%= post.author.id %>">
<img src="<%= post.author.profile.image_url_small %>" class="avatar" data-person-id="<%= post.author.id %>"/>
<a href="/people/<%= author.id %>">
<img src="<%= author.profile.image_url_small %>" class="avatar" data-person-id="<%= post.author.id %>"/>
</a>
<div class="content">
<div class="post_initial_info">
<span class="from">
<a href="/people/<%= post.author.id %>">
<%= post.author.profile.full_name %>
<a href="/people/<%= author.id %>">
<%= author.profile.full_name %>
</a>
</span>
<span class="details">
-
<a href="/posts/<%= post.id %>">
<time class="timeago" datetime="<%= post.created_at %>"/>
<a href="/posts/<%= id %>">
<time class="timeago" datetime="<%= created_at %>"/>
</a>
</span>
<p>
<%= post.text %>
<%= text %>
</p>
<div class="info">
<span class="via">
via <%= post.provider_display_name %>
via <%= provider_display_name %>
</span>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment