Add helper for webalizer stats

This commit is contained in:
Kyle Drake 2013-06-03 13:23:43 -07:00
parent 31afc3f364
commit 9395b268be

19
app.rb
View file

@ -6,8 +6,9 @@ use Rack::Session::Cookie, key: 'neocities',
secret: $config['session_secret']
get %r{.+} do
pass if request.host == '127.0.0.1'
subname = request.host.match /[\w-]+/
pass if subname.nil?
pass if subname.nil?
subname = subname.to_s
pass if subname == 'www' || subname == 'neocities' || subname == 'testneocities'
@ -90,6 +91,22 @@ get '/signout' do
redirect '/'
end
# Helper routes to get webalizer stats working, not used by anything important
get '/sites/:name' do
sites_name_redirect
end
get '/sites/:name/:file' do
sites_name_redirect
end
def sites_name_redirect
path = request.path.gsub "/sites/#{params[:name]}", ''
# path += "/#{params[:file]}" unless params[:file].nil?
redirect "http://#{params[:name]}.neocities.org#{path}"
end
def dashboard_if_signed_in
redirect '/dashboard' if signed_in?
end