Forum OpenACS Q&A: __ns_dirlist, fastpath, OpenACS 4.6.3

I need to provide directory access to files on a Linux server, and the file names contain spaces. The site is running OpenACS 4.6.3 and AOLserver AOLserver/3.3.1+ad13. I have the nsd-config.tcl file set as follows:

ns_section "ns/server/${servername}"
ns_param directoryproc css_dirlist ;# the name of the new procedure.
ns_param  directorylisting fancy              ;# Can be simple or fancy.

In the directory listing, it appears that the filename links are being truncated after the first space.

I tried modifying the __ns_dirlist function in fastpath.tcl to use the string map function to replace spaces with %20, but it does not appear that the function is being called (I added some ns_log lines, and nothing is showing up in the log file). Then I downloaded the css_dirlist from, modified nsd.tcl accordingly, but it doesn't appear that it is being called either.

Does OpenACS 4.x do directory listings differently? I don't have problems on my OpenACS 3.x site.

Posted by Bart Teeuwisse on

OpenACS has rolled ns_dirlist (or at least the creation of an index page) into the request processor. I don't have the time to look up exactly where but you can find it by searching for lines from the fastpath.tcl _ns_dirlist function in the OpenACS code base.


Posted by Tom Jackson on

Yes it does do things differently. Actually OpenACS copies the function of the dirlist proc, which is why it doesn't show up like you want it to, I had the same problem and it took me a while to figure out the problem.

I have set this up to work in the current version of OpenACS, let me see if I can get a copy of what I did.

Posted by James Thornton on
I found the problem -- in the rp_html_directory_listing proc, I changed

  set link "<a href=$tail>$tail</a>"

  set link "<a href=\"$tail\">$tail</a>"

(notice the quotes)

Posted by Don Baccus on
Submit a patch!  Don't delay - this is your chance for 15 minutes of fame! :)
Posted by Tom Jackson on

Okay, I tracked down what I did, which was simply to add a file "global/file-not-found.tcl", and a new configuration param under redirects.

The full instructions on a slightly nicer dirlist, plus all the files are at Download the tar file.

Note that the dirlist proc provided with OpenACS, as I tested it, would display the contents of _any_ directory which didn't have an index file (those under package www directories). My file-not-found file ensures the directory is under the actual pageroot of the server.