more best practices and refactoring, may have broke something

okor лет %!s(int64=12): %!d(string=назад)
Родитель
Сommit
bc38ec2493
2 измененных файлов с 19 добавлено и 24 удалено
  1. 5 10
      main.rb
  2. 14 14
      views/lookup.haml

+ 5 - 10
main.rb

@@ -25,7 +25,7 @@ helpers do
25 25
 			:domain => lookup_info.domain,
26 26
 			:created_on => lookup_info.created_on,
27 27
 			:expires_on => lookup_info.expires_on,
28
-			:whois_server => lookup_info.referral_whois,
28
+			:whois_servers => lookup_info.referral_whois,
29 29
 			:nameservers => lookup_info.nameservers,
30 30
 			:admin_contacts => admin_contacts,
31 31
 			:techical_contacts => technical_contacts
@@ -36,20 +36,15 @@ end
36 36
 
37 37
 
38 38
 get '/' do
39
-	cache_for_day
39
+	# cache_for_day
40 40
 	haml :index
41 41
 end
42 42
 
43 43
 
44
-get '/ip.json' do
45
-	{ :ip => request.ip }.to_json
46
-end
47
-
48
-
49 44
 get '/lookup' do
50 45
 	begin
51
-		cache_for_day
52
-		@formatted_response = whois_lookup
46
+		# cache_for_day
47
+		@whois = whois_lookup
53 48
 		haml :lookup
54 49
 	rescue
55 50
 		haml :error
@@ -59,7 +54,7 @@ end
59 54
 
60 55
 get '/lookup.json' do
61 56
 	begin
62
-		cache_for_day
57
+		# cache_for_day
63 58
 		whois_lookup.to_json
64 59
 	rescue
65 60
 		{:Error => 'Bad Request'}.to_json

+ 14 - 14
views/lookup.haml

@@ -7,44 +7,44 @@
7 7
 		.info
8 8
 			%p.title URL
9 9
 			%p.content
10
-				= @formatted_response[:domain]
10
+				= @whois[:domain]
11 11
 
12 12
 		.info
13 13
 			%p.title Admin Contact
14
-			%p.content
15
-				- if @formatted_response[:admin_contacts]
16
-					- @formatted_response[:admin_contacts].each do |contact|
17
-						= "<strong> #{contact[0]} </strong>: #{contact[1]} <br />"
14
+			.content
15
+				- if @whois[:admin_contacts]
16
+					- @whois[:admin_contacts].each do |contact|
17
+						= "<p><strong> #{contact[0]} </strong>: #{contact[1]} </p>"
18 18
 				- else
19 19
 					= 'none'
20 20
 
21 21
 		.info
22 22
 			%p.title Technical Contact
23
-			%p.content
24
-				- if @formatted_response[:technical_contacts]
25
-					- @formatted_response[:technical_contacts].each do |contact|
26
-						= "#{contact} <br />"
23
+			.content
24
+				- if @whois[:technical_contacts]
25
+					- @whois[:technical_contacts].each do |contact|
26
+						= "<p> #{contact} </p>"
27 27
 				- else
28 28
 					= 'none'
29 29
 
30 30
 		.info
31 31
 			%p.title Create Date
32 32
 			%p.content
33
-				= @formatted_response[:created_on]
33
+				= @whois[:created_on]
34 34
 
35 35
 		.info
36 36
 			%p.title Expire Date
37 37
 			%p.content
38
-				= @formatted_response[:expires_on]
38
+				= @whois[:expires_on]
39 39
 
40 40
 		.info
41 41
 			%p.title WHOIS Server
42 42
 			%ul.content
43
-				- @formatted_response[:whois_server].each do |server|
43
+				- @whois[:whois_servers].each do |server|
44 44
 					= "<li> #{server} </li>"
45 45
 
46 46
 		.info
47 47
 			%p.title Nameservers
48 48
 			%ul.content
49
-				- @formatted_response[:nameservers].each do |name|
50
-					= "<li> #{name} </li>"
49
+				- @whois[:name_servers].each do |server|
50
+					= "<li> #{server} </li>"