| ... | ... |
@@ -32,6 +32,7 @@ Currently are supported the following feeds : |
| 32 | 32 |
- https://www.slate.fr/rss.xml |
| 33 | 33 |
- https://www.vice.com/fr/rss |
| 34 | 34 |
- http://www.lesinrocks.com/feeds/feed-a-la-une/ |
| 35 |
+- http://www.numerama.com/rss/news.rss |
|
| 35 | 36 |
|
| 36 | 37 |
## License |
| 37 | 38 |
GPLv3 See the **LICENSE** file. |
| ... | ... |
@@ -0,0 +1,41 @@ |
| 1 |
+<?php |
|
| 2 |
+function DisplayNewsNumerama(){
|
|
| 3 |
+ |
|
| 4 |
+ $status = new StatusMessages(); |
|
| 5 |
+ ?> |
|
| 6 |
+ <script> |
|
| 7 |
+ function onArticle(index) {
|
|
| 8 |
+ var string_index = "article-"+index; |
|
| 9 |
+ var url = location.href; |
|
| 10 |
+ document.getElementById("article-current").innerHTML =
|
|
| 11 |
+ document.getElementById(string_index).innerHTML; |
|
| 12 |
+ location.href = "#article-top"; |
|
| 13 |
+ } |
|
| 14 |
+ </script> |
|
| 15 |
+ <div class="row"> |
|
| 16 |
+ <div class="col-lg-12"> |
|
| 17 |
+ <div class="panel panel-primary"> |
|
| 18 |
+ <div class="panel-heading"><i class="fa fa-newspaper-o fa-fw"></i> Numerama </div> |
|
| 19 |
+ <div class="panel-body"> |
|
| 20 |
+ <p><?php $status->showMessages(); ?></p> |
|
| 21 |
+ <div class="row"> |
|
| 22 |
+ <div class="col-md-6"> |
|
| 23 |
+ <div class="panel panel-default"> |
|
| 24 |
+ <div class="panel-body"> |
|
| 25 |
+ <?php |
|
| 26 |
+ $articles = file_get_contents(NEWS_RSS_NUMERAMA); |
|
| 27 |
+ echo $articles; |
|
| 28 |
+ ?> |
|
| 29 |
+ </div><!-- ./panel-body --> |
|
| 30 |
+ </div><!-- ./panel panel-default --> |
|
| 31 |
+ </div><!-- ./col-md-6 --> |
|
| 32 |
+ </div> <!-- /row --> |
|
| 33 |
+ </div><!-- /.panel-body --> |
|
| 34 |
+ <div class="panel-footer"><a href="<?php echo URI_NEWS_RSS_NUMERAMA; ?>"><i class="fa fa-rss"></i> <?php echo URI_NEWS_RSS_NUMERAMA; ?></a></div> |
|
| 35 |
+ </div><!-- /.panel-default --> |
|
| 36 |
+ </div><!-- /.col-lg-12 --> |
|
| 37 |
+ </div><!-- /.row --> |
|
| 38 |
+ <?php |
|
| 39 |
+} |
|
| 40 |
+ |
|
| 41 |
+?> |
| ... | ... |
@@ -5,11 +5,13 @@ define('NEWS_RSS_LIBERATION', 'sources/liberation.html');
|
| 5 | 5 |
define('NEWS_RSS_SLATEFR', 'sources/slatefr.html');
|
| 6 | 6 |
define('NEWS_RSS_VICEFR', 'sources/vicefr.html');
|
| 7 | 7 |
define('NEWS_RSS_LESINROCKS', 'sources/lesinrocks.html');
|
| 8 |
+define('NEWS_RSS_NUMERAMA', 'sources/numerama.html');
|
|
| 8 | 9 |
define('URI_NEWS_RSS_LEMONDE', 'http://www.lemonde.fr/rss/une.xml');
|
| 9 | 10 |
define('URI_NEWS_RSS_LIBERATION', 'http://rss.liberation.fr/rss/latest/');
|
| 10 | 11 |
define('URI_NEWS_RSS_SLATEFR', 'https://www.slate.fr/rss.xml');
|
| 11 | 12 |
define('URI_NEWS_RSS_VICEFR', 'http://www.vice.com/fr/rss');
|
| 12 | 13 |
define('URI_NEWS_RSS_LESINROCKS', 'http://www.lesinrocks.com/feeds/feed-a-la-une/');
|
| 14 |
+define('URI_NEWS_RSS_NUMERAMA', 'http://www.numerama.com/rss/news.rss');
|
|
| 13 | 15 |
|
| 14 | 16 |
include_once( 'includes/functions.php' ); |
| 15 | 17 |
include_once( 'includes/status_messages.php' ); |
| ... | ... |
@@ -19,6 +21,7 @@ include_once( 'includes/liberation.php' ); |
| 19 | 21 |
include_once( 'includes/slatefr.php' ); |
| 20 | 22 |
include_once( 'includes/vicefr.php' ); |
| 21 | 23 |
include_once( 'includes/lesinrocks.php' ); |
| 24 |
+include_once( 'includes/numerama.php' ); |
|
| 22 | 25 |
|
| 23 | 26 |
$output = $return = 0; |
| 24 | 27 |
$page = "lemonde"; |
| ... | ... |
@@ -103,6 +106,9 @@ $theme_url = 'dist/css/' . $theme; |
| 103 | 106 |
<li> |
| 104 | 107 |
<a href="index.php?page=lesinrocks"><i class="fa fa-newspaper-o fa-fw"></i> LesInrocks.fr</a> |
| 105 | 108 |
</li> |
| 109 |
+ <li> |
|
| 110 |
+ <a href="index.php?page=numerama"><i class="fa fa-newspaper-o fa-fw"></i> Numerama</a> |
|
| 111 |
+ </li> |
|
| 106 | 112 |
</ul> |
| 107 | 113 |
</div><!-- /.navbar-collapse --> |
| 108 | 114 |
</div><!-- /.navbar-default --> |
| ... | ... |
@@ -137,6 +143,9 @@ $theme_url = 'dist/css/' . $theme; |
| 137 | 143 |
case "lesinrocks": |
| 138 | 144 |
DisplayNewsLesInrocks(); |
| 139 | 145 |
break; |
| 146 |
+ case "numerama": |
|
| 147 |
+ DisplayNewsNumerama(); |
|
| 148 |
+ break; |
|
| 140 | 149 |
default: |
| 141 | 150 |
DisplayNewsLeMonde(); |
| 142 | 151 |
} |
| ... | ... |
@@ -5,4 +5,5 @@ php news-liberation.fr.php > liberation.html 2> /dev/null |
| 5 | 5 |
php news-slate.fr.php > slatefr.html 2> /dev/null |
| 6 | 6 |
php news-vice.fr.php > vicefr.html 2> /dev/null |
| 7 | 7 |
php news-lesinrocks.fr.php > lesinrocks.html 2> /dev/null |
| 8 |
+php news-numerama.fr.php > numerama.html 2> /dev/null |
|
| 8 | 9 |
|
| ... | ... |
@@ -5,4 +5,4 @@ php news-liberation.fr.php > liberation.html 2> /dev/null |
| 5 | 5 |
php news-slate.fr.php > slatefr.html 2> /dev/null |
| 6 | 6 |
php news-vice.fr.php > vicefr.html 2> /dev/null |
| 7 | 7 |
php news-lesinrocks.fr.php > lesinrocks.html 2> /dev/null |
| 8 |
- |
|
| 8 |
+php news-numerama.fr.php > numerama.html 2> /dev/null |
| ... | ... |
@@ -4,6 +4,7 @@ define('NEWS_RSS_LIBERATION', 'http://rss.liberation.fr/rss/latest/');
|
| 4 | 4 |
define('NEWS_RSS_SLATEFR', 'https://www.slate.fr/rss.xml');
|
| 5 | 5 |
define('NEWS_RSS_VICEFR', 'https://www.vice.com/fr/rss');
|
| 6 | 6 |
define('NEWS_RSS_LESINROCKS', 'http://www.lesinrocks.com/feeds/feed-a-la-une/');
|
| 7 |
+define('NEWS_RSS_NUMERAMA', 'http://www.numerama.com/rss/news.rss');
|
|
| 7 | 8 |
$NEWS_RSS_MAX_ITEMS = 10; |
| 8 | 9 |
|
| 9 | 10 |
function DOMinnerHTML(DOMNode $element) |
| ... | ... |
@@ -126,7 +126,7 @@ foreach ($articles as $article ) {
|
| 126 | 126 |
echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
| 127 | 127 |
echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
|
| 128 | 128 |
echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>'; |
| 129 |
- echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
|
| 129 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
|
| 130 | 130 |
echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-upi fa-2x"></i></a></div> '; |
| 131 | 131 |
echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div> '; |
| 132 | 132 |
echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
| ... | ... |
@@ -0,0 +1,140 @@ |
| 1 |
+<?php |
|
| 2 |
+include_once( 'news-constants.php' ); |
|
| 3 |
+ |
|
| 4 |
+$rss_content = file_get_contents(NEWS_RSS_NUMERAMA); |
|
| 5 |
+$xml = simplexml_load_string($rss_content); |
|
| 6 |
+if ($xml === false) {
|
|
| 7 |
+ echo 'Failed to read RSS'; |
|
| 8 |
+} else {
|
|
| 9 |
+ $channel = array(); |
|
| 10 |
+ $channel['title'] = $xml->channel->title; |
|
| 11 |
+ $channel['link'] = $xml->channel->link; |
|
| 12 |
+ $channel['description'] = $xml->channel->description; |
|
| 13 |
+ $channel['pubDate'] = $xml->channel->pubDate; |
|
| 14 |
+ $channel['timestamp'] = strtotime($xml->channel->pubDate); |
|
| 15 |
+ echo '<h4>' . $channel['title'] . '</h4>'; |
|
| 16 |
+ $cpt=0; |
|
| 17 |
+ foreach ($xml->channel->item as $item) {
|
|
| 18 |
+ $article = array(); |
|
| 19 |
+ $article['title'] = $item->title; |
|
| 20 |
+ $article['link'] = $item->link; |
|
| 21 |
+ $article['pubDate'] = $item->pubDate; |
|
| 22 |
+ $article['timestamp'] = strtotime($item->pubDate); |
|
| 23 |
+ $article['description'] = $item->description; |
|
| 24 |
+ $SEARCH_SUB1='<p><img width="1024" height="'; |
|
| 25 |
+ $pos_start = strpos($item->description, $SEARCH_SUB1); |
|
| 26 |
+ $pos_start += strlen($SEARCH_SUB1); |
|
| 27 |
+ $SEARCH_SUB2="\""; |
|
| 28 |
+ $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start); |
|
| 29 |
+ $height=substr($item->description, $pos_start, $pos_stop - $pos_start); |
|
| 30 |
+ $article['width']=1024; |
|
| 31 |
+ $article['height']=$height; |
|
| 32 |
+ $SEARCH_SUB1='src="'; |
|
| 33 |
+ $pos_start = strpos($item->description, $SEARCH_SUB1); |
|
| 34 |
+ $pos_start += strlen($SEARCH_SUB1); |
|
| 35 |
+ $SEARCH_SUB2="\""; |
|
| 36 |
+ $pos_stop = strpos($item->description, $SEARCH_SUB2, $pos_start); |
|
| 37 |
+ $article['image']=substr($item->description, $pos_start, $pos_stop - $pos_start); |
|
| 38 |
+ $articles[$cpt] = $article; |
|
| 39 |
+ echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
|
|
| 40 |
+ echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>'; |
|
| 41 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
|
| 42 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> '; |
|
| 43 |
+ echo $article['title'].' '; |
|
| 44 |
+ echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a><br></div></div>'; |
|
| 45 |
+ $cpt++; |
|
| 46 |
+ if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
|
|
| 47 |
+ break; |
|
| 48 |
+ } |
|
| 49 |
+ } |
|
| 50 |
+} |
|
| 51 |
+echo '</div><!-- ./panel-body -->'; |
|
| 52 |
+echo '</div><!-- ./panel panel-default -->'; |
|
| 53 |
+echo '</div><!-- ./col-md-6 -->'; |
|
| 54 |
+echo '<div class="col-md-6">'; |
|
| 55 |
+echo '<div class="panel panel-default">'; |
|
| 56 |
+echo '<div class="panel-body">'; |
|
| 57 |
+echo '<a name="article-top"></a><div id="article-current"></div>'; |
|
| 58 |
+$cpt=0; |
|
| 59 |
+foreach ($articles as $article ) {
|
|
| 60 |
+ $cpt_prev=$cpt-1; |
|
| 61 |
+ $cpt_next=$cpt+1; |
|
| 62 |
+ echo '<!-- ==================== article '.$cpt.'============== -->'; |
|
| 63 |
+ echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n"; |
|
| 64 |
+ echo "<hr>"; |
|
| 65 |
+ echo "<a name=\"article-$cpt\">"; |
|
| 66 |
+ $article_content = file_get_contents($article['link']); |
|
| 67 |
+/* $doc = new DOMDocument(); |
|
| 68 |
+ $doc->preserveWhiteSpace = false; |
|
| 69 |
+ $doc->formatOutput = true; |
|
| 70 |
+ $doc->loadHTML($article_content); |
|
| 71 |
+ $articles = $doc->getElementsByTagName('article');
|
|
| 72 |
+ $article_only=""; |
|
| 73 |
+ foreach ( $articles as $node) {
|
|
| 74 |
+ $article_only = DOMinnerHTML($node); |
|
| 75 |
+ } |
|
| 76 |
+ */ |
|
| 77 |
+ //$SEARCH_SUB1='<p class="chapo">'; |
|
| 78 |
+ $SEARCH_SUB1='<article class="post-content span8 tablet12 phone12">'; |
|
| 79 |
+ $pos_start = strpos($article_content, $SEARCH_SUB1); |
|
| 80 |
+ $pos_start += strlen($SEARCH_SUB1); |
|
| 81 |
+ $SEARCH_SUB2='<div id="bottom_ad"'; |
|
| 82 |
+ $pos_stop = strpos($article_content, $SEARCH_SUB2); |
|
| 83 |
+ $article_only = substr($article_content, $pos_start, $pos_stop - $pos_start); |
|
| 84 |
+ |
|
| 85 |
+ $orgStrings = array(' src="//www.numerama.com/');
|
|
| 86 |
+ $newStrings = array(' src="https://www.numerama.com/');
|
|
| 87 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 88 |
+ $orgStrings = array(' srcset="//www.numerama.com/');
|
|
| 89 |
+ $newStrings = array(' srcset="https://www.numerama.com/');
|
|
| 90 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 91 |
+ $orgStrings = array(' href="/');
|
|
| 92 |
+ $newStrings = array(' href="https://www.numerama.com/');
|
|
| 93 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 94 |
+ |
|
| 95 |
+ $orgStrings = array( ' width="500" height="281" frameborder="0" '); |
|
| 96 |
+ $newStrings = array( ' width="100%" frameborder="0" '); |
|
| 97 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 98 |
+ $orgStrings = array( 'style="width: 680px"'); |
|
| 99 |
+ $newStrings = array( 'style="width: 100%"'); |
|
| 100 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 101 |
+ $orgStrings = array( '<img src="'); |
|
| 102 |
+ $newStrings = array( '<img width="100%" src="'); |
|
| 103 |
+ $article_only = str_replace($orgStrings, $newStrings, $article_only); |
|
| 104 |
+ $re = '/alt="(.+?)" width="(.+?)" height="(.+?)"/'; |
|
| 105 |
+ $temp = preg_replace($re, 'width="100%"', $article_only); |
|
| 106 |
+ $article_only = $temp; |
|
| 107 |
+ $re = '/<iframe width="500" height="(.+?)"/'; |
|
| 108 |
+ $temp = preg_replace($re, '<iframe width="100%"', $article_only); |
|
| 109 |
+ $article_only = $temp; |
|
| 110 |
+ $re = '/sizes="\(max-width: (.+?)\) 100vw, (.+?)"/'; |
|
| 111 |
+ $temp = preg_replace($re, 'sizes="(max-width: 100%) 100vw,100%"', $article_only); |
|
| 112 |
+ $article_only = $temp; |
|
| 113 |
+ $re = '/<figure id="attachment_(.+?)" style="width: (.+?)" class="wp-caption aligncenter">/'; |
|
| 114 |
+ $temp = preg_replace($re, '<figure id="attachment_\\1" style="width: 100%" class="wp-caption aligncenter">', $article_only); |
|
| 115 |
+ $article_only = $temp; |
|
| 116 |
+ |
|
| 117 |
+ $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
|
|
| 118 |
+ $article_only = $temp; |
|
| 119 |
+ $temp = preg_replace('/\s\s+/', ' ', $article_only);
|
|
| 120 |
+ $article_only = $temp; |
|
| 121 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
|
| 122 |
+ echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div> '; |
|
| 123 |
+ echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 124 |
+ echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
|
|
| 125 |
+ //echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>'; |
|
| 126 |
+ echo '<div class="extract-content" id="'.$cpt.'">'; |
|
| 127 |
+ echo '<h4>'.$article['title'].'</h4><img width="100%" src="'.$article['image'].'" style="display:inline;"><br>'; |
|
| 128 |
+ echo $article_only.'</div>'; |
|
| 129 |
+ //$article_only = '<h4>'.$article['title'].'</h4><img src="'.$article['image'].'" style="display:inline;"><br>'; |
|
| 130 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
|
| 131 |
+ echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-upi fa-2x"></i></a></div> '; |
|
| 132 |
+ echo '<div id="nav-source" style="display:inline;"><a href="'.$article['link'].'" target="new-'.$cpt.'"><i class="fa fa-link fa-2x"></i></a></div> '; |
|
| 133 |
+ echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div> ';
|
|
| 134 |
+ echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
|
|
| 135 |
+ $cpt++; |
|
| 136 |
+ if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
|
|
| 137 |
+ break; |
|
| 138 |
+ } |
|
| 139 |
+} |
|
| 140 |
+?> |