world-flags 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +72 -0
- data/README.textile +79 -11
- data/VERSION +1 -1
- data/lib/world-flags.rb +71 -0
- data/lib/world_flags/countries.rb +21 -0
- data/lib/world_flags/languages.rb +22 -0
- data/lib/world_flags/locale_helper.rb +36 -2
- data/lib/world_flags/view_helper.rb +37 -14
- data/spec/world_flags/country_spec.rb +0 -0
- data/spec/world_flags/language_spec.rb +7 -0
- data/spec/world_flags/view_helper_spec.rb +12 -5
- data/vendor/assets/stylesheets/flags/basic.css +31 -0
- data/vendor/assets/stylesheets/flags/basic.scss.css +32 -0
- data/world-flags.gemspec +10 -3
- metadata +11 -4
data/CHANGELOG
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
## 0.2.0
|
2
|
+
|
3
|
+
Lots of new features, including:
|
4
|
+
|
5
|
+
- locale helper for use in Controllers
|
6
|
+
- localization/translations of countries and languages
|
7
|
+
- auto-selection of flag class, for flag matching current locale
|
8
|
+
- manually set which flag is to be selected
|
9
|
+
- and much more...
|
10
|
+
|
11
|
+
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,80 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
actionmailer (3.2.2)
|
5
|
+
actionpack (= 3.2.2)
|
6
|
+
mail (~> 2.4.0)
|
7
|
+
actionpack (3.2.2)
|
8
|
+
activemodel (= 3.2.2)
|
9
|
+
activesupport (= 3.2.2)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.1)
|
13
|
+
rack (~> 1.4.0)
|
14
|
+
rack-cache (~> 1.1)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.1.2)
|
17
|
+
activemodel (3.2.2)
|
18
|
+
activesupport (= 3.2.2)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.2)
|
21
|
+
activemodel (= 3.2.2)
|
22
|
+
activesupport (= 3.2.2)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.2)
|
26
|
+
activemodel (= 3.2.2)
|
27
|
+
activesupport (= 3.2.2)
|
28
|
+
activesupport (3.2.2)
|
29
|
+
i18n (~> 0.6)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
arel (3.0.2)
|
32
|
+
builder (3.0.0)
|
4
33
|
diff-lcs (1.1.3)
|
34
|
+
erubis (2.7.0)
|
5
35
|
git (1.2.5)
|
36
|
+
hike (1.2.1)
|
6
37
|
httparty (0.8.1)
|
7
38
|
multi_json
|
8
39
|
multi_xml
|
40
|
+
i18n (0.6.0)
|
9
41
|
jeweler (1.8.3)
|
10
42
|
bundler (~> 1.0)
|
11
43
|
git (>= 1.2.5)
|
12
44
|
rake
|
13
45
|
rdoc
|
46
|
+
journey (1.0.3)
|
14
47
|
json (1.6.5)
|
48
|
+
mail (2.4.4)
|
49
|
+
i18n (>= 0.4.0)
|
50
|
+
mime-types (~> 1.16)
|
51
|
+
treetop (~> 1.4.8)
|
52
|
+
mime-types (1.17.2)
|
15
53
|
multi_json (1.1.0)
|
16
54
|
multi_xml (0.4.2)
|
55
|
+
polyglot (0.3.3)
|
56
|
+
rack (1.4.1)
|
57
|
+
rack-cache (1.2)
|
58
|
+
rack (>= 0.4)
|
59
|
+
rack-ssl (1.3.2)
|
60
|
+
rack
|
61
|
+
rack-test (0.6.1)
|
62
|
+
rack (>= 1.0)
|
63
|
+
rails (3.2.2)
|
64
|
+
actionmailer (= 3.2.2)
|
65
|
+
actionpack (= 3.2.2)
|
66
|
+
activerecord (= 3.2.2)
|
67
|
+
activeresource (= 3.2.2)
|
68
|
+
activesupport (= 3.2.2)
|
69
|
+
bundler (~> 1.0)
|
70
|
+
railties (= 3.2.2)
|
71
|
+
railties (3.2.2)
|
72
|
+
actionpack (= 3.2.2)
|
73
|
+
activesupport (= 3.2.2)
|
74
|
+
rack-ssl (~> 1.3.2)
|
75
|
+
rake (>= 0.8.7)
|
76
|
+
rdoc (~> 3.4)
|
77
|
+
thor (~> 0.14.6)
|
17
78
|
rake (0.9.2.2)
|
18
79
|
rdoc (3.12)
|
19
80
|
json (~> 1.4)
|
@@ -29,6 +90,16 @@ GEM
|
|
29
90
|
multi_json (~> 1.0)
|
30
91
|
simplecov-html (~> 0.5.3)
|
31
92
|
simplecov-html (0.5.3)
|
93
|
+
sprockets (2.1.2)
|
94
|
+
hike (~> 1.2)
|
95
|
+
rack (~> 1.0)
|
96
|
+
tilt (~> 1.1, != 1.3.0)
|
97
|
+
thor (0.14.6)
|
98
|
+
tilt (1.3.3)
|
99
|
+
treetop (1.4.10)
|
100
|
+
polyglot
|
101
|
+
polyglot (>= 0.3.1)
|
102
|
+
tzinfo (0.3.32)
|
32
103
|
|
33
104
|
PLATFORMS
|
34
105
|
ruby
|
@@ -37,6 +108,7 @@ DEPENDENCIES
|
|
37
108
|
bundler (>= 1.0.0)
|
38
109
|
httparty
|
39
110
|
jeweler (>= 1.8.3)
|
111
|
+
rails (>= 3.1)
|
40
112
|
rdoc (>= 3.12)
|
41
113
|
rspec (>= 2.8.0)
|
42
114
|
simplecov (>= 0.5)
|
data/README.textile
CHANGED
@@ -2,6 +2,8 @@ h1. The flags of the world as a sprite for use with Rails
|
|
2
2
|
|
3
3
|
Includes css files for size 16 and 32 pixels and have all the worlds' flags.
|
4
4
|
|
5
|
+
See http://spritegen.website-performance.org/
|
6
|
+
|
5
7
|
h2. Configuration
|
6
8
|
|
7
9
|
In you asset application.css manifest file:
|
@@ -9,10 +11,13 @@ In you asset application.css manifest file:
|
|
9
11
|
*/
|
10
12
|
*= require_self
|
11
13
|
*= require_tree .
|
14
|
+
*= require flags/basic
|
12
15
|
*= require flags/flags32
|
13
16
|
*= require flags/flags32_semi
|
14
17
|
*/
|
15
18
|
|
19
|
+
The `flags/basic` stylesheet sets up a basic css for use with borders around the 32 and 64 pixel flag images (to mark selected language). Use this css as inspiration and customize by overriding styles as needed.
|
20
|
+
|
16
21
|
There is also support for semi-transparent flags. This can be used to fade certain flags while having the selected flag (or hovered over flag) in full brightness.
|
17
22
|
|
18
23
|
Simply add or remove the "semi" class for the flag to adjust the brightness level (fx for selection/mouse over).
|
@@ -25,7 +30,7 @@ $("li.flag['data-cc'=dk).removeClass('semi');
|
|
25
30
|
*= require_self
|
26
31
|
*= require_tree .
|
27
32
|
*= require flags/flags32
|
28
|
-
*= require flags/
|
33
|
+
*= require flags/flags62
|
29
34
|
*/
|
30
35
|
|
31
36
|
|
@@ -45,6 +50,21 @@ Alternatively for the 32 width flags
|
|
45
50
|
|
46
51
|
= use_flags 32
|
47
52
|
|
53
|
+
h2. Configuring localization
|
54
|
+
|
55
|
+
You can setup WorldFlags to use a localization map for the labels of the flag icons
|
56
|
+
|
57
|
+
WorldFlags.languages = some_language_hash # fx loaded from a yaml file
|
58
|
+
WorldFlags.countries = some_country_hash # fx loaded from a yaml file
|
59
|
+
|
60
|
+
Notice that it is a locale code pointing to a map of ISO_3166-1_alpha-2 codes
|
61
|
+
to labels for that locale.
|
62
|
+
|
63
|
+
{
|
64
|
+
:en => {:gb => 'English', :dk => 'Danish'}
|
65
|
+
:da => {:gb => 'Engelsk', :dk => 'Dansk'}
|
66
|
+
}
|
67
|
+
|
48
68
|
h2. Rendering
|
49
69
|
|
50
70
|
Flags will be rendered in HTML as:
|
@@ -66,23 +86,50 @@ WorldFlags supports flag sizes in 16, 32 and 64 pixels (size).
|
|
66
86
|
You can also use built in helper methods:
|
67
87
|
|
68
88
|
= flag_list 16 do
|
69
|
-
= flags :ar
|
89
|
+
= flags [:ar, :gb], :selected => :gb
|
70
90
|
|
71
91
|
Alternatively
|
72
92
|
|
73
|
-
=
|
74
|
-
= flag(:ar
|
93
|
+
= flag_list 32 do
|
94
|
+
= flag(:ar) + flag(:gb, :selected => true)
|
95
|
+
|
96
|
+
Or using the #flag_code helper
|
75
97
|
|
76
|
-
|
98
|
+
= flag(:ar) + flag(:gb, :selected => flag_code(I18n.locale)
|
77
99
|
|
78
|
-
|
79
|
-
|
100
|
+
For use with tooltips or similar js plguins, it can be useful to set the <li> title attribute:
|
101
|
+
|
102
|
+
= flag_list 32 do
|
103
|
+
= flags [:ar, :br, :gb], :title => true
|
80
104
|
|
81
105
|
The flag_title will render the following list item:
|
82
106
|
|
83
107
|
<li class="flag ar" lang="ar" title="Argentina"> </li>
|
84
108
|
|
85
|
-
The
|
109
|
+
Note: The ` is needed in order for the background (flag icon) to have something to be displayed against.
|
110
|
+
|
111
|
+
To also get content rendered for the <li>
|
112
|
+
|
113
|
+
= flags [:ar, :br, :gb], :content => true
|
114
|
+
|
115
|
+
Note: There is also a #flag_selected? helper, which is (and/or can be) used to determine if the flag to be drawn should have the "selected" class set)
|
116
|
+
The auto-select feature is by default turned off, but can be turned on/off using:
|
117
|
+
|
118
|
+
WorldFlags.auto_select = true # or WorldFlags.auto_select!
|
119
|
+
|
120
|
+
h2. Using localization
|
121
|
+
|
122
|
+
You can specify whether to look up labels for the flags for either language or country and for which locale to look up the labels (see Configuring localization)
|
123
|
+
|
124
|
+
Use danish (da) country labels
|
125
|
+
|
126
|
+
= flag_list 32 do
|
127
|
+
= flags [:ar, :br, :gb], :country => :da
|
128
|
+
|
129
|
+
Use danish (da) language labels
|
130
|
+
|
131
|
+
= flag_list 32 do
|
132
|
+
= flags [:ar, :br, :gb], :language => I18n.locale
|
86
133
|
|
87
134
|
h2. Get client country code (browser and geo)
|
88
135
|
|
@@ -111,7 +158,28 @@ class MainController < ApplicationController
|
|
111
158
|
end
|
112
159
|
end
|
113
160
|
|
114
|
-
|
161
|
+
If you include the WorldFlags::Locale module, you can simply do:
|
162
|
+
|
163
|
+
before_filter :set_locale
|
164
|
+
|
165
|
+
And it should set the I18n.locale appropriately, trying params[locale], browser, ip address in succession, defaulting to I18n.default_locale.
|
166
|
+
For each locale it will check if it is a vaild locale, using
|
167
|
+
WorldFlags::Locale#valid_locales
|
168
|
+
|
169
|
+
For convenience you can also include WorldFlags::All to include all these modules.
|
170
|
+
|
171
|
+
Example:
|
172
|
+
|
173
|
+
class MainController < ApplicationController
|
174
|
+
include WorldFlags::All
|
175
|
+
|
176
|
+
before_filter :set_locale
|
177
|
+
end
|
178
|
+
|
179
|
+
You must set up valid locales for use with WorldFlags in some initializer:
|
180
|
+
|
181
|
+
# fx [:da, :en] or even ['da', 'en']
|
182
|
+
WorldFlags::Locale.locales = my_valid_locales_list
|
115
183
|
|
116
184
|
h2. Nice effects
|
117
185
|
|
@@ -166,8 +234,8 @@ Layout file:
|
|
166
234
|
= link_to "Sign up", new_user_registration_path
|
167
235
|
|
168
236
|
#languages
|
169
|
-
=
|
170
|
-
=
|
237
|
+
= flag_list 64 do
|
238
|
+
= flags [:ar, :gb], :selected => WorldFlags.flag_code(@locale)
|
171
239
|
%p.clear
|
172
240
|
= yield
|
173
241
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/world-flags.rb
CHANGED
@@ -2,3 +2,74 @@ require "world_flags/view_helper"
|
|
2
2
|
require "world_flags/locale_helper"
|
3
3
|
require 'world_flags/rails/engine' if defined?(::Rails::Engine)
|
4
4
|
|
5
|
+
require "world_flags/languages"
|
6
|
+
require "world_flags/countries"
|
7
|
+
|
8
|
+
module WorldFlags
|
9
|
+
class << self
|
10
|
+
attr_accessor :auto_select
|
11
|
+
|
12
|
+
def auto_select?
|
13
|
+
auto_select
|
14
|
+
end
|
15
|
+
|
16
|
+
def auto_select!
|
17
|
+
@auto_select = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def label code = :en, options = {:language => :en}
|
21
|
+
label = options[:country] ? WorldFlags.country(options[:country], code) : WorldFlags.language(options[:language], code)
|
22
|
+
# if all else fails
|
23
|
+
default_locale = I18n.locale || :en
|
24
|
+
label ||= WorldFlags.language(default_locale, code)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Locale translation helper macros
|
28
|
+
|
29
|
+
def flag_code code
|
30
|
+
locale_flag_map[code.to_sym] || code
|
31
|
+
end
|
32
|
+
|
33
|
+
attr_accessor :locale_flag_map
|
34
|
+
|
35
|
+
# translate locales to flag code: ISO_3166-1_alpha-2
|
36
|
+
def locale_flag_map
|
37
|
+
@locale_map ||= {
|
38
|
+
:en => :gb,
|
39
|
+
:da => :dk
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Language helper macros
|
44
|
+
|
45
|
+
def language locale = :en, code = :en
|
46
|
+
locale ||= :en
|
47
|
+
languages[locale][code]
|
48
|
+
end
|
49
|
+
|
50
|
+
def languages= languages
|
51
|
+
raise ArgumentError, "Must be a hash, was: #{languages}" unless languages.kind_of?(Hash)
|
52
|
+
@languages = languages
|
53
|
+
end
|
54
|
+
|
55
|
+
def languages
|
56
|
+
@languages ||= {:en => Languages.en}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Country helper macros
|
60
|
+
|
61
|
+
def country locale = :en, code = :en
|
62
|
+
locale ||= :en
|
63
|
+
countries[locale][code]
|
64
|
+
end
|
65
|
+
|
66
|
+
def countries= countries
|
67
|
+
raise ArgumentError, "Must be a hash, was: #{countries}" unless countries.kind_of?(Hash)
|
68
|
+
@countries = countries
|
69
|
+
end
|
70
|
+
|
71
|
+
def countries
|
72
|
+
@countries ||= {:en => Countries.en}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module WorldFlags
|
2
|
+
module Countries
|
3
|
+
def self.en
|
4
|
+
{
|
5
|
+
:ar => 'Argentina',
|
6
|
+
:br => 'Brazil',
|
7
|
+
:gb => 'Great Britain',
|
8
|
+
:us => 'United States',
|
9
|
+
:es => 'Spain',
|
10
|
+
:gr => 'Greece',
|
11
|
+
:it => 'Italy',
|
12
|
+
:nl => 'Netherlands',
|
13
|
+
:de => 'Germany',
|
14
|
+
:dk => 'Denmark',
|
15
|
+
:se => 'Sweden',
|
16
|
+
:no => 'Norway',
|
17
|
+
:fi => 'Finland'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module WorldFlags
|
2
|
+
module Languages
|
3
|
+
def self.en
|
4
|
+
{
|
5
|
+
:ar => 'Argentinian Spanish',
|
6
|
+
:br => 'Brazilian Portuguese',
|
7
|
+
:po => 'Portuguese',
|
8
|
+
:gr => 'Greek',
|
9
|
+
:gb => 'British English',
|
10
|
+
:us => 'US English',
|
11
|
+
:es => 'Spanish',
|
12
|
+
:it => 'Italian',
|
13
|
+
:nl => 'Dutch',
|
14
|
+
:de => 'German',
|
15
|
+
:dk => 'Danish',
|
16
|
+
:se => 'Swedish',
|
17
|
+
:no => 'Norwegian',
|
18
|
+
:fi => 'Finnish'
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,5 +1,20 @@
|
|
1
1
|
require "httparty"
|
2
2
|
|
3
|
+
class Array
|
4
|
+
def downcase
|
5
|
+
self.map{|e| e.to_s.downcase}
|
6
|
+
end
|
7
|
+
|
8
|
+
def upcase
|
9
|
+
self.map{|e| e.to_s.upcase}
|
10
|
+
end
|
11
|
+
|
12
|
+
def select_first_in *list
|
13
|
+
list = list.flatten.compact
|
14
|
+
self.each {|e| return e if list.include?(e) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
3
18
|
module WorldFlags
|
4
19
|
module Geo
|
5
20
|
def self.ip_json
|
@@ -15,8 +30,26 @@ module WorldFlags
|
|
15
30
|
end
|
16
31
|
end
|
17
32
|
|
33
|
+
module Locale
|
34
|
+
def set_locale
|
35
|
+
I18n.locale = locales.select_first_in(valid_locales.downcase)
|
36
|
+
end
|
37
|
+
|
38
|
+
class << self
|
39
|
+
attr_writer :valid_locales
|
40
|
+
|
41
|
+
def valid_locales
|
42
|
+
@valid_locales ||= ['en', 'de', 'es', 'ru']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def locales
|
47
|
+
[params[:locale], browser_locale, ip_country_code, I18n.default_locale].downcase
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
18
51
|
module Browser
|
19
|
-
def self.browser_locale
|
52
|
+
def self.browser_locale request
|
20
53
|
return @browser_locale if @browser_locale
|
21
54
|
if lang = request.env["HTTP_ACCEPT_LANGUAGE"]
|
22
55
|
lang = lang.split(",").map { |l|
|
@@ -30,7 +63,7 @@ module WorldFlags
|
|
30
63
|
end
|
31
64
|
|
32
65
|
def browser_locale
|
33
|
-
WorldFlags::Browser.browser_locale
|
66
|
+
WorldFlags::Browser.browser_locale(request)
|
34
67
|
end
|
35
68
|
end
|
36
69
|
|
@@ -38,6 +71,7 @@ module WorldFlags
|
|
38
71
|
def self.included(base)
|
39
72
|
base.send :include, Geo
|
40
73
|
base.send :include, Browser
|
74
|
+
base.send :include, Locale
|
41
75
|
end
|
42
76
|
end
|
43
77
|
end
|
@@ -4,34 +4,57 @@ module WorldFlags
|
|
4
4
|
[16, 32, 64]
|
5
5
|
end
|
6
6
|
|
7
|
+
# define more mappings by setting WorldFlags.locale_flag_map to a Hash map
|
8
|
+
# http://en.wikipedia.org/wiki/ISO_639-1_language_matrix
|
9
|
+
def flag_code code
|
10
|
+
WorldFlags.flag_code code
|
11
|
+
end
|
12
|
+
|
7
13
|
def flags_list size = 16, &block
|
8
14
|
raise "Missing block" unless block_given?
|
9
|
-
raise "Supported sizes are only #{
|
15
|
+
raise "Supported sizes are only #{WorldFlags::ViewHelper.flag_sizes}" unless WorldFlags::ViewHelper.flag_sizes.include?(size.to_i)
|
10
16
|
content = capture(&block)
|
11
17
|
content_tag :ul, content, :class => "f#{size}"
|
12
18
|
end
|
13
19
|
alias_method :flag_list, :flags_list
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
# http://en.wikipedia.org/wiki/ISO_639-1_language_matrix
|
22
|
+
|
23
|
+
# should look up translation for each code
|
24
|
+
def flags flags_arr, options = {}
|
25
|
+
flags_arr.inject("") do |res, elem|
|
26
|
+
case elem
|
27
|
+
when Array
|
28
|
+
code = elem.first
|
29
|
+
name = elem.last
|
30
|
+
when String, Symbol
|
31
|
+
code = elem
|
32
|
+
name = WorldFlags.label(code, options)
|
33
|
+
else
|
34
|
+
raise ArgumentError, "Bad argument: #{flags_arr}, must be Hash or Array"
|
35
|
+
end
|
36
|
+
res << flag(code, name, options)
|
18
37
|
end.html_safe
|
19
38
|
end
|
20
39
|
|
21
|
-
def flags_title
|
22
|
-
|
23
|
-
|
24
|
-
|
40
|
+
def flags_title flags_arr, options = {}
|
41
|
+
flags flags_arr, options.merge(:title => true)
|
42
|
+
end
|
43
|
+
|
44
|
+
def flag code, name, options = {}
|
45
|
+
label = options[:content] ? name : ' '
|
46
|
+
extra_options = options[:title] ? {:title => name } : {}
|
47
|
+
selected = flag_selected?(code, options) ? 'selected' : ''
|
48
|
+
content_tag :li, label.html_safe, {:class => "flag #{code} #{selected}", :'data-country' => name, :'data-cc' => code}.merge(options[:html] || {}).merge(extra_options)
|
25
49
|
end
|
26
50
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
51
|
+
def flag_selected? code, options = {}
|
52
|
+
selected = options[:selected] || options[code.to_sym]
|
53
|
+
selected ||= (flag_code(I18n.locale.to_sym) == code.to_sym) if WorldFlags.auto_select?
|
30
54
|
end
|
31
55
|
|
32
|
-
def flag_title code, name,
|
33
|
-
|
34
|
-
content_tag :li, label.html_safe, :class => "flag #{code}", :title => name, :'data-cc' => code
|
56
|
+
def flag_title code, name, options = {}
|
57
|
+
flag code, name, options.merge(:title => true)
|
35
58
|
end
|
36
59
|
|
37
60
|
def use_flags size = 16
|
File without changes
|
@@ -27,30 +27,37 @@ describe WorldFlags::ViewHelper do
|
|
27
27
|
output.should == "<ul class=\"f32\"></ul>"
|
28
28
|
end
|
29
29
|
|
30
|
-
it "should list flags" do
|
30
|
+
it "should list flags using Hash arg" do
|
31
31
|
output = flags_list 32 do
|
32
32
|
flags :ar => 'Argentina', :gb => 'England'
|
33
33
|
end
|
34
|
-
output.should == "<ul class=\"f32\"><li class=\"flag ar\" data-cc=\"ar\" data-country=\"Argentina\"
|
34
|
+
output.should == "<ul class=\"f32\"><li class=\"flag ar \" data-cc=\"ar\" data-country=\"Argentina\"> </li><li class=\"flag gb \" data-cc=\"gb\" data-country=\"England\"> </li></ul>"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should list flags using Array" do
|
38
|
+
output = flags_list 32 do
|
39
|
+
flags [:ar, :gb]
|
40
|
+
end
|
41
|
+
output.should == "<ul class=\"f32\"><li class=\"flag ar \" data-cc=\"ar\" data-country=\"Argentinian Spanish\"> </li><li class=\"flag gb \" data-cc=\"gb\" data-country=\"British English\"> </li></ul>"
|
35
42
|
end
|
36
43
|
|
37
44
|
it "should list flags" do
|
38
45
|
output = flag_title :ar, 'Argentina'
|
39
|
-
output.should == "<li class=\"flag ar\" data-cc=\"ar\" title=\"Argentina\"> </li>"
|
46
|
+
output.should == "<li class=\"flag ar \" data-cc=\"ar\" data-country=\"Argentina\" title=\"Argentina\"> </li>"
|
40
47
|
end
|
41
48
|
|
42
49
|
it "should list flags" do
|
43
50
|
output = flags_list 32 do
|
44
51
|
flags_title :ar => 'Argentina'
|
45
52
|
end
|
46
|
-
output.should == "<ul class=\"f32\"><li class=\"flag ar\" data-cc=\"ar\" title=\"Argentina\"> </li></ul>"
|
53
|
+
output.should == "<ul class=\"f32\"><li class=\"flag ar \" data-cc=\"ar\" data-country=\"Argentina\" title=\"Argentina\"> </li></ul>"
|
47
54
|
end
|
48
55
|
|
49
56
|
it "should list flags combined" do
|
50
57
|
output = flags_list 32 do
|
51
58
|
[flags(:ar => 'Argentina', :gb => 'England'), flag(:br, 'Brazil')].join.html_safe
|
52
59
|
end
|
53
|
-
output.should == "<ul class=\"f32\"><li class=\"flag ar\" data-cc=\"ar\" data-country=\"Argentina\"
|
60
|
+
output.should == "<ul class=\"f32\"><li class=\"flag ar \" data-cc=\"ar\" data-country=\"Argentina\"> </li><li class=\"flag gb \" data-cc=\"gb\" data-country=\"England\"> </li><li class=\"flag br \" data-cc=\"br\" data-country=\"Brazil\"> </li></ul>"
|
54
61
|
end
|
55
62
|
end
|
56
63
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#languages {
|
2
|
+
float: right;
|
3
|
+
}
|
4
|
+
|
5
|
+
#languages ul {
|
6
|
+
list-style-type: none;
|
7
|
+
padding: 0;
|
8
|
+
margin-left: 0;
|
9
|
+
}
|
10
|
+
|
11
|
+
#languages li.flag {
|
12
|
+
float:left;
|
13
|
+
border: 1px solid none;
|
14
|
+
}
|
15
|
+
|
16
|
+
#languages li.flag.selected {
|
17
|
+
float:left;
|
18
|
+
border: 1px solid black;
|
19
|
+
}
|
20
|
+
#languages .f32 li.flag {
|
21
|
+
padding-bottom: 6px;
|
22
|
+
padding-right: 26px;
|
23
|
+
margin-right: 8px;
|
24
|
+
}
|
25
|
+
|
26
|
+
#languages .f64 li.flag {
|
27
|
+
padding-top: 12px;
|
28
|
+
padding-bottom: 24px;
|
29
|
+
padding-right: 60px;
|
30
|
+
margin-right: 8px;
|
31
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#languages {
|
2
|
+
float: right;
|
3
|
+
|
4
|
+
ul {
|
5
|
+
list-style-type: none;
|
6
|
+
padding: 0;
|
7
|
+
margin-left: 0;
|
8
|
+
}
|
9
|
+
|
10
|
+
li.flag {
|
11
|
+
float:left;
|
12
|
+
border: 1px solid none;
|
13
|
+
}
|
14
|
+
|
15
|
+
li.flag.selected {
|
16
|
+
float:left;
|
17
|
+
border: 1px solid black;
|
18
|
+
}
|
19
|
+
|
20
|
+
.f32 li.flag {
|
21
|
+
padding-bottom: 6px;
|
22
|
+
padding-right: 26px;
|
23
|
+
margin-right: 8px;
|
24
|
+
}
|
25
|
+
|
26
|
+
.f64 li.flag {
|
27
|
+
padding-top: 12px;
|
28
|
+
padding-bottom: 24px;
|
29
|
+
padding-right: 60px;
|
30
|
+
margin-right: 8px;
|
31
|
+
}
|
32
|
+
}
|
data/world-flags.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "world-flags"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kristian Mandrup"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-17"
|
13
13
|
s.description = "Use world flag icons in your Rails app"
|
14
14
|
s.email = "kmandrup@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
".rspec",
|
22
|
+
"CHANGELOG",
|
22
23
|
"Gemfile",
|
23
24
|
"Gemfile.lock",
|
24
25
|
"LICENSE.txt",
|
@@ -26,10 +27,14 @@ Gem::Specification.new do |s|
|
|
26
27
|
"Rakefile",
|
27
28
|
"VERSION",
|
28
29
|
"lib/world-flags.rb",
|
30
|
+
"lib/world_flags/countries.rb",
|
31
|
+
"lib/world_flags/languages.rb",
|
29
32
|
"lib/world_flags/locale_helper.rb",
|
30
33
|
"lib/world_flags/rails/engine.rb",
|
31
34
|
"lib/world_flags/view_helper.rb",
|
32
35
|
"spec/spec_helper.rb",
|
36
|
+
"spec/world_flags/country_spec.rb",
|
37
|
+
"spec/world_flags/language_spec.rb",
|
33
38
|
"spec/world_flags/locale_helper_spec.rb",
|
34
39
|
"spec/world_flags/view_helper_spec.rb",
|
35
40
|
"vendor/assets/images/flags/flags16.png",
|
@@ -38,6 +43,8 @@ Gem::Specification.new do |s|
|
|
38
43
|
"vendor/assets/images/flags/flags32_semi.png",
|
39
44
|
"vendor/assets/images/flags/flags64.png",
|
40
45
|
"vendor/assets/images/flags/flags64_semi.png",
|
46
|
+
"vendor/assets/stylesheets/flags/basic.css",
|
47
|
+
"vendor/assets/stylesheets/flags/basic.scss.css",
|
41
48
|
"vendor/assets/stylesheets/flags/flags16-semi.css.erb",
|
42
49
|
"vendor/assets/stylesheets/flags/flags16-semi.css.scss.erb",
|
43
50
|
"vendor/assets/stylesheets/flags/flags16.css.erb",
|
@@ -53,7 +60,7 @@ Gem::Specification.new do |s|
|
|
53
60
|
s.homepage = "http://github.com/kristianmandrup/world-flags"
|
54
61
|
s.licenses = ["MIT"]
|
55
62
|
s.require_paths = ["lib"]
|
56
|
-
s.rubygems_version = "1.8.
|
63
|
+
s.rubygems_version = "1.8.22"
|
57
64
|
s.summary = "World flags as sprites"
|
58
65
|
|
59
66
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: world-flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -117,6 +117,7 @@ extra_rdoc_files:
|
|
117
117
|
files:
|
118
118
|
- .document
|
119
119
|
- .rspec
|
120
|
+
- CHANGELOG
|
120
121
|
- Gemfile
|
121
122
|
- Gemfile.lock
|
122
123
|
- LICENSE.txt
|
@@ -124,10 +125,14 @@ files:
|
|
124
125
|
- Rakefile
|
125
126
|
- VERSION
|
126
127
|
- lib/world-flags.rb
|
128
|
+
- lib/world_flags/countries.rb
|
129
|
+
- lib/world_flags/languages.rb
|
127
130
|
- lib/world_flags/locale_helper.rb
|
128
131
|
- lib/world_flags/rails/engine.rb
|
129
132
|
- lib/world_flags/view_helper.rb
|
130
133
|
- spec/spec_helper.rb
|
134
|
+
- spec/world_flags/country_spec.rb
|
135
|
+
- spec/world_flags/language_spec.rb
|
131
136
|
- spec/world_flags/locale_helper_spec.rb
|
132
137
|
- spec/world_flags/view_helper_spec.rb
|
133
138
|
- vendor/assets/images/flags/flags16.png
|
@@ -136,6 +141,8 @@ files:
|
|
136
141
|
- vendor/assets/images/flags/flags32_semi.png
|
137
142
|
- vendor/assets/images/flags/flags64.png
|
138
143
|
- vendor/assets/images/flags/flags64_semi.png
|
144
|
+
- vendor/assets/stylesheets/flags/basic.css
|
145
|
+
- vendor/assets/stylesheets/flags/basic.scss.css
|
139
146
|
- vendor/assets/stylesheets/flags/flags16-semi.css.erb
|
140
147
|
- vendor/assets/stylesheets/flags/flags16-semi.css.scss.erb
|
141
148
|
- vendor/assets/stylesheets/flags/flags16.css.erb
|
@@ -162,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
169
|
version: '0'
|
163
170
|
segments:
|
164
171
|
- 0
|
165
|
-
hash:
|
172
|
+
hash: 1285407840837945831
|
166
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
174
|
none: false
|
168
175
|
requirements:
|
@@ -171,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
178
|
version: '0'
|
172
179
|
requirements: []
|
173
180
|
rubyforge_project:
|
174
|
-
rubygems_version: 1.8.
|
181
|
+
rubygems_version: 1.8.22
|
175
182
|
signing_key:
|
176
183
|
specification_version: 3
|
177
184
|
summary: World flags as sprites
|