diff --git a/public/assets/css/style.css b/public/assets/css/style.css new file mode 100644 index 0000000..9e6b0eb --- /dev/null +++ b/public/assets/css/style.css @@ -0,0 +1,182 @@ +/* Sommaire : +- body et html +- Header et ses contenues +- Body contenue + - Content + - Page de présentation des recettes + - Page d'une recette +- Footer + +*/ + +/*Tout*/ +html, body{ + height: 100%; + text-align: center; + /*font-size: 98%;*/ +} + + +/*Header et son contenu*/ +#header { + display: flex; + flex-direction: row; + padding: 3px; + padding-left: 2%; + padding-bottom: 10px; + background-color: blanchedalmond; +} + +#logo { + background-color: aqua; + background-image: url("Logo.jpg"); + /*background:no-repeat;*/ + height: 103px; + width: 141px; +} + +.logo{ + height: 100%; + width: 100%; + border: 1px white solid; + border-radius: 4px; + box-shadow: 1px 1px 1px black; +} + +nav { + flex: 9; + text-align: initial; + letter-spacing: 2px; + padding: 10px; +} + +.nav-list { + list-style-type: none; + margin: 0; + padding: 0; + background-color: rgb(255, 217, 160); + display: flex; + border: 1px solid rgba(0,0,0,.125); + border-radius: 40px; +} + + +.nav-element { + line-height: 2.5; + padding: 10px; +} + +/*Body et son contenu */ +body { + background-color: blanchedalmond; + display: flex; + flex-direction: column; + margin: 0; + padding: 0; + height: 100%; +} + +.sidebar { + background-color: aquamarine; + border: 1px solid rgba(0,0,0,.125); + border-radius: 10px; + width: 128px; +} + + +.main-body { + display: flex; + flex-direction: row; + overflow: auto; + flex: 1; + background-clip: border-box; + padding-right: 5%; + padding-left: 5%; +} + +/* content : le cadre de base du centre de notre site +*/ +.content { + background-color: #ffe4bb; + text-align: left; + width: 100%; + height: 100%; + border: 1px solid rgba(0,0,0,.125); + border-radius: 6px; + overflow: auto; +} + +/*Recettes : + représente le contenue centrale de la page. +*/ +.recettes { + --UneVariable: calc( 100vw / 500 ); + display: grid; + grid-template-columns: repeat(var(--UneVariable), 1fr); + grid-gap: 10px; + grid-auto-rows: minmax(300px, auto); + grid-auto-columns: auto; +} + +/* Classe recette icone : + C'est la classe de chaques éléments de notre liste de recette +*/ +.recette-icone{ + border: 3px solid rgba(0,0,0,.125); + border-radius: 40px; + text-align: left; + padding: 15px; + vertical-align: middle; + box-shadow: 3px 5px 5px black; + width: 500px; +} + +.recette-preview-image{ + max-width: calc( 10vh + 10vw ); + max-height: calc( 10vh + 10vw ); + border: 1px solid rgb(252, 223, 57); + border-radius: 25px; +} + +/*Ici commence le CSS pour la page de chaques recettes */ +/*contenue*/ +.recette-content { + display: flex; + flex-direction: column; +} + +/*titre*/ +.recette-title { + text-align: center; +} + +/*image*/ +.recette-image { + background-color: red; + aspect-ratio: 1/1; + max-height: calc( 30vh + 30vw ); + max-width: calc( 30vh + 30vw ); + border: 1px solid white; + border-radius: 30px; +} + +.recette-div-image { + display: flex; + justify-content: center; +} + +/*description*/ +.recette-desc { + padding : 10px; +} + + +/*Footer et son contenue*/ +footer{ + padding: 25px; + background: rgb(11, 189, 144); + color: white; +} + + + diff --git a/public/assets/images/Logo.jpg b/public/assets/images/Logo.jpg new file mode 100644 index 0000000..8310814 Binary files /dev/null and b/public/assets/images/Logo.jpg differ diff --git a/src/Domain/Recettes/RecettesAPIController.php b/src/Domain/Recettes/RecettesAPIController.php new file mode 100644 index 0000000..ec76612 --- /dev/null +++ b/src/Domain/Recettes/RecettesAPIController.php @@ -0,0 +1,16 @@ +recettes->list', routeAction: 'list', routeMethods: ['POST'] ), + ]; + + } +} \ No newline at end of file diff --git a/src/Domain/Recettes/RecettesController.php b/src/Domain/Recettes/RecettesController.php new file mode 100644 index 0000000..1ed1dc8 --- /dev/null +++ b/src/Domain/Recettes/RecettesController.php @@ -0,0 +1,24 @@ +index', routeAction: 'index', pageHeadTitle: 'Liste des recettes' ), + self::Route( routeUrl: '/recettes/{string}', routeName: 'recettes->show', routeAction: 'show', pageHeadTitle: 'Recette' ), + ]; + + } + + public function index(): View { + return new View( 'recettes/index', [] ); + } + +} \ No newline at end of file diff --git a/src/Domain/Recettes/RecettesManagementController.php b/src/Domain/Recettes/RecettesManagementController.php new file mode 100644 index 0000000..1a4cdab --- /dev/null +++ b/src/Domain/Recettes/RecettesManagementController.php @@ -0,0 +1,17 @@ +create', routeAction: 'create' ), + self::Route( routeUrl: '/recettes/edit/{int}', routeName: 'recettes->edit', routeAction: 'edit' ), + ]; + + } +} \ No newline at end of file diff --git a/src/Domain/Utilisateurs/AuthentificationController.php b/src/Domain/Utilisateurs/AuthentificationController.php new file mode 100644 index 0000000..04c1d30 --- /dev/null +++ b/src/Domain/Utilisateurs/AuthentificationController.php @@ -0,0 +1,57 @@ +auth', routeAction: 'auth', routeMethods: ['POST'] ), + self::Route( routeUrl: '/api/auth/logout', routeName: 'api->auth->logout', routeAction: 'logout', routeMethods: ['POST'] ), + + ]; + + } + + public function login(): View { + return new View( 'login' ); + } + + public function auth(): JSONResponse { + + Request::setCORS(); + + $username = Request::get( 'username' ); + $password = Request::get( 'password' ); + + // TODO : Récupération de l'utilisateur et verify_password. + + $userId = 1; + Authentification::loginUser( $userId ); + JSONResponse::sendSuccess( [ 'user_id' => $userId ] ); + + } + + public function logout(): JSONResponse { + + if( !Authentification::isLoggedIn() ) { + return JSONResponse::sendError( [ 'message' => 'Alrady disconnected' ] ); + } + + Authentification::destroySession(); + return JSONResponse::sendSuccess( [ 'message' => 'Logged out' ] ); + + } + +} \ No newline at end of file diff --git a/src/Helpers/Authentification.php b/src/Helpers/Authentification.php new file mode 100644 index 0000000..1c4a196 --- /dev/null +++ b/src/Helpers/Authentification.php @@ -0,0 +1,49 @@ +data = $data; + $this->htmlCode = $code; + + $this->returnResponse(); + } + + public function returnResponse(): never { + + header( 'Content-type: application/json' ); + http_response_code( $this->htmlCode ); + + $this->data['_status'] = $this->htmlCode; + $json = json_encode( $this->data ); + echo $json; + die(); + } + + public static function sendSuccess( $data = [] ): self { + $data['success'] = true; + return new self( $data, 200 ); + } + + public static function sendError( $data = [] ): self { + $data['success'] = false; + return new self( $data, 400 ); + } + +} \ No newline at end of file diff --git a/src/Http/Request.php b/src/Http/Request.php new file mode 100644 index 0000000..7172602 --- /dev/null +++ b/src/Http/Request.php @@ -0,0 +1,53 @@ +buildAutoloader(); $this->loadConfig(); + Authentification::startSession(); + try { Router::routeTo(); } catch ( InvalidRouteException $e ){ diff --git a/views/base.php b/views/base.php index c7aef16..2a8631b 100644 --- a/views/base.php +++ b/views/base.php @@ -2,6 +2,8 @@ - +
+ +
diff --git a/views/partials/footer.php b/views/partials/footer.php index da78eac..8015192 100644 --- a/views/partials/footer.php +++ b/views/partials/footer.php @@ -1,4 +1,14 @@ + diff --git a/views/partials/header.php b/views/partials/header.php index 150db74..792aadb 100644 --- a/views/partials/header.php +++ b/views/partials/header.php @@ -5,5 +5,19 @@ <?php echo V::getHeadTitle(); ?> + + diff --git a/views/recettes/index.php b/views/recettes/index.php new file mode 100644 index 0000000..df1e1f3 --- /dev/null +++ b/views/recettes/index.php @@ -0,0 +1,20 @@ + + + +
+
+ +
+ +
+
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
+