]> git.sur5r.net Git - bacula/docs/blobdiff - docs/tools/sf2bacula_downloads.pl
Update downloads
[bacula/docs] / docs / tools / sf2bacula_downloads.pl
index 23e2dc17c138ec9940acefc66189a530d39ed744..24123add5e777a5cb8966a4d6ec3f9b9a8173a3b 100755 (executable)
@@ -50,29 +50,38 @@ open(FP, $file);
 while (my $l = <FP>)
 {
     #                                         cat   vers  file
-    if ($l =~ m!href="(/projects/bacula/files/(.+?)/(.+?)/(.+?)/download)"!) {
-        if ($cur && $cur->{date} && !exists $seen{$cur->{file}}) {
-            push @{$cats{$cur->{cat}}}, $cur;
-            $seen{$cur->{file}} = 1;
-        }
-
+    if ($l =~ m!href="(/projects/bacula/files/([^/]+)/([^/]+)/([^/]+)/download)"!) {
         $cur = {
             dl  => $1,
             cat => $2,
             vers => $3,
-            file => $4,
+            file => $4
         };
     }
 
-    # the size and the date are just after
-    if ($l =~ m!<td>([\d\.]+ [KMG]B)</td>!) {
+    # the size, date, and downloads are just after
+    if ($cur && $l =~ m!<td>([\d\.]+ [KMG]B)</td>!) {
         $cur->{size} = $1;
         do {
             $l = <FP>;
-            if ($l =~ m!<td>(.+?)</td>!) {
+            if ($l =~ m!<td>(.*?)</td>!) {
                 $cur->{date} = $1;
             }
         } while (!$cur->{date});
+        do {
+            $l = <FP>;
+            if ($l =~ m!<td>(.*?)</td>!) {
+                $cur->{downloads} = $1;
+            }
+        } while (!$cur->{downloads});
+
+
+        # once we have a full $cur element, we can store it
+        if (!exists $seen{$cur->{file}}) {
+            push @{$cats{$cur->{cat}}}, $cur;
+            $seen{$cur->{file}} = 1;
+            $cur = undef;
+        }
     }
 }
 close(FP);
@@ -101,6 +110,7 @@ print '
 ';
 
 my $cat = 'bacula';
+my $row = 'odd';
 #use Data::Dumper;
 #print Data::Dumper::Dumper(\%cats);
 
@@ -112,7 +122,7 @@ sub print_cat
    <tr>
      <td> <br><a name="', $cat, '"></a><font size="+1"><b>', $cat, ':</b></font>
 <table cellspacing="2">
-<tr><th>Name</th><th align="center">', ($cat !~ /rpm/)?'Signature':'', '</th><th>Size</th><th>Date</th></tr>
+<tr class="title"><th>Name</th><th align="center">', ($cat !~ /rpm/)?'Signature':'', '</th><th>Size</th><th>Date</th><th>Downloads</th></tr>
 ';
     foreach my $elt ( sort { $a->{file} cmp $b->{file} }  @{$cats{$cat}})
     {
@@ -120,16 +130,18 @@ sub print_cat
         if ($elt->{vers} eq $version || $elt->{vers} =~ /$depkgs_version/)
         {
             print "
-<tr>
+<tr class=\"$row\">
  <td><a href='https://sourceforge.net$elt->{dl}'>$elt->{file}</td>
- <td align='center'>", 
+ <td align=\"center\">", 
  ($cat !~ /rpm/)?"<a href='https://sourceforge.net/projects/bacula/files/$cat/$elt->{vers}/$elt->{file}.sig/download'>sig":"", 
  "</td>
- <td>$elt->{size}</td>
- <td>$elt->{date}</td>
+ <td align=\"right\">$elt->{size}</td>
+ <td align=\"center\">$elt->{date}</td>
+ <td align=\"center\">$elt->{downloads}</td>
 </tr>
 ";
         }
+        if ($row eq 'odd') { $row = 'even'; } else { $row = 'odd'; }
     }
     print '</table>
      </td>
@@ -149,4 +161,3 @@ print '
 </table>
 <? require_once("inc/footer.php"); ?>
 ';
-