Skip to content

Instantly share code, notes, and snippets.

@k2052
Created April 12, 2012 02:29
Show Gist options
  • Save k2052/2364314 to your computer and use it in GitHub Desktop.
Save k2052/2364314 to your computer and use it in GitHub Desktop.
An insight into how my mind works.
Customdomains.controllers :items do
# alright lets say we do this
get :show, :maps => ['/portfolios/:slug/items/:slug', '/items/:slug'] do
end
# No need to worry about portfolioes/:id because that wont be accessed via domain.
# The only problem then is determining url_for
# We could simply default to the first path [0] and in url_for do url_for(:items, :show, :map => 1)
# The only thing to solve then is nested routes
# Remeber all we probably have to do is an each and map the action to each path
# If map determination is method in url_for then call it voilla,
# So we can hook method that checks for user_domain. if there is one then the second path.
# So this is the main solution. Now what about permissions use cases.
# Say you have a private site accessible via custom_domain or path.
# I guess we determine by session either way. So no issues? I think we're good.
# FINALLY!
# get '127.0.0.1/bob' do
# end
# get :show, map_to_or_host() do
# # we could to mount to / and just pass
# # but then how do we deal the rest of the routes.
# # god damnit middleware is needed?
# puts 'hey'
# end
#
#
# # Okay lets think about this we can abastra away the need git the domain/item
# # We just need the correct path
# # Ultimately we need to just dynamically match. So first how do we get the route information?
# # We cant have an alias that returns true.
# # We have a user_domain helper that can do that.
# # So in other words we need a path check funcitonality.
#
# # Think of the follow
#
# get :index, :maps => [{:map => '/portfolio', :if => }]
#
# # No wait this is stupid maps refer to request paths so all we need is a map that is absolute
# get :index, :map => '/portfolios/:id/items/:slug', :domain_map => 'http://user_domain/items/:slug'
#
# # Ideally it take place on a controller basis.
#
#
# # Something like a fallback map?
#
# if map elseif domain_map
#
# before do
# if user_domain
# @portfolio = Portfolio.find_by_domain(request.host.downcase)
# elsif params[:slug]
# @portfolio = Portfolio.find_by_slug(params[:slug])
# end
# end
#
# # Say I've this
# get :show, :map => "/porfolios/:id" do
# respond(@portfolio)
# end
#
# # And I want to it also match
# get :show, :map => "/porfolios/:id", match_if_host?(user_domain) do
# end
#
# # I think ultimately the router adds a host to this
# # So lets try dumping the router.
#
# # Now items would normally be scoped lie this
# get :show, :map => "/portfolios/:slug/items/:id" do
# end
#
# # But wee need them to mounted to the domain lik so
# get :show, :map => "/domain/items/:id" do
# end
#
# # We can handle this it two ways.
#
# # 1. two seperate maps
# get :show, :map => "/portfolios/:slug/items/:id", :map => "http::/user_domain/items/:id" do
# end
#
# # 2. Somehow treat the mount as a domain
# # So we'd mount the controller to either /portfolios or http::/user_domain and then in the controller just leave that out
# # of the map. This is the most transparent. But how do we handle on the fly mounting?
# get :show, :map => "/items/:id" do
# end
#
# # Ultimately i'd like to do something like
# # Where userdomain would return a true or false if mounted correctly.
# Customdomains.controllers :portfolios, :map => "/portfolios/:id", :map => user_domain do
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment