2020-08-02 14:15:06 +02:00
< ? php
require " mdp.php " ;
2021-04-05 18:32:22 +02:00
if ( isset ( $_GET [ 'pw' ]) AND $_GET [ 'pw' ] == $mdp AND isset ( $_GET [ 'site' ])) {
$site = $_GET [ 'site' ];
2020-08-02 14:15:06 +02:00
require " bibli/parsedown/Parsedown.php " ;
2021-04-05 18:32:22 +02:00
require " bibli/parsedown-extra/ParsedownExtra.php " ;
require " bibli/parsedown-extra-plugin/ParsedownExtraPlugin.php " ;
$nomsPages = array_diff ( scandir ( $site . " /md " ), array ( '..' , '.' ));
require $site . " /pages.inc.php " ;
foreach ( $nomsPages as $pageId ) {
$pageId = basename ( $pageId , " .md " );
if ( ! file_exists ( " temp/ " . $site ))
mkdir ( " temp/ " . $site , 555 );
2020-08-02 14:15:06 +02:00
// pages/exemple.md > temp/exemple.temp
2021-04-05 18:32:22 +02:00
// Exécute le PHP vers du HTML
2020-08-02 14:15:06 +02:00
ob_start ();
2021-04-05 18:32:22 +02:00
require $site . " /md/ " . $pageId . " .md " ;
file_put_contents ( " temp/ " . $site . " / " . $pageId . " .temp " , ob_get_contents ());
2020-08-02 14:15:06 +02:00
ob_end_clean ();
// temp/exemple.temp > temp2/exemple.temp2
2021-04-05 18:32:22 +02:00
// Compile le Markdown vers du HTML
$contenuPage = file_get_contents ( " temp/ " . $site . " / " . $pageId . " .temp " );
$Parsedown = new ParsedownExtraPlugin ;
$Parsedown = $Parsedown -> setUrlsLinked ( false );
$Parsedown = $Parsedown -> setMarkupEscaped ( false );
$Parsedown = $Parsedown -> setBreaksEnabled ( true );
$contenuPage = $Parsedown -> text ( $contenuPage );
file_put_contents ( " temp/ " . $site . " / " . $pageId . " .temp2 " , $contenuPage );
2020-08-02 14:15:06 +02:00
// temp2/exemple.temp2 > exemple.html
2021-04-05 18:32:22 +02:00
// Ajoute header et footer au HTML
2020-08-02 14:15:06 +02:00
ob_start ();
2021-04-05 18:32:22 +02:00
$pageMetas = getPageMetas ( $pageId );
2020-08-02 14:15:06 +02:00
require " inc/debut.php " ;
2021-04-05 18:32:22 +02:00
if ( $pageMetas [ 'type' ] == " article " ) {
echo " <h1> " . $pageMetas [ 'h1' ] . " </h1> " ;
2020-08-02 14:15:06 +02:00
echo " <article> " ;
2021-04-05 18:32:22 +02:00
} else if ( $pageMetas [ 'type' ] == " centré " ) {
2020-08-02 14:15:06 +02:00
echo " <div class='centre'> " ;
}
2021-04-05 18:32:22 +02:00
require " temp/ " . $site . " / " . $pageId . " .temp2 " ;
if ( $pageMetas [ 'type' ] == " article " ) {
2020-08-02 14:15:06 +02:00
echo " </article> " ;
2021-04-05 18:32:22 +02:00
} else if ( $pageMetas [ 'type' ] == " centré " ) {
2020-08-02 14:15:06 +02:00
echo " </div> " ;
}
require " inc/footer.php " ;
2021-04-05 18:32:22 +02:00
file_put_contents ( $site . " / " . $pageId . " .html " , ob_get_contents ());
2020-08-02 14:15:06 +02:00
ob_end_clean ();
}
// exemple.html > exemple.html.gz
2021-04-05 18:32:22 +02:00
// Compresse les fichiers textes statiques HTML & CSS
exec ( '/usr/local/bin/static-compress -c zopfli "' . $site . '/*.html" "' . $site . '/css/*.css"' );
2020-08-02 14:15:06 +02:00
} else {
2021-04-05 18:32:22 +02:00
echo " Non authentifié·e, ou pas de site définit " ;
2020-08-02 14:15:06 +02:00
}