Skip to content

Commit

Permalink
Add broken out server.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
LichP committed Apr 30, 2012
1 parent 11c4987 commit ea6379a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/stewiki/server.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require File.dirname(__FILE__) + '/../stewiki'
require 'sinatra/base'

class Stewiki::Server < Sinatra::Base

set :root, File.dirname(__FILE__) + '/server'

helpers do
end

get "/" do
redirect to('/page/Home')
end

get "/page/:pagename" do
@title = params[:pagename]
@page = Stewiki::Page[params[:pagename]]
@quicklinks = Stewiki::Page["QuickLinks"]
haml :display
end

get "/edit/:pagename" do
@title = "Editing: " + params[:pagename]
@page = Stewiki::Page[params[:pagename]]
@quicklinks = Stewiki::Page["QuickLinks"]
haml :edit
end

post "/edit/:pagename" do
Stewiki::Page[params[:pagename]].update(params[:content], params[:commit_message])
redirect to("/page/" + params[:pagename])
end

get "/history/:pagename" do
@title = "History: " + params[:pagename]
@page = Stewiki::Page[params[:pagename]]
@quicklinks = Stewiki::Page["QuickLinks"]
haml :history
end
end

0 comments on commit ea6379a

Please sign in to comment.