mailto:joel@yorku.ca
http://www.writer.yorku.ca/staff/joel/
URLShuffle is a Common Gateway Interface (CGI) for use with MacHTTP or Webstar and may be distributed freely. Its purpose is to take a bunch of URLs and rearrange their order, so users see links in a different order every time the CGI is called. URLShuffle is not specific to shuffling URL's. Basically, it can be used to shuffle any blocks of text in an html file.
You will need to:
(1) create a data file
(2) create a template file
(3) put both files and the URLShuffle.acgi in the same folder
(4) have a www browser call the CGI
URLShuffle uses three text files: a data file, a template file, and an html file. Two sets of sample files are included:
"sample" - these are files verbatim to the examples in this document
and
"chuckie" - these are files showing some more examples of shuffling
Data files:
These files have a ".dat" extension and are used to store the URLs to be shuffled. The first line of the file should indicate the number of URLs in the file followed by a carriage return. You should then insert the URLs, each ending with a carriage return. You can have a maximum of 50 entries in a data file. For maximum effect you will probably want to have six or more entries. Five works fairly well, too.
e.g.,
6
http://www.yorku.ca/
http://www.writer.yorku.ca/
http://www.yahoo.com/
http://www.info.apple.com/
http://altavista.digital.com/
http://www.webcrawler.com/
Template files:
Template files have a ".tpt" extension and are basically html files. The difference is that you will insert "(shuffle)" markers where you would like the reference from the data (.dat) file inserted. The template file is important so you can decide what format you would like the URLs to be displayed in. Since the data file and template file are used together, make sure the names before the filename extension are the same (i.e. "sample.dat" and "sample.tpt")
e.g.,
<HTML>
<HEAD>
<TITLE>yourTitle</TITLE>
</HEAD>
<BODY>
<UL>
<LI><A HREF="(shuffle)">anchor text</A>
<LI><A HREF="(shuffle)">anchor text</A>
<LI><A HREF="(shuffle)">anchor text</A>
<LI><A HREF="(shuffle)">anchor text</A>
<LI><A HREF="(shuffle)">anchor text</A>
<LI><A HREF="(shuffle)">anchor text</A>
</UL>
</BODY>
</HTML>
HTML files:
These files have a ".htm" (no 'L') extension. This is an html file that URLShuffle creates by copying the template (.tpt) file and substituting "(shuffle)" markers with entries from the data (.dat) file.
Launching the CGI:
URLShuffle can run synchronously or asynchronously. If the CGI runs synchronously, MacHTTP not process any requests from a browser until it receives a reply from the CGI. Running asynchronously, MacHTTP can continue processing requests while waiting for a reply from the CGI. To run synchronously, change the .acgi extension to .cgi.
i.e. URLShuffle.acgi becomes URLShuffle.cgi
Place URLShuffle, the data file, and the template file in the same folder. The direct parameter (text after the $) is used to specify the data/template files to use. So if you wanted to use the "sample" files,
URLShuffle.acgi$sample
would launch URLShuffle using the "sample.dat" and "sample.tpt" files to create the file "sample.htm". Any previous "chuckie.htm" file would be nuked and replaced by the new one.
URLShuffle would then send an HTTP header to MacHTTP/Webstar redirecting the user's browser to download the "sample.htm" file.
e.g.
conventially, you would have to have an html page with a link that calls URLShuffle:
<HTML>
<HEAD>
<TITLE>URLShuffle parent page</TITLE>
</HEAD>
<BODY>
<A HREF="/yourPath/URLShuffle.acgi$yourFile">anchor text</A>
</BODY>
</HTML>
Whenever the link is selected, URLShuffle will create a new page based on your template file, shuffling the contents each time it is reloaded. The caches of some browsers such as Netscape may prevent users from observing the page shuffled on subsequent occasions, unless they reload the page.
Alternatively, you may want URLShuffle to run automatically whenever someone accesses your page.
If you want to have the CGI run automatically when your page is accessed, you can put a META tag in your header to automatically execute a URL. I believe this only works with Netscape 2.x compatible browsers. Also, circumstances surrounding the cache and reloading don't seem to apply here. Just create an HTML file like this (you should explicitly reference your URL, i.e., http://...):
<HTML>
<HEAD>
<META HTTP-EQUIV=REFRESH CONTENT="0;
URL=http://yourServer/yourPath/URLShuffle.acgi$yourFile">
<TITLE>doYouNeedaTitle?</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
More?:
Hi,
This is my first attempt at CGI authoring. I wrote it with Think C 6.0, using the ANSI library for manipulating strings and files. A friend wanted things to be well... "not necessarily in that order". Well, they aren't and thanks for reading the docs. If anyone actually uses this thing, I'd be interested to know. My email address is joel@yorku.ca.
peace,
Joel
23 July 1996