Difference between revisions of "Extension:EmailToWiki"
From Biowikifarm Metawiki
m |
m (→Notes on the Wiki) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
<syntaxhighlight lang=php> | <syntaxhighlight lang=php> | ||
− | + | /* 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; | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 28: | Line 62: | ||
If using a Windows server you can get Perl from [http://www.activeperl.org 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 [[w:crontab|<code>/etc/crontab</code>]] with a line similar to the following which calls the script once every 5 minutes. | If using a Windows server you can get Perl from [http://www.activeperl.org 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 [[w:crontab|<code>/etc/crontab</code>]] with a line similar to the following which calls the script once every 5 minutes. | ||
− | */5 * * * * root /var/www/ | + | */5 * * * * root /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl > /dev/null |
+ | # logs go to /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.log | ||
+ | |||
+ | Make sure the script can be executed: | ||
+ | sudo chmod u+x,g-x,o-x /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl | ||
+ | == Notes on the Wiki == | ||
− | + | The configuration <code>EmailToWiki.conf</code> will work for ''one'' Wiki only. Some tips: | |
* for each wiki a separate extension folder, configure each differently | * for each wiki a separate extension folder, configure each differently | ||
+ | * some e-mail provider allow not by default to gather IMAP externally, check this in the providers settings | ||
+ | * in case of login errors you can switch on debug in EmailToWiki.pl (see http://search.cpan.org/~jettero/Net-IMAP-Simple-1.2206/Simple.pod#OBJECT_CREATION_METHOD) by recoding it. | ||
+ | * EmailToWiki.conf should be readable ''only'' for the user (root) specified doing the cron job, nobody else | ||
+ | * Finally create the template specified in EmailToWiki.conf | ||
+ | * to search these imported pages it you must turn on "show bots" at the search settings |
Latest revision as of 11:29, 9 October 2016
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 # logs go to /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.log
Make sure the script can be executed:
sudo chmod u+x,g-x,o-x /var/www/v-on/w/extensions/EmailToWiki_onwiki/EmailToWiki.pl
Notes on the Wiki
The configuration EmailToWiki.conf
will work for one Wiki only. Some tips:
- for each wiki a separate extension folder, configure each differently
- some e-mail provider allow not by default to gather IMAP externally, check this in the providers settings
- in case of login errors you can switch on debug in EmailToWiki.pl (see http://search.cpan.org/~jettero/Net-IMAP-Simple-1.2206/Simple.pod#OBJECT_CREATION_METHOD) by recoding it.
- EmailToWiki.conf should be readable only for the user (root) specified doing the cron job, nobody else
- Finally create the template specified in EmailToWiki.conf
- to search these imported pages it you must turn on "show bots" at the search settings