README.rdoc in pboling-subdomain-fu-0.3.0 vs README.rdoc in pboling-subdomain-fu-0.5.0
- old
+ new
@@ -8,15 +8,15 @@
== Installation
SubdomainFu is available both as a traditional plugin and a GemPlugin. To
install it as a traditional plugin (Rails 2.1 or later):
- script/plugin install git://github.com/pboling/subdomain-fu.git
+ script/plugin install git://github.com/mbleigh/subdomain-fu.git
To use it as a GemPlugin, add it to your environment.rb:
- config.gem 'pboling-subdomain-fu', :source => "http://gems.github.com", :lib => "subdomain-fu"
+ config.gem 'mbleigh-subdomain-fu', :source => "http://gems.github.com", :lib => "subdomain-fu"
== Examples
SubdomainFu works inside of Rails's URL Writing mechanisms to provide an easy and seamless
@@ -43,55 +43,72 @@
users_path(:subdomain => false) # => /users
In this way you can rest assured that you will never misdirect your links to the
same subdomain when you meant to change it.
+== Use in controllers and views
+
+You have access to current_subdomain and current_domain methods.
+
+current_subdomain - returns all subdomains.
+ Example for the URL http://awesome.website.stuff.example.com current_subdomain will return "awesome.website.stuff"
+
+current_domain - returns all subdomains except for the first subdomain and the domain with TLD.
+ Example for the URL http://awesome.website.stuff.example.com current_subdomain will return "website.stuff.example.com"
+
+This might appear strange at first, but the original plugin in this space was account_location,
+which had this behavior for current domain. Subdomain-fu did not use the same style as account_location
+with current_subdomain, thus the overlap. However Subdomain-fu has created a lot of utility in its implementation of
+current_subdomain, so the overlap stays!
+
+If what you really want is just the domain, then use request.domain. The purpose of current_domain is to only strip
+off the first subdomain, if any, and return what's left.
+
== Configuration
You may need to configure SubdomainFu based on your development setup. The
configuration required is:
-tld_size
---------
+=== TLD Size
A hash for each environment of the size of the top-level domain name.
(something.com = 1, localhost = 0, etc.)
SubdomainFu.tld_size = 1 # sets for current environment
SubdomainFu.tld_sizes = {:development => 0,
:test => 0,
:production => 1} # set all at once (also the defaults)
-mirrors
--------
+=== Mirrors
Mirrors are the subdomains that are equivalent to no subdomain (i.e. they 'mirror')
the usage of the root domain.
SubdomainFu.mirrors = %w(www site we) # Defaults to %w(www)
-preferred_mirror
-----------------
+=== Preferred Mirror
SubdomainFu also understands the notion of a 'preferred mirror', that is, if you
always want your links going to 'www.yourdomain.com' instead of 'yourdomain.com',
you can set the preferred mirror like so:
SubdomainFu.preferred_mirror = "www"
Now when you create a link with subdomain => false in the options the subdomain
will default to the preferred mirror.
-== Known Issues / Future Work
+== Routing
-SubdomainFu will eventually integrate with Rails' routing internals to provide
-the ability to specify routes based on the condition of a specific subdomain or
-simply whether a subdomain is present (or a mirror).
+SubdomainFu can also work within Rails' routing for subdomain-specific routes. For instance, if you only wanted your administrative tools available in the "admin" subdomain you could add this to your routes.rb file:
+ map.with_options :conditions => {:subdomain => 'admin} do |admin|
+ admin.resources :posts
+ admin.resources :users
+ end
+
== Resources
-* Acts As Community Project: http://actsascommunity.com/projects/subdomain-fu
* GitHub Repository: http://github.com/mbleigh/subdomain-fu
-* Lighthouse: http://mbleigh.lighthouseapp.com/projects/13148-subdomain-fu
+* RDocs: http://rdoc.info/projects/mbleigh/subdomain-fu
Copyright (c) 2008 Michael Bleigh (http://www.mbleigh.com/) and
Intridea, Inc. (http://www.intridea.com/). Released under the MIT license