small fix and refactor

This commit is contained in:
quenousimporte 2024-06-04 09:42:41 +02:00
parent 0175cf5fc7
commit 9e78ec8634
2 changed files with 32 additions and 48 deletions

View File

@ -1,4 +1,9 @@
<!DOCTYPE html>
<html> <html>
<head>
<title>Fichiers epub</title>
<link rel="icon" type="image/png" href="1F4F0_color.png" />
</head>
<body> <body>
<?php <?php
@ -6,6 +11,24 @@
require 'settings.php'; require 'settings.php';
require 'TPEpubCreator.php'; require 'TPEpubCreator.php';
function write_epub($epub)
{
if ( ! $epub->error ) {
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
}
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
$date = (new DateTime('today'))->format('Ymd'); $date = (new DateTime('today'))->format('Ymd');
@ -97,21 +120,7 @@
$epub->AddPage($pagecontent, false, strip_tags($articlebody->Title)); $epub->AddPage($pagecontent, false, strip_tags($articlebody->Title));
} }
} }
write_epub($epub);
if ( ! $epub->error ) {
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
} }
// Mediapart // Mediapart
@ -199,20 +208,7 @@
} }
} }
if ( ! $epub->error ) { write_epub($epub);
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
} }
// New York Times // New York Times
@ -301,30 +297,18 @@
} }
} }
if ( ! $epub->error ) { write_epub($epub);
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
} }
// list existing files // list existing files
echo '<div>';
$files = glob('epub/*'); $files = glob('epub/*');
foreach ($files as $file) foreach ($files as $file)
{ {
echo '<a href="' . $file . '">' . $file . '</a> ' . date('F d Y H:i:s', filemtime($file)) . '<br>'; echo '<a href="' . $file . '">' . str_replace('epub/', '', $file) . '</a> ' . date('F d Y H:i:s', filemtime($file)) . '<br>';
} }
echo '</div>';
?> ?>
<div> <div>

View File

@ -38,15 +38,15 @@
<a href="https://lundi.am">Lundi matin</a><br> <a href="https://lundi.am">Lundi matin</a><br>
<a href="https://www.terrestres.org">Terrestres</a><br> <a href="https://www.terrestres.org">Terrestres</a><br>
<a href="https://basta.media">Basta!</a><br> <a href="https://basta.media">Basta!</a><br>
<a href="https://theconversation.com/fr">The conversation</a><br> <a href="https://theconversation.com/fr">The Conversation</a><br>
<a href="https://www.theguardian.com/europe">The Guardian</a><br> <a href="https://www.theguardian.com/europe">The Guardian</a><br>
<a href="https://theintercept.com/">The intercept</a><br> <a href="https://theintercept.com/">The intercept</a><br>
</p> </p>
<h2>Ressources</h2> <h2>Ressources</h2>
<p> <p>
<a href="https://portail.basta.media">Revue de presse Basta</a><br> <a href="https://portail.basta.media">Revue de presse Basta</a><br>
<a href="https://www.bm-lyon.fr/les-offres-numeriques-de-la-bibliotheque/article/lire-la-presse-de-chez-vous">Europresse</a> : <a href="https://www.bm-lyon.fr/les-offres-numeriques-de-la-bibliotheque/article/lire-la-presse-de-chez-vous">Connexion Europresse</a>
<a href="https://nouveau.europresse.com/Pdf">Publications PDF</a> - <a href="https://nouveau.europresse.com/Pdf">Publications PDF</a>
- <a href="https://nouveau.europresse.com/Pdf/Edition?sourceCode=LM_P">Le Monde</a><br> - <a href="https://nouveau.europresse.com/Pdf/Edition?sourceCode=LM_P">Le Monde</a><br>
<a href="https://www.cairn.info/">Cairn</a> <a href="https://www.cairn.info/">Cairn</a>
- <a href="https://www.cairn.info/revue-ecologie-et-politique.htm">Écologie & politique</a><br> - <a href="https://www.cairn.info/revue-ecologie-et-politique.htm">Écologie & politique</a><br>