Sha256: 3a8ee21d431438fb38c9b34884ff09a1fda2d125bc70a122c4cd4cb7393ae446

Contents?: true

Size: 1.69 KB

Versions: 41

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true
module GoodJob
  class AssetsController < ActionController::Base # rubocop:disable Rails/ApplicationController
    skip_before_action :verify_authenticity_token, raise: false

    def self.js_modules
      @_js_modules ||= GoodJob::Engine.root.join("app", "assets", "good_job", "modules").children.select(&:file?).each_with_object({}) do |file, modules|
        key = File.basename(file.basename.to_s, ".js").to_sym
        modules[key] = file
      end
    end

    before_action do
      expires_in 1.year, public: true
    end

    def es_module_shims_js
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "vendor", "es_module_shims.js")
    end

    def bootstrap_css
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "vendor", "bootstrap", "bootstrap.min.css")
    end

    def bootstrap_js
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "vendor", "bootstrap", "bootstrap.bundle.min.js")
    end

    def chartjs_js
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "vendor", "chartjs", "chart.min.js")
    end

    def rails_ujs_js
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "vendor", "rails_ujs.js")
    end

    def scripts_js
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "scripts.js")
    end

    def style_css
      render file: GoodJob::Engine.root.join("app", "assets", "good_job", "style.css")
    end

    def modules_js
      module_name = params[:module].to_sym
      module_file = self.class.js_modules.fetch(module_name) { raise ActionController::RoutingError, 'Not Found' }
      render file: module_file
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
good_job-3.7.3 app/controllers/good_job/assets_controller.rb
good_job-3.7.2 app/controllers/good_job/assets_controller.rb
good_job-3.7.1 app/controllers/good_job/assets_controller.rb
good_job-3.7.0 app/controllers/good_job/assets_controller.rb
good_job-3.6.2 app/controllers/good_job/assets_controller.rb
good_job-3.6.1 app/controllers/good_job/assets_controller.rb
good_job-3.6.0 app/controllers/good_job/assets_controller.rb
good_job-3.5.1 app/controllers/good_job/assets_controller.rb
good_job-3.5.0 app/controllers/good_job/assets_controller.rb
good_job-3.4.8 app/controllers/good_job/assets_controller.rb
good_job-3.4.7 app/controllers/good_job/assets_controller.rb
good_job-3.4.6 app/controllers/good_job/assets_controller.rb
good_job-3.4.5 app/controllers/good_job/assets_controller.rb
good_job-3.4.4 app/controllers/good_job/assets_controller.rb
good_job-3.4.3 app/controllers/good_job/assets_controller.rb
good_job-3.4.2 app/controllers/good_job/assets_controller.rb
good_job-3.4.1 app/controllers/good_job/assets_controller.rb
good_job-3.4.0 app/controllers/good_job/assets_controller.rb
good_job-3.3.3 app/controllers/good_job/assets_controller.rb
good_job-3.3.2 app/controllers/good_job/assets_controller.rb