Commit 1fa52ab55625c7105cd96e96bb66f05664fd2223
1 parent
8f135d16
Exists in
master
and in
1 other branch
quick link to geocoded ip
Showing
3 changed files
with
19 additions
and
1 deletions
Show diff stats
app/models/click.rb
| 1 | 1 | class Click < ActiveRecord::Base |
| 2 | 2 | belongs_to :site |
| 3 | 3 | belongs_to :visitor |
| 4 | + | |
| 5 | + def page | |
| 6 | + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil | |
| 7 | + end | |
| 8 | + | |
| 9 | + | |
| 10 | + def ip | |
| 11 | + ip = what_was_clicked.split('[ip: ')[1].split(']').first rescue nil | |
| 12 | + end | |
| 13 | + | |
| 14 | + def to_html | |
| 15 | + if ip | |
| 16 | + return what_was_clicked.gsub('ip', "http://api.hostip.info/get_html.php?ip=#{ip}") | |
| 17 | + else | |
| 18 | + return what_was_clicked | |
| 19 | + end | |
| 20 | + end | |
| 4 | 21 | end | ... | ... |
app/views/clicks/index.html.erb
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | <tr> |
| 14 | 14 | <td><%=h click.site_id %></td> |
| 15 | 15 | <td><%=h click.visitor_id %></td> |
| 16 | - <td><%=h click.what_was_clicked %></td> | |
| 16 | + <td><%=h click.to_html %></td> | |
| 17 | 17 | <td><%= link_to 'Show', click %></td> |
| 18 | 18 | <td><%= link_to 'Destroy', click, :confirm => 'Are you sure?', :method => :delete %></td> |
| 19 | 19 | </tr> | ... | ... |
app/views/layouts/clicks.html.erb
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | |
| 4 | 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | 5 | <head> |
| 6 | + <script src="http://www.google.com/jsapi"></script> | |
| 6 | 7 | <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> |
| 7 | 8 | <script type="text/javascript" src="/javascripts/highcharts.js"></script> |
| 8 | 9 | <!--[if IE]> | ... | ... |