diff --git a/app/controllers/node.rb b/app/controllers/node.rb index 79ee927..f150bf0 100644 --- a/app/controllers/node.rb +++ b/app/controllers/node.rb @@ -12,4 +12,16 @@ class Node < Application headers['Location'] = purl return "You are being redirected." end + + def chora + if params[:program] and params[:program] =~ /PenguinCoder|tuxwiki/i + raise NotFound + end + safe_program = params[:program].gsub(/\W/, '').downcase + gurl = "http://github.com/penguincoder/#{safe_program}" + Merb.logger.info("Permenant Chora redirect for #{safe_program}") + self.status = 301 + headers['Location'] = gurl + return "You are being redirected." + end end \ No newline at end of file diff --git a/config/router.rb b/config/router.rb index 49b50a4..980d082 100644 --- a/config/router.rb +++ b/config/router.rb @@ -1,9 +1,13 @@ Merb.logger.info("Compiling routes...") Merb::Router.prepare do |r| - r.match('/node/:id').to( + r.match('/node/(node/)?:id').to( :controller => 'node', :action => 'show' ) + r.match('/horde/chora/:phpaction.php/:program').to( + :controller => 'node', + :action => 'chora' + ) r.resources :pages r.resources :comments r.resources :tags