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";
58 $escname =~ s/[+]/%2B/g;
60 my $tzoffset = $cgi->param('tzoffset') || 0;
61 $tzoffset =~ /^[-+]?\d{1,5}$/ or $tzoffset = 0;
62 $tzoffset = 0 + $tzoffset;
63 $tzoffset >= -43200 && $tzoffset <= 43200 or $tzoffset = 0;
67 defined($es) or $es = time();
69 my $str = strftime
("%Y-%m-%d %H:%M:%S ", (gmtime($es))[0..5], -1, -1, -1);
71 my $moff = int(abs($tzoffset) / 60);
72 $str .= sprintf("%s%02d%02d",
73 ($tzoffset >= 0 ?
"+" : "-"),
75 $moff - 60 * int($moff / 60));
82 my $y0 = $cgi->param('y0') || '';
83 if (($y0 eq 'Update' || $y0 eq 'Restart Mirroring') && $cgi->request_method eq 'POST') {
84 # submitted, let's see
85 my $ts = "<span class=\"timestamp\">" . format_epoch_ts
() . "</span>";
86 $gcgi->err_prelude("<p class=\"failed\">Project update failed at $ts.</p>\n");
87 if ($proj->cgi_fill($gcgi) and $proj->authenticate($gcgi) and $proj->update) {
88 print "<p class=\"updated\">Project successfully updated at $ts.</p>\n";
89 if ($proj->{clone_failed
}) {
91 print "<p>Please <a href=\"@{[url_path($Girocco::Config::webadmurl)]}".
92 "/mirrorproj.cgi?name=$escname\">pass onwards</a>.</p>\n";
93 print "<script language=\"javascript\">document.location=".
94 "'@{[url_path($Girocco::Config::webadmurl)]}/mirrorproj.cgi?name=$escname'</script>\n";
100 # $proj may be insane now but that's actually good for us since we'll let the
101 # user fix the invalid values he or she entered
102 my %h = $proj->form_defaults;
105 <p>Here you may adjust the settings of project $h{name}. Go wild.
107 if ($proj->{mirror
}) {
109 Since this is a mirrored project, you may opt to remove it from the site as well.
110 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
113 if ($proj->is_empty) {
115 Since this is an empty project, you may opt to remove it from the site as well.
116 Just <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">remove it</a>.</p>
121 <a href="@{[url_path($Girocco::Config::webadmurl)]}/delproj.cgi?name=$escname">request an authorization code</a> in order
122 to remove this project from the site.</p>
126 <p>Use the <b>+</b> button to enable access for more than a single user at a time.</p>
130 my $button_label = $proj->{clone_failed
} ?
'Restart Mirroring' : 'Update';
131 my $showstatusopt = $proj->{mirror
} && !$proj->{clone_failed
} && !$proj->{clone_in_progress
};
132 my $statuschecked = $proj->{statusupdates
} ?
'checked="checked"' : '';
135 <form method="post" action="@{[url_path($Girocco::Config::webadmurl)]}/editproj.cgi">
136 <input type="hidden" name="tzoffset" value="0" />
138 <tr><td class="formlabel">Project name:</td><td class="formdata"><a
139 href="@{[url_path($Girocco::Config::gitweburl)]}/$h{name}.git">$h{name}</a>.git
140 <input type="hidden" name="name" value="$h{name}" /></td></tr>
142 if ($Girocco::Config
::project_passwords
) {
144 <tr><td class="formlabel"><strong>Admin password:</strong></td><td>
145 <input type="password" name="cpwd" /> <sup class="sup"><span><a
146 href="@{[url_path($Girocco::Config::webadmurl)]}/pwproj.cgi?name=$escname"
147 class="ctxaction">(forgot password?)</a></span></sup></td></tr>
148 <tr><td class="formlabel">New admin password (twice):<br />
149 <em>(leave empty to keep it the same)</em></td><td>
150 <input type="password" name="pwd" /><br /><input type="password" name="pwd2" /><br />
154 if ($Girocco::Config
::project_owners
eq 'email') {
156 <tr><td class="formlabel">E-mail contact:</td><td><input type="text" name="email" value="$h{email}" /></td></tr>
160 if ($proj->{mirror
}) {
161 print "<tr><td class=\"formlabel\">Repository URL:</td><td><input type=\"text\" name=\"url\" value=\"$h{url}\" /></td></tr>\n";
162 print '<tr><td class="formlabel">Mirror refs:</td><td class="formdatatd">'.
163 '<label title="Unchecking this will mirror the entire refs namespace which is usually unnecessary. '.
164 'Non-git sources always mirror the entire refs namespace regardless of this setting.">'.
165 '<input type="checkbox" name="cleanmirror" value="1" '.($h{'cleanmirror'} ?
'checked="checked" ' : '').
166 'style="vertical-align:middle" /><span style="vertical-align:middle; margin-left:0.5ex">'.
167 'Only mirror <code>refs/heads/*</code>, <code>refs/tags/*</code> and <code>refs/notes/*</code></span></label></td></tr>'."\n"
168 if grep(/cleanmirror/, @Girocco::Config
::project_fields
);
171 <tr><td class="formlabel" style="vertical-align:middle">Users:</td><td>
174 $Girocco::Config
::manage_users
and print "<p>Only <a href=\"".
175 "@{[url_path($Girocco::Config::webadmurl)]}/reguser.cgi\">registered users</a> may push.</p>";
176 if ($Girocco::Config
::mob
and not grep { $_ eq $Girocco::Config
::mob
} @
{$h{users
}}) {
177 print "<p><em>(Please consider adding the <tt>$Girocco::Config::mob</tt> user.\n";
178 print "<sup class=\"sup\"><span><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></span></sup>)\n";
181 foreach my $user (@
{$h{users
}}) {
183 $mlm = " <sup class=\"sup\"><span><a href=\"@{[url_path($Girocco::Config::htmlurl)]}/mob.html\">(learn more)</a></span></sup>"
184 if $Girocco::Config
::mob
&& $user eq $Girocco::Config
::mob
;
185 print "<li><input type=\"checkbox\" name=\"user\" value=\"$user\" checked=\"1\" /> $user$mlm</li>\n";
188 <li>Add user: <input type="text" name="user" /></li>
189 <button type="button" onclick="adduseritem(this)"><b>+</b></button>
195 print '<tr><td class="formlabel">Default branch:</td><td><select size="1" name="HEAD">';
196 for ($proj->get_heads) {
197 my $selected = $proj->{HEAD
} eq $_ ?
' selected="selected"' : '';
198 print "<option$selected>".Girocco
::CGI
::html_esc
($_)."</option>";
200 print '</select></td></tr>
203 print '<tr><td class="formlabel">Tags (select to delete):</td><td>';
204 print '<select size="6" name="tags" multiple="multiple">';
205 for ($proj->get_ctag_names) {
206 print '<option>'.Girocco
::CGI
::html_esc
($_).'</option>';
208 print '</select></td></tr>
212 $gcgi->print_form_fields($Girocco::Project
::metadata_fields
, \
%h, @Girocco::Config
::project_fields
);
213 print <<EOT if $showstatusopt;
214 <tr><td class="formlabel">Enable status update emails:</td>
215 <td class="formdatatd"
216 ><input type="hidden" name="setstatusupdates" value="1"
217 /><input type="checkbox" name="statusupdates" value="1" $statuschecked /></td></tr>
220 <tr><td class="formlabel"></td><td><input type="submit" name="y0" value="$button_label" /></td></tr>
223 <script type="text/javascript">
226 var tzoffset = (new Date).getTimezoneOffset() * -60;
227 var form0 = document.forms[0];
228 if (form0 && form0.tzoffset) {
229 form0.tzoffset.value = tzoffset;