Extension:HeadScript

From mediawiki.org
This page is a translated version of the page Extension:HeadScript and the translation is 64% complete.
MediaWiki 拡張機能マニュアル
HeadScript
リリースの状態: 安定
実装 フック
説明 wikiの</head>の直前にスクリプトを追加
作者
最新バージョン 1.1.1 (2021-12-03)
MediaWiki >= 1.29.0
データベースの変更 いいえ
ライセンス MIT ライセンス
ダウンロード

  • $wgHeadScriptName
  • $wgHeadScriptCode
Quarterly downloads 80 (Ranked 69th)
translatewiki.net で翻訳を利用できる場合は、HeadScript 拡張機能の翻訳にご協力ください

The HeadScript extension allows scripts to easily be added just before ‎</head> of the wiki.

The code for the head script is defined in "LocalSettings.php " and is controlled by variables. This implementation makes it easy for inexperienced users to implement head scripts just before </head> of the wiki. It also makes it possible to add head scripts that cannot be changed or removed, such as would be possible by wiki 管理者 if the head script were added to the Sitenotice . This makes the extension particularly useful for placing Cookie Consent plugin or CSS style links, as such content cannot be removed by abusive or rogue administrators.

インストール

  • ダウンロードして、ファイルをextensions/フォルダー内のHeadScriptという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/HeadScript
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'HeadScript' );
    
  • 必要に応じて設定します。
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

設定

1つまたは複数のヘッドスクリプトをWikiに追加することができます。 ヘッダースクリプトは、任意のHTMLおよび/またはJavaScriptで構成することができます。

To configure the head script, add the following to "LocalSettings.php" after the installation line:

$wgHeadScriptCode = <<<'START_END_MARKER'
<script></script>
START_END_MARKER;

Leave untouched the first and last line with START_END_MARKER stuff, this is a special syntax of PHP (without it, it would be tricky to deal with apostrophes inside the script). Do not add whitespaces around the last line’s marker, it would break it (more details about this syntax). Do add new line after.

スクリプトを追加する場合は、<<<'START_END_MARKER'からSTART_END_MARKER;の間にコードを入れるだけです。

$wgHeadScriptCode = <<<'START_END_MARKER'
<script></script>
<script></script>
<script></script>
START_END_MARKER;

必要に応じて、スクリプトの名前も指定してください。

$wgHeadScriptName = 'my-wonderful-script';

META and LINK elements can also be added, such as:

$wgHeadScriptCode = <<<'START_END_MARKER'
<meta name="author" content="Wikimedia Foundation" />
<link rel="author" type="text/plain" href="/humans.txt" />
<script></script>
START_END_MARKER;

See also