Extension:EmailToWiki

From Biowikifarm Metawiki
Revision as of 14:53, 13 July 2016 by Andreas Plank (Talk | contribs) (+documentation)

Jump to: navigation, search

See Extension:EmailToWiki (MediaWiki)

Installation

  • Download the following source files from the Github mirror.
  • Put all files in a directory called EmailToWiki in the wikis extensions directory (done by bash script)
  • Create an empty directory in EmailToWiki called EmailToWiki.tmp which is writable by the webserver (done by bash script)
  • Create an empty file in EmailToWiki called EmailToWiki.log which is writable by the webserver (done by bash script)
  • Create configuration in a file called EmailToWiki.conf based on the EmailToWiki.conf.sample file (done by bash script)
  • Ensure the configuration file is readable by the Perl script, but not readable by the web-server (done by bash script)
  • Call the script on a regular basis, say every five minutes, from crontab as root or a privileged user
  • Include the PHP script from your LocalSettings.php file like usual:
/* optionally define extra namespace corresponding to EmalToWiki.conf prefix */
if (is_file("$IP/extensions/EmailToWiki_onwiki/EmailToWiki.php")) {
  require_once( "$IP/extensions/EmailToWiki_onwiki/EmailToWiki.php" );
  define("NS_EMAILTOWIKI",      3000);
  define("NS_EMAILTOWIKI_TALK", 3001);
  /**
   * Set $wgExtraNamespaces
   */
  switch ($wgLanguageCode) {
    case "de":
    case "de-formal":
      $wgExtraNamespaces[NS_EMAILTOWIKI]      = "E-Mail";
      $wgExtraNamespaces[NS_EMAILTOWIKI_TALK] = "E-Mail_Diskussion";
      break;
    case "en":
      $wgExtraNamespaces[NS_EMAILTOWIKI]      = "E-mail";
      $wgExtraNamespaces[NS_EMAILTOWIKI_TALK] = "E-mail_talk";
      break;
    case "fr":
      $wgExtraNamespaces[NS_EMAILTOWIKI]      = "E-mail";
      $wgExtraNamespaces[NS_EMAILTOWIKI_TALK] = "E-mail_discussion";
      break;
    default:
      $wgExtraNamespaces[NS_EMAILTOWIKI]      = "E-mail";
      $wgExtraNamespaces[NS_EMAILTOWIKI_TALK] = "E-mail_talk";
      break;
  }

  # require_once( "$IP/extensions/Lockdown/Lockdown.php" );
  $wgNamespacePermissionLockdown[NS_EMAILTOWIKI]['read'] = array('user');
  $wgNamespacePermissionLockdown[NS_EMAILTOWIKI_TALK]['read'] = array('user');
  # prevent inclusion of pages from that namespace
  $wgNonincludableNamespaces[] = NS_EMAILTOWIKI;
  $wgNonincludableNamespaces[] = NS_EMAILTOWIKI_TALK;
}

Install dependencies:

sudo apt-get install libwww-perl libnet-imap-simple-ssl-perl libemail-mime-perl
# The following extra packages will be installed:
#   libemail-address-perl libemail-date-format-perl libemail-messageid-perl libemail-mime-contenttype-perl libemail-mime-encodings-perl libemail-simple-perl
#   libio-socket-inet6-perl libmime-types-perl libnet-imap-simple-perl libparse-recdescent-perl libsocket6-perl
# The following NEW packages will be installed:
#   libemail-address-perl libemail-date-format-perl libemail-messageid-perl libemail-mime-contenttype-perl libemail-mime-encodings-perl libemail-mime-perl
#   libemail-simple-perl libio-socket-inet6-perl libmime-types-perl libnet-imap-simple-perl libnet-imap-simple-ssl-perl libparse-recdescent-perl libsocket6-perl

If using a Windows server you can get Perl from www.activeperl.org and add the execution to you system scheduler from control panel. On Linux you'll already have Perl and you can add the script to your /etc/crontab with a line similar to the following which calls the script once every 5 minutes.

*/5 * * * * root /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl > /dev/null
# */5 * * * * root /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl > /var/log/nginx/offene-naturfuehrer.de-emailtowiki.log

Make sure the script can be executed:

sudo chmod u+x,g+x  /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl

NOTE: The configuration EmailToWiki.conf will only work for one wiki only, work around:

  • for each wiki a separate extension folder, configure each differently