Merge branch 'main' into refactor/settings-tabs-locales

This commit is contained in:
Andreas Nedbal 2022-02-20 21:36:31 +01:00 committed by GitHub
commit 56af98294a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 115 additions and 130 deletions

View File

@ -63,9 +63,9 @@ class UserController < ApplicationController
:privacy_allow_stranger_answers, :privacy_allow_stranger_answers,
:privacy_show_in_search) :privacy_show_in_search)
if current_user.update(user_attributes) if current_user.update(user_attributes)
flash[:success] = t('flash.user.update_privacy.success') flash[:success] = t(".success")
else else
flash[:error] = t('flash.user.update_privacy.error') flash[:error] = t(".error")
end end
redirect_to edit_user_privacy_path redirect_to edit_user_privacy_path
end end

View File

@ -1,159 +1,104 @@
.card .card
.card-body .card-body
%h2 Your Profile Data %h2= t(".heading")
%p Everything we have about you! Really, not that much as you might expect. %p= t(".body")
%h3 General %h3= t(".section.general")
.row .row
.col-md-6.col-sm-6.col-xs-12 .col-md-6.col-sm-6.col-xs-12.mb-3
%h4 Profile %h4= t(".section.profile")
%p.font-weight-bold.mb-0 User name %p.font-weight-bold.mb-0= t("activerecord.attributes.user.screen_name")
%p.text-muted= current_user.screen_name %p.text-muted= current_user.screen_name
%p.font-weight-bold.mb-0 Display name %p.font-weight-bold.mb-0= t("activerecord.attributes.profile.display_name")
%p.text-muted %p.text-muted
- if current_user.profile.display_name.blank? = current_user.profile.display_name.presence || t(".none")
None set!
- else
= current_user.profile.display_name
%p.font-weight-bold.mb-0 Bio %p.font-weight-bold.mb-0= t("activerecord.attributes.profile.description")
%p.text-muted %p.text-muted
- if current_user.profile.description.blank? = current_user.profile.description.presence || t(".none")
None set!
- else
= current_user.profile.description
%p.font-weight-bold.mb-0 Location %p.font-weight-bold.mb-0= t("activerecord.attributes.profile.location")
%p.text-muted %p.text-muted
- if current_user.profile.location.blank? = current_user.profile.location.presence || t(".none")
None set!
- else
= current_user.profile.location
%p.font-weight-bold.mb-0 Website %p.font-weight-bold.mb-0= t("activerecord.attributes.profile.website")
%p.text-muted %p.text-muted
- if current_user.profile.website.blank? = current_user.profile.website.presence || t(".none")
None set!
- else .col-md-6.col-sm-6.col-xs-12.mb-3
= current_user.profile.website %h4= t(".section.pictures")
.col-md-6.col-sm-6.col-xs-12 %p.font-weight-bold.mb-0= t(".pictures.profile_picture.heading")
%h4 Pictures .media.mb-3
%p.font-weight-bold.mb-0 Profile picture
.media
.pull-left .pull-left
%img.profile--img{ src: current_user.profile_picture.url(:medium) } %img.profile--img{ src: current_user.profile_picture.url(:medium) }
.media-body .media-body
%ul %ul
%li %li
%a{ href: current_user.profile_picture.url(:small) } Small %a{ href: current_user.profile_picture.url(:small) }= t(".pictures.profile_picture.size.small")
%li %li
%a{ href: current_user.profile_picture.url(:medium) } Medium %a{ href: current_user.profile_picture.url(:medium) }= t(".pictures.profile_picture.size.medium")
%li %li
%a{ href: current_user.profile_picture.url(:large) } Large %a{ href: current_user.profile_picture.url(:large) }= t(".pictures.profile_picture.size.large")
%li %li
%a{ href: current_user.profile_picture.url(:original) } Original image %a{ href: current_user.profile_picture.url(:original) }= t(".pictures.profile_picture.size.original")
%p.font-weight-bold.mb-0 Header picture %p.font-weight-bold.mb-0= t(".pictures.profile_header.heading")
%img{ src: current_user.profile_header.url(:mobile), style: 'width: 100%' } %img{ src: current_user.profile_header.url(:mobile), style: "width: 100%" }
%p %p
%a{ href: current_user.profile_header.url(:mobile) } Mobile %a{ href: current_user.profile_header.url(:mobile) }= t(".pictures.profile_header.size.mobile")
| |
%a{ href: current_user.profile_header.url(:web) } Web %a{ href: current_user.profile_header.url(:web) }= t(".pictures.profile_header.size.web")
| |
%a{ href: current_user.profile_header.url(:retina) } Retina %a{ href: current_user.profile_header.url(:retina) }= t(".pictures.profile_header.size.retina")
| |
%a{ href: current_user.profile_header.url(:original) } Original image %a{ href: current_user.profile_header.url(:original) }= t(".pictures.profile_header.size.original")
.row .row
.col-md-6.col-sm-6.col-xs-12 .col-md-6.col-sm-6.col-xs-12.mb-3
%h4 Statistics %h3= t(".section.ip")
%p.font-weight-bold.mb-0= t("activerecord.attributes.user.current_sign_in_ip")
%p.font-weight-bold.mb-0 Answers
%p.text-muted= current_user.answered_count
%p.font-weight-bold.mb-0 Questions
%p.text-muted= current_user.asked_count
%p.font-weight-bold.mb-0 Following
%p.text-muted= current_user.followings.count
%p.font-weight-bold.mb-0 Followers
%p.text-muted= current_user.followers.count
%p.font-weight-bold.mb-0 Smiles
%p.text-muted= current_user.smiled_count + current_user.comment_smiled_count
%p.font-weight-bold.mb-0 Comments
%p.text-muted= current_user.commented_count
.col-md-6.col-sm-6.col-xs-12
%h4 Badges
%p.font-weight-bold.mb-0 Admin
%p
- if current_user.has_role? :administrator
%span.label.label-success
%i.fa.fa-fw.fa-check
- else
%span.label.label-danger
%i.fa.fa-fw.fa-close
%p.font-weight-bold.mb-0 Moderator
%p
- if current_user.mod?
%span.label.label-success
%i.fa.fa-fw.fa-check
- else
%span.label.label-danger
%i.fa.fa-fw.fa-close
.row
.col-md-6.col-sm-6.col-xs-12
%h3 IP
%p.font-weight-bold.mb-0 Current Sign In
%p.text-muted= current_user.current_sign_in_ip %p.text-muted= current_user.current_sign_in_ip
%p.font-weight-bold.mb-0 Last Sign In %p.font-weight-bold.mb-0= t("activerecord.attributes.user.last_sign_in_ip")
%p.text-muted= current_user.last_sign_in_ip %p.text-muted= current_user.last_sign_in_ip
.col-md-6.col-sm-6.col-xs-12 .col-md-6.col-sm-6.col-xs-12.mb-3
%h3 Miscellaneous %h3= t(".section.miscellaneous")
%p.font-weight-bold.mb-0 Locale %p.font-weight-bold.mb-0= t("activerecord.attributes.user.locale")
%p.text-muted %p.text-muted
- if current_user.locale.blank? = current_user.locale.presence || t(".none")
None set!
- else
= current_user.locale
%p.font-weight-bold.mb-0 Sign In count %p.font-weight-bold.mb-0= t("activerecord.attributes.user.sign_in_count")
%p.text-muted= current_user.sign_in_count %p.text-muted= current_user.sign_in_count
%h3 Dates %h3= t(".section.dates")
.row .row
.col-md-6.col-sm-6.col-xs-12 .col-md-6.col-sm-6.col-xs-12
%h4 Sign In %h4= t(".section.sign_in")
%p.font-weight-bold.mb-0 Current Sign In %p.font-weight-bold.mb-0= t("activerecord.attributes.user.current_sign_in_at")
%p.text-muted= current_user.current_sign_in_at ? localize(current_user.current_sign_in_at) : 'Not set' %p.text-muted= current_user.current_sign_in_at ? localize(current_user.current_sign_in_at) : t(".none")
%p.font-weight-bold.mb-0 Last Sign In %p.font-weight-bold.mb-0= t("activerecord.attributes.user.last_sign_in_at")
%p.text-muted= current_user.last_sign_in_at ? localize(current_user.last_sign_in_at) : 'Not set' %p.text-muted= current_user.last_sign_in_at ? localize(current_user.last_sign_in_at) : t(".none")
%p.font-weight-bold.mb-0 Remember me set at %p.font-weight-bold.mb-0= t("activerecord.attributes.user.remember_created_at")
%p.text-muted= current_user.remember_created_at ? localize(current_user.remember_created_at) : 'Not set' %p.text-muted= current_user.remember_created_at ? localize(current_user.remember_created_at) : t(".none")
.col-md-6.col-sm-6.col-xs-12 .col-md-6.col-sm-6.col-xs-12
%h4 Create/Update %h4= t(".section.create_update")
%p.font-weight-bold.mb-0 Account created %p.font-weight-bold.mb-0= t("activerecord.attributes.user.created_at")
%p.text-muted %p.text-muted
- if current_user.created_at - if current_user.created_at
= localize(current_user.created_at) = localize(current_user.created_at)
= " (#{time_ago_in_words(current_user.created_at)} ago)" = " (#{t('time.distance_ago', time: time_ago_in_words(current_user.created_at))})"
- else - else
Not set = t(".none")
%p.font-weight-bold.mb-0 Account last updated %p.font-weight-bold.mb-0= t("activerecord.attributes.user.updated at")
%p.text-muted %p.text-muted
- if current_user.created_at - if current_user.created_at
= localize(current_user.updated_at) = localize(current_user.updated_at)
= " (#{time_ago_in_words(current_user.updated_at)} ago)" = " (#{t('time.distance_ago', time: time_ago_in_words(current_user.updated_at))})"
- else - else
Not set = t(".none")

View File

@ -1,9 +1,8 @@
.card .card
.card-body .card-body
= bootstrap_form_for(current_user, url: { action: 'edit_privacy' }, method: :patch) do |f| = bootstrap_form_for(current_user, url: { action: "edit_privacy" }, method: :patch) do |f|
= f.check_box :privacy_allow_anonymous_questions
= f.check_box :privacy_allow_public_timeline
= f.check_box :privacy_allow_stranger_answers
= f.check_box :privacy_allow_anonymous_questions, label: t('views.settings.privacy.anonymous') = f.primary
= f.check_box :privacy_allow_public_timeline, label: t('views.settings.privacy.public')
= f.check_box :privacy_allow_stranger_answers, label: t('views.settings.privacy.stranger')
= f.submit t('views.actions.save'), class: 'btn btn-primary'

View File

@ -1,4 +1,4 @@
= render 'settings/data' = render "settings/data"
- provide(:title, generate_title('Your Data')) - provide(:title, generate_title(t(".title")))
- parent_layout 'user/settings' - parent_layout "user/settings"

View File

@ -1,4 +1,4 @@
= render 'settings/privacy' = render "settings/privacy"
- provide(:title, generate_title('Privacy Settings')) - provide(:title, generate_title(t(".title")))
- parent_layout 'user/settings' - parent_layout "user/settings"

View File

@ -42,15 +42,27 @@ en:
warning_color: "Warning color" warning_color: "Warning color"
warning_text: "Warning text color" warning_text: "Warning text color"
user: user:
created_at: "Account created at"
current_password: "Current password" current_password: "Current password"
current_sign_in_at: "Current sign in at"
current_sign_in_ip: "Current sign in IP"
email: "Email" email: "Email"
last_sign_in_at: "Last sign in at"
last_sign_in_ip: "Last sign in IP"
locale: "Language"
login: "Username or Email" login: "Username or Email"
remember_created_at: "Remember me set at"
password: "Password" password: "Password"
password_confirmation: "Confirm your password" password_confirmation: "Confirm your password"
privacy_allow_anonymous_questions: "Allow anonymous questions"
privacy_allow_public_timeline: "Show your answers in the public timeline"
privacy_allow_stranger_answers: "Allow other people to answer your questions"
profile_picture: "Profile picture" profile_picture: "Profile picture"
profile_header: "Profile header" profile_header: "Profile header"
sign_in_count: "Sign in count"
screen_name: "Username" screen_name: "Username"
show_foreign_themes: "Render other user themes when visiting their profile" show_foreign_themes: "Render other user themes when visiting their profile"
updated_at: "Account updated at"
help: help:
user: user:
email: "Don't forget to check your spam folder in case our mail might have landed there!" email: "Don't forget to check your spam folder in case our mail might have landed there!"

View File

@ -51,6 +51,9 @@ en:
error: :errors.invalid_otp error: :errors.invalid_otp
destroy_2fa: destroy_2fa:
success: "Two factor authentication has been disabled for your account." success: "Two factor authentication has been disabled for your account."
update_privacy:
success: :user.update.success
error: :user.update.error
update_profile: update_profile:
success: :user.update.success success: :user.update.success
error: :user.update.error error: :user.update.error

View File

@ -51,10 +51,6 @@ en:
error: "I'm sorry, %{name}, I'm afraid I can't do that." error: "I'm sorry, %{name}, I'm afraid I can't do that."
reason: "Ban reason: %{reason}" reason: "Ban reason: %{reason}"
until: "Banned until: %{time}" until: "Banned until: %{time}"
user:
update_privacy:
success: "Your privacy settings have been updated!"
error: "An error occurred. ;_;"
messages: messages:
noscript: "Please activate JavaScript." noscript: "Please activate JavaScript."
error: "An error occurred." error: "An error occurred."
@ -360,10 +356,6 @@ en:
create: "Create an account" create: "Create an account"
another: "Ask another question" another: "Ask another question"
join: "Join %{app_title} today! You'll be able to follow and ask people you know and a lot more." join: "Join %{app_title} today! You'll be able to follow and ask people you know and a lot more."
privacy:
anonymous: "Allow anonymous questions"
public: "Show your answers in the public timeline"
stranger: "Allow other people to answer your questions"
modal: modal:
ask: ask:
title: "Ask your followers" title: "Ask your followers"

View File

@ -43,6 +43,34 @@ en:
delete: delete:
action: "Delete my account" action: "Delete my account"
heading: "Unsatisfied?" heading: "Unsatisfied?"
data:
heading: "Your Profile Data"
body: "Everything we have about you! Really, not that much as you might expect."
none: "None set!"
section:
general: "General"
profile: "Profile"
pictures: "Pictures"
ip: "IP"
miscellaneous: "Miscellaneous"
dates: "Dates"
sign_in: "Sign In"
create_update: "Create/Update"
pictures:
profile_picture:
heading: "Profile picture"
size:
small: "Small"
medium: "Medium"
large: "Large"
original: "Original image"
profile_header:
heading: "Profile header"
size:
mobile: "Mobile"
web: "Web"
retina: "Retina"
original: "Original image"
export: export:
heading: "Export your data" heading: "Export your data"
body_html: | body_html: |
@ -158,10 +186,14 @@ en:
data: "Your Data" data: "Your Data"
export: "Export" export: "Export"
user: user:
data:
title: "Your Data"
edit: edit:
title: "Profile Settings" title: "Profile Settings"
edit_mute: edit_mute:
title: "Muted Words" title: "Muted Words"
edit_privacy:
title: "Privacy Settings"
edit_security: edit_security:
title: "Security Settings" title: "Security Settings"
edit_theme: edit_theme:

View File

@ -12,3 +12,5 @@ en:
update: "Update" update: "Update"
messages: messages:
noauth: "You must be signed in to do this." noauth: "You must be signed in to do this."
time:
distance_ago: "%{time} ago"