bootstrap_helpers 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bootstrap_helpers.gemspec +1 -0
- data/lib/bootstrap_helpers/url_processor.rb +12 -0
- data/lib/bootstrap_helpers/version.rb +1 -1
- data/lib/bootstrap_helpers/view_helpers.rb +8 -0
- data/test_app/app/controllers/samples_controller.rb +2 -0
- data/test_app/app/views/layouts/application.html.erb +21 -9
- data/test_app/app/views/samples/bootstrap_tab_items.html.erb +0 -0
- data/test_app/config/routes.rb +1 -0
- data/test_app/public/stylesheets/bootstrap.css +3 -0
- data/test_app/spec/requests/bootstrap_form_input_spec.rb +11 -0
- metadata +21 -6
data/bootstrap_helpers.gemspec
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
module UrlProcessor
|
2
|
+
|
3
|
+
def navigation_item_class(url_value)
|
4
|
+
case url_value
|
5
|
+
when Hash
|
6
|
+
url_value[:controller]=controller.controller_name unless url_value[:controller]
|
7
|
+
"active" if url_value[:controller]==controller.controller_name and url_value[:action]==controller.action_name
|
8
|
+
when String
|
9
|
+
"active" if request.fullpath.split("?")[0] == url_value.split("?")[0]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
require 'bootstrap_helpers/flash_message_proccessor'
|
2
|
+
require 'bootstrap_helpers/url_processor'
|
2
3
|
module BootstrapHelpers
|
3
4
|
|
4
5
|
module ViewHelpers
|
5
6
|
|
6
7
|
include FlashMessageProccessor
|
8
|
+
include UrlProcessor
|
7
9
|
|
8
10
|
def bootstrap_form_tag(path,legend='',params={})
|
9
11
|
form_tag path, params do
|
@@ -62,6 +64,12 @@ module BootstrapHelpers
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
67
|
+
def bootstrap_navigation_item(title, url_value, params={})
|
68
|
+
content_tag :li, :class=>navigation_item_class(url_value) do
|
69
|
+
link_to title, url_value, params
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
65
73
|
end
|
66
74
|
|
67
75
|
end
|
@@ -1,14 +1,26 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
</head>
|
9
|
-
<body>
|
3
|
+
<head>
|
4
|
+
<title>TestApp</title>
|
5
|
+
<%= stylesheet_link_tag :all %>
|
6
|
+
<%= javascript_include_tag :all %>
|
7
|
+
<%= csrf_meta_tag %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div class="topbar" data-scrollspy="scrollspy">
|
11
|
+
<div class="topbar-inner">
|
12
|
+
<div class="container">
|
13
|
+
<ul class="nav">
|
14
|
+
<%= bootstrap_navigation_item "Root", root_path, :class=>"some_class"%>
|
15
|
+
<%= bootstrap_navigation_item "Bootstrap Forms For", {:controller=>"samples", :action=>'bootstrap_forms_for'}, :class=>"some_class"%>
|
16
|
+
<%= bootstrap_navigation_item "Bootstrap Flash Messages", {:action=>'bootstrap_flash_messages'}, :class=>"some_class"%>
|
17
|
+
<%= bootstrap_navigation_item "Bootstrap Tab Items", bootstrap_tab_items_path, :class=>"some_class"%>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
10
22
|
|
11
|
-
<%= yield %>
|
23
|
+
<%= yield %>
|
12
24
|
|
13
|
-
</body>
|
25
|
+
</body>
|
14
26
|
</html>
|
File without changes
|
data/test_app/config/routes.rb
CHANGED
@@ -3,5 +3,6 @@ TestApp::Application.routes.draw do
|
|
3
3
|
controller :samples do
|
4
4
|
get '/bootstrap_forms_for'=>:bootstrap_forms_for, :as=>:bootstrap_forms_for
|
5
5
|
get '/bootstrap_flash_messages'=>:bootstrap_flash_messages, :as=>:bootstrap_flash_messages
|
6
|
+
get '/bootstrap_tab_items'=>:bootstrap_tab_items, :as=>:bootstrap_tab_items
|
6
7
|
end
|
7
8
|
end
|
@@ -38,4 +38,15 @@ describe SamplesController do
|
|
38
38
|
page.should have_selector("div.prepended_input .input-prepend .add-on", :text=>'%')
|
39
39
|
end
|
40
40
|
|
41
|
+
it 'should generate tabs in navigation bar', :focus=>true do
|
42
|
+
visit bootstrap_tab_items_path
|
43
|
+
page.should have_selector("ul.nav li", :count=>4)
|
44
|
+
page.should have_selector("ul.nav li.active", :count=>1)
|
45
|
+
first("li.active a")[:href].should include(bootstrap_tab_items_path.to_s)
|
46
|
+
[root_path, bootstrap_forms_for_path, bootstrap_flash_messages_path].each do |url|
|
47
|
+
visit url
|
48
|
+
first("li.active a")[:href].should include(url.to_s)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
41
52
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootstrap_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergey Pchelincev
|
@@ -15,10 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-21 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
version_requirements: *id001
|
34
|
+
name: rake
|
22
35
|
description: Speed up bilding you interface with bootstrap
|
23
36
|
email:
|
24
37
|
- jalkoby91@gmail.com
|
@@ -36,6 +49,7 @@ files:
|
|
36
49
|
- lib/bootstrap_helpers.rb
|
37
50
|
- lib/bootstrap_helpers/flash_message_proccessor.rb
|
38
51
|
- lib/bootstrap_helpers/railtie.rb
|
52
|
+
- lib/bootstrap_helpers/url_processor.rb
|
39
53
|
- lib/bootstrap_helpers/version.rb
|
40
54
|
- lib/bootstrap_helpers/view_helpers.rb
|
41
55
|
- test_app/.gitignore
|
@@ -52,6 +66,7 @@ files:
|
|
52
66
|
- test_app/app/views/samples/bootstrap_flash_messages.html.erb
|
53
67
|
- test_app/app/views/samples/bootstrap_form_input.html.erb
|
54
68
|
- test_app/app/views/samples/bootstrap_forms_for.html.erb
|
69
|
+
- test_app/app/views/samples/bootstrap_tab_items.html.erb
|
55
70
|
- test_app/app/views/samples/index.html.erb
|
56
71
|
- test_app/chromedriver.log
|
57
72
|
- test_app/config.ru
|