Hi! I've been working on getting support for multi domains in Roller. I started out by making an extra servlet to handle requests to /roller/domain, but after reviewing advice from Max Rudman, I chose to follow his idea, and create a filter instead.
So now I have a version of Roller where roller is running under tomcat on port 8080, if I access localhost:8080/roller/, I get the old functionality, nothing is changed (in theory at least). In front of tomcat I have an apache-server with mod_rewrite. Apache is listening to a virtual domain (blog.testdomain.com), and translating URLs to this domain into the form localhost/roller/domain/(service)blog.testdomain.com/(handle). So blog.testdomain.com/page/testblog would is tranlated to localhost/roller/domain/page/blog.testdomain.com/testblog. In Roller I have added a ServletFilter that filters everything coming to /roller/domain/, finds the right website in an association table and forwards the request to the normal servlet in the traditional form (/roller/page/handle). In addition it creates wrappers for the request and response. The point of the wrappers is to override URLs and redirects so the user is not moved back to the main Roller-site (localhost in my development environment). So far, there has been little need to change existing Roller-code. I had to create a DomainManager to handle the new database tables and their pojo-implementations. The DomainManager needed to be added to RollerManager so it can be used like the other managers, and that's about it actually. But unfortunately the URLs generated throughout Roller are never sent through encodeURL, so they are not picked up by the wrappers. This resulted in quite a few changes in velocity macros. All these changes consists in sending the URL through pageHelper.strutsUrlHelper(). This in turn calls the encodeURL method in the wrapper. In addition, SearchServlet and *WeblogCalendarModel needed to be changed. SearchServlet needs to use another context initializer so the pageHelper object is available in the velocity scripts, WeblogCalendarModel needs to call encodeURL on the URLs they create. This enables all URLs to be rewritten to the form /roller/domain/(service)/(domain)/(handle) on the way out, so the user still thinks he is on the domain. In addition, these changes enables the use of UrlRewriteFilter in Roller, so you can do whatever magic this can do. I use UrlRewriteFilter to rewrite the /roller/domain/(service)/(domain)(handle) URLs to the more user friendly form of http://(domain)/(service)/(handle). The same thing goes for redirects, like when the user commits a comment. The redirect is picked up by the wrapper and sent through encodeURL to translate the URL to the correct form before the user is actually redirected. So what's working right now? Basically everything a normal blog reader needs, - Browsing a users blog through back, forward, calendar etc. - Reading RSS-feeds. - Searching int the site (searching all sites does not work right). - Reading comments in a blog - Writing comments in a blog - Having one Roller-website appear in more than one domain with different handles. What doesn't work? Everything domain specific except the features listed above. - Logging in sends the user to the global roller domain (ie. /roller/*) - There is no way to add domains, add websites to a domain except hacking directly in (my)SQL. What next? The features we have now is the bare minimum needed to present blogs to web surfers and have them believe that they are browsing different domains when they are actually only browsing on one server. This is useful to us in it self, but we also need a way to configure this without hacking the database directly, and we need a way to let the user log in on one domain, and administer his websites on that domain. The most important thing here is the ability to edit and write entries. So that leaves these priorities. - Adding a user interface where the administrator can add domains, and put websites into different domains. - Figure out how to enable login on one domain, and not redirect the user to the global roller domain. - At a minimum, enable editing and creation of entries on a domain. - Enable domain wide search. We are still very interested in getting these changes upstream eventually, and we are working hard not to break existing functionality or add complexity. We are thankful for the feedback we have got so far. If anybody is interested, I can make my patches available. We are currently working on Roller 2.1 stable. Once 2.2 is available we will upgrade our patches to 2.2. -- Regards, Henning Kulander System consultant Linpro AS - Norway's #1 Linux company
