chalkers / quirky

A small yet powerful Sinatra and git powered Content Management System (CMS) - Under active development - Todos listed in quirky.rb

This URL has Read+Write access

chalkers (author)
Thu Jan 15 16:38:31 -0800 2009
commit  94dc49401738d46029138677361a12b0e81906d8
tree    3a428b13f73a8e9f729987a585d22507edef7d27
parent  32ac6a0c522da5698320143dc98cef5a08a82433
quirky / quirky.rb
100644 55 lines (42 sloc) 0.954 kb
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
QREPOSITORY_PATH = FileUtils.pwd + "/system"
%w{boot sinatra}.each {|lib| require lib}
 
#TODO Validation. Security/authentication. Branching site. Git remote adding and removing.
# => Previewing. Better error handling. Sitemap generation. Admin section.
 
before do
  
end
 
error QuirkyNotFoundException do
  throw :halt, [404, "File not found"]
end
 
helpers do
  def partial(partial, options={})
        haml partial, options.merge!(:layout => false)
  end
  
  def redirect_to(page)
    redirect "/#{page.to_s}.html"
  end
end
 
get "/" do
  redirect_to :index
end
 
get "/:name.html" do
  @page = Page.find(params[:name])
  haml :page
end
 
get "/new" do
  @page = Page.new
  haml :new
end
 
post "/" do
  redirect_to Page.save(params)
end
 
get "/update/:name.html" do
  @page = Page.find(params[:name])
  haml :update
end
 
put "/:name.html" do
  redirect_to Page.save(params)
end
 
delete "/:name.html" do
  Page.destroy(params[:name])
  redirect "/"
end