-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GovKit and Sunlight gems, as well as some POC code.
- Loading branch information
Showing
19 changed files
with
203 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var locale; | ||
|
||
function receiveLocation() { | ||
locale = google.loader.ClientLocation; | ||
$('#message').html('Finding representatives for '+ locale.address.city +'.'); | ||
|
||
$.get('/reps/find_by_latlong', {lat: locale.latitude, long: locale.longitude}, receiveReps); | ||
} | ||
|
||
|
||
function receiveReps(data) { | ||
$('#message').html('Found your representatives for '+ locale.address.city + ':'); | ||
var reps = $.parseJSON(data); | ||
var repContainer = $('#repContainer'); | ||
console.log(data[0]); | ||
$.each(data, function(index, value) { | ||
repContainer.append($('<div class="rep_name">'+ value +'</div>')); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the Home controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class HomeController < ApplicationController | ||
|
||
def index | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module HomeHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# A model to contain mentions of the :owner in the media | ||
class Mention < ActiveRecord::Base | ||
belongs_to :owner, :polymorphic => true | ||
|
||
scope :since, lambda { |d| where(["mentions.date > ?", d]) } | ||
|
||
# Returns the mentions in JSON form | ||
# | ||
# @params [Hash] A hash of options | ||
# @return The mentions in JSON form | ||
def as_json(opts = {}) | ||
default_opts = {:except => [:owner_id, :owner_type]} | ||
super(default_opts.merge(opts)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
class Rep < ActiveRecord::Base | ||
has_one :user | ||
|
||
def self.find_by_latlong(lat, long) | ||
logger.info 'Looking up rep for ' + lat.to_s + ' ' + long.to_s | ||
|
||
state = self.find_state_reps_by_latlong(lat, long) | ||
federal = self.find_federal_reps_by_latlong(lat, long) | ||
state.merge(federal) | ||
end | ||
|
||
def self.find_state_reps_by_latlong(lat, long) | ||
GovKit::OpenStates | ||
results = GovKit::OpenStatesResource.get_uri('/legislators/geo?', :query => {:lat => lat, :long => long}) | ||
representatives = Hash.new | ||
results.each{ |rep| | ||
representatives[rep.chamber + ' ' + rep.district] = rep.full_name | ||
} | ||
representatives | ||
end | ||
|
||
|
||
def self.find_federal_reps_by_latlong(lat, long) | ||
federal = Sunlight::Legislator.all_for(:latitude => lat, :longitude => long) | ||
representatives = Hash.new | ||
federal.each{ |rep| | ||
full_name = rep[1].firstname + ' ' + rep[1].lastname | ||
representatives[rep[1].govtrack_id] = full_name | ||
} | ||
representatives | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
#message | ||
Finding your representatives. | ||
|
||
#repContainer |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
!!! 5 | ||
%html | ||
%head | ||
%title | ||
AsqUs | ||
|
||
= stylesheet_link_tag "application" | ||
= javascript_include_tag "application" | ||
= javascript_include_tag "http://www.google.com/jsapi" | ||
= csrf_meta_tags | ||
:javascript | ||
google.load("maps", "2", {callback: receiveLocation}); | ||
%body | ||
|
||
= yield | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if defined? GovKit | ||
GovKit.configure do |config| | ||
# Get an API key for Sunlight's Open States project here: | ||
# http://services.sunlightlabs.com/accounts/register/ | ||
config.sunlight_apikey = 'f4838aad396e47fca55ae4f292273584' | ||
|
||
##API key for Votesmart | ||
# http://votesmart.org/services_api.php | ||
#config.votesmart_apikey = 'YOUR_VOTESMART_API_KEY' | ||
|
||
# API key for NIMSP. Request one here: | ||
# http://www.followthemoney.org/membership/settings.phtml | ||
#config.ftm_apikey = 'YOUR_FTM_API_KEY' | ||
|
||
# Technorati API key | ||
# config.technorati_apikey = 'YOUR_TECHNORATI_APIKEY' | ||
|
||
# Bing App ID | ||
#config.bing_appid = 'YOUR_BING_APPID' | ||
|
||
# Other things you could set here include alternate URLs for | ||
# the APIs. See GovKit::Configuration for available attributes. | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'rubygems' | ||
require 'sunlight' | ||
Sunlight::Base.api_key = 'f4838aad396e47fca55ae4f292273584' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class CreateMentions < ActiveRecord::Migration | ||
def self.up | ||
create_table :mentions, :force => true do |t| | ||
t.string "url", :limit => 8000 | ||
t.string "excerpt", :limit => 4000 | ||
t.string "title", :limit => 1000 | ||
t.string "source" | ||
t.datetime "date" | ||
t.float "weight" | ||
t.integer "owner_id" | ||
t.string "owner_type" | ||
t.string "search_source" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :mentions | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class HomeControllerTest < ActionController::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'test_helper' | ||
|
||
class HomeHelperTest < ActionView::TestCase | ||
end |