[Codestriker-commits] CVS update: codestriker/template/en/default listtopics.html.tmpl
Brought to you by:
sits
From: <si...@us...> - 2008-09-06 03:31:09
|
User: sits Date: 08/09/05 20:31:08 Modified: . codestriker.conf bin codestriker.pl.base lib/Codestriker/Action ListTopics.pm lib/Codestriker/Http UrlBuilder.pm lib/Codestriker/Http/Method UpdateTopicStateMethod.pm t/Http/Method update-topic-states.t template/en/default listtopics.html.tmpl Log: Got the update multiple topic states action working again. Index: codestriker.conf =================================================================== RCS file: /cvsroot/codestriker/codestriker/codestriker.conf,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- codestriker.conf 6 Sep 2008 00:31:51 -0000 1.103 +++ codestriker.conf 6 Sep 2008 03:31:05 -0000 1.104 @@ -102,7 +102,7 @@ # Indicate what style URLs to support. The default is CGI-style URLs. Set # this value to 0 for "nicer" URLs. -#$cgi_style = 0; +#$cgi_style = 1; # Valid repositories which may be selected at the create topic screen. # The order shown here is the order presented in the option list. Most Index: codestriker.pl.base =================================================================== RCS file: /cvsroot/codestriker/codestriker/bin/codestriker.pl.base,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- codestriker.pl.base 6 Sep 2008 00:31:50 -0000 1.29 +++ codestriker.pl.base 6 Sep 2008 03:31:06 -0000 1.30 @@ -1,141 +1,140 @@ - [% hash_ex_line %] +[% hash_ex_line %] - [% scary_warning %] +[% scary_warning %] - ############################################################################### - # Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved. - # si...@us... - # - # This program is free software; you can redistribute it and modify it under - # the terms of the GPL. - - # This is the top level package which receives all HTTP requests, and - # delegates it to the appropriate Action module. - - require 5.008_0; - - # Set this to the location of the Codestriker libraries on your system. - # Ideally, this should be done in the apache configs, but trying to do this - # in an easy way for Apache1/Apache2 with/without mod_perl with/without taint - # checking turned out to be a major headache. For mod_perl, setting this - # ensures the first time Codestriker is loaded, it can be compiled properly, - # even if @INC is blatted later. Also note all the use declarations below - # effectively "pre-load" all of the Codestriker modules in the system, as the - # modules below load all of their supporting modules. That is why the - # template plugins are "pre-loaded" here. - [% scmbug_lib %] - [% codestriker_lib %] - - use strict; - - use CGI qw/:standard :html3/; - use CGI::Carp 'fatalsToBrowser'; - - 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; - use Codestriker::Action::ListTopics; - use Codestriker::Action::DownloadTopic; - use Codestriker::Action::ListProjects; - use Codestriker::Action::EditProject; - use Codestriker::Action::CreateProject; - use Codestriker::Action::MetricsReport; - use Codestriker::Action::SubmitEditTopicProperties; - use Codestriker::Action::SubmitEditTopicMetrics; - use Codestriker::Action::SubmitEditTopicsState; - use Codestriker::Action::SubmitEditCommentsState; - use Codestriker::Action::SubmitEditProject; - use Codestriker::Action::SubmitNewProject; - use Codestriker::Action::SubmitNewTopic; - use Codestriker::Action::SubmitNewComment; - use Codestriker::Action::SubmitSearch; - use Codestriker::Action::ViewTopicFile; - use Codestriker::Action::ViewTopicInfo; - use Codestriker::Action::ViewTopic; - use Codestriker::Action::ViewTopicProperties; - use Codestriker::Action::ViewTopicComments; - [% IF has_rss %]use Codestriker::Action::ListTopicsRSS; [% END %] - - use Codestriker::Template::Plugin::AutomagicLinks; - use Codestriker::Template::Plugin::JavascriptEscape; - use Codestriker::Template::Plugin::StringObfuscator; - use Codestriker::Template::Plugin::FormatWhitespace; - - # Set the temp file location, if one has been specified. - if (defined $Codestriker::tmpdir && $Codestriker::tmpdir ne '') { - $CGITempFile::TMPDIRECTORY = $Codestriker::tmpdir; - } - - # Set the PATH to something sane if we aren't running under windows. - # For a lot of annoying reasons, we can't run Codestriker in - # tainted mode under Win32. - if (Codestriker::is_windows()) { - $ENV{'PATH'} = ''; - } else { - $ENV{'PATH'} = '/bin:/usr/bin'; - } - - # Prototypes of subroutines used in this module. - sub main(); - - main; - - sub main() { - # Initialise Codestriker, load up the configuration file. - Codestriker->initialise([% codestriker_conf %]); - - [% IF has_rss %] - # Only generated if install.pl found a good version of XML::RSS. - $Codestriker::rss_enabled = 1; - [% ELSE %] - # valid XML::RSS not found - $Codestriker::rss_enabled = 0; - [% END %] - - # If allow_delete is defined, but topic state 'Delete' is not, add it - # in. This accounts for older configuration files. - if (defined $Codestriker::allow_delete && $Codestriker::allow_delete && - (! grep /^Deleted$/, @Codestriker::topic_states)) { - push @Codestriker::topic_states, 'Deleted'; - } - - # Check if the old $allow_comment_email configuration option has been - # specified in the config file, rather than the new $email_send_options - # setting. - if (defined $Codestriker::allow_comment_email && - ! defined $Codestriker::email_send_options) { - $Codestriker::email_send_options = - { - comments_sent_to_topic_author => $Codestriker::allow_comment_email, - comments_sent_to_commenter => $Codestriker::allow_comment_email, - topic_state_change_sent_to_reviewers => 0 - }; - } - - # Limit the size of the posts that can be done. - $CGI::POST_MAX=$Codestriker::DIFF_SIZE_LIMIT; - - # 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); - - my $dispatcher = Codestriker::Http::Dispatcher->new($query); - $dispatcher->dispatch($http_input, $http_response); - - #[% 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 %] - } +############################################################################### +# Codestriker: Copyright (c) 2001, 2002 David Sitsky. All rights reserved. +# si...@us... +# +# This program is free software; you can redistribute it and modify it under +# the terms of the GPL. + +# This is the top level package which receives all HTTP requests, and +# delegates it to the appropriate Action module. + +require 5.008_0; + +# Set this to the location of the Codestriker libraries on your system. +# Ideally, this should be done in the apache configs, but trying to do this +# in an easy way for Apache1/Apache2 with/without mod_perl with/without taint +# checking turned out to be a major headache. For mod_perl, setting this +# ensures the first time Codestriker is loaded, it can be compiled properly, +# even if @INC is blatted later. Also note all the use declarations below +# effectively "pre-load" all of the Codestriker modules in the system, as the +# modules below load all of their supporting modules. That is why the +# template plugins are "pre-loaded" here. +[% scmbug_lib %] +[% codestriker_lib %] + +use strict; + +use CGI qw/:standard :html3/; +use CGI::Carp 'fatalsToBrowser'; + +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; +use Codestriker::Action::ListTopics; +use Codestriker::Action::DownloadTopic; +use Codestriker::Action::ListProjects; +use Codestriker::Action::EditProject; +use Codestriker::Action::CreateProject; +use Codestriker::Action::MetricsReport; +use Codestriker::Action::SubmitEditTopicProperties; +use Codestriker::Action::SubmitEditTopicMetrics; +use Codestriker::Action::SubmitEditTopicsState; +use Codestriker::Action::SubmitEditCommentsState; +use Codestriker::Action::SubmitEditProject; +use Codestriker::Action::SubmitNewProject; +use Codestriker::Action::SubmitNewTopic; +use Codestriker::Action::SubmitNewComment; +use Codestriker::Action::SubmitSearch; +use Codestriker::Action::ViewTopicFile; +use Codestriker::Action::ViewTopicInfo; +use Codestriker::Action::ViewTopic; +use Codestriker::Action::ViewTopicProperties; +use Codestriker::Action::ViewTopicComments; +[% IF has_rss %]use Codestriker::Action::ListTopicsRSS; [% END %] + +use Codestriker::Template::Plugin::AutomagicLinks; +use Codestriker::Template::Plugin::JavascriptEscape; +use Codestriker::Template::Plugin::StringObfuscator; +use Codestriker::Template::Plugin::FormatWhitespace; + +# Set the temp file location, if one has been specified. +if (defined $Codestriker::tmpdir && $Codestriker::tmpdir ne '') { + $CGITempFile::TMPDIRECTORY = $Codestriker::tmpdir; +} + +# Set the PATH to something sane if we aren't running under windows. +# For a lot of annoying reasons, we can't run Codestriker in +# tainted mode under Win32. +if (Codestriker::is_windows()) { + $ENV{'PATH'} = ''; +} else { + $ENV{'PATH'} = '/bin:/usr/bin'; +} + +# Prototypes of subroutines used in this module. +sub main(); + +main; + +sub main() { + # Initialise Codestriker, load up the configuration file. + Codestriker->initialise([% codestriker_conf %]); + + [% IF has_rss %] + # Only generated if install.pl found a good version of XML::RSS. + $Codestriker::rss_enabled = 1; + [% ELSE %] + # valid XML::RSS not found + $Codestriker::rss_enabled = 0; + [% END %] + + # If allow_delete is defined, but topic state 'Delete' is not, add it + # in. This accounts for older configuration files. + if (defined $Codestriker::allow_delete && $Codestriker::allow_delete && + (! grep /^Deleted$/, @Codestriker::topic_states)) { + push @Codestriker::topic_states, 'Deleted'; + } + + # Check if the old $allow_comment_email configuration option has been + # specified in the config file, rather than the new $email_send_options + # setting. + if (defined $Codestriker::allow_comment_email && + ! defined $Codestriker::email_send_options) { + $Codestriker::email_send_options = + { + comments_sent_to_topic_author => $Codestriker::allow_comment_email, + comments_sent_to_commenter => $Codestriker::allow_comment_email, + topic_state_change_sent_to_reviewers => 0 + }; + } + + # Limit the size of the posts that can be done. + $CGI::POST_MAX=$Codestriker::DIFF_SIZE_LIMIT; + + # 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); + + my $dispatcher = Codestriker::Http::Dispatcher->new($query); + $dispatcher->dispatch($http_input, $http_response); + + # 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); + # +} Index: ListTopics.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ListTopics.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- ListTopics.pm 6 Sep 2008 00:31:45 -0000 1.38 +++ ListTopics.pm 6 Sep 2008 03:31:06 -0000 1.39 @@ -52,11 +52,12 @@ $sort_order) = get_topic_list_query_params($http_input); # Query the model for the specified data. - my @topics = Codestriker::Model::Topic->query($sauthor, $sreviewer, $scc, $sbugid, - $sstate, $sproject, $stext, - $stitle, $sdescription, - $scomments, $sbody, $sfilename, - $sort_order); + my @topics = + Codestriker::Model::Topic->query($sauthor, $sreviewer, $scc, $sbugid, + $sstate, $sproject, $stext, + $stitle, $sdescription, + $scomments, $sbody, $sfilename, + $sort_order); # Display the data, with each topic title linked to the view topic screen. # If only a single project id is being searched over, set that id in the @@ -236,6 +237,7 @@ $vars->{'list_projects_url'} = $url_builder->list_projects_url(); $vars->{'view_metrics_url'} = $url_builder->metric_report_url(); + $vars->{'action_url'} = $url_builder->update_topic_states_url(); my $template = Codestriker::Http::Template->new("listtopics"); $template->process($vars); Index: UrlBuilder.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/UrlBuilder.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- UrlBuilder.pm 6 Sep 2008 00:31:47 -0000 1.47 +++ UrlBuilder.pm 6 Sep 2008 03:31:07 -0000 1.48 @@ -34,6 +34,7 @@ use Codestriker::Http::Method::UpdateTopicPropertiesMethod; use Codestriker::Http::Method::UpdateTopicMetricsMethod; use Codestriker::Http::Method::UpdateCommentMetricsMethod; +use Codestriker::Http::Method::UpdateTopicStateMethod; # Constructor for this class. sub new { @@ -203,6 +204,12 @@ return Codestriker::Http::Method::UpdateTopicMetricsMethod->new($self->{query})->url(%args); } +# Create the URL for updating a number of topic states. +sub update_topic_states_url { + my ($self, %args) = @_; + return Codestriker::Http::Method::UpdateTopicStateMethod->new($self->{query})->url(%args); +} + # Create the URL for adding new comments. sub add_comment_url { my ($self, %args) = @_; Index: UpdateTopicStateMethod.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Method/UpdateTopicStateMethod.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- UpdateTopicStateMethod.pm 6 Sep 2008 00:31:45 -0000 1.3 +++ UpdateTopicStateMethod.pm 6 Sep 2008 03:31:07 -0000 1.4 @@ -22,8 +22,7 @@ if ($self->{cgi_style}) { return $self->{url_prefix} . "?action=change_topics_state"; } else { - confess "Parameter projectid missing" unless defined $args{projectid}; - return $self->{url_prefix} . "/project/$args{projectid}/topic/update"; + return $self->{url_prefix} . "/topics/update"; } } @@ -32,12 +31,12 @@ my $action = $http_input->{query}->param('action'); my $path_info = $http_input->{query}->path_info(); - if ($self->{cgi_style} && defined $action && $action eq "change_topics_state") { + if ($self->{cgi_style} && defined $action && + $action eq "change_topics_state") { $http_input->extract_cgi_parameters(); return 1; - } elsif ($path_info =~ m{^/project/\d+/topic/update}) { - $self->_extract_nice_parameters($http_input, - project => 'projectid'); + } elsif ($path_info =~ m{^/topics/update}) { + $self->_extract_nice_parameters($http_input); return 1; } else { return 0; Index: update-topic-states.t =================================================================== RCS file: /cvsroot/codestriker/codestriker/t/Http/Method/update-topic-states.t,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- update-topic-states.t 31 Aug 2008 12:30:05 -0000 1.2 +++ update-topic-states.t 6 Sep 2008 03:31:07 -0000 1.3 @@ -22,7 +22,7 @@ "Update topic state URL CGI syntax"); is($url_nice->url(projectid => 10), - $mock_query->url() . '/project/10/topic/update', + $mock_query->url() . '/topics/update', "Update topic state URL nice syntax"); # Check that the parameters extracted correctly. @@ -31,10 +31,9 @@ $mock_http_input->mock('extract_cgi_parameters', sub { return undef; }); $mock_query->mock('path_info', sub { - return '/project/10/topic/update'; + return '/topics/update'; }); $mock_query->mock('param', sub { return undef; }); $url_nice->extract_parameters($mock_http_input); -is ($mock_http_input->{projectid}, "10", "project nice URL parameter extraction"); - \ No newline at end of file + Index: listtopics.html.tmpl =================================================================== RCS file: /cvsroot/codestriker/codestriker/template/en/default/listtopics.html.tmpl,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- listtopics.html.tmpl 24 Jun 2008 03:26:50 -0000 1.44 +++ listtopics.html.tmpl 6 Sep 2008 03:31:08 -0000 1.45 @@ -10,7 +10,7 @@ [% END %] [%# Display the heading and create the table #%] -<FORM METHOD="post" ENCTYPE="multipart/form-data"> +<FORM METHOD="post" ENCTYPE="multipart/form-data" ACTION="[% action_url %]"> <input TYPE="hidden" NAME="action" VALUE="change_topics_state" /> [%# Store the search parameters as hidden variables #%] |