2 # (c) Petr Baudis <pasky@suse.cz>
13 use POSIX
qw(strftime);
16 <script type="text/javascript">
18 function adduseritem(elem)
20 var inp = document.createElement('input');
23 var li = document.createElement('li');
24 li.appendChild(document.createTextNode('Add user: '));
26 elem.parentNode.insertBefore(li, elem);
31 my $gcgi = Girocco
::CGI
->new('Project Settings', undef, $script);
34 my $name = $cgi->param('name');
35 $name =~ s
#\.git$## if $name; #
37 unless (defined $name) {
38 print "<p>I need the project name as an argument now.</p>\n";
42 if (!Girocco
::Project
::does_exist
($name,1) && !Girocco
::Project
::valid_name
($name)) {
43 print "<p>Invalid project name. Go away, sorcerer.</p>\n";
47 if (!Girocco
::Project
::does_exist
($name,1)) {
48 print "<p>Sorry but the project $name does not exist. Now, how did you <em>get</em> here?!</p>\n";
52 my $proj = Girocco
::Project
->load($name);
54 print "<p>not found project $name, that's really weird!</p>\n";
57 push(@Girocco::Config
::project_fields
, "notifycia")
58 if $proj->{notifycia
} && !grep(/notifycia/, @Girocco::Config
::project_fields
);
60 $escname =~ s/[+]/%2B/g;
62 my $y0 = $cgi->param('y0') || '';
63 if (($y0 eq 'Update' || $y0 eq 'Restart Mirroring') && $cgi->request_method eq 'POST') {
64 # submitted, let's see
65 my $utc = strftime
('%Y-%m-%d %H:%M:%S UTC', (gmtime(time()))[0..5], -1, -1, -1);
66 my $ts = "<span class=\"timestamp\">$utc</span>";
67 $gcgi->err_prelude("<p class=\"failed\">Project update failed at $ts.</p>\n");
68 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
69 print "<p class=\"updated\">Project successfully updated at $ts.</p>\n";
70 if ($proj->{clone_failed
}) {
72 print "<p>Please <a href=\"@{[url_path($Girocco::Config::webadmurl)]}".
73 "/mirrorproj.cgi?name=$escname\">pass onwards</a>.</p>\n";
74 print "<script language=\"javascript\">document.location=".
75 "'@{[url_path($Girocco::Config::webadmurl)]}/mirrorproj.cgi?name=$escname'</script>\n";
81 # $proj may be insane now but that's actually good for us since we'll let the
82 # user fix the invalid values he or she entered
83 my %h = $proj->form_defaults;
86 <p>Here you may adjust the settings of project $h{name}. Go wild.
88 if ($proj->{mirror
}) {
90 Since this is a mirrored project, you may opt to remove it from the site as well.
91 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
94 if ($proj->is_empty) {
96 Since this is an empty project, you may opt to remove it from the site as well.
97 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
102 <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">request an authorization code</a> in order
103 to remove this project from the site.</p>
107 <p>Use the <b>+</b> button to enable access for more than a single user at a time.</p>
111 my $button_label = $proj->{clone_failed
} ?
'Restart Mirroring' : 'Update';
112 my $showstatusopt = $proj->{mirror
} && !$proj->{clone_failed
} && !$proj->{clone_in_progress
};
113 my $statuschecked = $proj->{statusupdates
} ?
'checked="checked"' : '';
116 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/editproj.cgi">
118 <tr><td class="formlabel">Project name:</td><td class="formdata"><a
119 href="@{[url_path($Girocco::Config::gitweburl)]}/$h{name}.git">$h{name}</a>.git
120 <input type="hidden" name="name" value="$h{name}" /></td></tr>
122 if ($Girocco::Config
::project_passwords
) {
124 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
125 <input type="password" name="cpwd" /> <sup><a
126 href="@{[url_path($Girocco::Config::webadmurl)]}/pwproj.cgi?name=$escname"
127 class="ctxaction">(forgot password?)</a></sup></td></tr>
128 <tr><td class="formlabel">New admin password (twice):<br />
129 <em>(leave empty to keep it the same)</em></td><td>
130 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
134 if ($Girocco::Config
::project_owners
eq 'email') {
136 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
140 if ($proj->{mirror
}) {
141 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
142 print '<tr><td class="formlabel">Mirror refs:</td><td class="formdatatd">'.
143 '<label title="Unchecking this will mirror the entire refs namespace which is usually unnecessary. '.
144 'Non-git sources always mirror the entire refs namespace regardless of this setting.">'.
145 '<input type="checkbox" name="cleanmirror" value="1" '.($h{'cleanmirror'} ?
'checked="checked" ' : '').
146 'style="vertical-align:middle" /><span style="vertical-align:middle; margin-left:0.5ex">'.
147 'Only mirror <code>refs/heads/*</code>, <code>refs/tags/*</code> and <code>refs/notes/*</code></span></label></td></tr>'."\n"
148 if grep(/cleanmirror/, @Girocco::Config
::project_fields
);
151 <tr><td class="formlabel" style="vertical-align:middle">Users:</td><td>
154 $Girocco::Config
::manage_users
and print "<p>Only <a href=\"".
155 "@{[url_path($Girocco::Config::webadmurl)]}/reguser.cgi\">registered users</a> may push.</p>";
156 if ($Girocco::Config
::mob
and not grep { $_ eq $Girocco::Config
::mob
} @
{$h{users
}}) {
157 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
158 print "<sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>)\n";
161 foreach my $user (@
{$h{users
}}) {
163 $mlm = " <sup><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></sup>"
164 if $Girocco::Config
::mob
&& $user eq $Girocco::Config
::mob
;
165 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user$mlm</li>\n";
168 <li>Add user: <input type="text" name="user" /></li>
169 <button type="button" onclick="adduseritem(this)"><b>+</b></button>
175 print '<tr><td class="formlabel">Default branch:</td><td><select size="1" name="HEAD">';
176 for ($proj->get_heads) {
177 my $selected = $proj->{HEAD
} eq $_ ?
' selected="selected"' : '';
178 print "<option$selected>".Girocco
::CGI
::html_esc
($_)."</option>";
180 print '</select></td></tr>
183 print '<tr><td class="formlabel">Tags (select to delete):</td><td>';
184 print '<select size="6" name="tags" multiple="multiple">';
185 for ($proj->get_ctag_names) {
186 print '<option>'.Girocco
::CGI
::html_esc
($_).'</option>';
188 print '</select></td></tr>
192 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, \
%h, @Girocco::Config
::project_fields
);
193 print <<EOT if $showstatusopt;
194 <tr><td class="formlabel">Enable status update emails:</td>
195 <td class="formdatatd"
196 ><input type="hidden" name="setstatusupdates" value="1"
197 /><input type="checkbox" name="statusupdates" value="1" $statuschecked /></td></tr>
200 <tr><td class="formlabel"></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>