twitter-bootswatch-rails-helpers 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +13 -0
- data/app/helpers/twitter/bootswatch/breadcrumbs_helper.rb +9 -0
- data/app/helpers/twitter/bootswatch/flash_helper.rb +49 -0
- data/app/views/twitter/bootswatch/_breadcrumbs.html.erb +14 -0
- data/lib/twitter/bootswatch/rails/helpers/bootswatch.rb +2 -0
- data/lib/twitter/bootswatch/rails/helpers/breadcrumbs.rb +34 -0
- data/lib/twitter/bootswatch/rails/helpers/engine.rb +21 -0
- data/lib/twitter/bootswatch/rails/helpers/version.rb +9 -0
- data/lib/twitter-bootswatch-rails-helpers.rb +1 -0
- data/twitter-bootswatch-rails-helpers.gemspec +24 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Scott V. Rosenthal
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Twitter Bootswatch Rails Helpers gem
|
2
|
+
|
3
|
+
- Requires [twitter-bootswatch-rails](https://github.com/scottvrosenthal/twitter-bootswatch-rails)
|
4
|
+
- Provides view helpers for twitter bootstrap's alerts and breadcrumbs
|
5
|
+
|
6
|
+
## Installing Gem
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'twitter-bootswatch-rails'
|
11
|
+
gem 'twitter-bootswatch-rails-helpers'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install twitter-bootswatch-rails-helpers
|
20
|
+
|
21
|
+
## Demo
|
22
|
+
|
23
|
+
The [demo](https://github.com/scottvrosenthal/twitter-bootswatch-rails-demo) will show you how this gem can be used.
|
24
|
+
|
25
|
+
## Usages
|
26
|
+
|
27
|
+
Please view the [demo](https://github.com/scottvrosenthal/twitter-bootswatch-rails-demo) project to see some examples on how to use these view helpers
|
28
|
+
|
29
|
+
Alerts:
|
30
|
+
|
31
|
+
```erb
|
32
|
+
<%= bootswatch_flash_container(:default, true) do %>
|
33
|
+
<h4>Alert block</h4><p>Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</p>
|
34
|
+
<% end %>
|
35
|
+
<%= bootswatch_flash_container(:success) do %>
|
36
|
+
<strong>Success</strong> You successfully read this important alert message.
|
37
|
+
<% end %>
|
38
|
+
<%= bootswatch_flash_container(:error) do %>
|
39
|
+
<strong>Error</strong> Change a few things up and try submitting again.
|
40
|
+
<% end %>
|
41
|
+
<%= bootswatch_flash_container(:info) do %>
|
42
|
+
<strong>Information</strong> This alert needs your attention, but it's not super important.
|
43
|
+
<% end %>
|
44
|
+
```
|
45
|
+
|
46
|
+
Breadcrumbs:
|
47
|
+
|
48
|
+
Place an add_breadcrumb call in the action of your controller:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
def index
|
52
|
+
add_breadcrumb "Test link", root_path
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
Place a call to the render_breadcrumbs helper at the top of the view or where you want it to render:
|
57
|
+
|
58
|
+
```erb
|
59
|
+
<%= render_breadcrumbs %>
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Twitter
|
2
|
+
module Bootswatch
|
3
|
+
module FlashHelper
|
4
|
+
|
5
|
+
def bootswatch_flash(alert_block=false)
|
6
|
+
alert_block_class = alert_block ? ' alert-block' : ''
|
7
|
+
flash_messages = []
|
8
|
+
flash.each do |type, message|
|
9
|
+
alert_type_class = bootswatch_alert_types(type)
|
10
|
+
text = content_tag(:div, link_to('x', '#', :class => 'close', 'data-dismiss' => 'alert') + message, :class => "alert fade in #{alert_type_class}#{alert_block_class}")
|
11
|
+
flash_messages << text if message
|
12
|
+
end
|
13
|
+
flash_messages.join('\n').html_safe
|
14
|
+
end
|
15
|
+
|
16
|
+
def bootswatch_flash_block(alert_block=false)
|
17
|
+
output = ''
|
18
|
+
flash.each do |type, message|
|
19
|
+
output << bootswatch_flash_container(type, alert_block) do
|
20
|
+
message
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
raw(output)
|
25
|
+
end
|
26
|
+
|
27
|
+
def bootswatch_flash_container(type, alert_block=false, &message)
|
28
|
+
alert_block_class = alert_block ? ' alert-block' : ''
|
29
|
+
alert_type_class = bootswatch_alert_types(type)
|
30
|
+
message_text = capture(&message)
|
31
|
+
output = content_tag(:div, :class => "alert #{alert_type_class}#{alert_block_class}") do
|
32
|
+
content_tag(:a, '×'.html_safe, :class => 'close', :data => {:dismiss => 'alert'}).html_safe.safe_concat(message_text)
|
33
|
+
end
|
34
|
+
|
35
|
+
raw(output)
|
36
|
+
end
|
37
|
+
|
38
|
+
def bootswatch_alert_types(alert_type)
|
39
|
+
case alert_type
|
40
|
+
when :info then 'alert-info'
|
41
|
+
when :notice, :success then 'alert-success'
|
42
|
+
when :alert, :error then 'alert-error'
|
43
|
+
else 'alert' # warning
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -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
|
+
<%= link_to @breadcrumbs.last[:name], @breadcrumbs.last[:url], @breadcrumbs.last[:options] %>
|
12
|
+
</li>
|
13
|
+
</ul>
|
14
|
+
<% end %>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Twitter
|
2
|
+
module Bootswatch
|
3
|
+
module Rails
|
4
|
+
module Helpers
|
5
|
+
module BreadCrumbs
|
6
|
+
def self.included(base)
|
7
|
+
base.extend(ClassMethods)
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def add_breadcrumb name, url, options={}
|
12
|
+
before_filter options do |controller|
|
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
|
+
url = eval(url.to_s) if url =~ /_path|_url|@/
|
23
|
+
@breadcrumbs << {:name => name, :url => url, :options => options}
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_breadcrumbs(divider = '/')
|
27
|
+
s = render :partial => 'twitter/bootswatch/breadcrumbs', :locals => {:divider => divider}
|
28
|
+
s.first
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/breadcrumbs.rb'
|
4
|
+
|
5
|
+
module Twitter
|
6
|
+
module Bootswatch
|
7
|
+
module Rails
|
8
|
+
module Helpers
|
9
|
+
class Engine < ::Rails::Engine
|
10
|
+
|
11
|
+
initializer 'twitter-bootswatch-rails-helpers.setup_helpers' do |app|
|
12
|
+
app.config.to_prepare do
|
13
|
+
ActionController::Base.send :include, BreadCrumbs
|
14
|
+
ActionController::Base.send :helper, FlashHelper
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'twitter/bootswatch/rails/helpers/bootswatch' if defined?(Rails)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'twitter/bootswatch/rails/helpers/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "twitter-bootswatch-rails-helpers"
|
8
|
+
gem.version = Twitter::Bootswatch::Rails::Helpers::VERSION
|
9
|
+
gem.authors = ["Scott V. Rosenthal"]
|
10
|
+
gem.email = ["sr7575@gmail.com"]
|
11
|
+
gem.homepage = "https://github.com/scottvrosenthal/twitter-bootswatch-rails-helpers"
|
12
|
+
gem.summary = %q{Twitter Bootswatch Rails Helpers gem for use with the twitter-bootswatch-rails.gem}
|
13
|
+
gem.description = %q{twitter-bootswatch-rails-helpers gem provides common view helpers for use with the twitter-bootswatch-rails.gem}
|
14
|
+
|
15
|
+
|
16
|
+
gem.rubyforge_project = "twitter-bootswatch-rails-helpers"
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
|
22
|
+
gem.add_dependency 'twitter-bootswatch-rails', '>= 2.1'
|
23
|
+
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: twitter-bootswatch-rails-helpers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.3.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott V. Rosenthal
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: twitter-bootswatch-rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.1'
|
30
|
+
description: twitter-bootswatch-rails-helpers gem provides common view helpers for
|
31
|
+
use with the twitter-bootswatch-rails.gem
|
32
|
+
email:
|
33
|
+
- sr7575@gmail.com
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- app/helpers/twitter/bootswatch/breadcrumbs_helper.rb
|
44
|
+
- app/helpers/twitter/bootswatch/flash_helper.rb
|
45
|
+
- app/views/twitter/bootswatch/_breadcrumbs.html.erb
|
46
|
+
- lib/twitter-bootswatch-rails-helpers.rb
|
47
|
+
- lib/twitter/bootswatch/rails/helpers/bootswatch.rb
|
48
|
+
- lib/twitter/bootswatch/rails/helpers/breadcrumbs.rb
|
49
|
+
- lib/twitter/bootswatch/rails/helpers/engine.rb
|
50
|
+
- lib/twitter/bootswatch/rails/helpers/version.rb
|
51
|
+
- twitter-bootswatch-rails-helpers.gemspec
|
52
|
+
homepage: https://github.com/scottvrosenthal/twitter-bootswatch-rails-helpers
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
hash: -2674487303380543985
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
hash: -2674487303380543985
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project: twitter-bootswatch-rails-helpers
|
78
|
+
rubygems_version: 1.8.24
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Twitter Bootswatch Rails Helpers gem for use with the twitter-bootswatch-rails.gem
|
82
|
+
test_files: []
|