Thread: [Codestriker-commits] CVS update: codestriker/t/Http url-builder.t
Brought to you by:
sits
|
From: <si...@us...> - 2008-08-10 12:18:45
|
User: sits
Date: 08/08/10 05:18:44
Modified: lib/Codestriker/TopicListeners BugTracking.pm Email.pm
lib/Codestriker/Action ListTopics.pm ViewTopicInfo.pm
ViewTopicComments.pm SubmitNewTopic.pm
SubmitNewComment.pm ListTopicsRSS.pm
ViewTopicProperties.pm ViewTopic.pm CreateTopic.pm
ListProjects.pm EditComment.pm
lib/Codestriker/Http Input.pm UrlBuilder.pm
Added: lib/Codestriker/Http/Method StaticResourcesMethod.pm
CreateTopicMethod.pm ViewTopicTextMethod.pm
SearchTopicsMethod.pm DownloadMetricsMethod.pm
AddCommentMethod.pm CreateProjectMethod.pm
ViewMetricsMethod.pm ViewTopicPropertiesMethod.pm
ViewTopicCommentsMethod.pm ListProjectsMethod.pm
EditProjectMethod.pm ViewTopicMetricsMethod.pm
ViewTopicFileMethod.pm ListTopicsMethod.pm
t/Http/Method create-project.t view-topic-properties.t
add-comment.t view-metrics.t list-projects.t
view-topic-comments.t view-topic-metrics.t
create-topic.t search-topics.t view-topic-text.t
list-topics.t edit-project.t download-metrics.t
view-topic-file.t
lib/Codestriker/Http Method.pm
t/Http url-builder.t
Log:
Initial major refactoring of the URL/dispatch system Codestriker uses. Still quite a bit of work to do, but this is a step in the direction of still supporting the old CGI URLs, but now supports nicer REST-style URLs as well.
Index: StaticResourcesMethod.pm
===================================================================
RCS file: StaticResourcesMethod.pm
diff -N StaticResourcesMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ StaticResourcesMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,42 @@
+###############################################################################
+# 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 returning the URL to static resources, such as online help.
+
+package Codestriker::Http::Method::StaticResourcesMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::StaticResourcesMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ # Check if the HTML files are accessible via another URL (required for
+ # sourceforge deployment), which is specified via $Codestriker::codestriker_css.
+ my $htmlurl;
+ if (defined $Codestriker::codestriker_css &&
+ $Codestriker::codestriker_css ne "" &&
+ $Codestriker::codestriker_css =~ /[\/\\]/o) {
+ $htmlurl = $Codestriker::codestriker_css;
+ $htmlurl =~ s/\/.+?\.css//;
+ } else {
+ # Standard Codestriker deployment.
+ $htmlurl = $self->{url_prefix};
+ $htmlurl =~ s/codestriker\/codestriker\.pl/codestrikerhtml/;
+ }
+
+ if ($self->{cgi_style}) {
+ return $htmlurl;
+ } else {
+ return $self->{url_prefix} . "/static";
+ }
+}
+
+1;
Index: CreateTopicMethod.pm
===================================================================
RCS file: CreateTopicMethod.pm
diff -N CreateTopicMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CreateTopicMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,53 @@
+###############################################################################
+# 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 creating a topic.
+
+package Codestriker::Http::Method::CreateTopicMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::CreateTopicMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, $obsoletes) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=create" .
+ (defined $obsoletes ? "&obsoletes=$obsoletes" : "");
+ } else {
+ return $self->{url_prefix} . "/topics/create" .
+ (defined $obsoletes ? "/obsoletes/$obsoletes" : "");
+ }
+}
+
+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 "create") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/topics/create/}) {
+ $self->_extract_nice_parameters($http_input,
+ obsoletes => 'obsoletes');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::CreateTopic->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicTextMethod.pm
===================================================================
RCS file: ViewTopicTextMethod.pm
diff -N ViewTopicTextMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicTextMethod.pm 10 Aug 2008 12:18:42 -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 viewing the topic text.
+
+package Codestriker::Http::Method::ViewTopicTextMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicTextMethod::ISA =
+ ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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=view&topic=$args{topicid}" .
+ (defined $args{updated} ? "&updated=$args{updated}" : "") .
+ (defined $args{tabwidth} ? "&tabwidth=$args{tabwidth}" : "") .
+ (defined $args{mode} ? "&mode=$args{mode}" : "") .
+ (defined $args{fview} ? "&fview=$args{fview}" : "") .
+ (defined $args{filenumber} ? "#" . "$args{filenumber}|$args{line}|$args{new}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/text" .
+ (defined $args{fview} ? "/filenumber/$args{filenumber}" : "") .
+ (defined $args{mode} ? "/mode/$args{mode}" : "") .
+ (defined $args{filenumber} ? "#" . "$args{filenumber}|$args{line}|$args{new}" : "");
+ }
+}
+
+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 "view") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/text}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ filenumber => 'fview', mode => 'mode');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopic->process($http_input, $http_output);
+}
+
+1;
Index: SearchTopicsMethod.pm
===================================================================
RCS file: SearchTopicsMethod.pm
diff -N SearchTopicsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SearchTopicsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# 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 searching topics.
+
+package Codestriker::Http::Method::SearchTopicsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::SearchTopicsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=search";
+ } else {
+ return $self->{url_prefix} . "/topics/search";
+ }
+}
+
+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 "search") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/topics/search/}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::Search->process($http_input, $http_output);
+}
+
+1;
Index: DownloadMetricsMethod.pm
===================================================================
RCS file: DownloadMetricsMethod.pm
diff -N DownloadMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ DownloadMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# 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 donwloading metrics.
+
+package Codestriker::Http::Method::DownloadMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::DownloadMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=metrics_download";
+ } else {
+ return $self->{url_prefix} . "/metrics/download";
+ }
+}
+
+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 "metrics_download") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/metrics/download$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::MetricsReport->process_download($http_input, $http_output);
+}
+
+1;
Index: AddCommentMethod.pm
===================================================================
RCS file: AddCommentMethod.pm
diff -N AddCommentMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ AddCommentMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,63 @@
+###############################################################################
+# 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::AddCommentMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::AddCommentMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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}" : "");
+ } else {
+ 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}" : "");
+ }
+}
+
+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+)/add}) {
+ $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: CreateProjectMethod.pm
===================================================================
RCS file: CreateProjectMethod.pm
diff -N CreateProjectMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ CreateProjectMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# 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 creating a project.
+
+package Codestriker::Http::Method::CreateProjectMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::CreateProjectMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=create_project";
+ } else {
+ return $self->{url_prefix} . "/admin/projects/create";
+ }
+}
+
+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 "create_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/projects/create$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::CreateProject->process($http_input, $http_output);
+}
+
+1;
Index: ViewMetricsMethod.pm
===================================================================
RCS file: ViewMetricsMethod.pm
diff -N ViewMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# 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 viewing metrics.
+
+package Codestriker::Http::Method::ViewMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=metrics_report";
+ } else {
+ return $self->{url_prefix} . "/metrics/view";
+ }
+}
+
+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 "metrics_report") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/metrics/view$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::MetricsReport->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicPropertiesMethod.pm
===================================================================
RCS file: ViewTopicPropertiesMethod.pm
diff -N ViewTopicPropertiesMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicPropertiesMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# 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 viewing the topic properties.
+
+package Codestriker::Http::Method::ViewTopicPropertiesMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicPropertiesMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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=view_topic_properties&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/properties";
+ }
+}
+
+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 "view_topic_properties") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/properties}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicProperties->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicCommentsMethod.pm
===================================================================
RCS file: ViewTopicCommentsMethod.pm
diff -N ViewTopicCommentsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicCommentsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# 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 viewing topic comments.
+
+package Codestriker::Http::Method::ViewTopicCommentsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicCommentsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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=list_comments&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/comments";
+ }
+}
+
+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 "list_comments") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/comments}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicComments->process($http_input, $http_output);
+}
+
+1;
Index: ListProjectsMethod.pm
===================================================================
RCS file: ListProjectsMethod.pm
diff -N ListProjectsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ListProjectsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+# 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 listing the projects.
+
+package Codestriker::Http::Method::ListProjectsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ListProjectsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=list_projects";
+ } else {
+ return $self->{url_prefix} . "/admin/projects/list";
+ }
+}
+
+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 "list_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/projects/list$}) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ListProjects->process($http_input, $http_output);
+}
+
+1;
Index: EditProjectMethod.pm
===================================================================
RCS file: EditProjectMethod.pm
diff -N EditProjectMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ EditProjectMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,51 @@
+###############################################################################
+# 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 editing a project.
+
+package Codestriker::Http::Method::EditProjectMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::EditProjectMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ my ($self, $projectid) = @_;
+
+ if ($self->{cgi_style}) {
+ return $self->{url_prefix} . "?action=edit_project&projectid=$projectid";
+ } else {
+ return $self->{url_prefix} . "/admin/project/$projectid/edit";
+ }
+}
+
+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_project") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/admin/project/\d+/edit$}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::EditProject->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicMetricsMethod.pm
===================================================================
RCS file: ViewTopicMetricsMethod.pm
diff -N ViewTopicMetricsMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicMetricsMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,54 @@
+###############################################################################
+# 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 viewing the topic metrics.
+
+package Codestriker::Http::Method::ViewTopicMetricsMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicMetricsMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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=viewinfo&topic=$args{topicid}";
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/metrics";
+ }
+}
+
+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 "viewinfo") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/metrics}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+sub execute {
+ my ($self, $http_input, $http_output) = @_;
+
+ Codestriker::Action::ViewTopicInfo->process($http_input, $http_output);
+}
+
+1;
Index: ViewTopicFileMethod.pm
===================================================================
RCS file: ViewTopicFileMethod.pm
diff -N ViewTopicFileMethod.pm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ViewTopicFileMethod.pm 10 Aug 2008 12:18:42 -0000 1.1
@@ -0,0 +1,60 @@
+###############################################################################
+# 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 viewing the a topic file.
+
+package Codestriker::Http::Method::ViewTopicFileMethod;
+
+use strict;
+use Codestriker::Http::Method;
+
+@Codestriker::Http::Method::ViewTopicFileMethod::ISA = ("Codestriker::Http::Method");
+
+# Generate a URL for this method.
+sub url() {
+ 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=view_file&fn=$args{filenumber}&" .
+ "topic=$args{topicid}&new=$args{new}" .
+ (defined $args{mode} ? "&mode=$args{mode}" : "") .
+ (defined $args{line} ? "#$args{filenumber}|$args{line}|$args{new}" : "");
+ } else {
+ return $self->{url_prefix} . "/project/$args{projectid}/topic/$args{topicid}/file/$args{filenumber}" .
+ (defined $args{mode} ? "/mode/$args{mode}" : "") .
+ (defined $args{line} ? "#$args{filenumber}|$args{line}|$args{new}" : "");
+ }
+}
+
+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 "view_file") {
+ $http_input->extract_cgi_parameters();
+ return 1;
+ } elsif ($path_info =~ m{^$self->{url_prefix}/project/\d+/topic/\d+/file/\d+}) {
+ $self->_extract_nice_parameters($http_input,
+ project => 'projectid', topic => 'topicid',
+ file => 'fn');
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+s...
[truncated message content] |
|
From: <si...@us...> - 2008-08-31 12:32:05
|
User: sits
Date: 08/08/31 05:32:04
Removed: t/Http url-builder.t
Log:
No longer need this file.
Index: url-builder.t
===================================================================
RCS file: url-builder.t
diff -N url-builder.t
--- url-builder.t 10 Aug 2008 12:18:44 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,228 +0,0 @@
-# Tests to ensure that UrlBuilder produces correct URLs.
-
-use strict;
-use Test::More tests => 40;
-
-use lib '../../lib';
-use Test::MockObject;
-use Codestriker;
-use Codestriker::Http::UrlBuilder;
-
-# 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' } );
-
-
-# Test view URL generation.
-my $url_cgi = Codestriker::Http::UrlBuilder->new($mock_query);
-my $url_nice = Codestriker::Http::UrlBuilder->new($mock_query, 0);
-
-is($url_cgi->view_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
- $mock_query->url() . '?action=view&topic=1234#2|3|1',
- "View URL CGI syntax");
-
-is($url_nice->view_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
- $mock_query->url() . '/project/10/topic/1234/view/text#2|3|1',
- "View URL nice syntax");
-
-is($url_cgi->view_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1, fview => 2),
- $mock_query->url() . '?action=view&topic=1234&fview=2#2|3|1',
- "View URL CGI syntax specific file");
-
-is($url_nice->view_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1, fview => 2),
- $mock_query->url() . '/project/10/topic/1234/view/text/filenumber/2#2|3|1',
- "View URL nice syntax specific file");
-
-# Check if parameters are missing.
-eval {
- $url_cgi->view_url(projectid => 10, filenumber => 2, line => 3, new => 1);
- fail("View URL missing topicid parameter");
-};
-if ($@) {
- # Expected.
- pass("View URL missing topicid parameter");
-}
-
-eval {
- $url_cgi->view_url(topicid => 1234, filenumber => 2, line => 3, new => 1);
- fail("View URL missing projectid parameter");
-};
-if ($@) {
- # Expected.
- pass("View URL missing projectid parameter");
-}
-
-# Test download URL generation.
-is($url_cgi->download_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
- $mock_query->url() . '?action=download&topic=1234',
- "Download URL CGI syntax");
-
-is($url_nice->download_url(topicid => 1234, projectid => 10, filenumber => 2, line => 3, new => 1),
- $mock_query->url() . '/project/10/topic/1234/download/text',
- "Download URL nice syntax");
-
-# Check if parameters are missing.
-eval {
- $url_cgi->download_url(projectid => 10);
- fail("Download URL missing topicid parameter");
-};
-if ($@) {
- # Expected.
- pass("Download URL missing topicid parameter");
-}
-
-eval {
- $url_cgi->download_url(topicid => 1234);
- fail("Download URL missing projectid parameter");
-};
-if ($@) {
- # Expected.
- pass("Download URL missing projectid parameter");
-}
-
-# Test create topic URL generation.
-is($url_cgi->create_topic_url(),
- $mock_query->url() . '?action=create',
- "Create topic URL CGI syntax");
-
-is($url_nice->create_topic_url(),
- $mock_query->url() . '/topics/create',
- "Create topic URL nice syntax");
-
-is($url_cgi->create_topic_url(45),
- $mock_query->url() . '?action=create&obsoletes=45',
- "Create topic with obsolete topics URL CGI syntax");
-
-is($url_nice->create_topic_url(45),
- $mock_query->url() . '/topics/create/obsoletes/45',
- "Create topic with obsolete topics URL nice syntax");
-
-# Test edit comment URL generation.
-is($url_cgi->edit_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',
- "Add comment URL CGI syntax");
-
-is($url_nice->edit_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',
- "Add comment URL nice syntax");
-
-# Test view file URL generation.
-is($url_cgi->view_file_url(filenumber => 3, line => 55, new => 0, topicid => 1234,
- projectid => 10),
- $mock_query->url() . '?action=view_file&fn=3&topic=1234&new=0#3|55|0',
- "View file URL CGI syntax");
-
-is($url_nice->view_file_url(filenumber => 3, line => 55, new => 0, topicid => 1234,
- projectid => 10),
- $mock_query->url() . '/project/10/topic/1234/view/file/filenumber/3#3|55|0',
- "View file URL nice syntax");
-
-# Test search URL generation.
-is($url_cgi->search_url(), $mock_query->url() . '?action=search',
- "Search URL CGI syntax");
-is($url_nice->search_url(), $mock_query->url() . '/topics/search',
- "Search URL nice syntax");
-
-# Test create project URL generation.
-is($url_cgi->create_project_url(), $mock_query->url() . '?action=create_project',
- "Create project URL CGI syntax");
-is($url_nice->create_project_url(), $mock_query->url() . '/admin/projects/create',
- "Create project URL nice syntax");
-
-# Test list project URL generation.
-is($url_cgi->list_projects_url(), $mock_query->url() . '?action=list_projects',
- "List projects URL CGI syntax");
-is($url_nice->list_projects_url(), $mock_query->url() . '/admin/projects/list',
- "List projects URL nice syntax");
-
-# Test edit project URL generation.
-is($url_cgi->edit_project_url(45), $mock_query->url() . '?action=edit_project&projectid=45',
- "List projects URL CGI syntax");
-is($url_nice->edit_project_url(45), $mock_query->url() . '/admin/project/45/edit',
- "List projects URL nice syntax");
-
-# Test view comments URL generation.
-is($url_cgi->view_comments_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '?action=list_comments&topic=1234',
- "View comments URL CGI syntax");
-
-is($url_nice->view_comments_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '/project/10/topic/1234/comments/list',
- "View comments URL nice syntax");
-
-# Test view properties URL generation.
-is($url_cgi->view_topic_properties_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '?action=view_topic_properties&topic=1234',
- "View topic properties URL CGI syntax");
-
-is($url_nice->view_topic_properties_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '/project/10/topic/1234/properties',
- "View topic properties URL nice syntax");
-
-# Test view topic metrics URL generation.
-is($url_cgi->view_topicinfo_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '?action=viewinfo&topic=1234',
- "View topic metrics URL CGI syntax");
-
-is($url_nice->view_topicinfo_url(topicid => 1234, projectid => 10),
- $mock_query->url() . '/project/10/topic/1234/metrics',
- "View topic metrics URL nice syntax");
-
-# Test metric reports URL generation.
-is($url_cgi->metric_report_url(),
- $mock_query->url() . '?action=metrics_report',
- "View metric reports URL CGI syntax");
-is($url_nice->metric_report_url(),
- $mock_query->url() . '/metrics/view',
- "View metric reports URL CGI syntax");
-
-is($url_cgi->metric_report_download_raw_data(),
- $mock_query->url() . '?action=metrics_download',
- "Download metrics report URL cgi syntax");
-is($url_nice->metric_report_download_raw_data(),
- $mock_query->url() . '/metrics/download',
- "Download metrics report URL nice syntax");
-
-# Test list topics URL generation.
-is ($url_cgi->list_topics_url(sauthor => "sits", sreviewer => "engineering",
- sbugid => "10,20", stitle => "Example title",
- scomments => "Critical Error",
- sstate => [0],
- sproject => [10,20]),
- $mock_query->url() . '?action=list_topics&sauthor=sits&sreviewer=engineering' .
- '&sbugid=10%2C20&stitle=Example%20title&scomments=Critical%20Error' .
- '&sstate=0&sproject=10%2C20',
- "List topics URL CGI syntax");
-is ($url_nice->list_topics_url(sauthor => "sits", sreviewer => "engineering",
- sbugid => "10,20", stitle => "Example title",
- scomments => "Critical Error",
- sstate => [0],
- sproject => [10,20]),
- $mock_query->url() . '/topics/list/author/sits/reviewer/engineering' .
- '/bugid/10%2C20/title/Example%20title/comment/Critical%20Error' .
- '/state/0/project/10%2C20',
- "List topics URL nice syntax");
-
-# Test list topics RSS URL generation.
-is ($url_cgi->list_topics_url_rss(sauthor => "sits", sreviewer => "engineering",
- sbugid => "10,20", stitle => "Example title",
- scomments => "Critical Error",
- sstate => [0],
- sproject => [10,20]),
- $mock_query->url() . '?action=list_topics_rss&sauthor=sits&sreviewer=engineering' .
- '&sbugid=10%2C20&stitle=Example%20title&scomments=Critical%20Error' .
- '&sstate=0&sproject=10%2C20',
- "List topics URL CGI syntax");
-is ($url_nice->list_topics_url_rss(sauthor => "sits", sreviewer => "engineering",
- sbugid => "10,20", stitle => "Example title",
- scomments => "Critical Error",
- sstate => [0],
- sproject => [10,20]),
- $mock_query->url() . '/feed/topics/list/author/sits/reviewer/engineering' .
- '/bugid/10%2C20/title/Example%20title/comment/Critical%20Error' .
- '/state/0/project/10%2C20',
- "List topics URL nice syntax");
-
\ No newline at end of file
|