Compare commits

...

3 Commits

Author SHA1 Message Date
quenousimporte 6aeeeb22ca force https 2024-08-27 10:40:59 +02:00
quenousimporte 6bc2a004fd mp add cover and change title 2024-08-27 10:40:53 +02:00
quenousimporte e6c226c100 add today only for mp 2024-08-27 10:40:26 +02:00
2 changed files with 23 additions and 4 deletions

12
.htaccess Normal file
View File

@ -0,0 +1,12 @@
RewriteEngine on
# Redirection du www vers non-www en HTTPS
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]
# Redirection vers HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# See https://ouvaton.coop/certificat-ssl/

View File

@ -19,6 +19,11 @@
function add_mp_article($url, $context, $epub)
{
if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy')))
{
return;
}
$article = file_get_contents($url, false, $context);
$doc = new DOMDocument();
$doc->loadHTML($article);
@ -26,7 +31,7 @@
$title = $finder->query('//h1')->item(0)->textContent;
$author = $finder->query('//a[contains(@href, "biographie")]')->item(0)->textContent;
$date = $finder->query('//time')->item(1)->textContent;
$date = trim($finder->query('//time')->item(1)->textContent);
$summary = $finder->query('//p[contains(@class, "news__heading__top__intro")]')->item(0)->textContent;
// strip images
@ -375,7 +380,8 @@
$epub = new TPEpubCreator();
$epub->temp_folder = 'temp/';
$epub->epub_file = 'epub/mediapart.epub';
$epub->title = 'Mediapart ' . $date;
$epub->title = 'Mediapart RSS ' . $date;
$epub->AddImage('https://www.mediapart.fr/icon-news-180x180.png', 'image/jpeg', true);
// load feeds
$feed = file_get_contents($feedurl);
@ -405,7 +411,8 @@
$epub = new TPEpubCreator();
$epub->temp_folder = 'temp/';
$epub->epub_file = 'epub/mediaparthome.epub';
$epub->title = 'Mediapart home ' . $date;
$epub->title = 'Mediapart A la une ' . $date;
$epub->AddImage('https://www.mediapart.fr/icon-news-180x180.png', 'image/jpeg', true);
$home = file_get_contents($homeurl, false, $context);
$doc = new DOMDocument();
@ -607,7 +614,7 @@
<input id="forcempcookies" name="forcempcookies" type="checkbox">
<label for="forcempcookies">Force cookies</label>
<br>
<input id="mptoday" name="mptoday" type="checkbox" disabled>
<input id="mptoday" name="mptoday" type="checkbox">
<label for="mptoday">Today only</label>
<br>