Browse files

Merge branch 'master' into adding-js+css-tabs-to-authors-pages

  • Loading branch information...
2 parents e99bfbf + e83c890 commit 696fcd9d6e5155f944f19522ddb276276b78b077 @shlomif shlomif committed Jun 18, 2009
Showing with 43 additions and 48 deletions.
  1. +0 −39 lib/CPANHQ/Controller/Root.pm
  2. +1 −9 root/wrapper.tt
  3. +42 −0 tmp/gen-twitter-feed.pl
View
39 lib/CPANHQ/Controller/Root.pm
@@ -4,8 +4,6 @@ use strict;
use warnings;
use parent 'Catalyst::Controller';
-use XML::RSS;
-use LWP::Simple qw(get);
__PACKAGE__->config->{namespace} = '';
@@ -21,43 +19,6 @@ CPANHQ::Controller::Root - Root Controller for CPANHQ
=cut
-=head2 auto
-
-=cut
-
-sub auto : Private {
- my( $self, $c ) = @_;
-
- my $rss = XML::RSS->new;
-
-=begin TwitterElimination
- # Getting rid of the Twitter feed, because:
- #
- # 1. Twitter is down at the moment.
- #
- # 2. It returns an HTTP error code of 200 ("OK") with a weirdo XML
- # instead of 4xx/5xx.
- #
- # 3. It makes the CPANHQ server slow.
- #
- # 4. It emits a warning.
-
- my $content = get(
- 'http://twitter.com/statuses/user_timeline/36758099.rss'
- );
-
- if (defined($content)) {
- $rss->parse( $content );
- }
-
-=end TwitterElimination
-
-=cut
-
- $c->stash( tweets => $rss );
- return 1;
-}
-
=head2 index
=cut
View
10 root/wrapper.tt
@@ -39,15 +39,7 @@ Not logged in (<a href="[% c.uri_for('/login') %]">Login</a>)
<div id=content>
[% content %]
</div>
- <div id=sidebar>
-<h2>CPANHQ Updates</h2>
-<ul id=tweets>
-[% FOREACH tweet IN tweets.items %]
- <li>[% tweet.description.remove( '^cpanhq: ' ) %] <span class="link">(<a href="[% tweet.link %]">link</a>)</span></li>
-[% END %]
-</ul>
-<p style="text-align: right;">Follow us on <a href="http://twitter.com/cpanhq">Twitter</a>.</p>
- </div>
+[% INSERT "static/tweets.html-portion" %]
<div id=footer>
<ul id=botmenu>
<li class=first><a href="[% c.uri_for('/about') %]">About CPANHQ</a></li>
View
42 tmp/gen-twitter-feed.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use XML::RSS;
+use LWP::Simple qw(get);
+
+my $content = get(
+ 'http://twitter.com/statuses/user_timeline/36758099.rss'
+);
+
+if (defined($content)) {
+
+ my $tweets = XML::RSS->new();
+
+ $tweets->parse( $content );
+
+ open my $html_fh, ">", "./root/static/tweets.html-portion";
+ print {$html_fh} <<'EOF';
+ <div id=sidebar>
+<h2>CPANHQ Updates</h2>
+<ul id=tweets>
+EOF
+
+ foreach my $tweet (@{$tweets->{'items'}})
+ {
+ my $desc = $tweet->{'description'};
+ $desc =~ s{^cpanhq: }{};
+ my $link = $tweet->{'link'};
+ print {$html_fh} qq{<li>$desc <span class="link">(<a href="$link>link</a>)</span></li>\n};
+ }
+
+ print {$html_fh} <<'EOF';
+</ul>
+<p style="text-align: right;">Follow us on <a href="http://twitter.com/cpanhq">Twitter</a>.</p>
+ </div>
+EOF
+
+ close($html_fh);
+}
+

0 comments on commit 696fcd9

Please sign in to comment.