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>
<head>
<title>Fichiers epub</title>
<link rel="icon" type="image/png" href="1F4F0_color.png" />
</head>
<body>
<?php
@ -6,6 +11,24 @@
require 'settings.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 = (new DateTime('today'))->format('Ymd');
@ -97,21 +120,7 @@
$epub->AddPage($pagecontent, false, strip_tags($articlebody->Title));
}
}
if ( ! $epub->error ) {
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
write_epub($epub);
}
// Mediapart
@ -199,20 +208,7 @@
}
}
if ( ! $epub->error ) {
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
write_epub($epub);
}
// New York Times
@ -301,30 +297,18 @@
}
}
if ( ! $epub->error ) {
$epub->CreateEPUB();
if ( ! $epub->error ) {
echo 'Success: ' . $epub->epub_file . ' created.<br>';
}
else
{
echo $epub->error;
}
} else {
echo $epub->error;
}
write_epub($epub);
}
// list existing files
echo '<div>';
$files = glob('epub/*');
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>

View File

@ -38,15 +38,15 @@
<a href="https://lundi.am">Lundi matin</a><br>
<a href="https://www.terrestres.org">Terrestres</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://theintercept.com/">The intercept</a><br>
</p>
<h2>Ressources</h2>
<p>
<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://nouveau.europresse.com/Pdf">Publications PDF</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/Edition?sourceCode=LM_P">Le Monde</a><br>
<a href="https://www.cairn.info/">Cairn</a>
- <a href="https://www.cairn.info/revue-ecologie-et-politique.htm">Écologie & politique</a><br>