mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Export follow/block lists as CSV
This commit is contained in:
parent
08b96f1b9f
commit
56d998cbdb
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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: "*"
|
||||
|
@ -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|
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user