diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4040c6c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.gem +.bundle +Gemfile.lock +pkg/* diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..53c6a4ce --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "http://rubygems.org" + +# Specify your gem's dependencies in twitter-bootstrap-rails.gemspec +gemspec +gem 'less-rails', :path => ENV['LESS_RAILS_PATH'] if ENV['LESS_RAILS_PATH'] diff --git a/README.md b/README.md new file mode 100644 index 00000000..311f4db8 --- /dev/null +++ b/README.md @@ -0,0 +1,133 @@ +# Twitter Bootstrap for Rails 3.1 Asset Pipeline +Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. +It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more. + + +twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails 3.1 Asset Pipeline + + +## Installing Gem + +Include Bootstrap in Gemfile; + + gem 'twitter-bootstrap-rails' + +or you can install from latest build; + + gem 'twitter-bootstrap-rails', :git => 'http://github.com/seyhunak/twitter-bootstrap-rails.git' + +You can run bundle from command line + + bundle install + + +## Using with Less + +Bootstrap was built with Preboot, an open-source pack of mixins and variables to be used in conjunction with Less, +a CSS preprocessor for faster and easier web development. + +## Using stylesheets with Less + +You have to require Bootstrap LESS (bootstrap.less) in your application.css + + /* + *= require bootstrap + */ + + /* Your stylesheets goes here... */ + + +Now, you can override LESS files provided by Twitter Bootstrap + + @import "bootstrap"; + + // Baseline grid + @basefont: 13px; + @baseline: 18px; + + +## Using javascripts + +You have to require Bootstrap JS (bootstrap.js) in your application.js + + //= require bootstrap + + $(document).ready(function(){ + /* Your javascripts goes here... */ + }); + + +## Using with coffeescript + +Using Twitter Bootstrap with the CoffeeScript is easy. +Just create a application.js.coffee file to /app/assets/javascripts/ folder and put lines below. + + $ -> + $("body > .topbar").scrollSpy() + $ -> + $(".tabs").tabs() + $ -> + $("a[rel=twipsy]").twipsy live: true + $ -> + $("a[rel=popover]").popover offset: 10 + $ -> + $(".topbar-wrapper").dropdown() + $ -> + $(".alert-message").alert() + $ -> + domModal = $(".modal").modal( + backdrop: true + closeOnEscape: true + ) + $(".open-modal").click -> + domModal.toggle() + + +## Using Static CSS, JS (w/o Less) + +twitter-bootstrap-rails has seperate branch (w/o Less) that just serves latest static CSS, JS files. + + You can install from latest build (from branch); + + gem 'twitter-bootstrap-rails', :git => "git://github.com/seyhunak/twitter-bootstrap-rails.git", :branch => "static" + + +## Changelog + + +## Credits +Seyhun Akyürek - seyhunak [at] gmail com + +[Follow me on Twitter](http://twitter.com/seyhunak "Twitter") + + +## Contributors & Patches + + + +## Thanks +Twitter Bootstrap +http://twitter.github.com/bootstrap + + +## License +Copyright (c) 2011 Seyhun Akyürek + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..f844006f --- /dev/null +++ b/Rakefile @@ -0,0 +1,3 @@ +require 'bundler' +Bundler::GemHelper.install_tasks + diff --git a/lib/twitter-bootstrap-rails.rb b/lib/twitter-bootstrap-rails.rb new file mode 100644 index 00000000..adb21579 --- /dev/null +++ b/lib/twitter-bootstrap-rails.rb @@ -0,0 +1,10 @@ +require 'less-rails' +require "twitter/bootstrap/rails/version" +require "twitter/bootstrap/rails/engine" + +module Twitter + module Bootstrap + module Rails + end + end +end diff --git a/lib/twitter-bootstrap-rails.rb~ b/lib/twitter-bootstrap-rails.rb~ new file mode 100644 index 00000000..aa3a2b40 --- /dev/null +++ b/lib/twitter-bootstrap-rails.rb~ @@ -0,0 +1,9 @@ +module Twitter + module Bootstrap + module Rails + end + end +end +require 'less-rails' +require "twitter/bootstrap/rails/version" +require "twitter/bootstrap/rails/engine" diff --git a/lib/twitter/bootstrap/bootstrap.rb~ b/lib/twitter/bootstrap/bootstrap.rb~ new file mode 100644 index 00000000..499af701 --- /dev/null +++ b/lib/twitter/bootstrap/bootstrap.rb~ @@ -0,0 +1,2 @@ +require "twitter/bootstrap/rails/version" +require "twitter/bootstrap/rails/engine" diff --git a/lib/twitter/bootstrap/rails/engine.rb b/lib/twitter/bootstrap/rails/engine.rb new file mode 100644 index 00000000..0b452d8c --- /dev/null +++ b/lib/twitter/bootstrap/rails/engine.rb @@ -0,0 +1,15 @@ +module Twitter + module Bootstrap + module Rails + class Engine < ::Rails::Engine + + initializer 'twitter-bootstrap-rails.setup', + :after => 'less-rails.after.load_config_initializers', + :group => :all do |app| + app.config.less.paths << File.join(config.root, 'vendor', 'toolkit') + end + + end + end + end +end diff --git a/lib/twitter/bootstrap/rails/engine.rb~ b/lib/twitter/bootstrap/rails/engine.rb~ new file mode 100644 index 00000000..7cad0b16 --- /dev/null +++ b/lib/twitter/bootstrap/rails/engine.rb~ @@ -0,0 +1,15 @@ +module Twitter + module Bootstrap + module Rails + class Engine < ::Rails::Engine + config.after_initialize do |app| + # Only run when less is installed + if app.config.try(:less) + app.config.less.paths << "#{config.root}vendor/stylesheets/bootstrap" + app.config.less.paths << "#{config.root}vendor/assets/stylesheets/bootstrap" + end + end + end + end + end +end diff --git a/lib/twitter/bootstrap/rails/version.rb b/lib/twitter/bootstrap/rails/version.rb new file mode 100644 index 00000000..ac461448 --- /dev/null +++ b/lib/twitter/bootstrap/rails/version.rb @@ -0,0 +1,8 @@ +module Twitter + module Bootstrap + module Rails + VERSION = "1.3.0" + end + end +end + diff --git a/twitter-bootstrap-rails.gemspec b/twitter-bootstrap-rails.gemspec new file mode 100644 index 00000000..fdea9c3d --- /dev/null +++ b/twitter-bootstrap-rails.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- +$:.push File.expand_path("../lib", __FILE__) +require "twitter/bootstrap/rails/version" + +Gem::Specification.new do |s| + s.name = "twitter-bootstrap-rails" + s.version = Twitter::Bootstrap::Rails::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["Seyhun Akyurek"] + s.email = ["seyhunak@gmail.com"] + s.homepage = "https://github.com/seyhunak/twitter-bootstrap-rails" + s.summary = %q{Bootstrap CSS toolkit for Rails 3.1 Asset Pipeline} + s.description = %q{twitter-bootstrap-rails project integrates Bootstrap CSS toolkit for Rails 3.1 Asset Pipeline} + + s.rubyforge_project = "twitter-bootstrap-rails" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } + s.require_paths = ["lib","vendor"] + + s.add_runtime_dependency 'less' + s.add_runtime_dependency "less-rails", "~> 2.0.1" + s.add_runtime_dependency 'railties' + s.add_runtime_dependency 'actionpack' + s.add_development_dependency "bundler" + s.add_development_dependency 'rails', '~> 3.1.1' +end + diff --git a/vendor/assets/javascripts/bootstrap.js b/vendor/assets/javascripts/bootstrap.js new file mode 100644 index 00000000..e82fcc26 --- /dev/null +++ b/vendor/assets/javascripts/bootstrap.js @@ -0,0 +1,7 @@ +//= require twitter/bootstrap/bootstrap-alerts +//= require twitter/bootstrap/bootstrap-dropdown +//= require twitter/bootstrap/bootstrap-modal +//= require twitter/bootstrap/bootstrap-twipsy +//= require twitter/bootstrap/bootstrap-popover +//= require twitter/bootstrap/bootstrap-scrollspy +//= require twitter/bootstrap/bootstrap-tabs diff --git a/vendor/assets/javascripts/bootstrap.js~ b/vendor/assets/javascripts/bootstrap.js~ new file mode 100644 index 00000000..d4d587b2 --- /dev/null +++ b/vendor/assets/javascripts/bootstrap.js~ @@ -0,0 +1,15 @@ +//= require bootstrap-alerts +//= require bootstrap-dropdown +//= require bootstrap-modal +//= require bootstrap-twipsy +//= require bootstrap-popover +//= require bootstrap-scrollspy +//= require bootstrap-tabs + +//= require twitter/bootstrap/bootstrap-alerts +//= require twitter/bootstrap/bootstrap-dropdown +//= require twitter/bootstrap/bootstrap-modal +//= require twitter/bootstrap/twipsy +//= require twitter/bootstrap/popover +//= require twitter/bootstrap/scrollspy +//= require twitter/bootstrap/tabs diff --git a/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alerts.js b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alerts.js new file mode 100644 index 00000000..d3c40be1 --- /dev/null +++ b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-alerts.js @@ -0,0 +1,104 @@ +/* ========================================================== + * bootstrap-alerts.js v1.3.0 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function( $ ){ + + /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) + * ======================================================= */ + + var transitionEnd + + $(document).ready(function () { + + $.support.transition = (function () { + var thisBody = document.body || document.documentElement + , thisStyle = thisBody.style + , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined + return support + })() + + // set CSS transition event type + if ( $.support.transition ) { + transitionEnd = "TransitionEnd" + if ( $.browser.webkit ) { + transitionEnd = "webkitTransitionEnd" + } else if ( $.browser.mozilla ) { + transitionEnd = "transitionend" + } else if ( $.browser.opera ) { + transitionEnd = "oTransitionEnd" + } + } + + }) + + /* ALERT CLASS DEFINITION + * ====================== */ + + var Alert = function ( content, selector ) { + this.$element = $(content) + .delegate(selector || '.close', 'click', this.close) + } + + Alert.prototype = { + + close: function (e) { + var $element = $(this).parent('.alert-message') + + e && e.preventDefault() + $element.removeClass('in') + + function removeElement () { + $element.remove() + } + + $.support.transition && $element.hasClass('fade') ? + $element.bind(transitionEnd, removeElement) : + removeElement() + } + + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + $.fn.alert = function ( options ) { + + if ( options === true ) { + return this.data('alert') + } + + return this.each(function () { + var $this = $(this) + + if ( typeof options == 'string' ) { + return $this.data('alert')[options]() + } + + $(this).data('alert', new Alert( this )) + + }) + } + + $(document).ready(function () { + new Alert($('body'), '.alert-message[data-alert] .close') + }) + +}( window.jQuery || window.ender ); \ No newline at end of file diff --git a/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js new file mode 100644 index 00000000..ab761860 --- /dev/null +++ b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-dropdown.js @@ -0,0 +1,50 @@ +/* ============================================================ + * bootstrap-dropdown.js v1.3.0 + * http://twitter.github.com/bootstrap/javascript.html#dropdown + * ============================================================ + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function( $ ){ + + var d = 'a.menu, .dropdown-toggle' + + function clearMenus() { + $(d).parent('li').removeClass('open') + } + + $(function () { + $('html').bind("click", clearMenus) + $('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' ) + }) + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + $.fn.dropdown = function ( selector ) { + return this.each(function () { + $(this).delegate(selector || d, 'click', function (e) { + var li = $(this).parent('li') + , isActive = li.hasClass('open') + + clearMenus() + !isActive && li.toggleClass('open') + return false + }) + }) + } + +}( window.jQuery || window.ender ); \ No newline at end of file diff --git a/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js new file mode 100644 index 00000000..75fecafb --- /dev/null +++ b/vendor/assets/javascripts/twitter/bootstrap/bootstrap-modal.js @@ -0,0 +1,238 @@ +/* ========================================================= + * bootstrap-modal.js v1.3.0 + * http://twitter.github.com/bootstrap/javascript.html#modal + * ========================================================= + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + + +!function( $ ){ + + /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) + * ======================================================= */ + + var transitionEnd + + $(document).ready(function () { + + $.support.transition = (function () { + var thisBody = document.body || document.documentElement + , thisStyle = thisBody.style + , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined + return support + })() + + // set CSS transition event type + if ( $.support.transition ) { + transitionEnd = "TransitionEnd" + if ( $.browser.webkit ) { + transitionEnd = "webkitTransitionEnd" + } else if ( $.browser.mozilla ) { + transitionEnd = "transitionend" + } else if ( $.browser.opera ) { + transitionEnd = "oTransitionEnd" + } + } + + }) + + + /* MODAL PUBLIC CLASS DEFINITION + * ============================= */ + + var Modal = function ( content, options ) { + this.settings = $.extend({}, $.fn.modal.defaults) + this.$element = $(content) + .delegate('.close', 'click.modal', $.proxy(this.hide, this)) + + if ( options ) { + $.extend( this.settings, options ) + + if ( options.show ) { + this.show() + } + } + + return this + } + + Modal.prototype = { + + toggle: function () { + return this[!this.isShown ? 'show' : 'hide']() + } + + , show: function () { + var that = this + this.isShown = true + this.$element.trigger('show') + + escape.call(this) + backdrop.call(this, function () { + that.$element + .appendTo(document.body) + .show() + + if ($.support.transition && that.$element.hasClass('fade')) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .trigger('shown') + }) + + return this + } + + , hide: function (e) { + e && e.preventDefault() + + var that = this + this.isShown = false + + escape.call(this) + + this.$element + .trigger('hide') + .removeClass('in') + + function removeElement () { + that.$element + .hide() + .trigger('hidden') + + backdrop.call(that) + } + + $.support.transition && this.$element.hasClass('fade') ? + this.$element.one(transitionEnd, removeElement) : + removeElement() + + return this + } + + } + + + /* MODAL PRIVATE METHODS + * ===================== */ + + function backdrop ( callback ) { + var that = this + , animate = this.$element.hasClass('fade') ? 'fade' : '' + if ( this.isShown && this.settings.backdrop ) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $('