Skip to content

Commit

Permalink
Added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
parolkar committed Oct 21, 2009
1 parent 1a312c6 commit 9ad75cb
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 15 deletions.
79 changes: 74 additions & 5 deletions README.markdown
@@ -1,15 +1,84 @@
GeoMereLaal
===========
GeoMereLaal plugin is all you need to create Location-Aware rails application based on [W3C Geolocaton API](http://dev.w3.org/geo/api/spec-source.html "W3C draft for geolocation api").

### What's Location-Awareness?
W3C proposed an API in which internet browsers can have capability to retrieve geo-location of the user via multiple sources (Wifi, LBS, IP, browser cookies) and share it with web apps so that apps can serve content based on user's location.

This plugin allows you to detect geo-loacation of your users through http://www.mozilla.com/en-US/firefox/geolocation/
### Who supports it?
<table border="1">
<tbody>
<tr>
<th>Web Browser</th>
<th>Geolocation API support</th>
</tr>
<tr>
<td>Mozilla Firefox</td>

Requirement: Firefox 3+
<td>supported in [Firefox 3.5](http://www.mozilla.com/en-US/firefox/geolocation/ "browser support") and later versions.</td>
</tr>
<tr>
<td>Chrome</td>
<td>Supports thru <a title="Google gears Geolocation API specification" href="http://code.google.com/apis/gears/api_geolocation.html">Google Gears Geolocation API</a></td>
</tr>
<tr>
<td>Opera</td>
<td>Supported in nightly builds – <a title="Operal Geolocation supported version - download page" href="http://labs.opera.com/news/2009/03/26/">download from this page</a></td>
</tr>

<tr>
<td>Safari</td>
<td>Support is <a title="Geolocation API support in Safari" href="http://blogs.computerworld.com/node/14114/print">coming soon</a> in the IPhone’s Safari browser.</td>
</tr>
<tr>
<td>Internet Explorer</td>
<td>An experimental support available from IE8.</td>
</tr>
</tbody>
</table>

Example
=======

soon to come..

How do I use it?
----------------
### Step 1 : Install
<pre><code> script/plugin install git://github.com/parolkar/geo_mere_laal.git </code></pre>
### Step 2 : Create form (as you always did but with new helpers)
Note: You may want to generate Address model this way script/generate model Address street:string locality:string city:string state:string country:string zip:string lat:string lng:string
<pre><code>
<% form_tag('#') do -%>
<%= label :address,"street","Street" -%>
<%= street_field :address, "street" %>

<%= label :address,"locality","Locality" -%>
<%= locality_field :address, "locality" %>

<%= label :address,"city","City" -%>
<%= city_field :address, "city" %>

<%= label :address,"state","State" -%>
<%= state_field :address, "state" %>

<%= label :address,"country","Country Name" -%>
<%= country_name_field :address, "country" %>

<%= label :address,"zip","Postal Code" -%>
<%= postal_code_field :address, "zip" %>

<% end %>
</code></pre>
### Step 3: ...... there is no step 3 ;-)
The rendered form will auto fill the content with user's geolocation

Output
------

(about to come)






Copyright (c) 2009 Abhishek Parolkar, released under the MIT license
Binary file added docs/geo_mere_laal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions lib/geo_mere_laal_helper.rb
Expand Up @@ -3,71 +3,71 @@ module GeoMereLaalHelper


def latitude_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml
result << "<script> GeoMereLaal.updateLatitude_callback = function(){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",GeoMereLaal.lat())}; </script>"
end

def longitude_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml
result << "<script> GeoMereLaal.updateLongitude_callback = function(){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",GeoMereLaal.lng())}; </script>"
end


def full_address_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateFullAddress_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def country_name_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateCountryName_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def country_code_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateCountryCode_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def state_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateState_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def city_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateCity_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def locality_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateLocality_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def street_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updateStreet_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
end

def postal_code_field(object, method, options={})
it = ActionView::Helpers::InstanceTag.new(object.dup, method, self)
it = ActionView::Helpers::InstanceTag.new(object.to_s.dup, method, self)
result = it.to_input_field_tag("text", options)
result << init_gml_rc
result << "<script> GMLReverseCoder.updatePostalCode_callback = function(resp_value){ document.getElementById(\"#{it.object_name.to_s+'_'+it.method_name.to_s}\").setAttribute(\"value\",resp_value)}; </script>"
Expand Down

0 comments on commit 9ad75cb

Please sign in to comment.