Module: Sinatra::Pagin
- Defined in:
- lib/sinatra/pagin.rb
Defined Under Namespace
Modules: Helpers
Class Method Summary collapse
Class Method Details
.registered(app) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sinatra/pagin.rb', line 5 def self.registered(app) app.helpers Pagin::Helpers app.before do page_pattern = /\/page\/(\d+)(\/)?(\.[^\.\/]+)?$/ request.path_info.match(page_pattern) if $1 page $1 request.path_info = request.path_info.gsub!(page_pattern, '')+$3.to_s request.path_info.gsub!(/^(?!\/)/) { |s| "/"+s } # force the first slash if not avail end end end |