/[simile]/links/csv2js.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 /links/csv2js.pl

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

revision 12 by dpavlin, Thu Aug 23 17:42:56 2007 UTC revision 13 by dpavlin, Thu Aug 23 17:55:05 2007 UTC
# Line 17  $|++; Line 17  $|++;
17  my $csv_path = 'links.csv';  my $csv_path = 'links.csv';
18  my $img_path = 'img';  my $img_path = 'img';
19  my $first_line_labels = 1;  my $first_line_labels = 1;
20    my $mirror_images = 1;
21  my $split_fields = {  my $split_fields = {
22          label => sub { return split(/,\s*/,$_[0]) },          label => sub { return split(/,\s*/,$_[0]) },
23  };  };
# Line 207  sub numeric_range { Line 208  sub numeric_range {
208    
209          warn "## round $min - $max / $step produced ranges: ",dump( @ranges ),"\n";          warn "## round $min - $max / $step produced ranges: ",dump( @ranges ),"\n";
210    
211          my $usage;          my $d = length( "$max" );
212    
213          foreach my $i ( 0 .. $#numbers ) {          foreach my $i ( 0 .. $#numbers ) {
214                  my $n = $numbers[$i];                  my $n = $numbers[$i];
# Line 215  sub numeric_range { Line 216  sub numeric_range {
216                  my $start = 0;                  my $start = 0;
217                  foreach my $r ( @ranges ) {                  foreach my $r ( @ranges ) {
218                          if ( $n < $r ) {                          if ( $n < $r ) {
219                                  $dump[$i]->{ $name . '_range' } =  $start . '-' . $r;                                  $dump[$i]->{ $name . '_range' } =  sprintf("%0${d}d-%0${d}d", $start, $r);
220                                  last;                                  last;
221                          }                          }
222                          $start = $r;                          $start = $r;
# Line 279  while (<$csv_fh>) { Line 280  while (<$csv_fh>) {
280          my $img_thumb_path = "$img_path/t/$id.jpg";          my $img_thumb_path = "$img_path/t/$id.jpg";
281          my $img_orig_path = "$img_path/$id.jpg";          my $img_orig_path = "$img_path/$id.jpg";
282    
283          if ( mirror( $url, $img_orig_path ) != RC_NOT_MODIFIED ) {          if ( $mirror_images && mirror( $url, $img_orig_path ) != RC_NOT_MODIFIED ) {
284                  warn "$url -> $img_orig_path\n";                  warn "$url -> $img_orig_path\n";
285          }          }
286          system('convert', '-geometry', '320x200', $img_orig_path, $img_thumb_path ) if ! -e $img_thumb_path;          system('convert', '-geometry', '320x200', $img_orig_path, $img_thumb_path ) if ! -e $img_thumb_path;

Legend:
Removed from v.12  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26