Subversion Repositories DevTools

Rev

Rev 1295 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1293 dpurdie 1
[% hash_ex_line %] 
2
 
3
[% scary_warning %]
4
 
5
###############################################################################
6
# Codestriker: Copyright (c) 2001, 2002 David Sitsky.  All rights reserved.
7
# sits@users.sourceforge.net
8
#
9
# This program is free software; you can redistribute it and modify it under
10
# the terms of the GPL.
11
 
12
# This is the top level package which receives all HTTP requests, and
13
# delegates it to the appropriate Action module.
14
 
15
require 5.8.0;
16
 
17
# Set this to the location of the Codestriker libraries on your system.
18
# Ideally, this should be done in the apache configs, but trying to do this
19
# in an easy way for Apache1/Apache2 with/without mod_perl with/without taint
20
# checking turned out to be a major headache.  For mod_perl, setting this
21
# ensures the first time Codestiker is loaded, it can be compiled properly,
22
# even if @INC is blatted later.  Also note all the use declarations below
23
# effectively "pre-load" all of the Codestriker modules in the system, as the
24
# modules below load all of their supporting modules.  That is why the
25
# template plugins are "pre-loaded" here.
26
[% codestriker_lib %]
27
 
28
use strict;
29
 
30
use CGI qw/:standard :html3/;
31
use CGI::Carp 'fatalsToBrowser';
32
 
33
use Codestriker;
34
use Codestriker::Http::Input;
35
use Codestriker::Http::Response;
36
use Codestriker::Action::CreateTopic;
37
use Codestriker::Action::EditComment;
38
use Codestriker::Action::Search;
39
use Codestriker::Action::ListTopics;
40
use Codestriker::Action::DownloadTopic;
41
use Codestriker::Action::ListProjects;
42
use Codestriker::Action::EditProject;
43
use Codestriker::Action::CreateProject;
44
use Codestriker::Action::MetricsReport;
45
use Codestriker::Action::SubmitEditTopicProperties;
46
use Codestriker::Action::SubmitEditTopicMetrics;
47
use Codestriker::Action::SubmitEditTopicsState;
48
use Codestriker::Action::SubmitEditCommentsState;
49
use Codestriker::Action::SubmitEditProject;
50
use Codestriker::Action::SubmitNewProject;
51
use Codestriker::Action::SubmitNewTopic;
52
use Codestriker::Action::SubmitNewComment;
53
use Codestriker::Action::SubmitSearch;
54
use Codestriker::Action::ViewTopicFile;
55
use Codestriker::Action::ViewTopicInfo;
56
use Codestriker::Action::ViewTopic;
57
use Codestriker::Action::ViewTopicProperties;
58
use Codestriker::Action::ViewTopicComments;
59
[% IF has_rss %]use Codestriker::Action::ListTopicsRSS; [% END %]
60
 
61
use Codestriker::Template::Plugin::AutomagicLinks;
62
use Codestriker::Template::Plugin::JavascriptEscape;
63
use Codestriker::Template::Plugin::StringObfuscator;
64
use Codestriker::Template::Plugin::FormatWhitespace;
65
 
66
# Set the temp file location, if one has been specified.
67
if (defined $Codestriker::tmpdir && $Codestriker::tmpdir ne '') {
68
    $CGITempFile::TMPDIRECTORY = $Codestriker::tmpdir;
69
}
70
 
71
# Set the PATH to something sane if we aren't running under windows.
72
# For a lot of annoying reasons, we can't run Codestriker in
73
# tainted mode under Win32.
74
if (Codestriker::is_windows()) {
75
    $ENV{'PATH'} = '';
76
} else {
77
    $ENV{'PATH'} = '/bin:/usr/bin';
78
}
79
 
80
# Prototypes of subroutines used in this module.
81
sub main();
82
 
83
main;
84
 
85
sub main() {
86
    # Initialise Codestriker, load up the configuration file.
87
    Codestriker->initialise([% codestriker_conf %]);
88
 
89
[% IF has_rss %]
90
    # only generated if checksetup.pl found a good version of XML::RSS.
91
    $Codestriker::rss_enabled = 1;
92
[% ELSE %]
93
    # valid XML::RSS not found
94
    $Codestriker::rss_enabled = 0;
95
[% END %]
96
 
97
    # If allow_delete is defined, but topic state 'Delete' is not, add it
98
    # in.  This accounts for older configuration files.
99
    if (defined $Codestriker::allow_delete && $Codestriker::allow_delete &&
100
	(! grep /^Deleted$/, @Codestriker::topic_states)) {
101
	push @Codestriker::topic_states, 'Deleted';
102
    }
103
 
104
    # Check if the old $allow_comment_email configuration option has been
105
    # specified in the config file, rather than the new $email_send_options
106
    # setting.
107
    if (defined $Codestriker::allow_comment_email &&
108
	! defined $Codestriker::email_send_options) {
109
	$Codestriker::email_send_options = 
110
	{
111
	  comments_sent_to_topic_author => $Codestriker::allow_comment_email,
112
	  comments_sent_to_commenter => $Codestriker::allow_comment_email,
113
	  topic_state_change_sent_to_reviewers => 0
114
	};
115
    }
116
 
117
    # Limit the size of the posts that can be done.
118
    $CGI::POST_MAX=$Codestriker::DIFF_SIZE_LIMIT;
119
 
120
    # Load the CGI object, and prepare the HTTP response.
121
    my $query = new CGI;
122
    my $http_response = Codestriker::Http::Response->new($query);
123
 
124
    # Process the HTTP input to ensure it is consistent.
125
    my $http_input = Codestriker::Http::Input->new($query, $http_response);
126
    $http_input->process();
127
 
128
    # Delegate the request to the appropriate Action module.
129
    my $action = $http_input->get("action");
130
    if ($action eq "create") {
131
	Codestriker::Action::CreateTopic->process($http_input, $http_response);
132
    } elsif ($action eq "submit_new_topic") {
133
	Codestriker::Action::SubmitNewTopic->process($http_input,
134
						     $http_response);
135
    } elsif ($action eq "view") {
136
	Codestriker::Action::ViewTopic->process($http_input, $http_response);
137
    } elsif ($action eq "view_topic_properties") {
138
	Codestriker::Action::ViewTopicProperties->process($http_input,
139
							  $http_response);
140
    } elsif ($action eq "viewinfo") {
141
	Codestriker::Action::ViewTopicInfo->process($http_input,
142
						    $http_response);
143
    } elsif ($action eq "edit") {
144
	Codestriker::Action::EditComment->process($http_input, $http_response);
145
    } elsif ($action eq "submit_comment") {
146
	Codestriker::Action::SubmitNewComment->process($http_input,
147
						       $http_response);
148
    } elsif ($action eq "view_file") {
149
	Codestriker::Action::ViewTopicFile->process($http_input,
150
						    $http_response);
151
    } elsif ($action eq "search") {
152
	Codestriker::Action::Search->process($http_input, $http_response);
153
    } elsif ($action eq "submit_search") {
154
	Codestriker::Action::SubmitSearch->process($http_input,
155
						   $http_response);
156
    } elsif ($action eq "list_topics") {
157
	Codestriker::Action::ListTopics->process($http_input, $http_response);
158
    } elsif ($action eq "download") {
159
	Codestriker::Action::DownloadTopic->process($http_input,
160
						    $http_response);
161
    } elsif ($action eq "edit_topic_properties") {
162
        Codestriker::Action::SubmitEditTopicProperties->process($http_input,
163
								$http_response);
164
    } elsif ($action eq "edit_topic_metrics") {
165
        Codestriker::Action::SubmitEditTopicMetrics->process($http_input,
166
							     $http_response);
167
    } elsif ($action eq "change_topics_state") {
168
        Codestriker::Action::SubmitEditTopicsState->process($http_input,
169
							    $http_response);
170
    } elsif ($action eq "list_comments") {
171
	Codestriker::Action::ViewTopicComments->process($http_input,
172
						   $http_response);
173
    } elsif ($action eq "change_comments_state") {
174
	Codestriker::Action::SubmitEditCommentsState->process($http_input,
175
						     $http_response);
176
    } elsif ($action eq "list_projects") {
177
	Codestriker::Action::ListProjects->process($http_input,
178
						   $http_response);
179
    } elsif ($action eq "edit_project") {
180
	Codestriker::Action::EditProject->process($http_input,
181
						  $http_response);
182
    } elsif ($action eq "create_project") {
183
	Codestriker::Action::CreateProject->process($http_input,
184
						    $http_response);
185
    } elsif ($action eq "submit_project") {
186
	Codestriker::Action::SubmitNewProject->process($http_input,
187
						    $http_response);
188
    } elsif ($action eq "submit_editproject") {
189
	Codestriker::Action::SubmitEditProject->process($http_input,
190
							$http_response);
191
    } elsif ($action eq "metrics_report") {
192
	Codestriker::Action::MetricsReport->process($http_input,
193
						    $http_response);
194
    } elsif ($action eq "metrics_download") {
195
	Codestriker::Action::MetricsReport->process_download($http_input,
196
							     $http_response);
197
[% IF has_rss %]
198
    # only generated if checksetup.pl found a good version of XML::RSS.
199
    } elsif ($action eq "list_topics_rss") {
200
	Codestriker::Action::ListTopicsRSS->process($http_input,
201
					            $http_response);
202
[% END %]
203
 
204
    } else {
205
	# Default action is to list topics that are in state open if the
206
	# list functionality is enabled, otherwise go to the create topic
207
	# screen.
208
	if ($Codestriker::allow_searchlist) {
209
	    Codestriker::Action::ListTopics->process($http_input,
210
						     $http_response);
211
        } else {
212
	    Codestriker::Action::CreateTopic->process($http_input,
213
						      $http_response);
214
	}
215
    }
216
}