Commit adfbbf1b10903e7be970777c077d5aa314766aba
1 parent
4cd51616
Exists in
master
and in
29 other branches
ActionItem225: comentario diferenciado para comentarios de usuarios nao logados …
…e de brinde rola o gravatar do carinha git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1572 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
35 additions
and
4 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -412,4 +412,25 @@ module ApplicationHelper |
412 | 412 | end |
413 | 413 | end |
414 | 414 | |
415 | + def gravatar_url_for(email, options = {}) | |
416 | + # Ta dando erro de roteamento | |
417 | + url_for( { :gravatar_id => Digest::MD5.hexdigest(email), | |
418 | + :host => 'www.gravatar.com', | |
419 | + :protocol => 'http://', | |
420 | + :only_path => false, | |
421 | + :controller => 'avatar.php' | |
422 | + }.merge(options) ) | |
423 | + end | |
424 | + | |
425 | + def str_gravatar_url_for(email, options = {}) | |
426 | + url = 'http://www.gravatar.com/avatar.php?gravatar_id=' + | |
427 | + Digest::MD5.hexdigest(email) | |
428 | + { :only_path => false }.merge(options).each { |k,v| | |
429 | + url += ( '&%s=%s' % [ k,v ] ) | |
430 | + } | |
431 | + # we can set the default imgage with this: | |
432 | + # :default => 'DOMAIN/images/icons-app/gravatar-minor.gif' | |
433 | + url | |
434 | + end | |
435 | + | |
415 | 436 | end | ... | ... |
app/views/content_viewer/_comment.rhtml
1 | -<div class="article-comment<%= ' comment-from-owner' if ( comment.author && (@page.profile.name == comment.author.name) ) %>"> | |
1 | +<div class="article-comment<%= ' comment-from-owner' if ( comment.author && (@page.profile.name == comment.author.name) ) %> comment-logged-<%= comment.author ? 'in' : 'out' %>"> | |
2 | 2 | <% if comment.author %> |
3 | 3 | <%= link_to content_tag( 'span', comment.author.name() ), comment.author.url, |
4 | 4 | :class => 'comment-picture', |
5 | - :style => 'background-image:url(%s)' % profile_icon(comment.author, :minor) %> | |
5 | + :style => 'background-image:url(%s)' % profile_icon(comment.author, :minor) | |
6 | + %> | |
6 | 7 | <% else %> |
7 | - <%# unauthenticated user: display default icon %> | |
8 | - <%= content_tag('span', ' ', :class => 'comment-picture', :style => 'background-image: url(/images/icons-app/user_icon_size-minor.png)' )%> | |
8 | + <%# unauthenticated user: display gravatar icon %> | |
9 | + <%= content_tag 'span', ' ', | |
10 | + :class => 'comment-picture', | |
11 | + :style => 'background-image:url(%s)' % str_gravatar_url_for( comment.email, :size => 50 ) | |
12 | + %> | |
9 | 13 | <% end %> |
10 | 14 | |
11 | 15 | <h4><%= comment.title %></h4> |
... | ... | @@ -13,6 +17,7 @@ |
13 | 17 | <%= _('By %{author} on %{date}') % { |
14 | 18 | :author => comment.author ? link_to(comment.author.name, comment.author.url) : content_tag('u', comment.name), |
15 | 19 | :date => show_time(comment.created_on) } %> |
20 | + <%= '<br/>' + _('(unauthenticated user)') if ! comment.author %> | |
16 | 21 | </div> |
17 | 22 | <div class="comment-text"> |
18 | 23 | <%= comment.body %> | ... | ... |