Class: Precious::App

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/gollum/frontend/app.rb

Direct Known Subclasses

IndexApp

Instance Method Summary collapse

Instance Method Details

#show_page_or_file(*names) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/gollum/frontend/app.rb', line 74

def show_page_or_file(*names)
  ps = names.collect do |name|
    wiki = Gollum::Wiki.new(settings.roots[request.script_name][:gollum_path], settings.roots[request.script_name][:wiki_options])
    if page = wiki.page(name)
      @page = page
      @name = name
      @content = page.formatted_data
      @base_path = wiki.base_path
      @rtfm_root = settings.roots[request.script_name][:wiki_options][:rtfm_root]
      mustache :page
    elsif file = wiki.file(name)
      content_type file.mime_type
      file.raw_data
    else
      nil
    end
  end.select {|p| p}

  ps.empty? ? nil : ps.first
end