Fix links at http://repo.or.cz/w/foobar
[girocco.git] / cgi / regproj.cgi
blob1fa45355da9213cae37f3214358a1bbc6053fddb
1 #!/usr/bin/perl
2 # (c) Petr Baudis <pasky@suse.cz>
3 # GPLv2
5 use strict;
6 use warnings;
8 use lib qw(/home/repo/repomgr/cgi);
9 use Git::RepoCGI;
11 my $repo = Git::RepoCGI->new('Project Registration');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->param('name');
15 $name ||= '';
17 if ($cgi->param('mode')) {
18 # submitted, let's see
19 # FIXME: racy, do a lock
20 my $name = $repo->wparam('name');
21 valid_proj_name($name)
22 and Git::RepoCGI::Project::does_exist($name)
23 and $repo->err("Project with that name already exists.");
24 $name =~ /\.git$/
25 and $repo->err("Project name should not end with .git, I'll add that automagically.");
27 my $mirror = $cgi->param('mode') eq 'mirror';
28 my $proj = Git::RepoCGI::Project->ghost($name, $mirror);
29 if ($proj->cgi_fill($repo)) {
30 if ($mirror) {
31 $proj->premirror;
32 print "<p>Initiated mirroring. You will be notified by mail about results.</p>\n";
33 } else {
34 $proj->conjure;
35 print <<EOT;
36 <p>
37 Project successfuly set up.
38 You can <a href="p/editproj.cgi">assign users</a> now (use project name as username, admin password as password).
39 You need to <a href="reguser.cgi">register a user</a> first if you have not done so yet.
40 (One user can have push access to multiple projects and multiple users can have push access to one project.)
41 </p>
42 <p>The push URL for the project is <tt>git+ssh://repo.or.cz/srv/git/$name.git</tt>.</p>
43 <p>You may experience permission problems if you try to push right now.
44 If so, that should get fixed automagically in few minutes.</p>
45 <p>Enjoy yourself!</p>
46 EOT
48 exit;
52 print <<EOT;
53 <p>Here you can register a project.
54 It can be hosted in two modes: mirror mode and push mode.
55 In the first mode, we will check another repository at a given URL every hour and mirror any new updates.
56 In the second mode, registered users with appropriate permissions will be able to push to the repository.
57 You currently cannot switch freely between those two modes;
58 if you want to switch from mirroring to push mode, delete and recreate
59 the project. If you want to switch the other way, please contact the administrator.</p>
60 <p>You will need the admin password to adjust project settings later
61 (mirroring URL, list of users allowed to push, project description, ...).
62 Use the project name as the username when asked by the browser.</p>
63 EOT
64 unless ($name =~ m#/#) {
65 print <<EOT;
66 <p>Note that if your project is a <strong>fork of an existing project</strong>
67 (this does not mean anything socially bad), please instead go to the project's
68 summary view and click the 'fork' link in the top bar. This way, both you and
69 we will save bandwidth and your project will be properly categorized. If your
70 project is a fork but the existing project is not registered here yet, please
71 consider registering it first; you do not have to be involved in the project
72 in order to register it here as a mirror.</p>
73 EOT
74 } else {
75 my $xname = $name; $xname =~ s#/$#.git#;
76 print <<EOT;
77 <p>Great, your project will be created as a subproject of the '$xname' project.
78 This means that it will be properly categorized and you will need to push only
79 the data <em>you</em> created, not the whole project. (That will be done automagically,
80 you do not need to specify any extra arguments during the push.)</p>
81 EOT
83 print <<EOT;
84 <p>By submitting this form, you are confirming that the repository contains only free software
85 and redistributing it does not violate any law of Czech Republic. Read <a href="/about.html">more details</a>
86 about the hosting and terms and conditions.</p>
87 <p>Have fun!</p>
88 <form method="post">
89 <p>Project name (w/o the .git suffix): <input type="text" name="name" value="$name" /></p>
90 <p>Admin password: <input type="password" name="pwd" /></p>
91 <p>E-mail contact: <input type="text" name="email" /></p>
92 <p>Hosting mode:</p><ul>
93 <li><input type="radio" name="mode" value="mirror" />Mirror mode. Repository URL: <input type="text" name="url" /></li>
94 <li><input type="radio" name="mode" value="push" />Push mode.</li></ul>
95 <p>Description: <input type="text" name="desc" /></p>
96 <p>Homepage URL: <input type="text" name="hp" /></p>
97 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80"></textarea></p>
98 <p><input type="submit" name="y0" value="Register" /></p>
99 </form>