Difference between revisions of "How to make dokuwiki a good mediawiki"

From Linuxintro
imported>ThorstenStaerk
(Created page with "I want the ACL features of dokuwiki and the look-and-feel of mediawiki.")
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
I want the ACL features of dokuwiki and the look-and-feel of mediawiki.
+
[http://www.wikimatrix.org/compare/DokuWiki+MediaWiki Comparing dokuwiki and mediawiki] [[User:ThorstenStaerk|I]] come to the result that
 +
 
 +
mediawiki has the advantages
 +
* look and feel
 +
* known markup language
 +
* edit buttons are above the section to be edited
 +
 
 +
while dokuwiki has the advantages
 +
* ACL's allow me to keep pages invisible
 +
* backup is easy because it is plain files
 +
 
 +
= Combining both =
 +
So to get to my perfect wiki there are two basic ways:
 +
* use mediawiki and patch/extend it until is can do ACL's. Accept that for a backup, a script is needed.
 +
* use dokuwiki and patches/plugins/skins until it looks like mediawiki and uses mediawiki's markup
 +
 
 +
Reading [http://www.mediawiki.org/wiki/Security_issues_with_authorization_extensions this] discourages going the first path with authorization extensions. So the only way to secure mediawiki would be to set up several mediawiki instances, an internal one, a public one and so on. This provokes so many problems that I decided not to go this way. The problems are:
 +
* you will have to do "recent changes" on both mediawiki instances in order to see the complete picture
 +
* you will have to search on both mediawiki instances
 +
* with two mediawiki instances, it is still not possible to have one page public to group A, and another one visible to group B.
 +
 
 +
= Adapting dokuwiki =
 +
 
 +
== Look and feel ==
 +
What stays is to modify dokuwiki to get mediawiki's look-and-feel and its syntax. To do this, use http://www.dokuwiki.org/template:monobook, then adapt :wiki:navigation to contain
 +
<pre>
 +
* [[:start]]
 +
* [[http://yourhost/dokuwiki/doku.php?do=recent|Recent Changes]]
 +
* [[http://yourhost/dokuwiki/doku.php?id=wiki&do=admin&page=statistics|Statistics]]
 +
</pre>
 +
 
 +
The next hindering thing in day-to-day operation will be the "edit" buttons. Mediawiki users are used to "edit" buttons that edit the section ''below'' them, not ''above'' them. To get re-arrange the buttons in a mediawiki, there is the [http://www.dokuwiki.org/plugin:editsections EditSections Plugin]. If this [https://github.com/dr4Ke/editsections/issues/1 does not work again], you can also apply this simple patch:
 +
<pre>
 +
--- dokuwiki-1/inc/parser/xhtml.php    2011-06-14 21:58:54.000000000 +0200
 +
+++ dokuwiki/inc/parser/xhtml.php      2011-07-10 18:09:07.000000000 +0200
 +
@@ -183,6 +190,7 @@ class Doku_Renderer_xhtml extends Doku_R
 +
        }
 +
        $this->doc .= '><a name="'.$hid.'" id="'.$hid.'">';
 +
        $this->doc .= $this->_xmlEntities($text);
 +
+        $this->finishSectionEdit();
 +
        $this->doc .= "</a></h$level>".DOKU_LF;
 +
    }
 +
 
 +
</pre>
 +
No matter if you decide to use the EditSections Plugin or the above patch, you will have to apply a patch so that dokuwiki does not highlight the section ''above'' the edit button when you move your mouse over it (the edit button, that is). Here is the patch:
 +
<pre>
 +
--- dokuwiki-1/lib/scripts/script.js    2011-06-14 21:58:54.000000000 +0200
 +
+++ dokuwiki/lib/scripts/script.js      2011-07-10 13:42:07.000000000 +0200
 +
@@ -550,37 +550,3 @@ addInitEvent(function(){
 +
    checkWindowsShares();
 +
});
 +
 +
-/**
 +
- * Highlight the section when hovering over the appropriate section edit button
 +
- *
 +
- * @author Andreas Gohr <andi@splitbrain.org>
 +
- */
 +
-addInitEvent(function(){
 +
-    var btns = getElementsByClass('btn_secedit',document,'form');
 +
-    for(var i=0; i<btns.length; i++){
 +
-        addEvent(btns[i],'mouseover',function(e){
 +
-            var tgt = this.parentNode;
 +
-            var nr = tgt.className.match(/(\s+|^)editbutton_(\d+)(\s+|$)/)[2];
 +
-            do {
 +
-                tgt = tgt.previousSibling;
 +
-            } while (tgt !== null && typeof tgt.tagName === 'undefined');
 +
-            if (tgt === null) return;
 +
-            while(typeof tgt.className === 'undefined' ||
 +
-                  tgt.className.match('(\\s+|^)sectionedit' + nr + '(\\s+|$)') === null) {
 +
-                if (typeof tgt.className !== 'undefined') {
 +
-                    tgt.className += ' section_highlight';
 +
-                }
 +
-                tgt = (tgt.previousSibling !== null) ? tgt.previousSibling : tgt.parentNode;
 +
-            }
 +
-            if (typeof tgt.className !== 'undefined') tgt.className += ' section_highlight';
 +
-        });
 +
-
 +
-        addEvent(btns[i],'mouseout',function(e){
 +
-            var secs = getElementsByClass('section_highlight');
 +
-            for(var j=0; j<secs.length; j++){
 +
-                secs[j].className = secs[j].className.replace(/section_highlight/g,'');
 +
-            }
 +
-        });
 +
-    }
 +
-});
 +
-
 +
</pre>
 +
 
 +
== Syntax ==
 +
Your users will be familiar with [[Help:Editing|mediawiki syntax]], so give it to them. [http://www.staerk.de/thorsten/Mediasyntax MediaSyntax] allows you to do this. It also contains a [https://github.com/tstaerk/mediasyntax/tree/master/tools converter] in case you have an existing base of articles in dokuwiki's syntax.
 +
 
 +
= See also =
 +
* [[Convert a dokuwiki to mediawiki]]
 +
* [[Dokuwiki#make_it_similar_to_mediawiki]]
 +
 
 +
{{stub}}

Revision as of 18:32, 10 July 2011

Comparing dokuwiki and mediawiki I come to the result that

mediawiki has the advantages

  • look and feel
  • known markup language
  • edit buttons are above the section to be edited

while dokuwiki has the advantages

  • ACL's allow me to keep pages invisible
  • backup is easy because it is plain files

Combining both

So to get to my perfect wiki there are two basic ways:

  • use mediawiki and patch/extend it until is can do ACL's. Accept that for a backup, a script is needed.
  • use dokuwiki and patches/plugins/skins until it looks like mediawiki and uses mediawiki's markup

Reading this discourages going the first path with authorization extensions. So the only way to secure mediawiki would be to set up several mediawiki instances, an internal one, a public one and so on. This provokes so many problems that I decided not to go this way. The problems are:

  • you will have to do "recent changes" on both mediawiki instances in order to see the complete picture
  • you will have to search on both mediawiki instances
  • with two mediawiki instances, it is still not possible to have one page public to group A, and another one visible to group B.

Adapting dokuwiki

Look and feel

What stays is to modify dokuwiki to get mediawiki's look-and-feel and its syntax. To do this, use http://www.dokuwiki.org/template:monobook, then adapt :wiki:navigation to contain

* [[:start]]
* [[http://yourhost/dokuwiki/doku.php?do=recent|Recent Changes]]
* [[http://yourhost/dokuwiki/doku.php?id=wiki&do=admin&page=statistics|Statistics]]

The next hindering thing in day-to-day operation will be the "edit" buttons. Mediawiki users are used to "edit" buttons that edit the section below them, not above them. To get re-arrange the buttons in a mediawiki, there is the EditSections Plugin. If this does not work again, you can also apply this simple patch:

--- dokuwiki-1/inc/parser/xhtml.php     2011-06-14 21:58:54.000000000 +0200
+++ dokuwiki/inc/parser/xhtml.php       2011-07-10 18:09:07.000000000 +0200
@@ -183,6 +190,7 @@ class Doku_Renderer_xhtml extends Doku_R
         }
         $this->doc .= '><a name="'.$hid.'" id="'.$hid.'">';
         $this->doc .= $this->_xmlEntities($text);
+        $this->finishSectionEdit();
         $this->doc .= "</a></h$level>".DOKU_LF;
     }

No matter if you decide to use the EditSections Plugin or the above patch, you will have to apply a patch so that dokuwiki does not highlight the section above the edit button when you move your mouse over it (the edit button, that is). Here is the patch:

--- dokuwiki-1/lib/scripts/script.js    2011-06-14 21:58:54.000000000 +0200
+++ dokuwiki/lib/scripts/script.js      2011-07-10 13:42:07.000000000 +0200
@@ -550,37 +550,3 @@ addInitEvent(function(){
     checkWindowsShares();
 });
 
-/**
- * Highlight the section when hovering over the appropriate section edit button
- *
- * @author Andreas Gohr <andi@splitbrain.org>
- */
-addInitEvent(function(){
-    var btns = getElementsByClass('btn_secedit',document,'form');
-    for(var i=0; i<btns.length; i++){
-        addEvent(btns[i],'mouseover',function(e){
-            var tgt = this.parentNode;
-            var nr = tgt.className.match(/(\s+|^)editbutton_(\d+)(\s+|$)/)[2];
-            do {
-                tgt = tgt.previousSibling;
-            } while (tgt !== null && typeof tgt.tagName === 'undefined');
-            if (tgt === null) return;
-            while(typeof tgt.className === 'undefined' ||
-                  tgt.className.match('(\\s+|^)sectionedit' + nr + '(\\s+|$)') === null) {
-                if (typeof tgt.className !== 'undefined') {
-                    tgt.className += ' section_highlight';
-                }
-                tgt = (tgt.previousSibling !== null) ? tgt.previousSibling : tgt.parentNode;
-            }
-            if (typeof tgt.className !== 'undefined') tgt.className += ' section_highlight';
-        });
-
-        addEvent(btns[i],'mouseout',function(e){
-            var secs = getElementsByClass('section_highlight');
-            for(var j=0; j<secs.length; j++){
-                secs[j].className = secs[j].className.replace(/section_highlight/g,'');
-            }
-        });
-    }
-});
-

Syntax

Your users will be familiar with mediawiki syntax, so give it to them. MediaSyntax allows you to do this. It also contains a converter in case you have an existing base of articles in dokuwiki's syntax.

See also


This article is a stub and needs improvement. You can help here :)