Minimal working frontend.

This commit is contained in:
Tom Preston-Werner
2010-07-07 00:29:51 -07:00
parent b770089da2
commit 2e49f2c9e7
37 changed files with 325 additions and 20 deletions
+62
View File
@@ -0,0 +1,62 @@
require 'rubygems'
require 'sinatra'
require 'gollum'
require 'mustache/sinatra'
require 'gollum/frontend/views/layout'
$path = "~/dev/mojombo/gollum/test/examples/lotr.git"
module Precious
class App < Sinatra::Base
register Mustache::Sinatra
dir = File.dirname(File.expand_path(__FILE__))
# We want to serve public assets for now
set :public, "#{dir}/public"
set :static, true
set :mustache, {
# Tell mustache where the Views constant lives
:namespace => Precious,
# Mustache templates live here
:templates => "#{dir}/templates",
# Tell mustache where the views are
:views => "#{dir}/views"
}
# Sinatra error handling
configure :development, :staging do
set :raise_errors, false
set :show_exceptions, true
set :dump_errors, true
set :clean_trace, false
end
get '/' do
show_page_or_file('Home')
end
get '/*' do
show_page_or_file(params[:splat].first)
end
def show_page_or_file(name)
wiki = Gollum::Wiki.new($path)
if page = wiki.page(name)
@content = page.formatted_data
mustache :page
elsif file = wiki.file(name)
file.raw_data
else
halt 404
end
end
end
end
Precious::App.run!