1
0
mirror of https://koodu.h-i.works/projects/thebadspace synced 2025-06-25 16:04:37 -05:00

Added support of fedifence CSV and pagination

Populated the DB with entries from a fedifence export provided by
@Oliphant (https://codeberg.org/oliphant/blocklists).

As such also updated the appropriate templates with pagination to be
able to peruse through the location directory.

Also added an edit link on the location template front end to make
finding and updating instance info easy.
This commit is contained in:
Ro
2023-01-23 19:59:51 -08:00
parent b9298451b7
commit 245531faf6
10 changed files with 234 additions and 21 deletions

View File

@ -12,6 +12,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RequestStack;
use Doctrine\Persistence\ManagerRegistry;
use App\Service\HandleLocations;
use App\Service\HandleImports;
use App\Service\Auth;
use App\Service\FileUploader;
use App\Service\Render;
@ -45,8 +46,27 @@ class Locations extends AbstractController
$member = $session->get("member");
$list = $locations->getLocationsPage($pageNum);
//$search = $connection->fetchAllAssociative("SELECT * FROM searchlocations('agenda')");
return $render->page(["list" => $list, "mode" => "index"], "Bad Space | Locations", "back/locations.twig");
$next = $pageNum + 1;
if ($next > $list["total"]) {
$next = 1;
}
$prev = $pageNum - 1;
if ($prev <= 0) {
$prev = $list["total"];
}
return $render->page(
[
"list" => $list,
"mode" => "index",
"curentPage" => $pageNum,
"nextPage" => $next,
"prevPage" => $prev
],
"Bad Space | Locations",
"back/locations.twig"
);
} else {
return $render->page([], "The Bad Space | Den", "back/index.twig");
}
@ -164,6 +184,7 @@ class Locations extends AbstractController
Request $request,
Auth $auth,
HandleLocations $locations,
HandleImports $imports,
ManagerRegistry $doctrine,
FileUploader $uploader,
Render $render
@ -181,7 +202,7 @@ class Locations extends AbstractController
$token = $request->get("token");
$entityManager = $doctrine->getManager();
$notice = '';
$type = $request->get("input_type");
if (!$this->isCsrfTokenValid("upload", $token)) {
$logger->info("CSRF failure");
return new Response(
@ -217,7 +238,12 @@ class Locations extends AbstractController
]);
}
//if it's cool, send it to be processed
$response = $locations->addMultipleLocations($file, $result["id"]);
if ($type == "tbs" || $type == "") {
$response = $locations->addMultipleLocations($file, $result["id"]);
} else {
$response = $imports->importLocations($file, $result["id"]);
}
if ($response["status"]) {
$notice = "New locations added! Take a break.";
return $render->page(

View File

@ -73,9 +73,26 @@ class Index extends AbstractController
Auth $auth,
Render $render,
HandleLocations $locations,
string $pageNum
int $pageNum = 1
): Response {
$list = $locations->getLocationsPage($pageNum, "true");
return $render->page(["list" => $list, "page" => $pageNum], "About The Bad Space", "front/listing.twig");
$next = $pageNum + 1;
if ($next > $list["total"]) {
$next = 1;
}
$prev = $pageNum - 1;
if ($prev <= 0) {
$prev = $list["total"];
}
return $render->page([
"list" => $list,
"currentPage" => $pageNum,
"nextPage" => $next,
"prevPage" => $prev
], "About The Bad Space", "front/listing.twig");
}
}