| External Articles|
Release status: experimental
|Description||Loads article text from external wikis.|
|Author(s)||Nathan Perry, Sam Wilson|
|Latest version||0.4.1 (2017-02-22)|
|License||GNU General Public License 3.0|
Translate the ExternalArticles extension if it is available at translatewiki.net
|Check usage and version matrix.|
|Open tasks · Report a bug|
The ExternalArticles extension imports articles from external wikis or text files:
- When you edit a page, the text of the same page on the external site is preloaded in the edit form.
- A maintenance script can be used to mass-import text files (and monitor changes in those files).
This can save time when importing pages from an external website, or developing pages in a local wiki with an external editor (such as an IDE).
- Download and place the file(s) in a directory called
- Add the following code at the bottom of your LocalSettings.php:
wfLoadExtension( 'ExternalArticles' );
- To use the 'watch' option to monitor pages to import, PHP's inotify extension must be installed.
- Done - Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
This step is optional. If you do not include the below code, this extension will use the defaults. If you define $eagRules, you must define all the elements of it (likely to change later so you can only override the settings you want).
This extension currently has only one configuration variable "$wgEagRules". If you wish to change the default behavior, put the following code in your LocalSettings.php above the
wfLoadExtension() statement for this extension.
// External Articles Configuration $wgEagRules = array(); // Specifies if text will be preloaded on edit $wgEagRules['onpreload'] = true; // Specifies the URL of the external wiki. Must point to the index.php?title= and not the short link $wgEagRules['url'] = 'http://en.wikipedia.org/w/index.php?title='; // Specifies the regular expression used to determine if an article will be preloaded. // See http://us3.php.net/manual/en/function.preg-match.php for more information. #$wgEagRules['rule'] = '/.*/'; // All articles $wgEagRules['rule'] = '/^Template:.*$/'; // Templates only (in English MediaWiki, default) #$wgEagRules['rule'] = '/^.*talk:.*$/'; // Talk pages only (and any page that contains "talk:")
$eagRulesbut was updated to conform to MediaWiki standards in version 0.4.0, and is now
$wgEagRules. Legacy configurations will need to be updated.
Loading external pages when editing
When a page is edited, its title must match the regular expression in
$eagRules['rule']. If it matches, the content of the external article matching the current local page name is fetched and then preloaded into the local edit box. The extension will only preload when creating a new article, and when there is not already a local page being preloaded.
Importing text files
extensions/ExternalArticles/maintenance/importTextFiles.php maintenance script can be used to import text files into a wiki. It is similar to the core script of the same name but enforces certain conventions and adds other features.
The importTextFiles script is given a single argument of a directory name that contains text files that should be imported. Any files in the top level of this directory will be imported into the main namespace of the wiki. There can be subdirectories in this directory, each corresponding to a different namespace in the wiki, and any files in these will be imported into the matching namespace. All file extensions are retained on import (i.e. most normal wiki pages will need to be in files with no file extensions).
--watch option to the importTextFiles script means that the script will remain open and monitor all files for changes. When a file is changed, it will be re-imported immediately. This makes it possible to work on wiki pages in an external editor, and as soon as files are saved they're automatically updated on the wiki.
The default rule does not support languages other than English, as the namespace of a template is assumed to be "Template". When implementing in other languages the template namespace string is localized, so the rule must be updated to fit the current language.
We're looking for feedback on this extension. Security, performance, etc...
Please post feedback to the Extension_talk:ExternalArticles page.
This extension just fetches external wiki-text and inserts it into the edit box. No checking is done to validate or verify the wiki-text, and any edit is attributed to the user running.
The long term goal of this extension is to allow a wiki to use templates or other articles from external MediaWiki wikis without having to import the articles and all the transcluded articles it depends on manually. When an article is demanded (viewed, created, linked to, transcluded) it will be automatically downloaded from the external wiki and added to the local one.
There is no release schedule for this extension. When we have time and motivation to work on this extension, we will do so and make new releases that implement features when it makes sense to do so.
In May 2013, User:Samwilson adopted this extension, moved it into Gerrit, and is in the process of updating it.