Posts tagged Plugin
Rails 2.3 and theme_support
Feb 2nd
A couple of months back, I realised that two of my projects (Generous and Catapult) could do with the help of the theme_support Rails plugin. Discovering that it didn’t play nicely with Rails 2.1, I created a fork on github and hacked at the _pick_template method to get it to do what I wanted. It turned out a few people were interested in having the plugin work with Rails 2.1, some of whom used more of the plugin’s featured than I need, and a few further forks emerged. I’ve been meaning to work through them and merge together the best bits, but the impending release of Rails 2.3 stopped me in my tracks.
I’m particularly keen to upgrade to 2.3 because Catapult generates a lot of routes and 2.3′s improved route handling should save us quite a bit of RAM and a number of cycles. So it was rather frustrating to find that yet again a new release of rails broke the plugin. Many hours later, working my way through the render path and trying to find the optimal solution, I’m not quite there, but it sort of works and seemed worth writing up:
It turns out that for most templates there’s a single point we can patch that will handle things. ActionView::Base#view_paths returns an instance of ActionView::PathSet which is an augmented Array that ActionView consults to find a template that matches its current requirements. By overriding that method we can check to see if a theme should be active and add that theme’s folder to the set of paths to be consulted.
module ActionView class Base alias_method :theme_support_old_view_paths, :view_paths def view_paths paths = theme_support_old_view_paths if controller and controller.current_theme theme_path = File.join(RAILS_ROOT, "themes", controller.current_theme, "views") if File.exists?(theme_path) and ! paths.include?(theme_path) paths.unshift(theme_path) end end paths end end end
The hitch is that this doesn’t work for layouts, which take a slightly different path. In my case, that’s not a huge deal, but it’s a major omission for other uses. I’ve also not yet tested the actionmailer handling.
You can track progress in a branch on GitHub. I’ll post here as I make more progress, but would welcome any contributions from the rest of the community.
UPDATE (10pm): I just checked in ActionMailer support. More on that tomorrow.
acts_as_amazon_product
Oct 15th
A couple of years ago I wrote and released a Ruby on Rails plugin called loads_from_amazon. It made it relatively simple to populate a model with data based on an amazon search, and was very helpful in the project I was then working on.
That project ended and I’ve not had time to maintain the plugin since. It was based on a clunky amazon ECS library and I kept meaning to rewrite it to sit on something more up to date, like amazon-ecs, but the time never materialised.
Today I stumbled upon acts_as_amazon_product which looks like it does everything my plugin did, and more. If you’re looking for that functionality, it seems like that’s the place to go.
MTPastEntries 0.3
Mar 9th
It can be all too easy to get sucked into a single project and then find most of the day has disappeared. I’ve now packaged up MTPastEntries version 0.3 and put it along with an instruction page here.
The main changes are to the PHP code which I’ve now had time to test. It seems to work pretty nicely for now, though as before I’ve not tested on a large-scale setup. I’ve also tidied up the perl a little bit, and added in two new tags MTPastEntriesIfComment and MTPastEntriesIfTrackback which are taken with only the slightest of modifications from Adam Kalsey/Brad Choate‘s SimpleComments plugin.
I’d like to add a number of features, such as some way of flagging up which previous entry each comment came from, sorting of comments by various parameters, and the aforementioned use of fields other than keywords, but it’s probably time to take a look at some other work for a while.
Moveable Type PastEntries 0.2
Mar 9th
It turned out that the first version of MT::PastEntries was riddled with bugs that were quietly filling up my logs, so I’ve just released version 0.2. This version has been tested on a small blog of three entries and worked as intended.
I suspect that on a blog of any size it would add considerable load when rebuilding static pages, so I’m going to move on to writing a PHP/Smarty version asap. Gavin suggested looking into integration with the ExtraFields plugin, so once the PHP version is in place that’ll probably be next on the ‘to do’ list.
UPDATE: I’ve had a first bash at the PHP side. I’ve not done any debugging yet, but for those who want to have a look, the whole lot is available here.
MT::PastEntries
Feb 28th
As part of my new found involvement with the Talk Euro project (aiming to produce an online, commentable, annotatable version of the EU constitution) I’ve been considering how to use Moveable Type to keep track of different versions of a particular clause or article in a document.
The issue is that the constitution (and the other documents we hope to then use the toolset with) will inevitably be amended over time and it would be good to be able to keep track of those amendments and to present comments on previous versions of an article to those reading the latest version.
The most elegant solution I’ve come up with so far is a plugin that will scan the keywords field of the entry for notes of the form previously:xx where xx is the ID of a previous version of this article and extract all comments made on any entries located. The plugin then provides a container tag that can be used to display those comments. In practice, the user will probably want to then disable comments on the previous version of the article, and offer some link from the old version to the new one.
For those who are interested, you can download the initial version here, but note that I haven’t even gotten as far as testing it; version 0.1 is simply to illustrate how the process might work.
Before releasing it for any serious usage, I’d want to add sorting of comments/trackbacks, and a way of attaching a note to each entry to indicate which previous entry it comes from (as well as the obvious refactoring, etc). And of course once that’s all stabilised, a PHP version will follow.