Archive for September, 2008

Database Exposure

When I last checked in about development status, I was about to shoehorn the BJCP style information into the database.  Well, consider the  most recent guidelines shoehorned.  They still need to be cleaned up a little bit, the textual data was a little messy, but at least the stats and descriptions are there now for easy reference.  In the process of fleshing out the style pages, I also made it easier to browse recipes within the style, narrowing down to extract, all grain, or partial mash.  And the relatively new search feature is an easy way to cut through the database looking for specific styles too.

In other developments:

  • I finally opened up the ingredients database to the masses. Previously I was the only person who could add new ingredients into the database, so folks had to drop me an email request or list their unlisted ingredients inside the recipe notes.  Now anybody can add anything right into the recipe on their own.
  • To accommodate an open ingredient database, I added inline ingredient search to Beer Calculus.  Now, rather than having to read through an alphabetical select box to find the malt, hop, yeast, or miscellaneous ingredient you need, you can switch on a search box and find the selection by typing a keyword or two.  And if the ingredient you’re searching for can’t be found, it’s easy to add it.
  • Previously all IBU results were calculated using an ages-old custom formula that combined parts of the “Daniels method” with the “Garetz method”.  I’ve now updated the IBU number to be customizable to the popular formulas (Tinseth, Garetz, Rager), but I also left in the old “Hopville method” so that existing recipes keep their existing IBU value.  By default, new recipes added to Hopville will calculate IBUs by averaging the three commonly used formulas, but brewers with a formula preference can customize to use that instead.
  • Fixed some rounding errors introduced by the recent migration to metrics-based recipe storage, and some other bugs I introduced in the broad sweep of new changes.

Current recipe count: 675


Comments (1)

automatic color palette for Rails

It’s difficult trying to standardize colors across a site. I picked up a tip somewhere to keep a legend at the top of a stylesheet, something like this;

F9F9FF off white
4a443c main text
B34700 link text
FF6600 action link text
eeeeee tiger body

Then you have an easy hex color reference right at the top of your main stylesheet. But “easy” becomes relative. On Hopville, I ended up describing shades of green as “medium”, “medium light”, “lightest”, and “extra-lightest”. Extra-lightest green? Which one was that again? And as the site’s color scheme has evolved, the legend has gotten out of date.  Some of the colors on the site aren’t in the legend any more, some of the colors in the legend aren’t in use anymore, and so on.
It just occurred to me that this could be automated, that I could scan all the stylesheets with a script, pull out the color attributes, and generate a color swatch page on the fly.  So when I want “that one shade of green”, I can go look it up and cut and paste the hex value, without having to dig through stylesheets or maintain a color palette legend.  Rails made it easy to generate it on the fly with an erb template (ignoring MVC for simplicity’s sake) and not even have to set up a cronjob.

Dynamic color palette browser created from stylesheets in Rails.

Dynamic color palette browser created from stylesheets in Rails.

The code:

stylesheet_dir = RAILS_ROOT + '/public/stylesheets'
files =
css_files = []
colors_in_stylesheets = {}

files.each do |file|
  if file.match(/\.css$/) + '/' + file).each do |line|
        if line.match(/\#([0-9a-f]{3,6})\;/i)
          unless colors_in_stylesheets[file]
            colors_in_stylesheets[file] = {}
          colors_in_stylesheets[file][$1.downcase] = 1

block_size = 100

<style type="text/css"> {
  width:<%= block_size %>px;
  height:<%= block_size %>px;
  border:1px dotted #ccc;
} span {
  border:1px dotted #ccc;
h2 { clear:left; }

<h1>Color Swatch</h1>
<% colors_in_stylesheets.keys.sort{|a,b|
   colors_in_stylesheets[b].size <=> colors_in_stylesheets[a].size
   }.each do |stylesheet| %>
  <h2><%= stylesheet %></h2>
  <% colors_in_stylesheets[stylesheet].sort.each do |color, garbage| %>
    <div class="swatch-block" style="background-color:#<%= color %>;">
    <span><%= color %></span>
  <% end %>
<% end %>

This works great for me since I always use hex colors, but I imagine it could be tweaked to find other color definitions as well.

Leave a Comment

Miscellaneous Developments

Continuing my second sweep through Hopville, lots of new stuff happened over the weekend:

  • New “miscellaneous ingredients” section added to the recipe page to handle flavorings, clarifiers, etc.
  • Recipe types have been added.  Search and style browsing both now include filtering by recipe type so you can find relevant recipes (all grain, extract, partial mash) more easily.
  • Recipes can now be exported as BeerXML.
  • Lots of little UI tweaks in pursuit of beery beauty.

Right now I’m trying to shoehorn the 2008 BJCP style guidelines into the database, and fleshing out new style pages that will make all the style information readily available on Hopville.

Current recipe count: 633

Comments (1)

Hopville goes better with search.

I’ve pretty much burnt out on fixing up my house, which has been my big summer project.  So now it’s back to working on stuff in my newly clean office space.  It’s stylin’.  I’m preparing a significant Hopville release right now, but it’s mostly significant in the guts of the program.  I’m converting the database to use metric units to store all recipe measurements.  This will make the site a lot more useful for non-U.S. folks.  It’s true that most users of the site are in the States, but that’s partly because the site is effectively useless for non-citizens.  We’re the only remaining stalwarts of the ancient English system.  Except maybe Burma.  And Liberia.  Not a lot of homebrewing going on in those locales.

But I’m not just converting to metric in order to feel wordly.  This change will also facilitate recipe importing and exporting features.  BeerXML is the language that brewing software uses to communicate with other brewing software about recipes, and it only speaks metric.

The metrics conversion shouldn’t affect U.S. users at all, the Beer Calculus interface and calculations will remain the same (assuming I didn’t mess up…but I’m being especially careful with this release), but users will be able to create, view, and edit recipes in whichever system they like.  Hopefully I’ll be rolling out that release by the end of the weekend, along with some navigation improvements.

Speaking of navigation improvements, I finally added search to Hopville this week.  It was a big, gaping hole in the site navigation so I’m glad some users contacted me to cow-prod me into adding it.

Current recipe count: 613

Leave a Comment