--- tamtam/tamtam2socialtext.pl 2007/12/12 23:08:14 19 +++ tamtam/tamtam2socialtext.pl 2007/12/13 11:46:46 23 @@ -12,10 +12,18 @@ use POSIX qw/strftime/; use File::Slurp; use File::MMagic::XS; +use Getopt::Long; use Data::Dump qw/dump/; my $debug = 0; my $max = 999; +my $attachments = 0; + +GetOptions( + 'debug+' => \$debug, + 'max=i' => \$max, + 'attachments' => \$attachments, +); my $page; my $page_date; @@ -35,7 +43,7 @@ 'attachment' => '+name', 'meta' => 'name', }, - ForceArray => [ 'attachment', 'widget' ], + ForceArray => [ 'attachment', 'meta', 'widget' ], ) || die "can't open $path: $!"; warn "## $path = ",dump( $ref ) if $debug; @@ -189,9 +197,10 @@ $body =~ s,``,,gs; $body .= qq{ + ---- -Original http://www.razmjenavjestina.org/$full_name {date: $date} +"original" {date: $date} }; Encode::_utf8_off( $body ); @@ -202,11 +211,14 @@ $Rester->put_pagetag( $name, $_ ); print "+ tag $_\n"; } - foreach my $a ( @{ $p->{attachments} } ) { - my $type = $m->get_mime( $a->{full_path} ); - my $content = read_file( $a->{full_path} ); - print "+ attachment ", $a->{name}," $type ", length($content), " bytes\n"; - $Rester->post_attachment($name, $a->{name}, $content, $type ); + + if ( $attachments ) { + foreach my $a ( @{ $p->{attachments} } ) { + my $type = $m->get_mime( $a->{full_path} ); + my $content = read_file( $a->{full_path} ); + print "+ attachment ", $a->{name}," $type ", length($content), " bytes\n"; + $Rester->post_attachment($name, $a->{name}, $content, $type ); + } } }