[Jifty-commit] r6108 - wifty/trunk/lib/Wifty

Jifty commits jifty-commit at lists.jifty.org
Sat Dec 13 18:43:31 EST 2008


Author: ruz
Date: Sat Dec 13 18:43:31 2008
New Revision: 6108

Modified:
   wifty/trunk/lib/Wifty/Dispatcher.pm
   wifty/trunk/lib/Wifty/View.pm

Log:
* split recent into recent changes and recent additions

Modified: wifty/trunk/lib/Wifty/Dispatcher.pm
==============================================================================
--- wifty/trunk/lib/Wifty/Dispatcher.pm	(original)
+++ wifty/trunk/lib/Wifty/Dispatcher.pm	Sat Dec 13 18:43:31 2008
@@ -8,9 +8,10 @@
 
 before '*', run {
     my $top = Jifty->web->navigation;
-    $top->child( Home   => url => "/", label => _("Home") );
-    $top->child( Recent => url => "/recent", label => _("Recent Changes") );
-    $top->child( Search => url => "/search", label => _("Search") );
+    $top->child( Home   => url => "/",                 label => _("Home") );
+    $top->child( Recent => url => "/recent/changes",   label => _("Recent Changes") );
+    $top->child( New    => url => "/recent/additions", label => _("New") );
+    $top->child( Search => url => "/search",           label => _("Search") );
 };
 
 # Default page
@@ -88,26 +89,31 @@
     set pages => $collection;
 };
 
-# Show recent edits
+# Show recent
+
+# backwards compat
+on '/recent', run {
+    redirect('/recent/changes');
+};
+
 under 'feeds/atom/recent', run {
     set pages => recent_changes();
 };
-on 'recent*', run {
-    set pages => recent_changes();
+on qr{^/recent/(.+)}, run {
+    my $type = $1;
+    if ( $type eq 'changes' ) {
+        set title => _('Updated this week');
+        set pages => Wifty::Model::PageCollection->recently_updated;
+    } elsif ( $type eq 'additions' ) {
+        set title => _('Created this week');
+        set pages => Wifty::Model::PageCollection->recently_created;
+    } else {
+        redirect('/recent/changes');
+    }
+    set( type => $type );
+    show('/recent');
 };
 
-sub recent_changes {
-    my $then = DateTime->from_epoch( epoch => ( time - ( 86400 * 7 ) ) );
-    my $pages = Wifty::Model::PageCollection->new();
-    $pages->limit(
-        column   => 'updated',
-        operator => '>',
-        value    => $then->ymd,
-    );
-    $pages->order_by( column => 'updated', order => 'desc' );
-    return $pages;
-}
-
 sub setup_page_nav {
     my ($prefix, $page, $rev) = @_;
 

Modified: wifty/trunk/lib/Wifty/View.pm
==============================================================================
--- wifty/trunk/lib/Wifty/View.pm	(original)
+++ wifty/trunk/lib/Wifty/View.pm	Sat Dec 13 18:43:31 2008
@@ -99,25 +99,14 @@
 };
 
 template recent => page {
-    my ($pages) = get(qw(pages));
-    { title is _('Updated this week') }
-    show( 'page_list', pages => $pages, id => 'recentupdates' );
-
-    add rel "alternate",
-        type => "application/atom+xml",
-        title => _('Updated this week') .' '. _('(full content)'),
-        href => '/feeds/atom/recent',
-    ;
-    add rel "alternate",
-        type => "application/atom+xml",
-        title => _('Updated this week') .' '. _('(headlines)'),
-        href => '/feeds/atom/recent/headlines',
-    ;
-    add rel "alternate",
-        type => "application/atom+xml",
-        title => _('Updated this week') .' '. _('(diffs)'),
-        href => '/feeds/atom/recent/diffs',
-    ;
+    my ($pages, $title, $type) = get(qw(pages title type));
+
+    title is $title;
+
+    set( id => 'recent-'. $type ); show( 'page_list' );
+
+    set( path => "recent/$type" );
+    show('/feeds/pages_links');
 };
 
 template pages => page {


More information about the Jifty-commit mailing list