Mediawiki 開發擴展

出自六年制學程
在2015年9月26日 (六) 15:26由丁志仁對話 | 貢獻所做的修訂版本

跳轉到: 導覽搜尋

視覺化編輯器(visual editer)

  • 需要 Parsoid
  • 設 $wgVisualEditorParsoidPrefix = 'localhost';
  • 設 $wgVisualEditorParsoidURL = 'http://localhost:8000'; // Debian,port是8142
  • 設 $wgDefaultUserOptions['visualeditor-enable'] = 1;
  • $wgHiddenPrefs[] = 'visualeditor-enable'; // 不許關閉,若要用 wiki 碼編,不用此行
  • 設 require_once "$IP/extensions/VisualEditor/VisualEditor.php";
  • MediaWiki 1.23,還需要額外的 PHP Parsoid 插件,之後的版本不用。

使用 Mimetex

這種方法實質上是利用外部的 cgi 鏈接來幫我們生成公式圖片,比較靈活,我們可以使用自定義的標籤或者修改代碼來實現。

自定義標籤方法見:Extension:Mimetex alternative

修改代碼使 math 也能過濾到使用 mimetex 見:利用外鏈CGI為Mediawiki添加數學公式支援

第二種方法是修改 includes/Math.php 下的 renderMath 方法:

public static function renderMath( $tex, $params=array() ) {
#	global $wgUser;
#	$math = new MathRenderer( $tex, $params );
#	$math->setOutputMode( $wgUser->getOption('math'));
#	return $math->render();
	return "<img class='tex' src='http://www.forkosh.dreamhost.com/mathtex.cgi?".rawurlencode($tex)."' alt='LaTeX:".htmlspecialchars($tex)."'>";
}