Articles

Working with CS-Wiki

February 18, 2007 (community server, .net)


Recently PI was tasked with creating a multi blog site for a client who wanted everything in .net. The best solution under these constraints is Community Server. Aspnix is a web host that provides Community Server support so we got an account.

A few months later my client asked if we could implement some wiki like functionality on the site. I had recently read about CS-Wiki which is a wiki extension for Community Server. This article discusses some of the issues I had with installing it.

The CS-Wiki source can be downloaded from www.codeplex.com/cswiki. The CodePlex site also offers a forum for developers to discuss, and these forums proved invaluable in troubleshooting my install. The download file comes with a readme.txt that does a decent job of explaining the installation process. I will discuss each of the steps and add my own comments.

I recommend making a back up of each of the files you are going to edit, you never know when this could go south.

Step one, copy the com.db40.Wiki,dll file over to your /bin folder. This is non destructive, so no need to worry. CS-Wiki requires .Net 2.0 so the bin will be automatically rolled into the site code next time it is accessed.

Step two, you are going to modify the communityserver.wiki.config file. You'll find this in your root. You are supposed to merge your current config with the contents of the one in the download. This means going through each of the sections and appending the contents from the download config to the bottom of the same section in your own config.

Step three, copy over the Wiki folder from the download to the root of your site. This is non destructive so just copy it over, no problem at all.

Step three, part two. There is a Themes folder in the download, you need to copy all the contents of this folder (and it's sub folders) into your sites Themes directory. You won't be overwriting anything per se, it's just a lot of following the directory trail and copy files into the right location.

Step 4, another merging of config files. Take your SiteUrls.config file from your root and merge the contents of of the siteurls.wiki.config file from the download. As before, copy each section into the corresponding section in your config file.

Step 5, yet another merge. Under /Languages/en-US/ you'll find resources.xml. There is also one at the same path in the download. Put them together. Remember to back everything up.

Step 6. Log into the admin panel for your Community Server and add the role WikiAdministrator.

Step 7 in the readme.txt says to create placeholder folders for the root topic sets. This means that you can create a directory off the root named, for example /PrionInteractive, and have a whole PI wiki running under that directory. The directory needs a file to be placed in it to kick start it into action. This is an xml file named _Namespace.xml and it contains the following.



<?xml version="1.0" encoding="utf-8"?>
    <TopicSet ID="PrionInteractive" Title="PrionInteractive" Owners="">
      <Permissions/>
</TopicSet>


So whatever you named yours, put the proper name in the files.

You also need to define the wiki folder in a couple of the config files. In the communityserver.config file you need to add the following under the CommunityServer/Wiki/Location element tags (which you just added a few steps ago). In my example, I would add this within the Location tag.



<add path = "/PrionInteractive" />


You also need to add an empty default.asp file into your new wiki folder. This has to do with the URL rewriting Community Server does. I put an empty file name default.aspx into /PrionInteractive

Permissions

There are number of tasks a wiki user can perform and the config file allows you to define who can do what. It uses an approach that I haven't seen before (although I haven't seen much, so take that for what it's worth).

In the communityserver.config file is a section named Wiki/DefaultPermissions which applies permissions to a number of roles. For each role a WikiPermission element is created with a name, an allow mask and a deny mask. The allow mask is an integer (a BitMask according to the parlance) that is the sum of all the tasks that a role can perform. The deny task is an integer that is the sum of all the tasks that a role is not allowed to perform. Due to the way the numbers are defined, it is not possible to have two different group of numbers sum to the same total.

For example, I want the role Everyone to be able to view the page. So i set the allow mask to 1. I set the deny mask to 0. I want the system administrator role to be able to do everything, so the allow mask is 72075194813907709 which is the sum of all tasks. The numbers get huge because we are dealing with binary numbers. So get excel or a calculator out if you are doing something fancy.

Wiki Data Storage

CS-Wiki does not use the database. It creates an xml file for each wiki that is structured to follow the content. The default location is in /app_data/wiki_data and in my example folder the file PrionInteractive.topic.xml would exist in that directory.

My biggest issue with making the whole system work had to do with this xml file. Since my Community Server implementation is on a hosted box I was unable to do whatever I wanted permission-wise. After I followed all of the above steps I would get a "Your changes could not be saved due to an unknown error." when I tried to submit an edit to a wiki page. This is clearly a permissions issue but I couldn't much around to find out what the proper settings should be.

In the end, I asked Aspnix tech support to give read/write access to the 'NETWORK SERVICE' user and the 'ASPNET' group. Performing just the latter didn't work but as soon as I did the former, everything worked great. It took me some forum posts and a couple weeks to discover that though.