Extension:RSS

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page Extension:RSS and the translation is 40% complete.
Other languages:
English • ‎Türkçe • ‎português do Brasil • ‎日本語
ショートカット: RSS
MediaWiki 拡張機能マニュアル
OOjs UI icon advanced.svg
RSS Feed-icon.svg
リリースの状態: 安定
300px
実装 タグ
説明 Display RSS feeds on a wiki page
作者 K. Elliott-McCrea, mutante, D. Kinzler, Rdb, Mafs, Alxndr, T. Gries, C. Reigrut, K001, J. De Dauw, J. Phoenix, M.A. Hershberger
最新バージョン 2.25.1 (2017-04-21)
MediaWiki 1.23+
PHP 5.4+
ライセンス GNU 一般公衆利用許諾書 2.0 以降
ダウンロード
README
RELEASE-NOTES
https://spookyverse.de/wiki/Vorlage:TV-Termine and https://spookyverse.de/wiki/Vorlage:RSS_News (see main the wikis' mains page where the rss feeds are displayed)
  • $wgRSSUserAgent
  • $wgRSSDateDefaultFormat
  • $wgRSSNamespaces
  • $wgRSSUrlNumberOfAllowedRedirects
  • $wgRSSFetchTimeout
  • $wgRSSItemMaxLength
  • $wgRSSAllowImageTag
  • $wgRSSProxy
  • $wgRSSCacheAge
  • $wgRSSAllowLinkTag
  • $wgRSSCacheCompare
  • $wgRSSUrlWhitelist
translatewiki.net で翻訳を利用できる場合は、RSS 拡張機能の翻訳にご協力ください
使用状況とバージョン マトリクスを確認してください。
問題点 未解決のタスク · バグを報告

The RSS extension renders ("displays") one or more RSS feeds on a wiki page in a standard or user-definable format. Since version 2.00, the extension is compatible with Extension:WikiArticleFeeds which generates RSS or ATOM feeds from MediaWiki pages (authoring tool).

ダウンロード

拡張機能は、Git から直接取得できる場合があります [?]:

  • コードを参照
  • 一部の拡張機能には安定版リリースのタグがあります。
    • タグを参照
    • タグを選択します
    • 「スナップショット」をクリックします
  • 各ブランチは過去の MediaWiki リリースと関連付けられています。 最新のアルファ バージョンを含む「master」ブランチもあります (MediaWiki のアルファ バージョンが必要な場合用)。

スナップショットを展開して、MediaWiki インストレーション内の extensions/RSS/ ディレクトリに配置します。

git に馴染みがあり、かつサーバーにシェルでアクセスできる場合は、拡張機能を以下のようにして取得することもできます:

cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/RSS.git

インストール

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

MediaWiki 1.27 以前を稼働させている利用者へ:

上記の手順では、wfLoadExtension() を使用してこの拡張機能をインストールする新しい方法を記載しています。 この拡張機能をこれらの過去のバージョン (MediaWiki 1.27 以前) にインストールする必要がある場合は、wfLoadExtension( 'RSS' ); の代わりに以下を使用する必要があります:

require_once "$IP/extensions/RSS/RSS.php";

使用法

Use one section between <rss>-tags for each feed. The rss element may contain parameters if you provide them as attributes to the rss element:

Parameters in the RSS tag
optional tag attributes コメント
template="name" 'name' (default: rss-item) is the name of a page in the MediaWiki template namespace (default: MediaWiki:Rss-item), which comprises the name of another template (default: MediaWiki:Rss-feed since version 1.90; Template:RSSPost before version 1.90) and a list of named variables of RSS Feed channel subelements (item), these values then being passed to this other template to finally format the RSS items.

Note that when a template is specified here, the extension doesn't pass to it the name of a - default - formatting template. The template specified here needs to take care of that by hard-coding the name of the other template. I.e the default template process is completely aborted.

templatename="Pagename" or

templatename="Namespace:Pagename"

'Pagename' is the name of a template page which is used in the default template MediaWiki:Rss-item (defining the channel subelements) to finally format the RSS items; the template can be in the template namespace (first example denotes a page Template:Pagename) or any other namespace (second example uses the full specified form Namespace:Pagename)
max="n" show at most n channel subelements (items)
highlight="term1 term2 ..." highlight terms in different colours
filter="term1 term2 ..." show only RSS items with at least one of the terms
filterout="term1 term2 ..." do not show any RSS item containing any of these terms
reverse display the RSS items in reverse order (since Version 2.25 seems to be a bug regarding the reverse sorting which may be worked around like this:

in \extensions\RSS\RSSParser.php edit line 62: $this->reversed = true; -> this needs to be set to false if entries should be sorted as dates desc (newest first) when the reverse variable is used in <rss>)

date="(Y-m-d H:i:s)" date format string[1]
(since r111347)
item-max-length="1000" limits the number of character in item descriptions (since r111350)

This is not correctly working in v2.18 see タスク T32377.

Tracking category

All pages in a wiki which use the RSS extension are automatically added to the RSS tracking Category:Pages_with_RSS_feeds.

Templates for channel subelements and styling the RSS Feed

A manual setup is not necessarily required. You can skip this complicated documentation section.
One template name has been changed: MediaWiki:Rss-feed since version 1.90; Template:RSSPost before version 1.90.[2]

The RSS extension renders feeds on wiki page by using two templates in the MediaWiki system namespace, which can be changed, or which wiki admins can redirected to user-editable namespaces. The mechanism is perhaps not easy to understand, but after its installation, the extension starts with a useful set of templates; a manual set-up is not required.

If a template is not specified, then the one in MediaWiki:Rss-item is used and determines only which RSS feed channel subelements (items) are used. The other template MediaWiki:Rss-feed determines how the complete feed is shown on wiki pages i.e. how and which channel items are shown are listed.

This is the template MediaWiki:Rss-item (since version 1.90) which determines which item elements are used[2]

{{ MediaWiki:Rss-feed \
| title = {{{title}}} \
| link = {{{link}}} \
| date = {{{date}}} \
| author = {{{author}}} \
| description = {{{description}}} }}

The selected items are passed to the other template MediaWiki:Rss-feed (since version 1.90)[2] which determines how the RSS Feed is rendered on the wiki pages. It iterates over each <item> of the RSS feed and substitutes the value of each element found there, e.g. <title>, <link>, <date>, <author>, etc.

Basic MediaWiki:Rss-feed template:

; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>'''
: {{{description}}}
: {{{author}}} {{{date}}}<!-- don't use newline here -->

An alternative improved MediaWiki:Rss-feed template requires the Extension:ParserFunctions:

<!-- The second is an improved version which requires Extension:ParserFunctions --> \
; '''<span class='plainlinks'>[{{{link}}} {{{title}}}]</span>''' \
{{#if: {{{description|}}} \
|: {{{description}}}}}{{#if: {{{author|}}} \
| {{#if: {{{date|}}} |: — {{{author}}} {{{date}}}}} \
| {{#if: {{{author|}}}|: — {{{author}}}}} {{#if: {{{date|}}}|:{{{date}}}}}|}}<!-- don't use newline here -->

Example

The following code renders the four recent items of the wikimedia blog feed on the present page and highlights some terms. The layout depends on the content of feed template MediaWiki:Rss-feed and also of the item template MediaWiki:Rss-item as mentioned above:

<rss max=4 highlight="community wiki foundation">https://wikimediafoundation.org/news/feed/</rss>
The World Health Organization and Wikimedia Foundation expand access to trusted information about COVID-19 on Wikipedia
Geneva, Switzerland, 22 October 2020 — The World Health Organization (WHO) and the Wikimedia Foundation, the nonprofit that administers Wikipedia, announced today a collaboration to expand the public…
Wikimedia Foundation 2020-10-22 13:01:35
Celebrating the people who go above and beyond to build free knowledge: Meet our 2020 Wikimedian of the Year
When I first created Wikipedia back in 2001, the internet was a very different place. Only seven percent of people worldwide had a broadband connection, and more people spent time building personal w…
Jimmy Wales 2020-10-15 16:30:00
Amazon donates $1 million gift to the Wikimedia Endowment to sustain free knowledge
For the third year in a row, Amazon has renewed its commitment to the Wikimedia Endowment, a permanent fund dedicated to ensuring the long-term future of Wikipedia and the other Wikimedia free knowle…
Wikimedia Foundation 2020-09-25 20:00:37
China blocks Wikimedia Foundation’s accreditation to World Intellectual Property Organization
China yesterday blocked the Wikimedia Foundation’s application for observer status at the World Intellectual Property Organization (WIPO), the United Nations (UN) organization that develops internati…
Wikimedia Foundation 2020-09-24 09:00:59

Configuration settings

Add any one of the following settings you want to customize to your LocalSettings.php.

Configuration settings in RSS.php
parameter default comment
$wgRSSCacheAge 3600 (one hour) Store entries in memcached for this many seconds
$wgRSSCacheCompare false Check cached content, if available, against remote. $wgRSSCacheCompare should be set to false or a timeout in seconds which is less than $wgRSSCacheAge after which a comparison will be made.
$wgRSSFetchTimeout 15 (since version 1.94)

5 (until version 1.93)

read timeout in seconds
$wgRSSUserAgent 'MediaWikiRSS/<Version> (+https://www.mediawiki.org/wiki/Extension:RSS) / MediaWiki RSS extension' User-Agent to use for fetching feeds
$wgRSSNamespaces null Ignore the RSS tag in all but the namespaces listed here

null means the <rss> tag can be used anywhere

$wgRSSUrlWhitelist


(since version 1.94)

array() (deny any URL = no whitelisted URLs) URL whitelist of RSS Feeds, the whitelist is empty by default and no URLs are allowed. If there are items in the array, and the used feed URL isn't in the array, it will not be allowed.
Use array( "*" ) if you as admin want to allow anyone to use any feed Url. In case your whitelist entries are ignored, please use square bracktes for the array instead, e.g. $wgRSSUrlWhitelist = [ 'URL1', 'URL2', 'URL3', ];
$wgRSSAllowedFeeds


(until version 1.93)

array() (allow any URL ) DEPRECATED: URL whitelist of RSS Feeds: if there are items in the array, and the used URL isn't in the array, it will not be allowed (originally proposed in bug 27768)
$wgRSSUrlNumberOfAllowedRedirects


(since version 2.10)

0 (no redirects are allowed) Maximum number of redirects to follow (defaults to 0). This should only be used when the target URLs are trusted to avoid attacks on intranet services accessible by HTTP.
$wgRSSProxy false Optional proxy server url and port number to be used for fetching feeds.

false: no proxy used

If you need a proxy for certain urls and not for others:
Example for disabling proxy use for certain urls in RSSParser::fetchRemote how to use a regular expression for a conditional proxy switching.

$wgRSSDateDefaultFormat "Y-m-d H:i:s" default date format[1] for RSS publication dates (since r111347)
$wgRSSItemMaxLength

(deactivated in version 2.12 r113297; will be activated later.)[3]

200 default maximum length of item descriptions (since r111350)
$wgRSSAllowLinkTag false to allow active links in feed items
$wgRSSAllowImageTag false If you allow to see images in feed items. Do not confuse this parameter with $wgAllowImageTag of MediaWiki core, Display of images causes privacy problems, because the image is fetched in the browser context, so the (image-) server log will contain data of the requesting browser, see the discussion here. Note that since 2013 due to the MediaWiki sanitizer, image tags which have the form <img src="blah"/> are not parsed correctly by the MediaWiki core sanitizer and are not displayed irrespective of this setting (see タスク T48443).

If you want the image to show, set this to true in LocalSettings.php and in \extensions\RSS\RSSParser.php remove this part at lines 485

if ( isset( $wgRSSAllowImageTag ) && $wgRSSAllowImageTag ) {
            $extraInclude[] = "img";
        } else {
            $extraExclude[] = "img";
        }

Technical history and attributions

RSS extension is a heavily modified version of the engines RSS by Mafs, RSS by Rdb78, RSS by Duesentrieb, and RSSFeed by Mutante.

References

  1. 1.0 1.1 https://php.net/date
  2. 2.0 2.1 2.2 Former versions before 1.90 used the name Template:RSSPost in the template MediaWiki:Rss-item which thus had the default value
    {{ RSSPost | title = {{{title}}} | link = {{{link}}} | date = {{{date}}} | author = {{{author}}} }}
  3. bug30377

関連項目