/[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 7 by dpavlin, Wed Dec 12 13:09:29 2007 UTC revision 9 by dpavlin, Wed Dec 12 13:22:32 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;          $body =~ s/^\s+([\*])/$1/gm;
93    
94            # fix links
95            $body =~ s/\["([^"]+)"\]/[$1]/gs;
96    
97          Encode::_utf8_off( $body );          Encode::_utf8_off( $body );
98    
99          my @tags = ( 'TamTam' );          my @tags = ( 'TamTam' );
100    
101          if ( $name =~ m!/! ) {          if ( $name =~ m!/! ) {
102                  my @page_tags = split(m!/!, $name);                  my @page_tags = split(m!/!, $name);
103                  pop @page_tags; # remove page name                  $name = pop @page_tags; # remove page name
104                  push @tags, @page_tags;                  push @tags, @page_tags;
                 $name =~ s!/!_!g;  
105          }          }
106    
107          $Rester->put_page( $name, {          $Rester->put_page( $name, {

Legend:
Removed from v.7  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26