Interactive Site listing CGI
Peter Reid
preid at reidit.co.uk
Mon Feb 7 17:28:29 EST 2005
>Hi Peter,
>
>I think this is a case where one can transplant
>regular Transcript into the rev-cgi arena. From a
>recent post :
><http://lists.runrev.com/pipermail/use-revolution/2005-February/050789.html>
>
>Of course in that script you can skip the folders, if
>you're not looking to make available the files in the
>subfolders.
>
>So you'll end up with something like :
>--
>on startUp
>
> ## STEP 1 :: read the arguments
> # read the query string passed from the webserver
> put $QUERY_STRING into tQueryStringA
> # turn it into an array for convenient access
> split tQueryStringA using "&" and "="
> # make sure to URLDecode the arguments
> put the keys of tQueryStringA into tArgNames
> repeat for each line tArgName in tArgNames
> put URLDecode(tQueryStringA[tArgName]) \
> into tArgumentsA[URLDecode(tArgName]
> end repeat
>
> ## STEP 2 :: read the files
> # now that we have our arguments, move on to the dir
> set the defaultDirectory to <tRootDir> & \
> tArgumentsA["directory"]
> # read all the files in the chosen directory
> put the files into tFiles
>
> ## STEP 3 :: build the file list as an HTML page
> # you will want to change the formatting
> put "<html><head>" into tBuffer
> put "<title>Directory Contents</title>" after \
> tBuffer
> put "</head><body>" after tBuffer
> put "<h1>Directory Contents :" && \
> tArgumentsA["directory"] after tBuffer
> put "</h1><hr />" after tBuffer
> # loop over the files
> repeat for each line tFile in tFiles
> put "<a href=" & quote & \
> URLEncode(tArgumentsA["directory"]) & "/" & \
> URLEncode(tFile) & quote & ">" after tBuffer
> put tFile & "</a><br />" after tBuffer
> end repeat
> put "<hr /></body></html>" after tBuffer
>
> ## STEP 4 :: send the result to the webserver
> # start with the headers
> put "Content-Type: text/html" & cr
> put "Content-Length: && the length of tBuffer
> put cr & cr & tBuffer
>
> # end of the cgi-script
>end startUp
>--
>
>Hope this gets you closer to your solution,
>
>Jan Schenkel.
Thanks Jan, I'll see where this takes me.
Peter
--
Peter Reid
Reid-IT Limited, Loughborough, Leics., UK
Tel: +44 (0)1509 268843 Fax: +44 (0)8700 527576
E-mail: preid at reidit.co.uk
preid at reidit.demon.co.uk
Web: http://www.reidit.co.uk
http://www.reidit.demon.co.uk
More information about the use-livecode
mailing list