twitter-bootstrapped 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.gitmodules +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +61 -0
- data/Rakefile +36 -0
- data/lib/generators/bootstrap/install/install_generator.rb +44 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.coffee +17 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.css.sass +7 -0
- data/lib/generators/bootstrap/install/templates/bootstrap.css.scss +8 -0
- data/lib/generators/bootstrap/layout/layout_generator.rb +25 -0
- data/lib/generators/bootstrap/layout/templates/flash.html.slim +12 -0
- data/lib/generators/bootstrap/layout/templates/footer.html.slim +3 -0
- data/lib/generators/bootstrap/layout/templates/header.html.slim +15 -0
- data/lib/generators/bootstrap/layout/templates/layout.html.slim +17 -0
- data/lib/generators/slim/scaffold/scaffold_generator.rb +43 -0
- data/lib/generators/slim/scaffold/templates/edit.html.slim +3 -0
- data/lib/generators/slim/scaffold/templates/index.html.slim +26 -0
- data/lib/generators/slim/scaffold/templates/new.html.slim +3 -0
- data/lib/generators/slim/scaffold/templates/plain_form.html.slim +15 -0
- data/lib/generators/slim/scaffold/templates/scaffolds.css.sass +15 -0
- data/lib/generators/slim/scaffold/templates/scaffolds.css.scss +21 -0
- data/lib/generators/slim/scaffold/templates/show.html.slim +9 -0
- data/lib/generators/slim/scaffold/templates/simpleform_form.html.slim +17 -0
- data/lib/twitter-bootstrapped.rb +7 -0
- data/lib/twitter-bootstrapped/engine.rb +9 -0
- data/lib/twitter-bootstrapped/version.rb +5 -0
- data/twitter-bootstrapped.gemspec +26 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/css/bootstrap-responsive.css +567 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/css/bootstrap-responsive.min.css +3 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/css/bootstrap.css +3365 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/css/bootstrap.min.css +610 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/img/glyphicons-halflings.png +0 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/js/bootstrap.js +1722 -0
- data/vendor/assets/twitter-bootstrap/bootstrap/js/bootstrap.min.js +1 -0
- data/vendor/assets/twitter-bootstrap/twitter-bootstrap-responsive.css +1 -0
- data/vendor/assets/twitter-bootstrap/twitter-bootstrap.css +1 -0
- data/vendor/assets/twitter-bootstrap/twitter-bootstrap.js +1 -0
- metadata +167 -0
data/.gitignore
ADDED
data/.gitmodules
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Gudleik Rasch
|
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,61 @@
|
|
1
|
+
# Twitter::Bootstrapped
|
2
|
+
|
3
|
+
Get quickly up and running with Twitter Bootstrap in Rails 3.
|
4
|
+
The gem provides version 2 of the Twitter Bootstrap assets as well as some generators.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'twitter-bootstrapped'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
$ rails generate bootstrap:install
|
16
|
+
|
17
|
+
|
18
|
+
## Generators
|
19
|
+
|
20
|
+
### Layout
|
21
|
+
|
22
|
+
To install a layout run
|
23
|
+
|
24
|
+
$ rails generate bootstrap:layout [name] [fixed or fluid]
|
25
|
+
|
26
|
+
This will create the following files
|
27
|
+
|
28
|
+
* app/views/layouts/application.html.slim
|
29
|
+
* app/views/layouts/_flash.html.slim
|
30
|
+
* app/views/application/_header.html.slim
|
31
|
+
* app/views/application/_footer.html.slim
|
32
|
+
|
33
|
+
Pass --help to get more information.
|
34
|
+
|
35
|
+
|
36
|
+
### Scaffolds (slim)
|
37
|
+
|
38
|
+
The gem comes with a slim scaffold generator.
|
39
|
+
Make sure you have configured template_engine to :slim
|
40
|
+
|
41
|
+
Instead of using the slim-rails, just use the slim gem and add this to config/initializers/generators.rb:
|
42
|
+
|
43
|
+
Rails.application.config.generators do |g|
|
44
|
+
g.template_engine = :slim
|
45
|
+
end
|
46
|
+
|
47
|
+
Then you can run the standard rails scaffold generator:
|
48
|
+
|
49
|
+
$ rails generate scaffold Product name:string price:integer
|
50
|
+
|
51
|
+
ps - the scaffold templates support SimpleForm ;)
|
52
|
+
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
1. Fork it
|
57
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
58
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
59
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
60
|
+
5. Create new Pull Request
|
61
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
|
5
|
+
namespace :bootstrap do
|
6
|
+
|
7
|
+
# desc 'Initialize the twitter bootstrap submodule'
|
8
|
+
task :setup do
|
9
|
+
`git submodule --quiet update`
|
10
|
+
end
|
11
|
+
|
12
|
+
# desc 'Sync twitter bootstrap repo'
|
13
|
+
task :update_repo => :setup do
|
14
|
+
`cd vendor/twitter-bootstrap; git checkout --quiet master; git pull --quiet origin master`
|
15
|
+
end
|
16
|
+
|
17
|
+
# desc 'Compile the assets. Requires lessc and uglifyjs'
|
18
|
+
task :make => :update_repo do
|
19
|
+
`cd vendor/twitter-bootstrap; make`
|
20
|
+
end
|
21
|
+
|
22
|
+
# desc 'Cleanup changes in bootstrap repo'
|
23
|
+
task :cleanup do
|
24
|
+
`cd vendor/twitter-bootstrap; git co -- .`
|
25
|
+
end
|
26
|
+
|
27
|
+
# desc 'Compile and install assets into gem'
|
28
|
+
task :install => :make do
|
29
|
+
`test -d vendor/assets/twitter-bootstrap/bootstrap && rm -rf vendor/assets/twitter-bootstrap/bootstrap`
|
30
|
+
`unzip -d vendor/assets/twitter-bootstrap/ vendor/twitter-bootstrap/docs/assets/bootstrap.zip`
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Fetch latest version, compile and install assets into gem'
|
34
|
+
task :upgrade => [ :install, :cleanup ]
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "This generator injects require twitter-bootstrap into your asset pipeline"
|
7
|
+
|
8
|
+
source_root File.expand_path("../templates", __FILE__)
|
9
|
+
|
10
|
+
def copy_assets
|
11
|
+
copy_file "bootstrap.coffee", "app/assets/javascripts/bootstrap.js.coffee"
|
12
|
+
|
13
|
+
ext = Rails.application.config.generators.options[:rails][:stylesheet_engine] || :sass
|
14
|
+
copy_file "bootstrap.css.#{ext}", "app/assets/stylesheets/bootstrap.css.#{ext}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_js
|
18
|
+
if File.exist?("app/assets/javascripts/application.js")
|
19
|
+
unless file_matches "app/assets/javascripts/application.js", /= require_tree .[^\/]/
|
20
|
+
append_to_file "app/assets/javascripts/application.js", "//= require bootstrap\n"
|
21
|
+
end
|
22
|
+
else
|
23
|
+
puts "Missing application.js/css. Please add '= require twitter-bootstrap' to your asset pipeline."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_css
|
28
|
+
if File.exist?("app/assets/stylesheets/application.css")
|
29
|
+
unless file_matches "app/assets/stylesheets/application.css", %r{\*= require_tree .[^/]}
|
30
|
+
insert_into_file "app/assets/stylesheets/application.css", " *= require bootstrap\n", :before => "*/"
|
31
|
+
end
|
32
|
+
else
|
33
|
+
puts "app/assets/stylesheets/application.css not found. Please add '= require twitter-bootstrap' manually."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
|
39
|
+
def file_matches(path, pattern)
|
40
|
+
File.binread(path).match pattern
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#= require twitter-bootstrap
|
2
|
+
|
3
|
+
jQuery ->
|
4
|
+
$(".alert-message").alert()
|
5
|
+
$(".tabs").button()
|
6
|
+
$(".carousel").carousel()
|
7
|
+
$(".collapse").collapse()
|
8
|
+
$(".dropdown-toggle").dropdown()
|
9
|
+
$(".modal").modal()
|
10
|
+
$("a[rel]").popover()
|
11
|
+
$(".navbar").scrollspy()
|
12
|
+
$(".tab").tab "show"
|
13
|
+
$(".tooltip").tooltip()
|
14
|
+
$(".typeahead").typeahead()
|
15
|
+
|
16
|
+
# Alternative to using data-dismiss attributes:
|
17
|
+
# $('a.close').on 'click', -> $(this).parent().hide()
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Bootstrap
|
4
|
+
module Generators
|
5
|
+
class LayoutGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
argument :layout_name, type: :string, default: "application"
|
9
|
+
argument :layout_type, type: :string, default: "fixed", banner: "*fixed or fluid"
|
10
|
+
|
11
|
+
attr_reader :app_name, :container
|
12
|
+
|
13
|
+
def copy_files
|
14
|
+
@app_name = Rails.application.class.to_s.split("::").first
|
15
|
+
@container= layout_type == "fixed" ? "container" : "container-fluid"
|
16
|
+
|
17
|
+
ext = Rails.application.config.generators.options[:rails][:template_engine] || :slim
|
18
|
+
template "layout.html.#{ext}", "app/views/layouts/#{layout_name}.html.#{ext}"
|
19
|
+
template "flash.html.#{ext}", "app/views/layouts/_flash.html.#{ext}"
|
20
|
+
template "header.html.#{ext}", "app/views/application/_header.html.#{ext}"
|
21
|
+
template "footer.html.#{ext}", "app/views/application/_footer.html.#{ext}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#flash
|
2
|
+
.alert.alert-info.fade.in style="display:#{self.flash.key?(:info) ? 'block' : 'none' }"
|
3
|
+
a.close data-dismiss="alert" ×
|
4
|
+
= self.flash[:info]
|
5
|
+
|
6
|
+
.alert.alert-notice.fade.in style="display:#{self.flash.key?(:notice) ? 'block' : 'none' }"
|
7
|
+
a.close data-dismiss="alert" ×
|
8
|
+
= self.flash[:notice]
|
9
|
+
|
10
|
+
.alert.alert-error.fade.in style="display:#{self.flash.key?(:alert) ? 'block' : 'none' }"
|
11
|
+
a.close data-dismiss="alert" ×
|
12
|
+
= self.flash[:alert]
|
@@ -0,0 +1,15 @@
|
|
1
|
+
.navbar.navbar-fixed-top
|
2
|
+
.navbar-inner
|
3
|
+
.<%= container %>
|
4
|
+
a.btn.btn-navbar data-toggle="collapse" data-target=".nav-collapse"
|
5
|
+
span.icon-bar
|
6
|
+
span.icon-bar
|
7
|
+
span.icon-bar
|
8
|
+
|
9
|
+
= link_to "<%= app_name %>", root_url, class: "brand"
|
10
|
+
|
11
|
+
.nav-collapse
|
12
|
+
ul.nav
|
13
|
+
li.active= link_to "Home", "#"
|
14
|
+
li= link_to "About", "#about"
|
15
|
+
li= link_to "Contact", "#contact"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
doctype html
|
2
|
+
html lang="en"
|
3
|
+
meta charset="utf-8"
|
4
|
+
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
5
|
+
title= content_for?(:title) ? yield(:title) : "<%= app_name %>"
|
6
|
+
= stylesheet_link_tag "<%= layout_name %>"
|
7
|
+
= csrf_meta_tags
|
8
|
+
|
9
|
+
body
|
10
|
+
= render 'header'
|
11
|
+
|
12
|
+
.<%= container %>
|
13
|
+
= render 'layouts/flash'
|
14
|
+
= yield
|
15
|
+
= render 'footer'
|
16
|
+
|
17
|
+
= javascript_include_tag "<%= layout_name %>"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rails/generators/erb/scaffold/scaffold_generator'
|
2
|
+
|
3
|
+
module Slim
|
4
|
+
module Generators
|
5
|
+
class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def copy_view_files
|
9
|
+
available_views.each do |view|
|
10
|
+
# filename = filename_with_extensions view
|
11
|
+
# template "#{view}.html.slim", File.join('app', 'views', controller_file_path, filename)
|
12
|
+
install_template view, view
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_form_file
|
17
|
+
filename = defined?(SimpleForm) ? 'simpleform_form' : 'plain_form'
|
18
|
+
install_template filename, "_form"
|
19
|
+
end
|
20
|
+
|
21
|
+
def copy_scaffold_stylesheet
|
22
|
+
ext = Rails.application.config.generators.options[:rails][:stylesheet_engine] || :sass
|
23
|
+
copy_file "scaffolds.css.#{ext}", "app/assets/stylesheets/scaffolds.css.#{ext}"
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def install_template(view, filename)
|
29
|
+
filename = filename_with_extensions filename
|
30
|
+
template "#{view}.html.slim", File.join('app', 'views', controller_file_path, filename)
|
31
|
+
end
|
32
|
+
|
33
|
+
def available_views
|
34
|
+
%w(index edit show new)
|
35
|
+
end
|
36
|
+
|
37
|
+
def handler
|
38
|
+
:slim
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
h1 Listing <%= plural_table_name %>
|
2
|
+
|
3
|
+
.well= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, class: 'btn btn-primary'
|
4
|
+
|
5
|
+
table.table.table-bordered.table-striped.listing
|
6
|
+
thead
|
7
|
+
tr
|
8
|
+
th #
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
|
+
th <%= attribute.human_name %>
|
11
|
+
<% end -%>
|
12
|
+
th
|
13
|
+
|
14
|
+
tbody
|
15
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
16
|
+
tr
|
17
|
+
td= <%= singular_table_name %>.id
|
18
|
+
<% attributes.each do |attribute| -%>
|
19
|
+
td= <%= singular_table_name %>.<%= attribute.name %>
|
20
|
+
<% end -%>
|
21
|
+
td
|
22
|
+
.btn-group.pull-right
|
23
|
+
= link_to 'Show', <%= singular_table_name %>, class: 'btn'
|
24
|
+
= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'btn'
|
25
|
+
= link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete, class: 'btn'
|
26
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
= form_for @<%= singular_table_name %> do |f|
|
2
|
+
- if @<%= singular_table_name %>.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
h2 = "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
|
5
|
+
ul
|
6
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |message|
|
7
|
+
li = message
|
8
|
+
|
9
|
+
<% attributes.each do |attribute| -%>
|
10
|
+
.field
|
11
|
+
= f.label :<%= attribute.name %>
|
12
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
13
|
+
<% end -%>
|
14
|
+
.form-actions
|
15
|
+
= f.submit 'Save'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
form.simple_form {
|
2
|
+
.alert p.error_notification {
|
3
|
+
margin-bottom: 0;
|
4
|
+
}
|
5
|
+
|
6
|
+
.form-actions {
|
7
|
+
height: 30px;
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
.form-actions {
|
12
|
+
input, a {
|
13
|
+
margin-right: 5px;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
table.listing {
|
18
|
+
tbody td {
|
19
|
+
vertical-align: middle;
|
20
|
+
}
|
21
|
+
}
|