Jonathan Martin
Archive for 2011
-
Ruby Extension: HTML Truncation
~ by Jonathan Martin
Another tip (err hurdle) I came across during the production of this blog — truncating an HTML string. Easy, right?
It seems simple enough: shorten some basic text content from a long entry. It’s extremely popular in blogs, catalogs, portfolios, etc. and with good reason — the average browser wants to find content through screening, not mass scrolling.
But a good trimmer must keep a few things in mind.
- Don’t split words
- Recognize/respect HTML tags
- Parse HTML according to standards
These add up to some pretty terse requirements once you actually get to coding. First, unless we want to manually parse HTML, we’ll have to use some standards based parser and loop through all the elements, until the specified number of characters/words (excluding tags!) is exceeded, at which point we append a user-defined tail and discard all other tags.
Update: the latest version of this handy widget is now available as a gem! Check it out at rubygems.org/gems/butter or bundle it with gem install butter.
-
Will, Predestination, and Calvinism
~ by Jonathan Martin
Figures, I wanted to reply to a comment and ended up writing a four-page essay! As that is certainly a little lengthy for a reply, I decided to expand it into an article so I could more fully (though it is still severely incomplete) address the topics of Calvinism, free will, predestination, etc.
I’ve been surprised by the amount of discussion generated by Two Sinners and a Saint; I think however the discussion should be turned from a Calvinism/Arminianism to a more relevant discussion of that article topic, as the purpose of this blog and the comments is not to be a forum that trails off on side topics.
That being said, I would like to “throw my hat in the ring” with my thoughts on the subject.
-
Rails 3: Action Mailer
~ by Jonathan Martin
As a result of designing this blog, I’ve come to appreciate the refinement of Rails 3, and the drudgery of a few “less than perfect” spots.
ActionMailer (now powered by the Mail gem instead of TMail) is an incredible refactoring of the traditional Rails 2.x email system; frankly, before Rails 3, the email system was anything but elegant — besides the clunky API, none of the traditional view helpers were available, and multipart emails with attachments were hackish.
The new system takes a huge step in the right direction by incorporating a sleek API interface and merge of ActionMailer with the traditional ActionController/ActionView. In essence, whereas before the mailer and controller/views were entirely separate entities, ActionMailer now inherits from these classes, and consequently acts much more like a traditional view. This approach hugely simplifies the design process by recognizing the similarity between HTML webpages and HTML email.
-
Two Sinners and a Saint
~ by LaJoie Ward
Thanks to LaJoie Ward, a good friend of mine, you won’t have to listen to my ramblings alone. She’s an incredible Christian writer (her narratives are amazing!) and scholar. If you enjoy her work as much as I do, check out her personal blog Thought of Joy.
Your character is who you are inside; it’s created in the small moments but comes out when you’re under pressure.
Judas and Peter were both with Jesus for three and a half years. They both heard his teachings, traveled with him, and did his bidding. And they both committed terrible betrayals against Jesus. But these men’s lives ended in drastically different ways. Judas, filled with guilt at the realization of what he had done, went out and hung himself. Peter, though he was sorrowful for having disowned his master and friend, was sincerely repentant, and was welcomed back by Jesus after the resurrection. What made the difference?