Clean up user-visible texts
[girocco/mytab.git] / cgi / p / editproj.cgi
blob0d01828e9b7d31faad850d0d17c6278c77b6520c
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 Settings');
12 my $cgi = $repo->cgi;
14 my $name = $cgi->remote_user();
16 if (!valid_proj_name($name)) {
17 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
18 exit;
21 if (!Git::RepoCGI::Project::does_exist($name)) {
22 print "<p>Sorry but this project does not exist. Now, how did you <em>get</em> here?!</p>\n";
23 exit;
26 if (!Git::RepoCGI::Project::available($name)) {
27 print "<p>Sorry but your project has not finished mirroring yet. If it takes inordinate amount of time, please ask the administrator about it.</p>\n";
28 exit;
31 my $proj = Git::RepoCGI::Project->load($name);
32 $proj or die "not found project $name, that's really weird!";
34 if ($cgi->param('email')) {
35 # submitted, let's see
36 if ($proj->cgi_fill($repo) and $proj->update) {
37 print "<p>Project successfuly updated.</p>\n";
41 # $proj may be insane now but that's actually good for us since we'll let the
42 # user fix the invalid values she entered
43 my %h = $proj->form_defaults;
45 print <<EOT;
46 <p>Here you can adjust the settings of project $h{name}. Go wild.
47 Though you can currently enable access only for a single user at a time
48 so perhaps you will need to click a lot. Sorry! (Patches welcome.)</p>
49 <form method="post">
50 <p>Project name (w/o the .git suffix): <a href="/w/$h{name}.git">$h{name}</a></p>
51 <p>Admin password: <input type="password" name="pwd" /> (leave empty to keep it at the current value)</p>
52 <p>E-mail contact: <input type="text" name="email" value="$h{email}" /></p>
53 <p>Repository URL: <input type="text" name="url" value="$h{url}" /></p>
54 <p>Description: <input type="text" name="desc" value="$h{desc}" /></p>
55 <p>Homepage URL: <input type="text" name="hp" value="$h{hp}" /></p>
56 <p>README (HTML, lt 8kb): <textarea name="README" rows="5" cols="80">$h{README}</textarea></p>
57 <p>Users:</p>
58 <ul>
59 EOT
60 if ($proj->{mirror}) {
61 print "<p><em>Warning: This is a mirrored repository, thus you cannot push into it. Changing the user set will have no practical effect.</em></p>\n";
62 } elsif (not grep { $_ eq 'mob' } @{$h{users}}) {
63 print "<p><em>(Please consider adding the <tt>mob</tt> user.<sup><a href=\"/mob.html\">(learn more)</a></sup>)</em></p>\n";
65 foreach my $user (@{$h{users}}) {
66 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user</li>\n";
68 print <<EOT;
69 <li>Add user: <input type="text" name="user" /></li>
70 </ul>
71 <p><input type="submit" name="y0" value="Update" /></p>
72 </form>
73 EOT