Showing 5 changed files with 237 additions and 24 deletions
+5 -3
includes/default.php
... ...
@@ -11,9 +11,11 @@ function DisplayNewsDefault(){
11 11
             <div class="col-md-6">
12 12
             <div class="panel panel-default">
13 13
             <div class="panel-body">
14
-            <p>A simple, responsive web interface to see french newspaper feeds.
14
+            <p><b>FR</b> Interface web responsive simple pour consulter les flux RSS de diff&eacute;rents sites d'informations fran&ccedil;ais.
15
+            Le canevas original vient de <a href="https://github.com/billz/raspap-webgui"><strong>raspap-webgui</strong></a></p>
16
+            <p><b>EN</b> A simple, responsive web interface to see french newspaper feeds.
15 17
             The original responsive template is from <a href="https://github.com/billz/raspap-webgui"><strong>raspap-webgui</strong></a></p>
16
-            <h2>Supported Feeds</h2>
18
+            <h2><i class="fa fa-rss" aria-hidden="true"></i> RSS</h2>
17 19
             <ul>
18 20
             <?php
19 21
             $location="sources/news-constants.php";
... ...
@@ -27,7 +29,7 @@ function DisplayNewsDefault(){
27 29
             </ul>
28 30
 
29 31
             <h2>License</h2>
30
-            <p>GPLv3 See the <a href="https://git.kawi.fr/ycawidro/news/blob/master/LICENSE" target="license"><strong>LICENSE</strong></a> file.</p>
32
+            <p>GPLv3 <a href="https://git.kawi.fr/ycawidro/news/blob/master/LICENSE" target="license"><strong>LICENSE</strong></a></p>
31 33
             </div><!-- ./panel-body -->
32 34
             </div><!-- ./panel panel-default -->
33 35
             </div><!-- ./col-md-6 -->
+41
includes/lepointfr.php
... ...
@@ -0,0 +1,41 @@
1
+<?php
2
+function DisplayNewsLePointFr(){
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> LePoint.fr   </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_LEPOINTFR);
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_LEPOINTFR; ?>"><i class="fa fa-rss"></i> <?php echo URI_NEWS_RSS_LEPOINTFR; ?></a></div>
35
+      </div><!-- /.panel-default -->
36
+    </div><!-- /.col-lg-12 -->
37
+  </div><!-- /.row -->
38
+  <?php
39
+}
40
+
41
+?>
+14 -21
index.php
... ...
@@ -7,6 +7,7 @@ define('NEWS_RSS_VICEFR', 'sources/vicefr.html');
7 7
 define('NEWS_RSS_LESINROCKS', 'sources/lesinrocks.html');
8 8
 define('NEWS_RSS_NUMERAMA', 'sources/numerama.html');
9 9
 define('NEWS_RSS_HUFFINGTONPOSTFR', 'sources/huffingtonpostfr.html');
10
+define('NEWS_RSS_LEPOINTFR', 'sources/lepointfr.html');
10 11
 define('URI_NEWS_RSS_LEMONDE', 'http://www.lemonde.fr/rss/une.xml');
11 12
 define('URI_NEWS_RSS_LIBERATION', 'http://rss.liberation.fr/rss/latest/');
12 13
 define('URI_NEWS_RSS_SLATEFR', 'https://www.slate.fr/rss.xml');
... ...
@@ -14,6 +15,7 @@ define('URI_NEWS_RSS_VICEFR', 'http://www.vice.com/fr/rss');
14 15
 define('URI_NEWS_RSS_LESINROCKS', 'http://www.lesinrocks.com/feeds/feed-a-la-une/');
15 16
 define('URI_NEWS_RSS_NUMERAMA', 'http://www.numerama.com/rss/news.rss');
16 17
 define('URI_NEWS_RSS_HUFFINGTONPOSTFR', 'http://www.huffingtonpost.fr/feeds/index.xml');
18
+define('URI_NEWS_RSS_LEPOINTFR', 'http://www.lepoint.fr/24h-infos/rss.xml');
17 19
 
18 20
 include_once( 'includes/functions.php' );
19 21
 include_once( 'includes/status_messages.php' );
... ...
@@ -25,6 +27,7 @@ include_once( 'includes/vicefr.php' );
25 27
 include_once( 'includes/lesinrocks.php' );
26 28
 include_once( 'includes/numerama.php' );
27 29
 include_once( 'includes/huffingtonpostfr.php' );
30
+include_once( 'includes/lepointfr.php' );
28 31
 include_once( 'includes/default.php' );
29 32
 
30 33
 $output = $return = 0;
... ...
@@ -95,27 +98,14 @@ $theme_url = 'dist/css/' . $theme;
95 98
         <div class="navbar-default sidebar" role="navigation">
96 99
           <div class="sidebar-nav navbar-collapse">
97 100
             <ul class="nav" id="side-menu">
98
-              <li>
99
-                <a href="index.php?page=lemonde"><i class="fa fa-newspaper-o fa-fw"></i> Le Monde</a>
100
-              </li>
101
-              <li>
102
-                <a href="index.php?page=liberation"><i class="fa fa-newspaper-o fa-fw"></i> Liberation</a>
103
-              </li>
104
-              <li>
105
-                <a href="index.php?page=slatefr"><i class="fa fa-newspaper-o fa-fw"></i> Slate.fr</a>
106
-              </li>
107
-              <li>
108
-                <a href="index.php?page=vicefr"><i class="fa fa-newspaper-o fa-fw"></i> Vice.fr</a>
109
-              </li>
110
-              <li>
111
-                <a href="index.php?page=lesinrocks"><i class="fa fa-newspaper-o fa-fw"></i> LesInrocks.fr</a>
112
-              </li>
113
-              <li>
114
-                <a href="index.php?page=numerama"><i class="fa fa-newspaper-o fa-fw"></i> Numerama</a>
115
-              </li>
116
-              <li>
117
-                <a href="index.php?page=huffingtonpostfr"><i class="fa fa-newspaper-o fa-fw"></i> HuffingtonPost.fr</a>
118
-              </li>
101
+              <li><a href="index.php?page=lemonde"><i class="fa fa-newspaper-o fa-fw"></i> Le Monde</a></li>
102
+              <li><a href="index.php?page=liberation"><i class="fa fa-newspaper-o fa-fw"></i> Liberation</a></li>
103
+              <li><a href="index.php?page=slatefr"><i class="fa fa-newspaper-o fa-fw"></i> Slate.fr</a></li>
104
+              <li><a href="index.php?page=numerama"><i class="fa fa-newspaper-o fa-fw"></i> Numerama</a></li>
105
+              <li><a href="index.php?page=huffingtonpostfr"><i class="fa fa-newspaper-o fa-fw"></i> HuffingtonPost.fr</a></li>
106
+              <li><a href="index.php?page=lepointfr"><i class="fa fa-newspaper-o fa-fw"></i> LePoint.fr</a></li>
107
+              <li><a href="index.php?page=vicefr"><i class="fa fa-newspaper-o fa-fw"></i> Vice.fr</a></li>
108
+              <li><a href="index.php?page=lesinrocks"><i class="fa fa-newspaper-o fa-fw"></i> LesInrocks.fr</a></li>
119 109
             </ul>
120 110
           </div><!-- /.navbar-collapse -->
121 111
         </div><!-- /.navbar-default -->
... ...
@@ -156,6 +146,9 @@ $theme_url = 'dist/css/' . $theme;
156 146
           case "huffingtonpostfr":
157 147
             DisplayNewsHuffingtonPostFr();
158 148
             break;
149
+          case "lepointfr":
150
+            DisplayNewsLePointFr();
151
+            break;
159 152
           default:
160 153
             DisplayNewsDefault();
161 154
         }
+1
sources/news-constants.php
... ...
@@ -6,6 +6,7 @@ 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 7
 define('NEWS_RSS_NUMERAMA', 'http://www.numerama.com/rss/news.rss');
8 8
 define('NEWS_RSS_HUFFINGTONPOSTFR', 'http://www.huffingtonpost.fr/feeds/index.xml');
9
+define('NEWS_RSS_LEPOINTFR', 'http://www.lepoint.fr/24h-infos/rss.xml');
9 10
 $NEWS_RSS_MAX_ITEMS = 10;
10 11
 
11 12
 function DOMinnerHTML(DOMNode $element) 
+176
sources/news-lepoint.fr.php
... ...
@@ -0,0 +1,176 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_LEPOINTFR);
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
+    $orgStrings = array('#xtor=RSS-221');
22
+    $newStrings = array('');
23
+    $article['link']  = str_replace($orgStrings, $newStrings, $article['link']);
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['image'] = $item->enclosure['url'];
28
+    //$articles[$article['timestamp']] = $article;  
29
+    $articles[$cpt] = $article;  
30
+    echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
31
+    echo '<img src="'.$article['image'].'" style="display:inline;" width="100%"><br>';
32
+    echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;';
33
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
34
+    echo $article['title'].'&nbsp;&nbsp;';
35
+    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>';
36
+    $cpt++;
37
+    if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
38
+      break;
39
+    }
40
+  }
41
+}
42
+echo '</div><!-- ./panel-body -->';
43
+echo '</div><!-- ./panel panel-default -->';
44
+echo '</div><!-- ./col-md-6 -->';
45
+echo '<div class="col-md-6">';
46
+echo '<div class="panel panel-default">';
47
+echo '<div class="panel-body">';
48
+echo '<a name="article-top"></a><div id="article-current"></div>';
49
+$cpt=0;
50
+foreach ($articles as $article ) {
51
+  $cpt_prev=$cpt-1;
52
+  $cpt_next=$cpt+1;
53
+  echo '<!-- ==================== article '.$cpt.'============== -->';
54
+  echo "<div class=\"article\" id=\"article-$cpt\" style=\"display: none;\">\n";
55
+  echo "<hr>";
56
+  echo "<a name=\"article-$cpt\">";
57
+  $article_content = http_get_contents($article['link']);
58
+
59
+  $SEARCH_SUB1='<h1 class="art-titre list-view">';
60
+  $pos_start = strpos($article_content, $SEARCH_SUB1);
61
+  $pos_stop = false;
62
+  if(!$pos_start) {
63
+    $SEARCH_SUB1='<h2 class="art-chapeau">';
64
+    $pos_start = strpos($article_content, $SEARCH_SUB1);
65
+  }
66
+  if($pos_start) {
67
+    $SEARCH_SUB1='<h3 class="header-meme-sujet">';
68
+    $pos_stop = strpos($article_content, $SEARCH_SUB1);
69
+    if(!$pos_stop) {
70
+      $SEARCH_SUB1='<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>';
71
+      $pos_stop = strpos($article_content, $SEARCH_SUB1);
72
+      if(!$pos_stop) {
73
+        $SEARCH_SUB1='</article>';
74
+        $pos_stop = strpos($article_content, $SEARCH_SUB1);
75
+      }
76
+    }
77
+  }
78
+
79
+  if( $pos_start && $pos_stop ) {
80
+    $article_only = substr($article_content, $pos_start, $pos_stop - $pos_start);
81
+  } else {
82
+    $article_only="";
83
+  }
84
+  
85
+  //echo "pos_start : $pos_start<br>";
86
+  //echo "pos_stop : $pos_stop<br>";
87
+
88
+  $orgStrings = array( ' href="/',
89
+    ' src="/sites/',
90
+    '<img src=',
91
+    ' data-src="/');
92
+  $newStrings = array( ' href="https://www.lepoint.fr/',
93
+    ' src="https://www.lepoint.fr/sites/',
94
+    '<img width="100%" src=',
95
+    ' data-src="https://www.lepoint.fr/' );
96
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
97
+  
98
+  $orgStrings = array( '<div class="row">',
99
+    '<div class="col-md-2">',
100
+    '<div class="col-md-8">',
101
+    '<div class="container width_wrap">',
102
+    '<div class="col-left">',
103
+    '<h3> </h3>',
104
+    '<h1>',
105
+    '</h1>',
106
+    '<p style="text-align:center">',
107
+    '<div class="image-wrap panoramique bg-undefined">',
108
+    '<div class="placement-left">' );
109
+  $newStrings = array('<div>',
110
+    '<div>',
111
+    '<div>',
112
+    '<div>',
113
+    '<div>',
114
+    '',
115
+    '<h4>',
116
+    '</h4>',
117
+    '<p>',
118
+    '<div>',
119
+    '<div>');
120
+  $article_only = str_replace($orgStrings, $newStrings, $article_only);
121
+  
122
+  $temp = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
123
+  $article_only = $temp;
124
+  $temp = preg_replace('/\s\s+/', ' ', $article_only);
125
+  $article_only = $temp;
126
+  $re = '/<a class="cboxElement" (.+?)><img (.+?)><\/a>/';
127
+  $temp = preg_replace($re, '<img \\2>', $article_only);
128
+  $article_only = $temp;
129
+  $re = '/<noscript>(.+?)<\/noscript>/';
130
+  $temp = preg_replace($re, '', $article_only);
131
+  $article_only = $temp;
132
+  
133
+  $orgStrings = array( 'http://www.lepoint.fr/' );
134
+  $newStrings = array( 'https://www.lepoint.fr/' );
135
+  $article_only  = str_replace($orgStrings, $newStrings, $article_only);
136
+
137
+  $re = '/<img class="w100" alt="(.+?)" data-lazyload="loading" onclick="(.+?)" src="(.+?)" title="(.+?)" data-src="(.+?)" \/>/';
138
+  $temp = preg_replace($re, '<img width="100%" src="\\5">', $article_only);
139
+  $article_only = $temp;
140
+
141
+  $re = '/<img class="" src data-lazyload="loading" data-src="(.+?)" data-alt="(.+?)" width="(.+?)" height="(.+?)" alt title="(.+?)"\/>/';
142
+  $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only);
143
+  $article_only = $temp;
144
+
145
+  $re = '/<img src data-lazyload="loading" data-src="(.+?)" data-alt="(.+?)" alt="(.+?)" width="(.+?)" height="(.+?)" \/>/';
146
+  $temp = preg_replace($re, '<img width="100%" src="\\1">', $article_only);
147
+  $article_only = $temp;
148
+
149
+  $re = '/<img class="w100" alt="" data-lazyload="loading" onclick="(.+?)" src="(.+?)" title="" data-src="(.+?)" \/>/';
150
+  $temp = preg_replace($re, '<img width="100%" src="\\3">', $article_only);
151
+  $article_only = $temp;
152
+
153
+  $re = '/<a href="(.+?)" class="button-type pat little-button-mob" onclick="(.+?)">Abonnez-vous<\/a>/';
154
+  $temp = preg_replace($re, '', $article_only);
155
+  $article_only = $temp;
156
+  
157
+  $re = '/<a onclick="(.+?)" data-shadowbox="#authform" href="(.+?)" id="connect_viafreemium" class="w100 block txtcenter br-4-all bg-grey-medium-blue pas font-black bold br-4-all upper">Identifiez-vous<\/a>/';
158
+  $temp = preg_replace($re, '', $article_only);
159
+  $article_only = $temp;
160
+  
161
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
162
+  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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
163
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
164
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
165
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
166
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
167
+  echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-up fa-2x"></i></a></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
168
+  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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
169
+  echo '<div id="nav-prev" onclick="onArticle('.$cpt_prev.')" style="display:inline;"><i class="fa fa-chevron-left fa-2x"></i></div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
170
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
171
+  $cpt++;
172
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
173
+      break;
174
+  }
175
+}
176
+?>