Rutgers changes to BaseContentService.java and AccessServlet.java SUPPORT FOR HTML EDITORS Many sites will want to use an HTML editor other than the one supplied with Sakai. More advanced editors may wish to take advantage of two facilities now integrated with Sakai: the file chooser and support for HTTP POST. 1. The file chooser Most HTML editors present the user with the ability to create links and images. More advanced editors have a "browse" function, so that users can simply click on an item to add a reference to it. If your editor has this functionality, you may want to configure it to use Sakai's file chooser. To activate a chooser, configure your HTML editor to navigate to a directory in your resources area, with an argument of "basedir". E.g. /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/?basedir=http://host/access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/ The basedir argument is normally a full URL starting with http: or https:. It is URL that the HTML editor will use as the default. URLs returned to the editor will be relative URLs, starting from that base. If you use "basedir=none", a full absolute URL will be returned. When you give a URL with the basedir argument, Sakai will display a directory page formatted specifically for use with an HTML editor. Each item will have a button next to it labelled "Choose". It will have the following Javascript code: onclick="seturl('URL')" where URL is the appropriate URL for that item. The Javascript function seturl is defined as follows: This causes a variable called "url" in the calling window to be set to the argument. If your editor uses a different variable, you may specify a variable that will be used instead of "url" by adding field=name to the invoking URL. That is if you call the file chooser with the URL 2. Variant of the file chooser for Sferyx In order to support the Sferyx editor, there is a variant of the standard file chooser. If the argument sbasedir is used instead of basedir, the display is formatted as expected by the Sferxy file dialog. E.g. the URL might be /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/?sbasedir=http://host/access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/ Items are displayed using the following code: as expected by Sferyx. the function seturl will be defined with window.opener.document.forms[0].myfield.value = url; which will the value of the variable "myfield" in the calling window. 3. Support for sending files via POST. Advanced HTML editors often have the ability to upload images and other content automatically to the server. The most convenient way to do this via HTTP is via the HTTP POST function. Sakai will accept POST functions. When a POST is done to /access/content, the form items in the POST are checked for any that are file items. Those items will be uploaded into sakai resources, assuming that the current logged in user has write access to the folder specified. Here is an example of a simple form that can be used to demonstrate this functionality:

What files are you sending?

This form will upload files to the user's workspace. The POST processor expects the URL specified in "action" to be the folder to which files will be updated. It must be under /access/content. (URLs pointing to URLs other than /access/content may also work, but if so they are handled by POST handlers defined elsewhere.) The file name used will be generated by the browser. It is normally the file name used on the local file system. If a file by that name already exists, it is replaced, with no error message or other indication. DISPLAY OF ITEMS IN /access/content It is possible to access the contents of Resources in two different ways: * by using the Resources tool within Sakai * by pointing your browser directly to the URL of an item Unless you are using an alias (described below), URLs look like this: /access/contents/user/myusername/item.html /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/item.html The first shows "item.html" in the worksite of the user "myusername". The second shows "item.html" in the resources area of a site whose site ID is 88db9fa5-9496-48f7-0082-2a28a46ab122. If you have created folders, they show up in the URL in the obvious way: /access/contents/user/myusername/folder/item.html /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/item.html URLs of this type cause your browser to access an item just as if the item was stored in a typical web server such as Apache. However there's one additional feature: If the folder or item has not been declared public, Sakai will check access permissions. If you have already logged into Sakai, your browser will have a cookie specifying a Sakai session. In that case, the user associated with the session will be used for checking. If you do not have an active Sakai session, Sakai will put up a login screen. If you successfully login, it will then go to the URL you originally specified. It is also possible to display a listing of a "collection". In Sakai the term "collection" refers to the contents of a folder, or of the top level worksite or Resources area. E.g. the first two URls show a worksite and Resources area; the second two show a folder. /access/contents/user/myusername/ /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/ /access/contents/user/myusername/folder/ /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/folder/ Note that URLs for collections should end in "/". However if you fail to use the "/", Sakai will redirect your browser to a URL that has the "/". When you access a collection, the listing will be in a format appropriate for students or other users who want to see the contents of the collection. This contrasts with the normal Resources tool, which uses a format that has lots of icons and other items intended to make it easy for people to add and modify content. The format of the listing is roughly as follows: Collection name Descriptive text applying to the whole collection This comes from the "Description" field that appears when you create or edit the folder or other collection Item title Item description. This comes from the Description field that appears when you create or edit the item Item title Item description 1. Aliases Sakai normally uses relatively complex URLs for resources. Typical resource URLs are for My Workspace: /access/contents/user/myusername/ for a Site: /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/ There are times when it is useful to access content directly, rather than asking everyone to login to sakai first. In that case it may be desirable to provide URLs that look more like a typical web server. For this purpose, you can use an ALIAS. E.g. if you assign the alias "mysite" to your site, its resources area would be accessed as /access/mysite/ rather than /access/content/group/88db9fa5-9496-48f7-0082-2a28a46ab122/ At the moment the same alias is used for access and email. That is, to allow your site to be accessed as /access/mysite/, you should assign an email alias of mysite@sakaihost. (This is likely to change in the future.) For user worksites, the ~ convention is used. That is /access/~myusername/ will access the user's worksite. It is the same as /access/contents/user/myusername/