Sha256: 1fb1f36bc9f3a6ed531ed5efdfe253c43bedf38274b2aae1fb872891052a0749

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

require_relative "version"

module BootswatchRails
  module ActionViewExtensions
    OFFLINE = (Rails.env.development? or Rails.env.test?)

    def bootswatch_link_tag(theme = nil, options = {})
      theme ||= BootswatchRails::THEMES[BootswatchRails::DEFAULT].to_s
      return stylesheet_link_tag(theme) if !options.delete(:force) and OFFLINE
      bootswatch_url = "//maxcdn.bootstrapcdn.com/bootswatch/#{BootswatchRails::BOOTSWATCH}/#{theme}/bootstrap.min.css"
      fontawesome_url = "//maxcdn.bootstrapcdn.com/font-awesome/#{BootswatchRails::FONT_AWESOME}/css/font-awesome.min.css"
      stylesheet_link_tag(bootswatch_url) + "\n  " + stylesheet_link_tag(fontawesome_url)
    end

    def bootstrap_include_tag(options = {})
      return javascript_include_tag(:bootstrap, options) if !options.delete(:force) and OFFLINE
      bootstrap_url = "//maxcdn.bootstrapcdn.com/bootstrap/#{BootswatchRails::BOOTSTRAP}/js/bootstrap.min.js"
      [ javascript_include_tag(bootstrap_url, options),
        javascript_tag("window.jQuery || document.write(unescape('#{javascript_include_tag(:bootstrap, options).gsub('<','%3C')}'))")
      ].join("\n").html_safe
    end
  end

  class Engine < Rails::Engine
    initializer "BootswatchRails" do |app|
      ActiveSupport.on_load(:action_view) do
        include BootswatchRails::ActionViewExtensions
      end
      app.config.assets.precompile += %w(cerulean.css cosmo.css custom.css cyborg.css darkly.css flatly.css journal.css lumen.css paper.css readable.css sandstone.css simplex.css slate.css spacelab.css superhero.css united.css yeti.css)
      app.config.assets.paths << File.expand_path('../../../vendor/assets/fonts', __FILE__)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bootswatch_rails-3.3.1.1 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.1.0 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.10 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.9 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.8 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.7 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.6 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.5 lib/bootswatch_rails/engine.rb
bootswatch_rails-3.3.0.4 lib/bootswatch_rails/engine.rb