Showing 4 changed files with 124 additions and 2 deletions
+24
dist/css/hackernews.css
... ...
@@ -105,3 +105,27 @@ h4 {
105 105
     width: 140px;
106 106
     float: left;
107 107
 }
108
+
109
+
110
+img {
111
+  width: 80%;
112
+  margin-left: auto;
113
+  margin-right: auto;
114
+}
115
+.img-conspiracy {
116
+  width: 50%;
117
+  margin-left: 30%;
118
+  margin-right: auto;
119
+}
120
+.wp-video {
121
+  width: 80%;
122
+}
123
+.wp-video-shortcode {
124
+  width: 80%;
125
+}
126
+
127
+iframe {
128
+  width: 80%;
129
+  margin-left: auto;
130
+  margin-right: auto;
131
+}
+1
sources/gennews.jessie.sh
... ...
@@ -10,3 +10,4 @@ php news-huffingtonpost.fr.php > huffingtonpostfr.html 2> /dev/null
10 10
 php news-lepoint.fr.php > lepointfr.html 2> /dev/null
11 11
 php news-lexpress.fr.php > lexpressfr.html 2> /dev/null
12 12
 php news-franceinfo.php > franceinfo.html 2> /dev/null
13
+php news-conspiracy.php > conspiracy.html 2> /dev/null
+94
sources/news-conspiracy.php
... ...
@@ -0,0 +1,94 @@
1
+<?php
2
+include_once( 'news-constants.php' );
3
+
4
+$rss_content = http_get_contents(NEWS_RSS_CONSPIRACY);
5
+$rss_content = str_replace("<content:encoded>","<contentEncoded>",$rss_content);
6
+$rss_content = str_replace("</content:encoded>","</contentEncoded>",$rss_content);
7
+$articles = array();
8
+$xml = simplexml_load_string($rss_content);
9
+if ($xml === false) {
10
+  echo 'Failed to read RSS';
11
+} else {
12
+  $channel = array();
13
+  $channel['title'] = $xml->channel->title;
14
+  $channel['link'] = $xml->channel->link;
15
+  $channel['description'] = $xml->channel->description;
16
+  $channel['pubDate'] = $xml->channel->pubDate;
17
+  $channel['timestamp'] = strtotime($xml->channel->pubDate);
18
+  echo '<h4>' . $channel['title'] . '</h4>';
19
+  $cpt=0;
20
+  foreach ($xml->channel->item as $item) {
21
+    $article = array();
22
+    $article['title'] = $item->title;
23
+    $article['link'] = $item->link;
24
+    $article['pubDate'] = $item->pubDate;
25
+    $article['timestamp'] = strtotime($item->pubDate);
26
+    $article['description'] = $item->description;
27
+    $article['content'] = $item->contentEncoded;
28
+    //Extract image
29
+    $re = '/<img class="size-medium wp-image-(.+?)" src="(.+?)" alt=(.+?)>/';
30
+    preg_match($re, $article['content'], $matches);
31
+    $article['image'] = $matches[2];
32
+    if ( 0 == strlen($article['image']) ) {
33
+      $re = '/<img class="aligncenter wp-image-(.+?)" src="(.+?)" alt=(.+?)>/';
34
+      preg_match($re, $article['content'], $matches);
35
+      $article['image'] = $matches[2];
36
+    }
37
+
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>&nbsp;&nbsp;';
42
+    echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div>&nbsp;';
43
+    echo $article['title'].'&nbsp;&nbsp;';
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_only = $article['content'];
67
+
68
+  //$article_only = preg_replace('//', '', $article_only);
69
+  $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
70
+  $article_only = preg_replace('/\s\s+/', ' ', $article_only);
71
+  $article_only = preg_replace('/<div (.+?) class="wp-video">/', '<div class="wp-video">', $article_only);
72
+  $article_only = preg_replace('/<video class="wp-video-shortcode" id="(.+?)" (.+?) preload="metadata" controls="controls">/', '<video class="wp-video-shortcode" id="\1" preload="metadata" controls="controls">', $article_only);
73
+  $article_only = preg_replace('/<iframe (.+?) src="(.+?)" (.+?)><\/iframe>/', '<iframe src="\2"></iframe>', $article_only);
74
+  $article_only = preg_replace('/<img (.+?) width="(.+?)" height="(.+?)" (.+?)>/', '<img \1 \4>', $article_only);
75
+  $article_only = preg_replace('/<img (.+?) srcset="(.+?)" sizes="(.+?)" \/>/', '<img \1>', $article_only);
76
+  $article_only = preg_replace('/<div id="(.+?)" style="width: (.+?)" (.+?)>/', '<div id="\1" \3>', $article_only);
77
+  $article_only = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $article_only);
78
+
79
+  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;';
80
+  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;';
81
+  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;';
82
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div>';
83
+  echo '<div class="extract-content" id="'.$cpt.'">'.$article_only.'</div>';
84
+  echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> ';
85
+  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;';
86
+  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;';
87
+  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;';
88
+  echo '<div id="nav-next" onclick="onArticle('.$cpt_next.')" style="display:inline;"><i class="fa fa-chevron-right fa-2x"></i></div></div>';
89
+  $cpt++;
90
+  if( $cpt > $NEWS_RSS_MAX_ITEMS ) {
91
+      break;
92
+  }
93
+}
94
+?>
+5 -2
sources/rss.php
... ...
@@ -9,6 +9,7 @@ define('NEWS_RSS_HUFFINGTONPOSTFR', 'https://www.huffingtonpost.fr/feeds/index.x
9 9
 define('NEWS_RSS_LEPOINTFR', 'http://www.lepoint.fr/24h-infos/rss.xml');
10 10
 define('NEWS_RSS_LEXPRESSFR', 'https://www.lexpress.fr/rss/alaune.xml');
11 11
 define('NEWS_RSS_FRANCEINFO', 'https://www.francetvinfo.fr/titres.rss');
12
+define('NEWS_RSS_CONSPIRACY', 'http://www.conspiracywatch.info/feed');
12 13
 
13 14
 $array_title=array(
14 15
   "lemonde" => "LeMonde.fr",
... ...
@@ -20,7 +21,8 @@ $array_title=array(
20 21
   "lexpressfr" => "L'Express.fr",
21 22
   "vicefr" => "Vice.fr",
22 23
   "franceinfo" => "FranceInfo",
23
-  "lesinrocks" => "LesInrocks.fr"
24
+  "lesinrocks" => "LesInrocks.fr",
25
+  "conspiracy" => "Conspiracy Watch"
24 26
 );
25 27
 $array_url=array(
26 28
   "lemonde" => NEWS_RSS_LEMONDE,
... ...
@@ -32,6 +34,7 @@ $array_url=array(
32 34
   "lexpressfr" => NEWS_RSS_LEXPRESSFR,
33 35
   "vicefr" => NEWS_RSS_VICEFR,
34 36
   "franceinfo" => NEWS_RSS_FRANCEINFO,
35
-  "lesinrocks" => NEWS_RSS_LESINROCKS
37
+  "lesinrocks" => NEWS_RSS_LESINROCKS,
38
+  "conspiracy" => NEWS_RSS_CONSPIRACY
36 39
 );
37 40
 ?>