Archive for February, 2007

Google Sitemap for Mephisto

I was getting frustrated with the idea of updating my sitemap.xml every time I created a new article on this blog. So I started mulling through the Mephisto Wiki and found a Mephisto Google Sitemap Plugin from Stephen Caudill which works great! I would have left a comment on his site, but it appears that comments have been turned off. So I’m leaving an endorsement here.

Bookmark and Share

No Response  |  add yours »

Jack my FAQ

Here’s a little freebie.

I’ve written a javascript that will take any faq page—properly formatted—and give it a little DHTML *umph* (oh, that’s right, we’re calling it AJAX these days). Basically it automatically converts all of the terms (questions) into links and collapses all of the defintions (answers) to be hidden until their term has been clicked. You can see an example of it in action on our newly deployed Travel Nursing staffing website.

Basically, for formatting, you only need to use a Definition List (DL) with proper <DT> tags for terms and <DD> tags for definitions.

<DL id="definitions">
	<DT>Is this the first Question?</DT>
	<DD>Because this question appears at the beggining of our definition list,
	it is in fact the first question and can be referred to as such from here on out.</DD>
	<DT>Is this the last Question?</DT>
	<DD>Yes, this is the last question. However, since there are only two
	questions in this example, it can also be considered the "second" question.</DD>
</DL>

Then just link to the file at the bottom of your page with the following code:

<script type="text/javascript" src="jackmyfaq.js"></script>

Download Jack My FAQ now!

Bookmark and Share

1 Response  |  add yours »

Best Way to do Multiple Select Combo Boxes in Rails

After much trial and error, and frustration, I have finally come up with what I believe is the best possible way to do multiple select combo boxes in Rails. It’s not so much that there aren’t examples on the web, it’s just that every example is so different. I’ve used what I feel is the best from each example and created this example.

First, it’s best that the options are in an array somewhere. In this example, we’ll assume that all states are set in an array on the application.rb and the array is named $states

In the _form, or wherever your form is, do the following:

<% if @model_name and @model_name.states
 
@states_selected = @model_name.states.collect
 
end %>
 
<label for="model_name_states">State</label><br/>
 
<%= select_tag 'model_name[states][]', options_for_select($states, @states_selected), { :multiple => true, :size =>5, :id => "model_name_states" } %></p>

This will not only dynamically create your select field with each option, but it will make it so that if someone leaves off a required field the same selected states will be selected on the edit screen!

See the Rails documentation for options_for_select to customize it even further. Obviously you can leave off the :multiple and :size to make it a single select with similar results, but it’s better to use select instead of select_tag for single select combo boxes.

Bookmark and Share

3 Responses  |  add yours »

RubyWeaver is alive!

RubyWeaver is an IDE for Ruby and Rails in Dreamweaver. This extension originally came from RidingTheClutch.com which seems to have mysteriously disappeared, along with it’s original author Rob Cameron whom I have tried to contact with regards to RubyWeaver, but with no avail. I’ve taken the liberty to make this extension available once again to those who are looking for it, which I believe to be many. Since Macromedia (Adobe) makes it very easy to retrieve the source code for an extension once it is installed, I’ve also taken the liberty of upgrading it a bit, since I have built a dreamweaver extension similar to this one before and thought everyone could benefit from the enhancements.

If you do any Ruby on Rails and want to use it with Dreamweaver, Download RubyWeaver 2.0 today!

Bookmark and Share

No Response  |  add yours »

Mephisto’s Lucid theme displaying incorrect timestamp

I don’t know if it’s because the Lucid theme for Mephisto was ported from Typo, but it was displaying the timestamp on my entries as UTC instead of MST, which is what I told Mephisto my time zone is in the Settings. Apparently Lucid uses JavaScript to convert the timestamp into a more descriptive time (“about an hour ago”) if the timestamp is less than a week old and otherwise displays the date.

Without having enough time to really look into it, I believe Mephisto is using TZinfo Gem to convert the database timestamp to whatever you set your timezone to be in the Settings and Lucid is reading that as UTC anyway and attempting to convert it to the users current time.

So rather that fudging the JavaScript, I decided to reformat the date that Lucid sees and let it do it’s thing. In other words, I plugged the following into the home.liquid, index.liquid, and single.liquid templates:

from

<p class="auth">Posted 
<span class="typo_date" title="{{ article.published_at }}">
{{ article.published_at }}
</span></p>

to

<p class="auth">Posted
<span class="typo_date" title="{{ article.published_at | date: "%a %b %d %H:%M:%S MST %Y" }}">
{{ article.published_at | date: "%a %b %d %H:%M:%S MST %Y" }}
</span></p>

where MST is my own time zone.

Hope this helps others, as I wasn’t able to find any other info about it.

Bookmark and Share

1 Response  |  add yours »

Search