Skip to content

Commit 329244d

Browse files
authored
Merge pull request #388 from baikiet/showemail
Allow showing user e-mail address.
2 parents a08cb4e + 4dfd531 commit 329244d

6 files changed

Lines changed: 18 additions & 1 deletion

File tree

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def configure_permitted_parameters
6262
devise_parameter_sanitizer.permit(:sign_up, keys: [:email])
6363
devise_parameter_sanitizer.permit(:account_update, keys: [
6464
:login, :email, :password, :password_confirmation, :current_password,
65-
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home,
65+
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home, :show_email,
6666
:polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home,
6767
:sort_by_date_on_home, :hide_signature, :show_negative_nodes,
6868
:totoz_style, :totoz_source,

app/helpers/node_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def posted_by(content, user_link='Anonyme')
109109
if user
110110
user_link = link_to(user.name, "/users/#{user.cached_slug}", rel: 'author')
111111
user_infos = []
112+
user_infos << email_link(user)
112113
user_infos << homesite_link(user)
113114
user_infos << jabber_link(user)
114115
user_infos << mastodon_link(user)

app/helpers/users_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def mini_avatar_img(user)
2525
image_tag(user.avatar_url, options)
2626
end
2727

28+
def email_link(user)
29+
return if not user.account.show_email
30+
karma = user.account.try(:karma).to_i
31+
return unless karma > 0
32+
link_to("courriel", "mailto:" + user.account.email)
33+
end
34+
2835
def homesite_link(user)
2936
return if user.homesite.blank?
3037
karma = user.account.try(:karma).to_i

app/models/account.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def can_plonk?
353353
512 => :show_negative_nodes,
354354
1024 => :bookmarks_on_home,
355355
2048 => :board_in_sidebar,
356+
4096 => :show_email,
356357
scopes: false
357358

358359
def types_on_home

app/views/devise/registrations/_preferences.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
%p
2121
= u.label :signature, "Signature"
2222
= u.text_field :signature, maxlength: 250, size: 100
23+
%p
24+
= f.check_box :show_email
25+
= f.label :show_email, "Publier mon adresse de courriel"
2326
%p
2427
= f.check_box :hide_avatar
2528
= f.label :hide_avatar, "Ne pas afficher les avatars sur le site"

app/views/statistics/users.html.haml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@
335335
%td
336336
.stat.misc(style="width: #{(width_stats * @stats.preferences(:hide_avatar) / maxval).to_i}px;")= @stats.preferences(:hide_avatar)
337337
%td #{@stats.pctrecent(@stats.preferences :hide_avatar)}
338+
%tr
339+
%td.stat Publication de l'adresse de courriel
340+
%td
341+
.stat.misc(style="width: #{(width_stats * @stats.preferences(:show_email) / maxval).to_i}px;")= @stats.preferences(:show_email)
342+
%td #{@stats.pctrecent(@stats.preferences :show_email)}
338343
%tr
339344
%td.stat Affichage des contenus avec une note négative
340345
%td

0 commit comments

Comments
 (0)