RTex Webby Filter(2008-04-29)
Good news today. Webby, my favorite little static website generator that could, is now being developed on GitHub. This will make contributing to the project easier for those of a git persuasion, and hopefully take a bit of pressure off Tim’s shoulders in the long-term. I’ll be maintaining a fork for contribution.
I really enjoy playing with Webby, and my recent work with RTeX has tweaked my interest in integrating PDF generation. Here’s a walkthrough on how to add a quick filter to do just that.
Installing the Goods
First of all, some prerequisites:- Get started on Webby, and create a project.
- Install RTeX
- Brush up on your LaTeX (see the RTeX FAQ for a pointer on resources).
If you’ve done all this, you’re ready… if you haven’t, you’re just skimming to see if this is interesting and/or simple, and that’s okay, too.
Creating a Document
Let’s create a file in your Webby content/ directory called example.tex and put the following in it:
--- extension: pdf created_at: 2008-04-29 08:12:58.135564 -05:00 layout: false filter: rtex --- \documentclass[12pt]{article} \begin{document} \title{A simple RTeX-generated PDF} \author{You \\ your-address@your-site.com} \maketitle \newpage See, it's simple\ldots \end{document}
Okay, LaTeX content aside (it can be a bit much to take in if you’re not used to it), this is a simple document.
The first portion of the file (the part that looks suspiciously like a YAML document) is the metadata. The first thing you should notice is the rtex filter we’re assigning, which we’ll work on shortly.
We also set some other bits; the extension so that the generated document is named correctly (ie, example.pdf), and layout, which we unset (you could use a nice, reusable LaTeX layout, but let’s skip that for this example).
A Simple Filter
Creating the filter for Webby is easy; it’s just the bit of glue that sticks RTeX and Webby together.
In your Webby project’s lib/ directory (create it if needed), add a file. You can call it whatever you like, but let’s use rtex_filter.rb for now.
Here’s the contents of the file:
require 'rtex' Webby::Filters.register :rtex do |input, cursor| RTeX::Document.new(input).to_pdf end
Not exactly rocket science, is it?
The Results
Now, regenerate your site. I commonly keep this running, as you can read about in the Webby documentation:
rake autobuild
You should find example.pdf in the corresponding location under output/. Just link it from your normal Webby pages; and here’s mine, freshly generated.
Obviously this is a simple document, but don’t let that fool you. Much more complex documents can be generated, for example this fancy sample from an TeX Tutorial was also generated live.
With very few changes to the filter (eg, looking for additional processing options in a page’s metadata), arbitrarily complex documents can be created directly from Webby.
Not bad for a “runt with a special knack for transforming text” and a gem that’s a poor man’s binding.
RTeX 2 Preview 1 Released(2008-04-28)
I’m happy to release RTeX 2 Preview 1 (v1.99.0), now available as a gem from RubyForge. RTeX can be used as a plugin with Rails 2.0.1+.
History
In 2006 I released a Rails plugin, Rtex, used to generate PDFs via the LaTeX typesetting system. It became a popular choice for people looking for a more advanced alternative to PDF::Writer, especially for larger documents.
Wiebe Cazemier joined the project in 2007, helping to improve the plugin and fielding patches and bug reports.
RTeX 2
RTeX 2 isn’t just a Rails plugin; it’s distributed as a gem and includes a standalone executable that can be used to process documents outside a Rails process (for delayed processing or use in some other type of application) through a series of custom filters (eg, Textile).
For more details…
- Documentation and Manual
- RubyForge for gem distribution and GitHub for development.
RubyLearning Interview(2008-04-18)
Satish Talim of RubyLearning.com just posted my responses to several questions he posed on Ruby as a language and my tips on mastering it.
It was a fun interview, and around a topic I really enjoy speaking about; Thanks Satish!
Migrating to Ruby 1.9(2008-04-14)
Here’s the slides for the other talk I gave at Scotland on Rails, going over the syntax and language feature changes between Ruby 1.8 and Ruby 1.9.
This is a significantly updated and expanded version of a similar talk I gave at the Austin on Rails meeting in February.
Introduction to Ruby(2008-04-14)
Here are the slides for the talk I gave at the Scotland on Rails charity workshop on April 3rd … to a group of very forgiving attendees who had graciously donated money only to see the first speaker arrive late and out-of-breath!
As you might imagine, the content of the talk is fairly elementary—but if you’re looking for a brief, code-centric overview of Ruby’s language features and syntax this might be the ticket.
Playing Catch-Up(2008-04-13)
It’s been a busy month, finishing up a big release at work and then escaping to hang out in the UK for a bit. Not that it’s an excuse to go dark, of course, but I have been preoccupied!
Scotland on Rails was a really excellent conference. A smallish regional event (even the regional conferences are getting big these days), it was a largely single-track event and had a very cohesive feel. I was lucky to be able to present twice during the conference; “Introduction to Ruby” for the charity workshop and a “Migrating to Ruby 1.9” plenary session (slides for both of these to be posted soon).
The conference covered a wide range of material; a good bit of pure Ruby (which always makes me happy), a suitable amount of Rails-centric sessions (it is Scotland on Rails, after all), and even an Erlang talk for good measure.
From an adoption standpoint, Scotland felt very US-in-late-2006 to me; a lot of individual passion and interest in the technology, a number of smaller companies actively using it, some large company/academic interest. It seems like there’s a lot of opportunity for growth, given the number of smart people around. It will be interesting to see what happens in the coming year or two; I definitely plan on returning to see for myself!
Thanks again to Alan, Paul, Abdel, and Graeme for all their hard work putting the conference together. This sort of thing is not a trivial undertaking!
To those I met over Ruby or a pint—let’s keep in touch!
Scotland on Rails, April 4th-5th(2008-02-23)
I love Ruby (and Rails) conferences. I attend as many as I can each year, and I’m especially excited about Scotland on Rails coming up in early April. Sure, part of it might be that I haven’t been back to the UK since I was a teenager (and I plan to cool my heels in Edinburgh for a few extra days), but more than anything else, it’s about meeting new people and reconnecting with old friends. It looks like there will be a wide range of both present at Scotland on Rails, and hopefully plenty of hacking, too!
I’ll be speaking at about Ruby 1.9 at the conference, and there’s a great lineup of other talks about a wide range of subjects. If you can make it to Edinburgh April 4th-5th, register away ... hope to see you there!
Advice for a Java Developer(2008-02-17)
The following is a slightly modified excerpt from an email I sent to a local Java developer interested in Ruby and Rails and looking for some advice. It includes a list of general purpose books I consider worth reading (though the list is by no means exhaustive) and basic tips I give people that are interested in pursuing an understanding of Ruby.
Over the last two years or so there’s definitely been an influx of people from Java, and that seems to be accelerating. Two of the developers I work with, in fact (Brian and Mike), are [somewhat] recent converts from Java; you’re definitely not alone.
With as much Java experience as you have, you probably don’t need a lot of hand-holding; but there are some concepts in Ruby might be somewhat foreign to you (depending on the rest of your background)—specifically concepts like block closures and the level of dynamicism present in the language. If you’re looking for books, I’d recommend you familiarize yourself with:
I think it’s important you get a firm grounding in the language before the framework, but here are some Rails (framework-level) books:
- Agile Web Development with Rails
- The Rails Way
- Rails Recipes (I like this better than “Rails Cookbook”); an up-to-date “Advanced Rails Recipes” is coming out soon.
- Ruby for Rails
Make sure you’re spending time:
- Reading code that highlights “best practices” (The Ruby Cookbook and Rails Recipes books above illustrate some examples); obviously like any community there are differences on opinion on what constitutes good, idiomatic Ruby, but I can give you some recommendations on specific projects
- Spending some time with Ruby developers (Austin on Rails is certainly a good place to start if you’re in the Austin, TX area); collaborate on an actual project if you can, but there’s value in just chatting, as well
- Following what’s going on in the Ruby community; there are a number of websites, mailing lists, and IRC channels that can help
I consider these steps far more important than a full bookshelf.
Ruby 1.9 Comparison App(2008-02-06)
As a follow-up to my Ruby 1.9 presentation post: the Ruby 1.8/1.9 comparison app that I wrote for and demoed at the Austin on Rails meeting in January is now available via github.
As you might imagine, the project was a quick hack and could use some work. Comment on, modify, and contribute at your leisure.
Ruby 1.9 Presentation(2008-02-04)
At the most recent Austin on Rails meeting, I gave a talk on Ruby 1.9, highlighting some important syntax and language feature changes. Here’s a copy of that presentation, if you’d like a peek (sorry it’s taken so long, with the hosting switch).
I’ll toss up the 1.8/1.9 comparison app in the next few days.






