Forum OpenACS Development: Extending acs-subsite

Collapse
Posted by Lee Denison on
It seems to be pretty common practice for a site to customise acs-subsite to do stuff like add extended user information, modify the user registration pages, partition the users and create a users home page.

This got me to thinking that it would be great if any package, eg. a project manager, which glued other packages together was able to act as a subsite.  So I started wondering whether it would be possible to 'extend' acs-subsite (ie. inherit and override its behaviour)...  or in some other way create an independent package that would customise the behaviour of acs-subsite.

Much of the acs-subsite ui has been made available as re-usable components in the lib directory...  so creating a package which extends its pages should be straight forward... are there other parts of acs-subsite which would be hard to extend and override?

Collapse
2: Re: Extending acs-subsite (response to 1)
Posted by Lee Denison on
Thinking about this, much of what I need could be acheived if the acs-subsite package could be treated as a service by other applications instead of an application.

The only real stumbling block I can see is that subsite::get looks up the parent subsite info by searching for a package with a package_key equal to 'acs-subsite'.  Is there any reason why modifying subsite::get, so that packages other than acs-subsite could register themselves as valid subsites, would be bad?

(a couple of other places in the code use site_node_closest_ancestor_package "acs-subsite" explicitly but not many)

Collapse
3: Re: Extending acs-subsite (response to 1)
Posted by Dave Bauer on
One idea I had was to create a parameter to specify a file to internally redirect to for requests under acs-subsite.

Using this the requests would be redirected to an index.vuh page. This way edit-this-page or a CMS could handle requests under acs-subsite without moving files around.

Collapse
4: Re: Extending acs-subsite (response to 3)
Posted by Randy O'Meara on
Dave,

It's there in acs-subsite. At least in 5.0: IndexRedirectUrl

Randy

Collapse
5: Re: Extending acs-subsite (response to 1)
Posted by Dave Bauer on
Randy,

That is not quite it. That does an ad_returnredirect and causes the vistior's browser to request a different URL.

The idea I have is to internally redirect requests. This way, a package can appear to be mounted at the same place as an instance of acs-subsite.

Effectively it is the same as symlinking in the index.vuh from edit-this-page in the pageroot.

Collapse
6: Re: Extending acs-subsite (response to 5)
Posted by Randy O'Meara on
Ahhh. I see. Is there a good reason (a pro) to performing the browser redirect over an internal redirect? Maybe the existing mechanism could be changed to do an internal redirect?

Alternately, the existing code could be made to discern an internal redirect if the value of this parameter (say) began with "//" (double slash), or some other syntax.

Collapse
8: Re: Extending acs-subsite (response to 1)
Posted by Tom Ayles on
The problem with using an internal redirect to some page instead of a browser redirect is that relative URLs will be interpreted wrongly - the browser is unaware of the real location of the page. So if you do an internal redirect to some-package/index from the acs-subsite index, and some-package/index contains a link to some-package/one?id=111, following that link will cause the browser to request the page 'one?id=111' from the acs-subsite package. Which doesn't exist.

I think the result of this is that a simple internal redirect (to a page) won't do the trick, and some clever use of a VUH is required. I guess you _could_ have an index.vuh in acs-subsite to handle the internal redirects to some other package, but as VUH's are last in the request processor pecking order, any pages still in acs-subsite's www directory would take precedence.

Collapse
7: Re: Extending acs-subsite (response to 1)
Posted by Lee Denison on
I seem to have it working.  I modified acs-subsite tcl procs so that it has a mechanism for packages to register themselves as subsites; which means subsite::get and [ad_conn subsite_id] will return more than packages with a package key value of acs-subsite.

I copied the subsite parameters I needed from the acs-subsite.info file and added 'after-install' and 'before-uninstall' callbacks which register my package as a subsite.  I also added 'after-mount' and 'before-uninstantiate' package callbacks which create an application group for my package - mirroring acs-subsite.

I swapped my package on to the root of the site and it just worked.  I guess I never realised that using a different package on the root of the site would be so trouble free...

Collapse
9: Re: Extending acs-subsite (response to 1)
Posted by Dave Bauer on
Lee,

Very interesting.

I also had the idea to have another package pretend to be acs-subsite in the context of dotLRN, so that packages under a class would be able to calculate the class home by using the same procedures as if they were mounted under a subsite.

Your experiments seems to support this idea.

What do you do about the user pages under acs-subsite?

Collapse
10: Re: Extending acs-subsite (response to 1)
Posted by Dave Bauer on
Maybe one way is to use the opposite of my redirect idea. That is, is a page is requested for /users/* and that page doesn't exist under the subsite replacement, fall back to acs-subsite.

This way for the majority of requests no redirect would occur.

Collapse
11: Re: Extending acs-subsite (response to 1)
Posted by Lee Denison on
Redirecting back to acs-subsite would be useful for stuff like the sitemap and 'shared' pages definately.  The user pages in particular are often very light wrappers around reusable includes in acs-subsite/lib so for most of those I'll probably copy and modify the wrappers.
Collapse
12: Re: Extending acs-subsite (response to 1)
Posted by Lee Denison on
Dave,

It's interesting that you mention dotLRN because I was thinking about the way dotLRN works when I decided that being able to replace acs-subsite might be a good idea.  It occured to me that a lot of the glue that dotLRN provides to the other packages could be the kind of thing that subsite replacement packages should be providing.  I've no idea what the common elements are right now but it seems like there should be some kind of standard contract there...

Collapse
13: Re: Extending acs-subsite (response to 1)
Posted by Dave Bauer on
Lee,

Really some of the "glue" in dotLRN should make it back into acs-subsite. I definitely want to be able to serve pages from a CMS but use the community features of acs-subsite.

Collapse
14: Re: Extending acs-subsite (response to 1)
Posted by Don Baccus on
At Copenhagen we talked about extending acs-subsite to optionally return a user portal page (which .LRN does), a standard index page like now, and other options (a CMS page ala ETP would be an obvious extension).

This would allow for some easy customization of acs-subsite through choosing options at the web UI level.

Collapse
Posted by Lee Denison on
Don,

Those would be good extensions to cover of a few of the most common customisations which would only require configuration through the ui.  But having the subsite api explicitly support developers who want their own package to act as a subsite would be a great way to allow more complete customisation right?