First import
git-svn-id: http://photonzero.com/dotfiles/trunk@1 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
commit
83d40113d2
60 changed files with 4264 additions and 0 deletions
87
bin/touchhtml
Executable file
87
bin/touchhtml
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Globals
|
||||
#
|
||||
use vars qw/$deftext %opt /;
|
||||
|
||||
#
|
||||
# Command line options processing
|
||||
#
|
||||
sub init()
|
||||
{
|
||||
use Getopt::Std;
|
||||
my $opt_string = 'hpci:o:t:j:';
|
||||
getopts( "$opt_string", \%opt ) or usage();
|
||||
usage() if $opt{h};
|
||||
}
|
||||
|
||||
#
|
||||
# Message about this program and how to use it
|
||||
#
|
||||
sub usage()
|
||||
{
|
||||
print STDERR << "EOF";
|
||||
|
||||
touchhtml -- Create a barebones HTML file
|
||||
|
||||
usage: $0 [-hpc][-i <FILE>][-o <FILE>][-t <TITLE>]
|
||||
|
||||
-h : This (help) message
|
||||
-p : Add <pre> tags
|
||||
-c : Print "Content-type" at the start (for CGI)
|
||||
-i FILE : Read body from given filename
|
||||
-o FILE : Output to given filename
|
||||
-t TITLE : Set the HTML <TITLE> field to given title
|
||||
-j FILE : Include this JavaScript filename in the body
|
||||
|
||||
EOF
|
||||
exit;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
|
||||
if (!$opt{o}) {
|
||||
open(FILEH, ">-");
|
||||
}
|
||||
else
|
||||
{
|
||||
open(FILEH, ">$opt{o}") || die "Cannot open file for writing!";
|
||||
}
|
||||
|
||||
if ($opt{c}) {
|
||||
print "Content-type: text/html\n\n";
|
||||
}
|
||||
|
||||
print FILEH <<FOO;
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>$opt{t}</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
FOO
|
||||
print FILEH "<pre>\n" if $opt{p};
|
||||
if ($opt{i})
|
||||
{
|
||||
open (INFILE, "<$opt{i}") || die "Cannot open file for reading!";
|
||||
while (<INFILE>)
|
||||
{
|
||||
print FILEH;
|
||||
}
|
||||
close(INFILE);
|
||||
}
|
||||
elsif (!(-t STDIN))
|
||||
{
|
||||
while (<STDIN>)
|
||||
{
|
||||
print FILEH;
|
||||
}
|
||||
}
|
||||
print FILEH "</pre>\n" if $opt{p};
|
||||
print FILEH "<script src='$opt{j}'>\n</script>\n" if $opt{j};
|
||||
print FILEH <<FOO;
|
||||
</BODY>
|
||||
</HTML>
|
||||
FOO
|
||||
|
||||
close(FILEH);
|
||||
Loading…
Add table
Add a link
Reference in a new issue