From 9395b268bedd22ad85ceee293fa94a5e0f21fe14 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 3 Jun 2013 13:23:43 -0700 Subject: [PATCH] Add helper for webalizer stats --- app.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app.rb b/app.rb index cfaa0190..c032a1d8 100644 --- a/app.rb +++ b/app.rb @@ -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