Compare commits
3 commits
6bafa8f0e6
...
2d27370670
Author | SHA1 | Date | |
---|---|---|---|
2d27370670 | |||
2ab152e158 | |||
2aa3bce5f7 |
12 changed files with 42 additions and 174 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -5,4 +5,8 @@ vendor
|
||||||
datas/config.json
|
datas/config.json
|
||||||
datas/*/*/*/*.md
|
datas/*/*/*/*.md
|
||||||
datas/*/*.md
|
datas/*/*.md
|
||||||
datas/template/*.php
|
datas/template/*.php
|
||||||
|
datas/.sync_*
|
||||||
|
datas/.nextcloudsync.log
|
||||||
|
datas/.syncthing..sync_ef35b144b904.db-shm.tmp
|
||||||
|
launch.json
|
|
@ -122,7 +122,8 @@ class Blogs {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function findPostBySlug(string $slug): string {
|
public function findPostBySlug(string $slug): string {
|
||||||
if ($this->mdFileCache[$slug] && file_exists($this->mdFileCache[$slug]['file'])) {
|
debug::n_print($slug);
|
||||||
|
if (!empty($this->mdFileCache[$slug]) && file_exists($this->mdFileCache[$slug]['file'])) {
|
||||||
return file_get_contents($this->mdFileCache[$slug]['file']);
|
return file_get_contents($this->mdFileCache[$slug]['file']);
|
||||||
} else {
|
} else {
|
||||||
return file_get_contents($this->notFound['file']);
|
return file_get_contents($this->notFound['file']);
|
||||||
|
@ -173,7 +174,10 @@ class Blogs {
|
||||||
* @return array The information of the markdown file
|
* @return array The information of the markdown file
|
||||||
*/
|
*/
|
||||||
public function returnPostInfo(string $slug): array {
|
public function returnPostInfo(string $slug): array {
|
||||||
return $this->mdFileCache[$slug];
|
if (isset($this->mdFileCache[$slug])) {
|
||||||
|
return $this->mdFileCache[$slug];
|
||||||
|
}
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,10 +285,13 @@ class Blogs {
|
||||||
* @param string $markdownContent The markdown content to extract the lead paragraph from
|
* @param string $markdownContent The markdown content to extract the lead paragraph from
|
||||||
* @return string|null The extracted lead paragraph or null
|
* @return string|null The extracted lead paragraph or null
|
||||||
*/
|
*/
|
||||||
static function extractLead(string $markdownContent): ?string {
|
static function extractLead(string $markdownFile): ?string {
|
||||||
$pattern = '/---\s*(.*?)\s*---/s';
|
if (file_exists($markdownFile)) {
|
||||||
if (preg_match($pattern, $markdownContent, $matches)) {
|
$markdownContent = file_get_contents($markdownFile);
|
||||||
return trim($matches[1]);
|
$pattern = '/---\s*(.*?)\s*---/s';
|
||||||
|
if (preg_match($pattern, $markdownContent, $matches)) {
|
||||||
|
return trim($matches[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,19 +46,22 @@ class Cache {
|
||||||
} elseif ($params['type'] === 'post') {
|
} elseif ($params['type'] === 'post') {
|
||||||
$postList = new Blogs($params);
|
$postList = new Blogs($params);
|
||||||
$postAttr = $postList->returnPostInfo($params['slug']);
|
$postAttr = $postList->returnPostInfo($params['slug']);
|
||||||
$mdModifiedTime = filemtime($postAttr['file']);
|
if (isset($postAttr['file']) && file_exists($postAttr['file'])) {
|
||||||
|
$mdModifiedTime = filemtime($postAttr['file']);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} elseif ($params['type'] === 'posts') {
|
} elseif ($params['type'] === 'posts') {
|
||||||
$mdModifiedTime = 0;
|
$mdModifiedTime = 0;
|
||||||
} elseif(file_exists(self::$fileDir . '/' . $params['type'] . 's' . $params['requestUrl'] . '.md')) {
|
} elseif (file_exists(self::$fileDir . '/' . $params['type'] . 's' . $params['requestUrl'] . '.md')) {
|
||||||
$mdModifiedTime = filemtime(self::$fileDir . '/' . $params['type'] . 's' . $params['requestUrl'] . '.md');
|
$mdModifiedTime = filemtime(self::$fileDir . '/' . $params['type'] . 's' . $params['requestUrl'] . '.md');
|
||||||
}
|
}
|
||||||
$cacheModifiedTime = filemtime(self::$pathCacheDir[$params['type']] . '/' . $params['cacheName']);
|
$cacheModifiedTime = filemtime(self::$pathCacheDir[$params['type']] . '/' . $params['cacheName']);
|
||||||
|
|
||||||
if ($mdModifiedTime > $cacheModifiedTime) {
|
if ($mdModifiedTime > $cacheModifiedTime) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,6 @@ use App\Blogs\Blogs;
|
||||||
use App\Cache;
|
use App\Cache;
|
||||||
use App\Fetching\Gitea;
|
use App\Fetching\Gitea;
|
||||||
use App\Fetching\NanoGal;
|
use App\Fetching\NanoGal;
|
||||||
use App\Utils\Debug;
|
|
||||||
use App\Fetching\Shaarli;
|
use App\Fetching\Shaarli;
|
||||||
|
|
||||||
class Home {
|
class Home {
|
||||||
|
@ -73,6 +72,12 @@ class Home {
|
||||||
$lastPics = $nanogalCache;
|
$lastPics = $nanogalCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$homeContent = file_get_contents('../datas/pages/home.md');
|
||||||
|
$homeContent = preg_replace("/<% lastPost %>/", $lastPost, $homeContent);
|
||||||
|
$homeContent = preg_replace("/<% lastShaare %>/", $lastShaare, $homeContent);
|
||||||
|
$homeContent = preg_replace("/<% lastAppsUpdates %>/", $lastAppsUpdates, $homeContent);
|
||||||
|
$homeContent = preg_replace("/<% lastPics %>/", $lastPics, $homeContent);
|
||||||
|
|
||||||
require __DIR__ . '/../../template/home.php';
|
require __DIR__ . '/../../template/home.php';
|
||||||
$content = ob_get_contents();
|
$content = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
|
@ -58,7 +58,6 @@ class NanoGal {
|
||||||
*/
|
*/
|
||||||
public function makeList(): ?string {
|
public function makeList(): ?string {
|
||||||
if (!empty($this->bookmarkList)) {
|
if (!empty($this->bookmarkList)) {
|
||||||
|
|
||||||
$htmlBookmark = '';
|
$htmlBookmark = '';
|
||||||
foreach ($this->bookmarkList as $value) {
|
foreach ($this->bookmarkList as $value) {
|
||||||
$htmlBookmark .='
|
$htmlBookmark .='
|
||||||
|
@ -67,8 +66,6 @@ class NanoGal {
|
||||||
<figcaption>' . $value['title'] . '</figcaption>
|
<figcaption>' . $value['title'] . '</figcaption>
|
||||||
</figure>';
|
</figure>';
|
||||||
}
|
}
|
||||||
$htmlBookmark .= '
|
|
||||||
</ul>';
|
|
||||||
return $htmlBookmark;
|
return $htmlBookmark;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -32,10 +32,13 @@ class Router {
|
||||||
* @return array|false Returns an array containing the target and parameters
|
* @return array|false Returns an array containing the target and parameters
|
||||||
*/
|
*/
|
||||||
public function match(array $config): array|false {
|
public function match(array $config): array|false {
|
||||||
|
$extraParams = [];
|
||||||
$requestMethod = $_SERVER['REQUEST_METHOD'];
|
$requestMethod = $_SERVER['REQUEST_METHOD'];
|
||||||
$this->requestUrl = $requestUrl = strtok($_SERVER['REQUEST_URI'], '?');
|
$this->requestUrl = $requestUrl = strtok($_SERVER['REQUEST_URI'], '?');
|
||||||
|
|
||||||
parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY), $extraParams);
|
if (!empty(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY))) {
|
||||||
|
parse_str(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY), $extraParams);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->routes as $route) {
|
foreach ($this->routes as $route) {
|
||||||
list($method, $url, $target) = $route;
|
list($method, $url, $target) = $route;
|
||||||
|
|
|
@ -6,11 +6,11 @@ class Selected {
|
||||||
|
|
||||||
static function selected($var, $ref) {
|
static function selected($var, $ref) {
|
||||||
$testPostsPage = explode('/', $ref);
|
$testPostsPage = explode('/', $ref);
|
||||||
if ($testPostsPage[1] === 'post') {
|
if (isset($testPostsPage[1]) && $testPostsPage[1] === 'post') {
|
||||||
$ref = '/posts';
|
$ref = '/posts';
|
||||||
}
|
}
|
||||||
if ($var === $ref) {
|
if ($var === $ref) {
|
||||||
return 'active';
|
return 'active';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
2
public/assets/css/app-min.css
vendored
2
public/assets/css/app-min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -1,86 +1,3 @@
|
||||||
:root {
|
|
||||||
color-scheme: dark light;
|
|
||||||
|
|
||||||
--primary: #cc2027;
|
|
||||||
--primary-darken: #8E161B;
|
|
||||||
--primary-lighten: #D64C52;
|
|
||||||
--primary-text-contrast: #FFF;
|
|
||||||
|
|
||||||
--secondary: #20ccc5;
|
|
||||||
--secondary-darken: #168E89;
|
|
||||||
--secondary-lighten: #4CD6D0;
|
|
||||||
--secondary-text-contrast: #000;
|
|
||||||
|
|
||||||
--error: #c43933;
|
|
||||||
--error-darken: #892723;
|
|
||||||
--error-lighten: #CF605B;
|
|
||||||
--error-text-contrast: #FFF;
|
|
||||||
|
|
||||||
--info: #206ccc;
|
|
||||||
--info-darken: #164B8E;
|
|
||||||
--info-lighten: #4C89D6;
|
|
||||||
--info-text-contrast: #FFF;
|
|
||||||
|
|
||||||
--success: #7dcc20;
|
|
||||||
--success-darken: #578E16;
|
|
||||||
--success-lighten: #97D64C;
|
|
||||||
--success-text-contrast: #000;
|
|
||||||
|
|
||||||
--warning: #cc5e20;
|
|
||||||
--warning-darken: #8E4116;
|
|
||||||
--warning-lighten: #D67E4C;
|
|
||||||
--warning-text-contrast: #FFF;
|
|
||||||
|
|
||||||
--background-color: light-dark(#fffbfb, #171414);
|
|
||||||
--background-color-darken: light-dark(#B2AFAF, #100E0E);
|
|
||||||
--background-color-lighten: light-dark(#FFFBFB, #454343);
|
|
||||||
|
|
||||||
--light-background-color: #fffbfb;
|
|
||||||
--dark-background-color: #171414;
|
|
||||||
|
|
||||||
--header-background-color: light-dark(#171414, #fffbfb);
|
|
||||||
--header-background-color-darken: light-dark(#100E0E, #B2AFAF);
|
|
||||||
--header-background-color-lighten: light-dark(#454343, #FFFBFB);
|
|
||||||
|
|
||||||
--header-text-color: light-dark(#fffbfb, #171414);
|
|
||||||
--header-text-color-secondary: #ffffffb3;
|
|
||||||
--header-text-color-disable: light-dark(#ffffff80, #454343);
|
|
||||||
|
|
||||||
--text-color: light-dark(#171414, #fffbfb);
|
|
||||||
--text-color-secondary: #ffffffb3;
|
|
||||||
--text-color-disable: light-dark(#454343, #ffffff80);
|
|
||||||
|
|
||||||
--light-text-color: #171414;
|
|
||||||
--dark-text-color: #fffbfb;
|
|
||||||
|
|
||||||
--text-color-inverse: light-dark(#fffbfb, #171414);
|
|
||||||
--text-color-secondary-inverse: #ffffffb3;
|
|
||||||
--text-color-disable-inverse: light-dark(#ffffff80, #454343);
|
|
||||||
|
|
||||||
--box-shadow-light: .4rem .4rem 0px .1rem #B2AFAF;
|
|
||||||
--box-shadow-dark: .4rem .4rem 0px .1rem #454343;
|
|
||||||
--box-shadow-auto: .4rem .4rem 0px .1rem light-dark(#B2AFAF, #454343);
|
|
||||||
|
|
||||||
--h1-color: var(--primary);
|
|
||||||
--h2-color: #c33d35;
|
|
||||||
--h3-color: #b94f44;
|
|
||||||
--h4-color: #ae5e52;
|
|
||||||
--h5-color: #a16a61;
|
|
||||||
--h6-color: #927671;
|
|
||||||
|
|
||||||
--font-size: 1.1em;
|
|
||||||
--default-space: .2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme=dark] {
|
|
||||||
color-scheme: dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
[data-theme="light"] {
|
|
||||||
color-scheme: light;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* RESET CSS BY Piccalil.li */
|
/* RESET CSS BY Piccalil.li */
|
||||||
/* https://piccalil.li/blog/a-more-modern-css-reset/ */
|
/* https://piccalil.li/blog/a-more-modern-css-reset/ */
|
||||||
/* License https://creativecommons.org/licenses/by/3.0/ */
|
/* License https://creativecommons.org/licenses/by/3.0/ */
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
<link rel="author" href="humans.txt">
|
<link rel="author" href="humans.txt">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="http://kt-theme.local/kt-scheme.css">
|
||||||
|
|
||||||
<?php if ($params[0]['config']['debug'] === true): ?>
|
<?php if ($params[0]['config']['debug'] === true): ?>
|
||||||
<link rel="stylesheet" href="../../assets/css/app.css?t=<?= time(); ?>">
|
<link rel="stylesheet" href="../../assets/css/app.css?t=<?= time(); ?>">
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
|
|
|
@ -1,73 +1,3 @@
|
||||||
<main class="home">
|
<main class="home">
|
||||||
<section class="what-is-this">
|
<?= $homeContent; ?>
|
||||||
<h2>C'est quoi ici ?!</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
C'est ma page d'accueil, mon petit coin de web à moi, ça renvoie vers d'autres trucs, n'hésitez pas à <a href="/slashes">fouiller</a>.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
J'ai réellement découvert internet en 1999 avec un Pentium 166mhz et un modem 33k sur un port ISA. J'ai tout de suite adoré ça, même un peu trop au vu de mes factures téléphonique de l'époque :-( .
|
|
||||||
Depuis je n'ai jamais quitté internet.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Je n'ai qu'un seul pseudonyme (parfois écrit Knah-Tsaeb, quand les sites n'autorisent pas les espaces) et un seul avatar. Donc si vous croisez un Knah Tsaeb quelque part sur le web, il y a de forte chance que ce soit moi.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Si vous voulez plus d'info, la page <a href="/about">/about</a> ou à propos en français est faite pour ça.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="social-networks">
|
|
||||||
<h2>Réseaux sociaux</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
J'ai un compte Masto, pis c'est tout et je n'y suis pas très actif :
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a href="https://mamot.fr/@Knah_Tsaeb">Mastodon</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="last-posts">
|
|
||||||
<h2>Derniers billets</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
Quelques articles écrits plus ou moins récemment.
|
|
||||||
</p>
|
|
||||||
<?= $lastPost; ?>
|
|
||||||
<p>
|
|
||||||
<a href="/posts">Tous mes posts</a>
|
|
||||||
</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="last-shaares">
|
|
||||||
<h2>Derniers marque-pages partagés</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
Ce sont mes derniers marque-pages partagés, l'ensemble est disponible sur mon <a href="/bookmarks">Shaarli</a>.
|
|
||||||
</p>
|
|
||||||
<?= $lastShaare; ?>
|
|
||||||
<a href="/bookmarks">Tous mes partages</a>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="last-apps-updates">
|
|
||||||
<h2>Dernières mise à jours</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
Les dernières mise à jours de mes apps.
|
|
||||||
</p>
|
|
||||||
<?= $lastAppsUpdates; ?>
|
|
||||||
<a href="#">Toutes les mises à jours</a>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section class="last-pics">
|
|
||||||
<h2>Dernières images partagées</h2>
|
|
||||||
<p class="section-header">
|
|
||||||
Ma galerie d'image et de photos.
|
|
||||||
</p>
|
|
||||||
<article>
|
|
||||||
<?= $lastPics; ?>
|
|
||||||
</article>
|
|
||||||
<a href="#">Toutes mes images/photos</a>
|
|
||||||
</section>
|
|
||||||
</main>
|
</main>
|
|
@ -20,7 +20,7 @@ use App\Blogs\Blogs;
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<?= Blogs::extractLead(file_get_contents($post['file'])); ?>
|
<?= Blogs::extractLead($post['file']); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
|
|
Loading…
Reference in a new issue