Hi again,

There are still problems with my 'default' script. One is the use of "@lib.css" (2nd line under "(html NIL"); it seems to make my browser look for "http://localhost:8080/@lib.css";. For some reason my browser is also looking for "http://localhost:8080/@lib/form.js";, but not always. I have tried replacing the "@lib.css" with NIL, but the browser keeps expecting @lib/form.js. Strange ...


/Jon

On 23-05-13 16:07 , Jon Kleiser wrote:
Hi,

Here is my improved 'default' script. It now works both on c9.io and on localhost, and it handles both "doc" and "doc/". The logic that takes care of all this, may not be rock solid and very clean, but at the moment it's the best I can do. Here it is:

# This 'default' will be executed as a "script", called from lib/http.l

(let (Localhost (tail (chop "127.0.0.1") (chop *Adr))
        IndexOf "Index of "
        Path (car (file))
        APath Path
        Th '(class . th) )
    (when (tail '("/" "/") (chop Path))
(setq Path (pack (head -1 (chop Path)))) # removing extra "/" at the end
        (setq APath
            (if Localhost
                Path            # need APath on localhost
                "" ) ) )        # no APath needed
    (html NIL
        (pack IndexOf Path (when Localhost " (localhost)"))    # title
        "@lib.css"
        '(style . "margin: 20px 60px; font-size: 105%;")    # body style
        (prin "<style scoped>"
            "tr:not(.th):hover {background-color: #ccf}"
            "</style>" )
        (<h1> NIL IndexOf Path)
        (<table> '(style . "border-collapse: collapse") NIL NIL
(<tr> Th (<th> NIL "Name") (<th> NIL "Last modified") (<th> NIL "Size"))
            (<tr> Th (<th> '(colspan . "3") (<hr>)))
            (chdir Path
                (for F (sort (dir))
(unless (= "default" F) # skipping name of this file
                        (let (Cnt (car (info F))
                                Dat (dat$ (cadr (info F)) "-")
                                Tim (tim$ (cddr (info F))) )
                            (when (=T Cnt) (setq Cnt "-"))    # directory
                            (<tr> NIL
                                (<td> NIL (<href> F (pack APath F)))
                                (<td> '(style . "padding: 0 2em")
(<span> NIL Dat) (<span> '(style . "padding-left: 1em") Tim) ) (<td> '(style . "text-align: right") Cnt)) ) ) ) )
            (<tr> Th (<th> '(colspan . "3") (<hr>))) )
        (<p> '(style . "margin: 0; font: italic small serif;")
(ht:Prin "PicoLisp v" (glue "." (version T)) " (" *OS ") Server") ) ) )

/Jon

--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to