added two helpers to handlebars for avatar images / links to people.
This commit is contained in:
parent
c5b30b39de
commit
f70b290316
8 changed files with 46 additions and 39 deletions
|
|
@ -4,4 +4,19 @@ Handlebars.registerHelper('t', function(scope, values) {
|
|||
|
||||
Handlebars.registerHelper('imageUrl', function(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 +"\" />";
|
||||
})
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<div class="media new_comment_form_wrapper {{#unless comments_count}} hidden {{/unless}}">
|
||||
{{#with current_user}}
|
||||
<a href="/people/{{guid}}" class="img">
|
||||
<img src="{{avatar.small}}" class="avatar" />
|
||||
{{{avatar this}}}
|
||||
</a>
|
||||
{{/with}}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
<div class="img">
|
||||
<a href="/people/{{author.guid}}" class="author-name">
|
||||
<img src="{{author.avatar.small}}" class="avatar smaller"/>
|
||||
</a>
|
||||
{{#linkToPerson author}}
|
||||
{{{avatar this "small"}}}
|
||||
{{/linkToPerson}}
|
||||
</div>
|
||||
|
||||
<div class="bd">
|
||||
<a href="/people/{{author.guid}}" class="author-name">
|
||||
{{author.name}}
|
||||
</a>
|
||||
{{#linkToPerson author}}
|
||||
{{name}}
|
||||
{{/linkToPerson}}
|
||||
|
||||
{{#if root}}
|
||||
<i class="icon-retweet"></i>
|
||||
{{#with root}}
|
||||
<a href="/people/{{author.guid}}" class="author-name">
|
||||
{{author.name}}
|
||||
</a>
|
||||
{{/with}}
|
||||
{{#linkToPerson root.author}}
|
||||
{{name}}
|
||||
{{/linkToPerson}}
|
||||
{{/if}}
|
||||
|
||||
<div class="post-time">
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
<div class="img">
|
||||
<a href="/people/{{author.guid}}" class="author-name">
|
||||
<img src="{{author.avatar.small}}" class="avatar smaller"/>
|
||||
</a>
|
||||
{{#linkToPerson author}}
|
||||
{{{avatar this "small"}}}
|
||||
{{/linkToPerson}}
|
||||
</div>
|
||||
|
||||
<div class="bd">
|
||||
<a href="/people/{{author.guid}}" class="author-name">
|
||||
{{author.name}}
|
||||
</a>
|
||||
{{#linkToPerson author}}
|
||||
{{name}}
|
||||
{{/linkToPerson}}
|
||||
|
||||
<div class="comment-content">
|
||||
{{{text}}}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
</div>
|
||||
<div class="bd">
|
||||
{{#each likes}}
|
||||
{{#with author}}
|
||||
<a href="/people/{{guid}}">
|
||||
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ >
|
||||
</a>
|
||||
{{/with}}
|
||||
{{#linkToPerson author}}
|
||||
{{{avatar this "small" "micro"}}}
|
||||
{{/linkToPerson}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -25,11 +23,9 @@
|
|||
</div>
|
||||
<div class="bd">
|
||||
{{#each participations}}
|
||||
{{#with author}}
|
||||
<a href="/people/{{guid}}">
|
||||
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ >
|
||||
</a>
|
||||
{{/with}}
|
||||
{{#linkToPerson author}}
|
||||
{{{avatar this "small" "micro"}}}
|
||||
{{/linkToPerson}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -44,11 +40,9 @@
|
|||
</div>
|
||||
<div class="bd">
|
||||
{{#each reshares}}
|
||||
{{#with author}}
|
||||
<a href="/people/{{guid}}">
|
||||
<img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/ >
|
||||
</a>
|
||||
{{/with}}
|
||||
{{#linkToPerson author}}
|
||||
{{{avatar this "small" "micro"}}}
|
||||
{{/linkToPerson}}
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
{{#with author}}
|
||||
<a href="/people/{{guid}}" class="img">
|
||||
<img src="{{avatar.small}}" class="avatar" />
|
||||
{{{avatar this}}}
|
||||
</a>
|
||||
{{/with}}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{{#people}}
|
||||
<a href="/people/{{guid}}">
|
||||
<img class="avatar" src="{{avatar.small}}" title="{{name}}"/>
|
||||
</a>
|
||||
{{#linkToPerson this}}
|
||||
{{{avatar this "small"}}}
|
||||
{{/linkToPerson}}
|
||||
{{/people}}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ body.idle {
|
|||
width: 20px;
|
||||
}
|
||||
|
||||
&.smaller {
|
||||
&.small {
|
||||
height: 35px;
|
||||
width: 35px;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue