Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow showing user e-mail address. #388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:email])
devise_parameter_sanitizer.permit(:account_update, keys: [
:login, :email, :password, :password_confirmation, :current_password,
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home,
:hide_avatar, :news_on_home, :diaries_on_home, :posts_on_home, :show_email,
:polls_on_home, :wiki_pages_on_home, :trackers_on_home, :bookmarks_on_home,
:sort_by_date_on_home, :hide_signature, :show_negative_nodes,
:totoz_style, :totoz_source,
Expand Down
1 change: 1 addition & 0 deletions app/helpers/node_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def posted_by(content, user_link='Anonyme')
if user
user_link = link_to(user.name, "/users/#{user.cached_slug}", rel: 'author')
user_infos = []
user_infos << email_link(user)
user_infos << homesite_link(user)
user_infos << jabber_link(user)
user_infos << mastodon_link(user)
Expand Down
7 changes: 7 additions & 0 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def mini_avatar_img(user)
image_tag(user.avatar_url, options)
end

def email_link(user)
return if not user.account.show_email
karma = user.account.try(:karma).to_i
return unless karma > 0
link_to("courriel", "mailto:" + user.account.email)
end

def homesite_link(user)
return if user.homesite.blank?
karma = user.account.try(:karma).to_i
Expand Down
1 change: 1 addition & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def can_plonk?
512 => :show_negative_nodes,
1024 => :bookmarks_on_home,
2048 => :board_in_sidebar,
4096 => :show_email,
scopes: false

def types_on_home
Expand Down
3 changes: 3 additions & 0 deletions app/views/devise/registrations/_preferences.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
%p
= u.label :signature, "Signature"
= u.text_field :signature, maxlength: 250, size: 100
%p
= f.check_box :show_email
= f.label :show_email, "Publier mon adresse de courriel"
%p
= f.check_box :hide_avatar
= f.label :hide_avatar, "Ne pas afficher les avatars sur le site"
Expand Down
5 changes: 5 additions & 0 deletions app/views/statistics/users.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@
%td
.stat.misc(style="width: #{(width_stats * @stats.preferences(:hide_avatar) / maxval).to_i}px;")= @stats.preferences(:hide_avatar)
%td #{@stats.pctrecent(@stats.preferences :hide_avatar)}
%tr
%td.stat Publication de l'adresse de courriel
%td
.stat.misc(style="width: #{(width_stats * @stats.preferences(:show_email) / maxval).to_i}px;")= @stats.preferences(:show_email)
%td #{@stats.pctrecent(@stats.preferences :show_email)}
%tr
%td.stat Affichage des contenus avec une note négative
%td
Expand Down