Sha256: dac35b07886de5a59263192f7b48596482e82bff8a4df8b93b4594cbfd24182b

Contents?: true

Size: 1.72 KB

Versions: 15

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require 'rails/generators'

module Geoblacklight
  class AssetsGenerator < Rails::Generators::Base
    source_root File.expand_path('templates', __dir__)

    desc <<-DESCRIPTION
      This generator makes the following changes to your application:
       1. Copies GBL javascript into the application
       2. Removes stock Rails and Blacklight stylesheets from the application
       3. Copies GBL stylesheets into the local application
       4. Sets asset initializer values into the local application
    DESCRIPTION

    def add_javascript
      copy_file 'assets/geoblacklight.js', 'app/assets/javascripts/geoblacklight.js'

      if Rails.version.to_i == 6
        append_to_file 'app/assets/javascripts/application.js',
                       "\n// Required by GeoBlacklight\n//= require geoblacklight"
      end
    end

    def remove_stylesheets
      remove_file 'app/assets/stylesheets/application.css'
      remove_file 'app/assets/stylesheets/blacklight.scss'
    end

    def add_stylesheets
      copy_file 'assets/application.scss', 'app/assets/stylesheets/application.scss'
      copy_file 'assets/_blacklight.scss', 'app/assets/stylesheets/_blacklight.scss'
      copy_file 'assets/_customizations.scss', 'app/assets/stylesheets/_customizations.scss'
      copy_file 'assets/_geoblacklight.scss', 'app/assets/stylesheets/_geoblacklight.scss'
    end

    def add_initializers
      append_to_file 'config/initializers/assets.rb',
                     "\nRails.application.config.assets.precompile += %w( favicon.ico )\n"

      append_to_file 'config/initializers/assets.rb',
                     "\nRails.application.config.assets.paths << Rails.root.join('vendor', 'assets', 'images')\n"
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
geoblacklight-4.0.0.pre.rc2 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-4.0.0.pre.rc1 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.6.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.5.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-4.0.0.pre.alpha.3 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-4.0.0.pre.alpha.2 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-4.0.0.pre.alpha.1 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-4.0.0.pre.alpha lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.4.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.3.1 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.3.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.2.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.1.0 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.0.1 lib/generators/geoblacklight/assets_generator.rb
geoblacklight-3.0.0 lib/generators/geoblacklight/assets_generator.rb