This file is indexed.

/usr/lib/ruby/vendor_ruby/innate/helper/link.rb is in ruby-innate 2013.02.21-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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
module Innate
  module Helper
    module Link
      def self.included(into)
        into.extend(self)
      end

      # Provide the path to given Node and actions.
      # Escapes GET parameters.
      #
      # Usage, mapping is Pages => '/', Users => '/users':
      #
      #   Pages.r                       # => URI('/')
      #   Pages.r(:foo)                 # => URI('/foo')
      #   Pages.r(:foo, :bar)           # => URI('/foo/bar')
      #   Pages.r(:foo, :a => :b)       # => URI('/foo?a=b')
      #   Pages.r(:foo, :bar, :a => :b) # => URI('/foo/bar?a=b')
      #
      #   Users.r                       # => URI('/users/')
      #   Users.r(:foo)                 # => URI('/users/foo')
      #   Users.r(:foo, :bar)           # => URI('/users/foo/bar')
      #   Users.r(:foo, :a => :b)       # => URI('/users/foo?a=b')
      #   Users.r(:foo, :bar, :a => :b) # => URI('/users/foo/bar?a=b')
      #
      # @return [URI] to the location
      def route(name = '/', *args)
        hash = {}
        hashes, names = args.partition{|arg| arg.respond_to?(:merge!) }
        hashes.each{|to_merge| hash.merge!(to_merge) }

        name = name.to_s.gsub(/__/, '/')

        location = route_location(self)
        front = Array[location, name, *names.map{|element|
          Rack::Utils.escape(element) }].join('/').squeeze('/')

        return URI(front) if hash.empty?

        query = Rack::Utils.build_query(hash)
        URI("#{front}?#{query}")
      end
      alias r route

      def route_location(klass)
        prefix = Innate.options.prefix
        location = Innate.to(klass) || Innate.to(klass.class)
        [prefix, location].join('/')
      end

      # Create a route to the currently active Node.
      #
      # This method is mostly here in case you include this helper elsewhere
      # and don't want (or can't) type SomeNode.r all the time.
      #
      # The usage is identical with {Innate::Helper::Link#route}.
      #
      # @param [#to_s] name
      # @return [URI] to the location
      # @see Ramaze::Helper::Link#route
      # @author manveru
      def route_self(name = '/', *args)
        Current.action.node.route(name, *args)
      end
      alias rs route_self

      # Create a link tag
      #
      # Usage, given Wiki is mapped to `/wiki`:
      #
      #   Wiki.a(:home)                   # => '<a href="/wiki/home">home</a>'
      #   Wiki.a('home', :home)           # => '<a href="/wiki/home">home</a>'
      #   Wiki.a('home', :/)              # => '<a href="/wiki/">home</a>'
      #   Wiki.a('foo', :/, :foo => :bar) # => '<a href="/wiki/?foo=bar">foo</a>'
      #   Wiki.a('example', 'http://example.com')
      #   # => '<a href="http://example.com">example</a>'
      #
      # @return [String]
      def anchor(text, *args)
        case first = (args.first || text)
        when URI
          href = first.to_s
        when /^\w+:\/\//
          uri       = URI(first)
          uri.query = Rack::Utils.escape_html(uri.query) if uri.query
          href      = uri.to_s
        else
          href = args.empty? ? r(text) : r(*args)
        end

        text = Rack::Utils.escape_html(text)
        %(<a href="#{href}">#{text}</a>)
      end
      alias a anchor
    end
  end
end