This is a really good question. Anti webpages are an experimental way
to create web pages and applications. Some of the design decisions I
made while creating them I would now do differently.
The antiweb manual is a simple example of an anti webpage (awp). It is
included with the antiweb distribution in src/manual.awp. When used in
this way, awps are compiled completely to static HTML files. These files
(along with gzipped copies of them) are stored in the antiweb cache
directory so they can be served very efficiently with antiweb. Before
antiweb serves up these static files, it checks to see if the modification
time on the awp file has changed. If it has, it recompiles the awp before
serving the files. In this sense, awp pages are more like a content
management system than a dynamic website programming environment.
However, awps can also be used to generate dynamic content. At the lowest
level, you can include lisp code in your awp file by including it
in a progn form:
(progn
(defmacro assert-or-return-error (status msg test)
`(unless ,test
(return-from :aw-handler (build-http-response ,status (("Content-Type" "text/html")) ,msg))))
)
And you can install POST and GET handlers which are also lisp code. Here's
an (untested) example:
(post-handler "/new-entry" (args)
(www-form-bind args (id contents)
(assert-or-return-error 400 "bad id parameter"
(and (stringp id) (#~m/^\d+/$ id)))
(assert-or-return-error 400 "missing contents parameter"
(stringp contents))
(with-bdb-transaction
(setf (bdb-get "entries.db" id) contents))
(build-http-response 200 (("Content-Type" "text/plain"))
"entry added OK")))
Antiweb's bdb (BerkeleyDB) bindings are described here:
http://hoytech.com/transactional-programming.html
When antiweb receives the first request for the awp file, it extracts all
the lisp code in the awp file and stores it in a .lisp file in the antiweb
cache, then uses the lisp compiler to compile it to machine code and loads
it. When it sees that the modification time of the awp file has changed, it
recompiles the lisp code in the same was as it does for static files.
There is also functionality for regular expression parsing of your routes,
URL decoding, JSON (de)serialization, cookie extraction/setting, etc but
unfortunately it is not documented.
While awp pages do have a rudimentary templating feature, this is not
complete and I would like to seriously improve on it. The best templating
system I have seen for any language is Perl's Template Toolkit and some
day I would like to copy it for AW:
Hope this helps describe what anti webpages are a bit better.
Doug
> --
> You received this message because you are subscribed to the Google Groups "antiweb" group.
> To post to this group, send email to ant...@googlegroups.com.
> To unsubscribe from this group, send email to antiweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/antiweb?hl=en.
>