Extension:Highlight Links in Category

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:Highlight Links in Category and the translation is 22% complete.

Other languages:
English • ‎Türkçe • ‎日本語
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
Highlight Links in Category
リリースの状態: 安定
Highlightlinksincategory.png
実装 ユーザー インターフェイス, MyWiki
説明 Adds a CSS class to links pointing to members of a category
作者 Brent Laabs (BrentLaabstalk)
最新バージョン 0.9.0 (2016-03-21)
MediaWiki 1.25+
データベースの変更 いいえ
ライセンス MIT ライセンス
ダウンロード download
readme
repository
https://allthetropes.org/
$wgHighlightLinksInCategory
translatewiki.net で翻訳を利用できる場合は、Highlight Links in Category 拡張機能の翻訳にご協力ください
使用状況とバージョン マトリクスを確認してください。

Highlight Links in Category is an extension that adds a CSS class to links pointing to members of a category.

For reporting an issue or a bug, please use Miraheze Phabricator.

インストール

  • ダウンロードして、ファイルを extensions/ フォルダー内の HighlightLinksInCategory という名前のディレクトリ内に配置します。
  • 以下のコードを LocalSettings.php の末尾に追加します:
    wfLoadExtension( 'HighlightLinksInCategory' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

Configuration parameters

$wgHighlightLinksInCategory
This global is an array that configures which categories get an added CSS class. The keys are the Category names, which must include underscores instead of spaces. Do not include the Category: namespace. The value for each key is the CSS class you would like to add to that category. For example:
    $wgHighlightLinksInCategory = array(
        "Disambiguation_pages" => 'disambig',
        "Templates" => 'templates',
    );

If you want add more than one class, separate the class names with spaces, like

    $wgHighlightLinksInCategory = array( "My_Cat" => "class1 class2 class3" );

You can add as many of these as you want, but from a UX perspective it's probably not awesome to add 500 different style links.

If $wgHighlightLinksInCategory is not set or empty, this extension will do nothing. If you're running a wiki farm and need to turn it off on some wikis, set $wgHighlightLinksInCategory = null; using false could lead to incorrect behavior.

Styling

Simply add the styles you need for these links to MediaWiki:Common.css on your wiki. For example:

    a.disambig {
        color: rebeccapurple
    }
    a.templates {
        font-weight: bold;
        background-color: #efe;
    }

If you want one category to override another, you'll have to specify it with CSS.

    a.templates.disambig {
        font-weight: normal;
        background-color: transparent;
        color: rebeccapurple;
    }

Or alternatively, you could have defined the original a.templates rule as a.templates:not(.disambig) instead.

There's also the link icon approach:

    a.superlink {
        background-image: url(super.png);
        padding-left: 16px;
    }

User Toggles

An easy way to set up toggling this highlighting on or off is to make a Gadget with CSS in it. Yes, this is a personalization extension that outsources the personalization part to other extensions; I can still sleep at night.

動作の仕組み

Right after MediaWiki determines which linked pages exist (to make redlinks), it runs the GetLinkColours hook (see LinkHolderArray.php). As we have a list of all of the page ids which are linked on that page, we can run one database query to see which of these links are in the set of categories we want to highlight. Because the query only happens on an index of the categorylinks table, it's reasonably fast. Then CSS classes are assigned based on the result, using the configuration values the user sets in $wgHighlightLinksInCategory.

Explaining how CSS works is outside the scope of this document.

既知の問題点

  • CSS styles are not added in Flow, because it doesn't appear to call the GetLinkColors hook there.

関連項目