helper_methods 0.0.1 → 0.0.2
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 +48 -6
- data/helper_methods.gemspec +1 -0
- data/lib/helper_methods.rb +17 -0
- data/lib/helper_methods/version.rb +1 -1
- metadata +19 -3
data/README.md
CHANGED
@@ -18,14 +18,56 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
22
|
-
<%= error_messages_for %>
|
21
|
+
Included helpers:
|
23
22
|
|
24
|
-
|
25
|
-
|
23
|
+
error_messages_for @resource
|
24
|
+
flash_messages
|
25
|
+
mobile_device?
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
In your forms use:
|
28
|
+
|
29
|
+
<%= error_messages_for @resource %>
|
30
|
+
|
31
|
+
And it will return:
|
32
|
+
|
33
|
+
<ul class="alert alert-error">
|
34
|
+
<li>Error description</li>
|
35
|
+
</ul>
|
36
|
+
|
37
|
+
Optionaly, you can pass a css class for ul element:
|
38
|
+
|
39
|
+
<%= error_messages_for @resource, 'my_css_class' %>
|
40
|
+
|
41
|
+
And it will return:
|
42
|
+
|
43
|
+
<ul class="my_css_class">
|
44
|
+
<li>Error description</li>
|
45
|
+
</ul>
|
46
|
+
|
47
|
+
For using flash messages, in your layout file, do:
|
48
|
+
|
49
|
+
<%= flash_messages %>
|
50
|
+
|
51
|
+
And in your controller, use:
|
52
|
+
|
53
|
+
flash[:success] = "Your success message"
|
54
|
+
flash[:notice] = "Your alert message"
|
55
|
+
flash[:error] = "Your error message"
|
56
|
+
flash[:info] = "Your info message"
|
57
|
+
|
58
|
+
This will return
|
59
|
+
|
60
|
+
<p class="alert alert-success">Your success message</p>
|
61
|
+
<p class="alert alert-notice">Your alert message</p>
|
62
|
+
<p class="alert alert-error">Your error message</p>
|
63
|
+
<p class="alert alert-info">Your info message</p>
|
64
|
+
|
65
|
+
Made for twitter-bootstrap.
|
66
|
+
|
67
|
+
|
68
|
+
And this helps you to manage mobile views
|
69
|
+
|
70
|
+
mobile_device?
|
29
71
|
|
30
72
|
## Contributing
|
31
73
|
|
data/helper_methods.gemspec
CHANGED
data/lib/helper_methods.rb
CHANGED
@@ -22,6 +22,23 @@ module HelperMethods
|
|
22
22
|
request.user_agent =~ /Mobile|webOS/
|
23
23
|
end
|
24
24
|
|
25
|
+
def youtube(video)
|
26
|
+
"<iframe width='580' height='420' src='http://www.youtube.com/embed/#{video}' frameborder='0' allowfullscreen></iframe>".html_safe
|
27
|
+
end
|
28
|
+
|
29
|
+
def youtube_link(video)
|
30
|
+
link_to "www.youtube.com/watch?v=#{video}", "http://www.youtube.com/watch?v=#{video}", class: 'various fancybox-media'
|
31
|
+
end
|
32
|
+
|
33
|
+
def textilize(text)
|
34
|
+
RedCloth.new(text).to_html.html_safe
|
35
|
+
end
|
36
|
+
|
37
|
+
def icon(icon, text="", direction="l")
|
38
|
+
return "<i class='icon-#{icon}'></i> #{text}".html_safe if direction == 'l'
|
39
|
+
return "#{text} <i class='icon-#{icon}'></i>".html_safe if direction == 'r'
|
40
|
+
end
|
41
|
+
|
25
42
|
end
|
26
43
|
|
27
44
|
ActionView::Base.send :include, HelperMethods
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helper_methods
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-09-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: RedCloth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
description: Helper methods that helps you to DRY
|
15
31
|
email:
|
16
32
|
- franciscomxs@gmail.com
|