Skip to content
Browse files

Add config.ru and make sure static links work

  • Loading branch information...
1 parent 2f3b72e commit f2f4b8ab80b703f65f1e2bd2ba08ab4eda6db6f3 @jschementi committed
Showing with 36 additions and 2 deletions.
  1. +27 −2 app.rb
  2. +9 −0 config.ru
View
29 app.rb
@@ -30,6 +30,31 @@ def get_feed(url)
get_feed 'http://twitter.com/statuses/user_timeline/8007442.rss'
end
-get %r{/([\w|/]+)} do |c|
- redirect "/#/#{c}"
+%W{/projects /writing /music /photos /about /art /about/resume}.each do |i|
+ get i do
+ redirect "/##{i}"
+ end
end
+
+get /\/(.+)/ do |c|
+ path = File.join(File.dirname(__FILE__), 'public', c)
+ if File.exist? path
+ url = "/#{c}"
+ url = url[0..-2] if url[-1] == '/'
+ if File.directory? path
+ indexhtml = File.join(path, "index.html")
+ indexphp = File.join(path, "index.php")
+ if File.exist?(indexhtml)
+ url = "#{url}/"
+ elsif File.exist?(indexphp)
+ url = "#{url}/index.php"
+ else
+ throw :halt, [404, "Not found"]
+ end
+ end
+ redirect url
+ else
+ throw :halt, [404, "Not found"]
+ end
+end
+
View
9 config.ru
@@ -0,0 +1,9 @@
+require 'rubygems'
+require 'sinatra'
+
+set :env, :production
+disable :run
+
+require 'app'
+
+run Sinatra::Application

0 comments on commit f2f4b8a

Please sign in to comment.
Something went wrong with that request. Please try again.