_comment.rhtml 1.88 KB
<%= content_tag('a', '', :name => comment.anchor) %>
<div class="article-comment<%= ' comment-from-owner' if ( comment.author && (@page.profile.name == comment.author.name) ) %> comment-logged-<%= comment.author ? 'in' : 'out' %>">
  <% if logged_in? && (user == @page.profile || user == comment.author) %>
    <% button_bar(:style => 'float: right; margin-top: 0;') do %>
      <%= icon_button(:delete, 'Delete', { :remove_comment => comment.id }, :method => :post, :confirm => _('Are you sure you want to remove this comment?')) %>
    <% end %>
  <% end %>
  
  <% if comment.author %>
    <%= link_to content_tag( 'span', comment.author.name() ), comment.author.url,
        :class => 'comment-picture',
        :style => 'background-image:url(%s)' % profile_icon(comment.author, :minor)
    %>
  <% else %>
    <%# unauthenticated user: display gravatar icon %>
    <%= content_tag 'span', '&nbsp;',
        :class => 'comment-picture',
        :style => 'background-image:url(%s)' % str_gravatar_url_for( comment.email, :size => 50 )
    %>
  <% end %>

  <h4><%= comment.title %></h4>
  <div class="comment-info">
    <%= _('By %{author} on %{date}') % {
        :author => comment.author ? link_to(comment.author.name, comment.author.url) : content_tag('u', comment.name),
        :date => show_time(comment.created_at) } %>
    <%= '<br/>' + _('(unauthenticated user)') if ! comment.author %>
  </div>
  <div class="comment-text">
    <p/>
    <%=
      comment.body.
              gsub( /\n\s*\n/, ' <p/> ' ).
              gsub( /\n/, ' <br/> ' ).
              gsub( /(^|\s)(www\.[^\s])/, '\1http://\2' ).
              gsub( /(https?:\/\/([^\s]+))/,
                    '<a href="\1" target="_blank" rel="nofolow" onclick="return confirm(\'' +
                    escape_javascript( _('Are you sure you want to visit this web site?') ) +
                    '\n\n\'+this.href)">\2</a>' )
    %>
  </div>
</div>