PageTemplate for Site Generation
So I was looking at my Python Blogger client and I tried implementing the same thing in Ruby. gdata-ruby confusion stymied me. I still don’t know whether library issues or my own ignorance blocked me.
That, of course, set me off on yet another thought. What if I tried to define my posts in a PageTemplate file and used filters to handle the dirty work? Well, that might be a little challenge. But what if I used this approach to generate a whole Web site? Okay, yeah. That may have come out of nowhere for you. The truth is that I love static site generation tools, from ZenWeb to WebMake. These tools appeal to me because coolnamehere is pretty much a static site and I love anything which can give that pile of pages a common format without making heavy server demands. Honestly, loading up PHP just so I can have a templated site seems like overkill.
Let’s see if I can build a site like coolnamehere with Ruby and PageTemplate. I plan to borrow heavily from ZenWeb, since there are a lot of things to like about the ZenSpider approach. I especially like building a site from a collection of pages and a chain of filters. Hey, PageTemplate has filters thanks to Greg Millam. Why don’t I try using them?
I am going to start small, by teaching SiteTemplate about Maruku.
It took me a bit of time to get that much done, because I needed to relearn how PageTemplate initializes. Note to self: don’t ever go a full year without using your own library.
The test is simple: create a template using the Maruku filter. Compare the output of that template with the text minus PageTemplate directives and fed into Maruku. The test passes if they look alike, or close enough.
Then the code I needed to make that test pass:
I cut corners by adding the
maruku filter method to PageTemplate’s DefaultPreprocessor. PageTemplate’s internals need a little work, since this isn’t the prettiest way a person might want to add filters. It works well, but it’s not pretty.
That works well enough. Next time I’ll try a template filter, which puts the Maruku output into a template file of my choosing. That way we get the standard look for pages.