Tk-MIMEApp

 view release on metacpan or  search on metacpan

lib/Tk/MIMEApp.pm  view on Meta::CPAN

package Tk::MIMEApp;
use base qw(Tk::Derived Tk::NoteBook);
use IO::File;
use MIME::Multipart::Parse::Ordered;
use Tk::MarkdownTk;
use YAML::Perl;
use Tk qw(Ev);

use 5.006;
use strict;
use warnings FATAL => 'all';

=head1 NAME

Tk::MIMEApp - The great new Tk::MIMEApp!

=head1 VERSION

Version 0.04

=cut

our $VERSION = '0.04';

our @Shelf = (); # we'll put our books here!

Construct Tk::Widget 'MIMEApp';

=head1 SYNOPSIS

ISA Tk::Notebook.  Can load MIME Multipart file with
application/x-ptk.markdown parts, converting them to
Tk (with Tk::MarkdownTk) for document-driven applications.

=head1 SUBROUTINES/METHODS

=head2 loadMultipart

Method that takes a filehandle and adds a page to the notebook
for each application/x-ptk.markdown part.  Will also add menu items
to the toplevel menu for application/x-yaml.menu parts.

=cut

sub loadMultipart {
  # load a MIME-multipart-style file containing at least one application/x-ptk.markdown
  my ($o,$fh) = @_;
  $o->{Objects} = {};
  push @Shelf, $o;
  my $mmps = MIME::Multipart::Parse::Ordered->new();
  my $parts = $o->{parts} = $mmps->parse($fh); # now an array... content is in $parts->[$i]->{Body}

  foreach my $part(@$parts){
    my $ct = $part->{'Content-Type'};
    if($ct eq "application/x-ptk.markdown"){

      # work out the IDs
      my $id = exists $part->{'ID'} ? $part->{'ID'} : "O$part";
      my $textid = $id.'_text';
      my $pageid = $id.'_page';

      # set up the page



( run in 1.417 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )