Add ability to export bookmarks
parent
5a9ad221bf
commit
dcd862048d
|
@ -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
|
|
@ -9,6 +9,14 @@ class Export
|
||||||
@account = account
|
@account = account
|
||||||
end
|
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
|
def to_blocked_accounts_csv
|
||||||
to_csv account.blocking.select(:username, :domain)
|
to_csv account.blocking.select(:username, :domain)
|
||||||
end
|
end
|
||||||
|
@ -55,6 +63,10 @@ class Export
|
||||||
account.statuses_count
|
account.statuses_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def total_bookmarks
|
||||||
|
account.bookmarks.count
|
||||||
|
end
|
||||||
|
|
||||||
def total_follows
|
def total_follows
|
||||||
account.following_count
|
account.following_count
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,6 +36,10 @@
|
||||||
%th= t('exports.domain_blocks')
|
%th= t('exports.domain_blocks')
|
||||||
%td= number_with_delimiter @export.total_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)
|
%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/
|
%hr.spacer/
|
||||||
|
|
||||||
|
|
|
@ -816,6 +816,7 @@ en:
|
||||||
request: Request your archive
|
request: Request your archive
|
||||||
size: Size
|
size: Size
|
||||||
blocks: You block
|
blocks: You block
|
||||||
|
bookmarks: Bookmarks
|
||||||
csv: CSV
|
csv: CSV
|
||||||
domain_blocks: Domain blocks
|
domain_blocks: Domain blocks
|
||||||
lists: Lists
|
lists: Lists
|
||||||
|
|
|
@ -124,6 +124,7 @@ Rails.application.routes.draw do
|
||||||
resources :mutes, only: :index, controller: :muted_accounts
|
resources :mutes, only: :index, controller: :muted_accounts
|
||||||
resources :lists, only: :index, controller: :lists
|
resources :lists, only: :index, controller: :lists
|
||||||
resources :domain_blocks, only: :index, controller: :blocked_domains
|
resources :domain_blocks, only: :index, controller: :blocked_domains
|
||||||
|
resources :bookmarks, only: :index, controller: :bookmarks
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :two_factor_authentication_methods, only: [:index] do
|
resources :two_factor_authentication_methods, only: [:index] do
|
||||||
|
|
Loading…
Reference in New Issue