Virtual Domains 0.6 Routing problems

I’m having trouble using virtual domains 0.6. I believe that is the
version that has been updated for the radiant .6 candidate. I am able to
specify the slug of a default page that I want any requests forwarded to
the radiant installation to go to. However nothing else seems to work.
Upon inserting a debugging block of code in the installation and running
all sorts of inspections on the “@hostname ||=
Page.request.respond_to?(:host) ? Page.request.host : nil” it always
returns nil. @hostname is always nil

On Apr 20, 2007, at 4:55 PM, Mathieu Lue wrote:

returns nil. @hostname is always nil
Is Page.request set to anything? If not, it means that the
CacheByDomain module isn’t being loaded properly, or the show_page
method is being overridden by something else.

If it is, then the request doesn’t have any host information which is
just odd.

~~ Brian

Hi,

I had the same problem when I installed virtual domain extension (ver.
1.1) some days ago. I solved it by this patch.

— virtual_domain_extension.rb.orig 2007-04-21 21:28:32.000000000
+0900
+++ virtual_domain_extension.rb 2007-04-21 21:37:23.000000000 +0900
@@ -8,7 +8,13 @@
def activate
Page.send :mattr_accessor, :request
require_dependency ‘application’

  • SiteController.send :alias_method, :show_page_orig, :show_page
  • SiteController.send :remove_method, :show_page
    SiteController.send :include, CacheByDomain
    VirtualDomainPage
    end
  • def deactivate
  • SiteController.send :alias_method, :show_page, :show_page_orig
  • end
    end

This removes the method SiteController#show_page before SiteController
includes CacheByDomain, because Ruby’s Mix-in is realised by inserting
a module into class inheritance relation.(SiteController >
CacheByDomain > ApplicationController > …) I think @hostname is
always nil when SiteController#show_page is not removed.(because
CacheByDomain#show_page is not called but original
SiteController#show_page, and Page.request is setted by
CacheByDomain#show_page) This patch works fine in my environment.


Keita Y.

2007/4/21, Brian G. [email protected]:

On Apr 21, 2007, at 9:23 AM, keita wrote:

Hi,

I had the same problem when I installed virtual domain extension (ver.
1.1) some days ago. I solved it by this patch.

Thank you very much. I will apply this patch and put out 1.2, which
should be available soon at:

http://silverinsanity.com/~benji/radiant/virtual_domain-1.2.tar.gz

~~ Brian

Sorry, I forgot remove the method SiteController#show_uncached_page.

— virtual_domain_extension.rb.orig 2007-04-22 00:34:57.000000000
+0900
+++ virtual_domain_extension.rb 2007-04-22 00:43:58.000000000 +0900
@@ -10,12 +10,15 @@
Page.send :mattr_accessor, :request
require_dependency ‘application’
SiteController.send :alias_method, :show_page_orig, :show_page

  • SiteController.send :alias_method, :show_uncached_page_orig,
    :show_uncached_page
    SiteController.send :remove_method, :show_page
  • SiteController.send :remove_method, :show_uncached_page
    SiteController.send :include, CacheByDomain
    VirtualDomainPage
    end

def deactivate
SiteController.send :alias_method, :show_page, :show_page_orig

  • SiteController.send :alias_method, :show_uncached_page,
    :show_uncached_page_orig
    end
    end

Keita Y.

2007/4/21, Brian G. [email protected]:

Thanks alot guys. 1.2.1 works like a breeze. The only question I have no
is that since the “:” character is used to delimit the domain name from
the slug, is there anyway to forward domains with a specified port? I
tried x.y.com:3003: and it didn’t work. I totally don’t need this
functionality but I was just curious.

On Apr 21, 2007, at 12:41 PM, Mathieu Lue wrote:

Thanks alot guys. 1.2.1 works like a breeze. The only question I
have no
is that since the “:” character is used to delimit the domain name
from
the slug, is there anyway to forward domains with a specified port? I
tried x.y.com:3003: and it didn’t work. I totally don’t need
this
functionality but I was just curious.

As written, it only distinguishes based on the host and completely
ignores the port. So, if you only have one Radiant instance on
x.y.com, then it doesn’t matter what port. If you want x.y.com:3003
and x.y.com:80 to be different “domains”, you’ll need to poke through
the code to change request.host to request.host_with_port.

And to add it to the YAML config, you’d do something like:

x.y.com:3003” : slug1

~~ Brian

On Apr 21, 2007, at 11:48 AM, keita wrote:

Sorry, I forgot remove the method SiteController#show_uncached_page.

I should have caught that myself. 1.2.1 will appear soon.

~~ Brian