TuM'Fatig as DokuWiki on NetBSD

    

This is how I installed and configured DokuWiki on NetBSD to render TuM’Fatig website.

Basic installation

Of course, install NetBSD and a PHP capable Web server.

Get the DokuWiki tarball and extract it into your preferred directory.

Browse the install URL and configure the DokuWiki basics.

Basic configuration

Connect to DokuWiki using the administrator password you just configured.
Click the “Admin” button and review the default parameters.

Customizing

The nice looking theme

I personnaly don’t really like the default look from DokuWiki. So let’s install another theme. Have a look at the template page and make your selection.

Until I find one that 100% fits me, I’ll use r7throot7.

Download and install the theme. Enable it from the admin section. Et voilà !

The RSS aggregator

I want to configure a page that summarizes every RSS feeds I usually read on my free time. DokuWiki has a option for RSS reading. It is really neat but, in my case, it is a bit too long to render the page - I have about 6 RSS feed to render and it takes about 10 seconds to render the page.

To optimize this, the idea is to configure the RSS feeding in the DokuWiki way and then force the rendering of the page via the server’s crontab. A script will fetch the DokuWiki URL and export it to HTML. Then it will include the rendered HTML code into the DokuWiki page and want to link to.

Not clear? Here we go !

Configure DokuWiki

If it is not already done, Allow embedded HTML from Dokuwiki’s parameters.

Create the DokuWiki RSS aggregator page

Browse to http://localhost/doku.php?id=news and create the following page.

====== BSD news ======  
{{rss>http://pipes.yahoo.com/pipes/pipe.run?\_id=hAaSh3eq3RGFSMoy\_w6H4A&_render=rss 10 10m}}

====== Apple News ======  
{{rss>http://pipes.yahoo.com/pipes/pipe.run?\_id=6ea171b4864d8349cdb69be57ad6970a&\_render=rss 10 10m}}

====== Matériel ======  
{{rss>http://pipes.yahoo.com/pipes/pipe.run?\_id=9b0ed5d7e250d4b19f3f20ad6c687e07&\_render=rss 10 10m}}

====== Freenews ======  
{{rss>http://pipes.yahoo.com/pipes/pipe.run?\_id=8b94277164fa68ef5a26abc469745fbc&\_render=rss 10 10m}}

====== Gizmodo ======  
{{rss>http://pipes.yahoo.com/pipes/pipe.run?\_id=528765981fefd8a8b613963d4f0ee2a6&\_render=rss 10 10m}}

Now log onto your server and create the rendering script in the bin directory of the DokuWiki installation:

...  
RSS_URL="doku.php?id=news&do=export_xhtmlbody"  
...  
ftp -V -o $TMP_FILE "http://$RSS_SITE/$RSS_URL"

Configure the script to be run by cron every 10 minutes. This will enable the automatic rendering of the page as the default home page ; that means that you won’t notice the update delay

Finally, check the rendered page. Don’t forget to configure the Start page name. Have it pointing to the generated page.

Document repository

I got the habbit of keeping the documentation I found on the Internet. This way, it is faster to find again and I can fill my memory with other (real) things. The need is to be able to create/read/maintain the document repository from my LAN and from the Wild Wild World.

I’ll use a dedicated directory of the media’s directory. I’ll configure the HTTP and SAMBA service to access it from WebDAV and Windows’ network neighborhood. I’ll use the filelist dokuwiki’s plugin to render the repository. The repository management will be done using the native DW’s media manager.

First, create the data/media/docs directory and set the permissions to 0775 to enable group writing rights. Then install the filelist plugin.

There will be two kinds of storage, matching the two kinds of documents. The “my article” section will grow following the usual DokuWiki way of life, using the docs:*: namesepaces. The rest of the document repository will be managed through WebDAV, SMB or the media manager and rendered using the filelist plugin.

The code for accessing the wiki articles is :

[[docs:systeme:dokuwiki\_at\_tumfatig|DokuWiki - How I build mine]]

The code for accessing the repository is :

{{filelist>data/media/docs/Système/BSD/*&style=table&tableheader=1&tableshowdatte=1&tableshowsize=1&direct=1}}

[UPDATE 11/09/2009] As I now own a MacBook Pro 13", I don’t use repository anymore. Everything is on the Mac.

In the same way, I like to keep a few images I found on the Internet to use as wallpaper. Read the Gallery Plugin page and install it with the plugin manager.

Blogging

Since I decided to write down about stuff I do, blogging seems a good thing to advertise it.

Read the DokuWiki blogging tips.
Install the plugin bundle configured with the Linkback, Bloglinks and Tag optional plugins.
Create the blog page and paste the following code:

{{blog>?5}}

Configure the plugin»blog»dateprefix. I used %Y:%m%d_ as proposed in the documentation. Create your first blog entry.

Boxing

There are cases when I like to fill the screen as much as possible. Therefore I organize contents with column. One way to achieve this is to create boxes.

Add the boxes plugin and surround text zones with <box> and </box> markups.

I also installed the clearfloat plugin to allow correct div cleaning after the boxes. I can then define column rendering using (<box>,<box><clearfloat>) layout.

Multiple language

As I’m half Brit, I want my website to be available in French and English.

Well… the real reason is that if I finally start writing (usefull) documentation, they’d better be readable in something more universal than French :p

First of all, install the translation plugin. Then configure the plugin as follow:

plugin»translation»translations = en  
plugin»translation»translateui = true

That allows the Wiki interface to be translated according to the language namespace that you select ; id=about will use the default language and id=en:about will use the English translation.

Now, I’d like to have the menu translated too. The theme I build uses standard pages to display the menu and quick links. I have to modify my theme so that is includes the page corresponding to the language indicated in the URL namespace. The language/namespace discovery will be done by parsing the $ID variable.

The original HTML code is:

<!-- menu -->
  <div id="menu">
    <?php print p_wiki_xhtml("menu", '', false); ?>
  </div>

The modified HTML code is:

<?php
  $RID = preg_replace('/^en:/i', '', $ID);
  if ( "$RID" == "$ID" ) {
    // Language is French (not English)
    $FR_ID = $ID;
    $EN_ID = "en:$ID";
    $MENU_ID = "menu";
    $QLNK_ID = "qlinks";
  } else {
    // Language is English
    $FR_ID = $RID;
    $EN_ID = $ID;
    $MENU_ID = "en:menu";
    $QLNK_ID = "en:qlinks";
  }
?>
...
<div id="quick-links">
  <?php print p_wiki_xhtml($QLNK_ID, '', false); ?>
</div
...  
<!- menu ->  
<div id="menu">  
<?php print p\_wiki\_xhtml($MENU_ID, ", false); ?>  
</div>

Create the menu, en:menu, qlinks and en:qlinks pages.

Add the language switch somewhere in the template. I used flag images:

<a href="<?php echo wl($FR\_ID); ?>" hreflang="fr"><?php echo '<img src="'.DOKU\_TPL.'images/lang-fr.png"/>'?></a>  
   
<a href="<?php echo wl($EN\_ID); ?>" hreflang="en"><?php echo '<img src="'.DOKU\_TPL.'images/lang-en.png"/>'?></a> 

Numbered Headings

When a post gets quite long, rendering the headers should be changed: they should be numbered.

This is achieved by installing the Numbered Headings plugin. Then add a - in the header declaration.

Clean URL

Quoting DokuWiki rewrite section:

By default, DokuWiki does no URL rewriting, resulting in URLs like this http://example.com/doku.php?id=page. These URLs are considered ugly and are not indexed well by some search engines.

This is how to enable clean URL from the web server side.

First, configure the rewrite rules on the server. Here are the directions for Lighttpd:

(...)  
server.modules = (  
(...)  
"mod_rewrite",  
(...)  
$HTTP["host"] == "www.tumfatig.net" {  
(...)  
$HTTP["url"] =~ "/(.|_)ht" { url.access-deny = ( "" ) }  
$HTTP["url"] =~ "^" + "/(bin|data|inc|conf)/" { url.access-deny = ( "" ) }  
$HTTP["url"] =~ "^" { index-file.names = ("doku.php") }  
url.rewrite = (  
"^" + "/lib/.*$" => "$0",  
"^" + "/_media/(.\*)??(.\*)$" => "/lib/exe/fetch.php?media=$1&$2",  
"^" + "/_media/(.*)$" => "/lib/exe/fetch.php?media=$1",  
"^" + "/_detail/(.\*)??(.\*)$" => "/lib/exe/detail.php?media=$1&$2",  
"^" + "/_detail/(.*)?$" => "/lib/exe/detail.php?media=$1",  
"^" + "/\_export/([^/]+)/(.\*)?(.\*)$" => "/doku.php?do=export\_$1&id=$2&$3",  
"^" + "/\_export/([^/]+)/(.*)" => "/doku.php?do=export\_$1&id=$2",  
"^" + "/doku.php.*" => "$0",  
"^" + "/feed.php.*" => "$0",  
"^" + "/(.\*)?(.\*)" => "/doku.php?id=$1&$2",  
"^" + "/(.*)" => "/doku.php?id=$1"  
)  
(...) 

Then, enable clean url on dokuwiki:

# vi conf/local.php  
(...)  
$conf['userewrite'] = 1;  
$conf['useslash'] = 1;  
$conf['sepchar'] = '-';  
(...) 

Finally, restart the web server and enjoy!