expoweb/noinfo/scripts/logbk.pl

113 lines
3.1 KiB
Perl
Executable File

#!/usr/bin/perl -w
#script to turn logbook.txt files into reasonable HTML files:
#logbook.html and trips
# very basic. Doesn't deal with trip IDs yet.
# Requires trip header format to be consistent:
#===YYYY-MM-DD | title | <people list>===
#and T/U: to always look like that and not also be mentioned in text
#edit year below manually. Used for 2006-2008
#triplist file doesn;t get a TU entry if none in logbook entry. Really out
# to be improved to normalise table
#print ("param1:$1");
#die;
my $year="2008";
my $infile=$year."logbook.txt";
my $outfile="logbook.html";
my $tripfile="trips.html";
open my $in, "<", $infile or die;
open my $out, ">", $outfile or die;
open my $triplist, ">", $tripfile or die;
print $out ("<!DOCTYPE html>
<html>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
<title>$year Expo Logbook</title></head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"../../css/main2.css\" />
<style type=\"text/css\">
.tripdate { float: left;}
.trippeople { float: right;}
.triptitle { font-size: 120%; text-align: center; font-weight: bold; clear: both }
.timeug { text-align: right; font-weight: bold }
p { clear: both }
</style>
<body>
<h1>Expo $year</h1>
<hr />
");
print $triplist ("<!DOCTYPE html>
<html>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
<title>Expo $year: trips index</title>
<link rel=\"stylesheet\" type=\"text/css\" href=\"../../css/main2.css\">
<style type=\"text/css\">
tr.nc { font-style: italic }
</style>
</head>
<body>
<h1>Expo $year: trips index</h1>
<p>This is an index to all caving trips that took place on Expo $year,
plus anything else that people saw fit to record in the logbook. The
list of trips here includes everything mentioned in the logbook, any of
the callout books or the Time Underground page in the bier book.
</p>
<table class=\"trad\">
<thead> <tr>
<th>Date</th>
<th>Person</th>
<th>Dest'n</th>
<th>T/U</th>
<th>Logbook writeup</th>
<th>Survey notes</th>
</tr>
");
while(<$in>){
if (/^===.*(2008-\d\d-\d\d) \|(.*)\|(.*)===$/) {
print $out ("<hr />\n\n<div class=\"tripdate\" id=\"t$1\">$1</div>\n");
print $out ("<div class=\"trippeople\">$3</div>\n");
print $out ("<div class=\"triptitle\">$2</div>\n");
print $triplist (" <tr>\n <td>$1</td>\n <td>$3</td>\n <td>$2</td>\n <td></td>\n <td></td>\n <td></td>\n </tr>\n");
} elsif (m!T/U!i) {
chomp;
print $out ("<div class=\"timeug\">$_</div>\n");
} else {
print $out $_
}
}
print $out ("<ul>
<li><a href=\"index.html\">Back to $year Index</a></li>
<li><a href=\"../../pubs.htm\">Index</a> to all publications</li>
<li><a href=\"../../index.htm\">Back to Expeditions intro page</a></li>
<li><a href=\"../../../index.htm\">CUCC Home Page</a></li>
</ul>
</body>
</html>");
print $triplist (" </tbody>
</table>
<hr>
<!-- LINKS -->
<ul>
<li><a href=\"../../infodx.htm\">Main index of the expedition site</a></li>
<li><a href=\"../../index.htm\">CUCC in Austria introduction page</a></li>
<li><a href=\"../../../index.htm\">CUCC Home Page</a></li>
</ul>
</body>
</html>
");
close $in;
close $out;
close $triplist;