Расширение:WikidataPageBanner

From mediawiki.org
This page is a translated version of the page Extension:WikidataPageBanner and the translation is 32% complete.
Outdated translations are marked like this.
Справка по расширениям MediaWiki
WikidataPageBanner
Статус релиза: стабильно
Реализация Функция парсера
Описание Добавляет широкие баннеры вверху страниц в указанных пространствах имён
Автор(ы) (under the mentorship of User:Jdlrobson and User:Syced). (Sumitобсуждение)
Последняя версия 0.0.3
MediaWiki >= 1.42
PHP 5.4+
Composer mediawiki/wikidata-page-banner
Лицензия GNU General Public License 2.0 или позднее
Скачать
README
  • $wgWPBDisabledNamespaces
  • $wgWPBEnableHeadingOverride
  • $wgWPBSkinDisabled
  • $wgWPBBannerProperty
  • $wgWPBEnablePageImagesBanners
  • $wgWPBStandardSizes
  • $wgWPBImage
  • $wgWPBDisplaySubtitleAfterBannerSkins
  • $wgWPBNamespaces
  • $wgWPBEnableMainPage
  • $wgWPBEnableDefaultBanner
pagebanner
Ежеквартальные загрузки 42 (Ranked 97th)
Переведите расширение WikidataPageBanner, если оно доступно на translatewiki.net
Проблемы Открытые задачи · Сообщить об ошибке

Расширение WikidataPageBanner добавляет широкие баннеры вверху страниц в указанных пространствах имён вики. The image filenames can be stored on Wikidata (with P948) instead of in the local wiki.

Широкие баннеры очень часто используются в проектах Wikivoyage. Это расширение главным образом вдохновлено Шаблоном:Pagebanner в Wikivoyage.

Установка

  • Скачайте и распакуйте файл(ы) в папку с названием WikidataPageBanner в вашей папке extensions/.
    Вместо этого разработчикам и соавторам кода следует установить расширение из Git, используя:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/WikidataPageBanner
  • Добавьте следующий код в конце вашего файла LocalSettings.php :
    wfLoadExtension( 'WikidataPageBanner' );
    
  • Yes Готово – Перейдите на страницу Special:Version на своей вики, чтобы удостовериться в том, что расширение успешно установлено.

Использование

There are a few different ways to set a banner image on a page:

  1. Чтобы использовать File:Image_name.jpg как собственное изображение баннера, используйте: {{PAGEBANNER:Image_name.jpg}}
  2. Расширение может автоматически добавить такой баннер на все страницы в указанных пространствах имён, если задана конфигурационная переменная $wgWPBImage.
  3. Если вики связана с Викиданными, она также может получать оттуда баннеры. In this case, the Template:PAGEBANNER must exist (but it can be empty). В Wikivoyage есть пример сложного Template:PAGEBANNER с логикой рендеринга и дополнительными зависимостями шаблона.

Параметры для функции {{PAGEBANNER}}

Следующие параметры поддерживаются функцией парсера {{PAGEBANNER}}:

  • |pgname= — Добавляет пользовательский заголовок к баннеру.
  • |icon-*=To add custom icons, add the parameter |icon-<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=Use |tooltip=image-caption to show image description on hovering over image.
  • |toc=Use |toc=yes to enable a Table Of Contents within banner.
  • |bottomtoc=Use |bottomtoc=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 section #Styling below.
  • |extraClass=Use |extraClass=<css-class names> (separated by spaces) to add additional classes to banners which can be used to customize it using styles in MediaWiki:Common.css
  • |origin=See section #origin 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'

Banner coordinate system.

Используйте этот параметр, чтобы определить предполагаемую область фокусировки изображения. Это используется, чтобы обрезать баннер соответствующим образом на маленьких экранах. Значение параметра должно состоять из координат x и y, разделенных запятой. Каждая координата представляет расстояние от центра изображения в виде значения от -1 до 1. Например, |origin=1,1 - верхний правый угол, а |origin=-1,1 - нижний правый угол. См. изображение справа для графической демонстрации координат.

Обратите внимание, что в настоящее время реализован параметр источника, предназначенный для изображений, которые намного больше целевого баннера (например, панорамы или портретные фотографии). Он не будет перемещать баннеры там, где изменение положения приводит к пустому пробелу в пространстве баннера. Например, если баннер отображается с шириной 320px и высотой 180px, изображение, которое также имеет размеры 320px и 180px, не может быть перемещено вообще; изображение шириной 600 пикселей и высотой 180 пикселей можно перемещать по горизонтали, а изображение шириной 320 пикселей и высотой 1000 пикселей можно перемещать по вертикали.

Переменные конфигурации

$wgWPBImage используется для установки изображения баннера по умолчанию. Добавить название изображения без префикса пространства имён 'Файл:'. Если вики не нужны баннеры по умолчанию, не редактируйте это поле.

$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 Расширение: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.