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