(!) please move this nice page to a subpage of HowTo.

Integrating MoinMoin into Joomla!

This page describes how to embed MoinMoin into Joomla!.

What we have done is to set up MoinMoin on the web server under the /wiki URL, so any requests there are sent to the MoinMoin installation and not to Joomla!. Then, moin requests a certain page from Joomla! and embeds the moin stuff in there, see below.

Authentication

See auth plugin for the code and save it as "joomla_auth.py" somewhere on your python path. Then configure moin as follows:

from joomla_auth import JoomlaAuth

class Config(DefaultConfig):
    ...

    joomlaauth = JoomlaAuth(
        mysql_user='MYSQL USER',
        mysql_pass='MYSQL PASSWORD',
        database='JOOMLA DATABASE',
        table_prefix='JOOMLA TABLE PREFIX',
        session_lifetime=JOOMLA SESSION LIFETIME IN SECONDS,
        hash_secret='YOUR HASH SECRET',
        # must be set to a valid group with the current code!
        # you can use ROOT and not set auth_methods_trusted below
        trusted_aro_group='TRUSTED GROUP'
    )
    auth = [joomlaauth]
    userprefs_disabled = ['changepass']
    actions_disabled = ['newaccount']
    # set this if you want useres in the trusted_aro_group to be in Moin's Trusted group
    auth_methods_trusted  = ['joomla_trusted']

    ...

Embedding

To get moin "embedded" into Joomla!, use the theme code as a base and insert appropriate code from Moin's base theme into it. The theme is based on modern so you need to copy the static files correctly, and you also need to edit the CSS to add the #moincontent selector to everything (the theme inserts everything moin generates into a div with that ID.)

Configure moin to force this theme as follows:

class Config(DefaultConfig):
    ...

    # it may be necessary to use an IP address in this URL if the
    # IP address checked against in Joomla! is 127.0.0.1.
    joomla_theme_url = 'embed URL'
    # Host: header that moin should send to Joomla!
    joomla_theme_host = 'hostname'
    # combined URL that Joomla! will generate
    joomla_theme_orig_returnto = 'embed URL with real hostname'
    joomla_charset = 'iso-8859-1'
    theme_default = 'joomla_theme'
    theme_force = True

    ...

Changing the Joomla! Template

You need to insert a comment into your Joomla! Site Template so that the MoinMoin theme can insert the content at the correct place. The theme will replace the data between <!-- Content --> and <!-- /Content -->. As Joomla! will strip all comments from the template, you need to do something like the following:

  <!<!-- -->-- Content --<!-- -->>
  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="height">
          <tr>
                  <td valign="top" class="content padding height">
                          <mos:joomla macro="mainbody" />
                  </td>
          </tr>
  </table>
  <!<!-- -->-- /Content --<!-- -->>

Remote Address Forwarding

MoinMoin will get a Joomla! Page to use it as the template. For this to work properly Joomla! needs know the remote IP adress from MoinMoin. Because of this the MoinMoin theme will forward the IP adress in a special HTTP header, and Joomla! needs to be modified to read out this header.

Edit the sessionCookieValue function in include/joomla.php. First replace $_SERVER['REMOTE_ADDR'] with $remote_addr. Then insert the following code at the top of the function:

        $remote_addr = $_SERVER['REMOTE_ADDR'];
        // use the IP address of the moin host
        if ($remote_addr == '127.0.0.1') {
                if (array_key_exists('HTTP_X_FORWARDED_FROM', $_SERVER)) {
                        $remote_addr = $_SERVER['HTTP_X_FORWARDED_FROM'];
                }
        }

Creating a Joomla! Menu Item

As a first step create a Static Content Item in Joomla and write down its ID. This does not need to contain any special content. After you did this, create a menuitem for the Wiki Page in your Menu. This menuitem should just be a simple URL menuitem, which points to /wiki.

Now you can build the URL to use with joomla_theme_url. It should be http://your.site/content/view/X/Y where X is the ID of the static content page, and Y is the ID of the menuitem. By doing it this way the menu will be shown opened inside the MoinMoin Wiki, and you can add more links inside the submenu.

MoinMoin: JoomlaIntegration (last edited 2009-08-13 22:30:50 by ReimarBauer)