Change home template rendering (not generic solution, need to be rework)
This commit is contained in:
parent
2ab152e158
commit
2d27370670
10 changed files with 36 additions and 171 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -5,4 +5,8 @@ vendor
|
|||
datas/config.json
|
||||
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 {
|
||||
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']);
|
||||
} else {
|
||||
return file_get_contents($this->notFound['file']);
|
||||
|
@ -173,7 +174,10 @@ class Blogs {
|
|||
* @return array The information of the markdown file
|
||||
*/
|
||||
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
|
||||
* @return string|null The extracted lead paragraph or null
|
||||
*/
|
||||
static function extractLead(string $markdownContent): ?string {
|
||||
$pattern = '/---\s*(.*?)\s*---/s';
|
||||
if (preg_match($pattern, $markdownContent, $matches)) {
|
||||
return trim($matches[1]);
|
||||
static function extractLead(string $markdownFile): ?string {
|
||||
if (file_exists($markdownFile)) {
|
||||
$markdownContent = file_get_contents($markdownFile);
|
||||
$pattern = '/---\s*(.*?)\s*---/s';
|
||||
if (preg_match($pattern, $markdownContent, $matches)) {
|
||||
return trim($matches[1]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -46,19 +46,22 @@ class Cache {
|
|||
} elseif ($params['type'] === 'post') {
|
||||
$postList = new Blogs($params);
|
||||
$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') {
|
||||
$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');
|
||||
}
|
||||
$cacheModifiedTime = filemtime(self::$pathCacheDir[$params['type']] . '/' . $params['cacheName']);
|
||||
|
||||
if ($mdModifiedTime > $cacheModifiedTime) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Blogs\Blogs;
|
|||
use App\Cache;
|
||||
use App\Fetching\Gitea;
|
||||
use App\Fetching\NanoGal;
|
||||
use App\Utils\Debug;
|
||||
use App\Fetching\Shaarli;
|
||||
|
||||
class Home {
|
||||
|
@ -73,6 +72,12 @@ class Home {
|
|||
$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';
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
|
|
@ -58,7 +58,6 @@ class NanoGal {
|
|||
*/
|
||||
public function makeList(): ?string {
|
||||
if (!empty($this->bookmarkList)) {
|
||||
|
||||
$htmlBookmark = '';
|
||||
foreach ($this->bookmarkList as $value) {
|
||||
$htmlBookmark .='
|
||||
|
@ -67,8 +66,6 @@ class NanoGal {
|
|||
<figcaption>' . $value['title'] . '</figcaption>
|
||||
</figure>';
|
||||
}
|
||||
$htmlBookmark .= '
|
||||
</ul>';
|
||||
return $htmlBookmark;
|
||||
}
|
||||
return null;
|
||||
|
|
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 */
|
||||
/* https://piccalil.li/blog/a-more-modern-css-reset/ */
|
||||
/* License https://creativecommons.org/licenses/by/3.0/ */
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
<link rel="author" href="humans.txt">
|
||||
|
||||
<link rel="stylesheet" href="http://kt-theme.local/kt-scheme.css">
|
||||
|
||||
<?php if ($params[0]['config']['debug'] === true): ?>
|
||||
<link rel="stylesheet" href="../../assets/css/app.css?t=<?= time(); ?>">
|
||||
<?php else : ?>
|
||||
|
|
|
@ -1,73 +1,3 @@
|
|||
<main class="home">
|
||||
<section class="what-is-this">
|
||||
<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>
|
||||
<?= $homeContent; ?>
|
||||
</main>
|
|
@ -20,7 +20,7 @@ use App\Blogs\Blogs;
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<?= Blogs::extractLead(file_get_contents($post['file'])); ?>
|
||||
<?= Blogs::extractLead($post['file']); ?>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
|
|
Loading…
Reference in a new issue