Jump to content

Gsak Html Prep For Plucker


Recommended Posts

Here is a perl script I created to manipulate the html output by GSAK to make it 'prettier' in plucker. I added links to the different directions and back to the top in the Bearing index pages.

 

#!/usr/bin/perl

 

#

# DESC: Search and Replace GSAK GeoCache HTML

#

 

print "\nSearch and Replace $ver\n";

 

@filelist = <*.htm>; #<*$glob>;

 

# process each file in file list

foreach $filename (@filelist) {

$filename1 = $filename;

 

# retrieve complete file

open (IN, "$filename") || die("Error Reading File: $filename $!");

{

undef $/;

$infile = <IN>;

}

close (IN) || die("Error Closing File: $filename $!");

 

# $infile =~ s!!!gsi;

 

# Index Page - remove some indexes I don't use

$infile =~ s!\<a href..PlacedBy.htm.*?\<br\>!!gsi; # Remove Placed By index

$infile =~ s!\<a href..LastFound.htm.*?\<br\>!!gsi; # Remove Found Date index

$infile =~ s!\<a href..UserFound.htm.*?\<br\>!!gsi; # Remove Found by Me index -- can comment out

$infile =~ s!\<a href..TravelBugs.htm.*?\<br\>!!gsi; # Remove Travel Bugs index

 

# Bearing Indexes - add jumps to all directions

$infile =~ s!(\<b\>Bearing: N\<\/b\>).*?(\<br\>)!<a name="n"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: NE\<\/b\>).*?(\<br\>)!<a name="ne"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: E\<\/b\>).*?(\<br\>)!<a name="e"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: SE\<\/b\>).*?(\<br\>)!<a name="se"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: S\<\/b\>).*?(\<br\>)!<a name="s"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: SW\<\/b\>).*?(\<br\>)!<a name="sw"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: W\<\/b\>).*?(\<br\>)!<a name="w"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

$infile =~ s!(\<b\>Bearing: NW\<\/b\>).*?(\<br\>)!<a name="nw"></a>$1 - <a href="\#n">N</a> <a href="\#ne">NE</a> <a href="\#e">E</a> <a href="\#se">SE</a> <a href="\#s">S</a> <a href="\#sw">SW</a> <a href="\#w">W</a> <a href="\#nw">NW</a> <a href="\#top">Top</a>$2!gsi;

 

# Found by me Index

$infile =~ s!\*NotFound\*.*?\<br\>!!gsi; # Remove all Not Found links

 

# Cache pages

#Remove Current and link line at top

$infile =~ s!\<center\>.*?\<center\>.*?Current at.*?\<\/center\>.*?\<br\>!!gsi;

 

# write complete file

open (PROD, ">$filename") || die("Error Writing to File: $filename $!");

print PROD $infile;

close (PROD) || die("Error Closing File: $filename $!");

 

}

 

print "\nFinished.\n";

 

exit(0);

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...