serialize current user json into body tag for now

This commit is contained in:
Daniel Grippi 2011-11-30 18:24:05 -08:00 committed by Dennis Collinson
parent 19db5519c0
commit 176963fdad
6 changed files with 10 additions and 5 deletions

View file

@ -22,7 +22,7 @@ class Comment < ActiveRecord::Base
t.add :id t.add :id
t.add :guid t.add :guid
t.add :text t.add :text
t.add :author, :template => :post t.add :author
end end

View file

@ -12,7 +12,7 @@ class Person < ActiveRecord::Base
# NOTE API V1 to be extracted # NOTE API V1 to be extracted
acts_as_api acts_as_api
api_accessible :post do |t| api_accessible :backbone do |t|
t.add :id t.add :id
t.add :name t.add :name
t.add lambda { |person| t.add lambda { |person|

View file

@ -19,7 +19,7 @@ class Post < ActiveRecord::Base
t.add :comments_count t.add :comments_count
t.add :last_three_comments t.add :last_three_comments
t.add :provider_display_name t.add :provider_display_name
t.add :author, :template => :post t.add :author
end end
xml_attr :provider_display_name xml_attr :provider_display_name

View file

@ -60,7 +60,7 @@
- if @person - if @person
%link{:rel => "alternate", :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => @person.name)}"} %link{:rel => "alternate", :href => "#{@person.public_url}.atom", :type => "application/atom+xml", :title => "#{t('.public_feed', :name => @person.name)}"}
%body{:class => "#{yield(:body_class)}"} %body{:class => "#{yield(:body_class)}", 'data-current-user-metadata' => CGI::escape(current_user.person.as_api_response(:backbone).to_json) }
- unless @page == :logged_out - unless @page == :logged_out
- flash.each do |name, msg| - flash.each do |name, msg|

View file

@ -2,5 +2,10 @@ var Post = Backbone.Model.extend({
url: "/posts/:id", url: "/posts/:id",
intTime: function(){ intTime: function(){
return +new Date(this.get("created_at")) / 1000; return +new Date(this.get("created_at")) / 1000;
},
// should be moved into the view or something?
currentUserJSON: function(){
return $.parseJSON(unescape($("body").data("current-user-metadata")));
} }
}); });