Extension:WikidataPageBanner
この拡張機能は Reading Web チームによって保守されています。 |
![]() リリースの状態: 安定 |
|
---|---|
![]() |
|
実装 | パーサー関数 |
説明 | 指定された名前空間のページにバナーを表示させる |
作者 | (under the mentorship of User:Jdlrobson and User:Syced). (Sumitトーク) |
最新バージョン | 0.0.3 |
MediaWiki | >= 1.38.0 |
PHP | 5.4+ |
Composer | mediawiki/wikidata-page-banner |
ライセンス | GNU 一般公衆利用許諾書 2.0 以降 |
ダウンロード | README |
|
|
pagebanner |
|
translatewiki.net で翻訳を利用できる場合は、WikidataPageBanner 拡張機能の翻訳にご協力ください | |
問題点 | 未解決のタスク · バグを報告 |
WikidataPageBanner拡張機能は指定された名前空間にページバナーを追加します。
Wikivoyageでは広く使われています。 特にWikivoyageのTemplate:pagebannerで多く使用されています。
インストール
- ダウンロードして、ファイルを
extensions/
フォルダー内のWikidataPageBanner
という名前のディレクトリ内に配置します。 - 以下のコードをLocalSettings.phpの末尾に追加します:
wfLoadExtension( 'WikidataPageBanner' );
- 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。
使用法
There are a few different ways to set a banner image on a page:
- バナー画像の指定方法 :カスタムバナー画像として
File:Image_name.jpg
を使用するには、ページ上に設定します。{{PAGEBANNER:Image_name.jpg}}
- この拡張機能は、
$wgWPBImage
設定変数で設定された指定された名前空間のすべてのページに、同じバナー画像を自動的に追加することができます。 - ウィキがウィキデータに接続されている場合、そこから各ページのバナーを取得することもできます。 In this case, the Template:PAGEBANNER must exist (but it can be empty). 英語版 Wikivoyage の Template:Pagebanner の中にはとても複雑な構造を持つものがあります。
パラメータ
{{PAGEBANNER}}
パーサー関数でサポートされているパラメータは以下のとおりです :
pgname
— バナーにカスタムタイトルを挿入します。icon-*
— To add custom icons, add the parametericon-<icon_name>=<Article about icon>
(where<icon_name>
is any icon name that you want). Then define a background-image on.oo-ui-icon-<icon_name>
, in MediaWiki:Common.css to use as the icon. Do this for any number of icons to add to the page.tooltip
— Usetooltip=image-caption
to show image description on hovering over image.toc
— Usetoc=yes
to enable a Table Of Contents within banner.bottomtoc
— Usebottomtoc=yes
to push Table Of Contents below banner. This will affect only the page on which its used. To set site-wide ToC at bottom, see #Styling below.extraClass
— UseextraClass=<css-class names>
(separated by spaces) to add additional classes to banners which can be used to customize it using styles in MediaWiki:Common.cssorigin
— See #origin parameter below.link
— Sets the target of the banner link and operates the same as the link parameter for images (e.g.link=Event name
will link to the 'Event name' page rather than the banner image page). Set to no value to remove the link, i.e.link=
.
'origin' パラメーター
このパラメータによって、画像の焦点エリアを指定できます。
画面が小さい場合にバナー画像を重要な部分のみにトリミングする際に使います。
パラメータはxとyをカンマで区切ったものである必要があります。
各座標は画像の中心からの距離を-1から1までで表しています。
例えば、右上は origin=1,1
で右下は origin=-1,1
です。
See the image at right for a graphical representation of the coordinates.
現在の実装例を見ればわかるように、このパラメータは、通常のバナーよりもはるかに大きい画像(パノラマやポートレート写真など)のためのものであることに留意してください。 バナーを再配置しても、バナースペース内の空白スペースが空になってしまうような時は、バナーの再配置は行われません。 例えば、幅320px、高さ180pxのバナーを表示している場合は、同じ幅320px、高さ180pxの画像では全く位置が変えられませんが、幅600px、高さ180pxの画像であれば横方向、幅320px、高さ1000pxの画像であれば縦方向に位置が変えられます。
環境設定の変数
$wgWPBImageによりバナー画像を指定します。 名前空間名'File:'をつけずに画像名のみを追加してください。 Wikiにデフォルトのバナーが必要なければ使用しないでください。
$wgWPBImage = "foo.jpg";
$wgWPBBannerProperty Banner property on Wikidata which holds a commons media file. Essential if Wikidata is enabled.
$wgWPBBannerProperty = "P948";
$wgWPBEnableDefaultBanner enables the default banner image on pages without the use of {{PAGEBANNER}}
.
$wgWPBEnableDefaultBanner = true;
バナーを表示させる名前空間の$wgWPBNamespaces配列。 デフォルトでは標準名前空間になっています。 true()を指定した場合、$wgWPBDisabledNamespacesで除外されたもの以外のすべての名前空間で有効になります。
$wgWPBNamespaces = [ NS_MAIN ];
$wgWPBDisabledNamespacesによって指定した名前空間でバナー画像が表示されないように設定できます。
ただしこのパラメータは、$wgWPBNamespaces
がtrue
の場合のみ有効です。
そうでない場合、このパラメータは無視され、$wgWPBNamespaces内の名前空間だけが考慮されます。
$wgWPBDisabledNamespaces = [ NS_FILE ];
$wgWPBStandardSizes is an array of standard predefined screen widths in increasing order of size.
$wgWPBStandardSizes = [ 320, 640, 1280, 2560 ];
$wgWPBEnablePageImagesBanners when set to true and Extension:PageImages is installed will use a page image when no Wikidata image or locally defined image is set.
$wgWPBEnablePageImagesBanners = true;
$wgWPBDisplaySubtitleAfterBannerSkins is an array of names of skins that should have the banner displayed in the site-notice area, instead of in the page subtitle (which is the default).
$wgWPBDisplaySubtitleAfterBannerSkins = [ 'minerva' ];
$wgWPBEnableHeadingOverride determines whether the page title is displayed overlayed on the banner image. Defaults to true.
$wgWPBEnableHeadingOverride = true;
$wgWPBEnableMainPage determines whether a banner is allowed to be shown on the Main Page. Defaults to false.
$wgWPBEnableMainPage = false;
Examples
A few use examples with explanation:
{{PAGEBANNER:Grand_canyon.jpg}}
Will add a banner using image Grand_canyon.jpg as source locally or from wikimedia commons.
{{PAGEBANNER:Grand_canyon.jpg|icon-star=<Name of star article>|icon-unesco=<Name of Unesco Article>}}
Will add a banner using image Grand_canyon.jpg as source locally or from wikimedia commons. Additionally will add icons with class names oo-ui-icon-star, oo-ui-icon-unesco. Set background-image property on theses classes in MediaWiki:Common.css to your desired icon.
{{PAGEBANNER:Grand_canyon.jpg|toc=yes|pgname=Some page}}
Will add a banner using image Grand_canyon.jpg as source locally or from Wikimedia Commons. Additionally adds a Table of Contents inside banner. Sets the name displayed on banner as Some page.
{{PAGEBANNER:Grand_canyon.jpg|extraClass=class1 class2}}
This will add a banner using the Grand_canyon.jpg image as source either locally or from Wikimedia Commons. It additionally adds CSS classes class1 and class2 to the .wpb-topbanner div.
Example usage for banner from Wikidata
Make sure $wgWPBBannerProperty
is set to correct Wikidata banner property.
Then leave the image name empty, and set any other required parameters:
{{PAGEBANNER:|other options...}}
This will use the banner image as set on the page's Wikidata item.
If there is no banner image set for that item, or the page doesn't have a Wikidata item,
a default image may be used (if $wgWPBImage
is set).
Styling
The extension has ample scope for styling the banner via Common.css. Here are some examples of common CSS changes.
.wpb-topbanner-toc {
position: relative;
}
This sets the ToC to appear just below the banner in case it's long.
Note that doing this would cause every banner page on a wiki to have the ToC at the bottom of the banner.
However, using bottomtoc=yes
as a paramter would only show the ToC at the bottom on the page it's used.
.wpb-topbanner .wpb-name {
font-size: 1em;
}
Would set the font size of the banner name to 1 em (smaller than the default 2.2 em).
.wpb-banner-toc {
line-height: 1em;
}
Would reduce the vertical spacing between lines of the ToC.
.wpb-topbanner-toc {
margin-top: 5px;
}
Would set some blank space between the banner and ToC.
この拡張機能は 1 つ以上のウィキメディアのプロジェクトで使用されています。 これはおそらく、この拡張機能が安定していて高いトラフィックのウェブサイトでも十分に動作することを意味します。 この拡張機能がインストールされている場所を確認するには、ウィキメディアの設定ファイル CommonSettings.php および InitialiseSettings.php 内で、この拡張機能の名前を探してください。 特定のウィキにインストールされている拡張機能の完全な一覧は、そのウィキの Special:Version ページにあります。 |