Add ability to export bookmarks

This commit is contained in:
Thibaut Girka 2020-10-07 17:33:02 +02:00
parent 5a9ad221bf
commit dcd862048d
5 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
module Settings
module Exports
class BookmarksController < BaseController
include ExportControllerConcern
def index
send_export_file
end
private
def export_data
@export.to_bookmarks_csv
end
end
end
end

View File

@ -9,6 +9,14 @@ class Export
@account = account
end
def to_bookmarks_csv
CSV.generate do |csv|
account.bookmarks.includes(:status).reorder(id: :desc).each do |bookmark|
csv << [ActivityPub::TagManager.instance.uri_for(bookmark.status)]
end
end
end
def to_blocked_accounts_csv
to_csv account.blocking.select(:username, :domain)
end
@ -55,6 +63,10 @@ class Export
account.statuses_count
end
def total_bookmarks
account.bookmarks.count
end
def total_follows
account.following_count
end

View File

@ -36,6 +36,10 @@
%th= t('exports.domain_blocks')
%td= number_with_delimiter @export.total_domain_blocks
%td= table_link_to 'download', t('exports.csv'), settings_exports_domain_blocks_path(format: :csv)
%tr
%th= t('exports.bookmarks')
%td= number_with_delimiter @export.total_bookmarks
%td= table_link_to 'download', t('bookmarks.csv'), settings_exports_bookmarks_path(format: :csv)
%hr.spacer/

View File

@ -816,6 +816,7 @@ en:
request: Request your archive
size: Size
blocks: You block
bookmarks: Bookmarks
csv: CSV
domain_blocks: Domain blocks
lists: Lists

View File

@ -124,6 +124,7 @@ Rails.application.routes.draw do
resources :mutes, only: :index, controller: :muted_accounts
resources :lists, only: :index, controller: :lists
resources :domain_blocks, only: :index, controller: :blocked_domains
resources :bookmarks, only: :index, controller: :bookmarks
end
resources :two_factor_authentication_methods, only: [:index] do