@@ -12,23 +12,23 @@ helpers do |
||
| 12 | 12 |
|
| 13 | 13 |
def cache_for_day |
| 14 | 14 |
if settings.environment != :development |
| 15 |
- response['Cache-Control'] = "public, max-age=86400" |
|
| 15 |
+ response['Cache-Control'] = 'public, max-age=86400' |
|
| 16 | 16 |
end |
| 17 | 17 |
end |
| 18 | 18 |
|
| 19 | 19 |
def whois_lookup |
| 20 |
- @lookup_info = Whois.query(params[:url]) |
|
| 21 |
- @admin_contacts = Hash[@lookup_info.admin_contacts[0].each_pair.to_a] |
|
| 22 |
- @technical_contacts = Hash[@lookup_info.technical_contacts[0].each_pair.to_a] |
|
| 20 |
+ lookup_info = Whois.query(params[:url]) |
|
| 21 |
+ admin_contacts = Hash[lookup_info.admin_contacts[0].each_pair.to_a] |
|
| 22 |
+ technical_contacts = Hash[lookup_info.technical_contacts[0].each_pair.to_a] |
|
| 23 | 23 |
|
| 24 |
- return {
|
|
| 25 |
- "domain" => @lookup_info.domain, |
|
| 26 |
- "created_on" => @lookup_info.created_on, |
|
| 27 |
- "expires_on" => @lookup_info.expires_on, |
|
| 28 |
- "whois_server" => @lookup_info.referral_whois, |
|
| 29 |
- "nameservers" => @lookup_info.nameservers, |
|
| 30 |
- "admin_contacts" => @admin_contacts, |
|
| 31 |
- "techical_contacts" => @technical_contacts |
|
| 24 |
+ {
|
|
| 25 |
+ :domain => lookup_info.domain, |
|
| 26 |
+ :created_on => lookup_info.created_on, |
|
| 27 |
+ :expires_on => lookup_info.expires_on, |
|
| 28 |
+ :whois_server => lookup_info.referral_whois, |
|
| 29 |
+ :nameservers => lookup_info.nameservers, |
|
| 30 |
+ :admin_contacts => admin_contacts, |
|
| 31 |
+ :techical_contacts => technical_contacts |
|
| 32 | 32 |
} |
| 33 | 33 |
end |
| 34 | 34 |
|
@@ -62,6 +62,6 @@ get '/lookup.json' do |
||
| 62 | 62 |
cache_for_day |
| 63 | 63 |
whois_lookup.to_json |
| 64 | 64 |
rescue |
| 65 |
- {"Error" => "Bad Request"}.to_json
|
|
| 65 |
+ {:Error => 'Bad Request'}.to_json
|
|
| 66 | 66 |
end |
| 67 | 67 |
end |
@@ -2,48 +2,49 @@ |
||
| 2 | 2 |
%html |
| 3 | 3 |
%head |
| 4 | 4 |
%title A free whois API service |
| 5 |
- %link{:rel => "stylesheet", :type => "text/css", :href => "/css/styles.css"}
|
|
| 5 |
+ %link{:rel => 'stylesheet', :type => 'text/css', :href => '/css/styles.css'}
|
|
| 6 | 6 |
%body |
| 7 | 7 |
.info |
| 8 | 8 |
%p.title URL |
| 9 | 9 |
%p.content |
| 10 |
- = @formatted_response["domain"] |
|
| 10 |
+ = @formatted_response[:domain] |
|
| 11 | 11 |
|
| 12 | 12 |
.info |
| 13 | 13 |
%p.title Admin Contact |
| 14 | 14 |
%p.content |
| 15 |
- - if @formatted_response["admin_contacts"] |
|
| 16 |
- - @formatted_response["admin_contacts"].each do |contact| |
|
| 17 |
- = "<strong>" + contact[0].to_s + "</strong>: " + contact[1].to_s + "<br />" |
|
| 15 |
+ - if @formatted_response[:admin_contacts] |
|
| 16 |
+ - @formatted_response[:admin_contacts].each do |contact| |
|
| 17 |
+ = "<strong> #{contact[0]} </strong>: #{contact[1]} <br />"
|
|
| 18 | 18 |
- else |
| 19 |
- = "none" |
|
| 19 |
+ = 'none' |
|
| 20 | 20 |
|
| 21 | 21 |
.info |
| 22 | 22 |
%p.title Technical Contact |
| 23 | 23 |
%p.content |
| 24 |
- - if @formatted_response["technical_contacts"] |
|
| 25 |
- - @formatted_response["technical_contacts"].each do |contact| |
|
| 26 |
- = contact.to_s + " <br />" |
|
| 24 |
+ - if @formatted_response[:technical_contacts] |
|
| 25 |
+ - @formatted_response[:technical_contacts].each do |contact| |
|
| 26 |
+ = "#{contact} <br />"
|
|
| 27 | 27 |
- else |
| 28 |
- = "none" |
|
| 28 |
+ = 'none' |
|
| 29 | 29 |
|
| 30 | 30 |
.info |
| 31 | 31 |
%p.title Create Date |
| 32 | 32 |
%p.content |
| 33 |
- = @formatted_response["created_on"] |
|
| 33 |
+ = @formatted_response[:created_on] |
|
| 34 | 34 |
|
| 35 | 35 |
.info |
| 36 | 36 |
%p.title Expire Date |
| 37 | 37 |
%p.content |
| 38 |
- = @formatted_response["expires_on"] |
|
| 38 |
+ = @formatted_response[:expires_on] |
|
| 39 | 39 |
|
| 40 | 40 |
.info |
| 41 | 41 |
%p.title WHOIS Server |
| 42 |
- %p.content |
|
| 43 |
- = @formatted_response["whois_server"] |
|
| 42 |
+ %ul.content |
|
| 43 |
+ - @formatted_response[:whois_server].each do |server| |
|
| 44 |
+ = "<li> #{server} </li>"
|
|
| 44 | 45 |
|
| 45 | 46 |
.info |
| 46 | 47 |
%p.title Nameservers |
| 47 |
- %p.content |
|
| 48 |
- - @formatted_response["nameservers"].each do |name| |
|
| 49 |
- = name.to_s + " <br />" |
|
| 48 |
+ %ul.content |
|
| 49 |
+ - @formatted_response[:nameservers].each do |name| |
|
| 50 |
+ = "<li> #{name} </li>"
|