Compare commits

..

No commits in common. "0b3c66b99b2c2865c83344bb49b3ce1bd7672758" and "dce35af9c6d75ab3f3cdce77188caa0ddc050fdf" have entirely different histories.

2 changed files with 28 additions and 26 deletions

View File

@ -3,8 +3,7 @@ javascript: (function()
var map = { var map = {
"www.mediapart.fr": "https://www.mediapart.fr/articles/feed", "www.mediapart.fr": "https://www.mediapart.fr/articles/feed",
"www.lemonde.fr": "https://www.lemonde.fr/rss/une.xml", "www.lemonde.fr": "https://www.lemonde.fr/rss/une.xml",
"www.nytimes.com": "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml", "www.nytimes.com": "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
"reporterre.net": "https://reporterre.net/spip.php?page=backend-simple"
}; };
var host = window.location.host; var host = window.location.host;
@ -26,12 +25,7 @@ javascript: (function()
items = xmldoc.evaluate("/rss/channel/item", xmldoc); items = xmldoc.evaluate("/rss/channel/item", xmldoc);
while ((item = items.iterateNext())) while ((item = items.iterateNext()))
{ {
var datenode = item.getElementsByTagName("pubDate"); var itemdate = new Date(item.getElementsByTagName("pubDate")[0].textContent);
if (!datenode || !datenode.length)
{
datenode = item.getElementsByTagName("dc:date");
}
var itemdate = new Date(datenode[0].textContent);
var itemlink = item.getElementsByTagName("link")[0].textContent; var itemlink = item.getElementsByTagName("link")[0].textContent;
if (itemdate.toDateString() == today.toDateString()) if (itemdate.toDateString() == today.toDateString())
{ {

View File

@ -12,18 +12,6 @@
require 'settings.php'; require 'settings.php';
require 'TPEpubCreator.php'; require 'TPEpubCreator.php';
function get_clean_html($node)
{
$innerHTM = '';
foreach ($node->childNodes as $childNode){
$nodeHTML = $childNode->ownerDocument->saveHTML($childNode);
$nodeHTML = str_replace('<aside', '<b><i', $nodeHTML);
$nodeHTML = str_replace('</aside', '</i></b', $nodeHTML);
$innerHTML .= $nodeHTML;
}
return '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
}
function add_mp_article($url, $context, $epub) function add_mp_article($url, $context, $epub)
{ {
if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy'))) if (isset($_POST['mptoday']) && $_POST['mptoday'] && !str_contains($url, (new DateTime('today'))->format('dmy')))
@ -77,8 +65,14 @@
else else
{ {
$node = $nodes->item(0); $node = $nodes->item(0);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title); $innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
} }
} }
@ -494,8 +488,15 @@
else else
{ {
$node = $nodes->item(0); $node = $nodes->item(0);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title); $innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
} }
} }
@ -562,8 +563,15 @@
else else
{ {
$node = $nodes->item(0); $node = $nodes->item(0);
$nodehtml = get_clean_html($node);
$epub->AddPage($nodehtml, false, $title); $innerHTML = '';
foreach ($node->childNodes as $childNode){
$innerHTML .= $childNode->ownerDocument->saveHTML($childNode);
}
$result .= '<div>' . strip_tags($innerHTML, '<p><b><h2><i>') . '</div>';
$epub->AddPage($result, false, $title);
} }
} }
} }