bootstrap_2_helpers 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +8 -0
- data/Rakefile +7 -0
- data/app/helpers/bootstrap_flash_helper.rb +17 -0
- data/app/helpers/flash_block_helper.rb +19 -0
- data/app/helpers/modal_helper.rb +42 -0
- data/app/helpers/twitter_breadcrumbs_helper.rb +5 -0
- data/app/views/twitter-bootstrap/_breadcrumbs.html.erb +14 -0
- data/lib/bootstrap_2_helpers/bootstrap/rails/engine.rb +23 -0
- data/lib/bootstrap_2_helpers/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb +42 -0
- data/lib/bootstrap_2_helpers/version.rb +3 -0
- data/lib/bootstrap_2_helpers.rb +9 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f592470b40de41ae8127b026455acff727c02ab6
|
4
|
+
data.tar.gz: 917da21d98d128915c835e58823d3ffc4ed1e376
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df5dbed9e228430fc5c6d1056539beda07588c2c5112b594c47f8201550b3364c6b5e042e3bcbe12cebcb900212d5492f8e63a8a3623e4177ba8755f7ad2ac3d
|
7
|
+
data.tar.gz: 27498156f5994bca36c741100a125936a55c09555b100dcb52356e894d7b0a17c7b43bb8e11580f37dbbb52d8e8ab12a70bd3c5f41141886812bbaf027961992
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Kvokka
|
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
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module BootstrapFlashHelper
|
2
|
+
def bootstrap_flash
|
3
|
+
flash_messages = []
|
4
|
+
flash.each do |type, message|
|
5
|
+
# Skip Devise :timeout and :timedout flags
|
6
|
+
next if type == :timeout
|
7
|
+
next if type == :timedout
|
8
|
+
type = :success if type == :notice
|
9
|
+
type = :error if type == :alert
|
10
|
+
text = content_tag(:div,
|
11
|
+
content_tag(:button, raw("×"), :class => "close", "data-dismiss" => "alert") +
|
12
|
+
message, :class => "alert fade in alert-#{type}")
|
13
|
+
flash_messages << text if message
|
14
|
+
end
|
15
|
+
flash_messages.join("\n").html_safe
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FlashBlockHelper
|
2
|
+
AVAIABLE_TYPES = %w[info success warning danger]
|
3
|
+
def flash_block
|
4
|
+
output = ''
|
5
|
+
flash.each do |type, message|
|
6
|
+
output += flash_container(type, message)
|
7
|
+
end
|
8
|
+
|
9
|
+
raw(output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def flash_container(type, message)
|
13
|
+
use_type = AVAIABLE_TYPES.include?(type.to_s) ? type : 'info'
|
14
|
+
raw(content_tag(:div, :class => "alert alert-#{use_type}") do
|
15
|
+
content_tag(:a, raw("×"),:class => 'close', :data => {:dismiss => 'alert'}) +
|
16
|
+
message
|
17
|
+
end)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ModalHelper
|
2
|
+
def modal_dialog(options = {}, escape = true, &block)
|
3
|
+
default_options = {:class => "bootstrap-modal modal"}
|
4
|
+
content_tag :div, nil, options.merge(default_options), escape, &block
|
5
|
+
end
|
6
|
+
|
7
|
+
def modal_header(options = {}, escape = true, &block)
|
8
|
+
default_options = {:class => 'modal-header'}
|
9
|
+
content_tag :div, nil, options.merge(default_options), escape do
|
10
|
+
raw("<button class=\"close\" data-dismiss=\"modal\">×</button>" + capture(&block))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def modal_body(options = {}, escape = true, &block)
|
15
|
+
default_options = {:class => 'modal-body'}
|
16
|
+
content_tag :div, nil, options.merge(default_options), escape, &block
|
17
|
+
end
|
18
|
+
|
19
|
+
def modal_footer(options = {}, escape = true, &block)
|
20
|
+
default_options = {:class => 'modal-footer'}
|
21
|
+
content_tag :div, nil, options.merge(default_options), escape, &block
|
22
|
+
end
|
23
|
+
|
24
|
+
def modal_toggle(content_or_options = nil, options = {}, &block)
|
25
|
+
if block_given?
|
26
|
+
options = content_or_options if content_or_options.is_a?(Hash)
|
27
|
+
default_options = {:class => 'btn', "data-toggle" => "modal", "href" => options[:dialog]}.merge(options)
|
28
|
+
|
29
|
+
content_tag :a, nil, default_options, true, &block
|
30
|
+
else
|
31
|
+
default_options = {:class => 'btn', "data-toggle" => "modal", "href" => options[:dialog]}.merge(options)
|
32
|
+
content_tag :a, content_or_options, default_options, true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def modal_cancel_button content, options = {}
|
37
|
+
default_options = {:class => "btn bootstrap-modal-cancel-button"}
|
38
|
+
|
39
|
+
content_tag_string "a", content, default_options.merge(options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% if @breadcrumbs.present? %>
|
2
|
+
<ul class="breadcrumb">
|
3
|
+
<% separator = divider %>
|
4
|
+
<% @breadcrumbs[0..-2].each do |crumb| %>
|
5
|
+
<li>
|
6
|
+
<%= link_to crumb[:name], crumb[:url], crumb[:options] %>
|
7
|
+
<span class="divider"><%= separator %></span>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
10
|
+
<li class="active">
|
11
|
+
<%= @breadcrumbs.last[:name] %>
|
12
|
+
</li>
|
13
|
+
</ul>
|
14
|
+
<% end %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
require_relative 'twitter-bootstrap-breadcrumbs.rb'
|
4
|
+
require_relative '../../../../app/helpers/flash_block_helper.rb'
|
5
|
+
require_relative '../../../../app/helpers/modal_helper.rb'
|
6
|
+
require_relative '../../../../app/helpers/flash_block_helper.rb'
|
7
|
+
|
8
|
+
module Bootstrap2Helpers
|
9
|
+
module Bootstrap
|
10
|
+
module Rails
|
11
|
+
class Engine < ::Rails::Engine
|
12
|
+
initializer 'twitter-bootstrap-rails.setup_helpers' do |app|
|
13
|
+
app.config.to_prepare do
|
14
|
+
ActionController::Base.send :include, BreadCrumbs
|
15
|
+
ActionController::Base.send :helper, FlashBlockHelper
|
16
|
+
ActionController::Base.send :helper, ModalHelper
|
17
|
+
ActionController::Base.send :helper, BootstrapFlashHelper
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Bootstrap2Helpers
|
2
|
+
module Bootstrap
|
3
|
+
module BreadCrumbs
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def add_breadcrumb(name, url, options = {})
|
10
|
+
class_name = self.name
|
11
|
+
before_filter options do |controller|
|
12
|
+
name = controller.send :translate_breadcrumb, name, class_name if name.is_a?(Symbol)
|
13
|
+
controller.send :add_breadcrumb, name, url
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def add_breadcrumb(name, url = '', options = {})
|
21
|
+
@breadcrumbs ||= []
|
22
|
+
name = translate_breadcrumb(name, self.class.name) if name.is_a?(Symbol)
|
23
|
+
url = eval(url.to_s) if url =~ /_path|_url|@/
|
24
|
+
@breadcrumbs << {:name => name, :url => url, :options => options}
|
25
|
+
end
|
26
|
+
|
27
|
+
def translate_breadcrumb(name, class_name)
|
28
|
+
scope = [:breadcrumbs]
|
29
|
+
namespace = class_name.underscore.split('/')
|
30
|
+
namespace.last.sub!('_controller', '')
|
31
|
+
scope += namespace
|
32
|
+
|
33
|
+
I18n.t name, :scope => scope
|
34
|
+
end
|
35
|
+
|
36
|
+
def render_breadcrumbs(divider = '/')
|
37
|
+
s = render :partial => 'twitter-bootstrap/breadcrumbs', :locals => {:divider => divider}
|
38
|
+
s.first
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module Bootstrap2Helpers
|
2
|
+
module Bootstrap
|
3
|
+
module Rails
|
4
|
+
require 'bootstrap_2_helpers/bootstrap/rails/engine' if defined?(Rails)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
end
|
8
|
+
require 'bootstrap_2_helpers/version'
|
9
|
+
require 'bootstrap_2_helpers/bootstrap/rails/engine' if defined?(Rails)
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bootstrap_2_helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kvokka
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Lihgt helpers breadcrumps from bootstrap 2.
|
42
|
+
email:
|
43
|
+
- root_p@mail.ru
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/helpers/bootstrap_flash_helper.rb
|
52
|
+
- app/helpers/flash_block_helper.rb
|
53
|
+
- app/helpers/modal_helper.rb
|
54
|
+
- app/helpers/twitter_breadcrumbs_helper.rb
|
55
|
+
- app/views/twitter-bootstrap/_breadcrumbs.html.erb
|
56
|
+
- lib/bootstrap_2_helpers.rb
|
57
|
+
- lib/bootstrap_2_helpers/bootstrap/rails/engine.rb
|
58
|
+
- lib/bootstrap_2_helpers/bootstrap/rails/twitter-bootstrap-breadcrumbs.rb
|
59
|
+
- lib/bootstrap_2_helpers/version.rb
|
60
|
+
homepage: https://github.com/kvokka/bootstrap_2_helpers
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Bootstrap2Helpers.
|
84
|
+
test_files: []
|
85
|
+
has_rdoc:
|