replace two more underscore templates with handlebar counterparts [ci skip]

This commit is contained in:
danielgrippi 2012-02-05 13:40:34 -08:00
parent 5a72f868d3
commit 36e5ca431f
6 changed files with 118 additions and 86 deletions

View file

@ -1,18 +0,0 @@
<% if(photos.length > 0) { %>
<div class="photo_attachments">
<a href="#" class="stream-photo-link">
<img src="<%= photos[0].sizes.large %>" class="stream-photo big_stream_photo" data-small-photo="<%= photos[0].sizes.small %>" data-full-photo="<%= photos[0].sizes.large %>" rel="lightbox">
</a>
<% for(photo in photos) {
if(photo == 0){ continue; }
if(photo == 8){ break; } %>
<a href="#" class="stream-photo-link">
<img src="<%= photos[photo].sizes.small %>" class="stream-photo thumb_small" data-small-photo="<%= photos[photo].sizes.small %>" data-full-photo="<%= photos[photo].sizes.large %>" rel="lightbox">
</a>
<% } %>
<% } %>
<div class="collapsible">
<%= text %>
<%= o_embed_html %>
</div>

View file

@ -1,62 +0,0 @@
<div class="right controls">
<% if(author.id != (!!current_user && current_user.id)) { %>
<a href="#" rel=nofollow>
<img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title= "<%= Diaspora.I18n.t('ignore') %>" />
<img src="/images/deletelabel.png" class="delete control_icon hide_post" title="<%= Diaspora.I18n.t('stream.hide') %>" />
</a>
<% } else { %>
<a href="#" rel=nofollow>
<img src="/images/deletelabel.png" class="delete control_icon remove_post" title="<%= Diaspora.I18n.t('delete') %>" />
</a>
<% } %>
</div>
<div class="sm_body">
<a href="/people/<%= author.guid %>">
<img src="<%= author.avatar.small %>" class="avatar" />
</a>
<div class="content">
<div class="post_initial_info">
<span class="from">
<a href="/people/<%= author.guid %>">
<%= author.name %>
</a>
</span>
<span class="details">
-
<a href="/posts/<%= id %>">
<time class="timeago" datetime="<%= created_at %>"/>
</a>
<% if(reshares_count) { %>
-
<%= Diaspora.I18n.t("stream.reshares", {count : reshares_count}) %>
<% } %>
</span>
</div>
<% if(text !== null && text.match(/#nsfw/i)) { %>
<div class="shield_wrapper">
<div class="shield">
<%= Diaspora.I18n.t('stream.nsfw') %>
<a href="#">
<%= Diaspora.I18n.t('stream.show') %>
</a>
</div>
<% } %>
<div class="post-content"> </div>
<% if(text !== null && text.match(/#nsfw/)) { %>
</div>
<% } %>
<div class="feedback"> </div>
<div class="likes"> </div>
<div class="comments"> </div>
</div>

View file

@ -0,0 +1,20 @@
{{#if photos.length}}
<div class="photo_attachments">
<a href="#" class="stream-photo-link">
{{#with largePhoto}}
<img src="{{sizes.large}}" class="stream-photo big_stream_photo" data-small-photo="{{sizes.small}}" data-full-photo="{{sizes.large}}" rel="lightbox">
{{/with}}
</a>
{{#each smallPhotos}}
<a href="#" class="stream-photo-link">
<img src="{{sizes.small}}" class="stream-photo thumb_small" data-small-photo="{{sizes.small}}" data-full-photo="{{sizes.large}}" rel="lightbox">
</a>
{{/each}}
{{/if}}
<div class="collapsible">
{{{text}}}
{{{o_embed_html}}}
</div>

View file

@ -0,0 +1,66 @@
<div class="right controls">
{{#if authorIsCurrentUser}}
<a href="#" rel=nofollow>
<img src="/images/icons/ignoreuser.png" alt="Ignoreuser" class="block_user control_icon" title="{{t "ignore"}}" />
<img src="/images/deletelabel.png" class="delete control_icon hide_post" title="{{t "stream.hide"}}" />
</a>
{{else}}
<a href="#" rel=nofollow>
<img src="/images/deletelabel.png" class="delete control_icon remove_post" title="{{t "delete"}}" />
</a>
{{/if}}
</div>
<div class="sm_body">
{{#with author}}
<a href="/people/{{guid}}">
<img src="{{avatar.small}}" class="avatar" />
</a>
{{/with}}
<div class="content">
<div class="post_initial_info">
<span class="from">
{{#with author}}
<a href="/people/{{guid}}">
{{name}}
</a>
{{/with}}
</span>
<span class="details">
-
<a href="/posts/{{id}}">
<time class="timeago" datetime="{{created_at}}" />
</a>
{{#if reshares_count}}
-
{{t "stream.reshares" count=reshares_count}}
{{/if}}
</span>
</div>
{{#if nsfw}}
<div class="shield_wrapper">
<div class="shield">
{{t "stream.nsfw"}}
<a href="#">
{{t "stream.show"}}
</a>
</div>
{{/if}}
<div class="post-content"> </div>
{{#if nsfw}}
</div>
{{/if}}
<div class="feedback"> </div>
<div class="likes"> </div>
<div class="comments"> </div>
</div>

View file

@ -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({

View file

@ -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)
}
});