Sha256: 0ce86e7beac96fec68b2f4c9435f20e381cd0317f2007da54b1919c043b9af5f

Contents?: true

Size: 889 Bytes

Versions: 9

Compression:

Stored size: 889 Bytes

Contents

# frozen_string_literal: true
module Blacklight
  class Assets < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)
  
    def assets
      copy_file "blacklight.scss", "app/assets/stylesheets/blacklight.scss"

      return if has_blacklight_assets?

      marker = if turbolinks?
                 '//= require turbolinks'
               else
                 '//= require jquery_ujs'
               end

      insert_into_file "app/assets/javascripts/application.js", :after => marker do
<<-EOF
//
// Required by Blacklight
//= require blacklight/blacklight
EOF
      end

    end

    private

    def turbolinks?
      @turbolinks ||= IO.read("app/assets/javascripts/application.js").include?('turbolinks')
    end

    def has_blacklight_assets?
      IO.read("app/assets/javascripts/application.js").include?('blacklight/blacklight')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-6.5.0 lib/generators/blacklight/assets_generator.rb
blacklight-6.4.2 lib/generators/blacklight/assets_generator.rb
blacklight-6.4.1 lib/generators/blacklight/assets_generator.rb
blacklight-6.4.0 lib/generators/blacklight/assets_generator.rb
blacklight-6.3.3 lib/generators/blacklight/assets_generator.rb
blacklight-6.3.1 lib/generators/blacklight/assets_generator.rb
blacklight-6.3.0 lib/generators/blacklight/assets_generator.rb
blacklight-6.2.0 lib/generators/blacklight/assets_generator.rb
blacklight-6.1.0 lib/generators/blacklight/assets_generator.rb