DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:farm

The Farm Plugin

In a farm, one single copy of wiki engine (the farmer) is used to run several individual wikis (the animals).

:!: For general, relevant and up-to-date instructions see farms.

This page describes a plugin that automatizes the redirect approach to farming. Be aware this could be out-dated.

Status

Compatible with DokuWiki

No compatibility info given!

plugin Turns a wiki into a wiki farm and provides farm admin / soap features

Last updated on
2010-01-18
Provides
Admin, Action

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to farmer

Tagged with farm

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to plugin installation on how to install plugins manually.

Download farm.zip Up 2010-01-18

Description

Farming is a technique to greatly lighten the job of multiple wiki-based big services. The goal is to “make all the wikis use one”, that is to say one DokuWiki application, one plugin dir, one template dir, administration through one and only interface, and multiple data sources, one for each animal.

From the user's point of view, it doesn't change anything; it's as if you had lots of wikis, as before.

It is a compilation of techniques discussed here, in the form of a plugin:

For people who can read French, here is my article from JRES2009 about this technique and plugin: Le farming dans DokuWiki, intérêt et mise en œuvre.

The best way to understand what it deals with is to try it.

You'd better install it in a new wiki with no content as it speeds up setup and as reverting from farm transformation isn't easy. This does not mean you will lose data; the plugin will just move your DokuWiki install.

Examples

Suppose you have a file system like this one:

/var/www/doku (where your DokuWiki is installed)

Example 1

If you set farmfsroot to /var/www/doku/, farmer to main/ and barn to wikis/ it will create the following structure:

/var/www/doku
+- main (where are put all the files from your original DokuWiki)
+- wikis (where will be put all the animals

Example 2

If you set farmfsroot to /var/www/doku/, farmer to main/ and barn to “” it creates:

/var/www/doku
+- main (where are put all the files from your original DokuWiki)

And will put all animals directly in /var/www/doku/.

Example 3

If you set farmfsroot to /var/www/, farmer to doku/ and barn to “” it creates:

/var/www/
+- doku (your original setup remains here, farm just adds its utilities)

All animals will be put in /var/www/

If the directory pointed by farmfsroot/barn exists and already contains folders (like animals from another farming system, farm1 or farm2 …) the setup script will ask you whether you want to convert some to the new system, leaving the other untouched.

For now the plugin can only work with userewrite parameter set IN THE FARM CONFIG (the farmer/animals can have userewrite = 0).

You just have to install it and then to go to admin page, click on “wiki farm management” and let the system guide you.

Code is way too big to be here, check out the technical documentation link below to see it.

Technical documentation can be found here: http://sourcesup.cru.fr/dwfarmplugin/

Hints

  • Looks like if using a wiki with no rewrite at all things are a bit dull, still investigating that … Stay tuned!
  • If you put the {ANIMAL} tag in any file (conf / pages …) of an animal and then use it as template the tag will be replaced by the new animal's name
  • DOKU_FARM_ANIMAL and DOKU_IS_FARMER are defined by the pre-loaded script, they can be used in other plugins / template or even config files!

Todo

  • Solve the problem of purely-without-rewrite wikis (mainly paths generated by tpl_metaheaders)
  • Add support for virtual hosting mode coming soon
  • Translate, debug CSS

Discussion

Congratulations

Gorgeous! ;-)
Thanks a lot — deshi


Features request

Great work! Thanks for it.

Do you think it would be difficult to adapt it for userdir wiki. I mean, user A has his/her wiki files in /home/group1/a/public_html/some/dir/wiki/ for example and user B has his/her wiki in /home/group2/b/public_html/ ?

Hervé.

It might not be difficult, you just need to hack animal.class.php and preload.php for having animal::__construct, animal::exists and such to look into a kind of list of username-wikipath pairs, plain file or db …
But it will require quite an amount of lines to be changed I am afraid …

First, congratulations for this very handy piece of code.

Here is a feature request, however. Say you have set up a farm with webroot http://farm.example.com/wiki. With urlrewrite enabled (via .htaccess), you would typically access the farmer at http://farm.example.com/wiki and the animals at http://farm.example.com/wiki/myanimal. Now assume you want to provide DokuWiki instances as name based virtual hosts. For instance you want to access the animal myanimal at http://myanimal.farm.example.com/wiki, where myanimal.farm.example.com and farm.example.com resolve to the same IP. One possibility is to:

Notice that this establishes only a prefered animal: others are still available at http://farm.example.com/wiki/barn/otheranimal, unless you also change access rules in the named virtual host config. This works without difficulty (at least after some hair loss due to fighting Apache rewrite engine). The only problem is that all DokuWiki generated content still refers to pages at http://myanimal.farm.example.com/wiki/myanimal/some_page_name, which works, but is unaesthetic (I precisely want to get rid of the redundant myanimal/ subpath). This is because DOKU_BASE is hardcoded in plugin:farm's preload.php and is set there to http://myanimal.farm.example.com/wiki/myanimal (webroot + animal name).

My question is: could you add a configuration option in the farm plugin, allowing to change DOKU_BASE on a per-animal basis? Or else, does anyone know of an elegant way to solve this problem without too much ad-hoc plumbing. Maybe I missed some easy, standard fix?

iouri on mar 2nd 2010


Bugs

About plugins manager


Schplurtz on feb 1st 2010 :

The pluginmanager works from within the farm. This is not desired and is a DokuWiki bug that is already reported. You may vote for this task→Fixed, it may speed up the resolution…

As a quick fix, edit DokuWiki file lib/plugins/plugin/admin.php and add if( $this→disabled ) return; to functions handle and function html, like this :

function handle() {
  if( $this->disabled ) return;
 
...
...

function html() {
  if( $this->disabled ) return;

About using

Hi Étienne,

First, I have a question about template's config files : when I parameter the config files of animaltemplate (local.php & local.protected.php), their are not completely used by another wiki created by the GUI, in particular if the options into this files concern the plugins, the auth or the Dokuwiki's templates. Is it normal?

On the other hand, I discovered some bugs:

  1. editing modes “Editable configuration” and “Protected configuration” (animal_config_editable & animal_config_protected) does not save the changes ;
  2. the French translation of $lang['config_deletewsdl_failure'] in fr/lang.php is wrong ;
  3. the farm messages (message_* in fr/lang.php) seem to appear in English although the wiki farm is in French (in my case) ;
  4. (when farmer wiki use URL rewriting and useslash is true, images (icons) in farm admin are not displayed when we admin the farm from a page into a namespace. → to check)

Good night and congratulation for your work! — Floriang, 2010-03-03 00:30 :


About statistics

An important improvement would be to display the statistics on demand and not systematically. In case of many large and wikis, the admin page is slow to load and does not load completely. — Floriang, 2010/04/26 18:25


About installing

After pressing the “next” button at the wiki farm management I get this message:

Warning: fopen(/www/htdocs/XXX/chaosboat/wikifarm/lib/plugins/farm/config.php) [function.fopen]: failed to open stream: Permission denied in /www/htdocs/XXX/chaosboat/wikifarm/lib/plugins/farm/install.class.php on line 107

Fatal error: Call to undefined method dokuwiki_farm_install::error() in /www/htdocs/XXX/chaosboat/wikifarm/lib/plugins/farm/install.class.php on line 123

Am I doing anything wrong?


Looks like your PHP engine have no rights to edit /www/htdocs/XXX/chaosboat/wikifarm/lib/plugins/farm/config.php , how are the /www/htdocs/XXX/chaosboat/wikifarm/lib/plugins/farm/ directory permissions?

Etienne

Not working here, checked with DokuWiki-rc2009-12-02 and DokuWiki-2009-12-14b

I do a basic install for DokuWiki at /var/www/farm, then install the farm plugin.

Then I go to manage the farm management plugin and write in the form the following parameters:

  • Farm Web root (ended with /) : http://localhost/farm/
  • Farm DocumentRoot (ended with /) : /var/www/farm/
  • Farmer's directory (ended with /) : farmer/
  • Barn's directory (ended with /) : barn/

Then I press Next button and get the following URL and message:

  http://localhost/farm/farmstructurecreator.php?l=en
  Cannot load DokuWiki rewrite file 

I also tried to create the farm outside fresh installed DokuWiki with this error:

 Cannot load config

Then I go back to the original wiki and get this:

  Warning: scandir(/var/www/farm/barn/) [function.scandir]: failed to open dir: No such file or directory in /var/www/farm/lib/plugins/farm/animal.class.php on line 676
  Warning: scandir() [function.scandir]: (errno 2): No such file or directory in /var/www/farm/lib/plugins/farm/animal.class.php on line 676
  Warning: Invalid argument supplied for foreach() in /var/www/farm/lib/plugins/farm/animal.class.php on line 676

In the /var/www/farm/ directory there is only one file: farmstructurecreator.php

And I also tried to create the farm inside the fresh installed DokuWiki /var/www/dokuwiki/farm with more strange results.

Am I doing anything wrong?

Nestor

Checked out your problems and found out what it was. When starting from fresh DokuWiki install there's no .htaccess but a .htaccess.dist file at docroot, but farm plugin was looking only for .htaccess to mod it, fixed that.

Also fixed some typos and other minor bugs.

The only remaining thing is that the “userewrite” FARM parameter should be checked in farm config (2nd item) otherwise animals images / CSS paths in HTML will be bad, I'm still investigating that …

I rebuild the archive but did NOT update installer so that it will do the work. You will have to re-install everything, but since it looks you didn't succeed in the first place I assume there is no problem with that … :-P

For those who successfully installed the farm (e.g. activated DokuWiki's userewrite and renamed .htaccess.dist to .htaccess before installing the farm) there is no need to re-install everything, just update the plugin to get new lang strings and other bug fixes. — Etienne
Many thanks Etienne :) , as soon as I can I will check again.

About the “image/CSS” problem, you mean theme assets or animal media assets?

Does mediamanager work?
Néstor
Here is another quick fix, I think I got rid of some images / CSS problems, you gave me the hint with the question about mediamanager, and now both works!

The only problem that remains is that I would need a LINK_ADDITIONNAL_PARAMETERS like constant to ensure compatibility with “no rewrite at all” mode wikis…

Thanks a lot!

Etienne

Hi,
thanks a lot for this great plugin. Most works fine, but I've got a problem with the configuration of my subdomains to the different animals. I hope anyone can explain me how to set up. Here my config:

http://wiki.mydomain.net/farm/             #Serverpath
http://wiki.mydomain.net/farm/barn/        #Barn's directory
http://wiki.mydomain.net/farm/farmer/      #Farmer's directory
http://wiki.mydomain.net/farm/barn/wiki1/  #one of the animals
http://animal1.mydomain.net/               #should link to the animal

My question is how to set up the subdomain. In the tips to farm I wrote about virtual hosts, but don't know where and how to set up.


Michael, 22/04/2010

Hi You plugin seems very interresting but I can't finish the installation.

I'm using easyPHP on Windows (sorry I don't the choice). For the DocumentRoot setting by default I have this path C:\Program Files\EasyPHP-5.3.2\www\Dokuwiki_Farm\ but it doesn't work because the plugin ask for a / at the end. But on windows only the \ is using in the path. I have tried different slution without success.


Javier, 12/09/2010

Hi, I can't finish the installation, after pressing the “next” button at the wiki farm management I get this message:

Errors encountered during setup
  * Failed to update install step

Steve, 05/10/2010

I get the same error as Javier on the first page and I'm guessing it's something to do with permissions, but don't know what to check. Any ideas please?


Benat, 27/10/2010

Hi, I get the same error as Javier and Steve. I use FreeBSD and I have set the permissions so that the whole DokuWiki directory is owned by Apache. This is a “try only” fresh DokuWiki install, with no URL rewriting by default, but I have also tried with internal rewriting turned on. I will try to install all the stuff by hand. Am I missing anything obvious? Thanks.

Benat, 01/12/2010

Setting up the farm by hand as explained here worked without any problems, but I had some time today so I decided to give the plugin a new try.

For some odd reason the install script fails at creating the “installed” file :
if(!@touch(DOKU_FARM_PLUGIN.'installed', 'w'))

(install.class.php, line 112). The permissions are correctly set though. I have touched the file manually and I can see the farm management interface. I will investigate further.

RemyA, 01/16/2011

The problem above comes from the use of the second parameter for the touch function. Remove that parameter and it will work.


New DokuWiki version “Anteater” needs a few new lines in preload.php $config_cascade array

  ,
  'userstyle' => array(
      'default' => DOKU_CONF.'userstyle.css',
      'print'   => DOKU_CONF.'printstyle.css',
      'feed'    => DOKU_CONF.'feedstyle.css',
      'all'     => DOKU_CONF.'allstyle.css',
      ),
  'userscript' => array(
      'default' => DOKU_CONF.'userscript.js'
      ),
  'acl'       => array(
      'default'   => DOKU_CONF.'acl.auth.php',
      ),
  'plainauth.users' => array(
      'default' => DOKU_CONF.'users.auth.php',
      ), 

Without these the acl is not working. — oivoiv

2010/11/10 09:10

william, 27/11/2010


Hi, I installed plugin Farm on version “Anteater” without the modifications upwards, and when I try to prameter the plugin in admin / managing farm, I get the 2 messages :

Warning: fopen(/home/erpwiki/www/farmstructurecreator.php) [function.fopen]: failed to open stream: Permission denied in /home/erpwiki/www/lib/plugins/farm/install.class.php on line 120

Warning: Cannot modify header information - headers already sent by (output started at /home/erpwiki/www/lib/plugins/farm/install.class.php:120) in /home/erpwiki/www/inc/actions.php on line 162

and , inglobal overview of the farm the messages : Vue globale

Warning: scandir(/home/erpwiki/www/barn/) [function.scandir]: failed to open dir: No such file or directory in /home/erpwiki/www/lib/plugins/farm/animal.class.php on line 697

Warning: scandir() [function.scandir]: (errno 2): No such file or directory in /home/erpwiki/www/lib/plugins/farm/animal.class.php on line 697

Warning: Invalid argument supplied for foreach() in /home/erpwiki/www/lib/plugins/farm/animal.class.php on line 697

what should be done ? thanks a lot for this work.

It seems that theres sth. wrong with your file permissions? Please check if the webserver has access to /home/erpwiki/www/ and /home/erpwiki/www/farmstructurecreator.php — lupo49Matthias Schulte
lupo49

2010/11/27 23:47

Typo in .htaccess file

Hi. I'm not able (yet) to have this plugin work on ubuntu server lucid lynx apache 2.2.14-5ubuntu8.4 with doku anteater, although I applied the correction indicated in this page. Anyway, I found a typo in file lib/plugins/farm/install/barn.htaccess First line reads

Option -Indexes

while it should read (notice the final s)

Options -Indexes
plugin/farm.txt · Last modified: 2015-09-27 21:14 by Aleksandr