Improving 68K Macintosh Browsing With Squid Part 3: Content Modification
Introduction
This is Part 3 of my series on improving basic internet browsing with a 68k Mac. This section deals with modifying image files to play nicely with IE4.
My Target machine has changed somewhat. I've recently aquired a SCSI2SD adapter and installed system 7.6.1 for something a bit different.
My Setup
Server:
VirtualBox VM
1 Processor
1 GB RAM
8 GB HDD image
Debian 9.3.0
|
Target Machine:
Macintosh Centris 650
25MHz 68040
108MB RAM (2x16MB, 2x32MB and 8MB onboard RAM)
16GB SCSI2SD HDD
Mac OS 7.6.1
|
If you've followed the tutorial so far open up /etc/squid/squid.conf and add the following line to the bottom of your document. Otherwise please see Part 1 and 2 to set up Squid and get your https working with this old browser.
url_rewrite_program /usr/local/bin/imagemod.pl
Next create the following folder and file and give it the proper permissions
mkdir /usr/local/bin/images
chmod 755 /usr/local/bin/images
nano /usr/local/bin/imagemod.pl
Copy this code into imagemod.pl. Basically this script grabs the image files and scales them down to a 68K friendly size and also converts png files to JPG as IE4 does not support this file type. Feel free to change the dimensions of the images to suit your needs.
#!/usr/bin/perl
$|=1;
$count = 0;
$pid = $$;
while(<>) {
@splitted=split(/ /,$_);
chomp $_;
if ($_ =~ /(.*\.jpg)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.jpg", "$url");
system("usr/bin/mogrify", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.jpg");
print "http://127.0.0.1/images/$pid-$count.jpg\n";
}
elsif ($_ =~ /(.*\.JPG)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.JPG", "$url");
system("usr/bin/mogrify", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.JPG");
print "http://127.0.0.1/images/$pid-$count.JPG\n";
}
elsif ($_ =~ /(.*\.gif)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.gif", "$url");
system("usr/bin/mogrify", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.gif");
print "http://127.0.0.1/images/$pid-$count.gif\n";
}
elsif ($_ =~ /(.*\.GIF)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.GIF", "$url");
system("usr/bin/mogrify", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.GIF");
print "http://127.0.0.1/images/$pid-$count.GIF\n";
}
elsif ($_ =~ /(.*\.png)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.png", "$url");
system("usr/bin/mogrify", "-format", "jpg", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.png");
print "http://127.0.0.1/images/$pid-$count.jpg\n";
}
elsif ($_ =~ /(.*\.PNG)/i) {
$url = $1;
system("usr/bin/wget", "-q", "-0","var/www/html/images/$pid-$count.PNG", "$url");
system("usr/bin/mogrify", "-format", "jpg", "-thumbnail", "640x480>", "-strip","/var/www/html/images/$pid-count.PNG");
print "http://127.0.0.1/images/$pid-$count.jpg\n";
}
else{
print "$splitted[0]\n";
}
$count++;
}
And that's pretty much it. Reboot your Squid box and give it a test! The only other thing you may want to do is set up a cron job to flush out the contents of /usr/local/bin/images . It will continue to fill up your drive if you're not careful.
Links
Upside-Down-Ternet
Improving 68K Macintosh Browsing With Squid
Last Updated: March 31, 2019
|