From 8e1a421694b6d436989797727ca65cb378e16e58 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 7 Jun 2016 04:55:39 -0700 Subject: [PATCH] Projects: enable gui editing of hooks.summaryonly field Signed-off-by: Kyle J. McKay --- Girocco/CGI.pm | 11 ++++++++--- Girocco/Config.pm | 4 ++-- Girocco/Project.pm | 13 ++++++++++++- cgi/editproj.cgi | 2 +- cgi/regproj.cgi | 1 + html/girocco.css | 7 +++++-- 6 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Girocco/CGI.pm b/Girocco/CGI.pm index bd7afb6..6c54452 100644 --- a/Girocco/CGI.pm +++ b/Girocco/CGI.pm @@ -221,13 +221,18 @@ sub print_form_fields { if (defined($field->[3]) && $field->[3] ne '') { $title=' title="'.html_esc($field->[3], 1).'"' } - print ''.$field->[0].':'; + print ''.$field->[0].':'; if ($field->[2] eq 'text') { - print ''; + } elsif ($field->[2] eq 'checkbox') { + print '{$field->[1]}; + printf ' value="%s"', ($valuemap && $valuemap->{$field->[1]} ? $valuemap->{$field->[1]} : "1"); + print ' />'; } else { - print ''; } diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 5493728..a80b48b 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -211,10 +211,10 @@ our $project_passwords = 1; our $project_owners = 'email'; # Which project fields to make editable, out of 'shortdesc', 'homepage', -# 'README', 'notifymail', 'notifytag' and 'notifyjson' +# 'README', 'notifymail', 'summaryonly', 'notifytag' and 'notifyjson' # 'notifycia' was used by the now defunct CIA service and while allowing it to # be edited does work and the value is saved, the value is totally ignored by Girocco -our @project_fields = qw(homepage shortdesc README notifymail notifytag notifyjson); +our @project_fields = qw(homepage shortdesc README notifymail summaryonly notifytag notifyjson); # Minimal number of seconds to pass between two updates of a project. our $min_mirror_interval = 3600; # 1 hour diff --git a/Girocco/Project.pm b/Girocco/Project.pm index ec95498..855fda7 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -42,6 +42,8 @@ our $metadata_fields = { 'to completely suppress any README'], notifymail => ['Commit notify – mail to', 'notifymail', 'text', 'comma separated address list'], + summaryonly => ['Summaries only', 'summaryonly', 'checkbox', + 'suppress patch/diff output in “Commit notify” email when showing new revisions'], notifytag => ['Tag notify – mail to', 'notifytag', 'text', 'comma separated address list – if not empty, tag '. 'notifications are sent here INSTEAD of to '. @@ -148,7 +150,7 @@ sub _boolval { defined($val) or $val = $def; $val =~ s/\s+//gs; $val = lc($val); - return 0 if $val eq '' || $val eq 'false' || $val eq 'off' || $val =~ /^0+$/; + return 0 if $val eq '' || $val eq 'false' || $val eq 'off' || $val eq 'no' || $val =~ /^0+$/; return 1; } @@ -244,6 +246,7 @@ sub _properties_load { $self->_readlocalconfigfile unless ref($self->{configfilehash}) eq 'HASH'; $self->{statusupdates} = _boolval($self->{configfilehash}->{'gitweb.statusupdates'}, 1); + $self->{summaryonly} = _boolval($self->{configfilehash}->{'hooks.summaryonly'}, 0); delete $self->{auth}; my $val = $self->{configfilehash}->{'gitweb.repoauth'}; defined($val) or $val = ''; @@ -269,6 +272,10 @@ sub _properties_save { unless defined($self->{statusupdates}) && $self->{statusupdates} =~ /^\d+$/; system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', '--bool', "gitweb.statusupdates", $self->{statusupdates}); + $self->{summaryonly} = 0 + unless defined($self->{summaryonly}) && $self->{summaryonly} =~ /^\d+$/; + system($Girocco::Config::git_bin, '--git-dir='.$self->{path}, 'config', '--bool', + "hooks.summaryonly", $self->{summaryonly}); if (defined($self->{origurl}) && defined($self->{url}) && $self->{origurl} ne $self->{url} && -e $self->_property_path(".banged")) { if (open($fd, '>', $self->_property_path(".bangagain"))) { @@ -662,6 +669,9 @@ sub cgi_fill { (valid_email_multi($self->{notifymail}) and length($self->{notifymail}) <= 512) or $gcgi->err("Invalid notify e-mail address. Use mail,mail to specify multiple addresses; total length must not exceed 512 characters, however."); } + if ($field_enabled->('summaryonly')) { + $self->{summaryonly} = $gcgi->wparam('summaryonly') || 0; + } } if ($field_enabled->('notifytag')) { @@ -707,6 +717,7 @@ sub form_defaults { hp => $self->{hp}, users => $self->{users}, notifymail => html_esc($self->{notifymail}), + summaryonly => html_esc($self->{summaryonly}), notifytag => html_esc($self->{notifytag}), notifyjson => html_esc($self->{notifyjson}), notifycia => html_esc($self->{notifycia}), diff --git a/cgi/editproj.cgi b/cgi/editproj.cgi index 66a069f..3f41849 100755 --- a/cgi/editproj.cgi +++ b/cgi/editproj.cgi @@ -183,7 +183,7 @@ print ' $gcgi->print_form_fields($Girocco::Project::metadata_fields, \%h, @Girocco::Config::project_fields); print <Enable status update emails: - EOT diff --git a/cgi/regproj.cgi b/cgi/regproj.cgi index ce04226..8dd9984 100755 --- a/cgi/regproj.cgi +++ b/cgi/regproj.cgi @@ -34,6 +34,7 @@ my %values = ( hp => '', mirror => $mirror_mode_set, notifymail => '', + summaryonly => '', notifytag => '', notifyjson => '', notifycia => '', diff --git a/html/girocco.css b/html/girocco.css index 445bf88..a9b410f 100644 --- a/html/girocco.css +++ b/html/girocco.css @@ -46,12 +46,15 @@ div.htmlcgi h4 { line-height: 1.75em; } -.formdata { +.formdata, .formdatatd { padding-top: 0.3em; - padding-left: 0.75em; line-height: 1.75em; } +.formdata { + padding-left: 0.75em; +} + .ctxaction { text-decoration: none; } -- 2.11.4.GIT