Re: Where to put a script (maybe new categ)?
[email protected] (John Lenton) Mon, 11 Feb 2002 11:57:06 -0300
| Newsgroups | perl.scripts |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Feb 11, 2002 at 06:52:41AM -0500, Rich Bowen wrote:
> On Tue, 5 Feb 2002, John Lenton wrote:
>
> > A script that goes down a dierctory tree fixing stuff so that a
> > web site that worked with IIS works with Apache.
> >
> > Where would you put it?
>
> Could you be a little more specific what "fixing stuff" would look like?
> Is there any reason that this is IIS/Apache specific, or could it be
> used for other purposes? For example, I want to recurse directories in a
> CVS checkout and change the server name in the CVS/Root files. That
> seems like a very similar task, or is this more specific than that?
it is more specific, although I could probably rip out the
functionality (although with File::Find what you describe is a
one-liner).
Let me describe the situation in larger detail:
IIS runs on WinNT. WinNT is shmosix, i.e. it claims POSIX
compliance while not really realizing the difference between
FILENAME, filename and FileName. A person writing a page for IIS
can, and will, use any which case for files, because it works.
The script is called 'lowercase', because the biggest problem in
the Ministerio de EconomÃa in Argentina (that this was developed
for) was the uppercase/lowercase problem. It does other
sanitizations as well: all links are made relative (i.e. if the
base is foo.com, http://foo.com/bar is changed to /bar), and all
weird characers (as per RFC 1738 and the 4.0.1 HTML spec) are
escaped.
Maybe the following will be of aid:
42:john@martina:lowercase$ ./lc
This is lowercase, version 1.05
Usage: lc [-v] [-b=<ext>] [-n=<name>] [-Z] [-f] <dir>
-v be verbose (toggle with SIGUSR1)
-b=<ext> change backup extension to "<ext>" (currently ".~~perl~~")
-n=<name> change site name to "<ext>" (currently "www.mecon.gov.ar")
-Z zap the files (instead of leaving a backup)
-f avoid asking sissy questions
<dir> process this directory instead of complaining
43:john@martina:lowercase$ ./lc -v .
This will lowercase everything under ., and change all the links in all
files that look like HTML into something saner wherever possible. Are you
absolutely sure you want me to do what you just told me to?
(yes/NO/?) ?
OK, let me try to clarify that:
- "link" is everything after a "src", "href" or "background". I try to be
smart about what is actually "fixed", but users are much smarter than
I. Thus, I will not even try to understand, let alone fix, tags that do not
match the standard (in this case, I mean RFC 1738 and a chunk of the 4.0.1
HTML spec <http://www.w3.org/TR/html401/intro/sgmltut.html#h-3.2.2>)
- "looks like HTML" currently means "matches /.html?$/"
Having said that, let me ask again. Are you sure?
(yes/NO)
--
John Lenton ([email protected]) -- Random fortune:
Be open to other people -- they may enrich your dream.