Forum OpenACS Development: Embedding xowiki portlets in different packages

Hi all.

We're trying to develop an OpenACS package and we would like to include in our pages certain "areas" that could be treated like xowiki pages (i.e. can be edited, revisioned and such).

The result would be something similar to what you get if you use {{adp portlets/wiki ... }} in a regular xowiki page, only that instead of being included that way, we would use an <include> element in the ADPs of our package.

Being rather new to the xotcl / xowiki scene I'm a bit lost. I have tried to simply include the wiki portlet but it will return an error stating that $__including_page has not been defined (which is true, of course).

In portlets/wiki.tcl (line 10) it is being used to generate the value for folder_id.

Does anybody have a suggestion on how to work around this problem or maybe about a different approach to including these wiki sections in our package?

Thanks.

Collapse
Posted by Caroline Meeks on
Hi Pablo,

Take a look at http://www.solutiongrove.com/mashup/portal

The portlets with content like Welcome, Featured Product etc. are XOWiki pages.

Is this what you are looking to do?

Yes, something very similar to that.

There would be a few sections that look like regular content to users, but admins get an extra "edit" button that allows, well, edition (or the "view" button from the current portlet, both are reasonable options).

How did you implement that? Are you using Gustaf's portlet?

BTW, I had been playing with that desktop early this morning not knowing it was wiki content. It's great!

Hi Pablo,

I've uploaded what could be the next version of the web desktop you saw on our mashups page.

https://openacs.org/storage/view/ajax-portal.tar.gz

Take a look at lib/portalelement.adp and lib/portalement.tcl. You will see a switch. Case 2 will show you how we grab the xowiki content.

The code is originally by Deds Castillo which I think he derived from Gustaf's portlet code in xowiki.

I hope this helps.

Hamilton

Just to add, you'll see that you'll need the item id to be able to fetch the content.

In index.tcl at the bottom, you will see some code that attempts to fetch a list of XoWiki pages from the xowiki instance mounted on a subsite.

Good Luck.

Hi Hamilton,

I'd like to try your ajax-portal package, but it requires version 0.4d of ajaxhelper, wich is not available in the CVS repository.

Could you kindly commit an updated version?

Tia,
Claudio

My apologies. There are a couple of things I need to update before I commit it to cvs head.

However, I have uploaded it to file storage below.

https://openacs.org/storage/view/ajaxhelper0.4d.tar.gz

Please be advised that ajax-portal is very much work in progress and isn't really ready for public consumption. It will take a bit to get it to work after installation.

If you encounter problems and you're stumped, let me know and I'll do my best to help.

Hi Hamilton,

I have AjaxHelper version 0.3d installed on an OpenACS 5.1.4. I followed the portal mashup tutorial to get the fading effects for portlets however in doing so it has become impossible to modify any custom portlets. Something to do with the JavaScript libraries conflicting with the JavaScript HTML editor - it gets rather messy and crashes the browser (Firefox and IE)? Thought I'd let you know as it could be a major bug for anyone who uses custom portlets.

Matthew

Collapse
Posted by Gustaf Neumann on
Pablo,

i have not looked how hamiltons beautiful mashup works. but anyhow, there is quite a simple way to include xowiki pages in other applications.

The xowiki portlets/includelets works only for nesting xowiki pages, since they reuses the context of the including object, which you don't have in the general case. however, someone has commited a version of view.tcl/adp into xowiki/lib, which mostly works (see below).

Include in your own page the following code

array set node_info [site_node::get -url /xowiki]
set folder_id [::xowiki::Page require_folder \
		   -name xowiki -package_id $node_info(package_id)]
set item_id [::Generic::CrItem lookup -name "en:index" -parent_id $folder_id]
set page_title "Page including a wiki page"
set context ""
where "en:index" is the name of the page to lookup.
Add to your own adp file something like
&lt;master&gt;
  &lt;property name="title"&gt;@page_title;noquote@&lt;/property&gt;
  &lt;property name="context"&gt;@context;noquote@&lt;/property&gt;

&lt;include src="/packages/xowiki/lib/view" item_id="@item_id@" folder_id="@folder_id@"&gt;

and change finally the the query parameter
in xowiki/lib/view.tcl to
{item_id:optional}
otherwise it will set always the specified item_id.
This is just a first shot. In the mid-term range,
the preferred interface would look most likely more like:
&lt;include src="/packages/xowiki/lib/view"
	 instance="/xowiki"
	 name="en:index"&gt;
where one does not need to know folders etc. However, If you want to have edit links of these pages in your own package, you will however have to know the right item_id etc. and point the link to /xowiki/edit?item_id=$item_id, since edit depends as well on package_ids etc. It would be much nicer to make edit etc. methods in an oo sense of the pages, such that one does not have to deal with item and package ids like now.

This is just to warn you, that the interface with the IDs might change in the future. For now, please use the approach with the IDs like sketched above. I will commit an updated version of xowiki/lib/view.tcl when i have some more time to look more closely to it... i am not too happy about maintaining multiple versions of view.tcl, this should be somewhat refactored.

Thanks everybody for the useful feedback and code. We will be implementing this throughout the week and post feedback on whatever we learn during the process.
Collapse
Posted by Pablo Moreno-Ger on
Following the suggestions received here we integrated the wiki into a custom package that we are working on so that blocks of text can be edited using xowiki (using adp includes).

Here is what we are trying to achieve:

1. Add edit buttons to the adp page that has the wiki includes that goes to the edit page. Ideally the edit page would show up in the URL space of the package itself and not within the xowiki url space (We have already achieved this following Gustaf's suggestion except for the URL space).

2. Pass a return URL to the xowiki edit page that we can use to bring us back to the page we were on before the edit.

For #2 Ham suggested we changed edit.tcl to add that param and modify the form when it is created like this:

set form_class [$object_type getFormClass]
$form_class create ::xowiki::f1 -volatile \
-data $page \
-folderspec $folderspec \
-submit_link $return_url

Unfortunately, it is not working. Even if we change the submit_link original definition in xowiki-form-procs.tcl, it always goes back to "view" after we edit.

Something is instructing it to do that and although it is probably obvious, we don't find it. Can any one help?

(commenting out line 160 didn't affect the behaviour, since we are dealing with plain pages)

Collapse
Posted by Hamilton Chua on
I'm not sure if you got this but I also suggested that you add a return_url to the query section on ad_page_contract at the top of edit.tcl

ad_page_contract {
This is the edit page for notes.

@author Gustaf Neumann (mailto:gustaf.neumann@wu-wien.ac.at)
@creation-date Oct 23, 2005
@cvs-id $Id: edit.tcl,v 1.13 2006/05/19 22:21:30 gustafn Exp $

@param item_id If present, item to be edited
@param name Name of the item
@param object_type the source class providing the data source for filling the form
} -query {
item_id:integer,optional
name:optional
last_page_id:integer,optional
folder_id:integer,optional
{object_type:optional ::xowiki::Page}
page_template:integer,optional
{return_url "view" }
}

By line #60, you should be referring to this line of code

### provide a nice link
my set submit_link [::xowiki::Page pretty_link \
-package_id [$data set parent_id] \
[$data set name]]

Also your edit link should ressemble edit?item_id=0000&return_url=/your_return_url

Also, please remember to go to acs-admin/apm and reload the changes on xowiki. Your changes to the proc will not take effect until you restart the instance or reload the changed tcl files.

Collapse
Posted by Gustaf Neumann on
The edit script is using ad_form and is called multiple times with different states. in order to provide e.g. the pretty name, one needs the page name, which is not available when one creates for example a new page. to make life easier for you, i have made a small change to edit.tcl and the form-procs to support the return_url. I have not tested intensively, but it seems to work.

as i wrote before, i hope to be able to come with a better approach in the not to distant future. Currently i am completely under water with a book project..

-gustaf

Thank you both for your replies. I was aware of the changes indicated by Hamilton (I omitted those for brevity). And I rebooted the server a couple of times which, I understand, should be as good as reloading the files... isn't it?

Anyway, thanks again. I will try those changes during the weekend.

-pablo.

restarting the server is certainly reloading the files. the faster approach is to go to the package manager and press reload changed files, this is however just necessary, when files in /packagename/tcl/ are altered.
I just made another enhancement to pass return_url correctly for PageInstances (of PageTemplates) as well. life is for those more complicated, since multiple forms are involved. please get the update from cvs, and pass the return_url to edit.tcl.
Just a quick note to let you know that I added your changes and it seems to be working perfectly. Thank you!

We will keep an eye on it and report any problems we find during testing.

--
Pablo.

Collapse
Posted by Eduardo Santos on
Hy everybody,

I know this forum is a little bit old, but it has something to do with my client's need, and need to find a way out of this. I'm using dotlrn 2.2.0 and OpenACS 5.2.3 and I'm trying to develop some kind of dotlrn applet for xowiki. The idea here is to make every community have its own instance of xowiki, where they can put their documentation.

There are a lot of workarounds, such as put a static-portlet with a link to the page in my xowiki instance wich is already created, but I want a better solution. I want to make the package create a new instance for the community, with all the permissions and users already able to see it. My idea is to insert another page in the community, where the xowiki link will be, something like /dotlrn/clubs/XOWIKI_INSTANCE already inserted in the portal_pages.

It seemed to be an easy task, but I'm facing some troubles. Can anyone help me to solve this?

Collapse
Posted by Gustaf Neumann on
see https://openacs.org/forums/message-view?message_id=584170 for using xowiki pages as dotlrn portal elements
Collapse
Posted by Dave Bauer on
Looks like the ajax portal code is https://openacs.org/storage/view/ajaxportal.zip now.