diff --git a/public/javascripts/app/templates/stream-element.handlebars b/public/javascripts/app/templates/stream-element.handlebars
new file mode 100644
index 000000000..2169338b7
--- /dev/null
+++ b/public/javascripts/app/templates/stream-element.handlebars
@@ -0,0 +1,66 @@
+
+ {{#with author}}
+
+
+
+ {{/with}}
+
+
+
+
+
+ {{#with author}}
+
+ {{name}}
+
+ {{/with}}
+
+
+
+ -
+
+
+
+
+ {{#if reshares_count}}
+ -
+ {{t "stream.reshares" count=reshares_count}}
+ {{/if}}
+
+
+
+ {{#if nsfw}}
+
+
+ {{/if}}
+
+
+
+ {{#if nsfw}}
+
+ {{/if}}
+
+
+
+
+
+
diff --git a/public/javascripts/app/views/content_view.js b/public/javascripts/app/views/content_view.js
index 5f593bf3f..220f68ccf 100644
--- a/public/javascripts/app/views/content_view.js
+++ b/public/javascripts/app/views/content_view.js
@@ -3,7 +3,9 @@ app.views.Content = app.views.StreamObject.extend({
var model = this.model
return _.extend(this.defaultPresenter(), {
text : app.helpers.textFormatter(model),
- o_embed_html : embedHTML(model)
+ o_embed_html : embedHTML(model),
+ largePhoto : this.largePhoto(),
+ smallPhotos : this.smallPhotos()
})
function embedHTML(model){
@@ -15,12 +17,23 @@ app.views.Content = app.views.StreamObject.extend({
return data.html || ""
}
}
+ },
+
+ largePhoto : function() {
+ var photos = this.model.get("photos")
+ if(!photos || photos.length == 0) { return }
+ return photos[0]
+ },
+
+ smallPhotos : function() {
+ var photos = this.model.get("photos")
+ if(!photos || photos.length < 2) { return }
+ return photos.slice(1,8)
}
})
app.views.StatusMessage = app.views.Content.extend({
- legacyTemplate : true,
- template_name : "#status-message-template"
+ templateName : "status-message"
});
app.views.Reshare = app.views.Content.extend({
diff --git a/public/javascripts/app/views/post_view.js b/public/javascripts/app/views/post_view.js
index 1047382bc..6689e48ab 100644
--- a/public/javascripts/app/views/post_view.js
+++ b/public/javascripts/app/views/post_view.js
@@ -1,7 +1,5 @@
app.views.Post = app.views.StreamObject.extend({
- legacyTemplate : true,
-
- template_name: "#stream-element-template",
+ templateName: "stream-element",
className : "stream_element loaded",
@@ -48,6 +46,13 @@ app.views.Post = app.views.StreamObject.extend({
return new postClass({ model : this.model });
},
+ presenter : function() {
+ return _.extend(this.defaultPresenter(), {
+ authorIsCurrentUser : this.authorIsCurrentUser(),
+ nsfw : this.nsfw()
+ })
+ },
+
removeNsfwShield: function(evt){
if(evt){ evt.preventDefault(); }
@@ -97,5 +102,13 @@ app.views.Post = app.views.StreamObject.extend({
this.$(".comment_box").focus();
return this;
+ },
+
+ authorIsCurrentUser : function() {
+ return this.model.get("author").id != (!!app.user() && app.user().id)
+ },
+
+ nsfw : function() {
+ return this.model.get("text") !== null && this.model.get("text").match(/#nsfw/i)
}
});