[Yapcom checkin] rev 34 - lib/YAPC

[prev] [thread] [next] [lurker] [Date index for 2003/11/25]

From: svn
Subject: [Yapcom checkin] rev 34 - lib/YAPC
Date: 00:51 on 25 Nov 2003
Author: gabor
Date: 2003-11-25 00:51:28 +0200 (Tue, 25 Nov 2003)
New Revision: 34

Modified:
   lib/YAPC/Organizer.pm
Log:
run_mode listings shortened

Modified: lib/YAPC/Organizer.pm
===================================================================
--- lib/YAPC/Organizer.pm	2003-11-24 22:33:34 UTC (rev 33)
+++ lib/YAPC/Organizer.pm	2003-11-24 22:51:28 UTC (rev 34)
@@ -22,32 +22,15 @@
 my @admin_pages = qw(admin admin_list_people admin_list_proposals); # list of pages accessible to administrators only
 my @other_pages = qw(list_people login);
 
+my @run_modes = map {$_, $_} @user_pages, @admin_pages, @other_pages;
 
 sub setup {
     my $self = shift;
     $self->start_mode('default');
     $self->mode_param('run');
     $self->run_modes(
-# default
+               @run_modes,
               'default'               => 'default',
-
-# user_pages
-              'proposal'              => 'proposal',
-              #personal_info
-              'change_password'       => 'change_password',
-              'user_account'          => 'user_account',
-              'logout'                => 'logout',
-
-# admin_pages
-              admin                   => 'admin',
-              admin_list_people       => 'admin_list_people',
-              admin_list_proposals    => 'admin_list_proposals',
-
-# other pages
-              'list_people'           => 'list_people',
-              'login'                 => 'login',
-
-# ?? maybe should be other ?
               'registration'          => 'registration',
               'validation'            => 'validation',
               'get_validation_code'   => 'get_validation_code',
@@ -61,11 +44,7 @@
    my $self = shift;
    my $run_mode = shift;
 
-   # REQUEST_URI looks like this:  /content.html
-   my $page = $ENV{REQUEST_URI} || '';
-   $page =~ s@.*/@@;
-   $page =~ s/\.html(\?.*)?$//;
-   $page ||= 'index';
+   my ($page, $filename) = get_page();
 
    if (grep {$_ eq $page} @other_pages) { return $self->prerun_mode($page) }
    
@@ -89,7 +68,6 @@
        return;
    }       
 
-   my $filename = "$templates_dir/$page.tmpl";
 
    if (not -e $filename) {
        #warn "YAPC script called for not existing file. Original: '$ENV{REQUEST_URI}' cut down: '$filename'\n";
@@ -100,9 +78,13 @@
 sub default {
     my $self = shift; 
     my $q = $self->query;
-    #warn "default\n";
 
+    my $t = $self->_server_page(get_page());
+    return $t->output;
+}
 
+sub get_page {
+
     # REQUEST_URI looks like this:  /content.html
     my $page = $ENV{REQUEST_URI} || '';
     $page =~ s@.*/@@;
@@ -111,8 +93,7 @@
 
     my $filename = "$templates_dir/$page.tmpl";
 
-    my $t = $self->_server_page($page, $filename);
-    return $t->output;
+    return ($page, $filename);
 }
 
 # maybe this should be replaced with a generic show page call

Generated at 01:06 on 25 Nov 2003 by mariachi 0.51