. Some LaTeX stuff is now more generic
authorJoey Schulze <joey@infodrom.org>
Fri, 22 Jun 2001 10:44:07 +0000 (10:44 +0000)
committerJoey Schulze <joey@infodrom.org>
Fri, 22 Jun 2001 10:44:07 +0000 (10:44 +0000)
 . The simple list is now sorted, whoops
 . Added --onlybooth so only projects will be displayed that actually
   have a booth assigned (thus ruling out sub-projects)

src/LinuxTag/2001/ltp

index 1be28ec..a20baa7 100755 (executable)
@@ -3,6 +3,10 @@
 use DBI;
 use Text::Wrap;
 
+# Some generic stuff for all LaTeX output files
+$latex_foot = '\end{document}';
+$latex_headline = '\centerline{\textbf{\large LinuxTag 2001 -- %s}}' . "\n\\vspace{2ex}";
+
 $engine  = "dbi:Pg:dbname=elt2k1;host=kuolema";
 $dbh = DBI->connect($engine);
 if (!$dbh) {
@@ -40,12 +44,15 @@ sub night
 
 sub list
 {
-    my $query = "SELECT name,boothnr FROM project ORDER BY name";
+    my $query = "SELECT name,boothnr FROM project ";
     my $sth;
     my $rc;
     my @row;
     my $nr = 0;
 
+    $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
+    $query .= " ORDER BY name";
+
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
         while (@row = $sth->fetchrow_array) {
@@ -96,7 +103,9 @@ sub list_titles
     my @row;
 
     $query = "SELECT DISTINCT project.boothnr,appendix.boothtitle "
-       . "FROM project,appendix WHERE project.name = appendix.project ORDER BY boothnr,boothtitle";
+       . "FROM project,appendix WHERE project.name = appendix.project";
+    $query .= " AND boothnr <> ''" if ($opt_onlybooth);
+    $query .= "  ORDER BY boothnr,boothtitle";
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
         while (@row = $sth->fetchrow_array) {
@@ -105,6 +114,101 @@ sub list_titles
     }
 }
 
+sub latex_head
+{
+    my $result = '\documentclass[12pt]{article}\usepackage{humanist}';
+    my @args = @_;
+
+    $result .= '\usepackage[latin1]{inputenc}\usepackage[T1]{fontenc}';
+    if (@args) {
+       $result .= join ("\n", @args);
+    }
+
+    $result .= '\topmargin=-1cm\setlength{\oddsidemargin}{0.5cm}'
+    . '\setlength{\textheight}{25.0cm}\thispagestyle{empty}'
+    . '\begin{document}';
+
+    return $result;
+}
+
+sub latex_members
+{
+    my $query;
+    my $sth;
+    my $rc;
+    my @row;
+    my $count = 0;
+
+    my $thead = '\parbox{5cm}{\textbf{Name}} &\parbox{8cm}{\textbf{Project}}\\\\';
+    my $head = '\tablefirsthead{' . $thead .'\hline\hline}'
+             . '\tablehead{'
+              . '\multicolumn{2}{l}{Members continued...} \\\\[2ex]'
+              . $thead . '\hline\hline}'
+             . '\begin{supertabular}{l|l}' . "\n";
+
+    my $foot = '\end{supertabular}';
+    my $trow = '%s & %s \\\\';
+
+    print latex_head ("\\usepackage{supertabular}");
+    printf $latex_headline, "Projects-Staff";
+
+    $query = "SELECT name,project FROM person WHERE list=0 ORDER BY name";
+    $sth = $dbh->prepare($query);
+    if ($sth && ($rc = $sth->execute) > 0) {
+       print $head;
+        while (@row = $sth->fetchrow_array) {
+           $count++;
+           printf $trow, $row[0], $row[1];
+           print '\hline' if (!($count % 5));
+           print "\n";
+        }
+       print $foot;
+    }
+
+    print "\\clearpage\n";
+
+    $query = "SELECT name,project FROM person WHERE list=0 ORDER BY project,name";
+    $sth = $dbh->prepare($query);
+    if ($sth && ($rc = $sth->execute) > 0) {
+       print $head;
+        while (@row = $sth->fetchrow_array) {
+           $count++;
+           printf $trow, $row[0], $row[1];
+           print '\hline' if (!($count % 5));
+           print "\n";
+        }
+       print $foot;
+    }
+    print $latex_foot;
+}
+
+sub latex_table
+{
+    my $query;
+    my $sth;
+    my $rc;
+    my @row;
+
+    my $head = '\renewcommand{\arraystretch}{1.5}\begin{tabular}{ll}';
+    my $foot = '\end{tabular}';
+    my $trow = '%s & \hspace{8cm}\ \\\\\cline{2-2}';
+
+    $query = "SELECT name FROM project WHERE name <> 'intern'";
+    $query .= " AND boothnr <> ''" if ($opt_onlybooth);
+    $query .= " ORDER BY name";
+    $sth = $dbh->prepare($query);
+    if ($sth && ($rc = $sth->execute) > 0) {
+       print latex_head ();
+       printf $latex_headline, "Projekte";
+       print $head;
+        while (@row = $sth->fetchrow_array) {
+           printf $trow . "\n", $row[0];
+        }
+       print $foot;
+       print $latex_foot;
+    }
+}
+
 sub descr
 {
     my $query;
@@ -117,6 +221,7 @@ sub descr
     my $cols;
 
     $query = "SELECT name,url,boothnr FROM project";
+    $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
         while (@row = $sth->fetchrow_array) {
@@ -125,7 +230,13 @@ sub descr
         }
     }
 
-    $query = "SELECT project,description,description_en FROM appendix";
+    if ($opt_onlybooth) {
+       $query = "SELECT appendix.project,appendix.description,appendix.description_en FROM appendix,project WHERE ";
+       $query .= "project.name = appendix.project AND project.boothnr <> ''";
+    } else {
+       $query = "SELECT project,description,description_en FROM appendix";
+    }
+
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
         while (@row = $sth->fetchrow_array) {
@@ -405,12 +516,14 @@ sub workshops
 
 sub exportlt
 {
-    my $query = "SELECT name,boothnr,url FROM project ORDER BY name";
+    my $query = "SELECT name,boothnr,url FROM project";
     my $sth;
     my $rc;
     my @row;
     my $nr = 0;
 
+    $query .= " WHERE boothnr <> ''" if ($opt_onlybooth);
+    $query .= " ORDER BY name";
     $sth = $dbh->prepare($query);
     if ($sth && ($rc = $sth->execute) > 0) {
         while (@row = $sth->fetchrow_array) {
@@ -426,6 +539,7 @@ sub help
     print "Options:\n";
     print "   --cols <n>         Text will be wrapped at n columns\n";
     print "   --nospace          No leading spaces\n";
+    print "   --onlybooth        Only projects with a non-empty boothnr\n";
     print "Commands:\n";
     print "   --help             This help\n";
     print "   --descr            List project descriptions\n";
@@ -433,10 +547,12 @@ sub help
     print "   --exportlt         Export for LT database\n";
     print "   --list|-l          List all projects\n";
     print "   --mails            List mail addresses of all projects\n";
+    print "   --members          LaTeX file with all project members\n";
     print "   --nili             Table for Nili accommodation\n";
     print "   --nili-details     Details for Nili accommodation\n";
     print "   --night [<place>]  List people that need a place to stay\n";
     print "   --titles           List booth titles\n";
+    print "   --table            LaTeX table with all projects\n";
     print "   --workshops        Workshop Schedule\n";
 
 }
@@ -445,6 +561,7 @@ sub help
 #
 $argc = 0;
 $opt_nospace = 0;
+$opt_onlybooth = 0;
 $opt_cols = 70;
 while ($argc <= $#ARGV) {
     if ($ARGV[$argc] eq "-h" || $ARGV[$argc] eq "--help") {
@@ -464,6 +581,8 @@ while ($argc <= $#ARGV) {
        exportlt ();
     } elsif ($ARGV[$argc] eq "--mails") {
        list_mails ('');
+    } elsif ($ARGV[$argc] eq "--members") {
+       latex_members ('');
     } elsif ($ARGV[$argc] eq "--nili") {
        nili ();
     } elsif ($ARGV[$argc] eq "--nili-details") {
@@ -476,6 +595,10 @@ while ($argc <= $#ARGV) {
        }
     } elsif ($ARGV[$argc] eq "--nospace") {
         $opt_nospace++;
+    } elsif ($ARGV[$argc] eq "--onlybooth") {
+        $opt_onlybooth++;
+    } elsif ($ARGV[$argc] eq "--table") {
+       latex_table ();
     } elsif ($ARGV[$argc] eq "--titles") {
        list_titles ();
     } elsif ($ARGV[$argc] eq "--workshops") {