Script For Viewing Thdl Contents

THL Toolbox > Developers' Zone > Script for Viewing THL Contents

Script for Viewing THL Contents

Contributor(s): Than Garson

Folder Structure

The present folder structure for THL can be viewed through a CGI script at external link: It starts at the root level, /thdl, and gives a progressively indented hierarchy of the THL folder structure. If the parameter "loc" is given set to the location (from /lv1) of a particular folder, the hierarchy of that folder is displayed. Thus,

external link:

displays the structure of the Art Collection's folder.

Folder Contents

Each folder name in the hierarchy is also linked. Clicking on one of them will activate another script called, This script will display the contents of the selected folder. Sub-folders are listed first. Then, files. Both are listed alphabetically irregardless of capitalization. The script also takes a "loc" parameter that contains the location (from /lv1) of the folder. Thus, the contents of the Collections folder may be seen by clicking on:

external link:

This script also displays a "Back" link (equivalent to the browser's back button) and a "Show folder hiearchy" link that calls for that folder.

Location and Maintenance Information

Both perl files are located in the "cgi-tibet" folder at /www/cgi-tibet. This means to get there you have to go up from /lv1/thdl to the root. Choose the symlink to "www" and then open the cgi-tibet folder. It is for this reason that the "loc" parameter must identify the folder location beginning with "/lv1/thdl....". The script requires a "loc" parameter and will crash without it. The does not necessarily need a "loc" parameter. If none is given, then the script automatically sets it to "/lv1/thdl" and displays the hierarchy for THL's root folder. Should THL be moved to another server or the present server somehow rearranged, this may need to be changed. The relavent code is at the top of the script and is as follows:

$q = new CGI;
$folder2srch = $q->param( "loc" );
$headStr = "THDL Directory: " . $folder2srch;
if($folder2srch eq '') {
$folder2srch = '/lv1/thdl';
$headStr = "THDL Root Directory";

The first line sets the variable $q to an new CGI object. Then, the $folder2srch variable is set to the parameter passed to the script by the name of "loc". The header string is then set appropriately. The next block of statements says that "if the $folder2srch variable is empty, set it to '/lv1/thdl' and set the header to 'THL Root Directory'." The line that would need to be changed in the event of a moving or restructuring of the server would be:

$folder2srch = '/lv1/thdl';

The '/lv1/thdl' would have to be changed to the location from the server's root level of THL's main folder. This is not in anyway connected to our permanent URL, This has to do with the location of our root folder on the server. So, if the whole THL got moved to /lv9/asia/thdl, then that line would have to be changed to: $folder2srch = '/lv9/asia/thdl';

Provided for unrestricted use by the external link: Tibetan and Himalayan Library