renamed 'search' to 'app_search' in router

This commit is contained in:
ZeKap 2024-02-22 09:05:55 +01:00
parent b68d533bac
commit c838a3d2ed
No known key found for this signature in database
GPG Key ID: 8D70E0631DD5792A
2 changed files with 50 additions and 52 deletions

View File

@ -11,7 +11,8 @@ use GuzzleHttp\Client;
class SearchController extends AbstractController
{
private static function makeRequest(string $method,string $endpoint, array $querryParams){
private static function makeRequest(string $method, string $endpoint, array $querryParams)
{
// Create a new Guzzle HTTP client
$baseUri = 'https://api.discogs.com/';
@ -19,35 +20,35 @@ class SearchController extends AbstractController
'base_uri' => $baseUri,
'timeout' => 2.0, // You can set request timeout (in seconds)
]);
// Set the base URI for the request and any default request options
$auth = array(
"key" => "kLzxeHuJCXRyQuBURaEN",
"secret" => "biDCkuoMbGLeDtQGqCPCtbVqmzPaVmQG"
);
// Create the query parameters array
$querryParams = array_merge($querryParams, $auth);
// Send a GET request to the specified URI with the query parameters
$response = $client->request($method, "/database/".$endpoint, [
$response = $client->request($method, "/database/" . $endpoint, [
'query' => $querryParams
]);
// Get the status code of the response
$statusCode = $response->getStatusCode();
// Get the body of the response
$body = $response->getBody()->getContents();
return json_decode($body,true);
return json_decode($body, true);
}
#[Route('/search', name: 'search')]
#[Route('/search', name: 'app_search')]
public function index(Request $request): Response
{
$page = $request->query->get('page');
$result = SearchController::makeRequest("GET","search",[
$result = SearchController::makeRequest("GET", "search", [
"q" => $request->query->get('q'),
"type" => "release",
"page" => strval($page),
@ -57,9 +58,9 @@ class SearchController extends AbstractController
return $this->render('search/search.html.twig', [
'controller_name' => 'SearchController',
'query' => $request->query->get('q'),
'page' => $request->query->get('page'),
'page' => $request->query->get('page'),
"next_page" => $page < $result["pagination"]["pages"] ? strval($page + 1) : strval($page),
"previous_page" => $page >1 ? strval($page - 1) : strval($page),
"previous_page" => $page > 1 ? strval($page - 1) : strval($page),
'results' => $result["results"]
]);
}

View File

@ -1,42 +1,39 @@
<!DOCTYPE html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}{{app.title}}{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>">
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('styles/app.css') }}"/>
<link rel="stylesheet" href="{{ asset('styles/fonts.css') }}"/>
{% endblock %}
{% block javascripts %}
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
</head>
<body>
{% block header %}
<header>
<a href="{{url('index')}}">Frutti</a>
<form action="{{url('search')}}" method="get">
<input type="text" name="q" id="q" placeholder="Search">
<label>
<input type="submit" value="search">
<img src="{{ asset('/styles/search.svg') }}" alt="Search">
</label>
</form>
<a href="{{url('app_login')}}" class="button-link">Connect</a>
</header>
{% endblock %}
<head>
<meta charset="UTF-8" />
<title>{% block title %}{{app.title}}{% endblock %}</title>
<link
rel="icon"
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text><text y=%221.3em%22 x=%220.2em%22 font-size=%2276%22 fill=%22%23fff%22>sf</text></svg>"
/>
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('styles/app.css') }}" />
<link rel="stylesheet" href="{{ asset('styles/fonts.css') }}" />
{% endblock %} {% block javascripts %} {% block importmap %}{{
importmap('app') }}{% endblock %} {% endblock %}
</head>
<body>
{% block header %}
<header>
<a href="{{url('index')}}">Frutti</a>
<form action="{{url('app_search')}}" method="get">
<input type="text" name="q" id="q" placeholder="Search" />
<label>
<input type="submit" value="search" />
<img src="{{ asset('/styles/search.svg') }}" alt="Search" />
</label>
</form>
<a href="{{url('app_login')}}" class="button-link">Connect</a>
</header>
{% endblock %}
<main>
{% block body %}{% endblock %}
</main>
{% block footer %}
<footer>
<p>Done by: Capelier 🏳️‍⚧️ — Rubini 💅 — Simaila 🤓</p>
</footer>
{% endblock %}
</body>
<main>{% block body %}{% endblock %}</main>
{% block footer %}
<footer>
<p>Done by: Capelier 🏳️‍⚧️ — Rubini 💅 — Simaila 🤓</p>
</footer>
{% endblock %}
</body>
</html>