helper_methods 0.0.3 → 0.0.4

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 CHANGED
@@ -26,7 +26,30 @@ Included helpers:
26
26
  youtube('z8WXgoBGRb4')
27
27
  youtube_link('z8WXgoBGRb4')
28
28
  icon('th-large icon-white')
29
- textilize
29
+
30
+ ### Youtube helpers
31
+
32
+ In your views, use:
33
+
34
+ youtube('z8WXgoBGRb4')
35
+
36
+ And it will become:
37
+
38
+ <iframe width='580' height='420'
39
+ src='http://www.youtube.com/embed/z8WXgoBGRb4'
40
+ frameborder='0'
41
+ allowfullscreen>
42
+ </iframe>
43
+
44
+ If you want the complete link, use:
45
+
46
+ youtube_link('z8WXgoBGRb4')
47
+
48
+ To return
49
+
50
+ http://www.youtube.com/watch?v=z8WXgoBGRb4
51
+
52
+ ### Form helpers
30
53
 
31
54
  In your forms use:
32
55
 
@@ -48,6 +71,8 @@ And it will return:
48
71
  <li>Error description</li>
49
72
  </ul>
50
73
 
74
+ ### View helpers
75
+
51
76
  For using flash messages, in your layout file, do:
52
77
 
53
78
  <%= flash_messages %>
@@ -76,6 +101,7 @@ This will return
76
101
 
77
102
  Made for twitter-bootstrap.
78
103
 
104
+ ### Mobile helpers
79
105
 
80
106
  And this helps you to manage mobile views
81
107
 
@@ -1,3 +1,3 @@
1
1
  module HelperMethods
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -35,6 +35,41 @@ module HelperMethods
35
35
  return "#{text} <i class='icon-#{icon}'></i>".html_safe if direction == 'r'
36
36
  end
37
37
 
38
+ def nav_link_to(text, path, css_class=nil, li_properties = {}, a_properties = {})
39
+ lp = li_properties.collect do |k, v|
40
+ %( #{k}="#{v}") unless k == :class
41
+ end.join
42
+
43
+ ap = a_properties.collect do |k, v|
44
+ %( #{k}="#{v}") unless k == :class
45
+ end.join
46
+
47
+ tag_class = %( class="#{css_class unless css_class.nil? }#{' ' if current_page? path and !css_class.nil?}#{'active' if current_page? path}") if current_page? path or !css_class.nil?
48
+
49
+ %(<li#{tag_class}#{lp}>#{link_to text, path, a_properties}</li>).html_safe
50
+ end
51
+
52
+ def is_active_link?(url, condition = nil)
53
+ url = url_for(url).sub(/\?.*/, '') # ignore GET params
54
+ case condition
55
+ when :inclusive, nil
56
+ !request.fullpath.match(/^#{Regexp.escape(url)}(\/.*|\?.*)?$/).blank?
57
+ when :exclusive
58
+ !request.fullpath.match(/^#{Regexp.escape(url)}\/?(\?.*)?$/).blank?
59
+ when Regexp
60
+ !request.fullpath.match(condition).blank?
61
+ when Array
62
+ controllers = [*condition[0]]
63
+ actions = [*condition[1]]
64
+ (controllers.blank? || controllers.member?(params[:controller])) &&
65
+ (actions.blank? || actions.member?(params[:action]))
66
+ when TrueClass
67
+ true
68
+ when FalseClass
69
+ false
70
+ end
71
+ end
72
+
38
73
  end
39
74
 
40
75
  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.3
4
+ version: 0.0.4
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-09-16 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Helper methods that helps you to DRY
15
15
  email: