Alessio Caiazza is sharing code with you

Bitbucket is a code hosting site. Unlimited public and private repositories. Free for small teams.

Don't show this again

nolith / home_dir http://abisso.org/projects/home_dir

A RadiantCMS extension that allow you to define /~user routes like apache userdir module.

Clone this repository (size: 8.4 KB): HTTPS / SSH
hg clone https://bitbucket.org/nolith/home_dir
hg clone ssh://hg@bitbucket.org/nolith/home_dir

home_dir / home_dir_extension.rb

Tag
1.0
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'

class HomeDirExtension < Radiant::Extension
  version "1.0"
  description "Allow to redirect www.yoursite.com/~user to a specific page, like on apache userdir"
  url "http://abisso.org/projects/home_dir"
  
  define_routes do |map|
    map.connect 'admin/home_dir/:action', :controller => 'admin/homes'
    map.homes ':user', :controller => 'home_redirect', :action =>'index', 
      :requirements => { :user => /~\w{2,16}/ }
  end
  
  def activate
    admin.tabs.add "Home Dir", "/admin/home_dir", :after => "Layouts", :visibility => [:all]
    Page.send :include, HomeDirTags
  end
  
  def deactivate
    admin.tabs.remove "Home Dir"
  end
  
end