Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Feat: configure app with yaml file (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlxisHenry committed Dec 20, 2022
1 parent 6074fa7 commit 1bbbe53
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
.env
vendor/
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"symfony/yaml": "^6.2"
}
}
175 changes: 175 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>CDN - HENRY Alexis</title>
<title><?= dashboard()->title ?></title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="./build/assets/favicon.ico" />
<!-- Font Awesome icons (free version)-->
Expand All @@ -21,7 +21,7 @@
<!-- Navigation-->
<nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand" href="#page-top">CDN</a>
<a class="navbar-brand" href="#page-top"><?= dashboard()->description ?></a>
<button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
Expand All @@ -41,17 +41,17 @@
<header class="masthead bg-primary text-white text-center">
<div class="container d-flex align-items-center flex-column">
<!-- Masthead Avatar Image-->
<img class="masthead-avatar mb-5" src="https://cdn.alexishenry.eu/shared/images/logo.png" alt="..." />
<img class="masthead-avatar mb-5" src="<?= dashboard()->image ?>" alt="..." />
<!-- Masthead Heading-->
<h1 class="masthead-heading text-uppercase mb-0">HENRY Alexis</h1>
<h1 class="masthead-heading text-uppercase mb-0"><?= dashboard()->owner->fullName ?></h1>
<!-- Icon Divider-->
<div class="divider-custom divider-light">
<div class="divider-custom-line"></div>
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
<div class="divider-custom-line"></div>
</div>
<!-- Masthead Subheading-->
<p class="masthead-subheading font-weight-light mb-0">bash only</p>
<p class="masthead-subheading font-weight-light mb-0"><?= dashboard()->owner->description ?></p>
</div>
</header>
<?php
Expand All @@ -63,7 +63,7 @@
?>
<!-- Copyright Section-->
<div class="copyright py-4 text-center text-white">
<div class="container"><small>Copyright &copy; CDN - HENRY Alexis 2022</small></div>
<div class="container"><small>&copy; <?= date('Y') . " " . dashboard()->title ?></small></div>
</div>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
Expand Down
16 changes: 16 additions & 0 deletions services/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

declare(strict_types=1);

require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/settings.php';

use Symfony\Component\Yaml\Yaml;

/**
* @return array
*/
Expand Down Expand Up @@ -89,4 +94,15 @@ function generateCategorySection(string $category, bool $background): string
".generateCategoryContentList($category)."
</div>
</section>";
}

/**
* @return object
*/
function dashboard(): object
{
// Parse settings yml file
$settings = Yaml::parseFile(__DIR__ . '/../settings.yml');
$dashboard = new Dashboard($settings['dashboard']);
return $dashboard;
}
98 changes: 98 additions & 0 deletions services/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

class Dashboard {

/**
* @var array
*/
private array $settings;

/**
* @var string
*/
public readonly string $title;

/**
* @var string
*/
public readonly string $description;

/**
* @var string $image
*/
public readonly string $image;

/**
* @var Owner
*/
public readonly Owner $owner;

public function __construct(array $settings)
{
$this->settings = $settings;
$this->setAttributes($settings);
}

/**
* @param array $credentials
* @return void
*/
private function setAttributes($settings): void
{
$this->title = $settings['title'];
$this->description = $settings['description'];
$this->image = $settings['image'];
$this->owner = new Owner($settings['owner']);
}


}

class Owner {

/**
* @var string $name
*/
public readonly string $name;

/**
* @var string $firstname
*/
public readonly string $firstname;

/**
* @var string $description
*/
public readonly string $description;

/**
* @var string $fullName
*/
public readonly string $fullName;

public function __construct(array $credentials)
{
$this->setAttributes($credentials);
}

/**
* @param array $credentials
* @return void
*/
private function setAttributes(array $credentials): void
{
$this->name = $credentials['name'];
$this->firstname = $credentials['firstname'];
$this->description = $credentials['description'];
$this->setFullName();
}

/**
* @return void
*/
private function setFullName(): void
{
$this->fullName = $this->firstname . ' ' . $this->name;
}

}
8 changes: 8 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
dashboard:
title: "CDN - HENRY Alexis"
description: "CDN"
image: "https://cdn.alexishenry.eu/shared/images/logo.png"
owner:
name: "Henry"
firstname: "Alexis"
description: "bash only"

0 comments on commit 1bbbe53

Please sign in to comment.