Class: Sidekiq::SprocketsMiddleware
- Inherits:
-
Object
- Object
- Sidekiq::SprocketsMiddleware
- Defined in:
- lib/sidekiq/web.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ SprocketsMiddleware
constructor
A new instance of SprocketsMiddleware.
Constructor Details
#initialize(app, options = {}) ⇒ SprocketsMiddleware
Returns a new instance of SprocketsMiddleware.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sidekiq/web.rb', line 11 def initialize(app, ={}) @app = app @root = [:root] path = [:path] || 'assets' @matcher = /^\/#{path}\/*/ @environment = ::Sprockets::Environment.new(@root) @environment.append_path 'assets/javascripts' @environment.append_path 'assets/javascripts/vendor' @environment.append_path 'assets/stylesheets' @environment.append_path 'assets/stylesheets/vendor' @environment.append_path 'assets/images' Compass.configuration do |config| config.project_path = "#{@root}/assets" config.images_dir = 'images' config.sass_dir = 'stylesheets' config.css_dir = 'stylesheets' config.javascripts_dir = 'javascripts' config.fonts_dir = 'stylesheets/fonts' config.http_images_path = '/assets' config.http_generated_images_path = '/assets' config.http_javascripts_path = '/assets' config.http_stylesheets_path = '/assets' # You can select your preferred output style here (can be overridden via the command line): output_style = :compressed # To enable relative paths to assets via compass helper functions. Uncomment: relative_assets = true # To disable debugging comments that display the original location of your selectors. Uncomment: line_comments = false end end |
Instance Method Details
#call(env) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/sidekiq/web.rb', line 51 def call(env) # Solve the problem of people requesting /sidekiq when they need to request /sidekiq/ so # that relative links in templates resolve correctly. return [301, { 'Location' => "#{env['SCRIPT_NAME']}/", 'Content-Type' => 'text/html' }, ['redirecting']] if env['SCRIPT_NAME'] == env['REQUEST_PATH'] return @app.call(env) unless @matcher =~ env["PATH_INFO"] env['PATH_INFO'].sub!(@matcher,'') @environment.call(env) end |