Turned on Index search

Activated the full text search on the index pages as well as plugging in
a tempalte to show location information. Still needs to be styled but
it's all wired up.

Also cleaned some typos in the About description. One day I'll be able
to spell. One day.
This commit is contained in:
Ro 2023-01-17 15:54:59 -08:00
parent c5d1ab0266
commit 477d6727f4
9 changed files with 143 additions and 35 deletions

View file

@ -4,34 +4,41 @@ section[role="start"] {
background-position: center;
background-repeat: no-repeat;
background-size: cover;
display: flex;
align-items: center;
justify-content: center;
}
section[role="start"] div {
section[role="start"] div[role="index-wrapper"] {
margin: 0 auto;
width: 100%;
max-width: 600px;
padding-top: 30px;
}
section[role="start"] div[role="index-search"] {
background: var(--primary);
width: 400px;
border-radius: 3px;
padding: 5px;
border-radius: 5px;
padding: 15px;
}
section[role="start"] span[role="title"] {
font-size: 100px;
line-height: 80px;
font-weight: bold;
color: var(--secondary);
section[role="start"] div input[type="text"] {
font-size: 2em;
width: 87%;
}
section[role="start"] p {
color: var(--white);
display: inline-block;
section[role="start"] div button {
vertical-align: top;
margin: 6px auto;
font-size: 1.87em;
width: 57px;
height: 57px;
}
section[role="start"] p a {
color: var(--highlight);
margin-top: 5px;
section[role="start"] div button i {
font-size: 1.5em;
}
section[role="start"] a.search-link {
background: var(--secondary);
padding: 5px;
color: var(--primary);
border-radius: 3px;
}

View file

@ -28,6 +28,10 @@ header > nav {
padding: 10px;
}
header > nav a {
color: var(--primary);
}
header > nav i {
font-size: 1.3em;
}
@ -49,7 +53,7 @@ main {
/* GLOBALS */
a {
color: var(--primary);
color: var(--highlight);
text-decoration: none;
border-bottom: 1px solid var(--white);
transition: all 0.2s linear;
@ -61,7 +65,7 @@ a[role="nav-links"] {
}
a:hover {
border-bottom: 1px solid var(--primary);
border-bottom: 1px solid var(--secondary);
}
sup {

View file

@ -12,7 +12,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RequestStack;
use Doctrine\Persistence\ManagerRegistry;
use App\Service\HandleLocations;
use Doctrine\DBAL\Connection;
use App\Service\Auth;
use App\Service\FileUploader;
use App\Service\Render;
@ -37,7 +36,6 @@ class Locations extends AbstractController
Auth $auth,
HandleLocations $locations,
ManagerRegistry $doctrine,
Connection $connection,
Render $render,
string $pageNum
): Response {

View file

@ -16,7 +16,7 @@ use App\Service\Auth;
class Members extends AbstractController
{
/**
* @Route("/den/members/page/{pageNum}", name="den-locations")
* @Route("/den/members/page/{pageNum}", name="den-members-index")
*/
public function showMembers(
Request $request,

View file

@ -21,7 +21,35 @@ class Index extends AbstractController
public function showIndex(Request $request, Auth $auth, Render $render, HandleLocations $locations): Response
{
$list = $locations->getActiveLocations();
return $render->page(["count" => count($list)], "This is The Bad Space", "front/index.twig");
if ($request->getMethod() == "GET") {
return $render->page(["count" => count($list)], "This is The Bad Space", "front/index.twig");
} else {
$results = $locations->searchLocations($request->request->get("index_search"));
return $render->page(
["count" => count($list),
"items" => $results['items']
],
"This is The Bad Space",
"front/index.twig"
);
};
}
/**
* @Route("/location/{uuid}", name="front-location")
*/
public function showLocations(
Request $request,
Render $render,
HandleLocations $locations,
string $uuid = "none"
): Response {
$location = $locations->getLocationbyUUID($uuid);
return $render->page(
["location" => $location[0]],
"The Bad Space | " . $location[0]->getName(),
"front/location.twig"
);
}
/**

View file

@ -11,6 +11,7 @@ use Exception;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Uid\Uuid;
use Doctrine\DBAL\Connection;
use App\Entity\Location;
use League\Csv\Reader;
@ -25,16 +26,59 @@ class HandleLocations
{
private $session;
private $entityManager;
private $conn;
private $limit = 4;
public function __construct(
Connection $connection,
EntityManagerInterface $entityManager,
RequestStack $requestStack
) {
$this->connection = $connection;
$this->entityManager = $entityManager;
$this->session = $requestStack->getSession();
}
public function searchLocations(string $terms)
{
$errorMessage = null;
$response = null;
//$utils = new StringTools();
//$term = $utils->removeCommonWords($terms);
$terms = str_replace(",", "", $terms);
$terms = str_replace(" ", "|", $terms);
try {
$search = $this->connection->fetchAllAssociative("SELECT * FROM searchlocations('$terms')");
} catch (PDOException $error) {
$errorMessage = $error->getMessage();
} catch (DBALException $error) {
$errorMessage = $error->getMessage();
} catch (ORMException $error) {
$errorMessage = $error->getMessage();
} catch (Exception $error) {
$errorMessage = $error->getMessage();
} catch (SyntaxErrorException $error) {
$errorMessage = $error->getMessage();
}
if ($errorMessage != null) {
$response = [
"status" => false,
"message" => $errorMessage,
];
} else {
$response = [
"status" => true,
"message" => "Good Reqeust",
"items" => $search,
"terms" => $terms,
];
}
return $response;
}
public function getActiveLocations()
{
$listings = $this->entityManager->getRepository(Location::class);

View file

@ -16,15 +16,12 @@
<a href="https://www.artistmarciax.com/">Artist Marcia X</a>
with additional support from
<a href="https://digital.rooting.garden">Ginger</a>
to provide a catolog of instances seek to cause harm and reduce the quality of experience in the fediverse.
to provide a catalog of instances that seek to cause harm and reduce the quality of experience in the fediverse.
</p>
</p>
<p>
Technial support provided by
Technical support provided by
<a href="https://roiskinda.cool/profile.html">Ro</a>.
</p>
</section>

View file

@ -5,12 +5,29 @@
{% block main %}
<section role="start">
<div>
<span role="title">{{ options.count }}</span>
<p>
Bad Spaces tracked.<br/>
Pace yourself.
</p>
<div role="index-wrapper">
<div role="index-search">
<form action="{{ path('index') }}" method="post" enctype="multipart/form-data">
<input type="text" name="index_search" value="" placeholder="Take a look"/>
<button>
<i class="ti ti-search"></i>
</button>
</form>
{{ options.count }}
Bad Spaces tracked. Shot by
<a href="https://unsplash.com/photos/935EcPU1pBI">Ussama Azam</a>
</div>
{% if options.items is defined %}
<div role="index-results">
<h3>Found</h3>
{% for item in options.items %}
<a class="search-link" href="/location/{{ item.uuid }}">{{ item.name }}</a><br/>
{% endfor %}
</div>
{% endif %}
</div>
</section>
{% endblock %}

View file

@ -0,0 +1,13 @@
{% extends "base/frame.twig" %}
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="/assets/css/front/start.css?=sdfsdf">
{% endblock %}
{% block main %}
<section role="location">
<h1>About
{{ options.location.name }}</h1>
This is a location
</section>
{% endblock %}