User: sits    
  Date: 08/08/13 04:30:47

  Modified:    lib/Codestriker/Http UrlBuilder.pm Method.pm
               bin      codestriker.pl.base
  Added:       lib/Codestriker/Http Dispatcher.pm
  Log:
  Next step in the URL refactoring.  Still a long way to go..
  
  
  
  Index: UrlBuilder.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Http/UrlBuilder.pm,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- UrlBuilder.pm     11 Aug 2008 22:32:38 -0000      1.37
  +++ UrlBuilder.pm     13 Aug 2008 11:30:47 -0000      1.38
  @@ -31,9 +31,6 @@
   use strict;
   use CGI;
   
  -use Codestriker::Http::Method;
  -use Codestriker::Http::Method::ListTopics;
  -
   # Constructor for this class.
   sub new {
       my ($type, $query, $cgi_style) = @_;
  @@ -70,7 +67,7 @@
       
       # Initialise all of the methods.
       $self->{list_topics_method} =
  -        Codestriker::Http::Method::ListTopics->new($self->{query}, 
$self->{url_prefix}, $self->{cgi_style});
  +        Codestriker::Http::Method::ListTopicsMethod->new($self->{query}, 
$self->{url_prefix}, $self->{cgi_style});
   
       return bless $self, $type;
   }
  @@ -78,7 +75,7 @@
   # Create the URL for viewing a topic.
   sub view_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ViewTopicTextMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ViewTopicTextMethod->new($self->{query})->url(%args);
   }
   
   # Create the URL for downloading the topic text.
  @@ -100,31 +97,31 @@
   # Create the URL for creating a topic.
   sub create_topic_url {
       my ($self, $obsoletes) = @_;
  -    return 
Codestriker::Http::Method::CreateTopicMethod->new($query)->url($obsoletes);
  +    return 
Codestriker::Http::Method::CreateTopicMethod->new($self->{query})->url($obsoletes);
   }        
   
   # Create the URL for editing a topic.
   sub edit_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::AddCommentMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::AddCommentMethod->new($self->{query})->url(%args);
   }
   
   # Create the URL for viewing a new file.
   sub view_file_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ViewTopicFileMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ViewTopicFileMethod->new($self->{query})->url(%args);
   }
   
   # Create the URL for the search page.
   sub search_url {
       my ($self) = @_;
  -    return 
Codestriker::Http::Method::SearchTopicsMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::SearchTopicsMethod->new($self->{query})->url();
   }
   
   # Create the URL for the documentation page.
   sub doc_url {
       my ($self) = @_;
  -    return 
Codestriker::Http::Method::StaticResourcesMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::StaticResourcesMethod->new($self->{query})->url();
   }
   
   # Create the URL for listing the topics (and topic search). See
  @@ -148,54 +145,54 @@
   # Create the URL for listing the topics.
   sub _list_topics_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ListTopicsMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ListTopicsMethod->new($self->{query})->url(%args);
   }
   
   
   # Construct a URL for editing a specific project.
   sub edit_project_url {
       my ($self, $projectid) = @_;
  -    return 
Codestriker::Http::Method::EditProjectMethod->new($query)->url($projectid);
  +    return 
Codestriker::Http::Method::EditProjectMethod->new($self->{query})->url($projectid);
   }
   
   # Construct a URL for listing all projects.
   sub list_projects_url {
       my ($self) = @_;
  -    return Codestriker::Http::Method::ListProjectsMethod->new($query)->url();
  +    return 
Codestriker::Http::Method::ListProjectsMethod->new($self->{query})->url();
   }
   
   # Construct a URL for creating a project.
   sub create_project_url {
       my ($self) = @_;
  -    return 
Codestriker::Http::Method::CreateProjectMethod->new($query)->url();
  +    return 
Codestriker::Http::Method::CreateProjectMethod->new($self->{query})->url();
   }
   
   # Create the URL for viewing comments.
   sub view_comments_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ViewTopicCommentsMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ViewTopicCommentsMethod->new($self->{query})->url(%args);
   }
   
   # Create the URL for viewing the topic properties.
   sub view_topic_properties_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ViewTopicPropertiesMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ViewTopicPropertiesMethod->new($self->{query})->url(%args);
   }
   
   # Create the URL for viewing the topic metrics.
   sub view_topicinfo_url {
       my ($self, %args) = @_;
  -    return 
Codestriker::Http::Method::ViewTopicMetricsMethod->new($query)->url(%args);
  +    return 
Codestriker::Http::Method::ViewTopicMetricsMethod->new($self->{query})->url(%args);
   }
   
   sub metric_report_url {
       my ($self) = @_;
  -    return Codestriker::Http::Method::ViewMetricsMethod->new($query)->url();
  +    return 
Codestriker::Http::Method::ViewMetricsMethod->new($self->{query})->url();
   }
   
   sub metric_report_download_raw_data {
       my ($self) = @_;
  -    return 
Codestriker::Http::Method::DownloadMetricsMethod->new($query)->url();
  +    return 
Codestriker::Http::Method::DownloadMetricsMethod->new($self->{query})->url();
   }
   
   1;
  
  
  
  
  
  Index: Method.pm
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Method.pm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Method.pm 11 Aug 2008 22:32:38 -0000      1.2
  +++ Method.pm 13 Aug 2008 11:30:47 -0000      1.3
  @@ -10,6 +10,7 @@
   
   use strict;
   use CGI;
  +use CGI::Carp qw(fatalsToBrowser);
   
   # The optional $cgi_style parameter indicates whether the old-style
   # CGI URLs are to be generated.  Default is for old-style URLs.
  @@ -42,7 +43,7 @@
   # If this query type is recognised, extract the parameters and store them 
into
   # $http_input and return true, otherwise return false.
   sub extract_parameters {
  -     my ($self, $query, $http_input) = @_;
  +     my ($self, $http_input) = @_;
        
        return 0;
   }
  
  
  
  
  
  Index: Dispatcher.pm
  ===================================================================
  RCS file: Dispatcher.pm
  diff -N Dispatcher.pm
  --- /dev/null 1 Jan 1970 00:00:00 -0000
  +++ Dispatcher.pm     13 Aug 2008 11:30:47 -0000      1.1
  @@ -0,0 +1,86 @@
  
+###############################################################################
  +# Codestriker: Copyright (c) 2001, 2002 David Sitsky.  All rights reserved.
  +# [EMAIL PROTECTED]
  +#
  +# This program is free software; you can redistribute it and modify it under
  +# the terms of the GPL.
  +
  +# Module for dispatching a URL to the appropriate Action class.
  +
  +package Codestriker::Http::Dispatcher;
  +
  +use strict;
  +use CGI;
  +
  +use Codestriker::Http::Method;
  +use Codestriker::Http::Method::ListTopicsMethod; 
  +use Codestriker::Http::Method::CreateTopicMethod; 
  +use Codestriker::Http::Method::ViewTopicTextMethod;
  +use Codestriker::Http::Method::ViewTopicCommentsMethod;
  +use Codestriker::Http::Method::ViewTopicFileMethod;
  +use Codestriker::Http::Method::ViewTopicMetricsMethod;
  +use Codestriker::Http::Method::ViewTopicPropertiesMethod;
  +use Codestriker::Http::Method::AddCommentMethod;
  +use Codestriker::Http::Method::AddTopicMethod;
  +use Codestriker::Http::Method::CreateProjectMethod;
  +use Codestriker::Http::Method::DownloadMetricsMethod;
  +use Codestriker::Http::Method::EditProjectMethod;
  +use Codestriker::Http::Method::ListProjectsMethod;
  +use Codestriker::Http::Method::SearchTopicsMethod;
  +use Codestriker::Http::Method::StaticResourcesMethod;
  +use Codestriker::Http::Method::ViewMetricsMethod;
  +
  +# Initialise all of the methods that are known to the system.
  +# TODO: add configuration to the parameter.
  +sub new {
  +     my ($type, $query) = @_;
  +     
  +    my $self = {};
  +    $self->{list_topics_method} =
  +        Codestriker::Http::Method::ListTopicsMethod->new($query); 
  +    $self->{create_topic_method} =
  +        Codestriker::Http::Method::CreateTopicMethod->new($query); 
  +
  +     my @methods = ();
  +     push @methods, 
Codestriker::Http::Method::ViewTopicTextMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ViewTopicCommentsMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ViewTopicFileMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ViewTopicMetricsMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ViewTopicPropertiesMethod->new($query);
  +     push @methods, $self->{list_topics_method};
  +     push @methods, Codestriker::Http::Method::AddCommentMethod->new($query);
  +     push @methods, Codestriker::Http::Method::AddTopicMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::CreateProjectMethod->new($query);
  +     push @methods, $self->{create_topic_method};
  +     push @methods, 
Codestriker::Http::Method::DownloadMetricsMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::EditProjectMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ListProjectsMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::SearchTopicsMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::StaticResourcesMethod->new($query);
  +     push @methods, 
Codestriker::Http::Method::ViewMetricsMethod->new($query);
  +
  +     $self->{methods} = [EMAIL PROTECTED];
  +    return bless $self, $type;
  +}
  +
  +# Determine which method can satisfy the input request and dispatch it
  +# to the appropriate action.
  +sub dispatch {
  +     my ($self, $http_input, $http_output) = @_;
  +     
  +     foreach my $method ( @{$self->{methods}} ) {
  +             if ($method->extract_parameters($http_input)) {
  +                     $method->execute($http_input, $http_output);
  +                     return;
  +             }
  +     }
  +     
  +     # If we have reached here, execute the default method.
  +     if ($Codestriker::allow_searchlist) {
  +             $self->{list_topics_method}->execute($http_input, $http_output);
  +    } else {
  +             $self->{create_topic_method}->execute($http_input, 
$http_output);
  +     }
  +}
  +
  +1;
  
  
  
  
  
  Index: codestriker.pl.base
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/bin/codestriker.pl.base,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- codestriker.pl.base       10 Jul 2008 10:43:55 -0000      1.26
  +++ codestriker.pl.base       13 Aug 2008 11:30:47 -0000      1.27
  @@ -34,6 +34,7 @@
   use Codestriker;
   use Codestriker::Http::Input;
   use Codestriker::Http::Response;
  +use Codestriker::Http::Dispatcher;
   use Codestriker::Action::CreateTopic;
   use Codestriker::Action::EditComment;
   use Codestriker::Action::Search;
  @@ -88,7 +89,7 @@
       Codestriker->initialise([% codestriker_conf %]);
   
   [% IF has_rss %]
  -    # only generated if checksetup.pl found a good version of XML::RSS.
  +    # Only generated if install.pl found a good version of XML::RSS.
       $Codestriker::rss_enabled = 1;
   [% ELSE %]
       # valid XML::RSS not found
  @@ -121,97 +122,21 @@
       # Load the CGI object, and prepare the HTTP response.
       my $query = new CGI;
       my $http_response = Codestriker::Http::Response->new($query);
  +    
  +    # TODO: need to put in mapping here from new URL scheme to old
  +    # scheme.
   
       # Process the HTTP input to ensure it is consistent.
       my $http_input = Codestriker::Http::Input->new($query, $http_response);
       $http_input->process();
  +    
  +    my $dispatcher = Codestriker::Http::Dispatcher->new($query);
  +    $dispatcher->dispatch($http_input, $http_response);
   
  -    # Delegate the request to the appropriate Action module.
  -    my $action = $http_input->get("action");
  -    if ($action eq "create") {
  -     Codestriker::Action::CreateTopic->process($http_input, $http_response);
  -    } elsif ($action eq "submit_new_topic") {
  -     Codestriker::Action::SubmitNewTopic->process($http_input,
  -                                                  $http_response);
  -    } elsif ($action eq "view") {
  -     Codestriker::Action::ViewTopic->process($http_input, $http_response);
  -    } elsif ($action eq "view_topic_properties") {
  -     Codestriker::Action::ViewTopicProperties->process($http_input,
  -                                                       $http_response);
  -    } elsif ($action eq "viewinfo") {
  -     Codestriker::Action::ViewTopicInfo->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "edit") {
  -     Codestriker::Action::EditComment->process($http_input, $http_response);
  -    } elsif ($action eq "submit_comment") {
  -     Codestriker::Action::SubmitNewComment->process($http_input,
  -                                                    $http_response);
  -    } elsif ($action eq "view_file") {
  -     Codestriker::Action::ViewTopicFile->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "search") {
  -     Codestriker::Action::Search->process($http_input, $http_response);
  -    } elsif ($action eq "submit_search") {
  -     Codestriker::Action::SubmitSearch->process($http_input,
  -                                                $http_response);
  -    } elsif ($action eq "list_topics") {
  -     Codestriker::Action::ListTopics->process($http_input, $http_response);
  -    } elsif ($action eq "download") {
  -     Codestriker::Action::DownloadTopic->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "edit_topic_properties") {
  -        Codestriker::Action::SubmitEditTopicProperties->process($http_input,
  -                                                             $http_response);
  -    } elsif ($action eq "edit_topic_metrics") {
  -        Codestriker::Action::SubmitEditTopicMetrics->process($http_input,
  -                                                          $http_response);
  -    } elsif ($action eq "change_topics_state") {
  -        Codestriker::Action::SubmitEditTopicsState->process($http_input,
  -                                                         $http_response);
  -    } elsif ($action eq "list_comments") {
  -     Codestriker::Action::ViewTopicComments->process($http_input,
  -                                                $http_response);
  -    } elsif ($action eq "change_comments_state") {
  -     Codestriker::Action::SubmitEditCommentsState->process($http_input,
  -                                                  $http_response);
  -    } elsif ($action eq "list_projects") {
  -     Codestriker::Action::ListProjects->process($http_input,
  -                                                $http_response);
  -    } elsif ($action eq "edit_project") {
  -     Codestriker::Action::EditProject->process($http_input,
  -                                               $http_response);
  -    } elsif ($action eq "create_project") {
  -     Codestriker::Action::CreateProject->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "submit_project") {
  -     Codestriker::Action::SubmitNewProject->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "submit_editproject") {
  -     Codestriker::Action::SubmitEditProject->process($http_input,
  -                                                     $http_response);
  -    } elsif ($action eq "metrics_report") {
  -     Codestriker::Action::MetricsReport->process($http_input,
  -                                                 $http_response);
  -    } elsif ($action eq "metrics_download") {
  -     Codestriker::Action::MetricsReport->process_download($http_input,
  -                                                          $http_response);
  -[% IF has_rss %]
  +#[% IF has_rss %]
       # only generated if checksetup.pl found a good version of XML::RSS.
  -    } elsif ($action eq "list_topics_rss") {
  -     Codestriker::Action::ListTopicsRSS->process($http_input,
  -                                                 $http_response);
  -[% END %]
  -
  -    } else {
  -     # Default action is to list topics that are in state open if the
  -     # list functionality is enabled, otherwise go to the create topic
  -     # screen.
  -     if ($Codestriker::allow_searchlist) {
  -         Codestriker::Action::ListTopics->process($http_input,
  -                                                  $http_response);
  -        } else {
  -         Codestriker::Action::CreateTopic->process($http_input,
  -                                                   $http_response);
  -     }
  -    }
  +#    } elsif ($action eq "list_topics_rss") {
  +#    Codestriker::Action::ListTopicsRSS->process($http_input,
  +#                                                $http_response);
  +#[% END %]
   }
  
  
  

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to