module Sinatra::Index

Public Class Methods

registered(app) click to toggle source
# 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

Public Instance Methods

use_static_index(*args)
Alias for: use_static_indices
use_static_indices(*args) click to toggle source
# File lib/j1_app/sinatra/extras/index.rb, line 25
def use_static_indices(*args)
  static_indices.concat(args.flatten)
end
Also aliased as: use_static_index