filsa.net: Frontier / Scripts / Weird Macros / Publishing Source code (2)
This is part of Phil's Script Archive

Publishing Source code (2)

How I include source in my pages.


This fat web page contains the linkSourceCode script object.

Use the 'Get Page Data' command from the Scripts menu to copy linkSourceCode into your object database.

Also available: info about fat pages and the Terms under which you can use this script.

This macro is one I use on every page of my scripts site. It publishes the source code of each script on a separate HTML page.

It shows one possible method for a macro generating other HTML files. This one is very simple, but it's easy for a macro to generate other files: for example, a frame macro might generate and render all the files that are called by a frameset.

The macro is called linkSourceCode

What it does: Creates an HTML page with the source of the script (specified by adrSource), writes the file to disk, and then returns the text of a link to that page.

Parameters:

insertSourceCode (adrSource=nil, adrPageTable=nil, srcSuffix = "_src", linktext=nil)

adrSource: Optional. The address of the script to publish (doesn't actually have to be a script). If this parameter is empty, the macro tries to look for adrPageData (fat page info) and use that as the adrSource.

adrPageTable: Optional. Defaults to whatever is in html.data.adrpagetable.

srcSuffix: Optional. The name of the source file is the same as the page being rendered, except that we add SrcSuffix. Defaults to "_src". An empty string "" results in an error.

linktext: Optional. The text of the link that is returned to the page. Defaults to the adrSource string.

Notes

I started using this after I got tired of using the includeSourceCode macro in my pages. I wanted the source to be in a separate file, and I wanted it to be completely automatic, so I wrote this macro.

Tue, Jun 16, 1998 at 0:07:57 PM by PS

I added a linktext parameter, which allows you to specify the text of the link. Hence the name. ;-)

Comments?

Send 'em to me, phil@filsa.net.

Thanks.

An example of this script in action is below, where you can see the source.

View the Source: user.html.macros.linkSourceCode


© copyright 1997-98 by Philip Suh. Comments are appreciated.
This page last updated on 7/17/98; 1:25:24 PM.
<http://www.filsa.net/frontier/scripts/WeirdMacros/linkSourceCode.html>
filsa.net: Frontier / Scripts / Weird Macros / Publishing Source code (2)