add api block to photo; photos display in stream
This commit is contained in:
parent
6911ed5d7d
commit
841cc29d25
5 changed files with 45 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -22,10 +22,25 @@
|
|||
</div>
|
||||
|
||||
<!-- duplicate from statusmessage partial -->
|
||||
<% if(root.photos_count > 0) { %>
|
||||
<div class="photo_attachments">
|
||||
<img src="<%= root.photos[0].sizes.large %>" class="stream-photo big_stream_photo">
|
||||
<% for(photo in root.photos) {
|
||||
if(photo == 0){ continue; }
|
||||
if(photo == 8){ break; } %>
|
||||
<img src="<%= root.photos[photo].sizes.small %>" class="stream-photo thumb_small">
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<p>
|
||||
<%= root.text %>
|
||||
</p>
|
||||
|
||||
<% if(o_embed_cache) { %>
|
||||
<%= root.o_embed_cache.posts.data.html %>
|
||||
<% } %>
|
||||
<!-- end duplication -->
|
||||
|
||||
</div>
|
||||
|
||||
<% } else { %>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,13 @@
|
|||
<% if(photos_count > 0) { %>
|
||||
<div class="photo_attachments">
|
||||
<img src="<%= photos[0].sizes.large %>" class="stream-photo big_stream_photo">
|
||||
<% for(photo in photos) {
|
||||
if(photo == 0){ continue; }
|
||||
if(photo == 8){ break; } %>
|
||||
<img src="<%= photos[photo].sizes.small %>" class="stream-photo thumb_small">
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
<p>
|
||||
<%= text %>
|
||||
</p>
|
||||
|
|
|
|||
Loading…
Reference in a new issue