User Tools

Site Tools


dokuwiki

I use Dokuwiki for this blog (yes, technically it's a blog, not a wiki), as it is easy to setup, requires no SQL database, and LOOKS AWESOME! I wish to thank Andreas Gohr and the DokuWiki Community for their great job!

Installing and configuring DokuWiki

This assumes you have already a running website on apache2 with php5 (www.example.org) and you want a new wiki page at http://www.example.org/my_new_wiki

Your linux distribution may have easy-installable package available, however I'll be installing the most recent version from source. Check http://www.splitbrain.org/projects/dokuwiki to make sure you're downloading the most recent version.

wget http://www.splitbrain.org/_media/projects/dokuwiki/dokuwiki-2010-11-07.tgz
tar -zxvf dokuwiki-2010-11-07.tgz
mv dokuwiki-2010-11-07 <BEGIN GeSHi>my_new_wiki_name<END GeSHi>
cd <BEGIN GeSHi>my_new_wiki_name<END GeSHi>
chown -R <BEGIN GeSHi>www-data<END GeSHi>: .

/* OPTIONAL: # mkdir files ← so you'll have a place to store linked files */ (my apache is running as www-data, check which username your apache is running with the command 'ps auxww|grep apache')

add the folder to your web folder /var/www/www.example.org/my_new_wiki FIXME

Visit the site: http://www.example.org/my_new_wiki click on 'or do you want to run the installer instead' and you will get redirected to the installer. If you the 'chown' command went wrong, you'll see some errors about '… is not writable by DokuWiki. You need to fix the permission settings of this directory!'.

Enter the required details. I made mine a 'Public Wiki' which means only I am allowed to make changes to it, others are free to read. I selected the 'CC Attribution-Noncommercial-Share Alike 3.0 Unported' license.

You'll see the message about the installation being successful, and can continue to your 'start' page.

Remove the install.php file now to prevent unauthorized access (optional):

rm install.php 

Enabling userewrite .htaccess

To get better google coverage, I enabled 'userewrite' (“.htaccess”), to do this click the 'Admin' buttom ⇒ 'Configuration Settings', don't forget to click 'Save'. This results in nicer urls.

cd /var/www/<BEGIN GeSHi>www.example.org<END GeSHi>/<BEGIN GeSHi>my_new_wiki<END GeSHi>/
cp .htaccess.dist .htaccess
nano .htaccess

Uncomment the following lines:

RewriteEngine on
RewriteRule ^_media/(.*)              lib/exe/fetch.php?media=$1  [QSA,L]
RewriteRule ^_detail/(.*)             lib/exe/detail.php?media=$1  [QSA,L]
RewriteRule ^_export/([^/]+)/(.*)     doku.php?do=export_$1&id=$2  [QSA,L]
RewriteRule ^$                        doku.php  [L]
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteRule (.*)                      doku.php?id=$1  [QSA,L]
RewriteRule ^index.php$               doku.php

Save and exit.

Dokuwiki configuration changes

You can make changes to how DokuWiki works in the configuration manager (Admin → Configuration). I made the following changes:

  • indexdelay: Time delay before indexing (sec): 60*60
  • disableactions: disabled all actions, except 'Search', 'Sitemap', 'Update Profile', 'Edit this page'
  • typography: none
  • breadcrumbs: 0
  • youarehere: enable
  • plugin»discussion»useavata: disable
  • plugin»discussion»wikisyntaxok: disable
  • plugin»discussion»subscribe: disable
  • sitemap: enable

Future:

  • authtype: Authentication backend: ldap (as soon as I've got LDAP working)

Dokuwiki table of contents TOC

On some pages I didn't see the Table of Contents (keywords TOC table of contents tpl_toc), but a quich search told me: “If you have more than three headlines, a table of contents is generated automatically” So I just had to create more headlines.

Clearing the cache of DokuWiki

After changing some templates, .php and .css files, I noticed changes were not activated immediately. Solution: clear the cached pages: “To force recaching of all pages, including page instructions, touch the local configuration file, conf/local.php.”

touch conf/local.php

Installed plugins

Popularity Feedback

This is installed by default. Click on 'Popularity Feedback' in the 'Admin' section of DokuWiki, to let the DokuWiki people know how DokuWiki is used.

Commentsrc

To hide some text on my wiki (editorial notes, specific ip addresses, names, etc) I use the dokuwiki commentsrc plugin ( I patched it (by hand) with Kohei MATSUSHITA's notes (didn't get plugin:comment working.)

I have disabled 'view page source'/'export' option in DokuWiki, haven't tested if this plugin is compatible with this option enabled.

  * This is an <BEGIN GeSHi>/*<END GeSHi> entertaining <BEGIN GeSHi>*/<END GeSHi> example

Will show as:

  • This is an /* entertaining */ example

plugin:discussion - allow people to comment on my wiki

http://www.dokuwiki.org/plugin:discussion Installation: Click the 'Admin' button, 'Plugins', paste this URL: http://cloud.github.com/downloads/dokufreaks/plugin-discussion/plugin-discussion.tgz Disabled: allow wiki syntax in comments and enable/disable subscribe to comments

Edit the page where you want to show the 'discussion' box, and add the following to the end of the page (you may change the text):

~~DISCUSSION|<BEGIN GeSHi>Please enter your comments<END GeSHi>~~

Anti spam

15 December 2010: I've noticed spam in the comments on my pages, so I implement a very small 'Turing test' (protection against spam bots), with a 'simple' unix question: “To prove you are human, enter the linux command to list the contents of directories”, I did it this way:

Enable 'addressfield' in the configuration ($conf['plugin']['discussion']['addressfield'] = 1;), then:

nano <BEGIN GeSHi>path_to_DokuWiki<END GeSHi>/lib/plugins/discussion/action.php

Find the line:

if ($address) $head .= ', <span class="adr">'.$address.'</span>';

Change it to:

<BEGIN GeSHi>//<END GeSHi>if ($address) $head .= ', <span class="adr">'.$address.'</span>';

Find the line:

<span><BEGIN GeSHi><?php echo $this->getLang('address') ?><END GeSHi>:</span>

Change it to:

<span><BEGIN GeSHi>To make sure you are human and not a spammer, enter the unix command to list the contents of a directory<END GeSHi>:</span>

Find the line:

if(empty($_REQUEST['name']) or empty($_REQUEST['mail'])) return; // don't add anonymous comments

Change it to:

if(<BEGIN GeSHi>($_REQUEST['address'] != "ls") or <END GeSHi>empty($_REQUEST['name']) or empty($_REQUEST['mail'])) return; // don't add anonymous comments

plugin:metaheaders - putting meta keywords and description in your DokuWiki for SEO

To help search engines (like Google) index your page properly, it is required to make some changes to the html headers. By default(?), DokuWiki disallows search engines indexing your site, by placing a 'noindex,nofollow' tag in the headers.

To edit the headers, we need a plugin that can do this. I've looked at plugin:keywords, but it did only keywords, no description. I'm not fluent in YAML, so plugin:meta_yaml wasn't an option either. Luckily I found plugin:metaheaders which I'm using right now. Install it using the plugin manager link, then:

nano <dokuwiki>/conf/metaheaders.conf.php
<?php
$clear[] = array ( 'name' => 'keywords' );
$headers['meta'][] = array( 'keywords' => '<BEGIN GeSHi>lxc,linux containers,virtualization,virtual machine,vm,guide,manual<END GeSHi>');
 
$clear[] = array ( 'name' => 'description' );
$headers['meta'][] = array( 'description' => '<BEGIN GeSHi>A complete step-by-step guide to setup virtualization on Linux using LXC<END GeSHi>');
 
$clear[] = array ( 'name' => 'robots' );
$headers['meta'][] = array( 'robots' => 'index,follow');
?>

See the DokuWiki SEO article for more hints. Remember to enable 'sitemap' in the configuration manager to further improve your sites visibility to search engines.

/* TODO: add keywords per section/heading, assemble them all to create a keywords header? */

plugin:googleanalytics

Google Analytics helps me gather statistics on my page's visitors, to see how popular my page is, where my visitors come from and which pages attract the most visitors, using which search terms. DokuWiki has a plugin for it, plugin:googleanalytics. After intallation, go to configuration manager and put the google-analytics-ID you got from Google into the right box.

Template modifications

DokuWiki title display

I wasn't content with the way the page title was displayed on my DokuWiki pages, so I searched for a way to change it. Previously, it was like Topic [Wiki Title] I wanted something like Wiki Title [Topic] Except for the first page with the 'Introduction', there the '[Topic]' should be left out the title completely.

In the configuration manager, set 'useheading' to 'Navigation only', this will use the first heading (= first text between ====== and ======) in a page as its name/topic.

In '/lib/tpl/default/main.php', originally there was:

  <title>
    <?php tpl_pagetitle()?>
    [<?php echo strip_tags($conf['title'])?>]
  </title>

The title of my first page is set to the first caption on the page (the stuff between '===== =====, in my case 'Introduction' becauase of the configuration setting 'useheading'='Navigation only'. So I changed the section to:

  <title>
    <?php
  echo strip_tags($conf['title']);
  if (strpos(tpl_pagetitle($id,true),"<BEGIN GeSHi>Introduction<END GeSHi>") === false) {
  echo " [";
  tpl_pagetitle($id,false);
  echo "]";
}
?>
  </title>

And now it works how I want it (… for the moment :) )

Syntax highlighting in <code> sections

Syntax highlighting in <code> </code> sections. Colorize some output in code blocks to make the reader extra aware that the text needs to be edited before use, using a (deprecated…) function of the GeSHi plugin, the default syntax highlighter in DokuWiki); e.g instead of:

nfs server=<NFS_SERVER_IP>

By putting <BEGIN GeSHi> <END GeSHi> around it, I now can do:

nfs server=<BEGIN GeSHi><NFS_SERVER_IP><END GeSHi>

Instad of just using <code>, you MUST use <code conf> ('text', which is the default won't work). TODO: check why <code php> doesn't work just as well. Download conf.php here (rename .phps to .php) and place it in inc/geshi/

The default 'tags' in GeSHi for highlighting something are '<BEGIN GeSHi>' and '<END GeSHi>'. I changed them to something easier: <BEGIN GeSHi> and <END GeSHi> (easy to remember: 'IMPortant'). Change it in inc/geshi.php or download it here, rename & place in /inc:

nano inc/geshi.php
/* The starter for important parts of the source */
define('GESHI_START_IMPORTANT', '<BEGIN GeSHi>');
/* The ender for important parts of the source */
define('GESHI_END_IMPORTANT', '<END GeSHi>');

Enable 'enable_important_blocks':

    var $enable_important_blocks = <BEGIN GeSHi>true<END GeSHi>;

Add a new style to the style.css file or download it:

nano lib/styles/style.css
.code .imp  { color: #FF0000; font-weight: bold; }

You might have to clean the DokuWiki page cache (perhaps even your browsers cache), to make sure .css and .html file are freshly created.

Floating ad/banner in DokuWiki

You can see it in action on this page, it's the 'Do you need help?' banner in the right hand corner.

Currently I have little knowledge of CSS, so excuse my lack of css/html coding skills. The 'floating div'-part was taken from Example 5a at Wickham's XHTML & CSS tutorial on div boxes position and a bit from BrainJar The round corners inspiration came from HTML, JavaScript's and picture tricks, which I by accident stumbled upon.

To make this work, I need something to automatically include my extra html/php/css code in all DokuWiki pages using 'Include Hooks'. I used meta.html and topheader.html (right click to download):

  • meta.html - html/php-code from this file is placed inside the HTML <head>, use this to add additional styles or metaheaders
nano lib/tpl/default/meta.html
<style type="text/css">
#fixedtop1 { position: fixed; bottom: 5px; right: 10px; border: 2px solid #005cb9;-moz-border-radius:10px;
-webkit-border-radius:10px; background:#ebebeb; margin-top:5px;margin-bottom:5px;z-index: 50; }
#center250a { width: 230px; margin: 5px; }
</style>
  • topheader.html - html/php-code from this file is placed at the very top of the page right after the <body> tag
nano lib/tpl/default/topheader.html
<div id="fixedtop1">
<div align=center id="center250a">
<p align="left">
<span style="float:left;width:50px;margin-left: 15px">
<img height=45 width=45 src="<?php echo DOKU_TPL; ?>images/needhelp.png">
</span>
<b>Do you need help?</b><br><br>
We provide affordable commercial support on this topic!<br>
Languages spoken: <img height=12 width=20 src="<?php echo DOKU_TPL; ?>images/nl.png">
<img height=12 width=20 src="<?php echo DOKU_TPL; ?>images/en.png">
<img height=12 width=20 src="<?php echo DOKU_TPL; ?>images/de.png">
<br><center>
Save time and <a href="support">contact us now!</a></center>
</p>
</div>
</div>

I got the language/flag icons (.png) from the Drupal 'language icons' project site, and put them into the right folder:

mv *.png <BEGIN GeSHi>path_to_DokuWiki<END GeSHi>/lib/tpl/default/images/

Notice how I used

<?php echo DOKU_TPL; ?>

in 'topheader.html' to fix the image path.

TODO

  • Dokuwiki: autogenerated sitemap
  • Templating
  • Syntax Highlighting (e.g.: root@vm-web# tar -zxvf dokuwiki-2010-11-07.tgz to distinguish between the prompt and the command to enter), perhaps using the 'linestyle'/numbering feature of the <code> command?
  • different color <code> boxes, one color for command line stuff, another for output display? [ <file> blocks ? ]
  • Combine all my wiki into one big one? Interwiki links?
  • Linking to Windows Shares?
  • No Formatting: If you need to display text exactly like it is typed (without any formatting), enclose the area either with tags or even simpler, with double percent signs <nowiki>%%.
  • Downloadable Code Blocks
  • DokuWiki's standard abbreviations are stored in the conf/acronyms.conf file. You can add your own abbreviations by creating a conf/acronyms.local.conf file and placing your abbreviations. acronyms.conf.local not read correctly? → /conf# cat acronyms.conf.local » acronyms.conf. Example acronyms.conf entry:
    (?)     not checked or tested, unsure
  • // Define if GeSHi should be paranoid about security
    if (!defined('GESHI_SECURITY_PARANOID')) {
        /** Tells GeSHi to be paranoid about security settings */
        define('GESHI_SECURITY_PARANOID', false);
    }
  • Mini feedback optie, like here

/* DokuWiki auteur bedanken: Logitech Harmony One Universal-Fernb?edienung → dokuwiki auteur? http://www.xing.com/profile/Andreas_Gohr

TODO: dokuwiki images If the inserted images don't display in the editor until after the page is displayed you may have a permissions problem with the media files. Add a .htaccess file into (webroot)/data/media/ with the lines order allow,deny allow from all

<dokuwiki>/_media/image.png
mkdir -p <dokuwiki>/_media/

CHECK: < code php >'div' linkt naar http://december.com/html/4/element/div.html

Dokuwiki: folding– → -, “ → `` (fancy) uitzetten -include files for download: fstab, config, vm-template/rootfs/etc/network/interfaces etc ?

*/

/*

mkdir <BEGIN GeSHi>path_to_DokuWiki<END GeSHi>/images</conf>
Copy some image files (.jpg, .gif, .png) there, and now you can use:
<code conf>{{images/<BEGIN GeSHi>imagefilename.extension<END GeSHi>}}

to display the image without having to use the media manager. */ Place image files (.jpg, .gif, .png) in the folder /data/media/ and you can use:

{{<BEGIN GeSHi>imagefilename.extension<END GeSHi>}}

to display the image without having to use the media manager.

dokuwiki.txt · Last modified: 2023-02-28 16:44 by 127.0.0.1