/[socialtext-import]/tamtam/tamtam2socialtext.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /tamtam/tamtam2socialtext.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by dpavlin, Wed Dec 12 12:48:42 2007 UTC revision 10 by dpavlin, Wed Dec 12 13:28:40 2007 UTC
# Line 11  use Encode; Line 11  use Encode;
11  use HTTP::Date;  use HTTP::Date;
12  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
13    
14  my $max = 2;  my $max = 5;
15    
16  my $page;  my $page;
17  my $page_date;  my $page_date;
18    
19    my @page_names;
20    
21  find({  find({
22          wanted => sub {          wanted => sub {
23                  my $path = $File::Find::name;                  my $path = $File::Find::name;
# Line 25  find({ Line 27  find({
27                  my $ref = XMLin( $path ) || die "can't open $path: $!";                  my $ref = XMLin( $path ) || die "can't open $path: $!";
28    
29                  my $name = $ref->{name} || die "no name in $path";                  my $name = $ref->{name} || die "no name in $path";
30    
31                    return if $name =~ m/^TamSystem/;
32    
33                  my $date =  $ref->{meta}->{LastModified};                  my $date =  $ref->{meta}->{LastModified};
34                  if ( ! $date ) {                  if ( ! $date ) {
35                          warn "SKIP: no LastModified in $path $name";                          warn "SKIP: no LastModified in $path $name";
# Line 83  foreach my $name ( keys %$page ) { Line 88  foreach my $name ( keys %$page ) {
88          $body =~ s/'''(.+?)'''/surround('*',$1)/gse;          $body =~ s/'''(.+?)'''/surround('*',$1)/gse;
89          $body =~ s/''(.+?)''/surround('_',$1)/gse;          $body =~ s/''(.+?)''/surround('_',$1)/gse;
90    
91            # fix bullets
92            $body =~ s/^\s+([\*])/$1/gm;
93    
94            # fix links
95            $body =~ s/\["([^"]+)"\]/[$1]/gs;
96            $body =~ s,\[(http://\S+)\s+([^\]]+)\],"$2"<$1>,gs;
97            $body =~ s,\[(http://[^\]]+)\],$1,gs;
98    
99          Encode::_utf8_off( $body );          Encode::_utf8_off( $body );
100    
101          my @tags = ( 'TamTam' );          my @tags = ( 'TamTam' );
102    
103          if ( $name =~ m!/! ) {          if ( $name =~ m!/! ) {
104                  my @page_tags = split(m!/!, $name);                  my @page_tags = split(m!/!, $name);
105                  pop @page_tags; # remove page name                  $name = pop @page_tags; # remove page name
106                  push @tags, @page_tags;                  push @tags, @page_tags;
                 $name =~ s!/!_!g;  
107          }          }
108    
109          $Rester->put_page( $name, {          $Rester->put_page( $name, {

Legend:
Removed from v.6  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26