MoreMenu

From Meta, a Wikimedia project coordination wiki
This page is a translated version of the page MoreMenu and the translation is 83% complete.
MoreMenu
ジミー・ウェールズの貢献を分析した結果
解説一般的なタスク、利用者またはページの統計ツールやログに便利なリンクを提供する
執筆者MusikAnimal
更新日2023-07-25 (241 days ago)
バージョン5.1.23
ソースGitHub
外装のサポートすべて
ブラウザのサポート「モダン」ブラウザすべてで、詳細は互換性#ブラウザを参照

モアメニュー(MoreMenu)というスクリプトは、ツールバーに置いたドロップダウン・メニューに既定で「ページ」を、適切な場合には「利用者」を追加します。Haza-w Drop-down menus(ドロップダウンメニュー)ガジェットの後継であり、前例に大きな影響を受けています。

概要

このガジェットは最大2本のドロップダウンメニューをメニューバーに追加し、一般的なタスクに使えるリンク、利用者またはページのログ、利用解析または統計ツール、また管理者用のツール類を用意します。特別ページを例外として、「ページ」 メニューを表示します。「利用者」メニューは特定の利用者に当てはまるページに限定して現れ、これには投稿記録ページも含まれます。

画面キャプチャ。ドロップダウンメニューの「ページ」に対するアクセス解析 Analytics のメニュー。
Coolest Tool Award 2022 logo
MoreMenu

2022 Coolest Tool
Award Winner

in the category
Editor

特定の権限がないと表示されないリンクもあります(例:リンクのブロック用のblock。)その他に、「利用者」メニューの項目は表示している利用者の、たとえば先方の 利用者権限、あるいは現在もしくは過去にブロックされたかどうかなどに応じて表示されます。たとえばブロック記録 項目が小メニューの「ブロック」に現れるのは、当該の利用者が過去にブロックされている場合のみです。またその他のリンクで、特定の名前空間や個別のプロジェクトに限定して表示されます。

インストール

グローバルなインストール (推奨)

お使いのglobal.jsに以下を追加します。

mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');

するとコアなモジュールをすべてインポートし、スクリプトを機能させてどのウィキでも使えるようになります。

ウィキペディア英語版の拡張機能

ウィキメディア英語版の利用者には、common.js を開き英語版用の拡張機能を インポートし、状況に応じて RfA/RfB 類と XfD 用のメニュー項目を追加します。

mw.loader.using(['mediawiki.util', 'mediawiki.api'], function () {
	mw.loader.load('https://en.wikipedia.org/w/?title=MediaWiki:Gadget-MoreMenu.enwiki.js&action=raw&ctype=text/javascript');
});

類似の拡張機能はどのウィキにも追加できるはずで、もしくはお使いのウィキに既に存在するかもしれません。以下のカスタム化にて詳細をご参照ください。

ページ読み込みによりメニューの位置が変わる

ベクター外装の利用者には、最上部のタブ類(「編集」「履歴を見る」その他)の位置が変わってしまう現象を予防できます。英語版 利用者の場合、お使いのglobal.css最上段に,以下を追加してください。

@import url('https://meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-MoreMenu-pagestyles.en.css&action=raw&ctype=text/css');

英語以外 の場合はパスにある.en を希望の言語のものに書き換えます。サポートする言語はSpecial:PrefixIndex/MediaWiki:Gadget-MoreMenu-pagestyles の一覧をご参照ください。 もしお使いの言語が見当たらない場合には、トークページ に投稿してメンテナーにお知らせください。

ガジェットとしてインストールする方法

お使いのウィキでこの MoreMenu を個人設定のガジェットタブに載せていることがあります。そうは言ってもグローバルなインストール方法が推奨されており、どのウィキでも MoreMenu は利用可能です。

インターフェース管理者の皆さんは、お使いのウィキでガジェットとしてインストールを希望する場合、以下の手順に従ってください。

  1. 以下の通り MediaWiki:Gadget-MoreMenu-local.js を作成。
    mw.loader.load('https://meta.wikimedia.org/w/load.php?modules=ext.gadget.MoreMenu');
    
  2. 以下をMediaWiki:Gadgets-definitionに加筆。
    * MoreMenu-local[ResourceLoader|dependencies=mediawiki.api,mediawiki.util,user.options]|MoreMenu-local.js
  3. ガジェットの説明をMediaWiki:Gadget-MoreMenu-localに記入し、可能な限りこのページへのリンクを張る([[meta:MoreMenu]]
  4. オプション:ベクター外装でページを読み込んだときにメニューの位置が「飛ばない」ようにするには、ピア・ガジェットを設定します。詳細はピア・ガジェットをご参照ください。
  5. オプション:MoreMenu を拡張して、お使いのウィキ固有のリンク、たとえば管理者権限の申請ページへのリンクを追加します。言語拡張コードを使いMediaWiki:Gadget-MoreMenu.extension.js を作成、 MediaWiki:Gadgets-definition を調整して使います。
    * MoreMenu-local[ResourceLoader|dependencies=mediawiki.api,mediawiki.util,user.options]|MoreMenu-local.js|MoreMenu.extension

翻訳する

翻訳はMediaWiki:Gadget-MoreMenu.messages.lang.jsから取り入れ、フォールバック言語として MediaWiki:Gadget-MoreMenu.messages.en.js を指定します。新しい翻訳を追加するには、トークページで保護されたページの編集の申請をして、マッサージのキーもしくは値のペアを一覧にして書き込みます。現在、サポートしている言語の一覧は Special:PrefixIndex/MediaWiki:Gadget-MoreMenu.messages をご参照ください。

英語の対訳を変更したときは、 プルリクエストを GitHub リポジトリに提出してください。

カスタム化

Options

  • MoreMenu.disableAutoRemovalDon't automatically remove the native "More" menu when it's empty.
  • MoreMenu.prefillDeletionReasonSet to false to disable prefilling the deletion reason when clicking the Delete link.

These options should be set at the top of your global.js, like the following:

MoreMenu = {
    disableAutoRemoval: true,
};

MoreMenu(モアメニュー)にはリンクや機能を追加してカスタマイズができます。moremenu.ready フックを有効にするまで、リンクは追加できません。下記のサンプルをご参照ください。

カスタムのリンクを追加

  • MoreMenu.addLink(menu, name, url, insertAfter)選んだメニューにリンクを追加。
  • MoreMenu.addSubmenuLink(menu, submenu, name, url, insertAfter)選んだサブメニューにリンクを追加。

それぞれのパラメーターを次に解説します。

  • menu — リンクをどこに配置するか示すトップレベルのメニューの ID。 "user" または "page"。
  • submenu — どのサブメニューにリンクを配置するか示す ID。たとえば、"analysis" または "page-logs"。
  • nameThe title for the link. This can be either a raw string or a message key.
  • urlThe URL for the link. Use mw.util.getUrl() for internal links.
  • insertAfter (optional) — The ID of an existing link after which to place the link. You can use false to force the link to be put at the top, and true to force it to the bottom. Otherwise, if no link with the given ID is found, or this parameter is omitted entirely, the link will be placed into the menu alphabetically.

サンプル

To add a link to https://example.org under the "Page" menu, add the following code to your common.js page:

mw.hook('moremenu.ready').add(function (config) {
    MoreMenu.addLink(
        'page',
        'Example',
        'https://www.example.org'
    );
    
    // add more MoreMenu.addLink(); instances here...
    
});

The config object contains a lot of data. In most cases you want your link to contain the target username (config.targetUser.name) or the page name (config.page.name). If these are external links, you may need to use the encoded names, as with config.targetUser.encodedName and config.page.encodedName. See Configuration values for a list of all the available data.

Say you wanted to show a link to the user's "Requests for Adminship" pages under the "Analysis" submenu:

mw.hook('moremenu.ready').add(function (config) {
    MoreMenu.addSubmenuLink(
        'user',
        'analysis',
        'RfAs',
        mw.util.getUrl('Special:PrefixIndex/Wikipedia:Requests for Adminship/' + config.user.name)
    );
    
    // add more links here...
    
});

Now let's say you wanted to add a "RfXs" submenu, with links to RfAs, request for bureaucratship, etc., and only show these links if those pages exist. See Links to pages matching a pattern for how to do this!

高度

Main article: MoreMenu/Advanced

In addition to MoreMenu.addLink() and MoreMenu.addSubmenuLink(), you can take advantage of the logic MoreMenu provides you in constructing your link based on some parameters, such as the user's permissions, or adding an entirely new submenu of links.

詳細は MoreMenu/Advanced をご参照ください。

P2Pのガジェット

このページは、 モアメニューを皆さんのローカルのウィキでガジェットに設定する解説文です。利用者単位のインストール方法は、ページ読み込み時にメニューを変更の項目をご参照ください。

最上位のメニューを追加するとベクター外装の場合、タブの,「閲覧」「編集」「履歴を見る」は位置が変わります。つまりモアメニュー読み込みが終わらないうちに急いで作業しようとすると、偶然、意図と違う場所を押す可能性があるのです。これを予防するには空間を確保するための非公式のガジェット(peer gadget )をインストールします。

最初に、Special:PrefixIndex/MediaWiki:Gadget-MoreMenu-pagestyles を開いてお使いの言語用に CSS コードが用意されているか、皆さんのウィキに転嫁できないか調べます。もしない場合は、バーの横幅を計算してください。ガジェットを有効にしてから、$('.mm-page').outerWidth()$('.mm-user').outerWidth() を走らせてツールバーの幅をパスセル換算で取得します。

幅が決まったら、以下の手順で MediaWiki:Gadget-MoreMenu-local-pagestyles.css を作成します(これは英語版の場合でありpxの代わりにemを使用。)

/*** VECTOR ***/

/* User menu */
.client-js .skin-vector.ns-2 #p-views,
.client-js .skin-vector.ns-3 #p-views,
.client-js > .skin-vector.mw-special-Contributions #p-views,
.client-js > .skin-vector.mw-special-DeletedContributions #p-views,
.client-js > .skin-vector.mw-special-Block #p-views {
    padding-right: 3.68em;
}

/* Page menu */
.client-js .skin-vector:not(.ns-special) #p-views .vector-menu-content::after {
    content: '';
    display: inline-block;
    width: 3.85em;
}

その後でガジェットの設定を次のように更新します。

* MoreMenu-local[ResourceLoader|dependencies=mediawiki.api,mediawiki.util,user.options|peers=MoreMenu-local-pagestyles]|MoreMenu-local.js
* MoreMenu-local-pagestyles[hidden]|MoreMenu-local-pagestyles.css


バグ報告/機能のリクエスト

質問/要望はいずれもトークページで受け付けます。