--- tamtam/tamtam2socialtext.pl 2007/12/12 13:28:40 10 +++ tamtam/tamtam2socialtext.pl 2007/12/12 14:04:11 11 @@ -11,7 +11,7 @@ use HTTP::Date; use Data::Dump qw/dump/; -my $max = 5; +my $max = 999; my $page; my $page_date; @@ -42,13 +42,19 @@ $page->{ $name } = [ $data, $date ]; + # strip path from page name + $name =~ s,^.+/([^/]+)$,$1,; + push @page_names, $name; + #warn dump( $ref ); }, }, shift @ARGV || '.'); my @pages = ( keys %$page ); -warn "found following pages: ", join(", ", @pages),"\n"; +warn "found following pages: ", join(", ", @page_names),"\n"; + +my $page_link_re = '\b(' . join('|', @page_names) . ')\b'; my $Rester = Socialtext::Resting->new( username => 'tamtam', @@ -64,7 +70,7 @@ my $level = length($1); return "\n" . ( '^' x $level ) . " $2\n"; } else { - die "can't parse header: $h"; + return $h; } } @@ -95,6 +101,7 @@ $body =~ s/\["([^"]+)"\]/[$1]/gs; $body =~ s,\[(http://\S+)\s+([^\]]+)\],"$2"<$1>,gs; $body =~ s,\[(http://[^\]]+)\],$1,gs; + $body =~ s,$page_link_re,[$1],gs; Encode::_utf8_off( $body );