diff --git a/app/views/templates/reshare.jst b/app/views/templates/reshare.jst index e5e6ecd79..7b297db7a 100644 --- a/app/views/templates/reshare.jst +++ b/app/views/templates/reshare.jst @@ -37,9 +37,7 @@ <% } %> <% } %> -
- <%= root.text %> -
+ <%= root.text %> <% if(o_embed_cache) { %> <%= root.o_embed_cache.posts.data.html %> diff --git a/app/views/templates/status_message.jst b/app/views/templates/status_message.jst index f22cde937..f05205a91 100644 --- a/app/views/templates/status_message.jst +++ b/app/views/templates/status_message.jst @@ -12,9 +12,7 @@ <% } %> <% } %> -- <%= text %> -
+<%= text %> <% if(o_embed_cache) { %> <%= o_embed_cache.posts.data.html %> diff --git a/config/assets.yml b/config/assets.yml index 573d3038a..c9a543c7d 100644 --- a/config/assets.yml +++ b/config/assets.yml @@ -10,6 +10,8 @@ javascripts: - public/javascripts/vendor/underscore.js - public/javascripts/vendor/backbone.js + - public/javascripts/vendor/markdown.js + - public/javascripts/app/app.js - public/javascripts/app/router.js - public/javascripts/app/views.js diff --git a/public/javascripts/app/views/post_content_view.js b/public/javascripts/app/views/post_content_view.js index 878d0c99d..cbff69067 100644 --- a/public/javascripts/app/views/post_content_view.js +++ b/public/javascripts/app/views/post_content_view.js @@ -1,11 +1,25 @@ -app.views.StatusMessage = app.views.StreamObject.extend({ - template_name : "#status-message-template" -}); +(function(){ + var postContentView = app.views.StreamObject.extend({ + presenter : function(){ + return _.extend(this.defaultPresenter(), { + text : markdown.toHTML(this.model.get("text") || "") + }) + }, + }) + + + app.views.StatusMessage = postContentView.extend({ + template_name : "#status-message-template" + }); + + app.views.Reshare = postContentView.extend({ + template_name : "#reshare-template" + }); + + app.views.ActivityStreams__Photo = postContentView.extend({ + template_name : "#activity-streams-photo-template" + }); +})(); + -app.views.Reshare = app.views.StreamObject.extend({ - template_name : "#reshare-template" -}); -app.views.ActivityStreams__Photo = app.views.StreamObject.extend({ - template_name : "#activity-streams-photo-template" -}); diff --git a/public/javascripts/app/views/post_view.js b/public/javascripts/app/views/post_view.js index fae53a95d..9468600d5 100644 --- a/public/javascripts/app/views/post_view.js +++ b/public/javascripts/app/views/post_view.js @@ -15,7 +15,8 @@ app.views.Post = app.views.StreamObject.extend({ subviews : { ".feedback" : "feedbackView", ".likes" : "likesInfoView", - ".comments" : "commentStreamView" + ".comments" : "commentStreamView", + ".post-content" : "postContentView" }, tooltips : [ @@ -45,24 +46,20 @@ app.views.Post = app.views.StreamObject.extend({ return this; }, - postRenderTemplate : function() { - this.renderPostContent() - .initializeTooltips() - .$("time").timeago(); - - return this; - }, - - renderPostContent: function(){ + postContentView: function(){ var normalizedClass = this.model.get("post_type").replace(/::/, "__"); var postClass = app.views[normalizedClass] || app.views.StatusMessage; - var postView = new postClass({ model : this.model }); + return new postClass({ model : this.model }); + }, - this.$(".post-content").html(postView.render().el); + postRenderTemplate : function() { + this.initializeTooltips(); + this.$("time").timeago(); return this; }, + removeNsfwShield: function(evt){ if(evt){ evt.preventDefault(); } diff --git a/spec/javascripts/app/views/post_view_spec.js b/spec/javascripts/app/views/post_view_spec.js index 235241bec..b0df21730 100644 --- a/spec/javascripts/app/views/post_view_spec.js +++ b/spec/javascripts/app/views/post_view_spec.js @@ -31,6 +31,13 @@ describe("app.views.Post", function(){ expect(view.$(".post_initial_info").html()).not.toContain("0 Reshares") }) + it("should markdownify the post's text", function(){ + this.statusMessage.set({text: "I have three Belly Buttons"}) + spyOn(window.markdown, "toHTML") + new app.views.Post({model : this.statusMessage}).render(); + expect(window.markdown.toHTML).toHaveBeenCalledWith("I have three Belly Buttons") + }) + context("user not signed in", function(){ it("does not provide a Feedback view", function(){ window.current_user = app.user(null); diff --git a/spec/javascripts/support/jasmine.yml b/spec/javascripts/support/jasmine.yml index fd307fb65..ad92fb19a 100644 --- a/spec/javascripts/support/jasmine.yml +++ b/spec/javascripts/support/jasmine.yml @@ -22,6 +22,7 @@ src_files: - public/javascripts/vendor/jquery.charcount.js - public/javascripts/vendor/timeago.js - public/javascripts/vendor/facebox.js + - public/javascripts/vendor/markdown.js - public/javascripts/jquery.infieldlabel-custom.js - public/javascripts/vendor/underscore.js - public/javascripts/vendor/backbone.js