MediaWikiの設定

提供: sha.ngri.la
2017年11月9日 (木) 14:00時点におけるTara.ttm (トーク | 投稿記録)による版 (MediaWiki:Sitenotice)
移動先: 案内検索

テンプレートの利用

テンプレートの作成と読み込み

記事の編集中に

{{テンプレート名}}

と書いて一旦保存すると、該当のテンプレートへのリンクが表示されるので、そのリンクをたどってテンプレートを編集する。

記事の読み込み

記事の内容を読み込むときには、

{{:ページ名}}

と記載する。

読み込みの制限

<noinclude></noinclude>タグで囲まれた部分は、引用先で表示されない。<includeonly></includeonly>で囲まれた部分は、引用先でのみ表示されて、元のページでは表示されない。

目次を隠す。

__NOTOC__をページに記載する。

外部リンクを新しいタブで開くようにする。

  1. Manual:$wgExternalLinkTarget - MediaWiki
  2. LocalSettings.phpに次の行を追加する。
$wgExternalLinkTarget = '_blank';

Google Analyticsを利用する。

  1. require_once( "$IP/extensions/googleAnalytics/googleAnalytics.php" );
  2. wiki-install-folder/extensions/googleAnalyticsという名前のフォルダをつくる。
  3. Download MediaWiki extension - MediaWikiからエクステンションファイルをダウンロードして解凍する。
  4. LocalSettings.phpに次の行を追加する。
require_once "$IP/extensions/googleAnalytics/googleAnalytics.php";
// Replace xxxxxxx-x with YOUR GoogleAnalytics UA number
$wgGoogleAnalyticsAccount = 'UA-xxxxxxx-x'; 
// Add HTML code for any additional web analytics (can be used alone or with $wgGoogleAnalyticsAccount)
$wgGoogleAnalyticsOtherCode = '<script type="text/javascript" src="https://analytics.example.com/tracking.js"></script>';

// Optional configuration (for defaults see googleAnalytics.php)
// Store full IP address in Google Universal Analytics (see https://support.google.com/analytics/answer/2763052?hl=en for details)
$wgGoogleAnalyticsAnonymizeIP = false; 
// Array with NUMERIC namespace IDs where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnoreNsIDs = array(500);
// Array with page names (see magic word Extension:Google Analytics Integration) where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnorePages = array('ArticleX', 'Foo:Bar');
// Array with special pages where web analytics code should NOT be included.
$wgGoogleAnalyticsIgnoreSpecials = array( 'Userlogin', 'Userlogout', 'Preferences', 'ChangePassword', 'OATH');
// Use 'noanalytics' permission to exclude specific user groups from web analytics, e.g.
$wgGroupPermissions['sysop']['noanalytics'] = true;
$wgGroupPermissions['bot']['noanalytics'] = true;
// To exclude all logged in users give 'noanalytics' permission to 'user' group, i.e.
$wgGroupPermissions['user']['noanalytics'] = true;

ページタイトルの先頭の文字を大文字にしない

  1. MacWiki - MacWiki:MediaWikiのインストール
  2. MediaWikiのカスタマイズ(3) タイトルの最初の文字を大文字に変換しない - nak on the web system side
  3. LocalSettings.phpに次の行を追加する。
$wgCapitalLinks = false;

ページタイトルを置き換える。

  1. Manual:$wgAllowDisplayTitle - MediaWiki
  2. 例えば、ページ名をiPodにしてもIPodと表示される。{{DISPLAYtitle:iPod}}と表示すると、iPodとiを小文字で表示する。置き換えると言ってもiPodがタイトルのページで{{DISPLAYTITLE:Foo}}と書いても機能しない。
  3. LocalSettings.phpに次の行を追加する。
$wgAllowDisplayTitle=true;

Google Maps

外部サイトのファイル

外部サイトの画像ファイルを直接埋め込む。

LocalSettings.phpに

$wgAllowExternalImages=true;

を追加する。

使用方法

http://sample.url/img/sampleimage.jpg

URLを書き込むだけ。

自動リンクを回避する

<nowiki>http://sha.ngri.la/</nowiki>

サイドバーの設定

サイドバーの設定のページを編集する。

** リンクするページ|表示名

[]で囲む必要はない。表示名を省略すると表示されない。

mobile

複数ファイルの一括アップロード

MediaWikiのバージョンを調べる

Extension:MsUpload - MediaWiki

  1. extensionのファイルをダウンロードする際に自分が使っているMediaWikiのバージョンを聞かれるのであらかじめ調べておく。

extensionファイルのダウンロードと解凍

Download MediaWiki extension - MediaWikiからファイルをextensionsフォルダにダウンロードして解凍。

LocalSettings.phpの編集1

LocalSettings.phpに次の項目を追加。

require_once "$IP/extensions/MsUpload/MsUpload.php";

LocalSettings.phpの編集2

LocalSettings.phpに次の項目を追加。必要に応じて設定内容を変える。(アップロード可能なファイルタイプなど)

$wgMSU_showAutoCat = true; // If true, files uploaded while editing a category will be added to that category
$wgMSU_checkAutoCat = true; // Whether the checkbox for the above mentioned case is checked by default
$wgMSU_imgParams = '400px'; // The default parameters for inserted images
$wgMSU_useDragDrop = true; // Should the drag & drop area be shown?
$wgMSU_useMsLinks = false; // Should we allow to insert links in the style of the Extension:MsLinks?

$wgEnableWriteAPI = true; // Enable the API
$wgEnableUploads = true; // Enable uploads
$wgAllowJavaUploads = true; // Solves problem with Office 2007 and newer files (docx, xlsx, etc.)
$wgGroupPermissions['user']['upload'] = true; // Allow regular users to upload files
// Make sure that the file types you want to upload are allowed:
$wgFileExtensions = array( 'bmp', 'doc', 'docx', 'flac', 'gif', 'ico', 'jpeg', 'jpg', 'mp3', 'mpp', 'odg', 'odp', 'ods', 'odt', 'ogg', 'pdf', 'png', 'ppt', 'pptx', 'ps', 'rtf', 'svg', 'swf', 'tif', 'tiff', 'xls', 'xlsx', 'xml' );

メンテナンス スクリプト

wikiのパス/maintenance以下にあります。

edit.php

$ edit.php "タイトル" < ウィキテキストを含んだファイル

Extension:Cite

<ref><references />で脚注を利用するには、拡張機能Citeを利用します。

cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Cite.git

最初からインストールされていたような気がするので、extensions/Cite/のディレクトリがあるかインストール前に要確認。

LocalSettings.phpの末尾に次の行を追加。

wfLoadExtension( 'Cite' );

MediaWiki:Sitenotice

全ページに表示するヘッダーを設定するには、MediaWiki:Sitenoticeに記載します。

設定のページ