about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/settings/exports_controller.rb32
-rw-r--r--app/views/settings/exports/show.html.haml15
-rw-r--r--config/locales/en.yml26
-rw-r--r--config/locales/simple_form.en.yml2
-rw-r--r--config/navigation.rb4
-rw-r--r--config/routes.rb8
6 files changed, 72 insertions, 15 deletions
diff --git a/app/controllers/settings/exports_controller.rb b/app/controllers/settings/exports_controller.rb
index d4ecb6e8a..4fcec5322 100644
--- a/app/controllers/settings/exports_controller.rb
+++ b/app/controllers/settings/exports_controller.rb
@@ -1,16 +1,46 @@
 # frozen_string_literal: true
 
+require 'csv'
+
 class Settings::ExportsController < ApplicationController
   layout 'admin'
 
   before_action :authenticate_user!
   before_action :set_account
 
-  def show; end
+  def show
+    @total_storage = current_account.media_attachments.sum(:file_file_size)
+    @total_follows = current_account.following.count
+    @total_blocks  = current_account.blocking.count
+  end
+
+  def download_following_list
+    @accounts = current_account.following
+
+    respond_to do |format|
+      format.csv { render text: accounts_list_to_csv(@accounts) }
+    end
+  end
+
+  def download_blocking_list
+    @accounts = current_account.blocking
+
+    respond_to do |format|
+      format.csv { render text: accounts_list_to_csv(@accounts) }
+    end
+  end
 
   private
 
   def set_account
     @account = current_user.account
   end
+
+  def accounts_list_to_csv(list)
+    CSV.generate do |csv|
+      list.each do |account|
+        csv << [(account.local? ? "#{account.username}@#{Rails.configuration.x.local_domain}" : account.acct)]
+      end
+    end
+  end
 end
diff --git a/app/views/settings/exports/show.html.haml b/app/views/settings/exports/show.html.haml
index d9006efdb..0a0ff8633 100644
--- a/app/views/settings/exports/show.html.haml
+++ b/app/views/settings/exports/show.html.haml
@@ -1,2 +1,17 @@
 - content_for :page_title do
   = t('settings.export')
+
+%table.table
+  %tbody
+    %tr
+      %th= t('exports.storage')
+      %td= number_to_human_size @total_storage
+      %td
+    %tr
+      %th= t('exports.follows')
+      %td= @total_follows
+      %td= table_link_to 'download', t('exports.csv'), follows_settings_export_path(format: :csv)
+    %tr
+      %th= t('exports.blocks')
+      %td= @total_blocks
+      %td= table_link_to 'download', t('exports.csv'), blocks_settings_export_path(format: :csv)
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 595f34312..e35b8d97a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -29,8 +29,8 @@ en:
     remote_follow: Remote follow
     unfollow: Unfollow
   application_mailer:
-    signature: Mastodon notifications from %{instance}
     settings: 'Change e-mail preferences: %{link}'
+    signature: Mastodon notifications from %{instance}
     view: 'View:'
   applications:
     invalid_url: The provided URL is invalid
@@ -63,6 +63,11 @@ en:
       x_minutes: "%{count}m"
       x_months: "%{count}mo"
       x_seconds: "%{count}s"
+  exports:
+    blocks: You block
+    csv: CSV
+    follows: You follow
+    storage: Media storage
   generic:
     changes_saved_msg: Changes successfully saved!
     powered_by: powered by %{link}
@@ -71,6 +76,15 @@ en:
       one: Something isn't quite right yet! Please review the error below
       other: Something isn't quite right yet! Please review %{count} errors below
   notification_mailer:
+    digest:
+      body: 'Here is a brief summary of what you missed on %{instance} since your last visit on %{since}:'
+      mention: "%{name} mentioned you in:"
+      new_followers_summary:
+        one: You have acquired one new follower! Yay!
+        other: You have gotten %{count} new followers! Amazing!
+      subject:
+        one: "1 new notification since your last visit \U0001F418"
+        other: "%{count} new notifications since your last visit \U0001F418"
     favourite:
       body: 'Your status was favourited by %{name}:'
       subject: "%{name} favourited your status"
@@ -86,15 +100,6 @@ en:
     reblog:
       body: 'Your status was boosted by %{name}:'
       subject: "%{name} boosted your status"
-    digest:
-      subject:
-        one: "1 new notification since your last visit 🐘"
-        other: "%{count} new notifications since your last visit 🐘"
-      body: 'Here is a brief summary of what you missed on %{instance} since your last visit on %{since}:'
-      mention: "%{name} mentioned you in:"
-      new_followers_summary:
-        one: You have acquired one new follower! Yay!
-        other: You have gotten %{count} new followers! Amazing!
   pagination:
     next: Next
     prev: Prev
@@ -104,6 +109,7 @@ en:
     proceed: Proceed to follow
     prompt: 'You are going to follow:'
   settings:
+    authorized_apps: Authorized apps
     back: Back to Mastodon
     edit_profile: Edit profile
     export: Data export
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 170af01cf..c4bd0ad96 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -29,12 +29,12 @@ en:
         must_be_follower: Block notifications from non-followers
         must_be_following: Block notifications from people you don't follow
       notification_emails:
+        digest: Send digest e-mails
         favourite: Send e-mail when someone favourites your status
         follow: Send e-mail when someone follows you
         follow_request: Send e-mail when someone requests to follow you
         mention: Send e-mail when someone mentions you
         reblog: Send e-mail when someone reblogs your status
-        digest: Send digest e-mails
     'no': 'No'
     required:
       mark: "*"
diff --git a/config/navigation.rb b/config/navigation.rb
index fd2659923..607a0ff10 100644
--- a/config/navigation.rb
+++ b/config/navigation.rb
@@ -9,8 +9,8 @@ SimpleNavigation::Configuration.run do |navigation|
       settings.item :preferences, safe_join([fa_icon('sliders fw'), t('settings.preferences')]), settings_preferences_url
       settings.item :password, safe_join([fa_icon('cog fw'), t('auth.change_password')]), edit_user_registration_url
       settings.item :two_factor_auth, safe_join([fa_icon('mobile fw'), t('settings.two_factor_auth')]), settings_two_factor_auth_url
-      # settings.item :export, safe_join([fa_icon('cloud-download fw'), t('settings.export')]), settings_export_url
-      settings.item :authorized_apps, safe_join([fa_icon('list fw'), 'Authorized Apps']), oauth_authorized_applications_url
+      settings.item :export, safe_join([fa_icon('cloud-download fw'), t('settings.export')]), settings_export_url
+      settings.item :authorized_apps, safe_join([fa_icon('list fw'), t('settings.authorized_apps')]), oauth_authorized_applications_url
     end
 
     primary.item :admin, safe_join([fa_icon('cogs fw'), 'Administration']), admin_accounts_url, if: proc { current_user.admin? } do |admin|
diff --git a/config/routes.rb b/config/routes.rb
index ac1d78d64..ea766e1b3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -46,7 +46,13 @@ Rails.application.routes.draw do
   namespace :settings do
     resource :profile, only: [:show, :update]
     resource :preferences, only: [:show, :update]
-    resource :export, only: [:show]
+
+    resource :export, only: [:show] do
+      collection do
+        get :follows, to: 'exports#download_following_list'
+        get :blocks, to: 'exports#download_blocking_list'
+      end
+    end
 
     resource :two_factor_auth, only: [:show] do
       member do