We switched to Git this year, and we now use Git almost exclusively at Art of Mission. We’ve even moved over most of our old svn repositories.

One thing we wanted to do recently was to post commit messages into our Backpack journal. Turns out it is very easy with Git and a little bit of Ruby code.

This would go in .git/hooks/post-commit (make sure to make the that file executable):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env ruby
require 'rexml/document'
require 'net/http'

# Customize these values: 
  # Your backpack account:
ACCOUNT = "yourbackpacksubdomain"
  # Your backpack user id:
USER_ID = 123456
  # Your token (you might want to put this in a shell variable):
TOKEN   = '1234567890987654321234567890987654321'
PROJECT = "my-project"

GIT     = `which git`.strip

def build_commit_message
  text = `#{GIT} log --all -n 1`
  lines = text.split("\n\ncommit ")

  revision = text[/([a-f0-9]{32})/]
  commit_author  = `#{GIT} show --pretty=format:"%an" #{revision} | sed q`.chomp
  commit_log     = `#{GIT} show --pretty=format:"%s" #{revision}  | sed q`.chomp
  # Additional useful data...
  # commit_date    = `#{GIT} show --pretty=format:"%aD" #{revision} | sed q`.chomp
  # commit_changed = `#{GIT}-diff-tree --name-status #{revision}    | sed -n '$p'`
  
  "[#{PROJECT}] #{commit_log}"
end

# Build the Backpack xml snippet:
def build_request(message)
  doc = REXML::Document.new
  request = doc.add_element 'request'
  request.add_element('token').add_text TOKEN
  journal_entry = request.add_element('journal-entry')
  journal_entry.add_element('body').add_text(message)
  return doc
end

# Post the request to Backpack:
def send_to_journal(message)
  doc = build_request(message)
  http = Net::HTTP.new("#{ACCOUNT}.backpackit.com")
  response = http.post("/users/#{USER_ID}/journal_entries.xml", doc.to_s, {'Content-Type' => 'application/xml'})
end

# Do it:
send_to_journal(build_commit_message)

Donor Tools New Homepage

August 8th, 2008

Donor Tools has a new home page – check it out!


Beautiful Printable Pages with CSS

In Donor Tools every page is a report. Adopting this simple philosophy has allowed us to almost completely eliminate the need to build dedicated reporting features. And it was almost effortless to implement – it took maybe a couple of hours.

CSS aficionados should recognize this trick already: it’s called print style sheets. Basically you have one set of stylesheet for screen display, and a separate set of styles for printing. This works in just about every modern browser, even the inferior ones. And the great thing about print styles is that we often don’t need to worry about complicated positioning or page flow – just provide some basic style instructions, hide non-printable controls and headers, and it looks beautiful on paper.

This has, of course, been discussed elsewhere, but I’m going to show you how we put it to work for Donor Tools.

I like to use CSS Edit, which in my opinion is the cream of the crop of CSS editors.

The first thing I do when I’m ready to start working on the print style sheet is to think about what I want to show up on paper, and what should be hidden. Opening up my page in CSS Edit, I use the X-ray tool to examine the blocks and divs that construct the page. Good HTML construction at this point is crucial to being able to target specific areas of the page.

Next, I turn off all the screen styles and switch the print stylesheet to display on the screen. Donor Tools is built in Rails, so a quick edit to the application.html.erb file is all that’s needed:

Flipping over to CSS Edit, now I can edit my print.css stylesheet with instant feedback.

I’ve turned off a lot of divs by targeting the names of the elements, and then applying display:none;. I also made a generic style called .noprint that I can apply to any random elements that should not print.

That’s it! Now, when someone uses their browser’s print function, they’ll get a beautiful, well-styled printout of what they’re looking at on the screen with no extra effort.

I talked about another approach in Easy Printable Pages with Rails


- or –
Why I plan not to renew my subscription
- or –
Why, Rupert Murdoch, Why?

John Gruber calls out the Wall Street Journal’s declining quality: An Aug 1 front-page article drives home my increasing gripes with the WSJ with a front-page article “addressing the issue of whether Barack Obama is ‘too physically fit’ to be elected president”.

Ok, that’s it. I’m done.

For months I’ve felt this welling up of frustration every time I open the morning paper. Sometimes I just let it sit in the driveway all day. I no longer feel the smug satisfaction that I used to feel reading the best newspaper available.

It seems to me that Wall Street Journal front pages are increasingly given over to eye-catching illustrations and info-graphics. The format and content of the articles seem now to be designed to appeal to “the masses”, or the “more sophisticated consumer”. They even changed the size of the paper, so it’s no longer the trademark WSJ wide-format. It fits on the newsstand next to the New York Times and the LA Times and the Austin American Statesman, and it still jumps out at you. It feels “mainstream”, and appealing in a mass-market sort of way.

But I subscribed to the Wall Street Journal precisely because it wasn’t appealing. I wanted to read the news that the economic elite reads; I wanted information that the common citizen wasn’t interested in.

I’m not interested in Barak Obama’s waist size, or what John McCain is mad at him about today, or Heath Ledger’s fantastic performance as The Joker – I can get all that “news” from our local rag. I’m not interested in op-ed articles masquerading as reporting – I can get that from Fox News and CNN. I’m interested in the impact of Congress’ offshore drilling policies on oil futures, and who just joined whose board of directors, and what are Starbucks’ plans to compete with McDonalds.

It’s a sad day.

The Wall Street Journal no longer offers anything of greater value than I can get from my local rag. Oh where, oh where will I turn?