Commit d2807b52 authored by danielgrippi's avatar danielgrippi Committed by Dennis Collinson

markdown for posts on front end, tags broken

parent c3ea1dfc
......@@ -37,9 +37,7 @@
<% } %>
<% } %>
<p class="collapsible">
<%= root.text %>
</p>
<%= root.text %>
<% if(o_embed_cache) { %>
<%= root.o_embed_cache.posts.data.html %>
......
......@@ -12,9 +12,7 @@
<% } %>
<% } %>
<p class="collapsible">
<%= text %>
</p>
<%= text %>
<% if(o_embed_cache) { %>
<%= o_embed_cache.posts.data.html %>
......
......@@ -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
......
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"
});
......@@ -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(); }
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment