Thursday, November 27, 2008

NEWS ALERT!

The Frog has rolled over for the first time! Wow!

Thursday, November 20, 2008

Templates in the PLT Web Server

Almost all Web application frameworks have a templating system to allow the dynamic portion of a site to modify some semi-static content before displaying it. These frameworks are primarily useful because they allow the contributions of non-programmers to be more easily integrated into an application and remove a barrier to using traditional HTML design tools, like Amaya and Dreamweaver.

The PLT Web Server now provides a templating system of its own. It uses the syntax of Scribble to provide access to all features of PLT Scheme to template authors. Furthermore, it requires zero run-time parsing of templates—the templates your servlet uses are loaded and compiled when your servlet is compiled.

The documentation has all the details about using templates in your applications. But here's a short example:

template.html:

<table>
 @in[c clients]{
  <tr><td>@(car c), @(cdr c)</td></tr>
 }
</table>

servlet.ss:

(let ([clients (list (cons "Young" "Brigham")
                     (cons "Smith" "Joseph"))])
 (include-template "template.html"))

Evaluates to:

<table>
  <tr><td>Young, Brigham</td></tr>
  <tr><td>Smith, Joseph</td></tr>
</table>

Tuesday, November 18, 2008

Mother 3 / Earthbound 2

One of my favourite games ever is Earthbound for the Super Nintendo. A few years ago I heard about a sequel coming out for the Gameboy Advance. I obsessively checked video game news sites until it was clear that it was not going to come out in America. Luckily, in the middle of October of this year, Mother 3 was translated by fans and a patch released for the GBA ROM.

I just finished playing and, man, it is awesome. It recreates the feel of the original and pushes it up a few notches and adds a whole bunch of unique stuff. I was very impressed and satisfied.

If you only play one GBA game this year, make it Mother 3!

Sunday, November 16, 2008

Quote from Human Action by Ludwig von Mises

Socialism cannot be realized because it is beyond human power to establish it as a social system. The choice is between capitalism and chaos. A man who chooses between drinking a glass of milk and a glass of potassium cyanide does not choose between two beverages; he chooses between life and death. A society that chooses between capitalism and socialism does not choose between two social systems; it chooses between social cooperation and disintegration of society. (p.680)

Friday, November 14, 2008

PLT Web Server Documentation Reorganization

The PLT Web Server was one of the first systems to get documented in Scribble, which was very convenient compared to the old documentation. However, it was organized too much like a reference manual with little guide to a user to understand how some modules fits in to the big picture. I've reorganized the documentation with the following paradigm:

  • Running the Web Server
  • Writing Servlets
  • Extending the Web Server

Other improvement related to this: I've added examples to almost every servlet function. I have integrated the stateless and non-stateless servlet documentation to put stateless servlets on a more secure footing and make it clear that they are usable in real applications. I've created an HTTP sub-module that encapsulates most of the HTTP handling. (This will limit the need to use what used to be considered internal Web Server functions.)

Tuesday, November 11, 2008

HTTPS and the PLT Web Server

Most of the updates to the PLT Web Server today were internal refactorings to make it easier to make some of the bigger changes down the pipe. However, one change is public, and very nice.

It is often desirable to run an HTTPS server with your application. The PLT Web Server has always supported this, because its TCP implementation is parameterized. However, it was not nearly easy enough to actually use that flexibility, unless you were a Scheme warrior, like Eli Barzilay, who used it to implement the handin-server.

For that reason I've integrated running the PLT Web Server in HTTPS into the plt-web-server command-line tool:

plt-web-server --ssl

And you've got yourself an HTTPS server on port 443. You can override that too:

plt-web-server --ssl -p 8443

The only thing you need to do is create a private-key.pem and server-cert.pem in the directory you run the PLT Web Server in, and you're good to go. Instructions to create those are included in the FAQ on HTTPS.

Monday, November 10, 2008

Stateless Servlets in the PLT Web Server

For over a year, the PLT Web Server has supported stateless Web Servlets via the #lang web-server language. This language compiles the servlet in a special way that allows continuations to be used and serializes them to be stored by the client on their Web browser. This greatly improves performance, with relatively few restrictions.

Unfortunately, it was a major pain to use this language, because the default Web server configuration did not provide a way to serve them.

I have merged the two dispatchers that were responsible for these servlets and traditional servlets. Thus, every Web server configuration that allows any servlets will allow both. This will improve the ease of transition and experimentation for our users. Hopefully with more use, they become even more useful!

Friday, November 7, 2008

Top-Level Servlets in the PLT Scheme Web Server

A common feature request for the PLT Scheme Web Server is to support servlets that respond to top-level requests. This has been possible in the past with hacks that do URL rewriting and yesterday I talked about how it can be done more effectively with the generalization of the dispatcher (web-server/dispatchers/dispatch-servlets) that interfaces with Scheme servlets.

One of the conveniences provided by the Web Server is web-server/servlet-env, a module that quickly sets up a server tailor for a single servlet. The function it provides serve/servlet accepts an argument to specify the path the servlet should be available from, but it had to end in .ss. I've now removed that restriction and enabled the server to serve other Scheme servlets at the same time.

Now it is incredibly easy to build a PLT Scheme Web Server application that completely controls a URL namespace.

Thursday, November 6, 2008

Generalizing the PLT Web Server Servlet Mapping

One of the tasks of the PLT Web Server is to associate URLs with programs that are run to produce the results. In most Web servers, like Apache, this is done in two steps:

  1. Associate URLs with filesystem paths.
  2. Evaluate files with different prefixes using different engines, e.g., .html is static and .pl is Perl.

(In other servers, like Ruby on Rails, URLs are mapped to function calls by default and there is special configuration required to get static content.)

In the past, the PLT Web Server worked like Apache: URLs were mapped to files and every file that ended with .ss or .scm was interpreted as a Scheme servlet.

Now, it is customizable! The PLT Web Server now accepts an arbitrary function mapping URLs to servlets. The old functionality is available via a pair of functions that construct ``default'' variants of this function.

This will make it easier to customize in arbitrary ways and replicate the behavior of servers like Ruby on Rails in PLT!

Wednesday, November 5, 2008

Password protection in the PLT Web Server

The password protection module for the PLT Web Server was very brittle and non-configurable, because it only allowed passwords to be setup via a password file. I've generalized it to accept an arbitrary predicate and provided some functions to recreate the old behavior by assembling the right predicate based on the contents of a password file. Hopefully this will make it easier to configure the Web Server.

Tuesday, November 4, 2008

Fast server setup in the PLT Web Server

Based on some feedback from untyped, I improved the documentation for Simple Single Servlet Servers in the PLT Web Server and added the option to provide many different paths to use to serve files. Hopefully this will make it clear what the incremental path of servlet development is.

New default configuration in PLT Web Server

I recently changed the default configuration in the PLT Scheme Web Server to allow servlets at any URL, rather than only inside of the "servlets/" sub-directory. One of the mistakes that I made in testing was to not close my browser or flush its cache. Matthew sent me an email this morning letting me know that it was trying to serve the PLT logo as if it were a servlet. Fixing this problem was not as simple as adding a filter to only consider URLs that end in ss or scm, because a common thing in Web apps is to add additional information in the URL, such as "view.ss/that-table". Instead, I created a new function in web-server/dispatchers/filesystem-map called filter-url->path that filters the result of the function that extracts the longest URL that points to a valid file. I just committed the change to SVN with the beautiful revision number 12233.