Integrate FCKEditor in Dokuwiki

Dokuwiki is a nice wiki application, easy to setup, and with a lot of plugins (notes, LaTeX rendering …). It features a tiny javascript editor in order to publish pages without knowledge of its wiki syntax. Yet, some users would certainly like a more advanced WYSIWYG editor, especially for handling images upload and positioning.

So, here’s a quick tutorial to embed FCKeditor[1], a GPL-ed WYSIWYG XHTML-compliant editor, in Dokuwiki[2].

First, setup FCK as the default DokuWiki editor:

 ptln('<script type="text/javascript" charset="utf-8" src="'.       DOKU_BASE.'lib/scripts/FCKeditor/fckeditor.js"></script>',$it);  ptln('<script type="text/javascript" charset="utf-8">window.onload = function() '.       '{ var fck = new FCKeditor("wiki__text", "100%", "600"); fck.BasePath = "'.       DOKU_BASE.'lib/scripts/FCKeditor/"; fck.ReplaceTextarea(); }</script>');

where “100%” and “600″ are the editor width and height;

 <div id="size__ctl"></div>
 alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName    + '" was not found' ) ;

Then, we need to tell DokuWiki that pages are now written in HTML, and not using its wiki syntax:

 io_saveFile($file, $text);

by

 io_saveFile($file, "<html>$text</html>");

so that it will save content between <html> tags, telling Dokuwiki we’re embedding HTML;

   p_render('xhtml',p_get_instructions($txt),$info)

by

   p_render('xhtml',p_get_instructions("<html>$txt</html>"),$info)

so that the preview text will be also interpreted as HTML.

One of the bast feature of FCK is its images/files upload management. If you want to enable it:

That’s all, you’ve got FCKeditor running in your wiki.

At least, if want to get an easy way to create internal links (and so, new pages), you should add a rewrite rule to make your wiki interpret links like foo as index.php?id=foo. Using it, you’ll be able to create new pages using the FCK link editor, by adding a link with no protocol and just a page name.

Notes

[1] I first choosed TinyMCE, until I discovered its images management plugin wasn’t free, while FCK’s one is.

[2] Using with DokuWiki v2006-03-09 and FCKeditor v2.3.

[3] $BASE is supposed to be the DokuWiki install path on your server.

DokuWiki URL rewriting in LightTPD

I’ve finally decided to setup DokuWiki as a personnal wiki, as it handles 2 of my first needs: namespaces and ACLs by namespaces.

Here are the options you need to set up to get clean URL rewriting in LightTPD.

In conf/dokuwiki.conf:

 $conf['userewrite']  = 1;        //this makes nice URLs: 0: off 1: .htaccess 2: internal  $conf['useslash']    = 1;        //use slash instead of colon? only when rewrite is on

The second line is optional, but I feel better handling namespaces pages with / - as subdirectories - instead of colons.

Actually, you can set option 2 (internal) for the userewrite parameter. Yet, URLs would be like "wiki/doku.php/mypage", and I’d prefer something like "wiki/mypage". In such a case (option 1), you need to set the following rules in lighttpd.conf:

 "^/wiki/?$" => "/wiki/doku.php",  "^/wiki/lib/(.*)/?$" => "/wiki/lib/$1",  "^/wiki/(.*)\?do=(.*)/?$" => "/wiki/doku.php?id=$1&do=$2",  "^/wiki/(.*)/?$" => "/wiki/doku.php?id=$1\