HTML templating in Scheme?

Templating is one of those must-haves for building websites; separating content from presentation is sliced bread compared to cavalierly interleave logic and HTML into one file. In Scheme, I think that quasiquotation could be used in wonderful ways to create templates; namely, every template can be a function that simply takes parameters and directly uses quasiquotation as the templater:

(define blog-post-template
  (lambda (title date message comments)
    `(html
       (head (title "My Blog - " ,title))
       (body
         (div (@ (class "post"))
           (h1 ,title)
           ,message)
         (div (@ (class "comments"))
           (p ,comments) ...)))))

and then to use it, you would just use

(blog-post-template
  "Another pedantic blog post"
  "Nov 20, 2010"
  "Today I'm going to complain about everything ..."
  '("Awesome blog!"
    "Actually, I disagree with you on everything"
    "Spam"))

You could also add a little more flexibility into your template by accepting an association list of parameters rather than fixed parameters:

(define blog-post-template
  (lambda params
    `(html
       (head (title "My Blog - " ,(cadr (assq 'title params))))
       (body))))

which can be made easier to use by redefining quasiquote with some templating-specific conveniences.

Google Summer of Code 2009: WordPress proposal

Objective: Create a single-file PHP installer for WordPress that will automate the downloading, unpacking, and setup of a WordPress blog.

Reason: As of right now, setting up a WordPress blog involves a lot of fiddling with files. The user must download the archive, unzip it on their computer, open a ftp connection to their server, upload all of the contents, hope that all the permissions are right, and navigate to the right directory. Since WordPress is such a popular blogging software, many people (most of whom are not familiar with a Unix shell or do not have access to one) would benefit from a single-file installer.

Deliverable: One (1) PHP file. No other files can be included with this (unless embedded), since this would void much of the advantage of such a single-file installer.

Basic procedure (a rough plan):

  1. Instruct the user on the requirements of WordPress (needs hosting with PHP, etc.).
  2. Instruct the user on downloading and uploading this installer, and subsequently running it.
  3. Check the server environment for required components, correct permissions, etc.
  4. Give the user some options on name, location, etc. and solicit other options like database credentials.
  5. Download the latest WordPress distribution.
  6. Unpack the distribution to the right place.
  7. Proceed more-or-less with the “usual” install.

How to get around Safe Chat

Today, my friend told me about this amazing new Internet filter. He went to a meeting at the city hall, where it was being demonstrated to the government. Apparently, the police gave it the thumbs up and recommended it for the schools. On a news story, it said that it was made by a Purdue University graduate Gabe Luu.

To make a long story short… the entire program is amateurish (can’t blame the one guy) and ultimately ineffective.

Personal Proxies

On the Safe Chat website, there’s an example image showing Porn.com with and without Safe Chat. What Safe Chat does is kill any browser that’s not Internet Explorer (no Firefox). So… I set Safe Chat to block MySpace, because according to the media, MySpace is the breeding grounds of predators.

OK, Safe Chat blocked MySpace.com like it should. But, with my own little proxy server, I got around it easy. Strike 1 for Safe Chat.

Public Proxies

OK, so maybe Safe Chat didn’t block my proxy because it’s a tiny obscure little proxy only used by me. Let’s try something much more popular. Let’s try PHProxy.org. Nope. Still got to MySpace. Strike 2.

Instant Messaging

Safe Chat’s instant messaging works by whitelisting contacts. Safe Chat quickly killed Miranda when I started it. Renaming the executible didn’t work. Thank god they didn’t miss that easy easy trick.

How I broke it

I got out my trusty debugger/memory editor and started playing around with SCCheck.exe’s memory. It terminated or exited or died or something, and my Internet access was unfettered. “That was easy.” Programs shouldn’t just go away when another program messes with it a little. That’s like poking a security guard in the face and walking past without raising any alarms.

Conclusion

How much did Luu bribe the police with? Either that or the police were computer illiterate. Seriously. Protection is very simple and unintelligent. It blacklists sites (try blacklisting the Internet), filters words, and bans the user from choosing which browser or instant messaging client to use. That’s all. There’s no comprehensive, company-maintaned, often-updated list of bad sites and categories. Safe Chat cannot compare to a dedicated corporate filtering solution, such as one from 8e6 (which Kokomo Schools already has, too!). Actually, Safe Chat cannot compare to most software solutions like it. So sad.
This software also has one of the worst interfaces ever. Nice cool titlebar Luu… but you are in desperate need of a UI expert. Speaking of which… I’m available for reasonable rates.

To Be Verbs

It seems that a lot of people are enjoying my “To Be” Verbs Analysis” program, and, well, some aren’t. Since only the school has Writer’s Workbench, people have trouble finding time to use it. Well, now they can do it at home. Mitchell pointed out that “It doesn’t work!” because it wasn’t picking up “wasn’t”, “weren’t”, and “isn’t”. It’s fixed now, along with a minor issue with having “Dr.”, “Mr.”, and words like that.

If you could, spread it to any of your friends that might need it too.