twitter_bootstrap_helpers 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ #
5
+ gem "rails"
6
+ gem "activesupport", ">= 3.1.0"
7
+ gem "actionpack", ">= 3.1.0"
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "minitest", ">= 0"
13
+ gem "bundler", ">= 1.0.0"
14
+ gem "jeweler", "~> 1.6.4"
15
+ gem "rcov", ">= 0"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,100 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.1.1)
5
+ actionpack (= 3.1.1)
6
+ mail (~> 2.3.0)
7
+ actionpack (3.1.1)
8
+ activemodel (= 3.1.1)
9
+ activesupport (= 3.1.1)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ i18n (~> 0.6)
13
+ rack (~> 1.3.2)
14
+ rack-cache (~> 1.1)
15
+ rack-mount (~> 0.8.2)
16
+ rack-test (~> 0.6.1)
17
+ sprockets (~> 2.0.2)
18
+ activemodel (3.1.1)
19
+ activesupport (= 3.1.1)
20
+ builder (~> 3.0.0)
21
+ i18n (~> 0.6)
22
+ activerecord (3.1.1)
23
+ activemodel (= 3.1.1)
24
+ activesupport (= 3.1.1)
25
+ arel (~> 2.2.1)
26
+ tzinfo (~> 0.3.29)
27
+ activeresource (3.1.1)
28
+ activemodel (= 3.1.1)
29
+ activesupport (= 3.1.1)
30
+ activesupport (3.1.1)
31
+ multi_json (~> 1.0)
32
+ arel (2.2.3)
33
+ builder (3.0.0)
34
+ erubis (2.7.0)
35
+ git (1.2.5)
36
+ hike (1.2.1)
37
+ i18n (0.6.0)
38
+ jeweler (1.6.4)
39
+ bundler (~> 1.0)
40
+ git (>= 1.2.5)
41
+ rake
42
+ json (1.7.3)
43
+ mail (2.3.3)
44
+ i18n (>= 0.4.0)
45
+ mime-types (~> 1.16)
46
+ treetop (~> 1.4.8)
47
+ mime-types (1.18)
48
+ minitest (2.8.1)
49
+ multi_json (1.0.3)
50
+ polyglot (0.3.3)
51
+ rack (1.3.5)
52
+ rack-cache (1.1)
53
+ rack (>= 0.4)
54
+ rack-mount (0.8.3)
55
+ rack (>= 1.0.0)
56
+ rack-ssl (1.3.2)
57
+ rack
58
+ rack-test (0.6.1)
59
+ rack (>= 1.0)
60
+ rails (3.1.1)
61
+ actionmailer (= 3.1.1)
62
+ actionpack (= 3.1.1)
63
+ activerecord (= 3.1.1)
64
+ activeresource (= 3.1.1)
65
+ activesupport (= 3.1.1)
66
+ bundler (~> 1.0)
67
+ railties (= 3.1.1)
68
+ railties (3.1.1)
69
+ actionpack (= 3.1.1)
70
+ activesupport (= 3.1.1)
71
+ rack-ssl (~> 1.3.2)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (~> 0.14.6)
75
+ rake (0.9.2.2)
76
+ rcov (0.9.11)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ sprockets (2.0.3)
80
+ hike (~> 1.2)
81
+ rack (~> 1.0)
82
+ tilt (~> 1.1, != 1.3.0)
83
+ thor (0.14.6)
84
+ tilt (1.3.3)
85
+ treetop (1.4.10)
86
+ polyglot
87
+ polyglot (>= 0.3.1)
88
+ tzinfo (0.3.33)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ actionpack (>= 3.1.0)
95
+ activesupport (>= 3.1.0)
96
+ bundler (>= 1.0.0)
97
+ jeweler (~> 1.6.4)
98
+ minitest
99
+ rails
100
+ rcov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Danil Pismenny
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ twitter_bootstrap_helpers
2
+ =========================
3
+
4
+ Хелперы для Twitter Bootstrap
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = twitter_bootstrap_helpers
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to twitter_bootstrap_helpers
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Danil Pismenny. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "twitter_bootstrap_helpers"
18
+ gem.homepage = "http://github.com/dapi/twitter_bootstrap_helpers"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Хелперы для Twitter Bootstrap}
21
+ gem.description = %Q{Хелперы для Twitter Bootstrap}
22
+ gem.email = "danil@orionet.ru"
23
+ gem.authors = ["Danil Pismenny"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ #require 'rake/rdoctask'
46
+ # Rake::RDocTask.new do |rdoc|
47
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ # rdoc.rdoc_dir = 'rdoc'
50
+ # rdoc.title = "twitter_bootstrap_helpers #{version}"
51
+ # rdoc.rdoc_files.include('README*')
52
+ # rdoc.rdoc_files.include('lib/**/*.rb')
53
+ # end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,139 @@
1
+ # encoding: utf-8
2
+
3
+ module BootstrapHelper
4
+
5
+ def icon name, opts={}, &block
6
+ icon_args = {}
7
+ span_args = {}
8
+
9
+ icon_args[:class] = ["icon-#{name}", opts[:class]].compact * ' '
10
+
11
+ if opts[:tooltip]
12
+ span_args[:rel] = :tooltip
13
+ span_args[:title] = opts[:tooltip]
14
+ end
15
+
16
+ if block_given?
17
+ content_tag :span, span_args do
18
+ content_tag( :i, '', icon_args ) << content_tag( :span, block.call, :class=>'icon-text' )
19
+ end
20
+ else
21
+ content_tag :i, '', icon_args.merge(span_args)
22
+ end
23
+ end
24
+
25
+ def white_icon name, opts={}, &block
26
+ opts[:class] = [opts[:class], 'icon-white'].compact * ' '
27
+ icon name, opts, &block
28
+ end
29
+
30
+ def gray_icon name, opts={}, &block
31
+ opts[:class] = [opts[:class], 'icon-gray'].compact * ' '
32
+ icon name, opts, &block
33
+ end
34
+
35
+ # Call it for form object
36
+ #
37
+ def error_notification(form)
38
+ if form.error_notification
39
+ alert :error, :close=>true do
40
+ form.error_notification
41
+ end
42
+ end
43
+ end
44
+
45
+
46
+ #Примеры использования
47
+
48
+ # = alert do
49
+ # Мама мыла раму
50
+
51
+ # = alert :info do
52
+ # Съешь ещё этих мягких французских булок
53
+
54
+ # Возможные типы
55
+ # error
56
+ # info
57
+ # success
58
+
59
+ # = alert :info, :close=>true, :block=>true do
60
+ # Да выпей чаю
61
+
62
+ # = alert :close=>true, :block=>true do
63
+ # Можно и так, без типа
64
+
65
+ def alert type_or_options=nil, options={}, &block
66
+ alert_classes = ['alert']
67
+
68
+ if type_or_options.is_a?(Hash)
69
+ options = type_or_options
70
+ elsif type_or_options.present?
71
+ alert_classes << "alert-#{type_or_options}"
72
+ end
73
+
74
+ alert_classes << "alert-block" if options[:block]
75
+ alert_classes << options[:class] if options[:class]
76
+
77
+ content = ''
78
+ content << link_to('×', '#', :class=>:close, :'data-dismiss'=>'alert').html_safe if options[:close]
79
+ content << capture(&block).html_safe
80
+
81
+ content_tag :div, content.html_safe, :class => alert_classes.join(' ')
82
+ end
83
+
84
+ def show_flashes
85
+ flashes=''
86
+ flash.each do |type,content|
87
+ flashes << alert(type, :close=>true) do
88
+ content
89
+ end
90
+ end
91
+ flashes.html_safe
92
+ end
93
+
94
+ def breadcrumbs items
95
+ divider = ''
96
+ content_tag :ul, :class=>'breadcrumb' do
97
+ items.map do |i|
98
+ content_tag :li, i[:url] ? link_to( i[:title], i[:url] ) : i[:title], :class=>(:active if i[:active])
99
+ end.join("<li class='divider'>#{divider}</li>").html_safe
100
+ end.html_safe
101
+ end
102
+
103
+ def nav_tabs opts={}, &block
104
+ @tabs = TwitterBootstrap::TabsGenerator.new self, opts
105
+ @tabs.generate block
106
+ end
107
+
108
+ # Public: Создает группу объединенных кнопок.
109
+ #
110
+ # type - тип кпопок (:radio, :checkbox)
111
+ #
112
+ # Examples:
113
+ # = button_group(:radio) do |g|
114
+ # = g.button('Home')
115
+ # = g.button('Posts')
116
+ #
117
+ def button_group(type, &block)
118
+ builder = TwitterBootstrap::ButtonGroupBuilder.new(type, self)
119
+ builder.build(block)
120
+ end
121
+
122
+ # Public: Создает группу кнопок и связанные с ними вкладки.
123
+ #
124
+ # Examples
125
+ #
126
+ # = button_group_with_tabs do |g|
127
+ # = g.button('Home','home', active: true) do
128
+ # %h3 Home
129
+ # ...
130
+ # = g.button('Posts', 'posts') do
131
+ # %h3 Posts
132
+ # ....
133
+ #
134
+ def button_group_with_tabs(&block)
135
+ builder = TwitterBootstrap::ButtonGroupWithTabsBuilder.new(self)
136
+ builder.build(block)
137
+ end
138
+
139
+ end
@@ -0,0 +1,64 @@
1
+ # encoding: utf-8
2
+
3
+ module TwitterBootstrap
4
+
5
+ class ButtonGroupBuilder
6
+ def initialize(type, view_context)
7
+ @type = type
8
+ @view_context = view_context
9
+
10
+ @buttons = ""
11
+ end
12
+
13
+ def build(block)
14
+ block.call(self)
15
+ @view_context.content_tag(:div, @buttons.html_safe, class: 'btn-group', data: {toggle: "buttons-#{@type}"})
16
+ end
17
+
18
+ def button(label, options = {})
19
+ button_class = ['btn']
20
+
21
+ button_class << options[:class] if options[:class]
22
+ button_class << 'active' if options[:active]
23
+
24
+ button_class = button_class.join(' ')
25
+
26
+ data = {toggle: 'button'}
27
+ data[:target] = "##{options[:target]}" if options[:target]
28
+
29
+ @buttons << @view_context.content_tag(:button, label, class: button_class, data: data)
30
+
31
+ ""
32
+ end
33
+ end
34
+
35
+ class ButtonGroupWithTabsBuilder < ButtonGroupBuilder
36
+ def initialize(view_context)
37
+ super(:radio, view_context)
38
+ @tabs = ""
39
+ end
40
+
41
+ def build(block)
42
+ block.call(self)
43
+
44
+ buttons = @view_context.content_tag(:div, @buttons.html_safe, class: 'btn-group', data: {toggle: 'buttons-radio'})
45
+ tabs = @view_context.content_tag(:div, @tabs.html_safe, class: 'tab-content')
46
+
47
+ @view_context.content_tag(:div, buttons << tabs, class: 'tabbable')
48
+ end
49
+
50
+ def button(label, target, options = {}, &block)
51
+ super(label, options.merge!(target: target))
52
+
53
+ tab_class = ['tab-pane']
54
+ tab_class << 'active' if options[:active]
55
+
56
+ tab_class = tab_class.join(' ')
57
+
58
+ @tabs << @view_context.content_tag(:div, @view_context.capture(&block), id: target, class: tab_class)
59
+
60
+ ""
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,4 @@
1
+ module TwitterBootstrapHelpers
2
+ class Engine < Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,121 @@
1
+ class TwitterBootstrap::TabsGenerator
2
+ #unloadable
3
+ #include ::ActionView::Helpers::UrlHelper
4
+ #include ::ActionView::Helpers::TagHelper
5
+
6
+ attr_accessor :panes, :active_pane, :context, :options
7
+
8
+ def initialize _context, opts={}
9
+ self.context = _context
10
+ self.panes = {}
11
+ self.options = opts
12
+ end
13
+
14
+ def active_pane
15
+ options[:active]
16
+ end
17
+
18
+ def active_pane= pane
19
+ options[:active] = pane
20
+ end
21
+
22
+ def generate block
23
+ buffer = context.content_tag :ul, :class=>'nav nav-tabs' do
24
+ block.call(self)
25
+ end
26
+ buffer << generate_tab_content
27
+ buffer
28
+
29
+ #buffer = ''
30
+
31
+ #if options[:position] == :belowe
32
+ #raise 'not ready'
33
+ #buffer << context.content_tag( :div,
34
+ #(generate_tab_content + generate_tab_navs).html_safe,
35
+ #:class => 'tabbable tabs-below')
36
+ #else
37
+ #context.content_tag :ul, :class=>'nav nav-tabs' do
38
+ #buffer << block.call(self)
39
+ #end
40
+ #buffer << generate_tab_content
41
+ #end
42
+ #buffer.html_safe
43
+ end
44
+
45
+ def pane id, title=nil, content_or_options=nil, options={}, &content_block
46
+ pane = {}
47
+ if block_given?
48
+ pane[:content] = content_block
49
+ options = content_or_options || {}
50
+ else
51
+ pane[:content] = content_or_options
52
+ end
53
+
54
+ pane[:link] = options[:link] if options.has_key?(:link)
55
+ pane[:tooltip] = options[:tooltip]
56
+ pane[:class] = ['tab-pane', options[:pane_class]].compact
57
+ pane[:title] = title ||= id
58
+ pane[:data] = options[:data]
59
+
60
+ if active_pane == id or options[:active]
61
+ self.active_pane = id
62
+ pane[:class] << :active
63
+ pane[:nav_class] ||= []
64
+ pane[:nav_class] << :active
65
+ end
66
+
67
+ self.panes[id] = pane
68
+
69
+ generate_nav_tab id, pane
70
+ end
71
+
72
+ private
73
+
74
+ def generate_tab_navs
75
+ context.content_tag :ul, :class=>'nav nav-tabs' do
76
+ buffer = ''
77
+ self.panes.each_pair do |id, pane|
78
+ buffer << generate_nav_tab(id, pane)
79
+ end
80
+ buffer.html_safe
81
+ end
82
+ end
83
+
84
+ def generate_nav_tab id, pane
85
+ attrs = {}
86
+ attrs[:class] = pane[:nav_class] * ' ' if pane.has_key? :nav_class
87
+ context.content_tag :li, attrs do
88
+ pane_attr = {:data => pane[:data] || {}}
89
+ if pane[:tooltip]
90
+ pane_attr[:title] = pane[:tooltip]
91
+ pane_attr[:rel] = :tooltip
92
+ end
93
+
94
+ if pane.has_key?(:link)
95
+ context.link_to pane[:title], pane[:link], pane_attr
96
+ else
97
+ pane_attr[:data][:toggle] = :tab
98
+ context.link_to pane[:title], "##{id}", pane_attr
99
+ end
100
+ end
101
+ end
102
+
103
+ def generate_tab_content
104
+ context.content_tag :div, :class=>'tab-content' do
105
+ buffer = ''
106
+ self.panes.each_pair do |id, pane|
107
+ buffer << generate_pane_content(id, pane)
108
+ end
109
+ buffer.html_safe
110
+ end
111
+ end
112
+
113
+ def generate_pane_content id, pane
114
+ if pane[:content].is_a? Proc
115
+ context.content_tag( :div, :class=>pane[:class], :id=>id, &pane[:content] ).html_safe
116
+ else
117
+ context.content_tag( :div, pane[:content], :class=>pane[:class], :id=>id ).html_safe
118
+ end
119
+ end
120
+ end
121
+
@@ -0,0 +1,77 @@
1
+ module TwitterBootstrap
2
+ module Helpers
3
+
4
+ include ::ActionView::Helpers::UrlHelper
5
+ include ::ActionView::Helpers::TagHelper
6
+ attr_accessor :output_buffer
7
+
8
+ #
9
+ # generate_menu_item :divider
10
+ #
11
+ # <li class='divider' />
12
+ #
13
+ #
14
+ # generate_menu_item :link => '#',
15
+ # :title => 'Menu item',
16
+ # :active => true,
17
+ # :items => [
18
+ # {
19
+ # *some_options*
20
+ # }
21
+ #
22
+ #
23
+ def generate_menu_item(item)
24
+
25
+ return tag :li, :class => 'divider-vertical' if item == :divider
26
+
27
+ html_options = {}
28
+
29
+ li_class = item[:li_class] ? [item[:li_class]] : []
30
+ li_class << :active if item[:active]
31
+ li_class << :dropdown if item[:items]
32
+
33
+ link_options = {}
34
+
35
+ link_options[:class] = item[:link_class] ? [item[:link_class]] : []
36
+
37
+ if item[:items]
38
+ link_options[:class] << 'dropdown-toggle'
39
+ link_options[:data] = { :toggle => :dropdown }
40
+ end
41
+
42
+ li_class = li_class.blank? ? nil : { :class => li_class.join(' ') }
43
+
44
+ content_tag :li, li_class, false do
45
+ inner = link_to item[:title], item[:link], link_options
46
+
47
+ inner << generate_menu_items( item[:items], 'dropdown-menu' ) if item[:items]
48
+ inner
49
+ end
50
+ end
51
+
52
+
53
+ # generate_menu_items [
54
+ # {
55
+ # :link => '#',
56
+ # :title => 'Menu item'
57
+ # }
58
+ # ]
59
+ #
60
+ def generate_menu_items(items, ul_class=:nav)
61
+ return '' unless items
62
+ content_tag(:ul, :class => ul_class) do
63
+ items = items.values if items.is_a? Hash
64
+ items.map { |i| generate_menu_item(i) }.join.html_safe
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ module TwitterBootstrapHelpers
72
+
73
+ end
74
+
75
+ require 'twitter_bootstrap_helpers/engine'
76
+ require 'twitter_bootstrap_helpers/tabs_generator'
77
+ require 'twitter_bootstrap_helpers/button_group_builder'
data/test/helper.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+
11
+ Bundler.require(:default)
12
+
13
+ require 'action_view'
14
+ require 'active_support'
15
+ require 'action_controller'
16
+
17
+ require 'minitest/unit'
18
+
19
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
20
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
21
+ require 'twitter_bootstrap_helpers'
22
+
23
+ class MiniTest::Unit::TestCase
24
+ end
25
+
26
+ MiniTest::Unit.autorun
@@ -0,0 +1,34 @@
1
+ require 'helper'
2
+
3
+ class TestTwitterBootstrapHelpers < ActionDispatch::IntegrationTest # MiniTest::Unit::TestCase
4
+ include TwitterBootstrap::Helpers
5
+
6
+ # include ActionView::Context
7
+ attr_accessor :output_buffer
8
+
9
+ def test_generate_divider
10
+ assert_equal "<li class=\"divider\" />", generate_menu_item(:divider)
11
+ end
12
+
13
+ def test_generate_menu_item
14
+ assert_equal "<li class=\"active\"><a href=\"#\">Menu</a></li>", generate_menu_item(:link => '#', :title=>'Menu', :active=>true)
15
+ end
16
+
17
+ def test_generate_menu_items
18
+ result = generate_menu_items [
19
+ { :link=>'#', :title=>'title' },
20
+ { :link=>'#', :title=>'title2', :active=>true, :items => [
21
+ { :link=>'#', :title=>'title2' },
22
+ :divider
23
+ ]
24
+ }
25
+ ]
26
+
27
+ assert_equal "<ul class=\"nav\"><li><a href=\"#\">title</a></li><li class=\"active dropdown\"><a href=\"#\" class=\"dropdown-toggle\">title2</a><ul class=\"dropdown-menu\"><li><a href=\"#\">title2</a></li><li class=\"divider\" /></ul></li></ul>", result
28
+ end
29
+
30
+ def test_generate_menu_items_from_hash
31
+ assert_equal "<ul class=\"nav\"><li><a href=\"#\">t</a></li><li><a href=\"#\">t2</a></li></ul>",
32
+ generate_menu_items( :key1 => { :link=>'#', :title=>'t' }, :key2 => { :link=>'#', :title=>'t2' } )
33
+ end
34
+ end
@@ -0,0 +1,74 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "twitter_bootstrap_helpers"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Danil Pismenny"]
12
+ s.date = "2012-05-21"
13
+ s.description = "\u{425}\u{435}\u{43b}\u{43f}\u{435}\u{440}\u{44b} \u{434}\u{43b}\u{44f} Twitter Bootstrap"
14
+ s.email = "danil@orionet.ru"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "app/helpers/bootstrap_helper.rb",
29
+ "lib/twitter_bootstrap_helpers.rb",
30
+ "lib/twitter_bootstrap_helpers/button_group_builder.rb",
31
+ "lib/twitter_bootstrap_helpers/engine.rb",
32
+ "lib/twitter_bootstrap_helpers/tabs_generator.rb",
33
+ "test/helper.rb",
34
+ "test/test_twitter_bootstrap_helpers.rb",
35
+ "twitter_bootstrap_helpers.gemspec",
36
+ "vendor/assets/javascripts/twitter_bootstrap_helpers.js"
37
+ ]
38
+ s.homepage = "http://github.com/dapi/twitter_bootstrap_helpers"
39
+ s.licenses = ["MIT"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = "1.8.10"
42
+ s.summary = "\u{425}\u{435}\u{43b}\u{43f}\u{435}\u{440}\u{44b} \u{434}\u{43b}\u{44f} Twitter Bootstrap"
43
+
44
+ if s.respond_to? :specification_version then
45
+ s.specification_version = 3
46
+
47
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
+ s.add_runtime_dependency(%q<rails>, [">= 0"])
49
+ s.add_runtime_dependency(%q<activesupport>, [">= 3.1.0"])
50
+ s.add_runtime_dependency(%q<actionpack>, [">= 3.1.0"])
51
+ s.add_development_dependency(%q<minitest>, [">= 0"])
52
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
53
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
54
+ s.add_development_dependency(%q<rcov>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<rails>, [">= 0"])
57
+ s.add_dependency(%q<activesupport>, [">= 3.1.0"])
58
+ s.add_dependency(%q<actionpack>, [">= 3.1.0"])
59
+ s.add_dependency(%q<minitest>, [">= 0"])
60
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
61
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
62
+ s.add_dependency(%q<rcov>, [">= 0"])
63
+ end
64
+ else
65
+ s.add_dependency(%q<rails>, [">= 0"])
66
+ s.add_dependency(%q<activesupport>, [">= 3.1.0"])
67
+ s.add_dependency(%q<actionpack>, [">= 3.1.0"])
68
+ s.add_dependency(%q<minitest>, [">= 0"])
69
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
71
+ s.add_dependency(%q<rcov>, [">= 0"])
72
+ end
73
+ end
74
+
@@ -0,0 +1,6 @@
1
+ $(function(){
2
+ // Переключает вкладки через кнопки в btn-group
3
+ $('.tabbable .btn-group button').click(function(){
4
+ $(this).tab('show');
5
+ });
6
+ });
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter_bootstrap_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Danil Pismenny
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: &23121800 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *23121800
25
+ - !ruby/object:Gem::Dependency
26
+ name: activesupport
27
+ requirement: &23117100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 3.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *23117100
36
+ - !ruby/object:Gem::Dependency
37
+ name: actionpack
38
+ requirement: &23115660 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 3.1.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *23115660
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: &23113220 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *23113220
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &23111820 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *23111820
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &23006580 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.6.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *23006580
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ requirement: &23003260 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *23003260
91
+ description: Хелперы для Twitter Bootstrap
92
+ email: danil@orionet.ru
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files:
96
+ - LICENSE.txt
97
+ - README.md
98
+ - README.rdoc
99
+ files:
100
+ - Gemfile
101
+ - Gemfile.lock
102
+ - LICENSE.txt
103
+ - README.md
104
+ - README.rdoc
105
+ - Rakefile
106
+ - VERSION
107
+ - app/helpers/bootstrap_helper.rb
108
+ - lib/twitter_bootstrap_helpers.rb
109
+ - lib/twitter_bootstrap_helpers/button_group_builder.rb
110
+ - lib/twitter_bootstrap_helpers/engine.rb
111
+ - lib/twitter_bootstrap_helpers/tabs_generator.rb
112
+ - test/helper.rb
113
+ - test/test_twitter_bootstrap_helpers.rb
114
+ - twitter_bootstrap_helpers.gemspec
115
+ - vendor/assets/javascripts/twitter_bootstrap_helpers.js
116
+ homepage: http://github.com/dapi/twitter_bootstrap_helpers
117
+ licenses:
118
+ - MIT
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ segments:
130
+ - 0
131
+ hash: 4016655193622081367
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ none: false
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 1.8.10
141
+ signing_key:
142
+ specification_version: 3
143
+ summary: Хелперы для Twitter Bootstrap
144
+ test_files: []