2 # (c) Petr Baudis <pasky@suse.cz>
14 my $gcgi = Girocco
::CGI
->new('Project Registration');
17 my $name = $cgi->param('name');
20 my $fork = $cgi->param('fork');
23 $name = "$fork/$name";
26 if ($cgi->param('mail')) {
27 print "<p>Go away, bot.</p>";
31 if ($cgi->param('mode')) {
32 # submitted, let's see
33 # FIXME: racy, do a lock
34 Girocco
::Project
::valid_name
($name)
35 and Girocco
::Project
::does_exist
($name)
36 and $gcgi->err("Project with the name '$name' already exists.");
38 and $gcgi->err("Project name should not end with <tt>.git</tt> - I'll add that automagically.");
40 my $mirror = $cgi->param('mode') eq 'mirror';
42 if ($mirror and $Girocco::Config
::mirror_sources
and not $cgi->param('url')) {
43 my $src = $cgi->param('source'); $src ||= '';
44 my $source; $src and $source = (grep { $_->{label
} eq $src } @
$Girocco::Config
::mirror_sources
)[0];
45 $source or $gcgi->err("Invalid or no mirror source $src specified");
47 my $n = $source->{label
};
48 my $u = $source->{url
};
49 if ($source->{inputs
}) {
50 for my $i (0..$#{$source->{inputs}}) {
51 my $v = $cgi->param($n.'_i'.$i);
53 $gcgi->err("Source specifier '".$source->{inputs
}->[$i]->{label
}."' not filled.");
60 $u = $cgi->param($n.'_url');
61 $u or $gcgi->err("Source URL not specified");
63 $cgi->param('url', $u);
66 my $proj = Girocco
::Project
->ghost($name, $mirror);
67 if ($proj->cgi_fill($gcgi)) {
69 unless ($Girocco::Config
::mirror
) {
70 $gcgi->err("Mirroring mode is not enabled at this site.");
74 print "<p>Please <a href=\"mirrorproj.cgi?name=$name\">pass onwards</a>.</p>\n";
75 print "<script language=\"javascript\">document.location='mirrorproj.cgi?name=$name'</script>\n";
78 unless ($Girocco::Config
::push) {
79 $gcgi->err("Push mode is not enabled at this site.");
85 Project <a href="$Girocco::Config::gitweburl/$name.git">$name</a> successfuly set up.</p>
87 print "<p>The push URL for the project is <tt>$Girocco::Config::pushurl/$name.git</tt>.</p>";
88 print "<p>The read-only URL for the project is <tt>" .
89 join("/$name.git</tt>, <tt>", $Girocco::Config
::gitpullurl
, $Girocco::Config
::httppullurl
) .
90 "/$name.git</tt>.</p>" if $Girocco::Config
::gitpullurl
or $Girocco::Config
::httppullurl
;
92 if ($Girocco::Config
::manage_users
) {
94 Everyone who wants to push must <a href="reguser.cgi">register himself as a user</a> first.
95 (One user can have push access to multiple projects and multiple users can have push access to one project.)
99 <p>You can <a href="editproj.cgi?name=$name">assign users</a> now
100 - don't forget to assign yourself as a user as well if you want to push!
103 <p>Note that you cannot clone an empty repository since it contains no branches; you need to make the first push from an existing repository.</p>
104 <p>You may experience permission problems if you try to push right now.
105 If so, that should get fixed automagically in few minutes, please be patient.</p>
106 <p>Enjoy yourself, and have a lot of fun!</p>
115 desc
=> 'our dedicated git monkeys will check another repository at a given URL every hour and mirror any new updates',
116 pwpurp
=> 'mirroring URL'
120 desc
=> 'registered users with appropriate permissions will be able to push to the repository',
121 pwpurp
=> 'list of users allowed to push'
124 my $me = $Girocco::Config
::mirror ?
$mirror_mode : undef;
125 my $pe = $Girocco::Config
::push ?
$push_mode : undef;
128 <p>At this site, you can host a project in one of two modes: $me->{name} mode and $pe->{name} mode.
129 In the <b>$me->{name} mode</b>, $me->{desc}.
130 In the <b>$pe->{name} mode</b>, $pe->{desc}.
131 You currently cannot switch freely between those two modes;
132 if you want to switch from mirroring to push mode, just delete and recreate
133 the project. If you want to switch the other way, please contact the administrator.</p>
136 my $mode = $me ?
$me : $pe;
137 print "<p>This site will host your project in a <b>$mode->{name} mode</b>: $mode->{desc}.</p>\n";
141 push @pwpurp, $me->{pwpurp
} if $me;
142 push @pwpurp, $pe->{pwpurp
} if $pe;
143 my $pwpurp = join(', ', @pwpurp);
145 if ($Girocco::Config
::project_passwords
) {
147 <p>You will need the admin password to adjust the project settings later
148 ($pwpurp, project description, ...).</p>
152 unless ($name =~ m
#/#) {
154 <p>Note that if your project is a <strong>fork of an existing project</strong>
155 (this does not mean anything socially bad), please instead go to the project's
156 gitweb page and click the 'fork' link in the top bar. This way, all of us
157 will save bandwidth and more importantly, your project will be properly categorized.
160 If your project is a fork but the existing project is not registered here yet, please
161 consider registering it first; you do not have to be involved in the project
162 in order to register it here as a mirror.</p>
165 my $xname = $name; $xname =~ s
#/$#.git#; #
166 my ($pushnote1, $pushnote2);
167 $pushnote1 = " and you will need to push only the data <em>you</em> created, not the whole project" if $pe;
168 $pushnote2 = "(That will be done automagically, you do not need to specify any extra arguments during the push.)" if $pe;
170 <p>Great, your project will be created as a subproject of the '$xname' project.
171 This means that it will be properly categorized$pushnote1. $pushnote2</p>
176 my $mirrorentry = '';
178 $mirrorentry = '<tr id="mirror_url"><td class="formlabel">Mirror source:</td><td>';
179 if (!$Girocco::Config
::mirror_sources
) {
180 $mirrorentry .= '<input type="text" name="url" />';
182 $mirrorentry .= "<table>"."\n";
183 my $checked = ' checked=checked';
184 foreach my $source (@
$Girocco::Config
::mirror_sources
) {
185 my $n = $source->{label
};
186 $mirrorentry .= '<tr><td class="formlabel">';
187 $mirrorentry .= '<p><input type="radio" name="source" value="'.$n.'" '.$checked.' />';
189 $mirrorentry .= '</p></td><td>';
191 if ($source->{desc
}) {
192 $mirrorentry .= '<p>';
193 $source->{link} and $mirrorentry .= '<a href="'.$source->{link}.'">';
194 $mirrorentry .= $source->{desc
};
195 $source->{link} and $mirrorentry .= '</a>';
196 $mirrorentry .= '</p>';
198 if (!$source->{inputs
}) {
199 $mirrorentry .= '<p>URL: <input type="text" name="'.$n.'_url" /></p>';
201 $mirrorentry .= '<p>';
203 foreach my $input (@
{$source->{inputs
}}) {
204 $mirrorentry .= $input->{label
};
205 $mirrorentry .= ' <input type="text" name="'.$n.'_i'.$i.'" />';
206 $mirrorentry .= $input->{suffix
} if $input->{suffix
};
207 $mirrorentry .= ' ';
209 $mirrorentry .= '</p>';
211 $mirrorentry .= '</td></tr>'."\n";
213 $mirrorentry .= "</table>";
215 $mirrorentry .= '</td></tr>';
218 $modechooser = <<EOT;
219 <tr><td class="formlabel">Hosting mode:</td><td><p>
220 <input type="radio" name="mode" value="mirror" id="mirror_radio" checked="checked" />Mirror mode<br />
221 <input type="radio" name="mode" value="push" id="push_radio" />Push mode
225 $modechooser = '<input type="hidden" name="mode" value="'.($me ?
$me->{name
} : $pe->{name
}).'" />';
231 $forkentry = '<input type="hidden" name="fork" value="'.$1.'" />'.$1.'/'
235 $Girocco::Config::legalese
238 <tr><td class="formlabel">Project name:</td><td>$forkentry<input type="text" name="name" value="$name" />.git</td></tr>
240 if ($Girocco::Config
::project_passwords
) {
242 <tr><td class="formlabel">Admin password (twice):</td><td><input type="password" name="pwd" /><br /><input type="password" name="pwd2" /></td></tr>
245 if ($Girocco::Config
::project_owners
eq 'email') {
247 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" /></td></tr>
253 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, undef, @Girocco::Config
::project_fields
);
256 <tr style="display:none"><td>Anti-captcha (leave empty!):</td><td><input type="text" name="mail" /></td></tr>
257 <tr><td></td><td><input type="submit" name="y0" value="Register" /></td></tr>