Merge pull request #354 from Retrospring/refactor/export-locales

This commit is contained in:
Andreas Nedbal 2022-02-13 17:05:54 +01:00 committed by GitHub
commit e6ff2e444d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 22 deletions

View file

@ -170,16 +170,16 @@ class UserController < ApplicationController
def export def export
if current_user.export_processing if current_user.export_processing
flash[:info] = 'An export is currently in progress for this account.' flash[:info] = t(".info")
end end
end end
def begin_export def begin_export
if current_user.can_export? if current_user.can_export?
ExportWorker.perform_async(current_user.id) ExportWorker.perform_async(current_user.id)
flash[:success] = 'Your account is currently being exported. This will take a little while.' flash[:success] = t(".success")
else else
flash[:error] = 'Nice try, kid.' flash[:error] = t(".error")
end end
redirect_to user_export_path redirect_to user_export_path

View file

@ -1,29 +1,20 @@
.card .card
.card-body .card-body
%h2 Export your data %h2= t(".heading")
%p = t(".body_html")
The data is inside a
%code= '.tar.gz'
archive and available in three formats: YAML, JSON, and XML. The archive also contains a copy of your
profile picture and header picture in all sizes.
%p
Please note that you can only export your data once a week. Exporting your data
will take a while, so please be patient. You will receive a question once exporting
is done.
- if current_user.can_export? - if current_user.can_export?
%form{ action: begin_user_export_path, method: :post } %form{ action: begin_user_export_path, method: :post }
%p.text-center %p.text-center
%button.btn.btn-lg.btn-primary#export-btn{ type: :submit } Export %button.btn.btn-lg.btn-primary#export-btn{ type: :submit }= t(".export")
= hidden_field_tag :authenticity_token, form_authenticity_token = hidden_field_tag :authenticity_token, form_authenticity_token
- else - else
%p.text-center %p.text-center
%button.btn.btn-lg.btn-primary.disabled{ disabled: :disabled } Export %button.btn.btn-lg.btn-primary.disabled{ disabled: :disabled }= t(".export")
%p %p
- if current_user.export_url.nil? - if current_user.export_url.nil?
Once exporting your account is done, a download link will appear here. = t(".export_url.none")
- else - else
Here is your export from = t(".export_url.present", time: current_user.export_created_at)
= succeed ':' do
= current_user.export_created_at
%a{ href: current_user.export_url } %a{ href: current_user.export_url }
= File.basename current_user.export_url = File.basename current_user.export_url

View file

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

View file

@ -22,6 +22,11 @@ en:
destroy: destroy:
success: "Service removed successfully." success: "Service removed successfully."
user: user:
export:
info: "An export is currently in progress for this account."
begin_export:
success: "Your account is currently being exported. This will take a little while."
error: "Exporting is currently not possible."
update: update:
success: "Profile updated successfully." success: "Profile updated successfully."
error: "Unable to update profile." error: "Unable to update profile."

View file

@ -39,6 +39,18 @@ en:
delete: delete:
action: "Delete my account" action: "Delete my account"
heading: "Unsatisfied?" heading: "Unsatisfied?"
export:
heading: "Export your data"
body_html: |
<p>The data is inside a <code>.tar.gz</code> archive and available in three formats: YAML, JSON, and XML.
The archive also contains a copy of your profile picture and header picture in all sizes.</p>
<p>Please note that you can only export your data once a week. Exporting your data
will take a while, so please be patient. You will receive a question once exporting
is done.</p>
export: "Export"
export_url:
none: "Once exporting your account is done, a download link will appear here."
present: "Here's your export from %{time}"
profile: profile:
adjust: adjust:
profile_picture: "Adjust your new profile picture" profile_picture: "Adjust your new profile picture"
@ -96,3 +108,5 @@ en:
title: "Profile Settings" title: "Profile Settings"
edit_theme: edit_theme:
title: "Theme Settings" title: "Theme Settings"
export:
title: "Export"