Re: viewing source code with embedded links

Rob McCool ([email protected])
Mon, 1 Nov 1993 15:46:52 -0600


/*
* viewing source code with embedded links by bryan d oakley (uunet!ctrbdo%[email protected])
* written on Nov 1, 11:31am.
*
* I am wanting to be able to view source code using Mosaic such that the
* code remains in it's existing non-wrapped state, but with links being
* properly rendered (ie: as if a <PRE> preceded each file). Now, I
* don't want to have to add a <PRE> to each file so I'm wondering what
* is the best way to accomplish this.
*
* The problem I am trying to solve falls somewhere between the domains
* of literate programming and the World Wide Web. The ultimate goal is
* to have hypertexified source code that a maintenance programmer could
* browse via Mosaic, with the ability to jump to specifications, test
* documents and so on. Ultimately I think it would be nice to have
* available a source code / HTML 'pretty-printer', which would take the
* source code and allow comments to be wrapped and rendered in a
* different font, perhaps tag variables with <VAR>, and so on.
*
* So, the question is, what's the best way to proceed? At this point,
* since I've just recently installed NCSA httpd (version 1.whatever),
* I'm assuming that I could create a script in htbin, though I'm not
* sure how I would use it. Ideally I would like the URL
* 'http://server/src/main.f' to execute my script causing main.f to be
* found and tagged, then displayed in Mosaic. If that URL won't work,
* is there one that will? I don't want the user to have to enter the
* name of the source file in an <ISINDEX> document.

Currently, there isn't any way to do this under NCSA httpd. What you can do
for now is write a short htbin script which takes as the first argument the
name of the source file and spits back something of type text/html
containing a <PRE> at the beginning. Such a script could be as simple as:

--cut
#!/bin/sh

echo Content-type: text/html
echo

echo "<PRE>"
cat $1
echo "</PRE>"

--cut

Note that this doesn't work for files with weird characters like spaces or
ampersands et. al., but you get the idea.

The way you'd access this is

http://your.server/htbin/src?/your/source/path/file.f

You can add HREFs to documents with question marks in them, and you can Open
URL in mosaic with the question mark in there and it will send it on to the
server.

We are planning to add the capability to have a script which looks like a
directory in the path name but is in actuality a file. I.e. if you were to
do:

http://your.server/htbin/src/your/source/path/file.f

The server would parse the URL, figure out that /htbin/src is actually a
server script, and execute it like

/htbin/src /your/source/path/file.f

* Perhaps someone is already working on such a beast? If not, I could
* use some fairly specific hints. I'm new to administrating httpd and
* Mosaic, so the knowledge base is low. I'm not on the internet so
* sound advice would be more appreciated than a pointer to an URL
* (though I can surf the 'net via my delphi account from home when I
* have to, so URLs would be appreciated as well).
*/

Hope this helps
--Rob