Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An entry in Sunlight Labs' Apps for America competition

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 db
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 log
Octocat-spinner-32 public
Octocat-spinner-32 script
Octocat-spinner-32 spec
Octocat-spinner-32 test
Octocat-spinner-32 tmp
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .gitmodules
Octocat-spinner-32 BLURB
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
README
      ___                       ___     
     /__/|          ___        /  /\    
    |  |:|         /  /\      /  /:/    
    |  |:|        /  /:/     /  /:/     
  __|  |:|       /  /:/     /  /:/  ___ 
 /__/\_|:|____  /  /::\    /__/:/  /  /\
 \  \:\/:::::/ /__/:/\:\   \  \:\ /  /:/
  \  \::/~~~~  \__\/  \:\   \  \:\  /:/ 
   \  \:\           \  \:\   \  \:\/:/  
    \  \:\           \__\/    \  \::/   
     \__\/                     \__\/    
     
     
This repository contains the unabridged source code for 
know-thy-congressman.com, a web-service/bookmarklet that displays beaucoup
information about your elected representatives.

Let me briefly describe the nature of the beast: When you click on the KTC 
bookmarklet, you load in all the Javascript, CSS, and Javascript Templates 
needed to render the eventual display. A search request for the given legislator
is sent to the server, where, if the politician's information is not yet cached
in the database, it is split out into many different requests for each of the 
supporting APIs, requested in parallel to a certain degree, and then merged
back into one large JSON data dump. The politician's JSON gets cached in the 
database, and the result is returned to the bookmarklet, which handles the 
parsing and graphing in Javascript to display the information on the screen.

Notable Methods:

  * Services.dig_up_dirt (in lib/services.rb)
    The main API querying method. Threads out requests to each of the APIs.
    
  * Services::Base#safe_request (in lib/services/base.rb)
    Accepts a block that executes a request, and ensures that any momentary API 
    downtime doesn't screw up the big picture.
    
  * Politician#information (in app/models/politician.rb)
    Accessing the information dump about a politician performs a search if the
    information has gone stale.
    
  * KTC.Loader (in public/javascripts/know-thy-congressman.js) has some 
    interesting methods for loading cross-domain css and javascripts in a 
    browser compatible fashion, even when JQuery has not yet been loaded.
    
  * KTC.Grapher.visualize (in public/javascripts/know-thy-congressman.js) is a
    messy ol' method, but is able to handle the canvas-based graphing of several 
    types of information: earmarks, votes, and favorite words.
    
  * KTC.Util.reloadCss (in public/javascripts/know-thy-congressman.js) is a 
    nice debugging bookmarklet to refresh all of the CSS on the page, without
    needing to reload it.
    
  * KTC.Politician.INFO_TO_DISPLAY (in public/javascripts/know-thy-congressman.js)
    is the constant that determines the layout, ordering, and data binding of
    the final display, and makes it simple to try out different arrangements.
    
    
Something went wrong with that request. Please try again.