Export follow/block lists as CSV
parent
08b96f1b9f
commit
56d998cbdb
|
@ -1,16 +1,46 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'csv'
|
||||||
|
|
||||||
class Settings::ExportsController < ApplicationController
|
class Settings::ExportsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
before_action :set_account
|
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
|
private
|
||||||
|
|
||||||
def set_account
|
def set_account
|
||||||
@account = current_user.account
|
@account = current_user.account
|
||||||
end
|
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
|
end
|
||||||
|
|
|
@ -1,2 +1,17 @@
|
||||||
- content_for :page_title do
|
- content_for :page_title do
|
||||||
= t('settings.export')
|
= 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
|
remote_follow: Remote follow
|
||||||
unfollow: Unfollow
|
unfollow: Unfollow
|
||||||
application_mailer:
|
application_mailer:
|
||||||
signature: Mastodon notifications from %{instance}
|
|
||||||
settings: 'Change e-mail preferences: %{link}'
|
settings: 'Change e-mail preferences: %{link}'
|
||||||
|
signature: Mastodon notifications from %{instance}
|
||||||
view: 'View:'
|
view: 'View:'
|
||||||
applications:
|
applications:
|
||||||
invalid_url: The provided URL is invalid
|
invalid_url: The provided URL is invalid
|
||||||
|
@ -63,6 +63,11 @@ en:
|
||||||
x_minutes: "%{count}m"
|
x_minutes: "%{count}m"
|
||||||
x_months: "%{count}mo"
|
x_months: "%{count}mo"
|
||||||
x_seconds: "%{count}s"
|
x_seconds: "%{count}s"
|
||||||
|
exports:
|
||||||
|
blocks: You block
|
||||||
|
csv: CSV
|
||||||
|
follows: You follow
|
||||||
|
storage: Media storage
|
||||||
generic:
|
generic:
|
||||||
changes_saved_msg: Changes successfully saved!
|
changes_saved_msg: Changes successfully saved!
|
||||||
powered_by: powered by %{link}
|
powered_by: powered by %{link}
|
||||||
|
@ -71,6 +76,15 @@ en:
|
||||||
one: Something isn't quite right yet! Please review the error below
|
one: Something isn't quite right yet! Please review the error below
|
||||||
other: Something isn't quite right yet! Please review %{count} errors below
|
other: Something isn't quite right yet! Please review %{count} errors below
|
||||||
notification_mailer:
|
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:
|
favourite:
|
||||||
body: 'Your status was favourited by %{name}:'
|
body: 'Your status was favourited by %{name}:'
|
||||||
subject: "%{name} favourited your status"
|
subject: "%{name} favourited your status"
|
||||||
|
@ -86,15 +100,6 @@ en:
|
||||||
reblog:
|
reblog:
|
||||||
body: 'Your status was boosted by %{name}:'
|
body: 'Your status was boosted by %{name}:'
|
||||||
subject: "%{name} boosted your status"
|
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:
|
pagination:
|
||||||
next: Next
|
next: Next
|
||||||
prev: Prev
|
prev: Prev
|
||||||
|
@ -104,6 +109,7 @@ en:
|
||||||
proceed: Proceed to follow
|
proceed: Proceed to follow
|
||||||
prompt: 'You are going to follow:'
|
prompt: 'You are going to follow:'
|
||||||
settings:
|
settings:
|
||||||
|
authorized_apps: Authorized apps
|
||||||
back: Back to Mastodon
|
back: Back to Mastodon
|
||||||
edit_profile: Edit profile
|
edit_profile: Edit profile
|
||||||
export: Data export
|
export: Data export
|
||||||
|
|
|
@ -29,12 +29,12 @@ en:
|
||||||
must_be_follower: Block notifications from non-followers
|
must_be_follower: Block notifications from non-followers
|
||||||
must_be_following: Block notifications from people you don't follow
|
must_be_following: Block notifications from people you don't follow
|
||||||
notification_emails:
|
notification_emails:
|
||||||
|
digest: Send digest e-mails
|
||||||
favourite: Send e-mail when someone favourites your status
|
favourite: Send e-mail when someone favourites your status
|
||||||
follow: Send e-mail when someone follows you
|
follow: Send e-mail when someone follows you
|
||||||
follow_request: Send e-mail when someone requests to follow you
|
follow_request: Send e-mail when someone requests to follow you
|
||||||
mention: Send e-mail when someone mentions you
|
mention: Send e-mail when someone mentions you
|
||||||
reblog: Send e-mail when someone reblogs your status
|
reblog: Send e-mail when someone reblogs your status
|
||||||
digest: Send digest e-mails
|
|
||||||
'no': 'No'
|
'no': 'No'
|
||||||
required:
|
required:
|
||||||
mark: "*"
|
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 :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 :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 :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 :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 :authorized_apps, safe_join([fa_icon('list fw'), t('settings.authorized_apps')]), oauth_authorized_applications_url
|
||||||
end
|
end
|
||||||
|
|
||||||
primary.item :admin, safe_join([fa_icon('cogs fw'), 'Administration']), admin_accounts_url, if: proc { current_user.admin? } do |admin|
|
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
|
namespace :settings do
|
||||||
resource :profile, only: [:show, :update]
|
resource :profile, only: [:show, :update]
|
||||||
resource :preferences, 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
|
resource :two_factor_auth, only: [:show] do
|
||||||
member do
|
member do
|
||||||
|
|
Reference in New Issue