afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-10-08 05:21 pm

[dw-free] Subscription Filters: create a module to display them as links

[commit: http://hg.dwscoalition.org/dw-free/rev/2b0c2e98b22f]

http://bugs.dwscoalition.org/show_bug.cgi?id=1867

Add subscription filters to logged-in homepage, as part of the ReadingList
widget.

Patch by [staff profile] denise.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/DW/Widget/ReadingList.pm
--------------------------------------------------------------------------------
diff -r 30df6fadab39 -r 2b0c2e98b22f bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Thu Oct 08 17:16:43 2009 +0000
+++ b/bin/upgrading/en.dat	Thu Oct 08 17:20:29 2009 +0000
@@ -4537,6 +4537,10 @@ widget.readinglist.breakdown.header=You 
 
 widget.readinglist.breakdown.personal=[[num]] personal journals
 
+widget.readinglist.filters.nofilters=You currently have no subscription filters. Would you like to <a [[aopts]]>create some</a>?
+
+widget.readinglist.filters.title=Your Subscription Filters
+
 widget.readinglist.readpage=Check out recent updates on your <a [[aopts]]>reading list</a>!
 
 widget.readinglist.title=Reading List
diff -r 30df6fadab39 -r 2b0c2e98b22f cgi-bin/DW/Widget/ReadingList.pm
--- a/cgi-bin/DW/Widget/ReadingList.pm	Thu Oct 08 17:16:43 2009 +0000
+++ b/cgi-bin/DW/Widget/ReadingList.pm	Thu Oct 08 17:20:29 2009 +0000
@@ -18,6 +18,7 @@ package DW::Widget::ReadingList;
 
 use strict;
 use base qw/ LJ::Widget /;
+use DW::User::ContentFilters;
 
 sub render_body {
     my ( $class, %opts ) = @_;
@@ -34,7 +35,20 @@ sub render_body {
     $ret .= "<p>" . $class->ml( 'widget.readinglist.breakdown.header' ) . "</p>";
     $ret .= "<ul><li>" . $class->ml( 'widget.readinglist.breakdown.personal', { num => $count{personal} + 0 } ) . "</li>";
     $ret .= "<li>" . $class->ml( 'widget.readinglist.breakdown.communities', { num => $count{community} + 0 } ) . "</li>";
-    $ret .= "<li>" . $class->ml( 'widget.readinglist.breakdown.feeds', { num => $count{syndicated} + 0 } ) . "</li></ul>";
+    $ret .= "<li>" . $class->ml( 'widget.readinglist.breakdown.feeds', { num => $count{syndicated} + 0 } ) . "</li></ul><br />";
+
+    my @filters = $remote->content_filters;
+
+    if ( @filters ) {
+        $ret .= $class->ml( 'widget.readinglist.filters.title' );
+        $ret .= "<ul>";
+        foreach my $filter ( @filters ) {
+            $ret .= "<li><a href='" . $remote->journal_base . "/read/" . LJ::eurl( $filter->{name} ) . "'>" . $filter->{name} . "</a></li>\n";
+        }
+        $ret .= "</ul>";
+    } else {
+        $ret .= $class->ml( 'widget.readinglist.filters.nofilters', { aopts => "href='$LJ::SITEROOT/manage/subscriptions/filters'" } );
+    }
 
     return $ret;
 }
--------------------------------------------------------------------------------
mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)

[staff profile] mark 2009-10-08 05:25 pm (UTC)(link)
+use DW::User::ContentFilters;

You don't need this.

+ $ret .= "<li><a href='" . $remote->journal_base . "/read/" . LJ::eurl( $filter->{name} ) . "'>" . $filter->{name} . "</a></li>\n";

It's an object, please use the accessor methods ($filter->name).
Edited 2009-10-08 17:26 (UTC)
mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)

[staff profile] mark 2009-10-08 05:34 pm (UTC)(link)
It's a real small change, you can make and commit it.
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2009-10-09 12:20 am (UTC)(link)
Oops. :)