ask 98/06/15 15:29:43
Added: stories/convert .htaccess indextemplate.epl stories2html.pl
storytemplate.epl
Log:
Files to convert the .txt stories to .html
Revision Changes Path
1.1 modperl-site/stories/convert/.htaccess
Index: .htaccess
===================================================================
Order Allow,Deny
Allow from none
Deny from all
1.1 modperl-site/stories/convert/indextemplate.epl
Index: indextemplate.epl
===================================================================
<html>
<head>
</head>
<body bgcolor="#FFFFFF">
<a href="../"> Back to mainpage </a><br>
<p>
<font face='Helvetica,Arial'>
[+ &Toolbox::FileList +]
</font>
</body>
</html>
1.1 modperl-site/stories/convert/stories2html.pl
Index: stories2html.pl
===================================================================
#!/usr/bin/perl -w
use strict;
use HTML::Embperl;
package Toolbox;
my $storydirectory = $ARGV[0] || "/export/pub/apache/perl/stories/";
sub FileList {
my $result;
foreach (sort (keys %Toolbox::Files)) {
$result .= qq[<a href="$_.html">];
$result .= $Toolbox::Files{$_}->{Title} ? $Toolbox::Files{$_}->{Title} : $_;
$result .= "</a>";
$result .= qq[ <font size="-1">(].$Toolbox::Files{$_}->{Author}.")</font>"
if ($Toolbox::Files{$_}->{Author});
$result .= "<br>\n";
}
return $result;
}
opendir (DIR, $storydirectory) or die "Could not open storydirectory";
my @files = grep { /\.txt$/ } readdir(DIR);
closedir(DIR);
foreach my $filename (@files) {
$filename =~ s/\.txt$//;
undef $/;
open (STORY, "<$storydirectory$filename.txt" ) or
die "Could not open story: $filename";
$_ = <STORY>;
close STORY;
$Toolbox::Files{$filename} = {};
s!\n(?:Title:\s*([^\n]*))!!;
$Toolbox::Title = ($1 || "");
$Toolbox::Files{$filename}->{Title} = $1 if $1;
s!(http://[^\s\)]+)!<a href="$1" target="_blank">$1</a>!gi;
s!(ftp://[^\s]+)!<a href="$1" target="_blank">$1</a>!gi;
m!\n(?:Author|From):\s+([^\n]*)!;
$Toolbox::Files{$filename}->{Author} = ($1 || "");
$Toolbox::Files{$filename}->{Author} =~ s!<!<!;
$Toolbox::Files{$filename}->{Author} =~ s!>!>!;
$Toolbox::Text = $_;
&HTML::Embperl::Execute({
inputfile => "./storytemplate.epl",
outputfile => "$storydirectory$filename.html",
escmode => 0
});
# just to avoid the 'used only once' warning
undef $Toolbox::Text;
undef $Toolbox::Title;
}
&HTML::Embperl::Execute({
inputfile => "./indextemplate.epl",
outputfile => $storydirectory."index.html",
escmode => 0
});
1.1 modperl-site/stories/convert/storytemplate.epl
Index: storytemplate.epl
===================================================================
<html>
<head>
<title>modperl story - [+ $Toolbox::Title +]</title>
</head>
<body bgcolor="#FFFFFF">
<a href="index.html">Back to story index</a> | <a href="../"> Back to mainpage </a><br>
<pre>
[+ $Toolbox::Text +]
</pre>
</body>
</html>
Added: stories/convert .htaccess indextemplate.epl stories2html.pl
storytemplate.epl
Log:
Files to convert the .txt stories to .html
Revision Changes Path
1.1 modperl-site/stories/convert/.htaccess
Index: .htaccess
===================================================================
Order Allow,Deny
Allow from none
Deny from all
1.1 modperl-site/stories/convert/indextemplate.epl
Index: indextemplate.epl
===================================================================
<html>
<head>
</head>
<body bgcolor="#FFFFFF">
<a href="../"> Back to mainpage </a><br>
<p>
<font face='Helvetica,Arial'>
[+ &Toolbox::FileList +]
</font>
</body>
</html>
1.1 modperl-site/stories/convert/stories2html.pl
Index: stories2html.pl
===================================================================
#!/usr/bin/perl -w
use strict;
use HTML::Embperl;
package Toolbox;
my $storydirectory = $ARGV[0] || "/export/pub/apache/perl/stories/";
sub FileList {
my $result;
foreach (sort (keys %Toolbox::Files)) {
$result .= qq[<a href="$_.html">];
$result .= $Toolbox::Files{$_}->{Title} ? $Toolbox::Files{$_}->{Title} : $_;
$result .= "</a>";
$result .= qq[ <font size="-1">(].$Toolbox::Files{$_}->{Author}.")</font>"
if ($Toolbox::Files{$_}->{Author});
$result .= "<br>\n";
}
return $result;
}
opendir (DIR, $storydirectory) or die "Could not open storydirectory";
my @files = grep { /\.txt$/ } readdir(DIR);
closedir(DIR);
foreach my $filename (@files) {
$filename =~ s/\.txt$//;
undef $/;
open (STORY, "<$storydirectory$filename.txt" ) or
die "Could not open story: $filename";
$_ = <STORY>;
close STORY;
$Toolbox::Files{$filename} = {};
s!\n(?:Title:\s*([^\n]*))!!;
$Toolbox::Title = ($1 || "");
$Toolbox::Files{$filename}->{Title} = $1 if $1;
s!(http://[^\s\)]+)!<a href="$1" target="_blank">$1</a>!gi;
s!(ftp://[^\s]+)!<a href="$1" target="_blank">$1</a>!gi;
m!\n(?:Author|From):\s+([^\n]*)!;
$Toolbox::Files{$filename}->{Author} = ($1 || "");
$Toolbox::Files{$filename}->{Author} =~ s!<!<!;
$Toolbox::Files{$filename}->{Author} =~ s!>!>!;
$Toolbox::Text = $_;
&HTML::Embperl::Execute({
inputfile => "./storytemplate.epl",
outputfile => "$storydirectory$filename.html",
escmode => 0
});
# just to avoid the 'used only once' warning
undef $Toolbox::Text;
undef $Toolbox::Title;
}
&HTML::Embperl::Execute({
inputfile => "./indextemplate.epl",
outputfile => $storydirectory."index.html",
escmode => 0
});
1.1 modperl-site/stories/convert/storytemplate.epl
Index: storytemplate.epl
===================================================================
<html>
<head>
<title>modperl story - [+ $Toolbox::Title +]</title>
</head>
<body bgcolor="#FFFFFF">
<a href="index.html">Back to story index</a> | <a href="../"> Back to mainpage </a><br>
<pre>
[+ $Toolbox::Text +]
</pre>
</body>
</html>