markdown for posts on front end, tags broken
This commit is contained in:
parent
c3ea1dfc6e
commit
d2807b5202
7 changed files with 44 additions and 27 deletions
|
|
@ -37,9 +37,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<p class="collapsible">
|
<%= root.text %>
|
||||||
<%= root.text %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<% if(o_embed_cache) { %>
|
<% if(o_embed_cache) { %>
|
||||||
<%= root.o_embed_cache.posts.data.html %>
|
<%= root.o_embed_cache.posts.data.html %>
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<p class="collapsible">
|
<%= text %>
|
||||||
<%= text %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<% if(o_embed_cache) { %>
|
<% if(o_embed_cache) { %>
|
||||||
<%= o_embed_cache.posts.data.html %>
|
<%= o_embed_cache.posts.data.html %>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ javascripts:
|
||||||
- public/javascripts/vendor/underscore.js
|
- public/javascripts/vendor/underscore.js
|
||||||
- public/javascripts/vendor/backbone.js
|
- public/javascripts/vendor/backbone.js
|
||||||
|
|
||||||
|
- public/javascripts/vendor/markdown.js
|
||||||
|
|
||||||
- public/javascripts/app/app.js
|
- public/javascripts/app/app.js
|
||||||
- public/javascripts/app/router.js
|
- public/javascripts/app/router.js
|
||||||
- public/javascripts/app/views.js
|
- public/javascripts/app/views.js
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,25 @@
|
||||||
app.views.StatusMessage = app.views.StreamObject.extend({
|
(function(){
|
||||||
template_name : "#status-message-template"
|
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 : {
|
subviews : {
|
||||||
".feedback" : "feedbackView",
|
".feedback" : "feedbackView",
|
||||||
".likes" : "likesInfoView",
|
".likes" : "likesInfoView",
|
||||||
".comments" : "commentStreamView"
|
".comments" : "commentStreamView",
|
||||||
|
".post-content" : "postContentView"
|
||||||
},
|
},
|
||||||
|
|
||||||
tooltips : [
|
tooltips : [
|
||||||
|
|
@ -45,24 +46,20 @@ app.views.Post = app.views.StreamObject.extend({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
postRenderTemplate : function() {
|
postContentView: function(){
|
||||||
this.renderPostContent()
|
|
||||||
.initializeTooltips()
|
|
||||||
.$("time").timeago();
|
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
renderPostContent: function(){
|
|
||||||
var normalizedClass = this.model.get("post_type").replace(/::/, "__");
|
var normalizedClass = this.model.get("post_type").replace(/::/, "__");
|
||||||
var postClass = app.views[normalizedClass] || app.views.StatusMessage;
|
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;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
removeNsfwShield: function(evt){
|
removeNsfwShield: function(evt){
|
||||||
if(evt){ evt.preventDefault(); }
|
if(evt){ evt.preventDefault(); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,13 @@ describe("app.views.Post", function(){
|
||||||
expect(view.$(".post_initial_info").html()).not.toContain("0 Reshares")
|
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(){
|
context("user not signed in", function(){
|
||||||
it("does not provide a Feedback view", function(){
|
it("does not provide a Feedback view", function(){
|
||||||
window.current_user = app.user(null);
|
window.current_user = app.user(null);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ src_files:
|
||||||
- public/javascripts/vendor/jquery.charcount.js
|
- public/javascripts/vendor/jquery.charcount.js
|
||||||
- public/javascripts/vendor/timeago.js
|
- public/javascripts/vendor/timeago.js
|
||||||
- public/javascripts/vendor/facebox.js
|
- public/javascripts/vendor/facebox.js
|
||||||
|
- public/javascripts/vendor/markdown.js
|
||||||
- public/javascripts/jquery.infieldlabel-custom.js
|
- public/javascripts/jquery.infieldlabel-custom.js
|
||||||
- public/javascripts/vendor/underscore.js
|
- public/javascripts/vendor/underscore.js
|
||||||
- public/javascripts/vendor/backbone.js
|
- public/javascripts/vendor/backbone.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue