From: Johann Hibschman
Subject: design advice for HTML generation?
Date: 
Message-ID: <mtlns969py.fsf@physics.berkeley.edu>
Hi all,

As part of my recreational programming for the past week or two, I've
been working on code to generate HTML from lisp.  I've been playing
with a few paradigms for structuring the code.  I'm currently using a
"makefile" style approach, with several source files which are read
and converted into actual HTML.

Source files are like:
   (html (head :title "Sample" :author "Johann")
     (bold "Blah blah")
     (par  "etc. etc.")
     (standard-footer))

In the beginning, these files were lambda-expressions calling actual
functions.  I would read them in, evaluate the lambda expression, and
apply it to a list of paramters.

I didn't like this, so I started simply reading the source files as
lists and using symbol-function to look up and apply the functions.
This seems much nicer to me.

Now, however, I'm wondering if I should take it a step further.  I
could keep a (symbol . function) association list, then look up the
read symbols in that list to find the function, rather than calling
symbol-function.  I could replace the defun's of functions like "par"
with macros which would enter the symbol/function pair into the
assoc-list.

This seems conceptually cleaner, in that I'd have full control over
what may appear in a source file, but I'm not sure it's worth the
effort.  Does anyone have any gut feeling on what would be
stylistically nicer?

Also, does anyone know of other public code that does something
similar?  I've seen the snippets of code in Paul Graham's ANSI Lisp
book.  Like I said, I'm just dabbling with this for fun, so I'm not
looking for something to use in practice, but more examples could be
fun to read.

Thanks,

- Johann

From: Rainer Joswig
Subject: Re: design advice for HTML generation?
Date: 
Message-ID: <6j65cv$dj4@desire.lavielle.com>
>As part of my recreational programming for the past week or two, I've
>been working on code to generate HTML from lisp

CL-HTTP has extensive capabilities for generating HTML code.
No need to reinvent. ;-)
From: Kelly Murray
Subject: Re: design advice for HTML generation?
Date: 
Message-ID: <nmpvhktkho.fsf@charlotte.i-have-a-misconfigured-system-so-shoot-me>
Johann Hibschman <······@physics.berkeley.edu> writes:
> been working on code to generate HTML from lisp.  I've been playing..
>    (html (head :title "Sample" :author "Johann")
>      (bold "Blah blah")
>      (par  "etc. etc.")
>      (standard-footer))
>

I've invested a lot of time on HTML generation.
The approach I've taken is to simply use macros, which ultimately
expand into calls to an output function. 
Of course, in my case,
the code is running within my Charlotte web server, and so the output
is not statically translated into static HTML files,
but executes at runtime within the server.
Doing it using macros allows the code to be compiled and executed
very efficiently with NO interpretation overhead.
Basically, static portions execute by directly generating strings.

I've appended below a SilkScript example from Mark Mann's Cooltutor.

Another related functionality which Charlotte supports is downloading
entire website trees from other servers.  So if you have a bunch
of documents that are dynamically generated, but otherwise are
static, Charlotte can execute them by accessing their URLs from
another web server that generates them dynamically,
and then cache the HTML results as static pages.
Therefore, the users view is always one of dynamic
generation and caching is only used as an optimization
to reduce CPU overhead of dynamic generation.

-Kelly Murray  ···@franz.com
  Lisp for the 00's   http://charlotte.franz.com/silkos




----cut-here------

 (head (meta :name "generator"
	     :content "Interaction 1.6p http://interaction.in-progress.com")
       (title "CoolTutor.Com"))
 (body :bgcolor "#060506"
       :text "#ffff9c"
       :link "#ffff9c"
       :vlink "#ff9c4a"
       ;; not supported
       ;; :credits "http://wg.compsmart.com/wg/credits.html"
       ;; :instructions "http://wg.compsmart.com/wg/howto.html"
       ;; :logo "http://wg.compsmart.com/wg/wgsmall.gif"
       )

 ;; make links work back to original server.
 (base "http://www.cooltutor.com/")

 (style :center
  (heading "Welcome to CoolTutor.Com")
  (table (:cellpadding 10)
    (row ()
      (cell ()
	(image :src "http://24.4.97.25/coolguy.gif" :alt "Pop Star"))
      (cell ()
	(image :src "http://24.4.97.25/hippie.gif" :alt "Daisy"))
      (cell ()
	(image :src "http://24.4.97.25/cave.gif" :alt "CaveMan"))
      (cell ()
	(image :src "http://24.4.97.25/gal.gif" :alt "Librarian"))
      (cell ()
	(image :src "http://24.4.97.25/spaceman.gif" :alt "Spaceman"))
      (cell ()
	(image :src "http://24.4.97.25/sunny.gif" :alt "Sunny"))
      (cell ()
	(image :src "http://24.4.97.25/man.gif" :alt "White Collar"))
	)))

  (table (:cellspacing 25)
    (row ()
      (cell (:align :center)
	(anchor "ONLINE CLASSROOMS" "chat/index?id=6354115"))
      (cell (:align :center)
	(anchor "ONLINE TUTORIALS" "tutorials/lessons?id=6354115"))
      )
    (row ()
      ;; Column 1
      (cell (:valign :top :width "50%")
	(text
	 (:bold "Hi. ") 
	 "You have found the place where people gather for classes "
	 "and tutorials on Web Site Design and Web Site Administration. "
	 "In order to help you get motivated for the task of learning html, "
	 "you are free to read or post html or xml related thoughts "
	 "on our News Group "
	 (anchor "forums" "forum/index?id=6354115")
	 ", or you can also visit our live online classroom where we "
	 (anchor "discuss html design." "/chat/room1?id=6354115")
	 ))
      ;; Column 2
      (cell (:valign :top :width "50%")
	(text
	 "Online tutorials are the heart of the time-independent "
	 "component of the CoolTutor Site. "
	 "After you take the "
	 (anchor "HTML QUIZ" "quiz?id=6354115")
	 " as a pretest of your HTML knowledge, "
	 "feel free to spend time working with our "
	 (anchor "online lessons" "/tutorials/lessons?id=6354115")
	 " and the "
	 (anchor "html composer" "/tutorials/index?id=6354115")
	 "."
	 )
	(hline)
	(style :center
	  (text "This Site is powered by "
		(anchor "Charlotte" "http://www.franz.com")
		"."))
	))
    (row ()
      (cell (:colspan 2)
	(style :center
	  (text :size "-1"
		(anchor "Web Browser Issues" "browsers?id=6354115"))
	  )))
    )
  )
 )