added two helpers to handlebars for avatar images / links to people.

This commit is contained in:
danielgrippi 2012-02-25 19:18:32 -08:00
parent c5b30b39de
commit f70b290316
8 changed files with 46 additions and 39 deletions

View file

@ -4,4 +4,19 @@ Handlebars.registerHelper('t', function(scope, values) {
Handlebars.registerHelper('imageUrl', function(path){ Handlebars.registerHelper('imageUrl', function(path){
return app.baseImageUrl() + path; return app.baseImageUrl() + path;
}) })
Handlebars.registerHelper('linkToPerson', function(context, block) {
var html = "<a href=\"/people/" + context.guid + "\" class=\"author-name\">";
html+= block.fn(context);
html+= "</a>";
return html
})
Handlebars.registerHelper('avatar', function(person, size, imageClass) {
size = (typeof(size) != "string" ? "small" : size);
imageClass = (typeof(imageClass) != "string" ? size : imageClass);
return "<img src=\"" + person.avatar[size] +"\" class=\"avatar " + imageClass + "\" title=\"" + person.name +"\" />";
})

View file

@ -15,7 +15,7 @@
<div class="media new_comment_form_wrapper {{#unless comments_count}} hidden {{/unless}}"> <div class="media new_comment_form_wrapper {{#unless comments_count}} hidden {{/unless}}">
{{#with current_user}} {{#with current_user}}
<a href="/people/{{guid}}" class="img"> <a href="/people/{{guid}}" class="img">
<img src="{{avatar.small}}" class="avatar" /> {{{avatar this}}}
</a> </a>
{{/with}} {{/with}}

View file

@ -1,21 +1,19 @@
<div class="img"> <div class="img">
<a href="/people/{{author.guid}}" class="author-name"> {{#linkToPerson author}}
<img src="{{author.avatar.small}}" class="avatar smaller"/> {{{avatar this "small"}}}
</a> {{/linkToPerson}}
</div> </div>
<div class="bd"> <div class="bd">
<a href="/people/{{author.guid}}" class="author-name"> {{#linkToPerson author}}
{{author.name}} {{name}}
</a> {{/linkToPerson}}
{{#if root}} {{#if root}}
<i class="icon-retweet"></i> <i class="icon-retweet"></i>
{{#with root}} {{#linkToPerson root.author}}
<a href="/people/{{author.guid}}" class="author-name"> {{name}}
{{author.name}} {{/linkToPerson}}
</a>
{{/with}}
{{/if}} {{/if}}
<div class="post-time"> <div class="post-time">

View file

@ -1,13 +1,13 @@
<div class="img"> <div class="img">
<a href="/people/{{author.guid}}" class="author-name"> {{#linkToPerson author}}
<img src="{{author.avatar.small}}" class="avatar smaller"/> {{{avatar this "small"}}}
</a> {{/linkToPerson}}
</div> </div>
<div class="bd"> <div class="bd">
<a href="/people/{{author.guid}}" class="author-name"> {{#linkToPerson author}}
{{author.name}} {{name}}
</a> {{/linkToPerson}}
<div class="comment-content"> <div class="comment-content">
{{{text}}} {{{text}}}

View file

@ -6,11 +6,9 @@
</div> </div>
<div class="bd"> <div class="bd">
{{#each likes}} {{#each likes}}
{{#with author}} {{#linkToPerson author}}
<a href="/people/{{guid}}"> {{{avatar this "small" "micro"}}}
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ > {{/linkToPerson}}
</a>
{{/with}}
{{/each}} {{/each}}
</div> </div>
</div> </div>
@ -25,11 +23,9 @@
</div> </div>
<div class="bd"> <div class="bd">
{{#each participations}} {{#each participations}}
{{#with author}} {{#linkToPerson author}}
<a href="/people/{{guid}}"> {{{avatar this "small" "micro"}}}
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ > {{/linkToPerson}}
</a>
{{/with}}
{{/each}} {{/each}}
</div> </div>
</div> </div>
@ -44,11 +40,9 @@
</div> </div>
<div class="bd"> <div class="bd">
{{#each reshares}} {{#each reshares}}
{{#with author}} {{#linkToPerson author}}
<a href="/people/{{guid}}"> {{{avatar this "small" "micro"}}}
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ > {{/linkToPerson}}
</a>
{{/with}}
{{/each}} {{/each}}
</div> </div>
</div> </div>

View file

@ -19,7 +19,7 @@
{{#with author}} {{#with author}}
<a href="/people/{{guid}}" class="img"> <a href="/people/{{guid}}" class="img">
<img src="{{avatar.small}}" class="avatar" /> {{{avatar this}}}
</a> </a>
{{/with}} {{/with}}

View file

@ -1,5 +1,5 @@
{{#people}} {{#people}}
<a href="/people/{{guid}}"> {{#linkToPerson this}}
<img class="avatar" src="{{avatar.small}}" title="{{name}}"/> {{{avatar this "small"}}}
</a> {{/linkToPerson}}
{{/people}} {{/people}}

View file

@ -337,7 +337,7 @@ body.idle {
width: 20px; width: 20px;
} }
&.smaller { &.small {
height: 35px; height: 35px;
width: 35px; width: 35px;
} }