├── .gitignore ├── .rspec ├── lib ├── rails_bootstrap_navbar.rb ├── rails-bootstrap-navbar │ ├── version.rb │ └── railtie.rb └── rails-bootstrap-navbar.rb ├── Gemfile ├── Rakefile ├── .travis.yml ├── spec └── spec_helper.rb ├── Guardfile ├── CHANGELOG.md ├── LICENSE.txt ├── rails_bootstrap_navbar.gemspec └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format documentation 3 | -------------------------------------------------------------------------------- /lib/rails_bootstrap_navbar.rb: -------------------------------------------------------------------------------- 1 | require 'rails-bootstrap-navbar' 2 | -------------------------------------------------------------------------------- /lib/rails-bootstrap-navbar/version.rb: -------------------------------------------------------------------------------- 1 | module RailsBootstrapNavbar 2 | VERSION = '3.0.0' 3 | end 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in rails-bootstrap-navbar.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /lib/rails-bootstrap-navbar.rb: -------------------------------------------------------------------------------- 1 | require_relative 'rails-bootstrap-navbar/version' 2 | require_relative 'rails-bootstrap-navbar/railtie' if defined?(Rails) 3 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | require 'rspec/core/rake_task' 4 | 5 | RSpec::Core::RakeTask.new(:spec) 6 | task default: :spec -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.2.7 4 | - 2.3.4 5 | - 2.4.1 6 | before_install: 7 | - gem update --system 8 | - gem update bundler 9 | sudo: false 10 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rails-bootstrap-navbar' 2 | 3 | RSpec.configure do |config| 4 | config.treat_symbols_as_metadata_keys_with_true_values = true 5 | config.run_all_when_everything_filtered = true 6 | config.filter_run :focus 7 | config.order = 'random' 8 | end 9 | -------------------------------------------------------------------------------- /Guardfile: -------------------------------------------------------------------------------- 1 | guard 'rspec', cli: '--drb --profile', all_after_pass: false do 2 | # Specs 3 | watch(%r(^spec/.+_spec\.rb$)) 4 | watch('spec/spec_helper.rb') { 'spec' } 5 | watch(%r(^spec/support/(.+)\.rb$)) { 'spec' } 6 | 7 | # Files 8 | watch(%r(^lib/(.+)\.rb$)) { |m| "spec/#{m[1]}_spec.rb" } 9 | end 10 | -------------------------------------------------------------------------------- /lib/rails-bootstrap-navbar/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'bootstrap-navbar' 2 | 3 | module BootstrapNavbar::Helpers 4 | def prepare_html(html) 5 | html.html_safe 6 | end 7 | end 8 | 9 | module RailsBootstrapNavbar 10 | class Railtie < Rails::Railtie 11 | config.after_initialize do 12 | BootstrapNavbar.configure do |config| 13 | config.current_url_method = if Rails.version >= '3.2' 14 | 'request.original_url' 15 | else 16 | '[request.protocol, request.host_with_port, request.fullpath].join' 17 | end 18 | end 19 | 20 | ActionView::Base.send :include, BootstrapNavbar::Helpers 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## v0.2.1 2 | 3 | * Gem 'bootstrap_navbar' was renamed to 'bootstrap-navbar' 4 | 5 | ## v0.2.0 6 | 7 | * Use gem 'bootstrap_navbar' for HTML rendering 8 | 9 | ## v0.1.0 10 | 11 | * Initial release 12 | 13 | ## v0.1.1.beta 14 | 15 | Added 2 new methods: 16 | 17 | * drop_down_divider 18 | * drop_down_header 19 | 20 | These allow you to add dividers and headers into your dropdowns. Surprisingly enough... 21 | 22 | ## v0.1.2.beta 23 | 24 | * Allow options for menu_items to pass through to link_to, so that you can set IDs, classes, method, data-tags etc. 25 | 26 | ## v0.1.3.beta 27 | 28 | * Made the menu_text feature work properly (it was missing a css class). Also added the ability to pull it left or right. 29 | 30 | ## v0.1.4.beta 31 | 32 | * Added ability to change the link for the brand text 33 | 34 | ## v0.1.5.beta 35 | 36 | * Minor fix - make menu_item link default to "#" 37 | * Readme updates 38 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 kraut computing UG (haftungsbeschränkt) 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. 23 | -------------------------------------------------------------------------------- /rails_bootstrap_navbar.gemspec: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | lib = File.expand_path('../lib', __FILE__) 4 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 5 | 6 | require 'rails-bootstrap-navbar/version' 7 | 8 | Gem::Specification.new do |gem| 9 | gem.name = 'rails_bootstrap_navbar' 10 | gem.version = RailsBootstrapNavbar::VERSION 11 | gem.platform = Gem::Platform::RUBY 12 | gem.author = 'Manuel Meurer' 13 | gem.email = 'manuel@krautcomputing.com' 14 | gem.description = 'Easily generate a Bootstrap navbar in your Rails app' 15 | gem.summary = 'Easily generate a Bootstrap navbar in your Rails app' 16 | gem.homepage = 'http://bootstrap-ruby.github.io/rails-bootstrap-navbar' 17 | gem.license = 'MIT' 18 | 19 | gem.files = `git ls-files`.split($/) 20 | gem.executables = gem.files.grep(%r(^bin/)).map { |f| File.basename(f) } 21 | gem.test_files = gem.files.grep(%r(^(test|spec|features)/)) 22 | gem.require_paths = ['lib'] 23 | 24 | gem.add_development_dependency 'rake', '< 11.0' 25 | gem.add_development_dependency 'rspec', '~> 2.13' 26 | gem.add_development_dependency 'guard-rspec', '~> 3.0' 27 | 28 | gem.add_runtime_dependency 'bootstrap-navbar', '~> 3.0' 29 | gem.add_runtime_dependency 'rails', '>= 3.0.0' 30 | end 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rails Bootstrap Navbar 2 | 3 | [![Gem Version](https://badge.fury.io/rb/rails_bootstrap_navbar.png)](http://badge.fury.io/rb/rails_bootstrap_navbar) 4 | [![Build Status](https://secure.travis-ci.org/bootstrap-ruby/rails-bootstrap-navbar.png)](http://travis-ci.org/bootstrap-ruby/rails-bootstrap-navbar) 5 | [![Code Climate](https://codeclimate.com/github/bootstrap-ruby/rails-bootstrap-navbar.png)](https://codeclimate.com/github/bootstrap-ruby/rails-bootstrap-navbar) 6 | 7 | Easily generate a [Bootstrap](https://getbootstrap.com/) navbar in your Rails app 8 | 9 | ## Installation 10 | 11 | Add this line to your application's Gemfile: 12 | 13 | gem 'rails_bootstrap_navbar' 14 | 15 | And then execute: 16 | 17 | $ bundle 18 | 19 | Or install it yourself as: 20 | 21 | $ gem install rails_bootstrap_navbar 22 | 23 | ## Requirements 24 | 25 | The necessary files from Bootstrap >= 2.0 have to be included separately, they are not part of this gem. 26 | 27 | At least the CSS files for the navbar are required, and the JS files for dropdowns and responsive features, if you want to use those in the navbar. 28 | 29 | ## Usage 30 | 31 | ### Set Bootstrap version 32 | 33 | This gem needs to know which Bootstrap version you are using, because the navbar HTML looks different in different Bootstrap versions. 34 | 35 | If you're using either the [`bootstrap-sass`](https://github.com/twbs/bootstrap-sass) or [`bootstrap`](https://github.com/twbs/bootstrap-rubygem) gem, you're all set because the Boostrap version will be sniffed automatically from those gems' versions. Make sure to include the `bootstrap-sass` or `bootstrap` gem before `rails_bootstrap_navbar` in your Gemfile though. 36 | 37 | If you include the Bootstrap CSS and JS some other way, you need to set the Bootstrap version explicitly in an initializer: 38 | 39 | ```ruby 40 | # config/initializers/rails-bootstrap-navbar.rb 41 | 42 | BootstrapNavbar.configure do |config| 43 | config.bootstrap_version = '4.0.0' 44 | end 45 | ``` 46 | 47 | ### Output HTML 48 | 49 | The gem [bootstrap-navbar](https://github.com/bootstrap-ruby/bootstrap-navbar) is used to generate the HTML. Please refer to the gem's [README](https://github.com/bootstrap-ruby/bootstrap-navbar/blob/master/README.md) and the following Wiki entries for detailed instructions on how to generate the navbar: 50 | 51 | [Usage with Bootstrap 2](https://github.com/bootstrap-ruby/bootstrap-navbar/wiki/Usage-with-Bootstrap-2) 52 | 53 | [Usage with Bootstrap 3](https://github.com/bootstrap-ruby/bootstrap-navbar/wiki/Usage-with-Bootstrap-3) 54 | 55 | [Usage with Bootstrap 4](https://github.com/bootstrap-ruby/bootstrap-navbar/wiki/Usage-with-Bootstrap-4) 56 | 57 | ## Acknowledgements 58 | 59 | Thanks to [Jules Copeland](https://github.com/julescopeland) for the initial version of this gem! 60 | 61 | ## Contributing 62 | 63 | 1. Fork it 64 | 2. Create your feature branch (`git checkout -b my-new-feature`) 65 | 3. Commit your changes (`git commit -am 'Added some feature'`) 66 | 4. Push to the branch (`git push origin my-new-feature`) 67 | 5. Create new Pull Request 68 | 69 | ## Support 70 | 71 | If you like this project, consider [buying me a coffee](https://www.buymeacoffee.com/279lcDtbF)! :) 72 | --------------------------------------------------------------------------------