Re: [SLUG] Looking for lazy way out

2005-06-23 Thread Angus Lees
At Wed, 22 Jun 2005 16:33:53 +1000, Simon Bryan wrote:
 I have uploaded a web based  CD to our Moodle setup, but all the links
 are broken. In true sloppy MS style most of the filenames are in
 uppercase whereas the html files refer to them in lower case. The
 underlying webserver is Apache, (thought mod-speling might help from
 some reading but it is already installed). I am looking for the lazy way
 out of going through and editing all the links in the html files or
 renaming all the disc files, is there a solution? NB there are hundreds
 of files and corresponding links :-(

Totally untested (other than checking it compiles).

Install and load mod_perl, then put this file in
/usr/share/perl5/Apache/IgnoreCase.pm (or wherever other Apache/foo.pm
modules are on your distro), then put something like this in your
httpd.conf (a Location block would be fine too):

 Directory /path/to/my/web/based/cd
   PerlFixupHandler Apache::IgnoreCase
 /Directory

(How do you people use Apache without mod_perl?)

package Apache::IgnoreCase;

use Apache::Constants ':common';

use strict;
use warnings;

sub find_path {
  my $path = $_[0];
  my $new = '';
 COMPONENT:
  for my $component (split '/', $path) {
 next if $component eq '';
 my $tmp = $new/$component;
 if (-e $tmp) {
$new = $tmp;
 } else {
my ($dir, $entry);
opendir $dir, $new or return undef;
while (defined($entry = readdir $dir)) {
   if (lc($entry) eq lc($component)) {
  $new .= /$entry;
  next COMPONENT;
   }
}
return undef; # similar entry not found
 }
  }
  $new = '/' if $new eq '';  # corner case
  return $new;
}

sub handler {
  my $r = $_[0];

  my $fn = $r-filename;
  unless (-e $fn) {
my $new = find_path($fn);
$r-filename($new) if $new;
  }

  return OK;  
}

1;

-- 
 - Gus
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

[SLUG] Looking for lazy way out

2005-06-22 Thread Simon
HI all,
I have uploaded a web based  CD to our Moodle setup, but all the links
are broken. In true sloppy MS style most of the filenames are in
uppercase whereas the html files refer to them in lower case. The
underlying webserver is Apache, (thought mod-speling might help from
some reading but it is already installed). I am looking for the lazy way
out of going through and editing all the links in the html files or
renaming all the disc files, is there a solution? NB there are hundreds
of files and corresponding links :-(


OLMC
Simon Bryan
IT Manager
[EMAIL PROTECTED]
LMB 14
North Parramatta
tel: 96833300
fax: 98901466
mobile: 0414238002


-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Looking for lazy way out

2005-06-22 Thread John Clarke
On Wed, Jun 22, 2005 at 04:33:53 +1000, Simon wrote:

 thought mod-speling might help from some reading but it is already installed

It is enabled?:

http://httpd.apache.org/docs/mod/mod_speling.html


Cheers,

John
-- 
So, where can one *get* Dave's Insanity Sauce?
Sidle up to the K-Y jelly counter of your local pharmacy, lean over the
counter, and ask:  Do you have anything, y'know, a bit *hotter*?
-- Alan J Rosenthal
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Looking for lazy way out

2005-06-22 Thread Gavin Carr
Hi Simon,

On Wed, Jun 22, 2005 at 04:33:53PM +1000, Simon wrote:
 I have uploaded a web based  CD to our Moodle setup, but all the links
 are broken. In true sloppy MS style most of the filenames are in
 uppercase whereas the html files refer to them in lower case. The
 underlying webserver is Apache, (thought mod-speling might help from
 some reading but it is already installed). I am looking for the lazy way
 out of going through and editing all the links in the html files or
 renaming all the disc files, is there a solution? NB there are hundreds
 of files and corresponding links :-(

Since laziness is one of the cardinal virtues of the perl-hacker, try:

  perl -MFile::Find -e 'find sub { rename $_, lc $_ if -f $_  $_ =~ 
m/\.html?$/i }, .'

from the top of your cd directory tree. This will lowercase all file names 
ending in .htm, .html, .HTML, .HTM, etc., so be careful that's exactly 
what you want!

Cheers,
Gavin

-- 
Open Fusion P/L - Open Source Business Solutions [ Linux - Perl - Apache ]
ph:  +612 9875 5032fax: +612 9875 4317
web: http://www.openfusion.com.au  mob: +61 403 171712
- Fashion is a variable, but style is a constant - Programming Perl
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Looking for lazy way out

2005-06-22 Thread Gavin Carr
On Wed, Jun 22, 2005 at 04:56:13PM +1000, Gavin Carr wrote:
 On Wed, Jun 22, 2005 at 04:33:53PM +1000, Simon wrote:
  I have uploaded a web based  CD to our Moodle setup, but all the links
  are broken. In true sloppy MS style most of the filenames are in
  uppercase whereas the html files refer to them in lower case. The
  underlying webserver is Apache, (thought mod-speling might help from
  some reading but it is already installed). I am looking for the lazy way
  out of going through and editing all the links in the html files or
  renaming all the disc files, is there a solution? NB there are hundreds
  of files and corresponding links :-(
 
 Since laziness is one of the cardinal virtues of the perl-hacker, try:
 
   perl -MFile::Find -e 'find sub { rename $_, lc $_ if -f $_  $_ =~ 
 m/\.html?$/i }, .'
 
 from the top of your cd directory tree. This will lowercase all file names 
 ending in .htm, .html, .HTML, .HTM, etc., so be careful that's exactly 
 what you want!

BTW, if you're familiar with find(1), you can do the same thing with that:

  find . -type f -iregex '\..*html?$' -print

to check the file list, and then:

  find . -type f -iregex '\..*html?$' -print0 | perl -n -0 -e 'rename $_, lc $_'

to do the renames. Note those '0's are zeros, not letter 'O's.

Cheers,
Gavin

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


[SLUG] Looking for lazy way out

2005-06-22 Thread Simon
HI all,
I have uploaded a web based  CD to our Moodle setup, but all the links
are broken. In true sloppy MS style most of the filenames are in
uppercase whereas the html files refer to them in lower case. The
underlying webserver is Apache, (thought mod-speling might help from
some reading but it is already installed). I am looking for the lazy way
out of going through and editing all the links in the html files or
renaming all the disc files, is there a solution? NB there are hundreds
of files and corresponding links :-(


OLMC
Simon Bryan
IT Manager
[EMAIL PROTECTED]
LMB 14
North Parramatta
tel: 96833300
fax: 98901466
mobile: 0414238002


-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Looking for lazy way out

2005-06-22 Thread Michael Fox
On 6/23/05, Simon [EMAIL PROTECTED] wrote:
 HI all,
 I have uploaded a web based  CD to our Moodle setup, but all the links
 are broken. In true sloppy MS style most of the filenames are in
 uppercase whereas the html files refer to them in lower case. The
 underlying webserver is Apache, (thought mod-speling might help from
 some reading but it is already installed). I am looking for the lazy way
 out of going through and editing all the links in the html files or
 renaming all the disc files, is there a solution? NB there are hundreds
 of files and corresponding links :-(

Another email? Is your SMTP server broken? As this is the 2nd time
this has come through

Hehe
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html