Fix staging server deployment #24

Merged
maxime.batista merged 2 commits from staging/fix into master 1 year ago

@ -30,6 +30,5 @@ echo "];" >> views-mappings.php
chmod +r views-mappings.php chmod +r views-mappings.php
// moshell does not supports file patterns mv dist/* front/assets/ front/style/ public/* /outputs/public/
bash <<< "mv dist/* public/* front/assets/ front/style/ /outputs/public/"
mv views-mappings.php /outputs/ mv views-mappings.php /outputs/

@ -27,7 +27,7 @@ function getAuthController(): APIAuthController {
function getRoutes(): AltoRouter { function getRoutes(): AltoRouter {
$router = new AltoRouter(); $router = new AltoRouter();
$router->setBasePath(get_public_path() . "/api"); $router->setBasePath(get_public_path(__DIR__));
$router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc))); $router->map("POST", "/tactic/[i:id]/edit/name", Action::auth(fn(int $id, Account $acc) => getTacticController()->updateName($id, $acc)));
$router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize())); $router->map("POST", "/auth", Action::noAuth(fn() => getAuthController()->authorize()));

@ -0,0 +1 @@
../front/assets

@ -29,6 +29,9 @@ use IQBall\Core\Model\AuthModel;
use IQBall\Core\Model\TacticModel; use IQBall\Core\Model\TacticModel;
use IQBall\Core\Model\TeamModel; use IQBall\Core\Model\TeamModel;
use IQBall\Core\Validation\ValidationFail; use IQBall\Core\Validation\ValidationFail;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
use Twig\TwigFunction;
function getConnection(): Connection { function getConnection(): Connection {
return new Connection(get_database()); return new Connection(get_database());
@ -55,6 +58,16 @@ function getAuthController(): AuthController {
return new AuthController(new AuthModel(new AccountGateway(getConnection()))); return new AuthController(new AuthModel(new AccountGateway(getConnection())));
} }
function getTwig(): Environment {
global $basePath;
$fl = new FilesystemLoader("../src/App/Views");
$twig = new Environment($fl);
maxime.batista marked this conversation as resolved
Review

Because path concatenation cannot always be resumed to a simple string concatenation, exposing a path(string) function would hide this base path.

use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class PathExtension extends AbstractExtension {
    private string $basePath;

    public function __construct(string $basePath) {
        $this->basePath = $basePath;
    }

    /**
     * @return TwigFunction[]
     */
    public function getFunctions(): array {
        return [new TwigFunction('path', fn(string $path): string => $this->basePath . '/' . $path)];
    }
}
// Register the extension
$twig->addExtension(new PathExtension($basePath));

// Or just register use this shortcut:
$twig->addFunction(new TwigFunction('path', fn(string $path): string => $this->basePath . '/' . $path));
<a class="button" href="{{ path('home') }}">Retour à la page d'accueil</a>
Because path concatenation cannot always be resumed to a simple string concatenation, exposing a `path(string)` function would hide this base path. ```php use Twig\Extension\AbstractExtension; use Twig\TwigFunction; class PathExtension extends AbstractExtension { private string $basePath; public function __construct(string $basePath) { $this->basePath = $basePath; } /** * @return TwigFunction[] */ public function getFunctions(): array { return [new TwigFunction('path', fn(string $path): string => $this->basePath . '/' . $path)]; } } ``` ```php // Register the extension $twig->addExtension(new PathExtension($basePath)); // Or just register use this shortcut: $twig->addFunction(new TwigFunction('path', fn(string $path): string => $this->basePath . '/' . $path)); ``` ```twig <a class="button" href="{{ path('home') }}">Retour à la page d'accueil</a> ```
$twig->addFunction(new TwigFunction('path', fn(string $str) => "$basePath$str"));
return $twig;
}
function getRoutes(): AltoRouter { function getRoutes(): AltoRouter {
global $basePath; global $basePath;
@ -104,6 +117,6 @@ function runMatch($match, MutableSessionHandle $session): HttpResponse {
//this is a global variable //this is a global variable
$basePath = get_public_path(); $basePath = get_public_path(__DIR__);
App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), "../src/App/Views/"); App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig());

@ -19,8 +19,8 @@ class API {
if ($response instanceof JsonHttpResponse) { if ($response instanceof JsonHttpResponse) {
header('Content-type: application/json'); header('Content-type: application/json');
echo $response->getJson(); echo $response->getJson();
} else { } else if (get_class($response) != HttpResponse::class) {
throw new Exception("API returned a non-json response."); throw new Exception("API returned unknown Http Response");
} }
} }

@ -2,8 +2,8 @@
namespace IQBall\Api\Controller; namespace IQBall\Api\Controller;
use IQBall\App\Control;
use IQBall\Core\Http\HttpCodes; use IQBall\Core\Http\HttpCodes;
use IQBall\Core\Route\Control;
use IQBall\Core\Http\HttpRequest; use IQBall\Core\Http\HttpRequest;
use IQBall\Core\Http\HttpResponse; use IQBall\Core\Http\HttpResponse;
use IQBall\Core\Http\JsonHttpResponse; use IQBall\Core\Http\JsonHttpResponse;

@ -2,7 +2,7 @@
namespace IQBall\Api\Controller; namespace IQBall\Api\Controller;
use IQBall\Core\Route\Control; use IQBall\App\Control;
use IQBall\Core\Data\Account; use IQBall\Core\Data\Account;
use IQBall\Core\Http\HttpCodes; use IQBall\Core\Http\HttpCodes;
use IQBall\Core\Http\HttpRequest; use IQBall\Core\Http\HttpRequest;

@ -16,13 +16,13 @@ class App {
/** /**
* renders (prints out) given HttpResponse to the client * renders (prints out) given HttpResponse to the client
* @param HttpResponse $response * @param HttpResponse $response
* @param string $twigViewsFolder * @param callable(): Environment $twigSupplier
* @return void * @return void
* @throws LoaderError * @throws LoaderError
* @throws RuntimeError * @throws RuntimeError
* @throws SyntaxError * @throws SyntaxError
*/ */
public static function render(HttpResponse $response, string $twigViewsFolder): void { public static function render(HttpResponse $response, callable $twigSupplier): void {
http_response_code($response->getCode()); http_response_code($response->getCode());
foreach ($response->getHeaders() as $header => $value) { foreach ($response->getHeaders() as $header => $value) {
@ -30,7 +30,7 @@ class App {
} }
if ($response instanceof ViewHttpResponse) { if ($response instanceof ViewHttpResponse) {
self::renderView($response, $twigViewsFolder); self::renderView($response, $twigSupplier);
} elseif ($response instanceof JsonHttpResponse) { } elseif ($response instanceof JsonHttpResponse) {
header('Content-type: application/json'); header('Content-type: application/json');
echo $response->getJson(); echo $response->getJson();
@ -40,13 +40,13 @@ class App {
/** /**
* renders (prints out) given ViewHttpResponse to the client * renders (prints out) given ViewHttpResponse to the client
* @param ViewHttpResponse $response * @param ViewHttpResponse $response
* @param string $twigViewsFolder * @param callable(): Environment $twigSupplier
* @return void * @return void
* @throws LoaderError * @throws LoaderError
* @throws RuntimeError * @throws RuntimeError
* @throws SyntaxError * @throws SyntaxError
*/ */
private static function renderView(ViewHttpResponse $response, string $twigViewsFolder): void { private static function renderView(ViewHttpResponse $response, callable $twigSupplier): void {
$file = $response->getFile(); $file = $response->getFile();
$args = $response->getArguments(); $args = $response->getArguments();
@ -56,10 +56,9 @@ class App {
break; break;
case ViewHttpResponse::TWIG_VIEW: case ViewHttpResponse::TWIG_VIEW:
try { try {
$fl = new FilesystemLoader($twigViewsFolder); $twig = call_user_func($twigSupplier);
$twig = new Environment($fl);
$twig->display($file, $args); $twig->display($file, $args);
} catch (RuntimeError | SyntaxError | LoaderError $e) { } catch (RuntimeError|SyntaxError|LoaderError $e) {
http_response_code(500); http_response_code(500);
echo "There was an error rendering your view, please refer to an administrator.\nlogs date: " . date("YYYD, d M Y H:i:s"); echo "There was an error rendering your view, please refer to an administrator.\nlogs date: " . date("YYYD, d M Y H:i:s");
throw $e; throw $e;

@ -1,12 +1,10 @@
<?php <?php
namespace IQBall\Core\Route; namespace IQBall\App;
use IQBall\App\ViewHttpResponse;
use IQBall\Core\Http\HttpCodes; use IQBall\Core\Http\HttpCodes;
use IQBall\Core\Http\HttpRequest; use IQBall\Core\Http\HttpRequest;
use IQBall\Core\Http\HttpResponse; use IQBall\Core\Http\HttpResponse;
use IQBall\Core\Http\JsonHttpResponse;
use IQBall\Core\Validation\ValidationFail; use IQBall\Core\Validation\ValidationFail;
use IQBall\Core\Validation\Validator; use IQBall\Core\Validation\Validator;

@ -1,24 +1,23 @@
<!doctype html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" <meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Paramètres</title> <title>Paramètres</title>
<style> <style>
body { body {
padding-left: 10%; padding-left: 10%;
padding-right: 10%; padding-right: 10%;
} }
</style> </style>
</head> </head>
<body>
<body> <button onclick="location.pathname='{{ path('/home') }}'">Retour</button>
<button onclick="location.pathname='/home'">Retour</button> <h1>Paramètres</h1>
<h1>Paramètres</h1> </body>
</body>
</html> </html>

@ -59,11 +59,11 @@
background-color: #0056b3; background-color: #0056b3;
} }
.role{ .role {
margin-top: 10px; margin-top: 10px;
} }
.radio{ .radio {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
@ -73,7 +73,7 @@
<div class="container"> <div class="container">
<h2>Ajouter un membre à votre équipe</h2> <h2>Ajouter un membre à votre équipe</h2>
<form action="/team/members/add" method="POST"> <form action="{{ path('/team/members/add') }}" method="POST">
<div class="form-group"> <div class="form-group">
<label for="team">Team où ajouter le membre :</label> <label for="team">Team où ajouter le membre :</label>
<input type="text" id="team" name="team" required> <input type="text" id="team" name="team" required>
@ -81,7 +81,7 @@
<input type="text" id="mail" name="mail" required> <input type="text" id="mail" name="mail" required>
<fieldset class="role"> <fieldset class="role">
<legend >Rôle du membre dans l'équipe :</legend> <legend>Rôle du membre dans l'équipe :</legend>
<div class="radio"> <div class="radio">
<label for="P">Joueur</label> <label for="P">Joueur</label>
<input type="radio" id="P" name="role" value="P" checked /> <input type="radio" id="P" name="role" value="P" checked />

@ -56,7 +56,7 @@
<div class="container"> <div class="container">
<h2>Supprimez un membre de votre équipe</h2> <h2>Supprimez un membre de votre équipe</h2>
<form action="/team/members/remove" method="POST"> <form action="{{ path('/team/members/remove') }}" method="POST">
<div class="form-group"> <div class="form-group">
<label for="team">Team où supprimer le membre :</label> <label for="team">Team où supprimer le membre :</label>
<input type="text" id="team" name="team" required> <input type="text" id="team" name="team" required>

@ -53,30 +53,35 @@
background-color: #0056b3; background-color: #0056b3;
} }
.error-messages{ .error-messages {
color : #ff331a; color: #ff331a;
font-style: italic; font-style: italic;
} }
{% for err in fails %} {% for err in fails %}
.form-group #{{ err.getFieldName() }} { .form-group
border-color: red;
#
{{ err.getFieldName() }}
{
border-color: red
;
} }
{% endfor %} {% endfor %}
</style> </style>
<div class="container"> <div class="container">
<center><h2>Se connecter</h2></center> <center><h2>Se connecter</h2></center>
<form action="login" method="post"> <form action="{{ path('/login') }}" method="post">
<div class="form-group"> <div class="form-group">
{% for name in fails %} {% for name in fails %}
<label class="error-messages"> {{ name.getFieldName() }} : {{ name.getMessage()}} </label> <label class="error-messages"> {{ name.getFieldName() }} : {{ name.getMessage() }} </label>
{% endfor %} {% endfor %}
<label for="email">Email :</label> <label for="email">Email :</label>
<input type="text" id="email" name="email" required> <input type="text" id="email" name="email" required>
<label for= "password">Mot de passe :</label> <label for="password">Mot de passe :</label>
<input type="password" id="password" name="password" required> <input type="password" id="password" name="password" required>
</div> </div>

@ -49,8 +49,8 @@
cursor: pointer; cursor: pointer;
} }
.error-messages{ .error-messages {
color : #ff331a; color: #ff331a;
font-style: italic; font-style: italic;
} }
@ -59,27 +59,31 @@
} }
{% for err in fails %} {% for err in fails %}
.form-group #{{ err.getFieldName() }} { .form-group
border-color: red;
#
{{ err.getFieldName() }}
{
border-color: red
;
} }
{% endfor %} {% endfor %}
</style> </style>
<div class="container"> <div class="container">
<center><h2>S'enregistrer</h2></center> <center><h2>S'enregistrer</h2></center>
<form action="register" method="post"> <form action="{{ path('/register') }}" method="post">
<div class="form-group"> <div class="form-group">
{% for name in fails %} {% for name in fails %}
<label class = "error-messages"> {{ name.getFieldName() }} : {{ name.getMessage() }} </label> <label class="error-messages"> {{ name.getFieldName() }} : {{ name.getMessage() }} </label>
{% endfor %} {% endfor %}
<label for="username">Nom d'utilisateur :</label> <label for="username">Nom d'utilisateur :</label>
<input type="text" id="username" name="username" required> <input type="text" id="username" name="username" required>
<label for= "password">Mot de passe :</label> <label for="password">Mot de passe :</label>
<input type="password" id="password" name="password" required> <input type="password" id="password" name="password" required>
<label for="confirmpassword">Confirmer le mot de passe :</label> <label for="confirmpassword">Confirmer le mot de passe :</label>
<input type="password" id="confirmpassword" name="confirmpassword" required> <input type="password" id="confirmpassword" name="confirmpassword" required>

@ -1,85 +1,91 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Twig view</title> <title>Twig view</title>
<style> <style>
body{ body {
background-color: #f1f1f1; background-color: #f1f1f1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
section{ section {
width: 60%; width: 60%;
} }
.square{ .square {
width:50px; width: 50px;
height:50px; height: 50px;
} }
#main_color { #main_color {
border: solid; border: solid;
background-color: {{ team.getInfo().getMainColor().getValue() }}; background-color: {{ team.getInfo().getMainColor().getValue() }};
} }
#second_color{
background-color: {{ team.getInfo().getSecondColor().getValue() }};
border: solid;
}
.container{ #second_color {
background-color: #fff; background-color: {{ team.getInfo().getSecondColor().getValue() }};
display: flex; border: solid;
flex-direction: column; }
align-items: center;
}
.team{
border-color: darkgrey;
border-radius: 20px;
} .container {
background-color: #fff;
display: flex;
flex-direction: column;
align-items: center;
}
.color{ .team {
flex-direction: row; border-color: darkgrey;
justify-content: space-between; border-radius: 20px;
}
.logo{ }
height: 80px;
width: 80px;
}
</style> .color {
</head> flex-direction: row;
<body> justify-content: space-between;
<header> }
<h1><a href="/">IQBall</a></h1>
</header>
<section class="container"> .logo {
height: 80px;
width: 80px;
}
<div class="team container"> </style>
<div> </head>
<h1>{{ team.getInfo().getName() }}</h1> <body>
<img src="{{ team.getInfo().getPicture() }}" alt="Logo d'équipe" class="logo"> <header>
</div> <h1><a href="{{ path('/') }}">IQBall</a></h1>
<div> </header>
<div class="color"><p>Couleur principale : </p><div class="square" id="main_color"></div> </div>
<div class="color"><p>Couleur secondaire : </p><div class="square" id="second_color"></div></div>
</div>
{% for m in team.listMembers() %} <section class="container">
<p> {{ m.getUserId() }} </p>
{% if m.getRole().isCoach() %} <div class="team container">
<p> : Coach</p> <div>
{% else %} <h1>{{ team.getInfo().getName() }}</h1>
<p> : Joueur</p> <img src="{{ team.getInfo().getPicture() }}" alt="Logo d'équipe" class="logo">
{% endif %} </div>
{% endfor %} <div>
<div class="color"><p>Couleur principale : </p>
<div class="square" id="main_color"></div>
</div>
<div class="color"><p>Couleur secondaire : </p>
<div class="square" id="second_color"></div>
</div> </div>
</div>
{% for m in team.listMembers() %}
<p> {{ m.getUserId() }} </p>
{% if m.getRole().isCoach() %}
<p> : Coach</p>
{% else %}
<p> : Joueur</p>
{% endif %}
{% endfor %}
</div>
</section> </section>
</body> </body>
</html> </html>

@ -10,7 +10,7 @@
<p>Aucune équipe n'a été trouvée</p> <p>Aucune équipe n'a été trouvée</p>
<div class="container"> <div class="container">
<h2>Chercher une équipe</h2> <h2>Chercher une équipe</h2>
<form action="/team/search" method="post"> <form action="{{ path('/team/search') }}" method="post">
<div class="form-group"> <div class="form-group">
<label for="name">Nom de l'équipe :</label> <label for="name">Nom de l'équipe :</label>
<input type="text" id="name" name="name" required> <input type="text" id="name" name="name" required>
@ -22,7 +22,7 @@
</div> </div>
{% else %} {% else %}
{% for t in teams %} {% for t in teams %}
<div class="team" onclick="window.location.href = '/team/{{ t.id }}'"> <div class="team" onclick="window.location.href = '{{ path("/team/#{t.id}") }}'">
<p>Nom de l'équipe : {{ t.name }}</p> <p>Nom de l'équipe : {{ t.name }}</p>
<img src="{{ t.picture }}" alt="logo de l'équipe"> <img src="{{ t.picture }}" alt="logo de l'équipe">
</div> </div>

@ -1,57 +1,57 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Error</title> <title>Error</title>
<style> <style>
body { body {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100vh; height: 100vh;
margin: 0; margin: 0;
} }
h1 { h1 {
color: #da6110; color: #da6110;
text-align: center; text-align: center;
margin-bottom: 15px margin-bottom: 15px
} }
h2 { h2 {
text-align: center; text-align: center;
margin-bottom: 15px; margin-bottom: 15px;
margin-top: 15px margin-top: 15px
} }
.button { .button {
display: block; display: block;
cursor : pointer; cursor: pointer;
background-color: white; background-color: white;
color : black; color: black;
text-align: center; text-align: center;
font-size: 20px; font-size: 20px;
border-radius: 12px; border-radius: 12px;
border : 2px solid #da6110; border: 2px solid #da6110;
margin-top: 15px; margin-top: 15px;
} }
.button:hover { .button:hover {
background-color: #da6110 background-color: #da6110
} }
</style> </style>
</head> </head>
<body> <body>
<h1>IQBall</h1> <h1>IQBall</h1>
{% for fail in failures %} {% for fail in failures %}
<h2>{{ fail.getKind() }} : {{ fail.getMessage() }}</h2> <h2>{{ fail.getKind() }} : {{ fail.getMessage() }}</h2>
{% endfor %} {% endfor %}
<button class="button" onclick="location.href='/home'" type="button">Retour à la page d'accueil</button> <button class="button" onclick="location.href='{{ path('/home') }}'" type="button">Retour à la page d'accueil</button>
</body> </body>
</html> </html>

@ -14,81 +14,83 @@
} }
#bandeau { #bandeau {
display : flex; display: flex;
flex-direction : row; flex-direction: row;
} }
#bandeau > h1 { #bandeau > h1 {
self-align : center; self-align: center;
padding : 0%; padding: 0%;
margin : 0%; margin: 0%;
justify-content : center; justify-content: center;
} }
#account { #account {
display : flex; display: flex;
flex-direction : column; flex-direction: column;
align-content : center; align-content: center;
} }
#account:hover { #account:hover {
background-color : gray; background-color: gray;
} }
#account img { #account img {
width : 70%; width: 70%;
height : auto; height: auto;
align-self : center; align-self: center;
padding : 5%; padding: 5%;
margin : 0%; margin: 0%;
} }
#account p { #account p {
align-self : center; align-self: center;
} }
</style> </style>
</head> </head>
<body> <body>
<div id="bandeau"> <div id="bandeau">
<h1>IQ Ball</h1> <h1>IQ Ball</h1>
<div id="account" onclick="location.pathname='/settings'"> <div id="account" onclick="location.pathname='{{ path('/settings') }}'">
<img <img
src="../../../front/assets/icon/account.svg" src="{{ path('/assets/icon/account.svg') }}"
alt="Account logo" alt="Account logo"
/> />
<p>Mon profil<p> <p>Mon profil
</div> <p>
</div> </div>
</div>
<h2>Mes équipes</h2> <h2>Mes équipes</h2>
<button onclick="location.pathname='/team/new'"> Créer une nouvelle équipe </button> <button onclick="location.pathname='{{ path('/team/new') }}'"> Créer une nouvelle équipe</button>
{% if recentTeam != null %} {% if recentTeam != null %}
{% for team in recentTeam %} {% for team in recentTeam %}
<div> <div>
<p> {{team.name}} </p> <p> {{ team.name }} </p>
</div> </div>
{% endfor %} {% endfor %}
{% else %} {% else %}
<p>Aucune équipe créé !</p> <p>Aucune équipe créé !</p>
{% endif %} {% endif %}
<h2> Mes strategies </h2> <h2> Mes strategies </h2>
<button onclick="location.pathname='/tactic/new'"> Créer une nouvelle tactique </button> <button onclick="location.pathname='{{ path('/tactic/new') }}'"> Créer une nouvelle tactique</button>
{% if recentTactic != null %} {% if recentTactic != null %}
{% for tactic in recentTactic %} {% for tactic in recentTactic %}
<div onclick="location.pathname=/tactic/{{ strategie.id }}/edit"> <div onclick="location.pathname='{{ path("/tactic/#{strategie.id}/edit") }}'">
<p> {{tactic.id}} - {{tactic.name}} - {{tactic.creation_date}} </p> <p> {{ tactic.id }} - {{ tactic.name }} - {{ tactic.creation_date }} </p>
<button onclick="location.pathname='/tactic/{{ tactic.id }}/edit'"> Editer la stratégie {{tactic.id}} </button> <button onclick="location.pathname='{{ path("/tactic/#{tactic.id}/edit") }}'"> Editer la
</div> stratégie {{ tactic.id }} </button>
{% endfor %} </div>
{% else %} {% endfor %}
<p> Aucune tactique créé !</p> {% else %}
{% endif %} <p> Aucune tactique créé !</p>
{% endif %}
</body> </body>
</html> </html>

@ -34,10 +34,7 @@
{% for item in bad_fields %} {% for item in bad_fields %}
#{{ item }}{ #{{ item }}{
border-color: red; border-color: red;
} }{% endfor %} input[type="text"], input[type="password"] {
{% endfor %}
input[type="text"], input[type="password"] {
width: 100%; width: 100%;
padding: 10px; padding: 10px;
border: 1px solid #ccc; border: 1px solid #ccc;
@ -64,12 +61,12 @@
<div class="container"> <div class="container">
<h2>Créer une équipe</h2> <h2>Créer une équipe</h2>
<form action="/team/new" method="post"> <form action="{{ path('/team/new') }}" method="post">
<div class="form-group"> <div class="form-group">
<label for="name">Nom de l'équipe :</label> <label for="name">Nom de l'équipe :</label>
<input type="text" id="name" name="name" required> <input type="text" id="name" name="name" required>
<label for= "picture">Logo:</label> <label for="picture">Logo:</label>
<input type="text" id="picture" name="picture" required > <input type="text" id="picture" name="picture" required>
<label for="main_color">Couleur principale</label> <label for="main_color">Couleur principale</label>
<input type="color" id="main_color" name="main_color" required> <input type="color" id="main_color" name="main_color" required>
<label for="second_color">Couleur secondaire</label> <label for="second_color">Couleur secondaire</label>

@ -34,10 +34,7 @@
{% for item in bad_fields %} {% for item in bad_fields %}
#{{ item }}{ #{{ item }}{
border-color: red; border-color: red;
} }{% endfor %} input[type="text"], input[type="password"] {
{% endfor %}
input[type="text"], input[type="password"] {
width: 100%; width: 100%;
padding: 10px; padding: 10px;
border: 1px solid #ccc; border: 1px solid #ccc;
@ -62,7 +59,7 @@
<div class="container"> <div class="container">
<h2>Chercher une équipe</h2> <h2>Chercher une équipe</h2>
<form action="/team/search" method="post"> <form action="{{ path('/team/search') }}" method="post">
<div class="form-group"> <div class="form-group">
<label for="name">Nom de l'équipe :</label> <label for="name">Nom de l'équipe :</label>
<input type="text" id="name" name="name" required> <input type="text" id="name" name="name" required>

@ -3,9 +3,9 @@
/** /**
* relative path of the public directory from the server's document root. * relative path of the public directory from the server's document root.
*/ */
function get_public_path(): string { function get_public_path(string $public_dir): string {
// find the server path of the index.php file // find the server path of the index.php file
$basePath = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])); $basePath = substr($public_dir, strlen($_SERVER['DOCUMENT_ROOT']));
$basePathLen = strlen($basePath); $basePathLen = strlen($basePath);
if ($basePathLen == 0) { if ($basePathLen == 0) {

Loading…
Cancel
Save