File: archive-to-html.pl

package info (click to toggle)
gri 2.12.26-1
  • links: PTS
  • area: main
  • in suites: buster, sid
  • size: 5,952 kB
  • ctags: 2,396
  • sloc: cpp: 36,598; sh: 4,196; lisp: 3,764; perl: 1,362; ansic: 1,046; makefile: 606
file content (70 lines) | stat: -rwxr-xr-x 1,461 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl -w

if ($#ARGV == 0) {
    $file = $ARGV[0];
} else {
    $file = "./gri.archive";
}
open(IN, $file) or die "Cannot open $file";

print "<html>
<head>
<title>Gri newsgroup archive</title>
</head>
<body bgcolor=\"#ffffff\" link=\"#993333\" vlink=\"#333399\">

<h2>12.8: Archive of messages sent to the gri newsgroup</h2>

";

$count = 1;
$date = "(unknown date)";
$subject = "(unknown subject)";
$from = "(unknown sender)";

$line = 0;
while(<IN>) {
    die if $line++>100000;
    chop;
    s/&/&amp;/g;  s/</&lt;/g;    s/>/&gt;/g;    # Fix <>.
    if (/^From /) {
	#print "Got From ...\n";
	while(<IN>) {
	    s/&/&amp;/g;  s/</&lt;/g;    s/>/&gt;/g;    # Fix <>.
	    chop;
	    #print "Got new line '$_'\n";
	    if (/Date:\s(.*)/)    { $date    = $1; }
	    if (/Subject:\s(.*)/) { $subject = $1; }
	    if (/From:\s(.*)/)    { $from    = $1; }
	    if (/X-Status:/) {
		print "<h2>12.8.$count. $subject</h2>\n";
		print "<i>On $date, $from wrote </i>...<br>\n";
		$date = "(unknown date)";
		$subject = "(unknown subject)";
		$from = "(unknown sender)";
		last;
	    }
	}
	$count++;
    } else {
	if (m,(http://.*),) {
	    $url = $1;
	    s:$url:<a href="$url">$url</a>:g;
	}
	if (m,mailto:\s*(.*),) {
	    $mailto = $1;
	    s,$mailto,<a href="mailto:$mailto">$mailto</a>,g;
	}
	if (m,[eE]mail:\s*(.*),) {
	    $mailto = $1;
	    s,$mailto,<a href="mailto:$mailto">$mailto</a>,g;
	}
	print "$_<br>\n";
    }

}

print "
</body>
</html>
";