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

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
__TOC__
 +
 +
<metadesc>How I take the good things from mediawiki and unite them with dokuwiki's advantages. Mediawiki has known syntax and nice look and feel, dokuwiki has ACLs and easy backup. Here is how I get both.</metadesc>
 +
 
[http://www.wikimatrix.org/compare/DokuWiki+MediaWiki Comparing dokuwiki and mediawiki] [[User:ThorstenStaerk|I]] come to the result that  
 
[http://www.wikimatrix.org/compare/DokuWiki+MediaWiki Comparing dokuwiki and mediawiki] [[User:ThorstenStaerk|I]] come to the result that  
  
 
mediawiki has the advantages
 
mediawiki has the advantages
 
* look and feel
 
* look and feel
* known syntax
+
* known markup language
 
* edit buttons are above the section to be edited
 
* edit buttons are above the section to be edited
  
Line 10: Line 14:
 
* backup is easy because it is plain files
 
* backup is easy because it is plain files
  
 +
Even worse, migrating your users from mediawiki to dokuwiki will be quite a challenge if you disrupt their habits, e.g. by changing a wiki's look-and-feel.
  
I want the ACL features of dokuwiki and the look-and-feel of mediawiki.
+
= 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
  
html_secedit replaces #<!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] --># by some text
+
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 ==
 +
=== Template ===
 +
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 the monobook template], it resembles to mediawiki
 +
* download the monobook template from http://www.dokuwiki.org/template:monobook, as of 2012-01-06 this went like:
 +
lib/tpl # wget --no-check-certificate http://andreas-haerter.com/downloads/dokuwiki-template-monobook/latest-update
 +
* extract it to lib/tpl
 +
lib/tpl # tar xvf 2011-12-10_monobook-update.tar.gz
 +
* rename it to default
 +
lib/tpl # mv default/ default-save
 +
lib/tpl # mv monobook/ default
 +
* set admin -> Configuration Settings -> Load 'monobook/user/user.js'
 +
* 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>
 +
 
 +
=== Edit buttons ===
 +
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:editsections2 EditSections2 Plugin]. Or you can use 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.
 +
 
 +
= Demo =
 +
Want to see this all in action? Look [http://www.staerk.de/dokuwiki/doku.php?id=mediasyntaxplugintest here].
  
 
= See also =
 
= See also =
 +
* [[mediawiki]]
 +
* [[dokuwiki]]
 
* [[Convert a dokuwiki to mediawiki]]
 
* [[Convert a dokuwiki to mediawiki]]
 
+
* [[Dokuwiki#make_it_similar_to_mediawiki]]
{{stub}}
 

Latest revision as of 07:06, 15 December 2014


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

Even worse, migrating your users from mediawiki to dokuwiki will be quite a challenge if you disrupt their habits, e.g. by changing a wiki's look-and-feel.

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

Template

What stays is to modify dokuwiki to get mediawiki's look-and-feel and its syntax. To do this, use the monobook template, it resembles to mediawiki

lib/tpl # wget --no-check-certificate http://andreas-haerter.com/downloads/dokuwiki-template-monobook/latest-update
  • extract it to lib/tpl
lib/tpl # tar xvf 2011-12-10_monobook-update.tar.gz 
  • rename it to default
lib/tpl # mv default/ default-save
lib/tpl # mv monobook/ default
  • set admin -> Configuration Settings -> Load 'monobook/user/user.js'
  • 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]]

Edit buttons

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 EditSections2 Plugin. Or you can use 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.

Demo

Want to see this all in action? Look here.

See also