less-rails-fontawesome 0.1.0 → 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/README.md +24 -10
- data/application_helper.rb +30 -26
- data/lib/less-rails-fontawesome/version.rb +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -8,38 +8,52 @@ With LESS and fonts from [Font Awesome](http://fortawesome.github.com/Font-Aweso
|
|
8
8
|
|
9
9
|
Add the gem to your *assets* group in the *Gemfile*:
|
10
10
|
|
11
|
+
```ruby
|
11
12
|
gem 'less-rails-fontawesome', :group => :assets
|
13
|
+
```
|
12
14
|
|
13
15
|
Then in your *app/assets/stylesheets/application.css.less*:
|
14
16
|
|
17
|
+
```css
|
15
18
|
@import 'fontawesome';
|
19
|
+
```
|
16
20
|
|
17
21
|
You can also use it with the [less-rails-bootstrap](https://github.com/metaskills/less-rails-bootstrap) gem.
|
18
22
|
Just import *fontawesome* right after *twitter/bootstrap*:
|
19
23
|
|
24
|
+
```css
|
20
25
|
@import 'twitter/bootstrap';
|
21
26
|
@import 'fontawesome';
|
27
|
+
```
|
28
|
+
|
29
|
+
([simple demo](http://sharp-ocean-6085.herokuapp.com/))
|
22
30
|
|
23
31
|
|
24
32
|
## Helper methods
|
25
33
|
|
26
|
-
To place Font Awesome icon add
|
27
|
-
attribute to
|
34
|
+
To place Font Awesome icon add *i* element and set its *class*
|
35
|
+
attribute to a icon name, for example:
|
28
36
|
|
37
|
+
```html
|
29
38
|
<i class="icon-trash"></i>
|
39
|
+
```
|
40
|
+
|
41
|
+
To ease placing icons in Rails *link_to* helper use
|
42
|
+
the [ilink_to](https://github.com/wbzyl/less-rails-fontawesome/blob/master/application_helper.rb) helper method.
|
30
43
|
|
31
|
-
|
32
|
-
[application_helper.rb](https://github.com/wbzyl/less-rails-fontawesome/blob/master/application_helper.rb)
|
33
|
-
a few helper methods.
|
34
|
-
For example, to place *icon-upload-alt* icon next to *Edit* button write something like:
|
44
|
+
For example, to place the *icon-upload-alt* icon next to *Edit* write something like:
|
35
45
|
|
36
|
-
|
46
|
+
```rhtml
|
47
|
+
<%= ilink_to "upload-alt", "Edit", edit_post_path(post), class: 'btn btn-mini' %>
|
48
|
+
```
|
37
49
|
|
38
|
-
to place *icon-trash* next to *Destroy* button write:
|
50
|
+
or to place *icon-trash* next to text *Destroy* button write:
|
39
51
|
|
40
|
-
|
52
|
+
```rhtml
|
53
|
+
<%= ilink_to "trash", "Destroy", post, confirm: 'Are you sure?', method: :delete, class: 'btn btn-mini btn-danger'%>
|
54
|
+
```
|
41
55
|
|
42
|
-
|
56
|
+
(precede the link text with the icon name stripped off *icon-* prefix)
|
43
57
|
|
44
58
|
|
45
59
|
## License
|
data/application_helper.rb
CHANGED
@@ -2,13 +2,15 @@ module ApplicationHelper
|
|
2
2
|
|
3
3
|
def ilink_to(*args, &block)
|
4
4
|
if block_given?
|
5
|
-
|
6
|
-
|
7
|
-
ilink_to(capture(&block), options, html_options)
|
8
|
-
else
|
9
|
-
icon, name = args[0].strip.split(' ', 2)
|
10
|
-
options = args[1] || {}
|
5
|
+
icon = args[0]
|
6
|
+
options = args[1] || {}
|
11
7
|
html_options = args[2]
|
8
|
+
ilink_to(icon, capture(&block), options, html_options)
|
9
|
+
else
|
10
|
+
icon = args[0]
|
11
|
+
name = args[1]
|
12
|
+
options = args[2] || {}
|
13
|
+
html_options = args[3]
|
12
14
|
|
13
15
|
html_options = convert_options_to_data_attributes(options, html_options)
|
14
16
|
url = url_for(options)
|
@@ -17,28 +19,30 @@ module ApplicationHelper
|
|
17
19
|
tag_options = tag_options(html_options)
|
18
20
|
|
19
21
|
href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href
|
20
|
-
"<a #{href_attr}#{tag_options}><i class=\"icon-#{icon}\"></i> #{ERB::Util.html_escape(name
|
22
|
+
"<a #{href_attr}#{tag_options}><i class=\"icon-#{icon}\"></i> #{ERB::Util.html_escape(name || url)}</a>".html_safe
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
# TODO:
|
27
|
+
|
28
|
+
# def ilink_to_unless
|
29
|
+
# if condition
|
30
|
+
# if block_given?
|
31
|
+
# block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
|
32
|
+
# else
|
33
|
+
# name
|
34
|
+
# end
|
35
|
+
# else
|
36
|
+
# ilink_to(name, options, html_options)
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
|
40
|
+
# def ilink_to_if(condition, name, options = {}, html_options = {}, &block)
|
41
|
+
# ilink_to_unless !condition, name, options, html_options, &block
|
42
|
+
# end
|
43
|
+
|
44
|
+
# def ilink_to_unless_current(name, options = {}, html_options = {}, &block)
|
45
|
+
# ilink_to_unless current_page?(options), name, options, html_options, &block
|
46
|
+
# end
|
43
47
|
|
44
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: less-rails-fontawesome
|
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,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: &
|
16
|
+
requirement: &6127880 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *6127880
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: less-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &6126840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 2.1.7
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *6126840
|
36
36
|
description: Font Awesome, LESS version, with assets pipeline, for Rails 3.1+ Asset
|
37
37
|
Pipeline
|
38
38
|
email:
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project: less-rails-fontawesome
|
79
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.16
|
80
80
|
signing_key:
|
81
81
|
specification_version: 3
|
82
82
|
summary: Font Awesome in LESS for Rails 3.1+ Asset Pipeline
|