[Jifty-commit] r468 - wifty/trunk/lib/Wifty
wifty/trunk/web/templates wifty/trunk/web/templates/_elements
wifty/trunk/web/templates/create wifty/trunk/web/templates/edit
wifty/trunk/web/templates/history
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Jan 5 17:48:01 EST 2006
Author: jesse
Date: Thu Jan 5 17:48:00 2006
New Revision: 468
Removed:
wifty/trunk/web/templates/index.html
Modified:
/ (props changed)
wifty/trunk/lib/Wifty/Dispatcher.pm
wifty/trunk/web/templates/_elements/wrapper
wifty/trunk/web/templates/create/dhandler
wifty/trunk/web/templates/edit/dhandler
wifty/trunk/web/templates/history/dhandler
wifty/trunk/web/templates/login
wifty/trunk/web/templates/logout
wifty/trunk/web/templates/pages
wifty/trunk/web/templates/recent
wifty/trunk/web/templates/signup
wifty/trunk/web/templates/view/dhandler
Log:
r22141 at truegrounds: jesse | 2006-01-05 23:46:21 +0100
* Wifty now uses the dispatcher
Modified: wifty/trunk/lib/Wifty/Dispatcher.pm
==============================================================================
--- wifty/trunk/lib/Wifty/Dispatcher.pm (original)
+++ wifty/trunk/lib/Wifty/Dispatcher.pm Thu Jan 5 17:48:00 2006
@@ -1,8 +1,92 @@
package Wifty::Dispatcher;
use Jifty::Dispatcher -base;
-under 'create/*', run {
- set page => $1;
- set action => Jifty->web->new_action( class => 'CreatePage' );
+on '/', run {
+ redirect( '/view/HomePage');
};
+
+under '/create/*', run {
+ set page => $1;
+ set action => Jifty->web->new_action( class => 'CreatePage' );
+};
+
+
+under ['view/*', 'edit/*'], run {
+ my ( $name, $rev );
+ warn "hey";
+ if ( $1 =~ qr{^(.*?)/?(\d*?)$} ) {
+ $name = $1;
+ $rev = $2;
+ }
+ my $page = Wifty::Model::Page->new();
+ $page->load_by_cols( name => $name );
+ Jifty->web->redirect( '/create/' . $name ) unless ( $page->id );
+ my $revision = Wifty::Model::Revision->new();
+ $revision->load_by_cols( page => $page->id, id => $rev ) if ($rev);
+ set page => $page;
+ set revision => $revision;
+ set viewer => Jifty->web->new_action( class => 'UpdatePage', record => $page );
+};
+
+under 'history/*', run {
+ my $name = $1;
+ my $page = Wifty::Model::Page->new();
+ $page->load_by_cols( name => $name );
+ redirect( '/create/' . $name ) unless ( $page->id );
+
+ my $revisions = $page->revisions;
+ $revisions->order_by( column => 'id', order => 'desc');
+
+ set page => $page;
+ set revisions => $revisions;
+
+};
+
+
+on 'pages', run {
+ my $pages = Wifty::Model::PageCollection->new();
+ $pages->unlimit();
+ set pages => $pages;
+};
+
+on 'recent', run {
+ 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' );
+ set pages => $pages;
+};
+
+on 'signup', run {
+ redirect('/') if ( Jifty->web->current_user->id );
+ set 'action' =>
+ Jifty->web->new_action( class => 'Signup', moniker => 'signupbox' );
+
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+
+};
+
+on 'login', run {
+ set 'action' =>
+ Jifty->web->new_action( class => 'Login', moniker => 'loginbox' );
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+
+};
+
+on 'logout', run {
+ Jifty->web->request->add_action(
+ moniker => 'logout',
+ class => 'Wifty::Action::Logout'
+ );
+};
+
+
1;
Modified: wifty/trunk/web/templates/_elements/wrapper
==============================================================================
--- wifty/trunk/web/templates/_elements/wrapper (original)
+++ wifty/trunk/web/templates/_elements/wrapper Thu Jan 5 17:48:00 2006
@@ -27,5 +27,3 @@
<%args>
$title => ""
</%args>
-<%init>
-</%init>
Modified: wifty/trunk/web/templates/create/dhandler
==============================================================================
--- wifty/trunk/web/templates/create/dhandler (original)
+++ wifty/trunk/web/templates/create/dhandler Thu Jan 5 17:48:00 2006
@@ -8,6 +8,6 @@
<& /_elements/markup &>
</&>
<%args>
-$action
-$page
+$action => undef
+$page => undef
</%args>
Modified: wifty/trunk/web/templates/edit/dhandler
==============================================================================
--- wifty/trunk/web/templates/edit/dhandler (original)
+++ wifty/trunk/web/templates/edit/dhandler Thu Jan 5 17:48:00 2006
@@ -1,22 +1,9 @@
-<%init>
-my $arg = $m->dhandler_arg();
-my ($name,$rev);
-if ($arg =~ qr{^(.*?)/?(\d*?)$}) {
- $name = $1;
- $rev = $2;
-}
-my $page = Wifty::Model::Page->new();
-$page->load_by_cols( name => $name );
-
-my $revision = Wifty::Model::Revision->new();
-if ($rev) {
-$revision->load_by_cols( page => $page->id, id=> $rev);
-}
-
-my $viewer = Jifty->web->new_action( class => 'UpdatePage', record => $page );
-$m->comp('/_elements/page_nav', page => $page->name, rev => $rev);
-
-</%init>
+<%args>
+$page
+$revision
+$viewer
+</%args>
+<&/_elements/page_nav, page => $page->name, rev => $revision->id &>
<&|/_elements/wrapper, title => 'Edit: '.$page->name . ($revision->id ? " as of ".$revision->created : '') &>
<% Jifty->web->form->start %>
<% Jifty->web->form->next_page( url => '/view/'.$page->name) %>
Modified: wifty/trunk/web/templates/history/dhandler
==============================================================================
--- wifty/trunk/web/templates/history/dhandler (original)
+++ wifty/trunk/web/templates/history/dhandler Thu Jan 5 17:48:00 2006
@@ -1,13 +1,8 @@
-<%init>
-my $name = $m->dhandler_arg();
-my $page = Wifty::Model::Page->new();
-$page->load_by_cols( name => $name );
-Jifty->web->redirect( '/create/' . $name ) unless ( $page->id );
-
-my $revisions = $page->revisions;
-$revisions->order_by( column => 'id', order => 'desc');
-$m->comp('/_elements/page_nav', page => $page->name);
-</%init>
+<%args>
+$page
+$revisions
+</%args>
+<& /_elements/page_nav, page => $page->name &>
<&|/_elements/wrapper, title => $revisions->count ." revisions of " .$page->name &>
<ul>
% while (my $rev = $revisions->next) {
Modified: wifty/trunk/web/templates/login
==============================================================================
--- wifty/trunk/web/templates/login (original)
+++ wifty/trunk/web/templates/login Thu Jan 5 17:48:00 2006
@@ -1,12 +1,5 @@
-<%init>
-my $action = Jifty->web->new_action(class => 'Login', moniker => 'loginbox' );
-
-my $next = Jifty->web->request->continuation || Jifty::Continuation->new(request => Jifty::Request->new(path => "/"));
-</%init>
<&|/_elements/wrapper, title => 'Login' &>
-
-
% if (not Jifty->web->current_user->id) {
<h2>Login</h2>
<% Jifty->web->form->start(call => $next, name => "loginbox") %>
@@ -18,8 +11,6 @@
<% Jifty->web->tangent( label => q{Don't have an account?}, url => '/signup' )%>
% }
% else {
-
-You're alrady logged in.
-
-%}
+You're already logged in.
+% }
</&>
Modified: wifty/trunk/web/templates/logout
==============================================================================
--- wifty/trunk/web/templates/logout (original)
+++ wifty/trunk/web/templates/logout Thu Jan 5 17:48:00 2006
@@ -1,12 +1,3 @@
<&| /_elements/wrapper, title => "Logged out" &>
<p>Ok, you're now logged out. Have a good day.</p>
</&>
-
-
-<%method setup_actions>
-<%perl>
- Jifty->web->request->add_action( moniker => 'logout',
- class => 'Wifty::Action::Logout'
- );
-</%perl>
-</%method>
Modified: wifty/trunk/web/templates/pages
==============================================================================
--- wifty/trunk/web/templates/pages (original)
+++ wifty/trunk/web/templates/pages Thu Jan 5 17:48:00 2006
@@ -1,7 +1,6 @@
-<%init>
-my $pages = Wifty::Model::PageCollection->new();
-$pages->unlimit();
-</%init>
+<%args>
+$pages
+</%args>
<&|/_elements/wrapper, title => 'These are the pages on your wiki!' &>
<ul id="pagelist">
% while (my $page = $pages->next) {
Modified: wifty/trunk/web/templates/recent
==============================================================================
--- wifty/trunk/web/templates/recent (original)
+++ wifty/trunk/web/templates/recent Thu Jan 5 17:48:00 2006
@@ -1,9 +1,6 @@
-<%init>
-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' );
-</%init>
+<%args>
+$pages
+</%args>
<&|/_elements/wrapper, title => 'Updated this week' &>
<dl id="recentudates">
% while (my $page = $pages->next) {
Modified: wifty/trunk/web/templates/signup
==============================================================================
--- wifty/trunk/web/templates/signup (original)
+++ wifty/trunk/web/templates/signup Thu Jan 5 17:48:00 2006
@@ -1,12 +1,7 @@
-<%init>
-if (Jifty->web->current_user->id) {
- $m->comp('/_elements/logged_in_already');
- return();
-}
-my $action = Jifty->web->new_action(class => 'Signup', moniker => 'signupbox' );
-
-my $next = Jifty->web->request->continuation || Jifty::Continuation->new(request => Jifty::Request->new(path => "/"));
-</%init>
+<%args>
+$action
+$next
+</%args>
<&|/_elements/wrapper, title => 'Signup' &>
<h2>Signup</h2>
<% Jifty->web->form->start(call => $next, name => "signupbox") %>
Modified: wifty/trunk/web/templates/view/dhandler
==============================================================================
--- wifty/trunk/web/templates/view/dhandler (original)
+++ wifty/trunk/web/templates/view/dhandler Thu Jan 5 17:48:00 2006
@@ -1,25 +1,8 @@
-<%init>
-use Wifty::Model::Page;
-my $arg = $m->dhandler_arg();
-my ($name,$rev);
-if ($arg =~ qr{^(.*?)/?(\d*?)$}) {
- $name = $1;
- $rev = $2;
-}
-my $page = Wifty::Model::Page->new();
-$page->load_by_cols( name => $name );
-
-my $revision = Wifty::Model::Revision->new();
-if ($rev) {
- $revision->load_by_cols( page => $page->id, id => $rev);
-}
-
-unless ( $page->id ) {
- Jifty->web->redirect( '/create/' . $name );
-}
-
-$m->comp('/_elements/page_nav', page => $page->name, rev => $rev);
-</%init>
+<%args>
+$page
+$revision
+</%args>
+<& /_elements/page_nav, page => $page->name, rev => $revision->id &>
<&|/_elements/wrapper, title => $page->name . ($revision->id ? " as of ".$revision->created : '') &>
% if ($revision->id) {
<% $page->wiki_content($revision->content) |n%>
More information about the Jifty-commit
mailing list