Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 4d28ac0

Browse files
committed
how much ?
1 parent 6a96824 commit 4d28ac0

File tree

5 files changed

+47
-0
lines changed

5 files changed

+47
-0
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ gem 'jquery-rails'
2828
gem 'pry-rails'
2929
gem 'heroku'
3030
gem 'bootstrap-sass'
31+
gem 'haml'
3132
gem 'haml_coffee_assets'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GEM
4343
erubis (2.7.0)
4444
execjs (1.3.1)
4545
multi_json (~> 1.0)
46+
haml (3.1.4)
4647
haml_coffee_assets (0.8.4)
4748
execjs (>= 1.2.9)
4849
sprockets (>= 2.0.3)
@@ -137,6 +138,7 @@ PLATFORMS
137138
DEPENDENCIES
138139
bootstrap-sass
139140
coffee-rails (~> 3.2.1)
141+
haml
140142
haml_coffee_assets
141143
heroku
142144
jquery-rails
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
1+
#encoding: utf-8
12
class CybersquattingController < ApplicationController
3+
respond_to :html, :json
4+
25
def index
36
render :index, layout: false
47
end
8+
9+
def how_much
10+
@domain = params[:d] || 'facebook'
11+
@domain_price = params[:domain_price].try(:to_f) || 4.99
12+
13+
# ß, à, á, â, ã, ä, å, æ, ç, è, é, ê, ë, ì, í
14+
# î, ï, ñ, ò, ó, ô, õ, ö, ù, ú, û, ü, ý, ÿ, œ
15+
squatting = {
16+
'a' => ['à', 'á', 'â', 'ã', 'ä', 'å', 'æ'],
17+
'b' => ['ß'],
18+
'c' => ['ç'],
19+
'e' => ['è', 'é', 'ê', 'ë', 'œ'],
20+
'i' => ['ì', 'í', 'î', 'ï'],
21+
'n' => ['ñ'],
22+
'o' => ['ò', 'ó', 'ô', 'ô', 'õ', 'ö', 'œ'],
23+
'u' => ['ù', 'ú', 'û', 'ü'],
24+
'y' => ['ý', 'ÿ']
25+
}
26+
27+
@domains = @domain.split(//).reduce(['']) do |ary, c|
28+
ary = ary.map do |partial_domain|
29+
squatting[c].try(:map){|sc| partial_domain + sc}.try(:<<, partial_domain + c) || partial_domain + c
30+
end
31+
ary.flatten
32+
end
33+
34+
@price = @domain_price * @domains.length
35+
r = {domains: @domains, price: @price}
36+
respond_with r.to_json
37+
end
538
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
!!!
2+
%form{method: 'GET'}
3+
%input{type: 'text', name: 'd', placeholder: 'domain, eg: facebook', value: @domain}
4+
%input{type: 'text', name: 'domain_price', placeholder: 'price, eg: 4.99', value: @domain_price}
5+
%input{type: 'submit'}
6+
7+
%p.total= "#{@domains.length} domains * $#{@domain_price} = $#{@price}"
8+
%ul
9+
- @domains.each do |d|
10+
%li= d

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Facessook::Application.routes.draw do
22
root to: 'cybersquatting#index'
33
#get '/**' => 'cybersquatting#index'
4+
get '/how_much' => 'cybersquatting#how_much'
45
end

0 commit comments

Comments
 (0)