From d286eab325e0452e0e9e7f01cd5d037aa49ae172 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Thu, 12 Mar 2015 23:17:30 -0500 Subject: [PATCH] add option to show user avatars on stories and comments just because --- app/assets/stylesheets/application.css | 9 +++++++++ app/controllers/settings_controller.rb | 2 +- app/models/user.rb | 4 ++-- app/views/comments/_comment.html.erb | 4 ++++ app/views/settings/index.html.erb | 11 +++++++++++ app/views/stories/_listdetail.html.erb | 18 +++++++++++++++--- .../20150313040930_add_user_avatar_pref.rb | 5 +++++ db/schema.rb | 3 ++- 8 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20150313040930_add_user_avatar_pref.rb diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 13da21e..aab52fe 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -527,9 +527,18 @@ li .domain { } li .byline { + margin-bottom: -5px; color: #888; font-size: 8.5pt; } +li .byline img.avatar { + border-radius: 8px; + height: 16px; + margin-bottom: 2px; + margin-right: 2px; + vertical-align: middle; + width: 16px; +} li.story .byline { margin-top: 1px; } diff --git a/app/controllers/settings_controller.rb b/app/controllers/settings_controller.rb index ab4fc32..ff0faba 100644 --- a/app/controllers/settings_controller.rb +++ b/app/controllers/settings_controller.rb @@ -81,7 +81,7 @@ private :username, :email, :password, :password_confirmation, :about, :email_replies, :email_messages, :email_mentions, :pushover_replies, :pushover_messages, :pushover_mentions, - :mailing_list_mode + :mailing_list_mode, :show_avatars ) end end diff --git a/app/models/user.rb b/app/models/user.rb index 344b3f2..fcb08fd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -83,9 +83,9 @@ class User < ActiveRecord::Base h end - def avatar_url + def avatar_url(size = 100) "https://secure.gravatar.com/avatar/" + - Digest::MD5.hexdigest(self.email.strip.downcase) + "?r=pg&d=mm&s=100" + Digest::MD5.hexdigest(self.email.strip.downcase) + "?r=pg&d=mm&s=#{size}" end def average_karma diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 31b7207..80fb2cb 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -30,6 +30,10 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ? <% end %> + <% if @user && @user.show_avatars? %> + + <% end %> + class="inactive_user" diff --git a/app/views/settings/index.html.erb b/app/views/settings/index.html.erb index 9bb0f70..13b44c6 100644 --- a/app/views/settings/index.html.erb +++ b/app/views/settings/index.html.erb @@ -170,6 +170,17 @@ +
+ +
+ Miscellaneous Settings +
+ +
+ <%= f.label :show_avatars, "Show User Avatars:", :class => "required" %> + <%= f.check_box :show_avatars %> +
+
<%= f.submit "Save All Settings" %> diff --git a/app/views/stories/_listdetail.html.erb b/app/views/stories/_listdetail.html.erb index 0eb4f89..406db77 100644 --- a/app/views/stories/_listdetail.html.erb +++ b/app/views/stories/_listdetail.html.erb @@ -54,7 +54,11 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %> ms.domain %>
<% end %> - by + + <% end %> + class="new_user" <% end %>><%= ms.user.username %> @@ -67,10 +71,18 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %> <% end %>