world-flags 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +88 -6
- data/VERSION +1 -1
- data/lib/world-flags.rb +1 -1
- data/lib/{rails_plugin → world_flags/rails_plugin}/engine.rb +1 -0
- data/lib/world_flags/world_flags_helper.rb +14 -2
- data/spec/world-flags_spec.rb +18 -0
- data/vendor/assets/stylesheets/flags/{flags16.css → flags16.css.erb} +1 -1
- data/vendor/assets/stylesheets/flags/{flags16.scss → flags16.css.scss.erb} +1 -1
- data/vendor/assets/stylesheets/flags/{flags32.css → flags32.css.erb} +1 -1
- data/vendor/assets/stylesheets/flags/{flags32.scss → flags32.css.scss.erb} +1 -1
- data/world-flags.gemspec +6 -6
- metadata +17 -17
data/README.textile
CHANGED
@@ -4,11 +4,15 @@ Includes css files for size 16 and 32 pixels and have all the worlds' flags.
|
|
4
4
|
|
5
5
|
h2. Configuration
|
6
6
|
|
7
|
-
In you asset application
|
7
|
+
In you asset application.css manifest file:
|
8
8
|
|
9
|
-
|
9
|
+
*/
|
10
|
+
*= require_self
|
11
|
+
*= require_tree .
|
12
|
+
*= require flags/flags32
|
13
|
+
*/
|
10
14
|
|
11
|
-
h2.
|
15
|
+
h2. Alternative config
|
12
16
|
|
13
17
|
Note that the ruby examples uses HAML syntax
|
14
18
|
|
@@ -20,6 +24,12 @@ or using a helper
|
|
20
24
|
|
21
25
|
= use_flags(16)
|
22
26
|
|
27
|
+
Alternatively for the 32 width flags
|
28
|
+
|
29
|
+
= use_flags 32
|
30
|
+
|
31
|
+
h2. Rendering
|
32
|
+
|
23
33
|
Flags will be rendered in HTML as:
|
24
34
|
|
25
35
|
<pre>
|
@@ -33,14 +43,86 @@ Flags will be rendered in HTML as:
|
|
33
43
|
|
34
44
|
The countries corresponding to the codes can be found at "http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2":http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
35
45
|
|
46
|
+
h2. Use
|
47
|
+
|
36
48
|
You can also use built in helper methods:
|
37
49
|
|
38
|
-
=
|
50
|
+
= flag_list 16 do
|
39
51
|
= flags :ar => 'Argentina', :en => 'England'
|
40
52
|
|
41
53
|
Alternatively
|
42
54
|
|
43
55
|
= flags_list 32 do
|
44
|
-
= flag
|
56
|
+
= flag(:ar, 'Argentina') + flag(:en, 'England')
|
57
|
+
|
58
|
+
For use with tooltips (see example below):
|
59
|
+
|
60
|
+
= flags_list 32 do
|
61
|
+
= flags_title(:ar => 'Argentina', :br => 'Brazil') + flag_title(:en, 'England')
|
62
|
+
|
63
|
+
The flag_title will render the following list item:
|
64
|
+
|
65
|
+
<li class="flag ar" title="Argentina"> </li>
|
66
|
+
|
67
|
+
The is needed in order for the background (flag icon) to have something to be displayed against.
|
68
|
+
|
69
|
+
h2. Nice effects
|
70
|
+
|
71
|
+
CSS config:
|
72
|
+
|
73
|
+
ul.f32 {
|
74
|
+
list-style-type: none;
|
75
|
+
padding: 0;
|
76
|
+
margin-left: 0;
|
77
|
+
|
78
|
+
li.flag {
|
79
|
+
float:left;
|
80
|
+
padding-bottom: 10px;
|
81
|
+
padding-right: 32px;
|
82
|
+
cursor: pointer;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
#languages {
|
87
|
+
float: right;
|
88
|
+
}
|
89
|
+
|
90
|
+
p.clear {
|
91
|
+
clear:both;
|
92
|
+
}
|
93
|
+
|
94
|
+
.tooltip {
|
95
|
+
display:none;
|
96
|
+
background: white;
|
97
|
+
border: 1px solid black;
|
98
|
+
font-size:14px;
|
99
|
+
font-weight: bold;
|
100
|
+
text-align: center;
|
101
|
+
height:16px;
|
102
|
+
width:120px;
|
103
|
+
padding:10px;
|
104
|
+
color: black;
|
105
|
+
}
|
106
|
+
|
107
|
+
Tooltip script:
|
108
|
+
|
109
|
+
http://jquerytools.org/demos/tooltip/index.html
|
110
|
+
|
111
|
+
$("li.flag[title]").tooltip()
|
112
|
+
|
113
|
+
Layout file:
|
114
|
+
|
115
|
+
%body
|
116
|
+
.main
|
117
|
+
= link_to "Sign un", new_user_session_path
|
118
|
+
= link_to "Sign up", new_user_registration_path
|
119
|
+
|
120
|
+
#languages
|
121
|
+
%ul.f32
|
122
|
+
%li.flag.ar{:title => 'Argentina'}
|
123
|
+
|
124
|
+
%li.flag.en{:title => 'England'}
|
125
|
+
|
126
|
+
%p.clear
|
127
|
+
= yield
|
45
128
|
|
46
|
-
See "the cheese wiki":http://www.cheesewiki.com/ for an example
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/world-flags.rb
CHANGED
@@ -6,8 +6,10 @@ module WorldFlagsHelper
|
|
6
6
|
def flags_list size = 16, &block
|
7
7
|
raise "Missing block" unless block_given?
|
8
8
|
raise "Supported sizes are only #{WorldFlagsHelper.flag_sizes}" unless WorldFlagsHelper.flag_sizes.include?(size.to_i)
|
9
|
-
|
9
|
+
content = capture(&block)
|
10
|
+
content_tag :ul, content, :class => "f#{size}"
|
10
11
|
end
|
12
|
+
alias_method :flag_list, :flags_list
|
11
13
|
|
12
14
|
def flags flags_hash
|
13
15
|
flags_hash.inject("") do |res, element|
|
@@ -15,11 +17,21 @@ module WorldFlagsHelper
|
|
15
17
|
end.html_safe
|
16
18
|
end
|
17
19
|
|
20
|
+
def flags_title flags_hash
|
21
|
+
flags_hash.inject("") do |res, element|
|
22
|
+
res << flag_title(element.first, element.last)
|
23
|
+
end.html_safe
|
24
|
+
end
|
25
|
+
|
18
26
|
def flag code, name
|
19
27
|
content_tag :li, name.html_safe, :class => "flag #{code}"
|
20
28
|
end
|
21
29
|
|
30
|
+
def flag_title code, name
|
31
|
+
content_tag :li, ' '.html_safe, :class => "flag #{code}", :title => name
|
32
|
+
end
|
33
|
+
|
22
34
|
def use_flags size = 16
|
23
|
-
stylesheet_link_tag "flags#{size}"
|
35
|
+
stylesheet_link_tag "flags/flags#{size}"
|
24
36
|
end
|
25
37
|
end
|
data/spec/world-flags_spec.rb
CHANGED
@@ -10,6 +10,12 @@ describe WorldFlagsHelper do
|
|
10
10
|
output.should == "<ul class=\"f16\"></ul>"
|
11
11
|
end
|
12
12
|
|
13
|
+
it "should work with alias :flag_list" do
|
14
|
+
output = flag_list do
|
15
|
+
end
|
16
|
+
output.should == "<ul class=\"f16\"></ul>"
|
17
|
+
end
|
18
|
+
|
13
19
|
it "should set size to 16 or 32" do
|
14
20
|
lambda do flags_list(8) { }
|
15
21
|
end.should raise_error
|
@@ -28,6 +34,18 @@ describe WorldFlagsHelper do
|
|
28
34
|
output.should == "<ul class=\"f32\"><li class=\"flag ar\">Argentina</li><li class=\"flag en\">England</li></ul>"
|
29
35
|
end
|
30
36
|
|
37
|
+
it "should list flags" do
|
38
|
+
output = flag_title :ar, 'Argentina'
|
39
|
+
output.should == "<li class=\"flag ar\" title=\"Argentina\"> </li>"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should list flags" do
|
43
|
+
output = flags_list 32 do
|
44
|
+
flags_title :ar => 'Argentina'
|
45
|
+
end
|
46
|
+
output.should == "<ul class=\"f32\"><li class=\"flag ar\" title=\"Argentina\"> </li></ul>"
|
47
|
+
end
|
48
|
+
|
31
49
|
it "should list flags combined" do
|
32
50
|
output = flags_list 32 do
|
33
51
|
[flags(:ar => 'Argentina', :en => 'England'), flag(:br, 'Brazil')].join.html_safe
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.f16 .flag{background:url(
|
1
|
+
.f16 .flag{background:url(<%= asset_path 'flags/flags16.png' %>) no-repeat;}
|
2
2
|
.f16 ._African_Union(OAS){background-position:0 -0px;}
|
3
3
|
.f16 ._Arab_League{background-position:0 -16px;}
|
4
4
|
.f16 ._ASEAN{background-position:0 -32px;}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.f32 .flag{background:url(
|
1
|
+
.f32 .flag{background:url(<%= asset_path 'flags/flags32.png' %>) no-repeat;}
|
2
2
|
.f32 ._African_Union(OAS){background-position:0 -0px;}
|
3
3
|
.f32 ._Arab_League{background-position:0 -32px;}
|
4
4
|
.f32 ._ASEAN{background-position:0 -64px;}
|
data/world-flags.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "world-flags"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
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"]
|
@@ -25,17 +25,17 @@ Gem::Specification.new do |s|
|
|
25
25
|
"README.textile",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
|
-
"lib/rails_plugin/engine.rb",
|
29
28
|
"lib/world-flags.rb",
|
29
|
+
"lib/world_flags/rails_plugin/engine.rb",
|
30
30
|
"lib/world_flags/world_flags_helper.rb",
|
31
31
|
"spec/spec_helper.rb",
|
32
32
|
"spec/world-flags_spec.rb",
|
33
33
|
"vendor/assets/images/flags/flags16.png",
|
34
34
|
"vendor/assets/images/flags/flags32.png",
|
35
|
-
"vendor/assets/stylesheets/flags/flags16.css",
|
36
|
-
"vendor/assets/stylesheets/flags/flags16.scss",
|
37
|
-
"vendor/assets/stylesheets/flags/flags32.css",
|
38
|
-
"vendor/assets/stylesheets/flags/flags32.scss",
|
35
|
+
"vendor/assets/stylesheets/flags/flags16.css.erb",
|
36
|
+
"vendor/assets/stylesheets/flags/flags16.css.scss.erb",
|
37
|
+
"vendor/assets/stylesheets/flags/flags32.css.erb",
|
38
|
+
"vendor/assets/stylesheets/flags/flags32.css.scss.erb",
|
39
39
|
"world-flags.gemspec"
|
40
40
|
]
|
41
41
|
s.homepage = "http://github.com/kristianmandrup/world-flags"
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70254344812800 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.8.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70254344812800
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
requirement: &
|
27
|
+
requirement: &70254344823820 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.12'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70254344823820
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70254344822400 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70254344822400
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &70254344820480 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.8.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70254344820480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &70254344819120 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0.5'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70254344819120
|
69
69
|
description: Use world flag icons in your Rails app
|
70
70
|
email: kmandrup@gmail.com
|
71
71
|
executables: []
|
@@ -82,17 +82,17 @@ files:
|
|
82
82
|
- README.textile
|
83
83
|
- Rakefile
|
84
84
|
- VERSION
|
85
|
-
- lib/rails_plugin/engine.rb
|
86
85
|
- lib/world-flags.rb
|
86
|
+
- lib/world_flags/rails_plugin/engine.rb
|
87
87
|
- lib/world_flags/world_flags_helper.rb
|
88
88
|
- spec/spec_helper.rb
|
89
89
|
- spec/world-flags_spec.rb
|
90
90
|
- vendor/assets/images/flags/flags16.png
|
91
91
|
- vendor/assets/images/flags/flags32.png
|
92
|
-
- vendor/assets/stylesheets/flags/flags16.css
|
93
|
-
- vendor/assets/stylesheets/flags/flags16.scss
|
94
|
-
- vendor/assets/stylesheets/flags/flags32.css
|
95
|
-
- vendor/assets/stylesheets/flags/flags32.scss
|
92
|
+
- vendor/assets/stylesheets/flags/flags16.css.erb
|
93
|
+
- vendor/assets/stylesheets/flags/flags16.css.scss.erb
|
94
|
+
- vendor/assets/stylesheets/flags/flags32.css.erb
|
95
|
+
- vendor/assets/stylesheets/flags/flags32.css.scss.erb
|
96
96
|
- world-flags.gemspec
|
97
97
|
homepage: http://github.com/kristianmandrup/world-flags
|
98
98
|
licenses:
|
@@ -109,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
segments:
|
111
111
|
- 0
|
112
|
-
hash:
|
112
|
+
hash: 1179484573373061656
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
115
|
requirements:
|