/usr/lib/ruby/vendor_ruby/simple_navigation/adapters/sinatra.rb is in ruby-simple-navigation 4.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 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 50 51 52 53 54 55 56 57 | require 'cgi'
module SimpleNavigation
module Adapters
class Sinatra < Base
def self.register(app)
SimpleNavigation.set_env(app.root, app.environment)
end
def initialize(context)
@context = context
@request = context.request
end
def context_for_eval
context || fail('no context set for evaluation the config file')
end
def request_uri
request.fullpath
end
def request_path
request.path
end
def current_page?(url)
url_string = CGI.unescape(url)
uri = if url_string.index('?')
request_uri
else
request_uri.split('?').first
end
if url_string =~ %r(^\w+://)
uri = "#{request.scheme}://#{request.host_with_port}#{uri}"
end
url_string == CGI.unescape(uri)
end
def link_to(name, url, options = {})
"<a href='#{url}'#{to_attributes(options)}>#{name}</a>"
end
def content_tag(type, content, options = {})
"<#{type}#{to_attributes(options)}>#{content}</#{type}>"
end
protected
def to_attributes(options)
options.map { |k, v| v.nil? ? '' : " #{k}='#{v}'" }.join
end
end
end
end
|