[parenscript-devel] best practice for developing a JS-only HTML5 webapp?

Red Daly reddaly at gmail.com
Sat Jan 8 23:05:37 UTC 2011






On Jan 8, 2011, at 1:44 PM, Jon Rosebaugh <chairos at gmail.com> wrote:

> As I said in the subject, I'm working on a JS-only (no server-side
> code) HTML5 webapp in Parenscript with jQuery. I have extensive JS
> experience, but I'm really new to Common Lisp.
> 
> I wanted a setup where I could edit a Parenscript file, hit save, then
> hit refresh in my browser and immediately see the new code, just as if
> I were working in Javascript.

I have such a setup, except that it can handle several files, either js or parenscript sources, with dependencies between the files.  It is an extension to ASDF.  In addition, there is a rough slime plugin that will send changes you make in emacs across a websocket to your browser.

Embarrassingly not much is documented, but the relevant libraries are paren-files for compilation and slime-proxy.  Paren-files is pretty well tested and mature, but needs docs.  The other lib needs some love, especially with the elisp side of things.

> I built a little server using
> Hunchentoot and cl-who that runs ps-compile-file on my parenscript
> source file as needed. This works fairly well, but maybe is not the
> best way to accomplish this.
> 
> However, there's a problem; I wanted to use parenscript functions
> without the namespace, so I defined a package in serve.lisp that uses
> parenscript, then put (in-package :innkeeper) at the top of my
> parenscript file. This doesn't work properly in the 2.2 release of
> Parenscript (which is what Quicklisp provides). It _does_ work in the
> git repo version (as of commit
> 0e01e555f404a7dcb8befb7587288c38abf526c2), but it's annoying to not be
> able to use Quicklisp for everything.

Yeah, Common Lisp will develop your character with charming exercises like that.  In my experience it's usually worth it anyway.

> 
> Once I have a release version I'll want to come up with some lisp
> program that compiles the parenscript to javascript, minifies it, and
> sticks it in an also-minified html file from cl-who, so the whole
> thing is compiled down to a single file. I'd appreciate any
> best-practice tips on that too.
> 
> Just in case my description was unclear, here's what I think are the
> relevant bits. If needed, I can provide the entire files off-list.
> 
> ; relevant bits of serve.lisp
> (defpackage "INNKEEPER"
>  (:use "COMMON-LISP" "HUNCHENTOOT" "CL-WHO" "PARENSCRIPT")
>  (:export :start-innserver :stop-innserver))
> 
> (in-package :innkeeper)
> 
> (define-easy-handler (jsgen :uri "/innkeeper.js") ()
>  (setf (content-type*) "application/javascript")
>  (ps-compile-file "/Users/jon/code/innkeeper/innkeeper.lisp"))
> 
> ; beginning (and a few representative lines) of innkeeper.lisp
> 
> (in-package :innkeeper)
> 
> (defmacro immediate (&body body)
>  `((lambda () , at body)))
> 
> (var *inn*
>     (create
>         setup (lambda () ((@ ($ "#top-tabs") tabs)))))
> 
> (j-query #'(@ *inn* setup))
> 
> _______________________________________________
> parenscript-devel mailing list
> parenscript-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/parenscript-

Red



More information about the parenscript-devel mailing list