Invalid URLs patch
The first patch I’ve submitted deals with invalid URLs for search results and tags being generated by the Site model. The search_url method uses an unescaped ampersand when a page number is included in the URL although the rest of the URL is escaped correctly. The tag_url method didn’t do anything with tags containing spaces so my patch uses the URI::escape method to correctly handle this.
Corrupted asset uploads on Windows
Unfortunately I’ve not yet joined all the cool kids on their Macs: I’m still using my trusty Dell laptop and Windows XP. When I first tried to upload an image asset on my local copy of Mephisto it became corrupted during the upload. A quick check of the attachment_fu plugin that is used by the Asset model showed that it was quite an old version. My patch is a quick fix that borrows a line of code from the newer version of attachment_fu: it sets the file mode to binary during uploads which fixes the corruption on Windows. At some point the entire plugin should probably be updated but for now this will do the trick.
URL filters link_to extensions
The current link_to filters provide a nice way of generating links in Liquid templates but if you need to customise the link, for example to set the class name or change the link title, you have to revert to creating your own links using HTML.
This patch allows you to optionally specify the link title, id, class and rel attributes in all of the link_to helpers and if you don’t specify a title attribute for a link it will generate one for you. Here are a couple of examples of the Liquid markup and the HTML generated:
{{ article | link_to_article: 'Link text', 'Link title', 'link-id', 'link-class', 'link-rel' }}
<a class="link-class" href="article url" id="link-id" rel="link-rel" title="Link title">Link text</a>
{{ section | link_to_section: nil, 'Read entries in this section' }}
<a href="section url" title="Read entries in this section">section name</a>
I’ve not included any updated tests with this patch simply because the existing URL filter tests do not appear to be working properly (I get a lot of unexpected nil object errors on my system). However I did check that I didn’t break any of the tests that are working on my system and I am using the patch on this site without any problems. Update: I was able to get tests to run by removing the RSpec plugins (they conflict with the test/spec gem traditionally used by Mephisto) so I’ve now been able to submit an updated patch that includes tests.
And finally…
That’s all for now but while I’m on the subject of patches I’d also like to get this patch from Rick Olson and this one from Xavier Shay added into Mephisto – it seems they’ve been forgotten about. If, like me, you think they’re worthy of inclusion why not give them a bump on the Mephisto Google Group?


2 comments
Comment on A medley of Mephisto patches by rick
November 23rd, 2007 @ 23:49 – permalink
Comment on A medley of Mephisto patches by Rob
November 25th, 2007 @ 16:15 – permalink
Leave a reply
You can use Markdown in your comment as well as plain HTML. You can use
<filter:jscode lang="ruby">and</filter:jscode>tags to surround code blocks (supported languages are css, html, javascript and ruby). Your email address will not be published.If your comment doesn’t appear immediately after posting it could have been marked as spam. Don’t worry: we regularly check for and approve incorrectly filtered comments so you shouldn’t have to wait too long for it to be shown.