Changeset 1478

Show
Ignore:
Timestamp:
09/08/07 18:18:52 (1 year ago)
Author:
jm3
Message:

working with 7 example neighborhoods and error-handling for non-existent yelp bug hoods like pac heights wtf yo

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • where-you-app/site/app/controllers/hood_controller.rb

    r1477 r1478  
    1818    res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) } 
    1919 
    20     # FIXME: check well-formedness of response 
    21      
    2220    @json = JSON.parse(res.body) 
    23     @neighborhood = @json["neighborhoods"][0]["name"] 
    24     return 
    25      if @json.has_key? 'neighborhoods' 
    26       @json = "fuckballs" 
    27      else 
    28       @json = "shitballs" 
    29      end 
     21    if @json.has_key? "neighborhoods"  
     22      if @json["neighborhoods"].length > 0 
     23        @neighborhood = @json["neighborhoods"][0]["name"] 
     24        @yelp_hood_url = @json["neighborhoods"][0]["url"] 
     25      else 
     26        @neighborhood = "ACTUALLY, YELP HAS NO IDEA WHERE YOU ARE. ISN'T THAT GAY?" 
     27        @yelp_hood_url = "http://www.youtube.com/watch?v=4NE-5jG6tvk" 
     28      end 
     29    end 
    3030 
    3131  end 
  • where-you-app/site/app/views/hood/index.rhtml

    r1477 r1478  
    11<script type="text/javascript"> 
    2   function populate_default( field_name, value ) { 
    3     document.forms[0][field_name].value = value; 
     2  function use_test_loc( lat, lng ) { 
     3    document.forms[0]["lat"].value  = lat; 
     4    document.forms[0]["long"].value = lng; 
    45  } 
    56</script> 
    67 
    78<div class="main" id="<%= @controller.controller_name %>"> 
    8   <h1>What Choo Know About My Hood?</h1
     9  <h2><a href="http://www.youtube.com/watch?v=4NE-5jG6tvk">Whachoo Know About My Hood?</a></h2
    910 
    1011  <pre> 
     
    1213 
    1314  <form method="POST"> 
    14     <label>lat 
     15    No GPS? Try some example places: <br /> 
     16      <a href="javascript:use_test_loc(40.719816, -73.985082);">L.E.S.</a>, 
     17      <a href="javascript:use_test_loc(37.785615, -122.415082);">loin</a>, 
     18      <a href="javascript:use_test_loc(37.783266, -122.393670);">SOMA</a>, 
     19      <a href="javascript:use_test_loc(37.474177, -122.264304);">pac heights</a>, 
     20      <a href="javascript:use_test_loc(37.802728, -122.405582);">telegraph hill</a>, 
     21      <a href="javascript:use_test_loc(37.756085, -122.418851);">the mission</a>, 
     22      <a href="javascript:use_test_loc(37.783789, -122.482768);">da richmond</a> 
     23    <label>lat: &nbsp; 
    1524      <input name="lat" value="<%= params[:lat] %>" /> 
    16       <a href="javascript:populate_default('lat','<%= @default_lat %>');">click to use an example latitude: <%= @default_lat %></a> 
    1725    </label> 
    18     <label>long 
     26    <label>long: 
    1927      <input name="long" value="<%= params[:long] %>" /> 
    20       <a href="javascript:populate_default('long','<%= @default_long %>');">click to use example longitude: <%= @default_long %></a> 
    2128    </label> 
    22     <input type="submit" value="where i'm at? (via geocode)"/> 
     29    <p/> 
     30    <input type="submit" value="Where i'm at?"/> 
    2331  </form> 
    2432 
    2533  <% if @neighborhood %> 
    2634  <div class="response"> 
    27     <h1>neighborhood:</h1
    28     @neighborhood: <%= @neighborhood %
     35    <h2>neighborhood:</h2
     36    <h1>You're in: <%=  link_to @neighborhood, @yelp_hood_url %></h1
    2937  </div> 
    3038  <% end %> 
  • where-you-app/site/app/views/hood/whats_my_hood.sh

    r1475 r1478  
    1212coords="lat=37.785615&long=-122.415082"    # Lahore Karahi, the dirty loin: 612 O'farrell St  
    1313 
     14# LES: (40.719816, -73.985082) 
     15 
    1416yelp_webservice_ID="Fc6e-WNOcF8aJCx-ZboOFQ" 
    1517