Add a unique body class in Ruby on Rails template

After using Drupal's template.php file to preprocess html and add unique classes to various html elements, I because very dependent on page specific css classes. While building a Ruby on Rails app, I thought it would be nice to at least add in a page-specific body class. Here's a quick snippet you can use:

<% page = request.request_uri.gsub(/^(\/)?/, '') page = page.gsub(/\//, '-') %> ">

This will:

Helpful regexs for stripping extranous styling

Content migration is a pain, particularly when you are charged with copying content from an old html site into a new framework. Often times, old content comes with the baggage of inline css styling, which wreaks havoc on your pretty new site design. Here's a handful of helpful regexs that I use to strip out undeed inline styling, while still preserving the html element structure.

To strip out span tags: <span[^>]+> Follow up to strip out the close tags:

Strip out inline styling: style="[^"]+"

Joomla: dynamically adding stylesheets by category and section

I once had the misfortune of developing a Joomla site with three separate templates, each of which contained four separate color schemes. The color scheme needed to be selected based on the content's section and/or category.

This PHP script will cycle through various methods for determining category id, section id, or content id. It also includes an array for manually setting the stylesheet by id.

Preserve destination with Rules' "page redirect" action

I often us the Rules module to redirect a user to the login page when they try to access protect content. Unfortunately, Rules' "page redirect" action doesn't preserve the destination parament, i.e., the node that the user was trying to view. Adding a small bit of php code to the redirect url fixes this issue:

To: user/login ? <?php destination=node/[node:nid] ?>