[tor-commits] r26958: {website} remove Announcements in favor of rss feed integrated blog po (in website/trunk: css en)
Andrew Lewman
andrew at torproject.org
Sat Sep 27 02:56:58 UTC 2014
Author: phobos
Date: 2014-09-27 02:56:58 +0000 (Sat, 27 Sep 2014)
New Revision: 26958
Modified:
website/trunk/css/layout.css
website/trunk/en/index.wml
Log:
remove Announcements in favor of rss feed integrated blog posts section.
Modified: website/trunk/css/layout.css
===================================================================
--- website/trunk/css/layout.css 2014-09-26 09:05:58 UTC (rev 26957)
+++ website/trunk/css/layout.css 2014-09-27 02:56:58 UTC (rev 26958)
@@ -1178,6 +1178,69 @@
line-height: 13px;
}
+/* BLOG WIDGET ----------*/
+
+div.blogRow, div.blogFirstRow {
+ height: 40px;
+ padding: 3px 10px;
+ margin: 0 0;
+}
+
+div.blogLastRow {
+ height: 20px;
+ text-align: center;
+ }
+
+div.blogFirstRow {
+ height: 22px;
+ background: url(../images/table-head.jpg) left top repeat-x #885ca4;
+ }
+
+.blogRow:hover {
+ background: #f6ffd5;
+ }
+
+div.blogRow1, div.blogRow3 {
+ background: #eee8f1;
+}
+
+.blogFeed a {
+text-decoration: none;
+}
+
+.blogFeed p {
+margin: 0;
+font-size: 12px;
+}
+
+p.blogTitle {
+ font-weight: bold;
+ text-decoration: underline;
+ }
+
+p.blogAuthor {
+ color: #000000;
+ text-align: right;
+ margin-top: -20px;
+ }
+
+p.blogAuthor em{
+ color: #4e6a20;
+ text-align: right;
+ margin-top: -20px;
+ }
+
+p.blogDate {
+ color: #000000;
+ }
+
+.blogFeed h2 {
+ font-size: 1.467em;
+ margin: 0;
+ line-height: 23px;
+ color: #f6f6ed;
+ }
+
/*
Project page
*/
Modified: website/trunk/en/index.wml
===================================================================
--- website/trunk/en/index.wml 2014-09-26 09:05:58 UTC (rev 26957)
+++ website/trunk/en/index.wml 2014-09-27 02:56:58 UTC (rev 26958)
@@ -153,35 +153,125 @@
</div>
<!-- END MAINCOL -->
<div id="sidecol">
- <div id="home-announcements" class="clearfix">
- <h2>Announcements</h2>
- <table>
- <tr>
- <td>
- <div class="calendar"><span class="month">Sep</span><br><span class="day">11</span></div>
- <p>Tor 0.2.5.7-rc is <a href="https://blog.torproject.org/blog/tor-0257-rc-out">out</a></p>
- </td>
- </tr>
- <tr>
- <td>
- <div class="calendar"><span class="month">Sep</span><br><span class="day">7</span></div>
- <p><a href="https://blog.torproject.org/blog/ahmia-search-after-gsoc-development">Ahmia search</a> after GSoC development</p>
- </td>
- </tr>
- <tr>
- <td>
- <div class="calendar"><span class="month">Sep</span><br><span class="day">3</span></div>
- <p>Tor Browser 3.6.5 and 4.0-alpha-2 are <a href="https://blog.torproject.org/blog/tor-browser-365-and-40-alpha-2-are-released">released</a></p>
- </td>
- </tr>
- <tr>
- <td>
- <div class="calendar"><span class="month">Sep</span><br><span class="day">2</span></div>
- <p>Tails 1.1.1 is <a href="https://blog.torproject.org/blog/tails-111-out">out</a></p>
- </td>
- </tr>
- </table>
- </div>
+ <!-- BLOG WIDGET -->
+<:
+ use strict;
+ use warnings;
+ use open ':std', ':encoding(UTF-8)';
+ use LWP::Simple;
+
+ # RSS feed url
+ my $url = 'https://blog.torproject.org/blog/feed';
+ # Number of posts to show
+ my $showPosts = "5";
+ # Maximum characters in post title to allow before truncating
+ my $titleMaxLength = "35";
+ # Maximum characters in author name to allow before truncating
+ my $authorMaxLength = "15";
+
+ # Retreive url
+ my $data = get( $url );
+
+ if ($data) # Url returned data
+ {
+ my $check = $data;
+ $check =~ m{<rss(.*?)>}i;
+ my $checkVal = $1;
+
+ if ($checkVal) # Is an rss feed
+ {
+ my $titleStr = $data;
+ my $linkStr = $data;
+ my $dateStr = $data;
+ my $authorStr = $data;
+
+ print "<div class='blogFeed'>
+ <div class='blogFirstRow'>
+ <h2>Recent Blog Posts</h2>
+ </div>";
+
+ # Generate posts
+ for my $i (0..$showPosts)
+ {
+
+ # Parse title
+ $titleStr =~ m{<title>(.*?)</title>}g;
+ my $titleVal = $1;
+ my $titleLength = length($titleVal);
+ my $title = $titleVal;
+
+ # Check title length and trim if necessary
+ my $titleTrim = $title;
+ if ($titleLength > $titleMaxLength)
+ {
+ my $trimLength = $titleMaxLength - 3;
+ my $titleTxt = substr($title, 0, $trimLength);
+ $titleTrim = "$titleTxt...";
+ }
+
+ # Parse link
+ $linkStr =~ m{<link>(.*?)</link>}g;
+ my $link = $1;
+
+ if ($i != 0)
+ {
+ # Parse date
+ $dateStr =~ m{<pubDate>(.*?)</pubDate>}g;
+ my $date = $1;
+
+ # Trim date
+ my $dateTrim = substr($date, 0, -15);
+
+ # Parse author
+ $authorStr =~ m{<dc:creator>(.*?)\s*</dc:creator>}g;
+ my $author = $1;
+
+ # Check author length and trim if necessary
+ my $authorLength = length($author);
+ my $authorTrim = $author;
+ if ($authorLength > $authorMaxLength)
+ {
+ my $authorTrimLength = $authorMaxLength - 3;
+ my $authorTxt = substr($author, 0, $authorTrimLength);
+ $authorTrim = "$authorTxt...";
+ }
+
+ # Begin html output
+ print "<a href=\'$link\' title=\'$title\'>";
+
+ # Required for alternating row colors - switch blogRow# to change order
+ if (0 == $i % 2) {
+ print "<div class='blogRow blogRow1'>";
+ } else {
+ print "<div class='blogRow blogRow0'>";
+ }
+
+ print "<p class='blogTitle'>$titleTrim</p>
+ <p class='blogDate'>$dateTrim</p>
+ <p class='blogAuthor'>Posted by: <em>$authorTrim</em></p>
+ </div>
+ </a>";
+ }
+ }
+
+ } else { # Not an rss feed
+ print "<div class='blogRow blogRow1'>";
+ print "<br /><p class='blogDate' style=\"text-align:center;color:\#999;line-height:16px;\"><em>Recent posts are temporarily unavailable</em></p></div>";
+ }
+
+ } else { # Url did not return any data
+ print "<div class='blogRow blogRow1'>";
+ print "<br /><p class='blogDate' style=\"text-align:center;color:\#999;line-height:16px;\"><em>Recent posts are temporarily unavailable</em></p></div>";
+ }
+
+ print "<a href='https://blog.torproject.org' title='Tor Blog Home'>
+ <div class='blogRow blogLastRow'>
+ <p>View all blog posts »</p>
+ </div>
+ </a>
+ </div>";
+:>
+ <!-- END BLOG WIDGET -->
<div id="home-users">
<h2>Who Uses Tor?</h2>
<div class="fauxhead"></div>
More information about the tor-commits
mailing list