PPresenter

 view release on metacpan or  search on metacpan

PPresenter/Export/Website/HTML.pm  view on Meta::CPAN

    <TD ALIGN=right>$row2.</TD>
    <TD>$links->[$row2]</TD></TR>
col2
    <TD COLSPAN=2>&nbsp;</TD></TR>
empty

    }

    <<index;
<CENTER>
<TABLE WIDTH=80%>
<TR><TH COLSPAN=2 ALIGN=left>Slides:</TH></TR>
@rows
</TABLE>
</CENTER>
index

}

sub Signature($$)
{   my ($export, $show, $slide) = @_;
    my $date      = localtime;
    my $slidename = $slide ? "$slide" : '';
    my $showname  = "$show";

    my $title     = $slidename eq ''        ? $showname
                  : $slidename eq $showname ? $slidename
                  : "$showname, $slidename";

    <<signature;
<I>$title.<BR>
   Generated by <A HREF="http://ppresenter.org">ppresenter</A>
   on $date.</I><BR>
signature
}

sub SlideImage($$$)
{   my ($export, $image, $slide, $view) = @_;

    my $viewport = $view->viewport;
    $viewport    =~ s/\W/_/g;

    my $file     = $viewport . '.' . lc($export->{-imageFormat});
    my $path     = $export->{-outputDir} . '/'
                 . $export->slideDir($slide) . '/'
                 . $file;

    $export->writeImage($image, $path);
    my ($width, $height) = $image->Get('width', 'height');

    <<include;
<IMG SRC="$file" WIDTH=$width HEIGHT=$height
 BORDER=0 HSPACE=15 VSPACE=15 ALIGN=center><P>
include
}

#
# The user interface to this module.
#

sub popup($$)
{   my ($export, $show, $screen) = @_;
    return $export->{popup}
        if exists $export->{popup};

    if($show->hasImageMagick)
    {   require PPresenter::Export::Images::ImageMagick;
        unshift @ISA, 'PPresenter::Export::Images::ImageMagick';
    }
    else
    {   require PPresenter::Export::Images::Tk;
        unshift @ISA, 'PPresenter::Export::Images::Tk';
    }

    $export->{popup} = my $popup = MainWindow->new(-screen => $screen
    , -title => 'Create a Website'
    );
    $popup->withdraw;

    my $vp  = $export->tkViewportSettings($show, $popup);
    my $fmt = $export->tkImageSettings($show,$popup);

    my $options = $popup->LabFrame
        ( -label     => "Don't know"
        , -labelside => 'acrosstop'
        );

    $options->Label
    ( -text     => 'export'
    , -anchor   => 'e'
    )->grid( $export->tkSlideSelector($popup)
           , -sticky => 'ew');

    $options->Label
    ( -text     => 'output directory'
    , -anchor   => 'e'
    )->grid( $options->Entry(-textvariable => \$export->{-outputDir})
           , -sticky => 'ew');

    $options->Label
    ( -text     => 'index file'
    , -anchor   => 'e'
    )->grid( $options->Entry(-textvariable => \$export->{-indexFile})
           , -sticky => 'ew');

    $options->Label
    ( -text     => 'slides as'
    , -anchor   => 'e'
    )->grid( $export->tkSlideFormatting($options, $show, 'slideAs')
           , -sticky => 'ew');

    if($show->containsSlideNotes)
    {   $options->Label
        ( -text     => 'notes as'
        , -anchor   => 'e'
        )->grid( $export->tkSlideFormatting($options, $show, 'notesAs')
               , -sticky => 'ew');
    }

    my $commands = $popup->Frame;
    $commands->Button
    ( -text      => 'Export'
    , -relief    => 'ridge'
    , -command   => sub { $popup->withdraw;
                          $export->makeSlides($show, $popup);
                        }
    )->grid($commands->Button
       ( -text      => 'Cancel'
       , -relief    => 'sunken'
       , -command   => sub {$popup->withdraw}
       )
       , -padx => 10, -pady => 10
    );

    $vp->pack(-fill => 'x') if $vp;
    $options->pack(-fill => 'x');
    $fmt->pack(-fill => 'x');
    $commands->pack(-fill => 'x');

    $popup->Popup(popover => 'cursor');
}

sub tkSlideFormatting($$$)
{   my ($export, $parent, $show, $label) = @_;

    my @options;
    # first slide used as standard for show, which is incorrect... but it
    # is hard to decide differently.  I do not expect many people will
    # change to incompatible formatters or templates within the show.

    my $view    = $show->find(slide => 'FIRST')->view('FIRST');
    my $linear  = $view->formatter->can('makeHTMLLinear');
    my $table   = $view->template->can('makeHTMLTable');

    push @options, 'image'     if $export->can('view2image');
    push @options, 'table'     if $table && $view->formatter->can('toHTML');
    push @options, 'flat text' if $linear;
    push @options, 'skip';

    $parent->Optionmenu
    ( -options  => \@options
    , -variable => \$export->{$label}
    , -command  => sub { $export->setSlideFormatting($label, shift) }
    );
}

sub setSlideFormatting($$$)
{   my ($export, $label, $option) = @_;
    $export->{"-$label"}
        = $option eq 'table'     ? 'TABLE'
        : $option eq 'flat text' ? 'LINEAR'
        : $option eq 'image'     ? 'IMAGE'
        : $option eq 'skip'      ? 'SKIP'
        : die "Unknown export option `$option'.\n";
}

sub slideFormatting($$)
{   my ($export, $value) = @_;
      $value eq 'TABLE'  ? 'table'
    : $value eq 'LINEAR' ? 'flat text'
    : $value eq 'IMAGE'  ? 'image'
    : $value eq 'SKIP'   ? 'skip'
    : undef
}

1;



( run in 1.176 second using v1.01-cache-2.11-cpan-364913b4093 )