Browse code

Do not use the network while building the tor website

Peter Palfrader authored on17/10/2014 16:46:14
Showing2 changed files
... ...
@@ -154,123 +154,7 @@
154 154
       <!-- END MAINCOL -->
155 155
       <div id="sidecol">
156 156
       <!-- BLOG WIDGET -->
157
-<:
158
-  use strict;
159
-  use warnings;
160
-  use open ':std', ':encoding(UTF-8)';
161
-  use LWP::Simple;
162
-
163
-  # RSS feed url
164
-  my $url = 'https://blog.torproject.org/blog/feed';
165
-  # Number of posts to show
166
-  my $showPosts = "5";
167
-  # Maximum characters in post title to allow before truncating
168
-  my $titleMaxLength = "35";
169
-  # Maximum characters in author name to allow before truncating
170
-  my $authorMaxLength = "15";
171
-  
172
-  # Retreive url
173
-  my $data = get( $url );
174
-  
175
-  if ($data) # Url returned data
176
-  {
177
-    my $check = $data;
178
-    $check =~ m{<rss(.*?)>}i;
179
-    my $checkVal = $1;
180
-
181
-    if ($checkVal) # Is an rss feed
182
-    {
183
-      my $titleStr = $data;
184
-      my $linkStr = $data;
185
-      my $dateStr = $data;
186
-      my $authorStr = $data;
187
-    
188
-      print "<div class='blogFeed'>
189
-             <div class='blogFirstRow'>
190
-             <h2>Recent Blog Posts</h2>
191
-             </div>";
192
-
193
-      # Generate posts
194
-      for my $i (0..$showPosts)
195
-      {  
196
-      	
197
-	# Parse title
198
-	$titleStr =~ m{<title>(.*?)</title>}g;
199
-	my $titleVal = $1;
200
-	my $titleLength = length($titleVal);
201
-	my $title = $titleVal;
202
-
203
-	# Check title length and trim if necessary
204
-      	my $titleTrim = $title;
205
-        if ($titleLength > $titleMaxLength)
206
-      	{
207
-    	    my $trimLength = $titleMaxLength - 3;
208
-    	    my $titleTxt = substr($title, 0, $trimLength);
209
-    	    $titleTrim = "$titleTxt...";
210
-      	}
211
-    
212
-	# Parse link
213
-	$linkStr =~ m{<link>(.*?)</link>}g;
214
-	my $link = $1;
215
-
216
-	if ($i != 0)
217
-        {
218
-	  # Parse date
219
-	  $dateStr =~ m{<pubDate>(.*?)</pubDate>}g;
220
-	  my $date = $1;
221
-
222
-	  # Trim date
223
-	  my $dateTrim = substr($date, 0, -15);
224
-
225
-	  # Parse author
226
-	  $authorStr =~ m{<dc:creator>(.*?)\s*</dc:creator>}g;
227
-	  my $author = $1;
228
-
229
-	  # Check author length and trim if necessary
230
-	  my $authorLength = length($author);
231
-	  my $authorTrim = $author;
232
-	  if ($authorLength > $authorMaxLength)
233
-	  {
234
-	      my $authorTrimLength = $authorMaxLength - 3;
235
-	      my $authorTxt = substr($author, 0, $authorTrimLength);
236
-	      $authorTrim = "$authorTxt...";
237
-	  }
238
-
239
-	  # Begin html output
240
-	  print "<a href=\'$link\' title=\'$title\'>";
241
-	  
242
-	  # Required for alternating row colors - switch blogRow# to change order
243
-	  if (0 == $i % 2) {
244
-	      print "<div class='blogRow blogRow1'>";
245
-	  } else {
246
-	      print "<div class='blogRow blogRow0'>";
247
-	  }
248
-	  
249
-	  print "<p class='blogTitle'>$titleTrim</p>
250
-		<p class='blogDate'>$dateTrim</p>
251
-		<p class='blogAuthor'>Posted by: <em>$authorTrim</em></p>
252
-		</div>
253
-		</a>";    
254
-	}
255
-      }
256
-      
257
-    } else {	# Not an rss feed
258
-      print "<div class='blogRow blogRow1'>";
259
-      print "<br /><p class='blogDate' style=\"text-align:center;color:\#999;line-height:16px;\"><em>Recent posts are temporarily unavailable</em></p></div>";    
260
-    }
261
-  
262
-  } else {	# Url did not return any data
263
-    print "<div class='blogRow blogRow1'>";
264
-    print "<br /><p class='blogDate' style=\"text-align:center;color:\#999;line-height:16px;\"><em>Recent posts are temporarily unavailable</em></p></div>";    
265
-  }
266
-  
267
-  print "<a href='https://blog.torproject.org' title='Tor Blog Home'>
268
-  <div class='blogRow blogLastRow'>
269
-	<p>View all blog posts &raquo;</p>
270
-	</div>
271
-	</a>
272
-	</div>";
273
-:>
157
+#include <blog-recent.wmi>
274 158
       <!-- END BLOG WIDGET -->
275 159
       	<div id="home-users">
276 160
           <h2>Who Uses Tor?</h2>
277 161
new file mode 100644
... ...
@@ -0,0 +1,2 @@
1
+<div class='blogRow blogRow1'>
2
+<br /><p class='blogDate' style=\"text-align:center;color:\#999;line-height:16px;\"><em>Recent posts are temporarily unavailable</em></p></div>