Andrew Lewman commited on 2014-09-27 04:56:58
Zeige 2 geänderte Dateien mit 181 Einfügungen und 28 Löschungen.
| ... | ... |
@@ -1178,6 +1178,69 @@ small {
|
| 1178 | 1178 |
line-height: 13px; |
| 1179 | 1179 |
} |
| 1180 | 1180 |
|
| 1181 |
+/* BLOG WIDGET ----------*/ |
|
| 1182 |
+ |
|
| 1183 |
+div.blogRow, div.blogFirstRow {
|
|
| 1184 |
+ height: 40px; |
|
| 1185 |
+ padding: 3px 10px; |
|
| 1186 |
+ margin: 0 0; |
|
| 1187 |
+} |
|
| 1188 |
+ |
|
| 1189 |
+div.blogLastRow {
|
|
| 1190 |
+ height: 20px; |
|
| 1191 |
+ text-align: center; |
|
| 1192 |
+ } |
|
| 1193 |
+ |
|
| 1194 |
+div.blogFirstRow {
|
|
| 1195 |
+ height: 22px; |
|
| 1196 |
+ background: url(../images/table-head.jpg) left top repeat-x #885ca4; |
|
| 1197 |
+ } |
|
| 1198 |
+ |
|
| 1199 |
+.blogRow:hover {
|
|
| 1200 |
+ background: #f6ffd5; |
|
| 1201 |
+ } |
|
| 1202 |
+ |
|
| 1203 |
+div.blogRow1, div.blogRow3 {
|
|
| 1204 |
+ background: #eee8f1; |
|
| 1205 |
+} |
|
| 1206 |
+ |
|
| 1207 |
+.blogFeed a {
|
|
| 1208 |
+text-decoration: none; |
|
| 1209 |
+} |
|
| 1210 |
+ |
|
| 1211 |
+.blogFeed p {
|
|
| 1212 |
+margin: 0; |
|
| 1213 |
+font-size: 12px; |
|
| 1214 |
+} |
|
| 1215 |
+ |
|
| 1216 |
+p.blogTitle {
|
|
| 1217 |
+ font-weight: bold; |
|
| 1218 |
+ text-decoration: underline; |
|
| 1219 |
+ } |
|
| 1220 |
+ |
|
| 1221 |
+p.blogAuthor {
|
|
| 1222 |
+ color: #000000; |
|
| 1223 |
+ text-align: right; |
|
| 1224 |
+ margin-top: -20px; |
|
| 1225 |
+ } |
|
| 1226 |
+ |
|
| 1227 |
+p.blogAuthor em{
|
|
| 1228 |
+ color: #4e6a20; |
|
| 1229 |
+ text-align: right; |
|
| 1230 |
+ margin-top: -20px; |
|
| 1231 |
+ } |
|
| 1232 |
+ |
|
| 1233 |
+p.blogDate {
|
|
| 1234 |
+ color: #000000; |
|
| 1235 |
+ } |
|
| 1236 |
+ |
|
| 1237 |
+.blogFeed h2 {
|
|
| 1238 |
+ font-size: 1.467em; |
|
| 1239 |
+ margin: 0; |
|
| 1240 |
+ line-height: 23px; |
|
| 1241 |
+ color: #f6f6ed; |
|
| 1242 |
+ } |
|
| 1243 |
+ |
|
| 1181 | 1244 |
/* |
| 1182 | 1245 |
Project page |
| 1183 | 1246 |
*/ |
| ... | ... |
@@ -153,35 +153,125 @@ |
| 153 | 153 |
</div> |
| 154 | 154 |
<!-- END MAINCOL --> |
| 155 | 155 |
<div id="sidecol"> |
| 156 |
- <div id="home-announcements" class="clearfix"> |
|
| 157 |
- <h2>Announcements</h2> |
|
| 158 |
- <table> |
|
| 159 |
- <tr> |
|
| 160 |
- <td> |
|
| 161 |
- <div class="calendar"><span class="month">Sep</span><br><span class="day">11</span></div> |
|
| 162 |
- <p>Tor 0.2.5.7-rc is <a href="https://blog.torproject.org/blog/tor-0257-rc-out">out</a></p> |
|
| 163 |
- </td> |
|
| 164 |
- </tr> |
|
| 165 |
- <tr> |
|
| 166 |
- <td> |
|
| 167 |
- <div class="calendar"><span class="month">Sep</span><br><span class="day">7</span></div> |
|
| 168 |
- <p><a href="https://blog.torproject.org/blog/ahmia-search-after-gsoc-development">Ahmia search</a> after GSoC development</p> |
|
| 169 |
- </td> |
|
| 170 |
- </tr> |
|
| 171 |
- <tr> |
|
| 172 |
- <td> |
|
| 173 |
- <div class="calendar"><span class="month">Sep</span><br><span class="day">3</span></div> |
|
| 174 |
- <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> |
|
| 175 |
- </td> |
|
| 176 |
- </tr> |
|
| 177 |
- <tr> |
|
| 178 |
- <td> |
|
| 179 |
- <div class="calendar"><span class="month">Sep</span><br><span class="day">2</span></div> |
|
| 180 |
- <p>Tails 1.1.1 is <a href="https://blog.torproject.org/blog/tails-111-out">out</a></p> |
|
| 181 |
- </td> |
|
| 182 |
- </tr> |
|
| 183 |
- </table> |
|
| 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 »</p> |
|
| 184 | 270 |
</div> |
| 271 |
+ </a> |
|
| 272 |
+ </div>"; |
|
| 273 |
+:> |
|
| 274 |
+ <!-- END BLOG WIDGET --> |
|
| 185 | 275 |
<div id="home-users"> |
| 186 | 276 |
<h2>Who Uses Tor?</h2> |
| 187 | 277 |
<div class="fauxhead"></div> |
| 188 | 278 |