[Jifty-commit] r6336 - in jifty/trunk: .

Jifty commits jifty-commit at lists.jifty.org
Fri Feb 13 02:13:35 EST 2009


Author: c9s
Date: Fri Feb 13 02:13:33 2009
New Revision: 6336

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/plugins/NewsFeed/lib/Jifty/Plugin/NewsFeed/View.pm

Log:
 r7215 at Oulixeus:  c9s | 2009-02-13 15:03:27 +0800
 - div wrapper for feed ( newsfeed plugin )


Modified: jifty/trunk/plugins/NewsFeed/lib/Jifty/Plugin/NewsFeed/View.pm
==============================================================================
--- jifty/trunk/plugins/NewsFeed/lib/Jifty/Plugin/NewsFeed/View.pm	(original)
+++ jifty/trunk/plugins/NewsFeed/lib/Jifty/Plugin/NewsFeed/View.pm	Fri Feb 13 02:13:33 2009
@@ -53,10 +53,6 @@
 
 order feed items by date, 'DESC' or 'ASC'
 
-=item style => I<string>  I<(optional)>
-
-style could be 'list', 'p' , 'none' , default is 'list'.
-
 =cut
 
 template 'display_feed' => sub {
@@ -67,6 +63,7 @@
     return unless ( $feed_url and $feed_url =~ m(^https?://) );
 
     use XML::Feed;
+	use LWP::Simple ();
     use Encode qw(decode_utf8);
 	use Cache::File;
 
@@ -77,9 +74,8 @@
 	my $c1 = Cache::File->new( cache_root =>  $plugin->config->{CacheRoot}  );
 	my $feed_xml = $c1->get( 'feed_url' );
  	unless ($feed_xml) {
-		use LWP::Simple;
 		Jifty->log->info('Fetch feed:' . $feed_url );
- 		$feed_xml = get $feed_url;
+ 		$feed_xml = LWP::Simple::get $feed_url;
  		$c1->set( 'feed_url' , $feed_xml , '1 hours' );
  	}
 
@@ -116,75 +112,27 @@
     @entries = reverse @entries 
             if( defined $options->{order} and $options->{order} eq 'ASC' );
 
-    my $style = $options->{style} || 'list';
-
-    h2 { { class is 'feed-title' } ; $feed_title } 
-            unless ( defined $options->{hide_title} );
-
-    if( $style eq 'list' ) {
-        show 'feed_list_style',\@entries;
-    }
-    elsif( $style eq 'p' ) {
-        show 'feed_p_style',\@entries;
-    }
-    elsif( $style eq 'none' ) {
-        show 'feed_none_style',\@entries;
-    }
-    else {
-        show 'feed_list_style',\@entries;
-    }
- 
-};
+	return unless @entries ;
 
-template 'feed_list_style' => sub {
-    my $self = shift;
-    my @entries = @{ +shift };
-    ul { { class is 'feed-entries' } ;
-        for my $entry ( @entries ) {
-            my $issued = $entry->issued;
-            my $title = decode_utf8 ( $entry->title );
-            my $summary = decode_utf8( $entry->summary );
-            my $link  = $entry->link;
-
-            li { { class is 'feed-entry' }; 
-                outs_raw (qq|<a class="feed-link" href="$link">$title</a>|); } 
-                    if ( $title );
-        }
-    };
-};
+	div { { id is $options->{wrapper_id} || 'feed' , class is $options->{wrapper_class} || 'feed' } ;
+		h2 { { class is 'feed-title' } ; $feed_title } 
+			unless ( defined $options->{hide_title} );
+		
+		for my $entry ( @entries ) {
+			my $issued = $entry->issued;
+			my $title = decode_utf8 $entry->title ;
+			my $summary = decode_utf8 $entry->summary ;
+			my $link  = $entry->link;
+
+			span { { class is $options->{item_class} || 'feed-entry' }; 
+				outs_raw (qq|<a class="feed-link" href="$link">$title</a>|); } 
+					if ( $title );
+		}
+	};
 
-template 'feed_p_style' => sub {
-    my $self = shift;
-    my @entries = @{ +shift };
-    for my $entry ( @entries ) {
-        my $issued = $entry->issued;
-        my $title = decode_utf8 ( $entry->title );
-        my $summary = decode_utf8( $entry->summary );
-        my $link  = $entry->link;
-
-        p { { class is 'feed-entry' }; 
-            outs_raw (qq|<a class="feed-link" href="$link">$title</a>|); } 
-                if ( $title );
-    }
-};
 
-template 'feed_none_style' => sub {
-    my $self = shift;
-    my @entries = @{ +shift };
-    for my $entry ( @entries ) {
-        my $issued = $entry->issued;
-        my $title = decode_utf8 ( $entry->title );
-        my $summary = decode_utf8( $entry->summary );
-        my $link  = $entry->link;
-
-        span { { class is 'feed-entry' }; 
-            outs_raw (qq|<a class="feed-link" href="$link">$title</a>|); } 
-                if ( $title );
-    }
-    
 };
 
 
 
-
 1;


More information about the Jifty-commit mailing list