diff --git a/app/models/photo.rb b/app/models/photo.rb index 759e12924..80d37327e 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -8,6 +8,20 @@ class Photo < 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 :created_at + t.add :author + t.add lambda { |photo| + { :small => photo.url(:thumb_small), + :medium => photo.url(:thumb_medium), + :large => photo.url(:scaled_full) } + }, :as => :sizes + end + mount_uploader :processed_image, ProcessedImage mount_uploader :unprocessed_image, UnprocessedImage diff --git a/app/models/post.rb b/app/models/post.rb index 4666fd923..5699ac19e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -25,11 +25,13 @@ class Post < ActiveRecord::Base t.add :provider_display_name t.add :author t.add :post_type + t.add :photos_count t.add :image_url t.add :object_url t.add :root t.add :o_embed_cache t.add :user_like + t.add :photos end xml_attr :provider_display_name diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 6057f6c0f..f8a172425 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -40,6 +40,10 @@ class StatusMessage < Post joins(:likes).where(:likes => {:author_id => person.id}) } + def photos_count + self.photos.size + end + def self.guids_for_author(person) Post.connection.select_values(Post.where(:author_id => person.id).select('posts.guid').to_sql) end diff --git a/app/views/templates/reshare.ujs b/app/views/templates/reshare.ujs index 04308a946..aef86c767 100644 --- a/app/views/templates/reshare.ujs +++ b/app/views/templates/reshare.ujs @@ -22,10 +22,25 @@ + <% if(root.photos_count > 0) { %> +
<% } else { %> diff --git a/app/views/templates/status_message.ujs b/app/views/templates/status_message.ujs index 6d7c40ef7..bda05eab3 100644 --- a/app/views/templates/status_message.ujs +++ b/app/views/templates/status_message.ujs @@ -1,3 +1,13 @@ +<% if(photos_count > 0) { %> +