diff --git a/app/models/aspect.rb b/app/models/aspect.rb index c87d60c93..a1241b5d6 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -11,7 +11,7 @@ class Aspect < ActiveRecord::Base has_many :aspect_visibilities has_many :posts, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Post' has_many :photos, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Photo' - + validates :name, :presence => true, :length => { :maximum => 20 } validates_uniqueness_of :name, :scope => :user_id, :case_sensitive => false diff --git a/app/models/comment.rb b/app/models/comment.rb index e3b6cfcae..63e46cb19 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -22,7 +22,7 @@ class Comment < ActiveRecord::Base t.add :id t.add :guid t.add :text - t.add :author, :template => :post + t.add :author end diff --git a/app/models/person.rb b/app/models/person.rb index cd914166d..ad66a4dfc 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -12,7 +12,7 @@ class Person < ActiveRecord::Base # NOTE API V1 to be extracted acts_as_api - api_accessible :post do |t| + api_accessible :backbone do |t| t.add :id t.add :name t.add lambda { |person| diff --git a/app/models/post.rb b/app/models/post.rb index 8a1af1210..9780e88b6 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -19,7 +19,7 @@ class Post < ActiveRecord::Base t.add :comments_count t.add :last_three_comments t.add :provider_display_name - t.add :author, :template => :post + t.add :author end xml_attr :provider_display_name diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 72fb456b6..7deaa9ecc 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -60,7 +60,7 @@ - if @person %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 - flash.each do |name, msg| diff --git a/public/javascripts/models/post.js b/public/javascripts/models/post.js index 5ed8a9ada..316b08d0b 100644 --- a/public/javascripts/models/post.js +++ b/public/javascripts/models/post.js @@ -2,5 +2,10 @@ var Post = Backbone.Model.extend({ url: "/posts/:id", intTime: function(){ 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"))); } });