This file is indexed.

/usr/share/doc/ruby-ramaze/examples/app/wiktacular/src/model.rb is in ruby-ramaze 2012.12.08-3.

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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
require 'fileutils'
require 'cgi'

class WikiEntry
  ENTRIES_DIR = __DIR__('../mkd')

  class << self
    def [](name)
      if File.exist?(File.join(ENTRIES_DIR, File.basename(File.expand_path(name))))
        new(name)
      end
    end

    def titles
      Dir[File.join(ENTRIES_DIR,'*')].entries
    end
  end

  include Ramaze::Helper::CGI

  attr_reader :history, :current, :name

  def initialize(name)
    # avoid tampering with the path
    @name = File.basename(File.expand_path(name))
    update
  end

  def update
    @current = "#{base}/current.mkd"
    @history = Dir["#{base}/*_*.mkd"]
  end

  def save(newtext)
    FileUtils.mkdir_p(base)

    if content != newtext
      history_name = "#{base}/#{timestamp}.mkd"
      FileUtils.mv(@current, history_name) if exists?
      File.open(@current, "w+"){|fp| fp.print(newtext) }
    end
  end

  def rename to
    FileUtils.mv(base, "mkd/#{to}")
  end

  def delete
    FileUtils.rm_rf(base) if exists?
  end

  def revert
    return if not exists? or @history.empty?
    FileUtils.mv(@current, @current + ".bak")
    FileUtils.mv(@history.last, @current) unless @history.empty?
    update
  end

  def unrevert
    bakfile = @current + '.bak'
    return unless File.exists?(bakfile)
    FileUtils.mv(bakfile, @current)
    update
  end

  def exists?
    File.exists?(@current)
  end

  def base
    File.join(ENTRIES_DIR, @name)
  end

  def route
    MainController.route(:index, name)
  end

  def content
    CGI.unescapeHTML(File.read(@current)) if exists?
  end

  def timestamp
    Time.now.strftime("%Y-%m-%d_%H-%M-%S")
  end

  def escape_path(path)
    File.basename(File.expand_path(path))
  end
end

class EntryView
  class << self
    def render content
      mkd2html(content || "No Entry")
    end

    def mkd2html(text)
      html = BlueCloth.new(text).to_html

      html.gsub!(/\[\[(.*?)\]\]/) do
        name = $1

        if entry = WikiEntry[name]
          exists = 'exists'
          route = entry.route
        else
          exists = 'nonexists'
          route = MainController.route(:index, name)
        end

        title = Rack::Utils.escape_html(name)
        "<a href='#{route}' class='#{exists}'>#{title}</a>"
      end

      html
    end
  end
end