add user.avatar with correct size
This commit is contained in:
@@ -556,6 +556,9 @@ tr.spacer {
|
||||
border: 1px solid;
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
display: inline-block;
|
||||
height: 66px; // 64px + 1px border on each side
|
||||
width: 66px;
|
||||
&:hover {
|
||||
color: #ab0000;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class User < ActiveRecord::Base
|
||||
include UsersHelper
|
||||
include ActionView::Helpers
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
belongs_to :role
|
||||
@@ -67,9 +68,11 @@ class User < ActiveRecord::Base
|
||||
!!(self.role >= :superadmin)
|
||||
end
|
||||
|
||||
|
||||
def avatar_url(size)
|
||||
return "https://minotar.net/helm/#{CGI.escape(self.ign)}/#{CGI.escape(size.to_s)}"
|
||||
def avatar(size, options = {})
|
||||
options[:class] ||= "avatar"
|
||||
options[:size] ||= size.to_s
|
||||
options[:alt] ||= "avatar"
|
||||
return image_tag("https://minotar.net/helm/#{CGI.escape(self.ign)}/#{CGI.escape(size.to_s)}", options)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<% @posts.each do |p| %>
|
||||
<div class="item-group with-avatar" id="post-<%= p.id %>">
|
||||
<div class="header">
|
||||
<%= link_to(image_tag(p.author.avatar_url(64), class: "avatar"), p.author, title: p.author.ign) %>
|
||||
<%= link_to(p.author.avatar(64), p.author, title: p.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: p.author } %> <time><%= link_to p.created_at.strftime("%e. %b %Y, %H:%M"), p %></time>
|
||||
<span class="comment-counter">
|
||||
<%= link_to pluralize(p.comments.count, "Comment"), p %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= link_to "News", blogposts_path %> → <%= link_to @post.title %>
|
||||
<div class="item-group post with-avatar" id="post-<%= @post.id %>">
|
||||
<div class="header">
|
||||
<%= link_to(image_tag(@post.author.avatar_url(64), class: "avatar"), @post.author, title: @post.author.ign) %>
|
||||
<%= link_to(@post.author.avatar(64), @post.author, title: @post.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: @post.author } %> <time><%= link_to @post.created_at.strftime("%e. %b %Y, %H:%M"), p %></time>
|
||||
<%= link_to "edit", edit_blogpost_path(@post.id), class: "editlink" if mod? %>
|
||||
<div class="clear-right"></div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="item-group with-avatar comment" id="comment-<%= c.id %>">
|
||||
<div class="header <%= "op" if c.author.is?(c.blogpost.author) %>">
|
||||
<%= link_to(image_tag(c.author.avatar_url(64), class: "avatar"), c.author, title: c.author.ign) %>
|
||||
<%= link_to(c.author.avatar(64), c.author, title: c.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: c.author } %>
|
||||
<time><%= link_to c.created_at.strftime("%e. %b %Y, %H:%M"), "#comment-#{c.id}" %></time>
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<% @threads.each do |thread| %>
|
||||
<div class="item-group with-avatar" id="thread-<%= thread.id %>">
|
||||
<div class="header">
|
||||
<%= link_to(image_tag(thread.author.avatar_url(64), class: "avatar"), thread.author, title: thread.author.ign) %>
|
||||
<%= link_to(thread.author.avatar(64), thread.author, title: thread.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: thread.author } %> <time><%= link_to thread.created_at.strftime("%e. %b %Y, %H:%M"), thread %></time>
|
||||
<span class="comment-counter">
|
||||
<%= link_to pluralize(thread.replies.count, "Reply"), thread %>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<%= link_to @thread.forum.group, forumgroup_path(@thread.forum.group) %> → <%= link_to @thread.forum, @thread.forum %> → <%= link_to @thread %>
|
||||
<div class="item-group thread with-avatar" id="thread-<%= @thread.id %>">
|
||||
<div class="header">
|
||||
<%= link_to(image_tag(@thread.author.avatar_url(64), class: "avatar"), @thread.author, title: @thread.author.ign) %>
|
||||
<%= link_to(@thread.author.avatar(64), @thread.author, title: @thread.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: @thread.author } %> <time><%= link_to @thread.created_at.strftime("%e. %b %Y, %H:%M"), p %></time>
|
||||
<%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if (@thread.author.is?(current_user) || mod?) %>
|
||||
<div class="clear-right"></div>
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<%= link_to current_user.name, current_user %><br/>
|
||||
<%= link_to "Logout", logout_path %>
|
||||
</span>
|
||||
<%= link_to image_tag(current_user.avatar_url(32), :class => "avatar"), current_user %>
|
||||
<%= link_to current_user.avatar(32), current_user %>
|
||||
<% else %>
|
||||
<%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> | <%= link_to "Sign up", signup_path %>
|
||||
<% end %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="item-group thread-reply with-avatar" id="reply-<%= reply.id %>">
|
||||
<div class="header">
|
||||
<%= link_to(image_tag(reply.author.avatar_url(64), class: "avatar"), reply.author, title: reply.author.ign) %>
|
||||
<%= link_to(reply.author.avatar(64), reply.author, title: reply.author.ign) %>
|
||||
<%= render partial: "users/username", locals: { user: reply.author } %>
|
||||
<time><%= link_to reply.created_at.strftime("%e. %b %Y, %H:%M"), "#reply-#{reply.id}" %></time>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div id="userlist">
|
||||
<% @users.each do |u| %>
|
||||
<div class="list-user">
|
||||
<%= link_to(image_tag(u.avatar_url(64)), u) %>
|
||||
<%= link_to(u.avatar(64), u) %>
|
||||
<div class="detail">
|
||||
<%= render partial: "users/username", locals: { user: u } %><br>
|
||||
<i><%= u.ign %></i>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
<% end %>
|
||||
|
||||
|
||||
<%= image_tag @user.avatar_url(128), :class => "user-avatar avatar", :alt => "avatar" %>
|
||||
<%= @user.avatar(128, class: "user-avatar avatar") %>
|
||||
<%= render partial: "users/username", locals: {user: @user} %>
|
||||
<table>
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user