[Codestriker-commits] CVS update: codestriker/lib/Codestriker/TopicListeners Email.pm
Brought to you by:
sits
|
From: <si...@us...> - 2008-08-18 11:11:38
|
User: sits
Date: 08/08/18 04:11:36
Modified: lib/Codestriker/Http Dispatcher.pm Response.pm UrlBuilder.pm
lib/Codestriker/Http/Method AddCommentMethod.pm
lib/Codestriker/Model Comment.pm
lib/Codestriker/Action ViewTopicComments.pm
t/Http/Method submit-search-topics.t add-comment.t
lib/Codestriker/TopicListeners Email.pm
Added: lib/Codestriker/Http/Method CreateCommentMethod.pm
t/Http/Method create-comment.t
Log:
Adding comments now works. Have to work on remaining submit actions.
Index: Dispatcher.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Dispatcher.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Dispatcher.pm 15 Aug 2008 06:10:40 -0000 1.2
+++ Dispatcher.pm 18 Aug 2008 11:11:28 -0000 1.3
@@ -21,6 +21,7 @@
use Codestriker::Http::Method::ViewTopicMetricsMethod;
use Codestriker::Http::Method::ViewTopicPropertiesMethod;
use Codestriker::Http::Method::AddCommentMethod;
+use Codestriker::Http::Method::CreateCommentMethod;
use Codestriker::Http::Method::AddTopicMethod;
use Codestriker::Http::Method::CreateProjectMethod;
use Codestriker::Http::Method::DownloadMetricsMethod;
@@ -49,6 +50,7 @@
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::CreateCommentMethod->new($query);
push @methods, Codestriker::Http::Method::AddCommentMethod->new($query);
push @methods, Codestriker::Http::Method::AddTopicMethod->new($query);
push @methods, Codestriker::Http::Method::CreateProjectMethod->new($query);
Index: Response.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Response.pm,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- Response.pm 1 Jul 2008 10:06:46 -0000 1.47
+++ Response.pm 18 Aug 2008 11:11:28 -0000 1.48
@@ -75,14 +75,14 @@
# $tabwidth parameters.
my %cookie = ();
- if (!exists $params{email} || $params{email} eq "") {
+ if (! defined $params{email} || $params{email} eq "") {
$email = Codestriker::Http::Cookie->get_property($query, 'email');
}
else {
$email = $params{email};
}
- if (!exists $params{reviewers} || $params{reviewers} eq "") {
+ if (! defined $params{reviewers} || $params{reviewers} eq "") {
$reviewers = Codestriker::Http::Cookie->get_property($query,
'reviewers');
}
@@ -90,14 +90,14 @@
$reviewers = $params{reviewers};
}
- if (!exists $params{cc} || $params{cc} eq "") {
+ if (! defined $params{cc} || $params{cc} eq "") {
$cc = Codestriker::Http::Cookie->get_property($query, 'cc');
}
else {
$cc = $params{cc};
}
- if (!exists $params{tabwidth} || $params{tabwidth} eq "") {
+ if (! defined $params{tabwidth} || $params{tabwidth} eq "") {
$tabwidth = Codestriker::Http::Cookie->get_property($query,
'tabwidth');
}
@@ -105,14 +105,14 @@
$tabwidth = $params{tabwidth};
}
- if (!exists $params{mode} || $params{mode} eq "") {
+ if (! defined $params{mode} || $params{mode} eq "") {
$mode = Codestriker::Http::Cookie->get_property($query, 'mode');
}
else {
$mode = $params{mode};
}
- if (!exists $params{repository} || $params{repository} eq "") {
+ if (! defined $params{repository} || $params{repository} eq "") {
$repository = Codestriker::Http::Cookie->get_property($query,
'repository');
}
@@ -120,7 +120,7 @@
$repository = $params{repository};
}
- if (!exists $params{projectid} || $params{projectid} eq "") {
+ if (! defined $params{projectid} || $params{projectid} eq "") {
$projectid = Codestriker::Http::Cookie->get_property($query,
'projectid');
}
@@ -128,7 +128,7 @@
$projectid = $params{projectid};
}
- if (!exists $params{topicsort} || $params{topicsort} eq "") {
+ if (! defined $params{topicsort} || $params{topicsort} eq "") {
$topicsort = Codestriker::Http::Cookie->get_property($query,
'topicsort');
}
@@ -289,7 +289,7 @@
# output an error message. This is usually due to a
# misconfiguration.
print " if ('function' != typeof window.add_comment_html) {\n";
- print " alert('Oh oh... can\\'t find codestriker.js, please check your apache config.');\n";
+ print " alert('Oh oh... can\\'t find codestriker.js, please check your web-server config.');\n";
print " }\n";
print "</script>\n";
Index: UrlBuilder.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/UrlBuilder.pm,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- UrlBuilder.pm 17 Aug 2008 22:25:36 -0000 1.42
+++ UrlBuilder.pm 18 Aug 2008 11:11:28 -0000 1.43
@@ -124,7 +124,7 @@
# Create the URL for editing a topic.
sub edit_url {
my ($self, %args) = @_;
- return Codestriker::Http::Method::AddCommentMethod->new($self->{query})->url(%args);
+ return Codestriker::Http::Method::CreateCommentMethod->new($self->{query})->url(%args);
}
# Create the URL for viewing a new file.
Index: AddCommentMethod.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Http/Method/AddCommentMethod.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddCommentMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
+++ AddCommentMethod.pm 18 Aug 2008 11:11:29 -0000 1.2
@@ -5,7 +5,7 @@
# This program is free software; you can redistribute it and modify it under
# the terms of the GPL.
-# Method for adding a comment to a topic.
+# Method for submitting a searching topic form.
package Codestriker::Http::Method::AddCommentMethod;
@@ -16,20 +16,16 @@
# Generate a URL for this method.
sub url() {
- my ($self, %args) = @_;
+ my ($self, %args) = @_;
- die "Parameter topicid missing" unless defined $args{topicid};
- die "Parameter projectid missing" unless defined $args{projectid};
-
if ($self->{cgi_style}) {
- return $self->{url_prefix} . "?action=edit&fn=$args{filenumber}&line=$args{line}&new=$args{new}&topic=$args{topicid}" .
- (defined $args{anchor} ? "&a=$args{anchor}" : "") .
- (defined $args{context} ? "&context=$args{context}" : "");
+ return $self->{url_prefix} . "?action=submit_comment";
} else {
+ die "Parameter topicid missing" unless defined $args{topicid};
+ die "Parameter projectid missing" unless defined $args{projectid};
+
return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/comment/" .
- "$args{filenumber}|$args{line}|$args{new}/add" .
- (defined $args{anchor} ? "/anchor/$args{anchor}" : "") .
- (defined $args{context} ? "/context/$args{context}" : "");
+ "$args{filenumber}|$args{line}|$args{new}/add";
}
}
@@ -38,7 +34,7 @@
my $action = $http_input->{query}->param('action');
my $path_info = $http_input->{query}->path_info();
- if ($self->{cgi_style} && defined $action && $action eq "edit") {
+ if ($self->{cgi_style} && defined $action && $action eq "submit_comment") {
$http_input->extract_cgi_parameters();
return 1;
} elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/comment/(\d+)\|(\d+)\|(\d+)/add}) {
@@ -57,7 +53,7 @@
sub execute {
my ($self, $http_input, $http_output) = @_;
- Codestriker::Action::EditComment->process($http_input, $http_output);
+ Codestriker::Action::SubmitNewComment->process($http_input, $http_output);
}
1;
Index: CreateCommentMethod.pm
===================================================================
RCS file: CreateCommentMethod.pm
diff -N CreateCommentMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CreateCommentMethod.pm 18 Aug 2008 11:11:29 -0000 1.1
@@ -0,0 +1,64 @@
+###############################################################################
+# 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.
+
+# Method for adding a comment to a topic.
+
+package Codestriker::Http::Method::CreateCommentMethod;
+
+use strict;
+use Carp;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::CreateCommentMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, %args) = @_;
+
+ confess "Parameter topicid missing" unless defined $args{topicid};
+ confess "Parameter projectid missing" unless defined $args{projectid};
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=edit&fn=$args{filenumber}&line=$args{line}&new=$args{new}&topic=$args{topicid}" .
+ (defined $args{anchor} ? "&a=$args{anchor}" : "") .
+ (defined $args{context} ? "&context=$args{context}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/comment/" .
+ "$args{filenumber}|$args{line}|$args{new}/create" .
+ (defined $args{anchor} ? "/anchor/$args{anchor}" : "") .
+ (defined $args{context} ? "/context/$args{context}" : "");
+ }
+}
+
+sub extract_parameters {
+ my ($self, $http_input) = @_;
+
+ my $action = $http_input->{query}->param('action');
+ my $path_info = $http_input->{query}->path_info();
+ if ($self->{cgi_style} && defined $action && $action eq "edit") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/comment/(\d+)\|(\d+)\|(\d+)/create}) {
+ $http_input->{fn} = $1;
+ $http_input->{line} = $2;
+ $http_input->{new} = $3;
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ anchor => 'anchor', context => 'context');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::EditComment->process($http_input, $http_output);
+}
+
+1;
Index: Comment.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Model/Comment.pm,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- Comment.pm 9 Jun 2006 03:20:02 -0000 1.23
+++ Comment.pm 18 Aug 2008 11:11:29 -0000 1.24
@@ -368,7 +368,8 @@
my $filteredByAuthor =
Codestriker->filter_email($filtered_by_author);
- if ($filteredByAuthor ne "" && $filteredAuthor ne $filteredByAuthor) {
+ if (defined $filteredByAuthor && $filteredByAuthor ne "" &&
+ $filteredAuthor ne $filteredByAuthor) {
# Don't keep this record.
$keep_comment = 0;
}
Index: ViewTopicComments.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/ViewTopicComments.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ViewTopicComments.pm 10 Aug 2008 12:18:43 -0000 1.19
+++ ViewTopicComments.pm 18 Aug 2008 11:11:29 -0000 1.20
@@ -112,7 +112,8 @@
$last_filenumber = $comment->{filenumber};
}
- if ($show_context ne "" && $show_context > 0 &&
+ if (defined $show_context && $show_context ne "" &&
+ $show_context > 0 &&
$comment->{filenumber} != -1 && $comment->{fileline} != -1) {
my $delta = Codestriker::Model::Delta->get_delta($topicid,
$comment->{filenumber},
Index: submit-search-topics.t
===================================================================
RCS file: /cvsroot/codestriker/codestriker/t/Http/Method/submit-search-topics.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- submit-search-topics.t 15 Aug 2008 06:10:42 -0000 1.1
+++ submit-search-topics.t 18 Aug 2008 11:11:36 -0000 1.2
@@ -6,7 +6,7 @@
use lib '../../../lib';
use Test::MockObject;
use Codestriker;
-use Codestriker::Http::Method::SearchTopicsMethod;
+use Codestriker::Http::Method::SubmitSearchTopicsMethod;
# Create a CGI mock object for these tests.
my $mock_query = Test::MockObject->new();
Index: add-comment.t
===================================================================
RCS file: /cvsroot/codestriker/codestriker/t/Http/Method/add-comment.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- add-comment.t 10 Aug 2008 12:18:42 -0000 1.1
+++ add-comment.t 18 Aug 2008 11:11:36 -0000 1.2
@@ -1,7 +1,7 @@
# Tests for the AddComment method.
use strict;
-use Test::More tests => 8;
+use Test::More tests => 7;
use lib '../../../lib';
use Test::MockObject;
@@ -19,12 +19,12 @@
is($url_cgi->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
projectid => 10, context => 3),
- $mock_query->url() . '?action=edit&fn=3&line=55&new=0&topic=1234&context=3',
+ $mock_query->url() . '?action=submit_comment',
"Add comment URL CGI syntax");
is($url_nice->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
projectid => 10, context => 3),
- $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/add/context/3',
+ $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/add',
"Add comment URL nice syntax");
# Check that the parameters extracted correctly.
@@ -32,7 +32,7 @@
$mock_http_input->{query} = $mock_query;
$mock_query->mock('path_info',
sub {
- return $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/add/context/3';
+ return $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/add';
});
$mock_query->mock('param', sub { return undef; });
$url_nice->extract_parameters($mock_http_input);
@@ -41,6 +41,5 @@
is ($mock_http_input->{fn}, "3", "fn nice URL parameter extraction");
is ($mock_http_input->{line}, "55", "line nice URL parameter extraction");
is ($mock_http_input->{new}, "0", "new nice URL parameter extraction");
-is ($mock_http_input->{context}, "3", "context nice URL parameter extraction");
\ No newline at end of file
Index: create-comment.t
===================================================================
RCS file: create-comment.t
diff -N create-comment.t
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ create-comment.t 18 Aug 2008 11:11:36 -0000 1.1
@@ -0,0 +1,46 @@
+# Tests for the CreateComment method.
+
+use strict;
+use Test::More tests => 8;
+
+use lib '../../../lib';
+use Test::MockObject;
+use Codestriker;
+use Codestriker::Http::Method::CreateCommentMethod;
+
+# Create a CGI mock object for these tests.
+my $mock_query = Test::MockObject->new();
+$mock_query->mock('url',
+ sub { 'http://localhost.localdomain/codestriker/codestriker.pl' } );
+
+# Create two method objects to test each URL scheme.
+my $url_cgi = Codestriker::Http::Method::CreateCommentMethod->new($mock_query, 1);
+my $url_nice = Codestriker::Http::Method::CreateCommentMethod->new($mock_query, 0);
+
+is($url_cgi->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
+ projectid => 10, context => 3),
+ $mock_query->url() . '?action=edit&fn=3&line=55&new=0&topic=1234&context=3',
+ "Create comment URL CGI syntax");
+
+is($url_nice->url(filenumber => 3, line => 55, new => 0, topicid => 1234,
+ projectid => 10, context => 3),
+ $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/create/context/3',
+ "Create comment URL nice syntax");
+
+# Check that the parameters extracted correctly.
+my $mock_http_input = Test::MockObject->new();
+$mock_http_input->{query} = $mock_query;
+$mock_query->mock('path_info',
+ sub {
+ return $mock_query->url() . '/project/10/topic/1234/comment/3|55|0/create/context/3';
+ });
+$mock_query->mock('param', sub { return undef; });
+$url_nice->extract_parameters($mock_http_input);
+is ($mock_http_input->{projectid}, "10", "projectid nice URL parameter extraction");
+is ($mock_http_input->{topicid}, "1234", "topicid nice URL parameter extraction");
+is ($mock_http_input->{fn}, "3", "fn nice URL parameter extraction");
+is ($mock_http_input->{line}, "55", "line nice URL parameter extraction");
+is ($mock_http_input->{new}, "0", "new nice URL parameter extraction");
+is ($mock_http_input->{context}, "3", "context nice URL parameter extraction");
+
+
\ No newline at end of file
Index: Email.pm
===================================================================
RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Email.pm 17 Aug 2008 22:25:37 -0000 1.33
+++ Email.pm 18 Aug 2008 11:11:36 -0000 1.34
@@ -333,7 +333,7 @@
line => $comment->{fileline},
new => $comment->{filenew},
topicid => $topic->{topicid},
- projectid => $topic->{projectid});
+ projectid => $topic->{project_id});
# Retrieve the comment details for this topic.
my @comments = $topic->read_comments();
|