forked from are0h/TheBadSpace
CSV Export for Mastdon
Added a link to export current active sites in the DB to a consumable CSV file. More formats will be added but this one needs to be tested first based on the ubiquity of Mastodonsymfony-version
parent
b8eda54267
commit
88e78f2c4a
@ -0,0 +1,12 @@
|
|||||||
|
section[role="exports"] {
|
||||||
|
background: var(--primary);
|
||||||
|
width: 100%;
|
||||||
|
max-width: 600px;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 0 auto;
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
section[role="exports"] a {
|
||||||
|
color: var(--highlight);
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use League\Csv\Reader;
|
||||||
|
|
||||||
|
class HandleExports
|
||||||
|
{
|
||||||
|
private $locations;
|
||||||
|
|
||||||
|
public function __construct(HandleLocations $locations)
|
||||||
|
{
|
||||||
|
$this->locations = $locations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildMastodonCSV()
|
||||||
|
{
|
||||||
|
$records = [['domain', 'severity', 'public_comment', 'reject_media', 'reject_reports', 'obfuscate']];
|
||||||
|
$entries = $this->locations->getActiveLocations();
|
||||||
|
foreach ($entries as $entry) {
|
||||||
|
$item = [$entry->getUrl(), $entry->getRating(), $entry->getDescription(), "FALSE", "FALSE", "FALSE"];
|
||||||
|
array_push($records, $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = new \SplTempFileObject();
|
||||||
|
foreach ($records as $record) {
|
||||||
|
$tmp->fputcsv($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
$reader = Reader::createFromFileObject($tmp);
|
||||||
|
return new Response($reader->getContent(), 200, [
|
||||||
|
'Content-Encoding' => 'none',
|
||||||
|
'Content-Type' => 'text/csv; charset=UTF-8',
|
||||||
|
'Content-Disposition' => 'attachment; filename="the-bad-space-mastodon.csv"',
|
||||||
|
'Content-Description' => 'File Transfer',
|
||||||
|
]);
|
||||||
|
|
||||||
|
//return $path;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
{% extends "base/frame.twig" %}
|
||||||
|
{% block stylesheets %}
|
||||||
|
<link rel="stylesheet" type="text/css" href="/assets/css/front/start.css?=sdfsdf">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<section role="exports">
|
||||||
|
<h1>File Exports</h1>
|
||||||
|
<a href="/exports/mastodon">For Mastodon</a>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue