/usr/lib/ruby/vendor_ruby/simple_navigation/adapters/nanoc.rb is in ruby-simple-navigation 3.11.0-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 | module SimpleNavigation
module Adapters
class Nanoc < Base
class << self
def register(root)
SimpleNavigation.set_env(root, 'development')
Nanoc3::Context.send(:include, SimpleNavigation::Helpers)
end
end
def initialize(ctx)
@context = ctx
end
# Returns the context in which the config files will be evaluated
def context_for_eval
context
end
# Returns true if the current request's url matches the specified url.
# Used to determine if an item should be autohighlighted.
def current_page?(url)
path = context.item.path
path && path.chop == url
end
# Returns a link with the specified name, url and options.
# Used for rendering.
def link_to(name, url, options={})
"<a href='#{url}' #{to_attributes(options)}>#{name}</a>"
end
# Returns a tag of the specified type, content and options.
# Used for rendering.
def content_tag(type, content, options={})
"<#{type} #{to_attributes(options)}>#{content}</#{type}>"
end
private
def to_attributes(options)
options.map {|k, v| v.nil? ? nil : "#{k}='#{v}'"}.compact.join(' ')
end
end
end
end
|