Forum OpenACS Development: Replacing home page with Xowiki instance

I have created an index.vuh that allows the home page to be managed by xowiki. It assumes the default locale and will show pages like this /index index of /xowiki/en/index. The urls will work with out without the language prefix for the default locale.

Here is the index.vuh

# -*- tcl -*-
set package_id (replace xowiki package instance here)
set folder_id (replace xowiki root folder_id here)

::xowiki::Package initialize -package_id $package_id -ad_doc {

  This is the resolver for this package. It turns a request into
  an object and executes the object with the computed method

  @author Gustaf Neumann (gustaf.neumann@wu-wien.ac.at)
  @creation-date July, 2006
  @cvs-id $Id: index.vuh,v 1.2.2.2 2006/12/11 16:52:44 compass Exp $

} -parameter {
  {-m view}
  {-folder_id:integer $folder_id}
} -url /xowiki[ad_conn url]

#ns_log Notice "HAM : 12"
#::$package_id log "--starting... [ns_conn url] [ns_conn query] \
        form vars = [ns_set array [ns_getform]]"
#::$package_id exists_form_parameter creator
#::$package_id log "-- [::xo::cc serialize]"

::$package_id reply_to_user [::$package_id invoke -method $m]

::$package_id log "--i ::$package_id DONE"
ad_script_abort

It hard codes the package_id and folder_id of the xowiki instance for now. It requires a patch to package-procs.tcl to generate the correct relative URLs
Index: package-procs.tcl
===================================================================
RCS file: /cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v
retrieving revision 1.25
diff -r1.25 package-procs.tcl
70c70,74
<       set lang [string range [lang::conn::locale -package_id [my id]] 0 1]
---
>       # DAVEB we can resolve the default language on request instead of in the links
>       #set lang [string range [lang::conn::locale -package_id [my id]] 0 1]
>     }
>     if {$lang eq [string range [lang::conn::locale -package_id [my id]] 0 1]} {
>       set lang ""
73c77
<     set host [expr {$absolute ? [ad_url] : ""}]
---
>     set host [expr {$absolute ? "[ad_url][my package_url]" : ""}]
75c79
<       return $host[my package_url]$lang/[ad_urlencode $name][expr {$anchor ne "" ? "\#${anchor}" : ""}]
---
>       return $host$lang/[ad_urlencode $name][expr {$anchor ne "" ? "\#${anchor}" : ""}]
77c81
<       return $host[my package_url][ad_urlencode $name][expr {$anchor ne "" ? "#${anchor}" : ""}]
---
>       return $host[ad_urlencode $name][expr {$anchor ne "" ? "#${anchor}" : ""}]


I think this is a good think to start with. Eventually I'd like to create a way to manage content under a subsite more cleanly, but this seems like a good compromise that works today.

I think the URL resolution might be acceptable to be added to xowiki, hopefully Gustaf can comment if what I did works as expected.

Collapse
Posted by Caroline Meeks on
BTW you can see it in action here: http://www.lnwprogram.org/

The use case that drove this work was the need for clean simple urls with out /xowiki/en

Collapse
Posted by Gustaf Neumann on
What's wrong with just using the following? all one has to adjust is the value for -url (note the trailing slash). Why is it necessary to change the package-procs?

-gustaf


# -*- tcl -*-
::xowiki::Package initialize -ad_doc {

This is a toplevel index.vuh file, intended to be
saved under .../openacs-4/www/index.vuh

The script uses an xowiki page as root page
of the site. Here, the start page is /xowiki/, the value after -url bwlow.
Replace the url, in case a different page or instance
name should be used

@author Gustaf Neumann (mailto:gustaf.neumann@wu-wien.ac.at)
@creation-date July, 2006
@cvs-id $Id: index.vuh,v 1.5 2006/09/15 16:45:00 gustafn Exp $

} -parameter {
{-m view}
{-folder_id:integer 0}
} -url /xowiki/

::$package_id reply_to_user [::$package_id invoke -method $m]
ad_script_abort

Collapse
Posted by Dave Bauer on
Gustaf

I will check out just using the URL instead of specifying package_id and folder_id.

Changing the package procs was a requirement for the client. The requested URLs without the language prefix. Also the system was not generating relative URLs. That is all the links in the wiki content went to /xowiki/en/pagename and we wanted them go just go to /pagename.

This helps since you can use xowiki to replace an existing URL structure without using redirects.

Collapse
Posted by Gustaf Neumann on
Dave,

you don't need package_id and folder_id, the initialize method will care about this. The page that i have posted just replaces the root page, so e.g. yoursite/forums will continue to work, no matter, what xowiki pages are installed.

What you are describing is a complete takeover of xowiki, where it handles all requests (this needs ... -url /xowiki[ns_conn url])

-gustaf
PS: i will thing about a configuration option for an xowiki instance that will allow an arbitrary prefix instead of /&gt;instancename&lt;/&gt;lang&lt to replace the patch...