Added more functionality:
authorJoey Schulze <joey@infodrom.org>
Tue, 26 Jun 2001 22:21:25 +0000 (22:21 +0000)
committerJoey Schulze <joey@infodrom.org>
Tue, 26 Jun 2001 22:21:25 +0000 (22:21 +0000)
 . --workshops.tex will output a nice source file for LaTeX with the
   workshop schedule
 . --descrweb will return HTML code to be used for www.linuxtag.org
 . --descrweben will return english texts whereever it is possible

src/LinuxTag/2001/ltp

index ec95297..a6639bc 100755 (executable)
@@ -7,6 +7,12 @@ use Text::Wrap;
 $latex_foot = '\end{document}';
 $latex_headline = '\centerline{\textbf{\large LinuxTag 2001 -- %s}}' . "\n\\vspace{2ex}";
 
+$latex_lthead = '\documentclass{lt}\begin{document}';
+%datum = ('2001-07-05' => 'Donnerstag, 5.7.',
+         '2001-07-06' => 'Freitag, 6.7.',
+         '2001-07-07' => 'Samstag, 7.7.',
+         '2001-07-08' => 'Sonntag, 8.7.');
+
 $engine  = "dbi:Pg:dbname=elt2k1;host=kuolema";
 $dbh = DBI->connect($engine);
 if (!$dbh) {
@@ -377,6 +383,50 @@ sub missing_descr
     }
 }
 
+sub descrweb
+{
+    my $query;
+    my $sth;
+    my $rc;
+    my @row;
+
+    my $name;
+    my $descr;
+    my $res = '';
+
+    my $t_head = '<table width=100% cellspacing=0 cellpadding=0 border=0>';
+    my $t_foot = '</table>';
+    my $t_title = '<tr bgcolor="#0d1651"><td align="left"><b><font face=Helvetica,Arial>&nbsp;%s</font></b></td>'
+                .'<td align="right"><b><font color="#ffffff" face=Helvetica,Arial>%s&nbsp;</font></b></td></tr>';
+    my $t_descr = '<tr><td colspan=2 align="left"><font face=Helvetica,Arial>%s</font></td></tr>';
+
+    if (@_) {
+       $query = "SELECT name,url,boothnr,description_en,description FROM project,appendix ";
+    } else {
+       $query = "SELECT name,url,boothnr,description,description_en FROM project,appendix ";
+    }
+    $query .= "WHERE project.name = appendix.project AND boothnr <> '' ORDER BY name";
+    $sth = $dbh->prepare($query);
+    if ($sth && ($rc = $sth->execute) > 0) {
+        while (@row = $sth->fetchrow_array) {
+           if (length ($row[1])) {
+               $name = sprintf ("<a href=\"%s\"><font color=\"#ffffff\">%s</font></a>", $row[1], $row[0]);
+           } else {
+               $name = sprintf ("<font color=\"#ffffff\">%s</font>", $row[0]);
+           }
+           if (length ($row[3])) { $descr = $row[3]; }
+           elsif (length ($row[4])) { $descr = $row[4]; }
+           else { next; }
+
+           $res .= sprintf ($t_title, $name, $row[2]);
+
+           $res .= sprintf ($t_descr, $descr);
+        }
+    }
+
+    print $t_head . $res . $t_foot . "\n" if ($res);
+}
+
 sub nili
 {
     my $query;
@@ -580,6 +630,64 @@ sub workshops
     }
 }
 
+sub latex_workshops
+{
+    my $query;
+    my $sth;
+    my $rc;
+    my @row;
+    my $date;
+    my $time;
+    my $room;
+    my %length;
+    my $line;
+
+    $dbh->do("SET DateStyle = 'ISO'"); 
+
+    $query = "SELECT room,date_time,title,speaker FROM workshop";
+
+    $sth = $dbh->prepare($query);
+    if ($sth && ($rc = $sth->execute) > 0) {
+        while (@row = $sth->fetchrow_array) {
+           $row[1] =~ /(\d+-\d+-\d+) (\d+:\d+):.*/;
+           $row[2] =~ s/#/\#/g;
+           $row[2] =~ s/&/\&/g;
+           $row[3] =~ s/#/\#/g;
+           $row[3] =~ s/&/\&/g;
+           $date = $1;
+           $time = $2;
+           $schedule{$date}{$row[0]}{$time}{talk} = $row[2];
+           $schedule{$date}{$row[0]}{$time}{speaker} = $row[3];
+       }
+    }
+
+    #print latex_head ();
+    print $latex_lthead;
+    foreach $date (keys %datum) {
+
+       #printf $latex_headline, $datum{$date};
+       printf "\\headline{Workshops}{%s}\n\n\\vspace{1cm}", $date;
+
+       printf '\begin{tabular}{l||c|c}'.
+              '\textbf{Zeit} &\parbox{6.5cm}{\centerline{\textbf{CCA III}}} '.
+                  '&\parbox{6.5cm}{\centerline{\textbf{CCA IV}}}\\\\\hline\hline';
+
+       foreach $time (('10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00')) {
+
+           printf "\\textbf{%s} & %s & %s\\\\", $time,
+                  $schedule{$date}{"CCA III"}{$time}{talk},
+                  $schedule{$date}{"CCA IV"}{$time}{talk};
+
+           printf "\\ & %s & %s\\\\\\hline",
+                  $schedule{$date}{"CCA III"}{$time}{speaker},
+                  $schedule{$date}{"CCA IV"}{$time}{speaker};
+       }
+       print '\end{tabular}';
+       print "\\clearpage\n";
+    }
+    print $latex_foot;
+}
+
 sub exportlt
 {
     my $query = "SELECT name,boothnr,url FROM project";
@@ -628,6 +736,7 @@ sub help
     print "   --help             This help\n";
     print "   --descr            List project descriptions\n";
     print "   --descr-miss       List projects and addrs that lack a description\n";
+    print "   --descrweb         Export HTML junk for www.linuxtag.org (add en)\n";
     print "   --exportlt         Export for LT database\n";
     print "   --list|-l          List all projects\n";
     print "   --mails            List mail addresses of all projects\n";
@@ -640,6 +749,7 @@ sub help
     print "   --titles           List booth titles\n";
     print "   --table            LaTeX table with all projects\n";
     print "   --workshops        Workshop Schedule\n";
+    print "   --workshops.tex    Workshop Schedule for LaTeX\n";
 
 }
 
@@ -661,6 +771,10 @@ while ($argc <= $#ARGV) {
         list ();
     } elsif ($ARGV[$argc] eq "--descr") {
        descr ();
+    } elsif ($ARGV[$argc] eq "--descrweb") {
+       descrweb ();
+    } elsif ($ARGV[$argc] eq "--descrweben") {
+       descrweb ('en');
     } elsif ($ARGV[$argc] eq "--descr-miss" || $ARGV[$argc] eq "--missing-descr") {
        missing_descr ();
     } elsif ($ARGV[$argc] eq "--exportlt") {
@@ -693,6 +807,8 @@ while ($argc <= $#ARGV) {
        list_titles ();
     } elsif ($ARGV[$argc] eq "--workshops") {
        workshops ();
+    } elsif ($ARGV[$argc] eq "--workshops.tex") {
+       latex_workshops ();
     }
     $argc++;
 }