font-awesome-rails-base64 4.0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,92 @@
1
+ module FontAwesome
2
+ module Rails
3
+ module IconHelper
4
+ # Creates an icon tag given an icon name and possible icon
5
+ # modifiers.
6
+ #
7
+ # Examples
8
+ #
9
+ # fa_icon "camera-retro"
10
+ # # => <i class="fa fa-camera-retro"></i>
11
+ #
12
+ # fa_icon "camera-retro", text: "Take a photo"
13
+ # # => <i class="fa fa-camera-retro"></i> Take a photo
14
+ #
15
+ # fa_icon "camera-retro 2x"
16
+ # # => <i class="fa fa-camera-retro fa-2x"></i>
17
+ # fa_icon ["camera-retro", "4x"]
18
+ # # => <i class="fa fa-camera-retro fa-4x"></i>
19
+ # fa_icon "spinner spin lg"
20
+ # # => <i class="fa fa-spinner fa-spin fa-lg">
21
+ #
22
+ # fa_icon "quote-left 4x", class: "pull-left"
23
+ # # => <i class="fa fa-quote-left fa-4x pull-left"></i>
24
+ #
25
+ # fa_icon "user", data: { id: 123 }
26
+ # # => <i class="fa fa-user" data-id="123"></i>
27
+ #
28
+ # content_tag(:li, fa_icon("check li", text: "Bulleted list item"))
29
+ # # => <li><i class="fa fa-check fa-li"></i> Bulleted list item</li>
30
+ def fa_icon(names = "flag", options = {})
31
+ classes = ["fa"]
32
+ classes.concat Private.icon_names(names)
33
+ classes.concat Array(options.delete(:class))
34
+ text = options.delete(:text)
35
+ icon = content_tag(:i, nil, options.merge(:class => classes))
36
+ Private.icon_join(icon, text)
37
+ end
38
+
39
+ # Creates an stack set of icon tags given a base icon name, a main icon
40
+ # name, and possible icon modifiers.
41
+ #
42
+ # Examples
43
+ #
44
+ # fa_stacked_icon "twitter", base: "square-o"
45
+ # # => <span class="fa-stack">
46
+ # # => <i class="fa fa-square-o fa-stack-2x"></i>
47
+ # # => <i class="fa fa-twitter fa-stack-1x"></i>
48
+ # # => </span>
49
+ #
50
+ # fa_stacked_icon "terminal inverse", base: "square", class: "pull-right", text: "Hi!"
51
+ # # => <span class="fa-stack pull-right">
52
+ # # => <i class="fa fa-square fa-stack-2x"></i>
53
+ # # => <i class="fa fa-terminal fa-inverse fa-stack-1x"></i>
54
+ # # => </span> Hi!
55
+ #
56
+ # fa_stacked_icon "camera", base: "ban-circle", reverse: true
57
+ # # => <span class="fa-stack">
58
+ # # => <i class="fa fa-camera fa-stack-1x"></i>
59
+ # # => <i class="fa fa-ban-circle fa-stack-2x"></i>
60
+ # # => </span>
61
+ def fa_stacked_icon(names = "flag", options = {})
62
+ classes = Private.icon_names("stack").concat(Array(options.delete(:class)))
63
+ base_names = Private.array_value(options.delete(:base) || "square-o").push("stack-2x")
64
+ names = Private.array_value(names).push("stack-1x")
65
+ base = fa_icon(base_names, options.delete(:base_options) || {})
66
+ icon = fa_icon(names, options.delete(:icon_options) || {})
67
+ icons = [base, icon]
68
+ icons.reverse! if options.delete(:reverse)
69
+ text = options.delete(:text)
70
+ stacked_icon = content_tag(:span, safe_join(icons), options.merge(:class => classes))
71
+ Private.icon_join(stacked_icon, text)
72
+ end
73
+
74
+ module Private
75
+ extend ActionView::Helpers::OutputSafetyHelper
76
+
77
+ def self.icon_join(icon, text)
78
+ return icon if text.blank?
79
+ safe_join([icon, ERB::Util.html_escape(text)], " ")
80
+ end
81
+
82
+ def self.icon_names(names = [])
83
+ array_value(names).map { |n| "fa-#{n}" }
84
+ end
85
+
86
+ def self.array_value(value = [])
87
+ value.is_a?(Array) ? value : value.to_s.split(/\s+/)
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,2 @@
1
+ require "font-awesome-rails/version"
2
+ require "font-awesome-rails/engine" if defined?(::Rails)
@@ -0,0 +1,6 @@
1
+ module FontAwesome
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module FontAwesome
2
+ module Rails
3
+ VERSION = "4.0.3.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ @import font-awesome
@@ -0,0 +1 @@
1
+ @import "font-awesome";
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require font-awesome
3
+ */
@@ -0,0 +1,2 @@
1
+ class PagesController < ActionController::Base
2
+ end
@@ -0,0 +1,3 @@
1
+ <%= fa_icon "flag" %>
2
+
3
+ <%= fa_stacked_icon "twitter", :base => "check-empty" %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # require "rails/all"
4
+ require "sprockets/railtie"
5
+
6
+ Bundler.require(:default, :development)
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ config.encoding = "utf-8"
11
+ config.assets.enabled = true
12
+ config.assets.version = '1.0'
13
+
14
+ # replacement for environments/*.rb
15
+ config.active_support.deprecation = :stderr
16
+ config.eager_load = false
17
+ end
18
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ if File.exist?(gemfile)
5
+ ENV['BUNDLE_GEMFILE'] = gemfile
6
+ require 'bundler'
7
+ Bundler.setup
8
+ end
9
+
10
+ $:.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'
8
+ Dummy::Application.config.secret_key_base = 'deadbeef' if Dummy::Application.config.respond_to?(:secret_key_base)
@@ -0,0 +1,3 @@
1
+ Dummy::Application.routes.draw do
2
+ get "/icons", :to => "pages#icons"
3
+ end
@@ -0,0 +1,65 @@
1
+ require 'test_helper'
2
+
3
+ class FontAwesomeRailsTest < ActionDispatch::IntegrationTest
4
+ teardown { clean_sprockets_cache }
5
+
6
+ test "engine is loaded" do
7
+ assert_equal ::Rails::Engine, FontAwesome::Rails::Engine.superclass
8
+ end
9
+
10
+ test "fonts are served" do
11
+ get "/assets/fontawesome-webfont.eot"
12
+ assert_response :success
13
+ get "/assets/fontawesome-webfont.ttf"
14
+ assert_response :success
15
+ get "/assets/fontawesome-webfont.woff"
16
+ assert_response :success
17
+ end
18
+
19
+ test "stylesheets are served" do
20
+ get "/assets/font-awesome.css"
21
+ assert_font_awesome(response)
22
+ end
23
+
24
+ test "stylesheets contain asset pipeline references to fonts" do
25
+ get "/assets/font-awesome.css"
26
+ assert_match "/assets/fontawesome-webfont.eot", response.body
27
+ assert_match "/assets/fontawesome-webfont.eot?#iefix", response.body
28
+ assert_match "/assets/fontawesome-webfont.woff", response.body
29
+ assert_match "/assets/fontawesome-webfont.ttf", response.body
30
+ assert_match "/assets/fontawesome-webfont.svg#fontawesomeregular", response.body
31
+ end
32
+
33
+ test "stylesheet is available in a css sprockets require" do
34
+ get "/assets/sprockets-require.css"
35
+ assert_font_awesome(response)
36
+ end
37
+
38
+ test "stylesheet is available in a sass import" do
39
+ get "/assets/sass-import.css"
40
+ assert_font_awesome(response)
41
+ end
42
+
43
+ test "stylesheet is available in a scss import" do
44
+ get "/assets/scss-import.css"
45
+ assert_font_awesome(response)
46
+ end
47
+
48
+ test "helpers should be available in the view" do
49
+ get "/icons"
50
+ assert_response :success
51
+ assert_select "i.fa.fa-flag"
52
+ assert_select "span.fa-stack"
53
+ end
54
+
55
+ private
56
+
57
+ def clean_sprockets_cache
58
+ FileUtils.rm_rf File.expand_path("../dummy/tmp", __FILE__)
59
+ end
60
+
61
+ def assert_font_awesome(response)
62
+ assert_response :success
63
+ assert_match(/font-family:\s*'FontAwesome';/, response.body)
64
+ end
65
+ end
@@ -0,0 +1,113 @@
1
+ require 'test_helper'
2
+
3
+ class FontAwesome::Rails::IconHelperTest < ActionView::TestCase
4
+
5
+ test "#fa_icon with no args should render a flag icon" do
6
+ assert_icon i("fa fa-flag")
7
+ end
8
+
9
+ test "#fa_icon should render different individual icons" do
10
+ assert_icon i("fa fa-flag"), "flag"
11
+ assert_icon i("fa fa-camera-retro"), "camera-retro"
12
+ assert_icon i("fa fa-cog"), "cog"
13
+ assert_icon i("fa fa-github"), "github"
14
+ end
15
+
16
+ test "#fa_icon should render icons with multiple modifiers" do
17
+ assert_icon i("fa fa-pencil fa-fixed-width"), "pencil fixed-width"
18
+ assert_icon i("fa fa-flag fa-4x"), "flag 4x"
19
+ assert_icon i("fa fa-refresh fa-2x fa-spin"), "refresh 2x spin"
20
+ end
21
+
22
+ test "#fa_icon should render icons with array modifiers" do
23
+ assert_icon i("fa fa-flag"), ["flag"]
24
+ assert_icon i("fa fa-check fa-li"), ["check", "li"]
25
+ assert_icon i("fa fa-flag fa-4x"), ["flag", "4x"]
26
+ assert_icon i("fa fa-refresh fa-2x fa-spin"), ["refresh", "2x", "spin"]
27
+ end
28
+
29
+ test "#fa_icon should incorporate additional class styles" do
30
+ assert_icon i("fa fa-flag pull-right"), "flag", :class => "pull-right"
31
+ assert_icon i("fa fa-flag fa-2x pull-right"), ["flag", "2x"], :class => ["pull-right"]
32
+ assert_icon i("fa fa-check fa-li pull-right special"), "check li", :class => "pull-right special"
33
+ assert_icon i("fa fa-check pull-right special"), "check", :class => ["pull-right", "special"]
34
+ end
35
+
36
+ test "#fa_icon should incorporate a text suffix" do
37
+ assert_icon "#{i("fa fa-camera-retro")} Take a photo", "camera-retro", :text => "Take a photo"
38
+ end
39
+
40
+ test "#fa_icon should html escape text" do
41
+ assert_icon "#{i("fa fa-camera-retro")} &lt;script&gt;&lt;/script&gt;", "camera-retro", :text => "<script></script>"
42
+ end
43
+
44
+ test "#fa_icon should not html escape safe text" do
45
+ assert_icon "#{i("fa fa-camera-retro")} <script></script>", "camera-retro", :text => "<script></script>".html_safe
46
+ end
47
+
48
+ test "#fa_icon should pull it all together" do
49
+ assert_icon "#{i("fa fa-camera-retro pull-right")} Take a photo", "camera-retro", :text => "Take a photo", :class => "pull-right"
50
+ end
51
+
52
+ test "#fa_icon should pass all other options through" do
53
+ assert_icon %(<i class="fa fa-user" data-id="123"></i>), "user", :data => { :id => 123 }
54
+ end
55
+
56
+ test "#fa_stacked_icon with no args should render a flag icon" do
57
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-flag fa-stack-1x")}</span>)
58
+ assert_stacked_icon expected
59
+ end
60
+
61
+ test "#fa_stacked_icon should render a stacked icon" do
62
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
63
+ assert_stacked_icon expected, "twitter", :base => "square-o"
64
+ expected = %(<span class="fa-stack">#{i("fa fa-square fa-stack-2x")}#{i("fa fa-terminal fa-inverse fa-stack-1x")}</span>)
65
+ assert_stacked_icon expected, ["terminal", "inverse"], :base => ["square"]
66
+ end
67
+
68
+ test "#fa_stacked_icon should incorporate additional class styles" do
69
+ expected = %(<span class="fa-stack pull-right">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span>)
70
+ assert_stacked_icon expected, "twitter", :base => "square-o", :class => "pull-right"
71
+ end
72
+
73
+ test "#fa_stacked_icon should reverse the stack" do
74
+ expected = %(<span class="fa-stack">#{i("fa fa-facebook fa-stack-1x")}#{i("fa fa-ban fa-stack-2x")}</span>)
75
+ assert_stacked_icon expected, "facebook", :base => "ban", :reverse => "true"
76
+ end
77
+
78
+ test "#fa_stacked_icon should html escape text" do
79
+ expected = %(<span class="fa-stack">#{i("fa fa-check-empty fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> &lt;script&gt;)
80
+ assert_stacked_icon expected, "twitter", :base => "check-empty", :text => "<script>"
81
+ end
82
+
83
+ test "#fa_stacked_icon should not html escape safe text" do
84
+ expected = %(<span class="fa-stack">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-twitter fa-stack-1x")}</span> <script>)
85
+ assert_stacked_icon expected, "twitter", :base => "square-o", :text => "<script>".html_safe
86
+ end
87
+
88
+ test "#fa_stacked_icon should accept options for base and main icons" do
89
+ expected = %(<span class="fa-stack">#{i("fa fa-camera fa-stack-1x text-info")}#{i("fa fa-ban fa-stack-2x text-error")}</span>)
90
+ assert_stacked_icon expected, "camera", :base => "ban", :reverse => true, :base_options => { :class => "text-error" }, :icon_options => { :class => "text-info" }
91
+ end
92
+
93
+ test "#fa_stacked_icon should pass all other options through" do
94
+ expected = %(<span class="fa-stack" data-id="123">#{i("fa fa-square-o fa-stack-2x")}#{i("fa fa-user fa-stack-1x")}</span>)
95
+ assert_stacked_icon expected, "user", :base => "square-o", :data => { :id => 123 }
96
+ end
97
+
98
+ private
99
+
100
+ def assert_icon(expected, *args)
101
+ message = "`fa_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
102
+ assert_dom_equal expected, fa_icon(*args), message
103
+ end
104
+
105
+ def assert_stacked_icon(expected, *args)
106
+ message = "`fa_stacked_icon(#{args.inspect[1...-1]})` should return `#{expected}`"
107
+ assert_dom_equal expected, fa_stacked_icon(*args), message
108
+ end
109
+
110
+ def i(classes)
111
+ %(<i class="#{classes}"></i>)
112
+ end
113
+ end
@@ -0,0 +1,7 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
metadata ADDED
@@ -0,0 +1,150 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: font-awesome-rails-base64
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - jay_rod_1859
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.2'
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: activesupport
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: tzinfo
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: sass-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: A fork of the original 'font-awesome-rails' gem to include a base64 encoded
76
+ css file of all of the fonts (primarily for the purposes of pdf generation).
77
+ email:
78
+ - jcsmith1859@gmail.com
79
+ executables: []
80
+ extensions: []
81
+ extra_rdoc_files: []
82
+ files:
83
+ - app/assets/fonts/fontawesome-webfont.eot
84
+ - app/assets/fonts/fontawesome-webfont.svg
85
+ - app/assets/fonts/fontawesome-webfont.ttf
86
+ - app/assets/fonts/fontawesome-webfont.woff
87
+ - app/assets/fonts/FontAwesome.otf
88
+ - app/assets/stylesheets/font-awesome-base64.css
89
+ - app/assets/stylesheets/font-awesome.css.erb
90
+ - app/helpers/font_awesome/rails/icon_helper.rb
91
+ - lib/font-awesome-rails/engine.rb
92
+ - lib/font-awesome-rails/version.rb
93
+ - lib/font-awesome-rails.rb
94
+ - LICENSE
95
+ - Rakefile
96
+ - README.md
97
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
98
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
99
+ - test/dummy/app/assets/stylesheets/sprockets-require.css
100
+ - test/dummy/app/controllers/pages_controller.rb
101
+ - test/dummy/app/views/pages/icons.html.erb
102
+ - test/dummy/config/application.rb
103
+ - test/dummy/config/boot.rb
104
+ - test/dummy/config/environment.rb
105
+ - test/dummy/config/initializers/secret_token.rb
106
+ - test/dummy/config/routes.rb
107
+ - test/dummy/config.ru
108
+ - test/font_awesome_rails_test.rb
109
+ - test/icon_helper_test.rb
110
+ - test/test_helper.rb
111
+ homepage: https://github.com/Outcome-Engenuity/font-awesome-rails
112
+ licenses:
113
+ - MIT
114
+ - SIL Open Font License
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.1.10
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: an asset gemification of the font-awesome icon font library
136
+ test_files:
137
+ - test/dummy/app/assets/stylesheets/sass-import.css.sass
138
+ - test/dummy/app/assets/stylesheets/scss-import.css.scss
139
+ - test/dummy/app/assets/stylesheets/sprockets-require.css
140
+ - test/dummy/app/controllers/pages_controller.rb
141
+ - test/dummy/app/views/pages/icons.html.erb
142
+ - test/dummy/config/application.rb
143
+ - test/dummy/config/boot.rb
144
+ - test/dummy/config/environment.rb
145
+ - test/dummy/config/initializers/secret_token.rb
146
+ - test/dummy/config/routes.rb
147
+ - test/dummy/config.ru
148
+ - test/font_awesome_rails_test.rb
149
+ - test/icon_helper_test.rb
150
+ - test/test_helper.rb