=pod

=head1 EXPORTS

=over 4

=cut


=pod

=item B<auto_edit_custom>

Custom auto-editing.  If you have any files outside of C<source_dir> that need auto-editing,
edit them here.  Otherwise this is a no-op.

=cut

sub auto_edit_custom()
{
    use File::Find ();

    my $from_dir = '/home/mike/work/votorola'; # I don't want the common auto_edit to run here, because it descends links, and it's too much of a pain to code custom restrictions negatively # easier to do it positively here
    File::Find::find( {no_chdir=>1, wanted=>sub
    {
        my $file = $File::Find::name;
        root_filter:
        {
            $file eq $from_dir . '/s/_/example_template/_autoindex-summary.html' and last;
            return; # exclude all others
        }

        auto_edit_found(); # edit the remainder, as usual
    }}, $from_dir );
}



=pod

=item B<response_for_voter_command>( $I<service_class>, $I<voter_command> )

Returns the response text for the specified $I<voter_command>.  The command is issued to
any instance of the given $I<service_class>, using the C<voter> shell.

You may return '' here.  The auto-edit request will simply be skipped, leaving that
particular portion of the source document unmodified.  (This is recommended.)

=cut

sub response_for_voter_command( $$ )
{
    use votorola::b::AutoEditor qw( $auto_edit_top $begin @buffer $is_buffer_changed );
    my $service_class = shift;
    my $voter_command = shift;

    # uncomment this to skip auto-editing of voter command docs
  # return '';

    my $voter_email = 'sim-auto-edit@zelea.com'; # dummy email address, any will do
    my $service_name = _service_for_class( $service_class );
    my $voteServer = $service_class eq 'votorola.s.mail.MailMetaService'? 'vdev': 'voff'; # prefer voff, as it is my minimal config # but only vdev has meta service
    my $command = "sudo -u $voteServer  /home/mike/var/deploy/votorola/votorola/s/_/bin/voter $voter_email $service_name $voter_command";
    my $response = `$command` or die "unable to execute command '$command'";
    return $response;
}



=pod

=item B<_service_for_class>( $I<service_class> ) returns $I<service_name>

Returns a particular $I<service_name> for a general $I<service_class>.  Customize this to
use your own service names, from your dev vote-server.

=cut

sub _service_for_class( $ )
{
    my $service_class = shift;
    $service_class eq 'votorola.s.mail.MailMetaService' and return 'mail';
    $service_class eq 'votorola.a.count.PollService' and return 'Sys/p/sandbox';
#   $service_class eq 'votorola.a.register.Register' and return 'register';
    die "you probably need to add a line here, for service class: " . $service_class;
}



=pod

=back

=cut

1;