/[webpac2]/trunk/sql/pgbits.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 /trunk/sql/pgbits.pl

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

revision 36 by dpavlin, Tue Aug 2 00:42:14 2005 UTC revision 37 by dpavlin, Tue Aug 2 15:20:44 2005 UTC
# Line 11  my $self = { Line 11  my $self = {
11          user => 'dpavlin',          user => 'dpavlin',
12          passwd => '',          passwd => '',
13          catalog => {          catalog => {
14                  path => '/rest/references/PgGeneratBits/bits',                  name    => 'PostgreSQL General Bits',
15                  title   => 'PostgreSQL General Bits',                  path    => '/rest/references/PgGeneratBits/bits',
16                  uri     => 'http://www.varlena.com/varlena/GeneralBits/archive.php',                  uri     => 'http://www.varlena.com/varlena/GeneralBits/archive.php',
17                    type    => 'pgbits',
18          },          },
19  };  };
20    
# Line 28  my $l = Class::DBI::Loader->new( Line 29  my $l = Class::DBI::Loader->new(
29          relationships   => 1,          relationships   => 1,
30  );  );
31    
32  my $this_catalog = $l->find_class('catalog_webarchive')->find_or_create( $self->{catalog} );  my $top = $l->find_class('topics_webarchive')->find_or_create( $self->{catalog} );
33  $this_catalog->dbi_commit;  $top->dbi_commit;
34    
35  sub issue {  sub issue {
36          my $file = shift || die;          my $file = shift || die;
# Line 43  sub issue { Line 44  sub issue {
44                  $issue_date = $1;                  $issue_date = $1;
45  print "## issue $issue_no on $issue_date [$file]\n";  print "## issue $issue_no on $issue_date [$file]\n";
46    
47                  $this_entry = $l->find_class('entries_pgbits')->find_or_create(                  $issue = $l->find_class('topics_pgbits')->find_or_create(
48                            name => "issue $issue_no",
49                          date => $issue_date,                          date => $issue_date,
                         issue => $issue_no,  
50                          path => $file,                          path => $file,
51                          title => $self->{catalog}->{title} . " :: $issue_no",                          issue => $issue_no,
52                            type => 'pgbits',
53                            parent_id => $top->id,
54                  );                  );
55                  $this_entry->dbi_commit;                  $issue->dbi_commit;
56    
                 $l->find_class('catalog_entry')->find_or_create(  
                         catalog_id => $this_catalog->id,  
                         entry_id => $this_entry->id,  
                         e_type => 'pgbits',  
                 )->dbi_commit;  
57          } else {          } else {
58                  warn "can't find issue number and date in $file, skipping\n";                  warn "can't find issue number and date in $file, skipping\n";
59                  return;                  return;
# Line 64  print "## issue $issue_no on $issue_date Line 62  print "## issue $issue_no on $issue_date
62    
63          while($html =~ s#^.*?<!-- IKEY="([^"]+)" -->.+?<MYTITLE>\s*([^<]+)\s*</MYTITLE>.+?<ITITLE>\s*([^<]+)\s*</ITITLE>.+?<IDATE>\s*([^<]+)\s*</IDATE>.+?</TABLE>\s*(.+?)\s*<ICONT>\s*(.+?)\s*</ICONT>##si){          while($html =~ s#^.*?<!-- IKEY="([^"]+)" -->.+?<MYTITLE>\s*([^<]+)\s*</MYTITLE>.+?<ITITLE>\s*([^<]+)\s*</ITITLE>.+?<IDATE>\s*([^<]+)\s*</IDATE>.+?</TABLE>\s*(.+?)\s*<ICONT>\s*(.+?)\s*</ICONT>##si){
64                  my $row = {                  my $row = {
65                          title => $2 . ( $3 ? " :: $3" : ""),                          name => $2 . ( $3 ? " :: $3" : ""),
66    
67                          ikey => $1,                          ikey => $1,
68                          mytitle => $2,                          mytitle => $2,
# Line 73  print "## issue $issue_no on $issue_date Line 71  print "## issue $issue_no on $issue_date
71                          html => $5,                          html => $5,
72                          contributors => $6,                          contributors => $6,
73    
74                          entry_id => $this_entry->id,                          type => 'pgbits',
                         i_type => 'pgbits',  
75                  };                  };
76            
77                  print $row->{title}," ", $row->{date},"\n";                  print $row->{name}," ", $row->{date},"\n";
78                  $l->find_class('items_pgbits')->find_or_create( $row )->dbi_commit;                  my $article = $l->find_class('items_pgbits')->find_or_create( $row );
79                    $article->dbi_commit;
80    
81                    $l->find_class('item_topics')->find_or_create(
82                            topic_id => $issue->id,
83                            item_id => $article->id,
84                    )->dbi_commit;
85          }          }
86  }  }
87    

Legend:
Removed from v.36  
changed lines
  Added in v.37

  ViewVC Help
Powered by ViewVC 1.1.26