Maintenance: Integration with MediaWiki
From Automated Assistance for Formal Reasoning
This article documents how to take the latest MediaWiki release and integrate it with aartifact. The following assumes that aartifact is installed in the directory /var/www/pub/, and that MediaWiki has been installed in the directory /var/www/pub/wiki/ and is functioning properly.
Contents |
[edit] Recommended cosmetic changes (optional)
- Adjust the footer (
wiki/skins/MonoBook.php):- remove the "powered by" icon;
- in the footer links section, leave only "last modified";
- add copyright and contact information to the footer links.
- Adjust MediaWiki settings (
wiki/LocalSettings.php):- remove the logo:
$wgLogo = "";
- two options are available for disabling section editing links:
- disable it by default for users, but allow them to enable it individually:
$wgDefaultUserOptions['editsection'] = 0;
- disable all editing buttons (including the top at the top of each page) for everyone by adding to the article MediaWiki:Common.css the following:
li#ca-edit { display: none; }
- disable it by default for users, but allow them to enable it individually:
- disable the editing toolbar by default:
$wgDefaultUserOptions['showtoolbar'] = 0;
- remove the logo:
- Set up naming and titles (
wiki/includes/OutputPage.php):- adjust the HTML and page title code:
public function getHTMLTitle() {
$title = $this->mHTMLtitle;
$title = str_replace('Main Page - ', 'aartifact - ', $title);
$title = str_replace('Aartifact', 'aartifact', $title);
return ($title);
}
public function getPageTitle() {
$title = $this->mPagetitle;
$title = str_replace('Main Page', 'Automated Assistance for Formal Reasoning', $title);
$title = str_replace('Aartifact', 'aartifact', $title);
return ($title);
}
[edit] Permissions (optional)
- Permissions for creating and editing articles can be set in
wiki/LocalSettings.php; for example:$wgGroupPermissions['*']['createaccount'] = false;$wgGroupPermissions['*']['createpage'] = false;$wgGroupPermissions['*']['createtalk'] = false;$wgGroupPermissions['*']['edit'] = false;
- To disable editing without modifying group permissions, add the following to the top of the
EditPage->attemptSave()function definition inwiki/includes/EditPage.php:- to disable editing by anonymous users without modifying permissions:
if ($wgTitle->getNamespace() == NS_USER) {$wgOut->addHtml("The <b>User</b> namespace has been disabled.");return false;
}
- to disable creation of User pages:
if ($wgUser->isAnon()) {$wgOut->addHtml("Saving of anonymous edits has been disabled .");return false;}
- to disable editing by anonymous users without modifying permissions:
[edit] Configuration integration (optional)
To make it possible to specify in pvt/aartifact.ini the MySQL credentials and information used by the MediaWiki instance, modify wiki/LocalSettings.php by adding the following (e.g. to the end of the file):
$aartifact_ini = parse_ini_file('../../pvt/aartifact.ini'); ## aartifact()
$wgDBtype = "mysql";
$wgDBserver = $aartifact_ini['mediawiki_mysql_server'];
$wgDBname = $aartifact_ini['mediawiki_mysql_name'];
$wgDBuser = $aartifact_ini['mediawiki_mysql_user'];
$wgDBpassword = $aartifact_ini['mediawiki_mysql_password'];
[edit] Editing and authoring interface
- Add new interface components (
wiki/includes/EditPage.php):- add the following inclusion to the top of the
EditPage.phpfile:include_once("/var/www/pub/component.interface/library.mediawiki.php"); // aartifact()
- inside the edit form, immediately before the
$wgOut->addHTMLblock or line that adds thetextareaelement (usually with identifierwpTextbox1), add the following line:-
$wgOut->addHTML(mkInterfaceStart()); // aartifact()
-
- to the main
textareaform element (usually with identifierwpTextbox1), make sure the following handlers exist:-
onclick="return(aacursor(this))" -
onkeyup="return(aacursor(this))" -
onkeydown="return(aacursor(this))" -
onkeypress="return(aacursor(this))" -
onmouseup="return(aacursor(this))"
-
- after the code displaying the
textareaelement, add the following line:-
$wgOut->addHTML(mkInterfaceEnd()); // aartifact()
-
- add the following inclusion to the top of the
- Remove elements if desired (
wiki/includes/EditPage.php):- summary dialog box.
[edit] Parsing syntax and LaTeX support
There are three options for setting up parsing of mathematical notation. All three require the following modifications.
- Introduce the aartifact syntax parsing function into the MediaWiki parsing process (
wiki/include/parser/Parser.php):- add the following inclusion to the top of the parser file:
include_once("/var/www/pub/component.interface/library.mediawiki.php"); // aartifact()
- add extra step to parse and convert raw article text by adding the following to the top of the
Parser->internalParsefunction definition:-
if (nonSpecNameSpace($this->mTitle)) $text = convMath($text); // aartifact()
-
- add the following inclusion to the top of the parser file:
Next, choose one of three possible options for LaTeX parsing and display support.
[edit] LaTeX source only
Under this option, when an article is viewed, the LaTeX source for mathematical notation will be displayed as it was entered by the user.
- Set the appropriate
aartifact.inisettings:- set the
mediawiki_mathsetting toSOURCE:-
mediawiki_math = SOURCE
-
- set the
[edit] LaTeX support without texcv
This option is appropriate for environments in which setting up the texcv component provided by MediaWiki is too cumbersome (e.g. OCaml is not available or difficult to install, such as on an AWS EC2 Micro image instance). Under this setting, in most cases the source will be displayed; in some cases, it will be replaced with HTML formatting.
- Set MediaWiki to use LaTeX (
wiki/LocalSettings.php):-
$wgUseTeX = true;
-
- Set the appropriate
aartifact.inisettings:- set the
mediawiki_mathsetting toHTML:-
mediawiki_math = HTML
-
- set the
- Modify the MediaWiki component that handles math text (
wiki/includes/Math.php):- add the following inclusion to the top of the file:
-
include_once("/var/www/pub/component.interface/library.mediawiki.php"); // aartifact()
-
- modify the body of the
MathRenderer->renderfunction:- remove the block of code that checks for
texcv, callstexcv, determines what this call returned (i.e. the file name and/or formatted HTML), and handles associated errors; be sure not to remove the code that saves the information into the database (this code immediately follows thetexvcsection); - add the following code in its place (this code will call the procedure
mkPng, which acts as a substitute fortexcvby creating a LaTeX file, converting it to PNG format, and returning the location of the temporary PNG file; this code then moves the file to its final location; this code should be followed by code that insert this instance of mathematical notation back into the database):
- remove the block of code that checks for
- add the following inclusion to the top of the file:
$contents = mkPng(' '.$this->tex.' ');
$this->html = null;
$this->mathml = null;
$this->conservativeness = 0;
$this->hash = $contents;
wfRunHooks( 'MathAfterTexvc', array( &$this, &$errmsg ) );
$hashpath = $this->_getHashPath();
@wfMkdirParents( $hashpath, 0755 );
rename( "$wgTmpDirectory/{$this->hash}.png", "$hashpath/{$this->hash}.png" );
[edit] LaTeX support with texcv
This portion of the documentation has not yet been written.