Skip to content

Commit

Permalink
fix markup display on reshares. DERP. [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgrippi committed Feb 6, 2012
1 parent f830768 commit fa54246
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
8 changes: 1 addition & 7 deletions app/models/post.rb
Expand Up @@ -35,13 +35,7 @@ class Post < ActiveRecord::Base
t.add :o_embed_cache t.add :o_embed_cache
t.add :user_like t.add :user_like
t.add :mentioned_people t.add :mentioned_people
t.add lambda { |post| t.add :photos
if post.respond_to?(:photos)
post.photos
else
[]
end
}, :as => :photos
end end


xml_attr :provider_display_name xml_attr :provider_display_name
Expand Down
4 changes: 4 additions & 0 deletions app/models/reshare.rb
Expand Up @@ -41,6 +41,10 @@ def mentioned_people
self.root ? root.mentioned_people : super self.root ? root.mentioned_people : super
end end


def photos
self.root ? root.photos : super
end

def receive(recipient, sender) def receive(recipient, sender)
local_reshare = Reshare.where(:guid => self.guid).first local_reshare = Reshare.where(:guid => self.guid).first
if local_reshare && local_reshare.root.author_id == recipient.person.id if local_reshare && local_reshare.root.author_id == recipient.person.id
Expand Down
8 changes: 4 additions & 4 deletions public/javascripts/app/templates/reshare.handlebars
Expand Up @@ -27,12 +27,12 @@
{{t "stream.reshares" count=reshares_count}} {{t "stream.reshares" count=reshares_count}}
{{/if}} {{/if}}
</div> </div>

{{> status-message}}

</div>
{{/with}} {{/with}}


{{> status-message}}

</div>

{{else}} {{else}}


<p> <p>
Expand Down
26 changes: 9 additions & 17 deletions public/javascripts/app/views/content_view.js
@@ -1,12 +1,10 @@
app.views.Content = app.views.StreamObject.extend({ app.views.Content = app.views.StreamObject.extend({
presenter : function(model){ presenter : function(){
var model = model || this.model

return _.extend(this.defaultPresenter(), { return _.extend(this.defaultPresenter(), {
text : app.helpers.textFormatter(model), text : app.helpers.textFormatter(this.model),
o_embed_html : embedHTML(model), o_embed_html : embedHTML(this.model),
largePhoto : this.largePhoto(model), largePhoto : this.largePhoto(),
smallPhotos : this.smallPhotos(model) smallPhotos : this.smallPhotos()
}) })


function embedHTML(model){ function embedHTML(model){
Expand All @@ -20,22 +18,16 @@ app.views.Content = app.views.StreamObject.extend({
} }
}, },


largePhoto : function(model) { largePhoto : function() {
var photos = model.get("photos") var photos = this.model.get("photos")
if(!photos || photos.length == 0) { return } if(!photos || photos.length == 0) { return }
return photos[0] return photos[0]
}, },


smallPhotos : function(model) { smallPhotos : function() {
var photos = model.get("photos") var photos = this.model.get("photos")
if(!photos || photos.length < 2) { return } if(!photos || photos.length < 2) { return }
return photos.slice(1,8) return photos.slice(1,8)
},

// should be a private function in this.presenter()
rootPresenter : function(model) {
if(!model || !model.get("root")) { return }
return this.presenter(new app.models.Post(model.get("root")))
} }
}) })


Expand Down

0 comments on commit fa54246

Please sign in to comment.