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.
symfony-version
Ro 2 years ago
parent c5d1ab0266
commit 477d6727f4

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

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

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

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

@ -21,7 +21,35 @@ class Index extends AbstractController
public function showIndex(Request $request, Auth $auth, Render $render, HandleLocations $locations): Response public function showIndex(Request $request, Auth $auth, Render $render, HandleLocations $locations): Response
{ {
$list = $locations->getActiveLocations(); $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"
);
} }
/** /**

@ -11,6 +11,7 @@ use Exception;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Uid\Uuid; use Symfony\Component\Uid\Uuid;
use Doctrine\DBAL\Connection;
use App\Entity\Location; use App\Entity\Location;
use League\Csv\Reader; use League\Csv\Reader;
@ -25,16 +26,59 @@ class HandleLocations
{ {
private $session; private $session;
private $entityManager; private $entityManager;
private $conn;
private $limit = 4; private $limit = 4;
public function __construct( public function __construct(
Connection $connection,
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,
RequestStack $requestStack RequestStack $requestStack
) { ) {
$this->connection = $connection;
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->session = $requestStack->getSession(); $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() public function getActiveLocations()
{ {
$listings = $this->entityManager->getRepository(Location::class); $listings = $this->entityManager->getRepository(Location::class);

@ -16,15 +16,12 @@
<a href="https://www.artistmarciax.com/">Artist Marcia X</a> <a href="https://www.artistmarciax.com/">Artist Marcia X</a>
with additional support from with additional support from
<a href="https://digital.rooting.garden">Ginger</a> <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> </p>
<p> <p>
Technial support provided by Technical support provided by
<a href="https://roiskinda.cool/profile.html">Ro</a>. <a href="https://roiskinda.cool/profile.html">Ro</a>.
</p> </p>
</section> </section>

@ -5,12 +5,29 @@
{% block main %} {% block main %}
<section role="start"> <section role="start">
<div> <div role="index-wrapper">
<span role="title">{{ options.count }}</span> <div role="index-search">
<p> <form action="{{ path('index') }}" method="post" enctype="multipart/form-data">
Bad Spaces tracked.<br/> <input type="text" name="index_search" value="" placeholder="Take a look"/>
Pace yourself. <button>
</p> <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> </div>
</section> </section>
{% endblock %} {% endblock %}

@ -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 %}
Loading…
Cancel
Save