Module: Sinatra::Index

Defined in:
lib/j1_app/sinatra/extras/index.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/j1_app/sinatra/extras/index.rb', line 7

def self.registered(app)
  app.set :static_indices, []
  app.before do
    if app.static? && (request.get? || request.head?)
      orig_path = request.path_info
      path = unescape orig_path
      path = path << '/' unless path.end_with? '/'

      app.static_indices.each do |idx|
        request.path_info = path + idx
        static!
      end

      request.path_info = orig_path
    end
  end
end

Instance Method Details

#use_static_indices(*args) ⇒ Object Also known as: use_static_index



25
26
27
# File 'lib/j1_app/sinatra/extras/index.rb', line 25

def use_static_indices(*args)
  static_indices.concat(args.flatten)
end