Ex Dolo::With Intent

search:

This Just In:

Mephisto Sitemap plugin goes 1.0

My most popular OSS project, the Mephisto Sitemap Plugin is now officially all grown up and version 1.0. At a venerable 1.25 years old, it's gone through a lot of changes since it's inception and I really feel that it's a decent piece of software now. It boasts Mephisto admin integration, passing tests, modern code and full Sitemap 0.9 compliance and it even validates to boot.

NB: the repository URI has changed!

In an effort to properly reflect the fact that sitemaps are relatively standard now, and no longer specific to Google, the repository URI has been changed from:

http://svn.exdolo.com/projects/plugins/mephisto_google_site_map/

to:

http://svn.exdolo.com/projects/plugins/mephisto_sitemap/

Please also ensure you're no longer using the devjavu SVN repository, as changes are no longer being mirrored there. The above URI is the only correct one.

Installation:

piston import http://svn.exdolo.com/projects/plugins/mephisto_sitemap/tags/1.0 \
vendor/plugins/mephisto_sitemap

Enjoy. And as always feedback and bug reports are welcome!

Update

There seems to be an issue with Mephisto's custom routes for plugins, so for now, please add this:

map.connect 'sitemap.xml', :controller => 'sitemap'

To your config/routes.rb file, to ensure the URI is accessible. I'll dig in to Mephisto tonight and see if I can find a fix. Also, there was initially a type on the piston import command above, which has been fixed.

read on…

  • posted by: vox December 09, 2007 @ 03:08 PM
  • 2 comments

Rails 2.0 RC1 Requires PostgreSQL 8.1 or better

Subsequent to the changes introduced by the new Foxy Fixtures feature in Rails 2.0, the PostgreSQL adapter functionally requires PostgreSQL 8.1 or better. Prior to 8.1, there was no support for the DISABLE / ENABLE TRIGGER action for the ALTER TABLE statement.

So if you're getting this big, ugly error (or similar):

PGError: ERROR:  syntax error at or near "ENABLE" at character 25

when running your specs or tests after upgrading to the latest release candidate, that's what's going on. Doing an upgrade to 8.2.5 solved the problem for me.

read on…

  • posted by: vox November 12, 2007 @ 01:50 PM
  • 0 comments

Stopping Rails from Cache-Busting

The Scenario

In development, Rails does something that's generally helpful, namely appending a querystring to asset paths (stylesheets, javascript includes, etc.) like so:

/stylesheets/application.css?1190414487

This is useful because some browsers stubbornly cache content regardless of their local modifications or the etags you send them. Even the more modern browsers occasionally just futz things up. So the fact that Rails forces the browser to re-download my assets in development to ensure the most recent changes are always shown is great. However...

I recently started using CSSEdit from MacRabbit software, whose X-Ray feature has proved invaluable a few times recently in solving some complicated layout issues. Another really useful feature of CSSEdit is it's Live Preview, which (I believe) uses the WebKit engine to constantly update a user stylesheet for the page it's embedded browser is viewing, so you can see how your changes affect the page in real time.

The Problem

This really cool feature is also where my problem starts. To achieve this effect, it overrides the entire stylesheet path. Remember this: application.css?1190414487 ? That number in the querystring is the asset's modification time… The other end of the equation in how CSSEdit's override works is in a comment it places at the top of your CSS file ala:

/* @override http://localhost:3000/stylesheets/application.css?1190414487 */

So, as you're editing that file in CSSEdit, it's modification time changes, and the first time you refresh the CSSEdit browser (CSS and HTML edits often go hand-in-hand), the override no longer works, since the stylesheet path is now different than what it's being told to override.

Two Simple Solutions

The "if it hurts, don't do that" solution:

When setting up your Override for CSSEdit's live preview, use the "Extract and Override" option.

CSSEdit's Extract and Override

This copies the stylesheet in question into a new stylesheet which then overrides the current rendered pages. The key here is that since you're not editing the actual stylesheet linked in the page, the modification time doesn't change and it therefor continues to be overriden when you reload the page.

The "I'm so stubborn it hurts" solution:

If you stubbornly insist on editing the actual file you're overriding (like myself), there's another solution still, but one you'll want to use with a bit of prudence.

Doing a bit of digging into how rails adds that modification time will bring your attention to this private method:

ActionView::Helpers::AssetTagHelper#rewrite_asset_path!

which attempts to use an ENV key named RAILS_ASSET_ID *or* the files modification time. So... throwing:

ENV['RAILS_ASSET_ID'] = ''

in your development.rb effectively turns off the modification querystring, which allows overrides to work as expected without having to worry about updating your override after every refresh.

Alternatively, since CSSEdit uses a slightly modified WebKit UserAgent string:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419.3 (KHTML, like Gecko) Safari

vs Safari's:

Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419.3 (KHTML, like Gecko) Safari/419.3

you could monkey patch that method in development, which would give you the option of doing something like browser sniffing the CSSEdit browser and conditionally stopping Rails from adding the modification time to the assets path. I whipped up a simple plugin: cssedit_asset_id_fix to illustrate this technique (which is coincidentally the method I'm using).

NB: if you choose to use the demonstration plugin, do note that since it uses browser sniffing, it is inherently prone to breakage. Something like this is only acceptable in development, in my opinion.

read on…

  • posted by: vox October 02, 2007 @ 04:23 PM
  • 2 comments

powered by rails and mephisto.